Commit b8a3d6bc authored by Tony SIM's avatar Tony SIM Committed by Dmitry Torokhov

Input: tca6416-keypad - add support for tca6408a

Support 8-bit tca6408a I/O expander as a keypad.
Signed-off-by: default avatarTony SIM <chinyeow.sim.xt@renesas.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent da0c4901
...@@ -180,20 +180,22 @@ config KEYBOARD_GPIO ...@@ -180,20 +180,22 @@ config KEYBOARD_GPIO
module will be called gpio_keys. module will be called gpio_keys.
config KEYBOARD_TCA6416 config KEYBOARD_TCA6416
tristate "TCA6416 Keypad Support" tristate "TCA6416/TCA6408A Keypad Support"
depends on I2C depends on I2C
help help
This driver implements basic keypad functionality This driver implements basic keypad functionality
for keys connected through TCA6416 IO expander for keys connected through TCA6416/TCA6408A IO expanders.
Say Y here if your device has keys connected to Say Y here if your device has keys connected to
TCA6416 IO expander. Your board-specific setup logic TCA6416/TCA6408A IO expander. Your board-specific setup logic
must also provide pin-mask details(of which TCA6416 pins must also provide pin-mask details(of which TCA6416 pins
are used for keypad). are used for keypad).
If enabled the complete TCA6416 device will be managed through If enabled the entire TCA6416 device will be managed through
this driver. this driver.
To compile this driver as a module, choose M here: the
module will be called tca6416_keypad.
config KEYBOARD_MATRIX config KEYBOARD_MATRIX
tristate "GPIO driven matrix keypad support" tristate "GPIO driven matrix keypad support"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
static const struct i2c_device_id tca6416_id[] = { static const struct i2c_device_id tca6416_id[] = {
{ "tca6416-keys", 16, }, { "tca6416-keys", 16, },
{ "tca6408-keys", 8, },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, tca6416_id); MODULE_DEVICE_TABLE(i2c, tca6416_id);
...@@ -46,8 +47,9 @@ struct tca6416_keypad_chip { ...@@ -46,8 +47,9 @@ struct tca6416_keypad_chip {
struct i2c_client *client; struct i2c_client *client;
struct input_dev *input; struct input_dev *input;
struct delayed_work dwork; struct delayed_work dwork;
u16 pinmask; int io_size;
int irqnum; int irqnum;
u16 pinmask;
bool use_polling; bool use_polling;
struct tca6416_button buttons[0]; struct tca6416_button buttons[0];
}; };
...@@ -56,7 +58,9 @@ static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val) ...@@ -56,7 +58,9 @@ static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val)
{ {
int error; 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) { if (error < 0) {
dev_err(&chip->client->dev, dev_err(&chip->client->dev,
"%s failed, reg: %d, val: %d, error: %d\n", "%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,7 +75,9 @@ static int tca6416_read_reg(struct tca6416_keypad_chip *chip, int reg, u16 *val)
{ {
int retval; 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) { if (retval < 0) {
dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n", dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n",
__func__, reg, retval); __func__, reg, retval);
...@@ -224,6 +230,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client, ...@@ -224,6 +230,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client,
chip->client = client; chip->client = client;
chip->input = input; chip->input = input;
chip->io_size = id->driver_data;
chip->pinmask = pdata->pinmask; chip->pinmask = pdata->pinmask;
chip->use_polling = pdata->use_polling; chip->use_polling = pdata->use_polling;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment