Re: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-02-08 Thread David Brownell
On Thursday 05 February 2009, David Brownell wrote:
> 
> > Pushing this to l-o tree, let me know when/if you need the patch
> > against the mainline tree added to the omap-upstream queue.
> 
> I'll (re?)send the mainline patch in a bit.
> 
> Meanwhile, here's the rename patch.

Ugh, here's the *right* rename patch.  "twl4030_keypad"
needs an underscore.  (That's long been the driver name,
and the file name should match.)


= CUT HERE
From: David Brownell 

Rename this so it no longer presumes needless OMAP dependency.

Signed-off-by: David Brownell 
---
 drivers/input/keyboard/Makefile |2 
 drivers/input/keyboard/omap-twl4030keypad.c |  489 -
 drivers/input/keyboard/twl4030_keypad.c |  493 ++
 3 files changed, 494 insertions(+), 490 deletions(-)

--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-key
 obj-$(CONFIG_OMAP_PS2) += innovator_ps2.o
 obj-$(CONFIG_KEYBOARD_TSC2301) += tsc2301_kp.o
 obj-$(CONFIG_KEYBOARD_LM8323)  += lm8323.o
-obj-$(CONFIG_KEYBOARD_TWL4030) += omap-twl4030keypad.o
+obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keypad.o
 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY)   += pxa930_rotary.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
--- a/drivers/input/keyboard/omap-twl4030keypad.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * drivers/input/keyboard/omap-twl4030keypad.c
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- * Copyright (C) 2008 Nokia Corporation
- *
- * Code re-written for 2430SDP by:
- * Syed Mohammed Khasim 
- *
- * Initial Code:
- * Manjunatha G K 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/*
- * The TWL4030 family chips include a keypad controller that supports
- * up to an 8x8 switch matrix.  The controller can issue system wakeup
- * events, since it uses only the always-on 32KiHz oscillator, and has
- * an internal state machine that decodes pressed keys, including
- * multi-key combinations.
- *
- * This driver lets boards define what keycodes they wish to report for
- * which scancodes, as part of the "struct twl4030_keypad_data" used in
- * the probe() routine.
- *
- * See the TPS65950 documentation; that's the general availability
- * version of the TWL5030 second generation part.
- */
-#define MAX_ROWS   8   /* TWL4030 hard limit */
-
-struct twl4030_keypad {
-   unsigned*keymap;
-   unsigned intkeymapsize;
-   u16 kp_state[MAX_ROWS];
-   unsignedn_rows;
-   unsignedn_cols;
-   unsignedirq;
-
-   struct device   *dbg_dev;
-   struct input_dev *input;
-};
-
-#define ROWCOL_MASKKEY(0xf, 0xf, 0)
-#define KEYNUM_MASK~PERSISTENT_KEY(0xf, 0xf)
-
-/*--*/
-
-/* arbitrary prescaler value 0..7 */
-#define PTV_PRESCALER  4
-
-/* Register Offsets */
-#define KEYP_CTRL  0x00
-#define KEYP_DEB   0x01
-#define KEYP_LONG_KEY  0x02
-#define KEYP_LK_PTV0x03
-#define KEYP_TIMEOUT_L 0x04
-#define KEYP_TIMEOUT_H 0x05
-#define KEYP_KBC   0x06
-#define KEYP_KBR   0x07
-#define KEYP_SMS   0x08
-#define KEYP_FULL_CODE_7_0 0x09/* row 0 column status */
-#define KEYP_FULL_CODE_15_80x0a/* ... row 1 ... */
-#define KEYP_FULL_CODE_23_16   0x0b
-#define KEYP_FULL_CODE_31_24   0x0c
-#define KEYP_FULL_CODE_39_32   0x0d
-#define KEYP_FULL_CODE_47_40   0x0e
-#define KEYP_FULL_CODE_55_48   0x0f
-#define KEYP_FULL_CODE_63_56   0x10
-#define KEYP_ISR1  0x11
-#define KEYP_IMR1  0x12
-#define KEYP_ISR2  0x13
-#define KEYP_IMR2  0x14
-#define KEYP_SIR   0x15
-#define KEYP_EDR   0x16/* edge triggers */
-#define KEYP_SIH_CTRL 

Re: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-02-05 Thread David Brownell
On Wednesday 04 February 2009, Tony Lindgren wrote:
> 
> > Start cleaning up the twl4030 keypad driver to become more
> > suitable for mainline.
> > 
> >  - Remove false OMAP dependencies:  names, , Kconfig
> >  - We don't need a miniature header file
> >  - Add missing input_sync()
> >  - ...
> > 
> > The driver should also be renamed as "twl4030_keypad.c"; that will
> > be a different patch.
> 
> Pushing this to l-o tree, let me know when/if you need the patch
> against the mainline tree added to the omap-upstream queue.

I'll (re?)send the mainline patch in a bit.

Meanwhile, here's the rename patch.

- Dave

= CUT HERE
From: David Brownell 

Rename this so it no longer presumes needless OMAP dependency.

Signed-off-by: David Brownell 
---
 drivers/input/keyboard/Makefile |2 
 drivers/input/keyboard/omap-twl4030keypad.c |  489 -
 drivers/input/keyboard/twl4030keypad.c  |  493 ++
 3 files changed, 494 insertions(+), 490 deletions(-)

--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_KEYBOARD_OMAP)   += omap-key
 obj-$(CONFIG_OMAP_PS2) += innovator_ps2.o
 obj-$(CONFIG_KEYBOARD_TSC2301) += tsc2301_kp.o
 obj-$(CONFIG_KEYBOARD_LM8323)  += lm8323.o
-obj-$(CONFIG_KEYBOARD_TWL4030) += omap-twl4030keypad.o
+obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030keypad.o
 obj-$(CONFIG_KEYBOARD_PXA27x)  += pxa27x_keypad.o
 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY)   += pxa930_rotary.o
 obj-$(CONFIG_KEYBOARD_AAED2000)+= aaed2000_kbd.o
--- a/drivers/input/keyboard/omap-twl4030keypad.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * drivers/input/keyboard/omap-twl4030keypad.c
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- * Copyright (C) 2008 Nokia Corporation
- *
- * Code re-written for 2430SDP by:
- * Syed Mohammed Khasim 
- *
- * Initial Code:
- * Manjunatha G K 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/*
- * The TWL4030 family chips include a keypad controller that supports
- * up to an 8x8 switch matrix.  The controller can issue system wakeup
- * events, since it uses only the always-on 32KiHz oscillator, and has
- * an internal state machine that decodes pressed keys, including
- * multi-key combinations.
- *
- * This driver lets boards define what keycodes they wish to report for
- * which scancodes, as part of the "struct twl4030_keypad_data" used in
- * the probe() routine.
- *
- * See the TPS65950 documentation; that's the general availability
- * version of the TWL5030 second generation part.
- */
-#define MAX_ROWS   8   /* TWL4030 hard limit */
-
-struct twl4030_keypad {
-   unsigned*keymap;
-   unsigned intkeymapsize;
-   u16 kp_state[MAX_ROWS];
-   unsignedn_rows;
-   unsignedn_cols;
-   unsignedirq;
-
-   struct device   *dbg_dev;
-   struct input_dev *input;
-};
-
-#define ROWCOL_MASKKEY(0xf, 0xf, 0)
-#define KEYNUM_MASK~PERSISTENT_KEY(0xf, 0xf)
-
-/*--*/
-
-/* arbitrary prescaler value 0..7 */
-#define PTV_PRESCALER  4
-
-/* Register Offsets */
-#define KEYP_CTRL  0x00
-#define KEYP_DEB   0x01
-#define KEYP_LONG_KEY  0x02
-#define KEYP_LK_PTV0x03
-#define KEYP_TIMEOUT_L 0x04
-#define KEYP_TIMEOUT_H 0x05
-#define KEYP_KBC   0x06
-#define KEYP_KBR   0x07
-#define KEYP_SMS   0x08
-#define KEYP_FULL_CODE_7_0 0x09/* row 0 column status */
-#define KEYP_FULL_CODE_15_80x0a/* ... row 1 ... */
-#define KEYP_FULL_CODE_23_16   0x0b
-#define KEYP_FULL_CODE_31_24   0x0c
-#define KEYP_FULL_CODE_39_32   0x0d
-#define KEYP_FULL_CODE_47_40   0x0e
-#define KEYP_FULL_CODE_55_48   0x0f
-#define KEYP_FULL_CODE_63_56   0x10
-#define KEYP_ISR1  0x11
-#define KEYP_IMR1  0x12
-#define KEYP_ISR2

Re: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-02-04 Thread Tony Lindgren
* David Brownell  [090122 22:59]:
> From: David Brownell 
> 
> Start cleaning up the twl4030 keypad driver to become more
> suitable for mainline.
> 
>  - Remove false OMAP dependencies:  names, , Kconfig
>  - We don't need a miniature header file
>  - Add missing input_sync()
>  - Fix section annotations
>  - Fix probe() error cleanup
>  - Streamline i/o calls
>  - Remove needless mutex; maintain key state only via irqs
>  - Remove unneeded headers
>  - Use "unsigned" for things that can't be negative
> 
> The driver should also be renamed as "twl4030_keypad.c"; that will
> be a different patch.

Pushing this to l-o tree, let me know when/if you need the patch
against the mainline tree added to the omap-upstream queue.

Tony


> Signed-off-by: David Brownell 
> Reviewed-by: Trilok Soni 
> ---
> Refresh against RC2, with feedback addressed, and also a few
> deltas that had accidentally been omitted.
> 
>  arch/arm/mach-omap2/board-2430sdp.c |1 
>  arch/arm/mach-omap2/board-3430sdp.c |1 
>  arch/arm/mach-omap2/board-ldp.c |1 
>  arch/arm/mach-omap2/board-omap2evm.c|1 
>  arch/arm/mach-omap2/board-omap3evm.c|1 
>  drivers/input/keyboard/Kconfig  |9 
>  drivers/input/keyboard/omap-twl4030keypad.c |  300 +++---
>  drivers/input/keyboard/twl4030-keypad.h |   82 ---
>  include/linux/i2c/twl4030.h |   16 +
>  9 files changed, 200 insertions(+), 212 deletions(-)
> 
> --- a/arch/arm/mach-omap2/board-2430sdp.c
> +++ b/arch/arm/mach-omap2/board-2430sdp.c
> @@ -38,7 +38,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> --- a/arch/arm/mach-omap2/board-3430sdp.c
> +++ b/arch/arm/mach-omap2/board-3430sdp.c
> @@ -36,7 +36,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> --- a/arch/arm/mach-omap2/board-ldp.c
> +++ b/arch/arm/mach-omap2/board-ldp.c
> @@ -34,7 +34,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> --- a/arch/arm/mach-omap2/board-omap2evm.c
> +++ b/arch/arm/mach-omap2/board-omap2evm.c
> @@ -35,7 +35,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> --- a/arch/arm/mach-omap2/board-omap3evm.c
> +++ b/arch/arm/mach-omap2/board-omap3evm.c
> @@ -30,7 +30,6 @@
>  #include 
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -260,14 +260,15 @@ config KEYBOARD_OMAP
> module will be called omap-keypad.
>  
>  config KEYBOARD_TWL4030
> - tristate "TI TWL4030 keypad support"
> + tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
>   depends on TWL4030_CORE
>   help
> -   Say Y here if you want to use the OMAP TWL4030 keypad.
> +   Say Y here if your board use the keypad controller on
> +   TWL4030 family chips.  It's safe to say enable this
> +   even on boards that don't use the keypad controller.
>  
> To compile this driver as a module, choose M here: the
> -   module will be called omap-twl4030keypad. This driver depends on
> -   TWL4030 Core and TWL4030 GPIO I2C client driver
> +   module will be called twl4030_keypad.
>  
>  config OMAP_PS2
>   tristate "TI OMAP Innovator 1510 PS/2 keyboard & mouse support"
> --- a/drivers/input/keyboard/omap-twl4030keypad.c
> +++ b/drivers/input/keyboard/omap-twl4030keypad.c
> @@ -25,50 +25,117 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
> -#include 
> -#include 
> -#include 
> -#include 
>  #include 
> -#include 
>  #include 
> -#include 
> -#include 
>  
> -#include "twl4030-keypad.h"
> -
> -#define PTV_PRESCALER4
> -
> -#define MAX_ROWS 8 /* TWL4030 hardlimit */
> -
> -/* Global variables */
> +/*
> + * The TWL4030 family chips include a keypad controller that supports
> + * up to an 8x8 switch matrix.  The controller can issue system wakeup
> + * events, since it uses only the always-on 32KiHz oscillator, and has
> + * an internal state machine that decodes pressed keys, including
> + * multi-key combinations.
> + *
> + * This driver lets boards define what keycodes they wish to report for
> + * which scancodes, as part of the "struct twl4030_keypad_data" used in
> + * the probe() routine.
> + *
> + * See the TPS65950 documentation; that's the general availability
> + * version of the TWL5030 second generation part.
> + */
> +#define MAX_ROWS 8   /* TWL4030 hard limit */
>  
> -struct omap_keypad {
> - int *keymap;
> +struct twl4030_keypad {
> + unsigned*keymap;
>   unsigned intkeymapsize;
>   u16 kp_state[MAX_ROWS];
> - int n_rows;
> - int n_cols;
> - int irq;
> 

Re: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-01-23 Thread Tony Lindgren
* David Brownell  [090123 13:11]:
> On Friday 23 January 2009, Felipe Balbi wrote:
> > This looks good. I also see this driver is going to mainline, so we're
> > gonna have to drop this driver from l-o on 2.6.30 merge window, right ?
> 
> If by "we" you mean "Tony", I suppose so.  ;)
> 
> My notion is that this patch merges, and then I'll send
> two patches:  (a) to OMAP, a rename patch; (b) to mainline,
> submit the cleaned-up-and-renamed driver.
> 
> Then when it merges to mainline, there will be no deltas
> between the driver versions, and Tony won't have to think
> about such issues.

Great, I like!

Tony
--
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: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-01-23 Thread David Brownell
On Friday 23 January 2009, Felipe Balbi wrote:
> This looks good. I also see this driver is going to mainline, so we're
> gonna have to drop this driver from l-o on 2.6.30 merge window, right ?

If by "we" you mean "Tony", I suppose so.  ;)

My notion is that this patch merges, and then I'll send
two patches:  (a) to OMAP, a rename patch; (b) to mainline,
submit the cleaned-up-and-renamed driver.

Then when it merges to mainline, there will be no deltas
between the driver versions, and Tony won't have to think
about such issues.

- Dave

--
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: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-01-23 Thread Felipe Balbi
On Tue, Jan 20, 2009 at 12:51:46AM -0800, David Brownell wrote:
> From: David Brownell 
> 
> Start cleaning up the twl4030 keypad driver to become more
> suitable for mainline.
> 
>  - Get rid of false OMAP dependencies:  in names, 
>  - We don't need a miniature header file
>  - Fix section annotations 
>  - Streamline i/o calls
>  - Remove needless mutex; maintain key state only via irqs
>  - Remove unneeded headers
>  - Use "unsigned" for things that can't be negative
> 
> The driver should also be renamed as "twl4030_keypad.c"; that'll
> be a different patch.
> 
> Signed-off-by: David Brownell 

This looks good. I also see this driver is going to mainline, so we're
gonna have to drop this driver from l-o on 2.6.30 merge window, right ?

> ---
>  arch/arm/mach-omap2/board-2430sdp.c |1 
>  arch/arm/mach-omap2/board-3430sdp.c |1 
>  arch/arm/mach-omap2/board-ldp.c |1 
>  arch/arm/mach-omap2/board-omap2evm.c|1 
>  arch/arm/mach-omap2/board-omap3evm.c|1 
>  drivers/input/keyboard/omap-twl4030keypad.c |  274 --
>  drivers/input/keyboard/twl4030-keypad.h |   82 ---
>  include/linux/i2c/twl4030.h |8 
>  8 files changed, 178 insertions(+), 191 deletions(-)
> 
> --- a/arch/arm/mach-omap2/board-2430sdp.c
> +++ b/arch/arm/mach-omap2/board-2430sdp.c
> @@ -38,7 +38,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> --- a/arch/arm/mach-omap2/board-3430sdp.c
> +++ b/arch/arm/mach-omap2/board-3430sdp.c
> @@ -37,7 +37,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> --- a/arch/arm/mach-omap2/board-ldp.c
> +++ b/arch/arm/mach-omap2/board-ldp.c
> @@ -34,7 +34,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> --- a/arch/arm/mach-omap2/board-omap2evm.c
> +++ b/arch/arm/mach-omap2/board-omap2evm.c
> @@ -35,7 +35,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> --- a/arch/arm/mach-omap2/board-omap3evm.c
> +++ b/arch/arm/mach-omap2/board-omap3evm.c
> @@ -30,7 +30,6 @@
>  #include 
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> --- a/drivers/input/keyboard/omap-twl4030keypad.c
> +++ b/drivers/input/keyboard/omap-twl4030keypad.c
> @@ -25,30 +25,31 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
> -#include 
> -#include 
> -#include 
> -#include 
>  #include 
> -#include 
>  #include 
> -#include 
> -#include 
>  
> -#include "twl4030-keypad.h"
> -
> -#define PTV_PRESCALER4
> -
> -#define MAX_ROWS 8 /* TWL4030 hardlimit */
> -
> -/* Global variables */
> +/*
> + * The TWL4030 family chips include a keypad controller that supports
> + * up to an 8x8 switch matrix.  The controller can issue system wakeup
> + * events, since it uses only the always-on 32KiHz oscillator, and has
> + * an internal state machine that decodes pressed keys, including
> + * multi-key combinations.
> + *
> + * This driver lets boards define what keycodes they wish to report for
> + * which scancodes, as part of the "struct twl4030_keypad_data" used in
> + * the probe() routine.
> + *
> + * See the TPS65950 documentation; that's the general availability
> + * version of the TWL5030 second generation part.
> + */
> +#define MAX_ROWS 8   /* TWL4030 hard limit */
>  
> -struct omap_keypad {
> +struct twl4030_keypad {
>   int *keymap;
>   unsigned intkeymapsize;
>   u16 kp_state[MAX_ROWS];
> @@ -57,18 +58,84 @@ struct omap_keypad {
>   int irq;
>  
>   struct device   *dbg_dev;
> - struct input_dev *omap_twl4030kp;
> -
> - /* sync read/write */
> - struct mutexmutex;
> + struct input_dev *input;
>  };
>  
> -static int twl4030_kpread(struct omap_keypad *kp,
> - u32 module, u8 *data, u32 reg, u8 num_bytes)
> +#define ROWCOL_MASK  KEY(0xf, 0xf, 0)
> +#define KEYNUM_MASK  ~PERSISTENT_KEY(0xf, 0xf)
> +
> +/*--*/
> +
> +/* arbitrary prescaler value 0..7 */
> +#define PTV_PRESCALER4
> +
> +/* Register Offsets */
> +#define KEYP_CTRL0x00
> +#define KEYP_DEB 0x01
> +#define KEYP_LONG_KEY0x02
> +#define KEYP_LK_PTV  0x03
> +#define KEYP_TIMEOUT_L   0x04
> +#define KEYP_TIMEOUT_H   0x05
> +#define KEYP_KBC 0x06
> +#define KEYP_KBR 0x07
> +#define KEYP_SMS 0x08
> +#define KEYP_FULL_CODE_7_0   0x09/* row 0 column status */
> +#define KEYP_FULL_CODE_15_8  0x0a/* ... row 1 ... */
> +#define KEYP_FULL_CODE_23_16 0x0b
> +#def

Re: [patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-01-22 Thread David Brownell
From: David Brownell 

Start cleaning up the twl4030 keypad driver to become more
suitable for mainline.

 - Remove false OMAP dependencies:  names, , Kconfig
 - We don't need a miniature header file
 - Add missing input_sync()
 - Fix section annotations
 - Fix probe() error cleanup
 - Streamline i/o calls
 - Remove needless mutex; maintain key state only via irqs
 - Remove unneeded headers
 - Use "unsigned" for things that can't be negative

The driver should also be renamed as "twl4030_keypad.c"; that will
be a different patch.

Signed-off-by: David Brownell 
Reviewed-by: Trilok Soni 
---
Refresh against RC2, with feedback addressed, and also a few
deltas that had accidentally been omitted.

 arch/arm/mach-omap2/board-2430sdp.c |1 
 arch/arm/mach-omap2/board-3430sdp.c |1 
 arch/arm/mach-omap2/board-ldp.c |1 
 arch/arm/mach-omap2/board-omap2evm.c|1 
 arch/arm/mach-omap2/board-omap3evm.c|1 
 drivers/input/keyboard/Kconfig  |9 
 drivers/input/keyboard/omap-twl4030keypad.c |  300 +++---
 drivers/input/keyboard/twl4030-keypad.h |   82 ---
 include/linux/i2c/twl4030.h |   16 +
 9 files changed, 200 insertions(+), 212 deletions(-)

--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -38,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -36,7 +36,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
--- a/arch/arm/mach-omap2/board-omap2evm.c
+++ b/arch/arm/mach-omap2/board-omap2evm.c
@@ -35,7 +35,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -30,7 +30,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -260,14 +260,15 @@ config KEYBOARD_OMAP
  module will be called omap-keypad.
 
 config KEYBOARD_TWL4030
-   tristate "TI TWL4030 keypad support"
+   tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
depends on TWL4030_CORE
help
- Say Y here if you want to use the OMAP TWL4030 keypad.
+ Say Y here if your board use the keypad controller on
+ TWL4030 family chips.  It's safe to say enable this
+ even on boards that don't use the keypad controller.
 
  To compile this driver as a module, choose M here: the
- module will be called omap-twl4030keypad. This driver depends on
- TWL4030 Core and TWL4030 GPIO I2C client driver
+ module will be called twl4030_keypad.
 
 config OMAP_PS2
tristate "TI OMAP Innovator 1510 PS/2 keyboard & mouse support"
--- a/drivers/input/keyboard/omap-twl4030keypad.c
+++ b/drivers/input/keyboard/omap-twl4030keypad.c
@@ -25,50 +25,117 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 
-#include 
 
-#include "twl4030-keypad.h"
-
-#define PTV_PRESCALER  4
-
-#define MAX_ROWS   8 /* TWL4030 hardlimit */
-
-/* Global variables */
+/*
+ * The TWL4030 family chips include a keypad controller that supports
+ * up to an 8x8 switch matrix.  The controller can issue system wakeup
+ * events, since it uses only the always-on 32KiHz oscillator, and has
+ * an internal state machine that decodes pressed keys, including
+ * multi-key combinations.
+ *
+ * This driver lets boards define what keycodes they wish to report for
+ * which scancodes, as part of the "struct twl4030_keypad_data" used in
+ * the probe() routine.
+ *
+ * See the TPS65950 documentation; that's the general availability
+ * version of the TWL5030 second generation part.
+ */
+#define MAX_ROWS   8   /* TWL4030 hard limit */
 
-struct omap_keypad {
-   int *keymap;
+struct twl4030_keypad {
+   unsigned*keymap;
unsigned intkeymapsize;
u16 kp_state[MAX_ROWS];
-   int n_rows;
-   int n_cols;
-   int irq;
+   unsignedn_rows;
+   unsignedn_cols;
+   unsignedirq;
 
struct device   *dbg_dev;
-   struct input_dev *omap_twl4030kp;
-
-   /* sync read/write */
-   struct mutexmutex;
+   struct input_dev *input;
 };
 
-static int twl4030_kpread(struct omap_keypad *kp,
-   u32 module, u8 *data, u32 reg, u8 num_bytes)
+#define ROWCOL_MASKKEY(0xf, 0xf, 0)
+#define KEYNUM_MASK   

[patch 2.6.29-rc1-omap git] twl4030_keypad cleanup

2009-01-20 Thread David Brownell
From: David Brownell 

Start cleaning up the twl4030 keypad driver to become more
suitable for mainline.

 - Get rid of false OMAP dependencies:  in names, 
 - We don't need a miniature header file
 - Fix section annotations 
 - Streamline i/o calls
 - Remove needless mutex; maintain key state only via irqs
 - Remove unneeded headers
 - Use "unsigned" for things that can't be negative

The driver should also be renamed as "twl4030_keypad.c"; that'll
be a different patch.

Signed-off-by: David Brownell 
---
 arch/arm/mach-omap2/board-2430sdp.c |1 
 arch/arm/mach-omap2/board-3430sdp.c |1 
 arch/arm/mach-omap2/board-ldp.c |1 
 arch/arm/mach-omap2/board-omap2evm.c|1 
 arch/arm/mach-omap2/board-omap3evm.c|1 
 drivers/input/keyboard/omap-twl4030keypad.c |  274 --
 drivers/input/keyboard/twl4030-keypad.h |   82 ---
 include/linux/i2c/twl4030.h |8 
 8 files changed, 178 insertions(+), 191 deletions(-)

--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -38,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
--- a/arch/arm/mach-omap2/board-omap2evm.c
+++ b/arch/arm/mach-omap2/board-omap2evm.c
@@ -35,7 +35,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -30,7 +30,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
--- a/drivers/input/keyboard/omap-twl4030keypad.c
+++ b/drivers/input/keyboard/omap-twl4030keypad.c
@@ -25,30 +25,31 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 
-#include 
 
-#include "twl4030-keypad.h"
-
-#define PTV_PRESCALER  4
-
-#define MAX_ROWS   8 /* TWL4030 hardlimit */
-
-/* Global variables */
+/*
+ * The TWL4030 family chips include a keypad controller that supports
+ * up to an 8x8 switch matrix.  The controller can issue system wakeup
+ * events, since it uses only the always-on 32KiHz oscillator, and has
+ * an internal state machine that decodes pressed keys, including
+ * multi-key combinations.
+ *
+ * This driver lets boards define what keycodes they wish to report for
+ * which scancodes, as part of the "struct twl4030_keypad_data" used in
+ * the probe() routine.
+ *
+ * See the TPS65950 documentation; that's the general availability
+ * version of the TWL5030 second generation part.
+ */
+#define MAX_ROWS   8   /* TWL4030 hard limit */
 
-struct omap_keypad {
+struct twl4030_keypad {
int *keymap;
unsigned intkeymapsize;
u16 kp_state[MAX_ROWS];
@@ -57,18 +58,84 @@ struct omap_keypad {
int irq;
 
struct device   *dbg_dev;
-   struct input_dev *omap_twl4030kp;
-
-   /* sync read/write */
-   struct mutexmutex;
+   struct input_dev *input;
 };
 
-static int twl4030_kpread(struct omap_keypad *kp,
-   u32 module, u8 *data, u32 reg, u8 num_bytes)
+#define ROWCOL_MASKKEY(0xf, 0xf, 0)
+#define KEYNUM_MASK~PERSISTENT_KEY(0xf, 0xf)
+
+/*--*/
+
+/* arbitrary prescaler value 0..7 */
+#define PTV_PRESCALER  4
+
+/* Register Offsets */
+#define KEYP_CTRL  0x00
+#define KEYP_DEB   0x01
+#define KEYP_LONG_KEY  0x02
+#define KEYP_LK_PTV0x03
+#define KEYP_TIMEOUT_L 0x04
+#define KEYP_TIMEOUT_H 0x05
+#define KEYP_KBC   0x06
+#define KEYP_KBR   0x07
+#define KEYP_SMS   0x08
+#define KEYP_FULL_CODE_7_0 0x09/* row 0 column status */
+#define KEYP_FULL_CODE_15_80x0a/* ... row 1 ... */
+#define KEYP_FULL_CODE_23_16   0x0b
+#define KEYP_FULL_CODE_31_24   0x0c
+#define KEYP_FULL_CODE_39_32   0x0d
+#define KEYP_FULL_CODE_47_40   0x0e
+#define KEYP_FULL_CODE_55_48   0x0f
+#define KEYP_FULL_CODE_63_56   0x10
+#define KEYP_ISR1  0x11
+#define KEYP_IMR1  0x12
+#define KEYP_ISR2  0x13
+#define KEYP_IMR2  0x14
+#define KEYP_SIR   0x15
+#define KEYP_EDR   0x16/* edge triggers */
+#defi