aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTony SIM <chinyeow.sim.xt@renesas.com>2010-12-07 05:54:00 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-12-08 00:10:28 -0500
commitb8a3d6bcbc85d7636d9f2adede8479ce2999c232 (patch)
treede14a88bbd559ad86b6eff79cbb043a795acef2b /drivers
parentda0c490115de026618a7fdcd886602da44392a50 (diff)
Input: tca6416-keypad - add support for tca6408a
Support 8-bit tca6408a I/O expander as a keypad. Signed-off-by: Tony SIM <chinyeow.sim.xt@renesas.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c13
2 files changed, 16 insertions, 7 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index ee85e5bf4b2a..a378e959368e 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -180,20 +180,22 @@ config KEYBOARD_GPIO
180 module will be called gpio_keys. 180 module will be called gpio_keys.
181 181
182config KEYBOARD_TCA6416 182config KEYBOARD_TCA6416
183 tristate "TCA6416 Keypad Support" 183 tristate "TCA6416/TCA6408A Keypad Support"
184 depends on I2C 184 depends on I2C
185 help 185 help
186 This driver implements basic keypad functionality 186 This driver implements basic keypad functionality
187 for keys connected through TCA6416 IO expander 187 for keys connected through TCA6416/TCA6408A IO expanders.
188 188
189 Say Y here if your device has keys connected to 189 Say Y here if your device has keys connected to
190 TCA6416 IO expander. Your board-specific setup logic 190 TCA6416/TCA6408A IO expander. Your board-specific setup logic
191 must also provide pin-mask details(of which TCA6416 pins 191 must also provide pin-mask details(of which TCA6416 pins
192 are used for keypad). 192 are used for keypad).
193 193
194 If enabled the complete TCA6416 device will be managed through 194 If enabled the entire TCA6416 device will be managed through
195 this driver. 195 this driver.
196 196
197 To compile this driver as a module, choose M here: the
198 module will be called tca6416_keypad.
197 199
198config KEYBOARD_MATRIX 200config KEYBOARD_MATRIX
199 tristate "GPIO driven matrix keypad support" 201 tristate "GPIO driven matrix keypad support"
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index 00137bebcf97..800fbccf1f0f 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -29,6 +29,7 @@
29 29
30static const struct i2c_device_id tca6416_id[] = { 30static const struct i2c_device_id tca6416_id[] = {
31 { "tca6416-keys", 16, }, 31 { "tca6416-keys", 16, },
32 { "tca6408-keys", 8, },
32 { } 33 { }
33}; 34};
34MODULE_DEVICE_TABLE(i2c, tca6416_id); 35MODULE_DEVICE_TABLE(i2c, tca6416_id);
@@ -46,8 +47,9 @@ struct tca6416_keypad_chip {
46 struct i2c_client *client; 47 struct i2c_client *client;
47 struct input_dev *input; 48 struct input_dev *input;
48 struct delayed_work dwork; 49 struct delayed_work dwork;
49 u16 pinmask; 50 int io_size;
50 int irqnum; 51 int irqnum;
52 u16 pinmask;
51 bool use_polling; 53 bool use_polling;
52 struct tca6416_button buttons[0]; 54 struct tca6416_button buttons[0];
53}; 55};
@@ -56,7 +58,9 @@ static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val)
56{ 58{
57 int error; 59 int error;
58 60
59 error = i2c_smbus_write_word_data(chip->client, reg << 1, val); 61 error = chip->io_size > 8 ?
62 i2c_smbus_write_word_data(chip->client, reg << 1, val) :
63 i2c_smbus_write_byte_data(chip->client, reg, val);
60 if (error < 0) { 64 if (error < 0) {
61 dev_err(&chip->client->dev, 65 dev_err(&chip->client->dev,
62 "%s failed, reg: %d, val: %d, error: %d\n", 66 "%s failed, reg: %d, val: %d, error: %d\n",
@@ -71,7 +75,9 @@ static int tca6416_read_reg(struct tca6416_keypad_chip *chip, int reg, u16 *val)
71{ 75{
72 int retval; 76 int retval;
73 77
74 retval = i2c_smbus_read_word_data(chip->client, reg << 1); 78 retval = chip->io_size > 8 ?
79 i2c_smbus_read_word_data(chip->client, reg << 1) :
80 i2c_smbus_read_byte_data(chip->client, reg);
75 if (retval < 0) { 81 if (retval < 0) {
76 dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n", 82 dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n",
77 __func__, reg, retval); 83 __func__, reg, retval);
@@ -224,6 +230,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client,
224 230
225 chip->client = client; 231 chip->client = client;
226 chip->input = input; 232 chip->input = input;
233 chip->io_size = id->driver_data;
227 chip->pinmask = pdata->pinmask; 234 chip->pinmask = pdata->pinmask;
228 chip->use_polling = pdata->use_polling; 235 chip->use_polling = pdata->use_polling;
229 236