Re: [PATCHv2 2/4] Input: keypad: Add smsc ece1099 keypad driver

2012-09-05 Thread Vaibhav Hiremath


On 9/5/2012 5:06 PM, Sourav Poddar wrote:
 From: G, Manjunath Kondaiah manj...@ti.com
 
 SMSC ECE1099 is a keyboard scan or GPIO expansion device.The device
 supports a keypad scan matrix of 23*8.This driver uses this
 device as a keypad driver.
 
 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Cc: Benoit Cousson b-cous...@ti.com
 Cc: Felipe Balbi ba...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Signed-off-by: G, Manjunath Kondaiah manj...@ti.com
 Signed-off-by: Sourav Poddar sourav.pod...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 ---
 Changes since v1:
  - Prevent the use of kfree since devm_kzalloc was used.
  - Use devexit around remove api
  drivers/input/keyboard/Kconfig   |   11 +
  drivers/input/keyboard/Makefile  |1 +
  drivers/input/keyboard/smsc-ece1099-keypad.c |  306 
 ++
  3 files changed, 318 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/keyboard/smsc-ece1099-keypad.c
 
 diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
 index c50fa75..2a2d374 100644
 --- a/drivers/input/keyboard/Kconfig
 +++ b/drivers/input/keyboard/Kconfig
 @@ -593,6 +593,17 @@ config KEYBOARD_TWL4030
 To compile this driver as a module, choose M here: the
 module will be called twl4030_keypad.
  
 +config KEYBOARD_SMSC
 +   tristate SMSC ECE1099 keypad support
 +   depends on I2C=y

Any specific reason behind =y

 +   help
 + Say Y here if your board use the smsc keypad controller
 + for omap5 defconfig. 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 smsc-ece1099-keypad.
 +
  config KEYBOARD_XTKBD
   tristate XT keyboard
   select SERIO
 diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
 index 44e7600..0f2aa26 100644
 --- a/drivers/input/keyboard/Makefile
 +++ b/drivers/input/keyboard/Makefile
 @@ -52,5 +52,6 @@ obj-$(CONFIG_KEYBOARD_TC3589X)  += 
 tc3589x-keypad.o
  obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o
  obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o
  obj-$(CONFIG_KEYBOARD_TWL4030)   += twl4030_keypad.o
 +obj-$(CONFIG_KEYBOARD_SMSC)+= smsc-ece1099-keypad.o
  obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
  obj-$(CONFIG_KEYBOARD_W90P910)   += w90p910_keypad.o
 diff --git a/drivers/input/keyboard/smsc-ece1099-keypad.c 
 b/drivers/input/keyboard/smsc-ece1099-keypad.c
 new file mode 100644
 index 000..71cd7d6
 --- /dev/null
 +++ b/drivers/input/keyboard/smsc-ece1099-keypad.c
 @@ -0,0 +1,306 @@
 +/*
 + * SMSC_ECE1099 Keypad driver
 + *
 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/i2c.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/init.h
 +#include linux/interrupt.h
 +#include linux/input.h
 +#include linux/gpio.h
 +#include linux/slab.h
 +#include linux/jiffies.h
 +#include linux/input/matrix_keypad.h
 +#include linux/delay.h
 +#include linux/mfd/core.h
 +#include linux/mfd/smsc.h
 +#include linux/of_gpio.h
 +#include linux/of.h
 +
 +#define KEYPRESS_TIME  200
 +
 +struct smsc_keypad {
 + struct smsc *smsc;
 + struct matrix_keymap_data *keymap_data;
 + unsigned int last_key_state[16];
 + unsigned int last_col;
 + unsigned int last_key_ms[16];
 + unsigned short *keymap;
 + struct i2c_client *client;
 + struct input_dev *input;
 + int rows, cols;
 + int row_shift;
 + bool no_autorepeat;
 + unsignedirq;
 + struct device *dev;
 +};
 +
 +static void smsc_kp_scan(struct smsc_keypad *kp)
 +{
 + struct input_dev *input = kp-input;
 + int i, j;
 + int row, col;
 + int temp, code;
 + unsigned int new_state[16];
 + unsigned int bits_changed;
 + int this_ms;
 +
 + smsc_write(kp-dev, SMSC_KP_INT_MASK, 0x00);
 + smsc_write(kp-dev, SMSC_KP_INT_STAT, 0xFF);
 +
 + /* Scan for row and column */
 + for (i = 0; i  kp-cols; i++) {
 + smsc_write(kp-dev, SMSC_KP_OUT, SMSC_KSO_EVAL + i);
 + /* Read Row Status */
 + smsc_read(kp-dev, SMSC_KP_IN, temp);
 + if (temp == 0xFF)
 + continue;
 +
 + col = i;
 + for (j = 0; j  kp-rows; j++) {
 + if ((temp  0x01) != 0x00) {
 + temp = temp  1;
 + continue;
 + }
 +
 + row = j;
 + new_state[col] =  (1  row);
 + bits_changed = kp-last_key_state[col] ^ new_state[col];
 + 

Re: [PATCHv2 2/4] Input: keypad: Add smsc ece1099 keypad driver

2012-09-05 Thread Poddar, Sourav
+ other external mailing list (did a reply to by mistake)

On Thu, Sep 6, 2012 at 11:04 AM, Poddar, Sourav sourav.pod...@ti.com wrote:
 Hi Vaibhav,

 On Thu, Sep 6, 2012 at 12:01 AM, Vaibhav Hiremath hvaib...@ti.com wrote:


 On 9/5/2012 5:06 PM, Sourav Poddar wrote:
 From: G, Manjunath Kondaiah manj...@ti.com

 SMSC ECE1099 is a keyboard scan or GPIO expansion device.The device
 supports a keypad scan matrix of 23*8.This driver uses this
 device as a keypad driver.

 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Cc: Benoit Cousson b-cous...@ti.com
 Cc: Felipe Balbi ba...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Signed-off-by: G, Manjunath Kondaiah manj...@ti.com
 Signed-off-by: Sourav Poddar sourav.pod...@ti.com
 Acked-by: Felipe Balbi ba...@ti.com
 ---
 Changes since v1:
  - Prevent the use of kfree since devm_kzalloc was used.
  - Use devexit around remove api
  drivers/input/keyboard/Kconfig   |   11 +
  drivers/input/keyboard/Makefile  |1 +
  drivers/input/keyboard/smsc-ece1099-keypad.c |  306 
 ++
  3 files changed, 318 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/keyboard/smsc-ece1099-keypad.c

 diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
 index c50fa75..2a2d374 100644
 --- a/drivers/input/keyboard/Kconfig
 +++ b/drivers/input/keyboard/Kconfig
 @@ -593,6 +593,17 @@ config KEYBOARD_TWL4030
 To compile this driver as a module, choose M here: the
 module will be called twl4030_keypad.

 +config KEYBOARD_SMSC
 +   tristate SMSC ECE1099 keypad support
 +   depends on I2C=y

 Any specific reason behind =y

 Nope, my bad..=y should be dropped.
 +   help
 + Say Y here if your board use the smsc keypad controller
 + for omap5 defconfig. 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 smsc-ece1099-keypad.
 +
  config KEYBOARD_XTKBD
   tristate XT keyboard
   select SERIO
 diff --git a/drivers/input/keyboard/Makefile 
 b/drivers/input/keyboard/Makefile
 index 44e7600..0f2aa26 100644
 --- a/drivers/input/keyboard/Makefile
 +++ b/drivers/input/keyboard/Makefile
 @@ -52,5 +52,6 @@ obj-$(CONFIG_KEYBOARD_TC3589X)  += 
 tc3589x-keypad.o
  obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o
  obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o
  obj-$(CONFIG_KEYBOARD_TWL4030)   += twl4030_keypad.o
 +obj-$(CONFIG_KEYBOARD_SMSC)+= smsc-ece1099-keypad.o
  obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
  obj-$(CONFIG_KEYBOARD_W90P910)   += w90p910_keypad.o
 diff --git a/drivers/input/keyboard/smsc-ece1099-keypad.c 
 b/drivers/input/keyboard/smsc-ece1099-keypad.c
 new file mode 100644
 index 000..71cd7d6
 --- /dev/null
 +++ b/drivers/input/keyboard/smsc-ece1099-keypad.c
 @@ -0,0 +1,306 @@
 +/*
 + * SMSC_ECE1099 Keypad driver
 + *
 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/i2c.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/init.h
 +#include linux/interrupt.h
 +#include linux/input.h
 +#include linux/gpio.h
 +#include linux/slab.h
 +#include linux/jiffies.h
 +#include linux/input/matrix_keypad.h
 +#include linux/delay.h
 +#include linux/mfd/core.h
 +#include linux/mfd/smsc.h
 +#include linux/of_gpio.h
 +#include linux/of.h
 +
 +#define KEYPRESS_TIME  200
 +
 +struct smsc_keypad {
 + struct smsc *smsc;
 + struct matrix_keymap_data *keymap_data;
 + unsigned int last_key_state[16];
 + unsigned int last_col;
 + unsigned int last_key_ms[16];
 + unsigned short *keymap;
 + struct i2c_client *client;
 + struct input_dev *input;
 + int rows, cols;
 + int row_shift;
 + bool no_autorepeat;
 + unsignedirq;
 + struct device *dev;
 +};
 +
 +static void smsc_kp_scan(struct smsc_keypad *kp)
 +{
 + struct input_dev *input = kp-input;
 + int i, j;
 + int row, col;
 + int temp, code;
 + unsigned int new_state[16];
 + unsigned int bits_changed;
 + int this_ms;
 +
 + smsc_write(kp-dev, SMSC_KP_INT_MASK, 0x00);
 + smsc_write(kp-dev, SMSC_KP_INT_STAT, 0xFF);
 +
 + /* Scan for row and column */
 + for (i = 0; i  kp-cols; i++) {
 + smsc_write(kp-dev, SMSC_KP_OUT, SMSC_KSO_EVAL + i);
 + /* Read Row Status */
 + smsc_read(kp-dev, SMSC_KP_IN, temp);
 + if (temp == 0xFF)
 + continue;
 +
 + col = i;
 + for (j = 0; j  kp-rows; j++) {
 + if ((temp  0x01) != 0x00) {
 +