forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/hwtracing/coresight/coresight-priv.h
....@@ -6,6 +6,7 @@
66 #ifndef _CORESIGHT_PRIV_H
77 #define _CORESIGHT_PRIV_H
88
9
+#include <linux/amba/bus.h>
910 #include <linux/bitops.h>
1011 #include <linux/io.h>
1112 #include <linux/coresight.h>
....@@ -21,6 +22,7 @@
2122 #define CORESIGHT_CLAIMCLR 0xfa4
2223 #define CORESIGHT_LAR 0xfb0
2324 #define CORESIGHT_LSR 0xfb4
25
+#define CORESIGHT_DEVARCH 0xfbc
2426 #define CORESIGHT_AUTHSTATUS 0xfb8
2527 #define CORESIGHT_DEVID 0xfc8
2628 #define CORESIGHT_DEVTYPE 0xfcc
....@@ -64,8 +66,8 @@
6466 #define coresight_simple_reg64(type, name, lo_off, hi_off) \
6567 __coresight_simple_func(type, NULL, name, lo_off, hi_off)
6668
67
-extern const u32 barrier_pkt[4];
68
-#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(barrier_pkt))
69
+extern const u32 coresight_barrier_pkt[4];
70
+#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt))
6971
7072 enum etm_addr_type {
7173 ETM_ADDR_TYPE_NONE,
....@@ -85,6 +87,7 @@
8587 * struct cs_buffer - keep track of a recording session' specifics
8688 * @cur: index of the current buffer
8789 * @nr_pages: max number of pages granted to us
90
+ * @pid: PID this cs_buffer belongs to
8891 * @offset: offset within the current buffer
8992 * @data_size: how much we collected in this run
9093 * @snapshot: is this run in snapshot mode
....@@ -93,6 +96,7 @@
9396 struct cs_buffers {
9497 unsigned int cur;
9598 unsigned int nr_pages;
99
+ pid_t pid;
96100 unsigned long offset;
97101 local_t data_size;
98102 bool snapshot;
....@@ -102,9 +106,8 @@
102106 static inline void coresight_insert_barrier_packet(void *buf)
103107 {
104108 if (buf)
105
- memcpy(buf, barrier_pkt, CORESIGHT_BARRIER_PKT_SIZE);
109
+ memcpy(buf, coresight_barrier_pkt, CORESIGHT_BARRIER_PKT_SIZE);
106110 }
107
-
108111
109112 static inline void CS_LOCK(void __iomem *addr)
110113 {
....@@ -146,13 +149,25 @@
146149 void coresight_disable_path(struct list_head *path);
147150 int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data);
148151 struct coresight_device *coresight_get_sink(struct list_head *path);
149
-struct coresight_device *coresight_get_enabled_sink(bool reset);
152
+struct coresight_device *
153
+coresight_get_enabled_sink(struct coresight_device *source);
150154 struct coresight_device *coresight_get_sink_by_id(u32 id);
155
+struct coresight_device *
156
+coresight_find_default_sink(struct coresight_device *csdev);
151157 struct list_head *coresight_build_path(struct coresight_device *csdev,
152158 struct coresight_device *sink);
153159 void coresight_release_path(struct list_head *path);
160
+int coresight_add_sysfs_link(struct coresight_sysfs_link *info);
161
+void coresight_remove_sysfs_link(struct coresight_sysfs_link *info);
162
+int coresight_create_conns_sysfs_group(struct coresight_device *csdev);
163
+void coresight_remove_conns_sysfs_group(struct coresight_device *csdev);
164
+int coresight_make_links(struct coresight_device *orig,
165
+ struct coresight_connection *conn,
166
+ struct coresight_device *target);
167
+void coresight_remove_links(struct coresight_device *orig,
168
+ struct coresight_connection *conn);
154169
155
-#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
170
+#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X)
156171 extern int etm_readl_cp14(u32 off, unsigned int *val);
157172 extern int etm_writel_cp14(u32 off, u32 val);
158173 #else
....@@ -160,4 +175,64 @@
160175 static inline int etm_writel_cp14(u32 off, u32 val) { return 0; }
161176 #endif
162177
178
+struct cti_assoc_op {
179
+ void (*add)(struct coresight_device *csdev);
180
+ void (*remove)(struct coresight_device *csdev);
181
+};
182
+
183
+extern void coresight_set_cti_ops(const struct cti_assoc_op *cti_op);
184
+extern void coresight_remove_cti_ops(void);
185
+
186
+/*
187
+ * Macros and inline functions to handle CoreSight UCI data and driver
188
+ * private data in AMBA ID table entries, and extract data values.
189
+ */
190
+
191
+/* coresight AMBA ID, no UCI, no driver data: id table entry */
192
+#define CS_AMBA_ID(pid) \
193
+ { \
194
+ .id = pid, \
195
+ .mask = 0x000fffff, \
196
+ }
197
+
198
+/* coresight AMBA ID, UCI with driver data only: id table entry. */
199
+#define CS_AMBA_ID_DATA(pid, dval) \
200
+ { \
201
+ .id = pid, \
202
+ .mask = 0x000fffff, \
203
+ .data = (void *)&(struct amba_cs_uci_id) \
204
+ { \
205
+ .data = (void *)dval, \
206
+ } \
207
+ }
208
+
209
+/* coresight AMBA ID, full UCI structure: id table entry. */
210
+#define CS_AMBA_UCI_ID(pid, uci_ptr) \
211
+ { \
212
+ .id = pid, \
213
+ .mask = 0x000fffff, \
214
+ .data = (void *)uci_ptr \
215
+ }
216
+
217
+/* extract the data value from a UCI structure given amba_id pointer. */
218
+static inline void *coresight_get_uci_data(const struct amba_id *id)
219
+{
220
+ struct amba_cs_uci_id *uci_id = id->data;
221
+
222
+ if (!uci_id)
223
+ return NULL;
224
+
225
+ return uci_id->data;
226
+}
227
+
228
+void coresight_release_platform_data(struct coresight_device *csdev,
229
+ struct coresight_platform_data *pdata);
230
+struct coresight_device *
231
+coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode);
232
+void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev,
233
+ struct coresight_device *ect_csdev);
234
+
235
+void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev);
236
+struct coresight_device *coresight_get_percpu_sink(int cpu);
237
+
163238 #endif