0001
0002 #ifndef __ASMARM_CTI_H
0003 #define __ASMARM_CTI_H
0004
0005 #include <asm/io.h>
0006 #include <asm/hardware/coresight.h>
0007
0008
0009
0010
0011 #define CTICONTROL 0x000
0012 #define CTISTATUS 0x004
0013 #define CTILOCK 0x008
0014 #define CTIPROTECTION 0x00C
0015 #define CTIINTACK 0x010
0016 #define CTIAPPSET 0x014
0017 #define CTIAPPCLEAR 0x018
0018 #define CTIAPPPULSE 0x01c
0019 #define CTIINEN 0x020
0020 #define CTIOUTEN 0x0A0
0021 #define CTITRIGINSTATUS 0x130
0022 #define CTITRIGOUTSTATUS 0x134
0023 #define CTICHINSTATUS 0x138
0024 #define CTICHOUTSTATUS 0x13c
0025 #define CTIPERIPHID0 0xFE0
0026 #define CTIPERIPHID1 0xFE4
0027 #define CTIPERIPHID2 0xFE8
0028 #define CTIPERIPHID3 0xFEC
0029 #define CTIPCELLID0 0xFF0
0030 #define CTIPCELLID1 0xFF4
0031 #define CTIPCELLID2 0xFF8
0032 #define CTIPCELLID3 0xFFC
0033
0034
0035
0036
0037 #define LOCKACCESS 0xFB0
0038 #define LOCKSTATUS 0xFB4
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 struct cti {
0050 void __iomem *base;
0051 int irq;
0052 int trig_out_for_irq;
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066 static inline void cti_init(struct cti *cti,
0067 void __iomem *base, int irq, int trig_out)
0068 {
0069 cti->base = base;
0070 cti->irq = irq;
0071 cti->trig_out_for_irq = trig_out;
0072 }
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 static inline void cti_map_trigger(struct cti *cti,
0085 int trig_in, int trig_out, int chan)
0086 {
0087 void __iomem *base = cti->base;
0088 unsigned long val;
0089
0090 val = __raw_readl(base + CTIINEN + trig_in * 4);
0091 val |= BIT(chan);
0092 __raw_writel(val, base + CTIINEN + trig_in * 4);
0093
0094 val = __raw_readl(base + CTIOUTEN + trig_out * 4);
0095 val |= BIT(chan);
0096 __raw_writel(val, base + CTIOUTEN + trig_out * 4);
0097 }
0098
0099
0100
0101
0102
0103
0104
0105 static inline void cti_enable(struct cti *cti)
0106 {
0107 __raw_writel(0x1, cti->base + CTICONTROL);
0108 }
0109
0110
0111
0112
0113
0114
0115
0116 static inline void cti_disable(struct cti *cti)
0117 {
0118 __raw_writel(0, cti->base + CTICONTROL);
0119 }
0120
0121
0122
0123
0124
0125
0126
0127 static inline void cti_irq_ack(struct cti *cti)
0128 {
0129 void __iomem *base = cti->base;
0130 unsigned long val;
0131
0132 val = __raw_readl(base + CTIINTACK);
0133 val |= BIT(cti->trig_out_for_irq);
0134 __raw_writel(val, base + CTIINTACK);
0135 }
0136
0137
0138
0139
0140
0141
0142
0143
0144 static inline void cti_unlock(struct cti *cti)
0145 {
0146 __raw_writel(CS_LAR_KEY, cti->base + LOCKACCESS);
0147 }
0148
0149
0150
0151
0152
0153
0154
0155
0156 static inline void cti_lock(struct cti *cti)
0157 {
0158 __raw_writel(~CS_LAR_KEY, cti->base + LOCKACCESS);
0159 }
0160 #endif