mpc85xx: copy the fdt for mpc8548cds to $(BIN_DIR)
[openwrt.git] / target / linux / omap24xx / patches-2.6.37 / 510-retu-tahvo-user-debugging.patch
1 ---
2 drivers/cbus/Kconfig | 8 +++
3 drivers/cbus/retu-user.c | 117 +++++++++++++++++++++++++++++++++++++++++++++-
4 drivers/cbus/tahvo-user.c | 75 +++++++++++++++++++++++++++++
5 3 files changed, 198 insertions(+), 2 deletions(-)
6
7 Index: linux-2.6.37/drivers/cbus/Kconfig
8 ===================================================================
9 --- linux-2.6.37.orig/drivers/cbus/Kconfig 2011-02-05 20:01:30.636705379 +0100
10 +++ linux-2.6.37/drivers/cbus/Kconfig 2011-02-05 20:56:11.593025426 +0100
11 @@ -28,6 +28,10 @@
12 If you want support for Tahvo's user space read/write etc. functions,
13 you should say Y here.
14
15 +config CBUS_TAHVO_USER_DEBUG
16 + depends on CBUS_TAHVO_USER
17 + bool "Enable Tahvo user space interface debugging"
18 +
19 config CBUS_TAHVO_USB
20 depends on CBUS_TAHVO && USB
21 tristate "Support for Tahvo USB transceiver"
22 @@ -56,6 +60,10 @@
23 If you want support for Retu's user space read/write etc. functions,
24 you should say Y here.
25
26 +config CBUS_RETU_USER_DEBUG
27 + depends on CBUS_RETU_USER
28 + bool "Enable Retu user space interface debugging"
29 +
30 config CBUS_RETU_POWERBUTTON
31 depends on CBUS_RETU
32 bool "Support for Retu power button"
33 Index: linux-2.6.37/drivers/cbus/retu-user.c
34 ===================================================================
35 --- linux-2.6.37.orig/drivers/cbus/retu-user.c 2011-02-05 20:01:30.637705440 +0100
36 +++ linux-2.6.37/drivers/cbus/retu-user.c 2011-02-05 20:56:42.584938988 +0100
37 @@ -46,6 +46,12 @@
38
39 #define PFX "retu-user: "
40
41 +#ifdef CONFIG_CBUS_RETU_USER_DEBUG
42 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
43 +#else
44 +# define dprintk(fmt, x...) do { } while (0)
45 +#endif
46 +
47 /* Bitmap for marking the interrupt sources as having the handlers */
48 static u32 retu_irq_bits;
49
50 @@ -105,6 +111,93 @@
51 3
52 };
53
54 +#ifdef CONFIG_CBUS_RETU_USER_DEBUG
55 +static const char * reg_access_text(unsigned int reg)
56 +{
57 + if (WARN_ON(reg >= ARRAY_SIZE(retu_access_bits)))
58 + return "X";
59 + switch (retu_access_bits[reg]) {
60 + case READ_ONLY:
61 + return "R";
62 + case WRITE_ONLY:
63 + return "W";
64 + case READ_WRITE:
65 + return "RW";
66 + case TOGGLE:
67 + return "T";
68 + }
69 + return "X";
70 +}
71 +
72 +static const char * reg_name(unsigned int reg)
73 +{
74 + static const char *names[] = {
75 + [RETU_REG_ASICR] = "ASIC ID & revision",
76 + [RETU_REG_IDR] = "Interrupt ID",
77 + [RETU_REG_IMR] = "Interrupt mask",
78 + [RETU_REG_RTCDSR] = "RTC seconds register",
79 + [RETU_REG_RTCHMR] = "RTC hours and minutes register",
80 + [RETU_REG_RTCHMAR] = "hours and minutes alarm and time set register",
81 + [RETU_REG_RTCCALR] = "RTC calibration register",
82 + [RETU_REG_ADCR] = "ADC result",
83 + [RETU_REG_ADCSCR] = "ADC sample ctrl",
84 + [RETU_REG_CC1] = "Common control register 1",
85 + [RETU_REG_CC2] = "Common control register 2",
86 + [RETU_REG_CTRL_CLR] = "Regulator clear register",
87 + [RETU_REG_CTRL_SET] = "Regulator set register",
88 + [RETU_REG_STATUS] = "Status register",
89 + [RETU_REG_WATCHDOG] = "Watchdog register",
90 + [RETU_REG_AUDTXR] = "Audio Codec Tx register",
91 + };
92 + const char *name;
93 +
94 + if (reg >= ARRAY_SIZE(names))
95 + return "";
96 + name = names[reg];
97 + if (!name)
98 + return "";
99 + return name;
100 +}
101 +
102 +static const char * adc_chan_name(unsigned int chan)
103 +{
104 + static const char *names[] = {
105 + [0x05] = "Headset hook detect",
106 + };
107 + const char *name;
108 +
109 + if (chan >= ARRAY_SIZE(names))
110 + return "";
111 + name = names[chan];
112 + if (!name)
113 + return "";
114 + return name;
115 +}
116 +
117 +static const char * retu_irq_name(unsigned int id)
118 +{
119 + static const char *names[] = {
120 + [RETU_INT_PWR] = "Power",
121 + [RETU_INT_CHAR] = "Char",
122 + [RETU_INT_RTCS] = "RTCS",
123 + [RETU_INT_RTCM] = "RTCM",
124 + [RETU_INT_RTCD] = "RTCD",
125 + [RETU_INT_RTCA] = "RTCA",
126 + [RETU_INT_HOOK] = "Hook",
127 + [RETU_INT_HEAD] = "Head",
128 + [RETU_INT_ADCS] = "ADC timer",
129 + };
130 + const char *name;
131 +
132 + if (id >= ARRAY_SIZE(names))
133 + return "";
134 + name = names[id];
135 + if (!name)
136 + return "";
137 + return name;
138 +}
139 +#endif
140 +
141 /*
142 * The handler for all RETU interrupts.
143 *
144 @@ -157,6 +250,8 @@
145 /* Mark that this interrupt has a handler */
146 retu_irq_bits |= 1 << id;
147
148 + dprintk("Subscribed to IRQ %d (%s)\n", id, retu_irq_name(id));
149 +
150 return 0;
151 }
152
153 @@ -216,6 +311,10 @@
154
155 /* Generate new value */
156 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
157 +
158 + dprintk("{WRITE %s} 0x%02X(%s) <= msk 0x%04X, val 0x%04X ==> res 0x%04X\n",
159 + reg_name(reg), reg, reg_access_text(reg), MASK(field), value, tmp);
160 +
161 /* Write data to RETU */
162 retu_write_reg(reg, tmp);
163 spin_unlock_irqrestore(&retu_lock, flags);
164 @@ -244,6 +343,9 @@
165 /* Read the register */
166 value = retu_read_reg(reg) & mask;
167
168 + dprintk("{READ %s} 0x%02X(%s) <= msk 0x%04X ==> res 0x%04X\n",
169 + reg_name(reg), reg, reg_access_text(reg), mask, value);
170 +
171 /* Right justify value */
172 while (!(mask & 1)) {
173 value = value >> 1;
174 @@ -273,7 +375,7 @@
175 static long retu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
176 {
177 struct retu_tahvo_write_parms par;
178 - int ret;
179 + int ret, result;
180
181 switch (cmd) {
182 case URT_IOCT_IRQ_SUBSCR:
183 @@ -290,7 +392,15 @@
184 printk(KERN_ERR "copy_to_user failed: %d\n", ret);
185 break;
186 case RETU_IOCH_ADC_READ:
187 - return retu_read_adc(arg);
188 + result = retu_read_adc(arg);
189 + if (result >= 0) {
190 + dprintk("{READ-ADC %s} chan 0x%02lX ==> result 0x%04X\n",
191 + adc_chan_name(arg), arg, result);
192 + } else {
193 + dprintk("{READ-ADC %s} chan 0x%02lX ==> failed %d\n",
194 + adc_chan_name(arg), arg, result);
195 + }
196 + return result;
197 default:
198 return -ENOIOCTLCMD;
199 }
200 @@ -332,6 +442,8 @@
201 list_move(&irq->node, &retu_irqs_reserve);
202 spin_unlock_irqrestore(&retu_irqs_lock, flags);
203
204 + dprintk("{IRQ %s} %d delivered\n", retu_irq_name(irq_id), (int)irq_id);
205 +
206 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
207 sizeof(irq_id));
208 if (ret)
209 Index: linux-2.6.37/drivers/cbus/tahvo-user.c
210 ===================================================================
211 --- linux-2.6.37.orig/drivers/cbus/tahvo-user.c 2011-02-05 20:01:30.638705501 +0100
212 +++ linux-2.6.37/drivers/cbus/tahvo-user.c 2011-02-05 20:57:03.817249794 +0100
213 @@ -46,6 +46,12 @@
214
215 #define PFX "tahvo-user: "
216
217 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
218 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
219 +#else
220 +# define dprintk(fmt, x...) do { } while (0)
221 +#endif
222 +
223 /* Bitmap for marking the interrupt sources as having the handlers */
224 static u32 tahvo_irq_bits;
225
226 @@ -87,6 +93,60 @@
227 1
228 };
229
230 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
231 +static const char * reg_access_text(unsigned int reg)
232 +{
233 + if (WARN_ON(reg >= ARRAY_SIZE(tahvo_access_bits)))
234 + return "X";
235 + switch (tahvo_access_bits[reg]) {
236 + case READ_ONLY:
237 + return "R";
238 + case WRITE_ONLY:
239 + return "W";
240 + case READ_WRITE:
241 + return "RW";
242 + case TOGGLE:
243 + return "T";
244 + }
245 + return "X";
246 +}
247 +
248 +static const char * reg_name(unsigned int reg)
249 +{
250 + static const char *names[] = {
251 + [TAHVO_REG_ASICR] = "ASIC ID & revision",
252 + [TAHVO_REG_IDR] = "Interrupt ID",
253 + [TAHVO_REG_IDSR] = "Interrupt status",
254 + [TAHVO_REG_IMR] = "Interrupt mask",
255 + [TAHVO_REG_LEDPWMR] = "LED PWM",
256 + [TAHVO_REG_USBR] = "USB control",
257 + };
258 + const char *name;
259 +
260 + if (reg >= ARRAY_SIZE(names))
261 + return "";
262 + name = names[reg];
263 + if (!name)
264 + return "";
265 + return name;
266 +}
267 +
268 +static const char * tahvo_irq_name(unsigned int id)
269 +{
270 + static const char *names[] = {
271 + [TAHVO_INT_VBUSON] = "VBUSON",
272 + };
273 + const char *name;
274 +
275 + if (id >= ARRAY_SIZE(names))
276 + return "";
277 + name = names[id];
278 + if (!name)
279 + return "";
280 + return name;
281 +}
282 +#endif
283 +
284 /*
285 * The handler for all TAHVO interrupts.
286 *
287 @@ -142,6 +202,8 @@
288 /* Mark that this interrupt has a handler */
289 tahvo_irq_bits |= 1 << id;
290
291 + dprintk("Subscribed to IRQ %d (%s)\n", id, tahvo_irq_name(id));
292 +
293 return 0;
294 }
295
296 @@ -200,6 +262,10 @@
297 }
298 /* Generate a new value */
299 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
300 +
301 + dprintk("{WRITE %s} 0x%02X(%s) <= msk 0x%04X, val 0x%04X ==> res 0x%04X\n",
302 + reg_name(reg), reg, reg_access_text(reg), MASK(field), value, tmp);
303 +
304 /* Write data to TAHVO */
305 tahvo_write_reg(reg, tmp);
306 spin_unlock_irqrestore(&tahvo_lock, flags);
307 @@ -228,6 +294,9 @@
308 /* Read the register */
309 value = tahvo_read_reg(reg) & mask;
310
311 + dprintk("{READ %s} 0x%02X(%s) <= msk 0x%04X ==> res 0x%04X\n",
312 + reg_name(reg), reg, reg_access_text(reg), mask, value);
313 +
314 /* Right justify value */
315 while (!(mask & 1)) {
316 value = value >> 1;
317 @@ -314,6 +383,8 @@
318 list_move(&irq->node, &tahvo_irqs_reserve);
319 spin_unlock_irqrestore(&tahvo_irqs_lock, flags);
320
321 + dprintk("{IRQ %s} %d delivered\n", tahvo_irq_name(irq_id), (int)irq_id);
322 +
323 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
324 sizeof(irq_id));
325 if (ret)
This page took 0.08474 seconds and 5 git commands to generate.