1
2
3
4
5
6
7#ifndef _CORESIGHT_CORESIGHT_CTI_H
8#define _CORESIGHT_CORESIGHT_CTI_H
9
10#include <linux/coresight.h>
11#include <linux/device.h>
12#include <linux/fwnode.h>
13#include <linux/list.h>
14#include <linux/spinlock.h>
15#include <linux/sysfs.h>
16#include <linux/types.h>
17
18#include "coresight-priv.h"
19
20
21
22
23
24
25
26
27#define CTICONTROL 0x000
28#define CTIINTACK 0x010
29#define CTIAPPSET 0x014
30#define CTIAPPCLEAR 0x018
31#define CTIAPPPULSE 0x01C
32#define CTIINEN(n) (0x020 + (4 * n))
33#define CTIOUTEN(n) (0x0A0 + (4 * n))
34#define CTITRIGINSTATUS 0x130
35#define CTITRIGOUTSTATUS 0x134
36#define CTICHINSTATUS 0x138
37#define CTICHOUTSTATUS 0x13C
38#define CTIGATE 0x140
39#define ASICCTL 0x144
40
41#define ITCHINACK 0xEDC
42#define ITTRIGINACK 0xEE0
43#define ITCHOUT 0xEE4
44#define ITTRIGOUT 0xEE8
45#define ITCHOUTACK 0xEEC
46#define ITTRIGOUTACK 0xEF0
47#define ITCHIN 0xEF4
48#define ITTRIGIN 0xEF8
49
50#define CTIDEVAFF0 0xFA8
51#define CTIDEVAFF1 0xFAC
52
53
54
55
56
57
58
59#define CTIINOUTEN_MAX 32
60
61
62
63
64
65
66
67
68struct cti_trig_grp {
69 int nr_sigs;
70 u32 used_mask;
71 int sig_types[];
72};
73
74
75
76
77
78
79
80
81
82
83
84
85
86struct cti_trig_con {
87 struct cti_trig_grp *con_in;
88 struct cti_trig_grp *con_out;
89 struct coresight_device *con_dev;
90 const char *con_dev_name;
91 struct list_head node;
92 struct attribute **con_attrs;
93 struct attribute_group *attr_group;
94};
95
96
97
98
99
100
101
102
103
104
105
106
107struct cti_device {
108 int nr_trig_con;
109 u32 ctm_id;
110 struct list_head trig_cons;
111 int cpu;
112 const struct attribute_group **con_groups;
113};
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138struct cti_config {
139
140 int nr_ctm_channels;
141 int nr_trig_max;
142
143
144 atomic_t enable_req_count;
145 bool hw_enabled;
146 bool hw_powered;
147
148
149 u32 trig_in_use;
150 u32 trig_out_use;
151 u32 trig_out_filter;
152 bool trig_filter_enable;
153 u8 xtrig_rchan_sel;
154
155
156 u32 ctiappset;
157 u8 ctiinout_sel;
158 u32 ctiinen[CTIINOUTEN_MAX];
159 u32 ctiouten[CTIINOUTEN_MAX];
160 u32 ctigate;
161 u32 asicctl;
162};
163
164
165
166
167
168
169
170
171
172
173
174struct cti_drvdata {
175 void __iomem *base;
176 struct coresight_device *csdev;
177 struct cti_device ctidev;
178 spinlock_t spinlock;
179 struct cti_config config;
180 struct list_head node;
181 void (*csdev_release)(struct device *dev);
182};
183
184
185
186
187enum cti_chan_op {
188 CTI_CHAN_ATTACH,
189 CTI_CHAN_DETACH,
190};
191
192enum cti_trig_dir {
193 CTI_TRIG_IN,
194 CTI_TRIG_OUT,
195};
196
197enum cti_chan_gate_op {
198 CTI_GATE_CHAN_ENABLE,
199 CTI_GATE_CHAN_DISABLE,
200};
201
202enum cti_chan_set_op {
203 CTI_CHAN_SET,
204 CTI_CHAN_CLR,
205 CTI_CHAN_PULSE,
206};
207
208
209extern const struct attribute_group *coresight_cti_groups[];
210int cti_add_default_connection(struct device *dev,
211 struct cti_drvdata *drvdata);
212int cti_add_connection_entry(struct device *dev, struct cti_drvdata *drvdata,
213 struct cti_trig_con *tc,
214 struct coresight_device *csdev,
215 const char *assoc_dev_name);
216struct cti_trig_con *cti_allocate_trig_con(struct device *dev, int in_sigs,
217 int out_sigs);
218int cti_enable(struct coresight_device *csdev);
219int cti_disable(struct coresight_device *csdev);
220void cti_write_all_hw_regs(struct cti_drvdata *drvdata);
221void cti_write_intack(struct device *dev, u32 ackval);
222void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value);
223int cti_channel_trig_op(struct device *dev, enum cti_chan_op op,
224 enum cti_trig_dir direction, u32 channel_idx,
225 u32 trigger_idx);
226int cti_channel_gate_op(struct device *dev, enum cti_chan_gate_op op,
227 u32 channel_idx);
228int cti_channel_setop(struct device *dev, enum cti_chan_set_op op,
229 u32 channel_idx);
230int cti_create_cons_sysfs(struct device *dev, struct cti_drvdata *drvdata);
231struct coresight_platform_data *
232coresight_cti_get_platform_data(struct device *dev);
233const char *cti_plat_get_node_name(struct fwnode_handle *fwnode);
234
235
236static inline bool cti_active(struct cti_config *cfg)
237{
238 return cfg->hw_powered && cfg->hw_enabled;
239}
240
241#endif
242