]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
I2C: TWL4030 keyboard driver enhancements
authorKlaus Pedersen <klaus.k.pedersen@nokia.com>
Wed, 2 Apr 2008 08:42:29 +0000 (11:42 +0300)
committerTony Lindgren <tony@atomide.com>
Wed, 2 Apr 2008 09:37:34 +0000 (12:37 +0300)
commit48d162206e908e4a0cc93aaa62eb93abbad3f785
treeda815637c7e7808a253f6c7625d2938cb1b5b9b2
parent7d414b71036cb803893bcd0a7ed12dfb337f38ff
I2C: TWL4030 keyboard driver enhancements

While getting trying to get the keyboard driver to accept my
keyboard layout I found and fixed a few bugs.

- Fixed the driver to respect the matrix size and .rep
  fields from "struct omap_kp_platform_data"

- Fixed misc. configuration problems.

- Fixed some problems with the interrupt/polling code by
  implementing 100% event driven scan handling (there
  was a race between the timer and interrupt initiated
  calls to twl_4030_kp_scan()).

- Too many interrupts was delivered -> enable "PENDING_DISABLE".

- The controller would hang with keys stuck on -> program
  KEYP_TIMEOUT so sensible timeout.

Other enhancements:

- Simple ghost key suppression.
- Support for non-matrix switches. That is switches connected
  between GND and a row.

To configure the driver for the non-matrix switches you add the
key as you normally would, but the col-index will have to be the
same value as the col-size.

For example with .cols = 2 and you will use the value "2" for
COL for the two non-matrix switches:

static int rocket_control_keymap[] = {
/* COL ROW */
KEY(0,  0, KEY_3),
KEY(0,  1, KEY_2),
KEY(1,  0, KEY_1),
KEY(1,  1, KEY_LAUNCH),
KEY(2,  0, KEY_ABORT),
KEY(2,  1, KEY_SD),
0
}

Cleanup:

I might have gone too far when fixing the twl4030-keypad.h file,
but I was loosing breath and attention spelling my way through
these 32+ letter identifiers with names like:

    BIT_KEYP_CTRL_REG_TOLE_EN_MASK

which is a bit in the register:

   REG_KEYP_CTRL_REG

leading to statements like:

   twl4030_kpwrite_u8(TWL4030_MODULE_KEYPAD,
           BIT_KEYP_CTRL_REG_TOLE_EN_MASK, REG_KEYP_CTRL_REG);

What I did was to take out all the redundant stuff like BIT, REG
and MASK, making reading a little easier:

   twl4030_kpwrite_u8(TWL4030_MODULE_KEYPAD,
                      KEYP_CTRL_TOLE_EN, KEYP_CTRL);

There was a lot of configuration stuff in header file that wasn't
really needed. I think I even found a joke:

.h had this line:
   #define BIT_PTV_REG_PTV4                       (0x4)

.c had this:
       /* Set Pre Scalar Field PTV to 4 */
       reg = BIT_LK_PTV_REG_PTV_MASK & (BIT_PTV_REG_PTV4 << BIT_LK_PTV_REG_PTV);

Signed-off-by: Klaus Pedersen <klaus.k.pedersen@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/input/keyboard/omap-twl4030keypad.c
drivers/input/keyboard/twl4030-keypad.h