Add p54spi EEPROM initscript
[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-rc1/drivers/cbus/Kconfig
8 ===================================================================
9 --- linux-2.6.37-rc1.orig/drivers/cbus/Kconfig 2010-11-05 17:04:49.001997921 +0100
10 +++ linux-2.6.37-rc1/drivers/cbus/Kconfig 2010-11-05 17:04:52.017998785 +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-rc1/drivers/cbus/retu-user.c
34 ===================================================================
35 --- linux-2.6.37-rc1.orig/drivers/cbus/retu-user.c 2010-11-05 17:04:49.002997987 +0100
36 +++ linux-2.6.37-rc1/drivers/cbus/retu-user.c 2010-11-05 17:04:52.017998785 +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,94 @@
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 + [0x14] = "Charger detect?",
92 + };
93 + const char *name;
94 +
95 + if (reg >= ARRAY_SIZE(names))
96 + return "";
97 + name = names[reg];
98 + if (!name)
99 + return "";
100 + return name;
101 +}
102 +
103 +static const char * adc_chan_name(unsigned int chan)
104 +{
105 + static const char *names[] = {
106 + [0x05] = "Headset hook detect",
107 + };
108 + const char *name;
109 +
110 + if (chan >= ARRAY_SIZE(names))
111 + return "";
112 + name = names[chan];
113 + if (!name)
114 + return "";
115 + return name;
116 +}
117 +
118 +static const char * retu_irq_name(unsigned int id)
119 +{
120 + static const char *names[] = {
121 + [RETU_INT_PWR] = "Power",
122 + [RETU_INT_CHAR] = "Char",
123 + [RETU_INT_RTCS] = "RTCS",
124 + [RETU_INT_RTCM] = "RTCM",
125 + [RETU_INT_RTCD] = "RTCD",
126 + [RETU_INT_RTCA] = "RTCA",
127 + [RETU_INT_HOOK] = "Hook",
128 + [RETU_INT_HEAD] = "Head",
129 + [RETU_INT_ADCS] = "ADC timer",
130 + };
131 + const char *name;
132 +
133 + if (id >= ARRAY_SIZE(names))
134 + return "";
135 + name = names[id];
136 + if (!name)
137 + return "";
138 + return name;
139 +}
140 +#endif
141 +
142 /*
143 * The handler for all RETU interrupts.
144 *
145 @@ -157,6 +251,8 @@
146 /* Mark that this interrupt has a handler */
147 retu_irq_bits |= 1 << id;
148
149 + dprintk("Subscribed to IRQ %d (%s)\n", id, retu_irq_name(id));
150 +
151 return 0;
152 }
153
154 @@ -216,6 +312,10 @@
155
156 /* Generate new value */
157 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
158 +
159 + dprintk("{WRITE %s} 0x%02X(%s) <= msk 0x%04X, val 0x%04X ==> res 0x%04X\n",
160 + reg_name(reg), reg, reg_access_text(reg), MASK(field), value, tmp);
161 +
162 /* Write data to RETU */
163 retu_write_reg(reg, tmp);
164 spin_unlock_irqrestore(&retu_lock, flags);
165 @@ -244,6 +344,9 @@
166 /* Read the register */
167 value = retu_read_reg(reg) & mask;
168
169 + dprintk("{READ %s} 0x%02X(%s) <= msk 0x%04X ==> res 0x%04X\n",
170 + reg_name(reg), reg, reg_access_text(reg), mask, value);
171 +
172 /* Right justify value */
173 while (!(mask & 1)) {
174 value = value >> 1;
175 @@ -273,7 +376,7 @@
176 static long retu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
177 {
178 struct retu_tahvo_write_parms par;
179 - int ret;
180 + int ret, result;
181
182 switch (cmd) {
183 case URT_IOCT_IRQ_SUBSCR:
184 @@ -290,7 +393,15 @@
185 printk(KERN_ERR "copy_to_user failed: %d\n", ret);
186 break;
187 case RETU_IOCH_ADC_READ:
188 - return retu_read_adc(arg);
189 + result = retu_read_adc(arg);
190 + if (result >= 0) {
191 + dprintk("{READ-ADC %s} chan 0x%02lX ==> result 0x%04X\n",
192 + adc_chan_name(arg), arg, result);
193 + } else {
194 + dprintk("{READ-ADC %s} chan 0x%02lX ==> failed %d\n",
195 + adc_chan_name(arg), arg, result);
196 + }
197 + return result;
198 default:
199 return -ENOIOCTLCMD;
200 }
201 @@ -332,6 +443,8 @@
202 list_move(&irq->node, &retu_irqs_reserve);
203 spin_unlock_irqrestore(&retu_irqs_lock, flags);
204
205 + dprintk("{IRQ %s} %d delivered\n", retu_irq_name(irq_id), (int)irq_id);
206 +
207 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
208 sizeof(irq_id));
209 if (ret)
210 Index: linux-2.6.37-rc1/drivers/cbus/tahvo-user.c
211 ===================================================================
212 --- linux-2.6.37-rc1.orig/drivers/cbus/tahvo-user.c 2010-11-05 17:04:49.003998052 +0100
213 +++ linux-2.6.37-rc1/drivers/cbus/tahvo-user.c 2010-11-05 17:04:52.018998824 +0100
214 @@ -46,6 +46,12 @@
215
216 #define PFX "tahvo-user: "
217
218 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
219 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
220 +#else
221 +# define dprintk(fmt, x...) do { } while (0)
222 +#endif
223 +
224 /* Bitmap for marking the interrupt sources as having the handlers */
225 static u32 tahvo_irq_bits;
226
227 @@ -87,6 +93,64 @@
228 1
229 };
230
231 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
232 +static const char * reg_access_text(unsigned int reg)
233 +{
234 + if (WARN_ON(reg >= ARRAY_SIZE(tahvo_access_bits)))
235 + return "X";
236 + switch (tahvo_access_bits[reg]) {
237 + case READ_ONLY:
238 + return "R";
239 + case WRITE_ONLY:
240 + return "W";
241 + case READ_WRITE:
242 + return "RW";
243 + case TOGGLE:
244 + return "T";
245 + }
246 + return "X";
247 +}
248 +
249 +static const char * reg_name(unsigned int reg)
250 +{
251 + static const char *names[] = {
252 + [TAHVO_REG_ASICR] = "ASIC ID & revision",
253 + [TAHVO_REG_IDR] = "Interrupt ID",
254 + [TAHVO_REG_IDSR] = "Interrupt status",
255 + [TAHVO_REG_IMR] = "Interrupt mask",
256 + [TAHVO_REG_LEDPWMR] = "LED PWM",
257 + [TAHVO_REG_USBR] = "USB control",
258 + [0x04] = "Charge current control?",
259 + [0x08] = "Charge ctl 1?",
260 + [0x0C] = "Charge ctl 2?",
261 + [0x0D] = "Battery current ADC?",
262 + };
263 + const char *name;
264 +
265 + if (reg >= ARRAY_SIZE(names))
266 + return "";
267 + name = names[reg];
268 + if (!name)
269 + return "";
270 + return name;
271 +}
272 +
273 +static const char * tahvo_irq_name(unsigned int id)
274 +{
275 + static const char *names[] = {
276 + [TAHVO_INT_VBUSON] = "VBUSON",
277 + };
278 + const char *name;
279 +
280 + if (id >= ARRAY_SIZE(names))
281 + return "";
282 + name = names[id];
283 + if (!name)
284 + return "";
285 + return name;
286 +}
287 +#endif
288 +
289 /*
290 * The handler for all TAHVO interrupts.
291 *
292 @@ -142,6 +206,8 @@
293 /* Mark that this interrupt has a handler */
294 tahvo_irq_bits |= 1 << id;
295
296 + dprintk("Subscribed to IRQ %d (%s)\n", id, tahvo_irq_name(id));
297 +
298 return 0;
299 }
300
301 @@ -200,6 +266,10 @@
302 }
303 /* Generate a new value */
304 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
305 +
306 + dprintk("{WRITE %s} 0x%02X(%s) <= msk 0x%04X, val 0x%04X ==> res 0x%04X\n",
307 + reg_name(reg), reg, reg_access_text(reg), MASK(field), value, tmp);
308 +
309 /* Write data to TAHVO */
310 tahvo_write_reg(reg, tmp);
311 spin_unlock_irqrestore(&tahvo_lock, flags);
312 @@ -228,6 +298,9 @@
313 /* Read the register */
314 value = tahvo_read_reg(reg) & mask;
315
316 + dprintk("{READ %s} 0x%02X(%s) <= msk 0x%04X ==> res 0x%04X\n",
317 + reg_name(reg), reg, reg_access_text(reg), mask, value);
318 +
319 /* Right justify value */
320 while (!(mask & 1)) {
321 value = value >> 1;
322 @@ -314,6 +387,8 @@
323 list_move(&irq->node, &tahvo_irqs_reserve);
324 spin_unlock_irqrestore(&tahvo_irqs_lock, flags);
325
326 + dprintk("{IRQ %s} %d delivered\n", tahvo_irq_name(irq_id), (int)irq_id);
327 +
328 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
329 sizeof(irq_id));
330 if (ret)
This page took 0.054875 seconds and 5 git commands to generate.