1#ifndef __ASMARM_CTI_H
2#define __ASMARM_CTI_H
3
4#include <asm/io.h>
5#include <asm/hardware/coresight.h>
6
7
8
9
10#define CTICONTROL 0x000
11#define CTISTATUS 0x004
12#define CTILOCK 0x008
13#define CTIPROTECTION 0x00C
14#define CTIINTACK 0x010
15#define CTIAPPSET 0x014
16#define CTIAPPCLEAR 0x018
17#define CTIAPPPULSE 0x01c
18#define CTIINEN 0x020
19#define CTIOUTEN 0x0A0
20#define CTITRIGINSTATUS 0x130
21#define CTITRIGOUTSTATUS 0x134
22#define CTICHINSTATUS 0x138
23#define CTICHOUTSTATUS 0x13c
24#define CTIPERIPHID0 0xFE0
25#define CTIPERIPHID1 0xFE4
26#define CTIPERIPHID2 0xFE8
27#define CTIPERIPHID3 0xFEC
28#define CTIPCELLID0 0xFF0
29#define CTIPCELLID1 0xFF4
30#define CTIPCELLID2 0xFF8
31#define CTIPCELLID3 0xFFC
32
33
34
35
36#define LOCKACCESS 0xFB0
37#define LOCKSTATUS 0xFB4
38
39
40
41
42
43
44
45
46
47
48struct cti {
49 void __iomem *base;
50 int irq;
51 int trig_out_for_irq;
52};
53
54
55
56
57
58
59
60
61
62
63
64
65static inline void cti_init(struct cti *cti,
66 void __iomem *base, int irq, int trig_out)
67{
68 cti->base = base;
69 cti->irq = irq;
70 cti->trig_out_for_irq = trig_out;
71}
72
73
74
75
76
77
78
79
80
81
82
83static inline void cti_map_trigger(struct cti *cti,
84 int trig_in, int trig_out, int chan)
85{
86 void __iomem *base = cti->base;
87 unsigned long val;
88
89 val = __raw_readl(base + CTIINEN + trig_in * 4);
90 val |= BIT(chan);
91 __raw_writel(val, base + CTIINEN + trig_in * 4);
92
93 val = __raw_readl(base + CTIOUTEN + trig_out * 4);
94 val |= BIT(chan);
95 __raw_writel(val, base + CTIOUTEN + trig_out * 4);
96}
97
98
99
100
101
102
103
104static inline void cti_enable(struct cti *cti)
105{
106 __raw_writel(0x1, cti->base + CTICONTROL);
107}
108
109
110
111
112
113
114
115static inline void cti_disable(struct cti *cti)
116{
117 __raw_writel(0, cti->base + CTICONTROL);
118}
119
120
121
122
123
124
125
126static inline void cti_irq_ack(struct cti *cti)
127{
128 void __iomem *base = cti->base;
129 unsigned long val;
130
131 val = __raw_readl(base + CTIINTACK);
132 val |= BIT(cti->trig_out_for_irq);
133 __raw_writel(val, base + CTIINTACK);
134}
135
136
137
138
139
140
141
142
143static inline void cti_unlock(struct cti *cti)
144{
145 __raw_writel(CS_LAR_KEY, cti->base + LOCKACCESS);
146}
147
148
149
150
151
152
153
154
155static inline void cti_lock(struct cti *cti)
156{
157 __raw_writel(~CS_LAR_KEY, cti->base + LOCKACCESS);
158}
159#endif
160