aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/tca6416-keypad.c
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/input/keyboard/tca6416-keypad.c
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/input/keyboard/tca6416-keypad.c')
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c13
1 files changed, 10 insertions, 3 deletions
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