Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cti.h
Go to the documentation of this file.
1 #ifndef __ASMARM_CTI_H
2 #define __ASMARM_CTI_H
3 
4 #include <asm/io.h>
5 
6 /* The registers' definition is from section 3.2 of
7  * Embedded Cross Trigger Revision: r0p0
8  */
9 #define CTICONTROL 0x000
10 #define CTISTATUS 0x004
11 #define CTILOCK 0x008
12 #define CTIPROTECTION 0x00C
13 #define CTIINTACK 0x010
14 #define CTIAPPSET 0x014
15 #define CTIAPPCLEAR 0x018
16 #define CTIAPPPULSE 0x01c
17 #define CTIINEN 0x020
18 #define CTIOUTEN 0x0A0
19 #define CTITRIGINSTATUS 0x130
20 #define CTITRIGOUTSTATUS 0x134
21 #define CTICHINSTATUS 0x138
22 #define CTICHOUTSTATUS 0x13c
23 #define CTIPERIPHID0 0xFE0
24 #define CTIPERIPHID1 0xFE4
25 #define CTIPERIPHID2 0xFE8
26 #define CTIPERIPHID3 0xFEC
27 #define CTIPCELLID0 0xFF0
28 #define CTIPCELLID1 0xFF4
29 #define CTIPCELLID2 0xFF8
30 #define CTIPCELLID3 0xFFC
31 
32 /* The below are from section 3.6.4 of
33  * CoreSight v1.0 Architecture Specification
34  */
35 #define LOCKACCESS 0xFB0
36 #define LOCKSTATUS 0xFB4
37 
38 /* write this value to LOCKACCESS will unlock the module, and
39  * other value will lock the module
40  */
41 #define LOCKCODE 0xC5ACCE55
42 
52 struct cti {
53  void __iomem *base;
54  int irq;
56 };
57 
69 static inline void cti_init(struct cti *cti,
70  void __iomem *base, int irq, int trig_out)
71 {
72  cti->base = base;
73  cti->irq = irq;
74  cti->trig_out_for_irq = trig_out;
75 }
76 
87 static inline void cti_map_trigger(struct cti *cti,
88  int trig_in, int trig_out, int chan)
89 {
90  void __iomem *base = cti->base;
91  unsigned long val;
92 
93  val = __raw_readl(base + CTIINEN + trig_in * 4);
94  val |= BIT(chan);
95  __raw_writel(val, base + CTIINEN + trig_in * 4);
96 
97  val = __raw_readl(base + CTIOUTEN + trig_out * 4);
98  val |= BIT(chan);
99  __raw_writel(val, base + CTIOUTEN + trig_out * 4);
100 }
101 
108 static inline void cti_enable(struct cti *cti)
109 {
110  __raw_writel(0x1, cti->base + CTICONTROL);
111 }
112 
119 static inline void cti_disable(struct cti *cti)
120 {
121  __raw_writel(0, cti->base + CTICONTROL);
122 }
123 
130 static inline void cti_irq_ack(struct cti *cti)
131 {
132  void __iomem *base = cti->base;
133  unsigned long val;
134 
135  val = __raw_readl(base + CTIINTACK);
136  val |= BIT(cti->trig_out_for_irq);
137  __raw_writel(val, base + CTIINTACK);
138 }
139 
147 static inline void cti_unlock(struct cti *cti)
148 {
149  void __iomem *base = cti->base;
150  unsigned long val;
151 
152  val = __raw_readl(base + LOCKSTATUS);
153 
154  if (val & 1) {
155  val = LOCKCODE;
156  __raw_writel(val, base + LOCKACCESS);
157  }
158 }
159 
167 static inline void cti_lock(struct cti *cti)
168 {
169  void __iomem *base = cti->base;
170  unsigned long val;
171 
172  val = __raw_readl(base + LOCKSTATUS);
173 
174  if (!(val & 1)) {
175  val = ~LOCKCODE;
176  __raw_writel(val, base + LOCKACCESS);
177  }
178 }
179 #endif