Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Hi Dmitry, Gentle Ping on this.. ~Sourav On Wed, May 9, 2012 at 3:37 PM, Poddar, Sourav sourav.pod...@ti.com wrote: Hi Dmitry, On Wed, May 9, 2012 at 3:14 PM, Poddar, Sourav sourav.pod...@ti.com wrote: Hi Dmitry, I did some minor fixes to the patch which you suggested above and the keypad is functional now. Changes: - Move pm_runtime_enable before using pm_runtime_get_sync. Sending the patch inlined..(also attached). From: G, Manjunath Kondaiah manj...@ti.com Date: Mon, 10 Oct 2011 20:52:05 +0530 Subject: [PATCH] Input: omap-keypad: dynamically handle register offsets Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Cc: Andrew Morton a...@linux-foundation.org Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com Signed-off-by: Dmitry Torokhov d...@mail.ru --- drivers/input/keyboard/Kconfig | 4 +- drivers/input/keyboard/omap4-keypad.c | 120 +--- 2 files changed, 95 insertions(+), 29 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index f354813..33bbdee 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -512,9 +512,9 @@ config KEYBOARD_OMAP module will be called omap-keypad. config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..d7102e8 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,19 +68,52 @@ #define OMAP4_MASK_IRQSTATUSDISABLE 0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; void __iomem *base; - int irq; + unsigned int irq; unsigned int rows; unsigned int cols; + u32 reg_offset; + u32 irqreg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, + keypad_data-base + keypad_data-reg_offset + offset); +} + +static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-irqreg_offset + offset); +} + +static void kbd_write_irqreg(struct omap4_keypad *keypad_data, + u32 offset, u32 value) +{ + __raw_writel(value, + keypad_data-base + keypad_data-irqreg_offset + offset); +} + + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +124,11 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, + OMAP4_VAL_IRQDISABLE); - *new_state = __raw_readl(keypad_data-base + OMAP4_KBD_FULLCODE31_0); - *(new_state + 1) = __raw_readl(keypad_data-base - + OMAP4_KBD_FULLCODE63_32); + *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); + *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); for (row = 0; row keypad_data-rows; row++) { changed = key_state[row] ^ keypad_data-key_state[row]; @@ -121,12 +153,13 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) sizeof(keypad_data-key_state)); /* clear pending interrupts */ - __raw_writel(__raw_readl(keypad_data-base + OMAP4_KBD_IRQSTATUS), - keypad_data-base + OMAP4_KBD_IRQSTATUS); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, + kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); /* enable interrupts */ - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, -
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Hi Sourav, On Thu, May 17, 2012 at 07:01:49PM +0530, Poddar, Sourav wrote: Hi Dmitry, Gentle Ping on this.. The patch has been committed to my 'next' branch for 3.5 on 05/11/12: http://git.kernel.org/?p=linux/kernel/git/dtor/input.git;a=commit;h=f77621cc640a7c50b3d8c5254ecc5d91eaa99d0d Thanks. -- Dmitry -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
On Thu, May 17, 2012 at 8:55 PM, Dmitry Torokhov dmitry.torok...@gmail.com wrote: Hi Sourav, On Thu, May 17, 2012 at 07:01:49PM +0530, Poddar, Sourav wrote: Hi Dmitry, Gentle Ping on this.. The patch has been committed to my 'next' branch for 3.5 on 05/11/12: Thanks. http://git.kernel.org/?p=linux/kernel/git/dtor/input.git;a=commit;h=f77621cc640a7c50b3d8c5254ecc5d91eaa99d0d Thanks. -- Dmitry -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Hi Dmitry , On Wed, May 9, 2012 at 10:48 AM, Dmitry Torokhov dmitry.torok...@gmail.com wrote: Ho Sourav, On Thu, Apr 26, 2012 at 11:24:37AM +0530, Sourav Poddar wrote: -config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support +config KEYBOARD_OMAP4+ I think this works purely by accident - '+' sign getting dropped by parser... @@ -139,16 +192,33 @@ static int omap4_keypad_open(struct input_dev *input) disable_irq(keypad_data-irq); - __raw_writel(OMAP4_VAL_FUNCTIONALCFG, - keypad_data-base + OMAP4_KBD_CTRL); - __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, - keypad_data-base + OMAP4_KBD_DEBOUNCINGTIME); - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQSTATUS); - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, - keypad_data-base + OMAP4_KBD_IRQENABLE); - __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, - keypad_data-base + OMAP4_KBD_WAKEUPENABLE); + keypad_data-revision = kbd_read_revision(keypad_data, + OMAP4_KBD_REVISION); + switch (keypad_data-revision) { + case 1: + keypad_data-irqstatus = OMAP4_KBD_IRQSTATUS + 0x0c; + keypad_data-irqenable = OMAP4_KBD_IRQENABLE + 0x0c; + keypad_data-reg_offset = 0x10; + break; This should be done in probe(). Dont we then require pm_runtime_put_sync in probe, since we are trying to read the keypad revision register.? Could you please tell me if the version of the patch below works for you? I just quickly tested this patch and saw the following kernel carsh. [1.571838] Bad mode in data abort handler detected [1.576934] Internal error: Oops - bad mode: 0 [#1] SMP ARM [1.582763] Modules linked in: [1.585937] CPU: 0Not tainted (3.4.0-rc5-dirty #11) [1.591522] PC is at __key.13633+0x3f39df40/0x8 [1.596252] LR is at omap4_keypad_probe+0x1cc/0x3dc [1.601348] pc : [0018]lr : [c0466ffc]psr: 4092 [1.601348] sp : df831e68 ip : fc31c000 fp : 0040 [1.613311] r10: c246 r9 : 0080 r8 : 0003 [1.618774] r7 : de36e880 r6 : df966008 r5 : df965480 r4 : c2422bc0 [1.625579] r3 : 6013 r2 : r1 : r0 : 001e [1.632385] Flags: nZcv IRQs off FIQs on Mode IRQ_32 ISA ARM Segment kernel [1.640106] Control: 10c53c7d Table: 8000404a DAC: 0017 [1.646118] Process swapper/0 (pid: 1, stack limit = 0xdf8302f8) [1.652374] Stack: (0xdf831e68 to 0xdf832000) [1.656921] 1e60: 001e 6013 c2422bc0 df965480 [1.665466] 1e80: df966008 de36e880 0003 0080 c246 0040 fc31c000 df831e68 [1.674011] 1ea0: c0466ffc 0018 4092 c008b744 df967590 0098 [1.682556] 1ec0: df96603c df966008 c0c49dd8 df96603c c06f2a00 008e c06687f0 c0643fcc [1.691070] 1ee0: c02b8748 c02b8730 c02b72c4 df966008 c06f2a00 df96603c [1.699615] 1f00: 008e c02b74d8 c06f2a00 df831f18 c02b7444 c02b5b2c df8402a8 df968e90 [1.708160] 1f20: c06f2a00 c06e5e28 de395bc0 c02b625c c0575768 c024d028 [1.716705] 1f40: df83 c06f2a00 008e c06687f0 c0643fcc c02b7ac4 [1.725219] 1f60: df83 0007 c06fdc00 008e c0008630 0001 c1058170 [1.733764] 1f80: c05f8500 c0643fcc 0001 6013 0001 c05716e0 0006 0006 [1.742309] 1fa0: 6013 c064dbb0 0007 c06fdc00 c061e20c 008e c06687f0 c064dbb8 [1.750854] 1fc0: c061e374 0006 0006 c061e20c c061e28c [1.759399] 1fe0: c00152b8 0013 c00152b8 [1.767944] [c0466ffc] (omap4_keypad_probe+0x1cc/0x3dc) from [df831e68] (0xdf831e68) [1.776397] Code: e59ff410 eabb ea9a eafa (ea78) [1.782775] [ cut here ] [1.787628] WARNING: at arch/arm/mach-omap2/omap_l3_noc.c:113 l3_interrupt_handler+0x17c/0x1b4() [1.796783] L3 custom error: MASTER:MPU TARGET:L4CFG [1.801971] Modules linked in: [1.805175] [c001bba4] (unwind_backtrace+0x0/0xf4) from [c003f9f0] (warn_slowpath_common+0x4c/0x64) [1.815002] [c003f9f0] (warn_slowpath_common+0x4c/0x64) from [c003fa9c] (warn_slowpath_fmt+0x30/0x40) [1.825012] [c003fa9c] (warn_slowpath_fmt+0x30/0x40) from [c00341ac] (l3_interrupt_handler+0x17c/0x1b4) [1.835205] [c00341ac] (l3_interrupt_handler+0x17c/0x1b4) from [c009d88c] (handle_irq_event_percpu+0x64/0x24c) [1.846008] [c009d88c] (handle_irq_event_percpu+0x64/0x24c) from [c009dab0] (handle_irq_event+0x3c/0x5c) [1.856292] [c009dab0] (handle_irq_event+0x3c/0x5c) from [c00a05f4] (handle_fasteoi_irq+0x98/0x13c) [1.866088] [c00a05f4] (handle_fasteoi_irq+0x98/0x13c) from [c009d330] (generic_handle_irq+0x34/0x44) [
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
On Wed, May 9, 2012 at 12:24 PM, Poddar, Sourav sourav.pod...@ti.com wrote: Hi Dmitry , On Wed, May 9, 2012 at 10:48 AM, Dmitry Torokhov dmitry.torok...@gmail.com wrote: Ho Sourav, On Thu, Apr 26, 2012 at 11:24:37AM +0530, Sourav Poddar wrote: -config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support +config KEYBOARD_OMAP4+ I think this works purely by accident - '+' sign getting dropped by parser... @@ -139,16 +192,33 @@ static int omap4_keypad_open(struct input_dev *input) disable_irq(keypad_data-irq); - __raw_writel(OMAP4_VAL_FUNCTIONALCFG, - keypad_data-base + OMAP4_KBD_CTRL); - __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, - keypad_data-base + OMAP4_KBD_DEBOUNCINGTIME); - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQSTATUS); - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, - keypad_data-base + OMAP4_KBD_IRQENABLE); - __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, - keypad_data-base + OMAP4_KBD_WAKEUPENABLE); + keypad_data-revision = kbd_read_revision(keypad_data, + OMAP4_KBD_REVISION); + switch (keypad_data-revision) { + case 1: + keypad_data-irqstatus = OMAP4_KBD_IRQSTATUS + 0x0c; + keypad_data-irqenable = OMAP4_KBD_IRQENABLE + 0x0c; + keypad_data-reg_offset = 0x10; + break; This should be done in probe(). Dont we then require pm_runtime_put_sync in probe, since we are trying to read the keypad revision register.? Sorry for the typo, I meant pm_runtime_get_sync. Could you please tell me if the version of the patch below works for you? I just quickly tested this patch and saw the following kernel carsh. [ 1.571838] Bad mode in data abort handler detected [ 1.576934] Internal error: Oops - bad mode: 0 [#1] SMP ARM [ 1.582763] Modules linked in: [ 1.585937] CPU: 0 Not tainted (3.4.0-rc5-dirty #11) [ 1.591522] PC is at __key.13633+0x3f39df40/0x8 [ 1.596252] LR is at omap4_keypad_probe+0x1cc/0x3dc [ 1.601348] pc : [0018] lr : [c0466ffc] psr: 4092 [ 1.601348] sp : df831e68 ip : fc31c000 fp : 0040 [ 1.613311] r10: c246 r9 : 0080 r8 : 0003 [ 1.618774] r7 : de36e880 r6 : df966008 r5 : df965480 r4 : c2422bc0 [ 1.625579] r3 : 6013 r2 : r1 : r0 : 001e [ 1.632385] Flags: nZcv IRQs off FIQs on Mode IRQ_32 ISA ARM Segment kernel [ 1.640106] Control: 10c53c7d Table: 8000404a DAC: 0017 [ 1.646118] Process swapper/0 (pid: 1, stack limit = 0xdf8302f8) [ 1.652374] Stack: (0xdf831e68 to 0xdf832000) [ 1.656921] 1e60: 001e 6013 c2422bc0 df965480 [ 1.665466] 1e80: df966008 de36e880 0003 0080 c246 0040 fc31c000 df831e68 [ 1.674011] 1ea0: c0466ffc 0018 4092 c008b744 df967590 0098 [ 1.682556] 1ec0: df96603c df966008 c0c49dd8 df96603c c06f2a00 008e c06687f0 c0643fcc [ 1.691070] 1ee0: c02b8748 c02b8730 c02b72c4 df966008 c06f2a00 df96603c [ 1.699615] 1f00: 008e c02b74d8 c06f2a00 df831f18 c02b7444 c02b5b2c df8402a8 df968e90 [ 1.708160] 1f20: c06f2a00 c06e5e28 de395bc0 c02b625c c0575768 c024d028 [ 1.716705] 1f40: df83 c06f2a00 008e c06687f0 c0643fcc c02b7ac4 [ 1.725219] 1f60: df83 0007 c06fdc00 008e c0008630 0001 c1058170 [ 1.733764] 1f80: c05f8500 c0643fcc 0001 6013 0001 c05716e0 0006 0006 [ 1.742309] 1fa0: 6013 c064dbb0 0007 c06fdc00 c061e20c 008e c06687f0 c064dbb8 [ 1.750854] 1fc0: c061e374 0006 0006 c061e20c c061e28c [ 1.759399] 1fe0: c00152b8 0013 c00152b8 [ 1.767944] [c0466ffc] (omap4_keypad_probe+0x1cc/0x3dc) from [df831e68] (0xdf831e68) [ 1.776397] Code: e59ff410 eabb ea9a eafa (ea78) [ 1.782775] [ cut here ] [ 1.787628] WARNING: at arch/arm/mach-omap2/omap_l3_noc.c:113 l3_interrupt_handler+0x17c/0x1b4() [ 1.796783] L3 custom error: MASTER:MPU TARGET:L4CFG [ 1.801971] Modules linked in: [ 1.805175] [c001bba4] (unwind_backtrace+0x0/0xf4) from [c003f9f0] (warn_slowpath_common+0x4c/0x64) [ 1.815002] [c003f9f0] (warn_slowpath_common+0x4c/0x64) from [c003fa9c] (warn_slowpath_fmt+0x30/0x40) [ 1.825012] [c003fa9c] (warn_slowpath_fmt+0x30/0x40) from [c00341ac] (l3_interrupt_handler+0x17c/0x1b4) [ 1.835205] [c00341ac] (l3_interrupt_handler+0x17c/0x1b4) from [c009d88c] (handle_irq_event_percpu+0x64/0x24c) [ 1.846008] [c009d88c] (handle_irq_event_percpu+0x64/0x24c) from [c009dab0] (handle_irq_event+0x3c/0x5c) [ 1.856292]
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Hi Dmitry , On Wed, May 9, 2012 at 10:48 AM, Dmitry Torokhov dmitry.torok...@gmail.com wrote: Ho Sourav, On Thu, Apr 26, 2012 at 11:24:37AM +0530, Sourav Poddar wrote: -config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support +config KEYBOARD_OMAP4+ I think this works purely by accident - '+' sign getting dropped by parser... @@ -139,16 +192,33 @@ static int omap4_keypad_open(struct input_dev *input) disable_irq(keypad_data-irq); - __raw_writel(OMAP4_VAL_FUNCTIONALCFG, - keypad_data-base + OMAP4_KBD_CTRL); - __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, - keypad_data-base + OMAP4_KBD_DEBOUNCINGTIME); - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQSTATUS); - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, - keypad_data-base + OMAP4_KBD_IRQENABLE); - __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, - keypad_data-base + OMAP4_KBD_WAKEUPENABLE); + keypad_data-revision = kbd_read_revision(keypad_data, + OMAP4_KBD_REVISION); + switch (keypad_data-revision) { + case 1: + keypad_data-irqstatus = OMAP4_KBD_IRQSTATUS + 0x0c; + keypad_data-irqenable = OMAP4_KBD_IRQENABLE + 0x0c; + keypad_data-reg_offset = 0x10; + break; This should be done in probe(). Dont we then require pm_runtime_put_sync in probe, since we are trying to read the keypad revision register.? Ah, indeed, but I think not pm_runtime_get_sync() but pm_runtime_set_active(). Not sure if this will fix the crash... -- Dmitry Input: omap-keypad - dynamically handle register offsets From: G, Manjunath Kondaiah manj...@ti.com Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com Signed-off-by: Dmitry Torokhov d...@mail.ru --- drivers/input/keyboard/Kconfig|4 + drivers/input/keyboard/omap4-keypad.c | 117 ++--- 2 files changed, 94 insertions(+), 27 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 20a3753..84ee155 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -531,9 +531,9 @@ config KEYBOARD_OMAP module will be called omap-keypad. config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..c9fd0df 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,19 +68,52 @@ #define OMAP4_MASK_IRQSTATUSDISABLE0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; void __iomem *base; - int irq; + unsigned int irq; unsigned int rows; unsigned int cols; + u32 reg_offset; + u32 irqreg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, +keypad_data-base + keypad_data-reg_offset + offset); +} + +static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-irqreg_offset + offset); +} + +static void kbd_write_irqreg(struct omap4_keypad *keypad_data, +u32 offset, u32 value) +{ + __raw_writel(value, +keypad_data-base + keypad_data-irqreg_offset + offset); +} + + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +124,11 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, -keypad_data-base + OMAP4_KBD_IRQENABLE); +
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Hi Dmitry, I did some minor fixes to the patch which you suggested above and the keypad is functional now. Changes: - Move pm_runtime_enable before using pm_runtime_get_sync. Sending the patch inlined..(also attached). From: G, Manjunath Kondaiah manj...@ti.com Date: Mon, 10 Oct 2011 20:52:05 +0530 Subject: [PATCH] Input: omap-keypad: dynamically handle register offsets Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Cc: Andrew Morton a...@linux-foundation.org Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com Signed-off-by: Dmitry Torokhov d...@mail.ru --- drivers/input/keyboard/Kconfig|4 +- drivers/input/keyboard/omap4-keypad.c | 120 +--- 2 files changed, 95 insertions(+), 29 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index f354813..33bbdee 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -512,9 +512,9 @@ config KEYBOARD_OMAP module will be called omap-keypad. config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..d7102e8 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,19 +68,52 @@ #define OMAP4_MASK_IRQSTATUSDISABLE0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; void __iomem *base; - int irq; + unsigned int irq; unsigned int rows; unsigned int cols; + u32 reg_offset; + u32 irqreg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, +keypad_data-base + keypad_data-reg_offset + offset); +} + +static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-irqreg_offset + offset); +} + +static void kbd_write_irqreg(struct omap4_keypad *keypad_data, +u32 offset, u32 value) +{ + __raw_writel(value, +keypad_data-base + keypad_data-irqreg_offset + offset); +} + + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +124,11 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, -keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, +OMAP4_VAL_IRQDISABLE); - *new_state = __raw_readl(keypad_data-base + OMAP4_KBD_FULLCODE31_0); - *(new_state + 1) = __raw_readl(keypad_data-base - + OMAP4_KBD_FULLCODE63_32); + *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); + *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); for (row = 0; row keypad_data-rows; row++) { changed = key_state[row] ^ keypad_data-key_state[row]; @@ -121,12 +153,13 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) sizeof(keypad_data-key_state)); /* clear pending interrupts */ - __raw_writel(__raw_readl(keypad_data-base + OMAP4_KBD_IRQSTATUS), - keypad_data-base + OMAP4_KBD_IRQSTATUS); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, +kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); /* enable interrupts */ - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, - keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, + OMAP4_DEF_IRQENABLE_EVENTEN | + OMAP4_DEF_IRQENABLE_LONGKEY); return IRQ_HANDLED; } @@ -139,16 +172,17 @@ static int omap4_keypad_open(struct input_dev
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Hi Dmitry, On Wed, May 9, 2012 at 3:14 PM, Poddar, Sourav sourav.pod...@ti.com wrote: Hi Dmitry, I did some minor fixes to the patch which you suggested above and the keypad is functional now. Changes: - Move pm_runtime_enable before using pm_runtime_get_sync. Sending the patch inlined..(also attached). From: G, Manjunath Kondaiah manj...@ti.com Date: Mon, 10 Oct 2011 20:52:05 +0530 Subject: [PATCH] Input: omap-keypad: dynamically handle register offsets Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Cc: Andrew Morton a...@linux-foundation.org Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com Signed-off-by: Dmitry Torokhov d...@mail.ru --- drivers/input/keyboard/Kconfig | 4 +- drivers/input/keyboard/omap4-keypad.c | 120 +--- 2 files changed, 95 insertions(+), 29 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index f354813..33bbdee 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -512,9 +512,9 @@ config KEYBOARD_OMAP module will be called omap-keypad. config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..d7102e8 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,19 +68,52 @@ #define OMAP4_MASK_IRQSTATUSDISABLE 0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; void __iomem *base; - int irq; + unsigned int irq; unsigned int rows; unsigned int cols; + u32 reg_offset; + u32 irqreg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, + keypad_data-base + keypad_data-reg_offset + offset); +} + +static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-irqreg_offset + offset); +} + +static void kbd_write_irqreg(struct omap4_keypad *keypad_data, + u32 offset, u32 value) +{ + __raw_writel(value, + keypad_data-base + keypad_data-irqreg_offset + offset); +} + + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +124,11 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, + OMAP4_VAL_IRQDISABLE); - *new_state = __raw_readl(keypad_data-base + OMAP4_KBD_FULLCODE31_0); - *(new_state + 1) = __raw_readl(keypad_data-base - + OMAP4_KBD_FULLCODE63_32); + *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); + *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); for (row = 0; row keypad_data-rows; row++) { changed = key_state[row] ^ keypad_data-key_state[row]; @@ -121,12 +153,13 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) sizeof(keypad_data-key_state)); /* clear pending interrupts */ - __raw_writel(__raw_readl(keypad_data-base + OMAP4_KBD_IRQSTATUS), - keypad_data-base + OMAP4_KBD_IRQSTATUS); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, + kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); /* enable interrupts */ - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, - keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, +
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Gentle ping on this.. any comments? ~Sourav On Thu, Apr 26, 2012 at 11:24 AM, Sourav Poddar sourav.pod...@ti.com wrote: From: G, Manjunath Kondaiah manj...@ti.com Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Cc: Andrew Morton a...@linux-foundation.org Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com --- Changes since v1: - Fix Felipe's comment about getting rid of one argument from irqstatus/irqenable api - Fix Dmitry's comment: - get rid of revision check in readl/writel - Relace ENODEV with proper macro. - Use switch statement drivers/input/keyboard/Kconfig | 6 +- drivers/input/keyboard/omap4-keypad.c | 115 ++--- 2 files changed, 95 insertions(+), 26 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index f354813..9a0e1a9 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -511,10 +511,10 @@ config KEYBOARD_OMAP To compile this driver as a module, choose M here: the module will be called omap-keypad. -config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support +config KEYBOARD_OMAP4+ + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..8e46563 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,6 +68,11 @@ #define OMAP4_MASK_IRQSTATUSDISABLE 0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; @@ -76,11 +81,61 @@ struct omap4_keypad { unsigned int rows; unsigned int cols; + unsigned int revision; + u32 irqstatus; + u32 irqenable; + u32 reg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_read_irqstatus(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + offset); +} + +static int kbd_write_irqstatus(struct omap4_keypad *keypad_data, + u32 value) +{ + return __raw_writel(value, keypad_data-base + keypad_data-irqstatus); +} + +static int kbd_write_irqenable(struct omap4_keypad *keypad_data, + u32 value) +{ + return __raw_writel(value, keypad_data-base + keypad_data-irqenable); +} + +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, keypad_data-base + + keypad_data-reg_offset + offset); +} + +static int kbd_read_revision(struct omap4_keypad *keypad_data, u32 offset) +{ + int reg; + reg = __raw_readl(keypad_data-base + offset); + reg = 0x03 30; + reg = 30; + + switch (reg) { + case 1: + return KBD_REVISION_OMAP5; + case 0: + return KBD_REVISION_OMAP4; + default: + return -EINVAL; + } +} + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +146,10 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqenable(keypad_data, OMAP4_VAL_IRQDISABLE); - *new_state = __raw_readl(keypad_data-base + OMAP4_KBD_FULLCODE31_0); - *(new_state + 1) = __raw_readl(keypad_data-base - + OMAP4_KBD_FULLCODE63_32); + *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); + *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); for (row = 0; row keypad_data-rows; row++) { changed = key_state[row] ^ keypad_data-key_state[row]; @@ -121,12 +174,12 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) sizeof(keypad_data-key_state)); /* clear pending interrupts */ -
Re: [RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
Ho Sourav, On Thu, Apr 26, 2012 at 11:24:37AM +0530, Sourav Poddar wrote: -config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support +config KEYBOARD_OMAP4+ I think this works purely by accident - '+' sign getting dropped by parser... @@ -139,16 +192,33 @@ static int omap4_keypad_open(struct input_dev *input) disable_irq(keypad_data-irq); - __raw_writel(OMAP4_VAL_FUNCTIONALCFG, - keypad_data-base + OMAP4_KBD_CTRL); - __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, - keypad_data-base + OMAP4_KBD_DEBOUNCINGTIME); - __raw_writel(OMAP4_VAL_IRQDISABLE, - keypad_data-base + OMAP4_KBD_IRQSTATUS); - __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, - keypad_data-base + OMAP4_KBD_IRQENABLE); - __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, - keypad_data-base + OMAP4_KBD_WAKEUPENABLE); + keypad_data-revision = kbd_read_revision(keypad_data, + OMAP4_KBD_REVISION); + switch (keypad_data-revision) { + case 1: + keypad_data-irqstatus = OMAP4_KBD_IRQSTATUS + 0x0c; + keypad_data-irqenable = OMAP4_KBD_IRQENABLE + 0x0c; + keypad_data-reg_offset = 0x10; + break; This should be done in probe(). Could you please tell me if the version of the patch below works for you? Thanks. -- Dmitry Input: omap-keypad - dynamically handle register offsets From: G, Manjunath Kondaiah manj...@ti.com Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com Signed-off-by: Dmitry Torokhov d...@mail.ru --- drivers/input/keyboard/Kconfig|4 + drivers/input/keyboard/omap4-keypad.c | 102 + 2 files changed, 80 insertions(+), 26 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 20a3753..84ee155 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -531,9 +531,9 @@ config KEYBOARD_OMAP module will be called omap-keypad. config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..ddd5c9e 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,19 +68,52 @@ #define OMAP4_MASK_IRQSTATUSDISABLE0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; void __iomem *base; - int irq; + unsigned int irq; unsigned int rows; unsigned int cols; + u32 reg_offset; + u32 irqreg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, +keypad_data-base + keypad_data-reg_offset + offset); +} + +static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-irqreg_offset + offset); +} + +static void kbd_write_irqreg(struct omap4_keypad *keypad_data, +u32 offset, u32 value) +{ + __raw_writel(value, +keypad_data-base + keypad_data-irqreg_offset + offset); +} + + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +124,11 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, -keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, +OMAP4_VAL_IRQDISABLE); - *new_state = __raw_readl(keypad_data-base + OMAP4_KBD_FULLCODE31_0); - *(new_state + 1) = __raw_readl(keypad_data-base - + OMAP4_KBD_FULLCODE63_32); +
[RESEND/PATCHv2] Input: omap-keypad: dynamically handle register offsets
From: G, Manjunath Kondaiah manj...@ti.com Keypad controller register offsets are different for omap4 and omap5. Handle these offsets through static mapping and assign these mappings during run time. Tested on omap4430 sdp with 3.4-rc3. Tested on omap5430evm with 3.1-custom kernel. Cc: Andrew Morton a...@linux-foundation.org Signed-off-by: Felipe Balbi ba...@ti.com Signed-off-by: G, Manjunath Kondaiah manj...@ti.com Signed-off-by: Sourav Poddar sourav.pod...@ti.com --- Changes since v1: - Fix Felipe's comment about getting rid of one argument from irqstatus/irqenable api - Fix Dmitry's comment: - get rid of revision check in readl/writel - Relace ENODEV with proper macro. - Use switch statement drivers/input/keyboard/Kconfig|6 +- drivers/input/keyboard/omap4-keypad.c | 115 ++--- 2 files changed, 95 insertions(+), 26 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index f354813..9a0e1a9 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -511,10 +511,10 @@ config KEYBOARD_OMAP To compile this driver as a module, choose M here: the module will be called omap-keypad. -config KEYBOARD_OMAP4 - tristate TI OMAP4 keypad support +config KEYBOARD_OMAP4+ + tristate TI OMAP4+ keypad support help - Say Y here if you want to use the OMAP4 keypad. + Say Y here if you want to use the OMAP4+ keypad. To compile this driver as a module, choose M here: the module will be called omap4-keypad. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index e809ac0..8e46563 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -68,6 +68,11 @@ #define OMAP4_MASK_IRQSTATUSDISABLE0x +enum { + KBD_REVISION_OMAP4 = 0, + KBD_REVISION_OMAP5, +}; + struct omap4_keypad { struct input_dev *input; @@ -76,11 +81,61 @@ struct omap4_keypad { unsigned int rows; unsigned int cols; + unsigned int revision; + u32 irqstatus; + u32 irqenable; + u32 reg_offset; unsigned int row_shift; unsigned char key_state[8]; unsigned short keymap[]; }; +static int kbd_read_irqstatus(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + offset); +} + +static int kbd_write_irqstatus(struct omap4_keypad *keypad_data, + u32 value) +{ + return __raw_writel(value, keypad_data-base + keypad_data-irqstatus); +} + +static int kbd_write_irqenable(struct omap4_keypad *keypad_data, + u32 value) +{ + return __raw_writel(value, keypad_data-base + keypad_data-irqenable); +} + +static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset) +{ + return __raw_readl(keypad_data-base + + keypad_data-reg_offset + offset); +} + +static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value) +{ + __raw_writel(value, keypad_data-base + + keypad_data-reg_offset + offset); +} + +static int kbd_read_revision(struct omap4_keypad *keypad_data, u32 offset) +{ + int reg; + reg = __raw_readl(keypad_data-base + offset); + reg = 0x03 30; + reg = 30; + + switch (reg) { + case 1: + return KBD_REVISION_OMAP5; + case 0: + return KBD_REVISION_OMAP4; + default: + return -EINVAL; + } +} + /* Interrupt handler */ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) { @@ -91,12 +146,10 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) u32 *new_state = (u32 *) key_state; /* Disable interrupts */ - __raw_writel(OMAP4_VAL_IRQDISABLE, -keypad_data-base + OMAP4_KBD_IRQENABLE); + kbd_write_irqenable(keypad_data, OMAP4_VAL_IRQDISABLE); - *new_state = __raw_readl(keypad_data-base + OMAP4_KBD_FULLCODE31_0); - *(new_state + 1) = __raw_readl(keypad_data-base - + OMAP4_KBD_FULLCODE63_32); + *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); + *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); for (row = 0; row keypad_data-rows; row++) { changed = key_state[row] ^ keypad_data-key_state[row]; @@ -121,12 +174,12 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) sizeof(keypad_data-key_state)); /* clear pending interrupts */ - __raw_writel(__raw_readl(keypad_data-base + OMAP4_KBD_IRQSTATUS), - keypad_data-base + OMAP4_KBD_IRQSTATUS); + kbd_write_irqstatus(keypad_data, + kbd_read_irqstatus(keypad_data,