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 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
12 If you want support for Tahvo's user space read/write etc. functions,
13 you should say Y here.
15 +config CBUS_TAHVO_USER_DEBUG
16 + depends on CBUS_TAHVO_USER
17 + bool "Enable Tahvo user space interface debugging"
20 depends on CBUS_TAHVO && USB
21 tristate "Support for Tahvo USB transceiver"
23 If you want support for Retu's user space read/write etc. functions,
24 you should say Y here.
26 +config CBUS_RETU_USER_DEBUG
27 + depends on CBUS_RETU_USER
28 + bool "Enable Retu user space interface debugging"
30 config CBUS_RETU_POWERBUTTON
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
39 #define PFX "retu-user: "
41 +#ifdef CONFIG_CBUS_RETU_USER_DEBUG
42 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
44 +# define dprintk(fmt, x...) do { } while (0)
47 /* Bitmap for marking the interrupt sources as having the handlers */
48 static u32 retu_irq_bits;
54 +#ifdef CONFIG_CBUS_RETU_USER_DEBUG
55 +static const char * reg_access_text(unsigned int reg)
57 + if (WARN_ON(reg >= ARRAY_SIZE(retu_access_bits)))
59 + switch (retu_access_bits[reg]) {
72 +static const char * reg_name(unsigned int reg)
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?",
95 + if (reg >= ARRAY_SIZE(names))
103 +static const char * adc_chan_name(unsigned int chan)
105 + static const char *names[] = {
106 + [0x05] = "Headset hook detect",
110 + if (chan >= ARRAY_SIZE(names))
112 + name = names[chan];
118 +static const char * retu_irq_name(unsigned int id)
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",
133 + if (id >= ARRAY_SIZE(names))
143 * The handler for all RETU interrupts.
146 /* Mark that this interrupt has a handler */
147 retu_irq_bits |= 1 << id;
149 + dprintk("Subscribed to IRQ %d (%s)\n", id, retu_irq_name(id));
156 /* Generate new value */
157 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
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);
162 /* Write data to RETU */
163 retu_write_reg(reg, tmp);
164 spin_unlock_irqrestore(&retu_lock, flags);
166 /* Read the register */
167 value = retu_read_reg(reg) & mask;
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);
172 /* Right justify value */
173 while (!(mask & 1)) {
176 static long retu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
178 struct retu_tahvo_write_parms par;
183 case URT_IOCT_IRQ_SUBSCR:
185 printk(KERN_ERR "copy_to_user failed: %d\n", ret);
187 case RETU_IOCH_ADC_READ:
188 - return retu_read_adc(arg);
189 + result = retu_read_adc(arg);
191 + dprintk("{READ-ADC %s} chan 0x%02lX ==> result 0x%04X\n",
192 + adc_chan_name(arg), arg, result);
194 + dprintk("{READ-ADC %s} chan 0x%02lX ==> failed %d\n",
195 + adc_chan_name(arg), arg, result);
202 list_move(&irq->node, &retu_irqs_reserve);
203 spin_unlock_irqrestore(&retu_irqs_lock, flags);
205 + dprintk("{IRQ %s} %d delivered\n", retu_irq_name(irq_id), (int)irq_id);
207 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
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
216 #define PFX "tahvo-user: "
218 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
219 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
221 +# define dprintk(fmt, x...) do { } while (0)
224 /* Bitmap for marking the interrupt sources as having the handlers */
225 static u32 tahvo_irq_bits;
231 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
232 +static const char * reg_access_text(unsigned int reg)
234 + if (WARN_ON(reg >= ARRAY_SIZE(tahvo_access_bits)))
236 + switch (tahvo_access_bits[reg]) {
249 +static const char * reg_name(unsigned int reg)
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?",
265 + if (reg >= ARRAY_SIZE(names))
273 +static const char * tahvo_irq_name(unsigned int id)
275 + static const char *names[] = {
276 + [TAHVO_INT_VBUSON] = "VBUSON",
280 + if (id >= ARRAY_SIZE(names))
290 * The handler for all TAHVO interrupts.
293 /* Mark that this interrupt has a handler */
294 tahvo_irq_bits |= 1 << id;
296 + dprintk("Subscribed to IRQ %d (%s)\n", id, tahvo_irq_name(id));
303 /* Generate a new value */
304 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
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);
309 /* Write data to TAHVO */
310 tahvo_write_reg(reg, tmp);
311 spin_unlock_irqrestore(&tahvo_lock, flags);
313 /* Read the register */
314 value = tahvo_read_reg(reg) & mask;
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);
319 /* Right justify value */
320 while (!(mask & 1)) {
323 list_move(&irq->node, &tahvo_irqs_reserve);
324 spin_unlock_irqrestore(&tahvo_irqs_lock, flags);
326 + dprintk("{IRQ %s} %d delivered\n", tahvo_irq_name(irq_id), (int)irq_id);
328 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,