summaryrefstree
path: root/kernel/drivers/vision/npu/npu-profile.h
blob: a4cc48ec32bc4555ce71da2f734f373679ac7fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Samsung Exynos SoC series NPU driver
 *
 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
 *              http://www.samsung.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef _NPU_PROFILE_H_
#define _NPU_PROFILE_H_

#include <npu-common.h>
#include <linux/mutex.h>
#include <linux/wait.h>
#include "npu-util-statekeeper.h"

#define PPMU_NUM 5

#define NPU_PROFILE_UNIT_NUM	10	/* 0: Firmware, 1: D.Drv */
#define NPU_PROFILE_POINT_NUM	4096*1024

/* Device driver specific */
#define PROFILE_UID		0xFFFF0000	/* Special UID for profile */
#define PROFILE_CMD_POST_RETRY_INTERVAL	100
#define PROFILE_CMD_POST_RETRY_CNT	10
#define PROFILE_HW_RESP_TIMEOUT		1000

enum probe_id {
	/*
	 * 0(0x00) ~ 31 : Processing
	 * .uid = UID
	 * .frame_id = frame ID
	 * .param[0] = direction (EQ and DQ only)
	 * .param[1] = request ID (between SCHEDULED ~ DONE only)
	 * .param[2] = reserved
	 * .param[3] = reserved
	 * .param[4] = reserved
	 */
	PROBE_ID_DD_FRAME_EQ = 0,
	PROBE_ID_DD_FRAME_SCHEDULED,
	PROBE_ID_DD_FRAME_PROCESS,
	PROBE_ID_DD_FRAME_COMPLETED,
	PROBE_ID_DD_FRAME_DONE,
	PROBE_ID_DD_FRAME_DQ,
	PROBE_ID_DD_FRAME_VS4L_QBUF_ENTER,
	PROBE_ID_DD_FRAME_VS4L_DQBUF_RET,
	/*
	 * 32(0x20) ~ 63 : Network mgmt.
	 * .uid = UID
	 * .frame_id = N/A
	 * .param[0] = Command code (See nw_cmd_e definition in npu-commoh.h)
	 * .param[1] = request ID (between SCHEDULED ~ DONE only)
	 * .param[2] = reserved
	 * .param[3] = reserved
	 * .param[4] = reserved
	 */
	PROBE_ID_DD_NW_RECEIVED = 32,
	PROBE_ID_DD_NW_SCHEDULED,
	PROBE_ID_DD_NW_PROCESS,
	PROBE_ID_DD_NW_COMPLETED,
	PROBE_ID_DD_NW_DONE,
	PROBE_ID_DD_NW_NOTIFIED,
	PROBE_ID_DD_NW_VS4L_ENTER,
	PROBE_ID_DD_NW_VS4L_RET,

	PROBE_ID_MAX = 99
};

enum profile_unit_id {
	PROFILE_UNIT_FIRMWARE = 0,
	PROFILE_UNIT_DEVICE_DRIVER,
	PROFILE_UNIT_END,
};

struct probe_point {
	u32 id;
	u32 timestamp;
	u32 session_id; /* session id is same with object id of firmware */
	u32 frame_id;
	u32 param[5];
	/*
	 * parameter represents various meaning depend on id
	 * espeically GP, SG
	 * param[0] : group id
	 * param[1] : subgroup id
	 */
};

struct probe_meta {
	u32	profile_unit_id;
	u32	start_idx;
	u32	total_count;
	u32	valid_count;
};

struct npu_profile {
	u32			point_cnt;
	u32			rsvd0;
	struct probe_meta	meta[NPU_PROFILE_UNIT_NUM];
	struct probe_point	point[NPU_PROFILE_POINT_NUM];
};


struct npu_profile_control {
	struct npu_profile		*profile_data;	/* Pointer to buf's vaddr */
	struct npu_memory_buffer        buf;		/* Shared buffer handle to struct profile_data object */
	struct npu_statekeeper          statekeeper;
	int                             unit_num;       /* Not used yet */
	int                             point_num;      /* Not used yet */
	atomic_t			next_probe_point_idx;	/* Index of npu_profile.point[] to be used on next profile data */
	void __iomem			*pwm;		/* PWM SFR */
	struct mutex			lock;
	wait_queue_head_t		wq;
	int				result_code;
	atomic_t			result_available;
};

struct npu_system;
int npu_profile_probe(struct npu_system *system);
int npu_profile_open(struct npu_system *system);
int npu_profile_close(struct npu_system *system);
int npu_profile_release(void);

void profile_point1(const u32 point_id, const u32 uid, const u32 frame_id, const u32 p0);
void profile_point3(
	const u32 point_id, const u32 uid, const u32 frame_id,
	const u32 p0, const u32 p1, const u32 p2);

#endif	/* _NPU_PROFILE_H_ */