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/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
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/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
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",
94 + if (reg >= ARRAY_SIZE(names))
102 +static const char * adc_chan_name(unsigned int chan)
104 + static const char *names[] = {
105 + [0x05] = "Headset hook detect",
109 + if (chan >= ARRAY_SIZE(names))
111 + name = names[chan];
117 +static const char * retu_irq_name(unsigned int id)
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",
132 + if (id >= ARRAY_SIZE(names))
142 * The handler for all RETU interrupts.
145 /* Mark that this interrupt has a handler */
146 retu_irq_bits |= 1 << id;
148 + dprintk("Subscribed to IRQ %d (%s)\n", id, retu_irq_name(id));
155 /* Generate new value */
156 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
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);
161 /* Write data to RETU */
162 retu_write_reg(reg, tmp);
163 spin_unlock_irqrestore(&retu_lock, flags);
165 /* Read the register */
166 value = retu_read_reg(reg) & mask;
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);
171 /* Right justify value */
172 while (!(mask & 1)) {
175 static long retu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
177 struct retu_tahvo_write_parms par;
182 case URT_IOCT_IRQ_SUBSCR:
184 printk(KERN_ERR "copy_to_user failed: %d\n", ret);
186 case RETU_IOCH_ADC_READ:
187 - return retu_read_adc(arg);
188 + result = retu_read_adc(arg);
190 + dprintk("{READ-ADC %s} chan 0x%02lX ==> result 0x%04X\n",
191 + adc_chan_name(arg), arg, result);
193 + dprintk("{READ-ADC %s} chan 0x%02lX ==> failed %d\n",
194 + adc_chan_name(arg), arg, result);
201 list_move(&irq->node, &retu_irqs_reserve);
202 spin_unlock_irqrestore(&retu_irqs_lock, flags);
204 + dprintk("{IRQ %s} %d delivered\n", retu_irq_name(irq_id), (int)irq_id);
206 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,
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
215 #define PFX "tahvo-user: "
217 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
218 +# define dprintk(fmt, x...) printk(KERN_DEBUG PFX fmt, x)
220 +# define dprintk(fmt, x...) do { } while (0)
223 /* Bitmap for marking the interrupt sources as having the handlers */
224 static u32 tahvo_irq_bits;
230 +#ifdef CONFIG_CBUS_TAHVO_USER_DEBUG
231 +static const char * reg_access_text(unsigned int reg)
233 + if (WARN_ON(reg >= ARRAY_SIZE(tahvo_access_bits)))
235 + switch (tahvo_access_bits[reg]) {
248 +static const char * reg_name(unsigned int reg)
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",
260 + if (reg >= ARRAY_SIZE(names))
268 +static const char * tahvo_irq_name(unsigned int id)
270 + static const char *names[] = {
271 + [TAHVO_INT_VBUSON] = "VBUSON",
275 + if (id >= ARRAY_SIZE(names))
285 * The handler for all TAHVO interrupts.
288 /* Mark that this interrupt has a handler */
289 tahvo_irq_bits |= 1 << id;
291 + dprintk("Subscribed to IRQ %d (%s)\n", id, tahvo_irq_name(id));
298 /* Generate a new value */
299 tmp = (tmp & ~MASK(field)) | (value & MASK(field));
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);
304 /* Write data to TAHVO */
305 tahvo_write_reg(reg, tmp);
306 spin_unlock_irqrestore(&tahvo_lock, flags);
308 /* Read the register */
309 value = tahvo_read_reg(reg) & mask;
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);
314 /* Right justify value */
315 while (!(mask & 1)) {
318 list_move(&irq->node, &tahvo_irqs_reserve);
319 spin_unlock_irqrestore(&tahvo_irqs_lock, flags);
321 + dprintk("{IRQ %s} %d delivered\n", tahvo_irq_name(irq_id), (int)irq_id);
323 ret = copy_to_user(buf + i * sizeof(irq_id), &irq_id,