0001
0002
0003
0004
0005
0006
0007 #ifndef _CORESIGHT_CORESIGHT_CTI_H
0008 #define _CORESIGHT_CORESIGHT_CTI_H
0009
0010 #include <linux/coresight.h>
0011 #include <linux/device.h>
0012 #include <linux/fwnode.h>
0013 #include <linux/list.h>
0014 #include <linux/spinlock.h>
0015 #include <linux/sysfs.h>
0016 #include <linux/types.h>
0017
0018 #include "coresight-priv.h"
0019
0020
0021
0022
0023
0024
0025
0026
0027 #define CTICONTROL 0x000
0028 #define CTIINTACK 0x010
0029 #define CTIAPPSET 0x014
0030 #define CTIAPPCLEAR 0x018
0031 #define CTIAPPPULSE 0x01C
0032 #define CTIINEN(n) (0x020 + (4 * n))
0033 #define CTIOUTEN(n) (0x0A0 + (4 * n))
0034 #define CTITRIGINSTATUS 0x130
0035 #define CTITRIGOUTSTATUS 0x134
0036 #define CTICHINSTATUS 0x138
0037 #define CTICHOUTSTATUS 0x13C
0038 #define CTIGATE 0x140
0039 #define ASICCTL 0x144
0040
0041 #define ITCHINACK 0xEDC
0042 #define ITTRIGINACK 0xEE0
0043 #define ITCHOUT 0xEE4
0044 #define ITTRIGOUT 0xEE8
0045 #define ITCHOUTACK 0xEEC
0046 #define ITTRIGOUTACK 0xEF0
0047 #define ITCHIN 0xEF4
0048 #define ITTRIGIN 0xEF8
0049
0050 #define CTIDEVAFF0 0xFA8
0051 #define CTIDEVAFF1 0xFAC
0052
0053
0054
0055
0056
0057
0058
0059 #define CTIINOUTEN_MAX 32
0060
0061
0062
0063
0064
0065
0066
0067
0068 struct cti_trig_grp {
0069 int nr_sigs;
0070 u32 used_mask;
0071 int sig_types[];
0072 };
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 struct cti_trig_con {
0087 struct cti_trig_grp *con_in;
0088 struct cti_trig_grp *con_out;
0089 struct coresight_device *con_dev;
0090 const char *con_dev_name;
0091 struct list_head node;
0092 struct attribute **con_attrs;
0093 struct attribute_group *attr_group;
0094 };
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 struct cti_device {
0108 int nr_trig_con;
0109 u32 ctm_id;
0110 struct list_head trig_cons;
0111 int cpu;
0112 const struct attribute_group **con_groups;
0113 };
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 struct cti_config {
0139
0140 int nr_ctm_channels;
0141 int nr_trig_max;
0142
0143
0144 atomic_t enable_req_count;
0145 bool hw_enabled;
0146 bool hw_powered;
0147
0148
0149 u32 trig_in_use;
0150 u32 trig_out_use;
0151 u32 trig_out_filter;
0152 bool trig_filter_enable;
0153 u8 xtrig_rchan_sel;
0154
0155
0156 u32 ctiappset;
0157 u8 ctiinout_sel;
0158 u32 ctiinen[CTIINOUTEN_MAX];
0159 u32 ctiouten[CTIINOUTEN_MAX];
0160 u32 ctigate;
0161 u32 asicctl;
0162 };
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174 struct cti_drvdata {
0175 void __iomem *base;
0176 struct coresight_device *csdev;
0177 struct cti_device ctidev;
0178 spinlock_t spinlock;
0179 struct cti_config config;
0180 struct list_head node;
0181 void (*csdev_release)(struct device *dev);
0182 };
0183
0184
0185
0186
0187 enum cti_chan_op {
0188 CTI_CHAN_ATTACH,
0189 CTI_CHAN_DETACH,
0190 };
0191
0192 enum cti_trig_dir {
0193 CTI_TRIG_IN,
0194 CTI_TRIG_OUT,
0195 };
0196
0197 enum cti_chan_gate_op {
0198 CTI_GATE_CHAN_ENABLE,
0199 CTI_GATE_CHAN_DISABLE,
0200 };
0201
0202 enum cti_chan_set_op {
0203 CTI_CHAN_SET,
0204 CTI_CHAN_CLR,
0205 CTI_CHAN_PULSE,
0206 };
0207
0208
0209 extern const struct attribute_group *coresight_cti_groups[];
0210 int cti_add_default_connection(struct device *dev,
0211 struct cti_drvdata *drvdata);
0212 int cti_add_connection_entry(struct device *dev, struct cti_drvdata *drvdata,
0213 struct cti_trig_con *tc,
0214 struct coresight_device *csdev,
0215 const char *assoc_dev_name);
0216 struct cti_trig_con *cti_allocate_trig_con(struct device *dev, int in_sigs,
0217 int out_sigs);
0218 int cti_enable(struct coresight_device *csdev);
0219 int cti_disable(struct coresight_device *csdev);
0220 void cti_write_all_hw_regs(struct cti_drvdata *drvdata);
0221 void cti_write_intack(struct device *dev, u32 ackval);
0222 void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value);
0223 int cti_channel_trig_op(struct device *dev, enum cti_chan_op op,
0224 enum cti_trig_dir direction, u32 channel_idx,
0225 u32 trigger_idx);
0226 int cti_channel_gate_op(struct device *dev, enum cti_chan_gate_op op,
0227 u32 channel_idx);
0228 int cti_channel_setop(struct device *dev, enum cti_chan_set_op op,
0229 u32 channel_idx);
0230 int cti_create_cons_sysfs(struct device *dev, struct cti_drvdata *drvdata);
0231 struct coresight_platform_data *
0232 coresight_cti_get_platform_data(struct device *dev);
0233 const char *cti_plat_get_node_name(struct fwnode_handle *fwnode);
0234
0235
0236 static inline bool cti_active(struct cti_config *cfg)
0237 {
0238 return cfg->hw_powered && cfg->hw_enabled;
0239 }
0240
0241 #endif