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(-)
7 --- linux-2.6.36-rc4.orig/drivers/cbus/Kconfig
8 +++ linux-2.6.36-rc4/drivers/cbus/Kconfig
9 @@ -28,6 +28,10 @@ config CBUS_TAHVO_USER
10 If you want support for Tahvo's user space read/write etc. functions,
11 you should say Y here.
13 +config CBUS_TAHVO_USER_DEBUG
14 + depends on CBUS_TAHVO_USER
15 + bool "Enable Tahvo user space interface debugging"
18 depends on CBUS_TAHVO && USB
19 tristate "Support for Tahvo USB transceiver"
20 @@ -56,6 +60,10 @@ config CBUS_RETU_USER
21 If you want support for Retu's user space read/write etc. functions,
22 you should say Y here.
24 +config CBUS_RETU_USER_DEBUG
25 + depends on CBUS_RETU_USER
26 + bool "Enable Retu user space interface debugging"
28 config CBUS_RETU_POWERBUTTON
30 bool "Support for Retu power button"
31 --- linux-2.6.36-rc4.orig/drivers/cbus/retu-user.c
32 +++ linux-2.6.36-rc4/drivers/cbus/retu-user.c
35 #define PFX "retu-user: "
37 +#ifdef CONFIG_CBUS_RETU_USER_DEBUG
38 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
40 +# define dprintk(fmt, x...) do { } while (0)
43 /* Bitmap for marking the interrupt sources as having the handlers */
44 static u32 retu_irq_bits;
46 @@ -105,6 +111,94 @@ static const u8 retu_access_bits[] = {
50 +#ifdef CONFIG_CBUS_RETU_USER_DEBUG
51 +static const char * reg_access_text(unsigned int reg)
53 + if (WARN_ON(reg >= ARRAY_SIZE(retu_access_bits)))
55 + switch (retu_access_bits[reg]) {
68 +static const char * reg_name(unsigned int reg)
70 + static const char *names[] = {
71 + [RETU_REG_ASICR] = "ASIC ID & revision",
72 + [RETU_REG_IDR] = "Interrupt ID",
73 + [RETU_REG_IMR] = "Interrupt mask",
74 + [RETU_REG_RTCDSR] = "RTC seconds register",
75 + [RETU_REG_RTCHMR] = "RTC hours and minutes register",
76 + [RETU_REG_RTCHMAR] = "hours and minutes alarm and time set register",
77 + [RETU_REG_RTCCALR] = "RTC calibration register",
78 + [RETU_REG_ADCR] = "ADC result",
79 + [RETU_REG_ADCSCR] = "ADC sample ctrl",
80 + [RETU_REG_CC1] = "Common control register 1",
81 + [RETU_REG_CC2] = "Common control register 2",
82 + [RETU_REG_CTRL_CLR] = "Regulator clear register",
83 + [RETU_REG_CTRL_SET] = "Regulator set register",
84 + [RETU_REG_STATUS] = "Status register",
85 + [RETU_REG_WATCHDOG] = "Watchdog register",
86 + [RETU_REG_AUDTXR] = "Audio Codec Tx register",
87 + [0x14] = "Charger detect?",
91 + if (reg >= ARRAY_SIZE(names))
99 +static const char * adc_chan_name(unsigned int chan)
101 + static const char *names[] = {
102 + [0x05] = "Headset hook detect",
106 + if (chan >= ARRAY_SIZE(names))
108 + name = names[chan];
114 +static const char * retu_irq_name(unsigned int id)
116 + static const char *names[] = {
117 + [RETU_INT_PWR] = "Power",
118 + [RETU_INT_CHAR] = "Char",
119 + [RETU_INT_RTCS] = "RTCS",
120 + [RETU_INT_RTCM] = "RTCM",
121 + [RETU_INT_RTCD] = "RTCD",
122 + [RETU_INT_RTCA] = "RTCA",
123 + [RETU_INT_HOOK] = "Hook",
124 + [RETU_INT_HEAD] = "Head",
125 + [RETU_INT_ADCS] = "ADC timer",
129 + if (id >= ARRAY_SIZE(names))
139 * The handler for all RETU interrupts.
141 @@ -157,6 +251,8 @@ static int retu_user_subscribe_to_irq(in
142 /* Mark that this interrupt has a handler */
143 retu_irq_bits |= 1 << id;
145 + dprintk("Subscribed to IRQ %d (%s)\n", id, retu_irq_name(id));
150 @@ -216,6 +312,10 @@ static int retu_user_write_with_mask(u32
152 /* Generate new value */
153 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
155 + dprintk("{WRITE %s} 0x%02X(%s) <= msk 0x%04X, val 0x%04X ==> res 0x%04X\n",
156 + reg_name(reg), reg, reg_access_text(reg), MASK(field), value, tmp);
158 /* Write data to RETU */
159 retu_write_reg(reg, tmp);
160 spin_unlock_irqrestore(&retu_lock, flags);
161 @@ -244,6 +344,9 @@ static u32 retu_user_read_with_mask(u32
162 /* Read the register */
163 value = retu_read_reg(reg) & mask;
165 + dprintk("{READ %s} 0x%02X(%s) <= msk 0x%04X ==> res 0x%04X\n",
166 + reg_name(reg), reg, reg_access_text(reg), mask, value);
168 /* Right justify value */
169 while (!(mask & 1)) {
171 @@ -273,7 +376,7 @@ static int retu_close(struct inode *inod
172 static long retu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
174 struct retu_tahvo_write_parms par;
179 case URT_IOCT_IRQ_SUBSCR:
180 @@ -290,7 +393,15 @@ static long retu_ioctl(struct file *filp
181 printk(KERN_ERR "copy_to_user failed: %d\n", ret);
183 case RETU_IOCH_ADC_READ:
184 - return retu_read_adc(arg);
185 + result = retu_read_adc(arg);
187 + dprintk("{READ-ADC %s} chan 0x%02lX ==> result 0x%04X\n",
188 + adc_chan_name(arg), arg, result);
190 + dprintk("{READ-ADC %s} chan 0x%02lX ==> failed %d\n",
191 + adc_chan_name(arg), arg, result);
197 @@ -332,6 +443,8 @@ static ssize_t retu_read(struct file *fi
198 list_move(&irq->node, &retu_irqs_reserve);
199 spin_unlock_irqrestore(&retu_irqs_lock, flags);
201 + dprintk("{IRQ %s} %d delivered\n", retu_irq_name(irq_id), (int)irq_id);
203 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
206 --- linux-2.6.36-rc4.orig/drivers/cbus/tahvo-user.c
207 +++ linux-2.6.36-rc4/drivers/cbus/tahvo-user.c
210 #define PFX "tahvo-user: "
212 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
213 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
215 +# define dprintk(fmt, x...) do { } while (0)
218 /* Bitmap for marking the interrupt sources as having the handlers */
219 static u32 tahvo_irq_bits;
221 @@ -87,6 +93,64 @@ static const u8 tahvo_access_bits[] = {
225 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
226 +static const char * reg_access_text(unsigned int reg)
228 + if (WARN_ON(reg >= ARRAY_SIZE(tahvo_access_bits)))
230 + switch (tahvo_access_bits[reg]) {
243 +static const char * reg_name(unsigned int reg)
245 + static const char *names[] = {
246 + [TAHVO_REG_ASICR] = "ASIC ID & revision",
247 + [TAHVO_REG_IDR] = "Interrupt ID",
248 + [TAHVO_REG_IDSR] = "Interrupt status",
249 + [TAHVO_REG_IMR] = "Interrupt mask",
250 + [TAHVO_REG_LEDPWMR] = "LED PWM",
251 + [TAHVO_REG_USBR] = "USB control",
252 + [0x04] = "Charge current control?",
253 + [0x08] = "Charge ctl 1?",
254 + [0x0C] = "Charge ctl 2?",
255 + [0x0D] = "Battery current ADC?",
259 + if (reg >= ARRAY_SIZE(names))
267 +static const char * tahvo_irq_name(unsigned int id)
269 + static const char *names[] = {
270 + [TAHVO_INT_VBUSON] = "VBUSON",
274 + if (id >= ARRAY_SIZE(names))
284 * The handler for all TAHVO interrupts.
286 @@ -142,6 +206,8 @@ static int tahvo_user_subscribe_to_irq(i
287 /* Mark that this interrupt has a handler */
288 tahvo_irq_bits |= 1 << id;
290 + dprintk("Subscribed to IRQ %d (%s)\n", id, tahvo_irq_name(id));
295 @@ -200,6 +266,10 @@ static int tahvo_user_write_with_mask(u3
297 /* Generate a new value */
298 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
300 + dprintk("{WRITE %s} 0x%02X(%s) <= msk 0x%04X, val 0x%04X ==> res 0x%04X\n",
301 + reg_name(reg), reg, reg_access_text(reg), MASK(field), value, tmp);
303 /* Write data to TAHVO */
304 tahvo_write_reg(reg, tmp);
305 spin_unlock_irqrestore(&tahvo_lock, flags);
306 @@ -228,6 +298,9 @@ static u32 tahvo_user_read_with_mask(u32
307 /* Read the register */
308 value = tahvo_read_reg(reg) & mask;
310 + dprintk("{READ %s} 0x%02X(%s) <= msk 0x%04X ==> res 0x%04X\n",
311 + reg_name(reg), reg, reg_access_text(reg), mask, value);
313 /* Right justify value */
314 while (!(mask & 1)) {
316 @@ -314,6 +387,8 @@ static ssize_t tahvo_read(struct file *f
317 list_move(&irq->node, &tahvo_irqs_reserve);
318 spin_unlock_irqrestore(&tahvo_irqs_lock, flags);
320 + dprintk("{IRQ %s} %d delivered\n", tahvo_irq_name(irq_id), (int)irq_id);
322 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,