diff options
author | Tony SIM <chinyeow.sim.xt@renesas.com> | 2010-12-07 02:54:00 -0800 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-12-07 21:10:28 -0800 |
commit | b8a3d6bcbc85d7636d9f2adede8479ce2999c232 (patch) | |
tree | de14a88bbd559ad86b6eff79cbb043a795acef2b /drivers/input/keyboard/tca6416-keypad.c | |
parent | da0c490115de026618a7fdcd886602da44392a50 (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.c | 13 |
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 @@ static const struct i2c_device_id tca6416_id[] = { { "tca6416-keys", 16, }, + { "tca6408-keys", 8, }, { } }; MODULE_DEVICE_TABLE(i2c, tca6416_id); @@ -46,8 +47,9 @@ struct tca6416_keypad_chip { struct i2c_client *client; struct input_dev *input; struct delayed_work dwork; - u16 pinmask; + int io_size; int irqnum; + u16 pinmask; bool use_polling; struct tca6416_button buttons[0]; }; @@ -56,7 +58,9 @@ static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val) { int error; - error = i2c_smbus_write_word_data(chip->client, reg << 1, val); + error = chip->io_size > 8 ? + i2c_smbus_write_word_data(chip->client, reg << 1, val) : + i2c_smbus_write_byte_data(chip->client, reg, val); if (error < 0) { dev_err(&chip->client->dev, "%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) { int retval; - retval = i2c_smbus_read_word_data(chip->client, reg << 1); + retval = chip->io_size > 8 ? + i2c_smbus_read_word_data(chip->client, reg << 1) : + i2c_smbus_read_byte_data(chip->client, reg); if (retval < 0) { dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n", __func__, reg, retval); @@ -224,6 +230,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client, chip->client = client; chip->input = input; + chip->io_size = id->driver_data; chip->pinmask = pdata->pinmask; chip->use_polling = pdata->use_polling; |