Commit 1cdbd3e5 authored by Jonathan Bakker's avatar Jonathan Bakker Committed by Dmitry Torokhov

Input: tm2-touchkey - add support for aries touchkey variant

The touchkey variant found on aries board is slighty different,
it uses a fixed regulator and writes/read to the same place
Signed-off-by: default avatarJonathan Bakker <xc-racer2@live.ca>
Signed-off-by: default avatarPaweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 07df1c55
...@@ -4,6 +4,7 @@ Required properties: ...@@ -4,6 +4,7 @@ Required properties:
- compatible: - compatible:
* "cypress,tm2-touchkey" - for the touchkey found on the tm2 board * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
* "cypress,midas-touchkey" - for the touchkey found on midas boards * "cypress,midas-touchkey" - for the touchkey found on midas boards
* "cypress,aries-touchkey" - for the touchkey found on aries boards
- reg: I2C address of the chip. - reg: I2C address of the chip.
- interrupt-parent: a phandle for the interrupt controller (see interrupt - interrupt-parent: a phandle for the interrupt controller (see interrupt
binding[0]). binding[0]).
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey" #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
#define ARIES_TOUCHKEY_CMD_LED_ON 0x1
#define ARIES_TOUCHKEY_CMD_LED_OFF 0x2
#define TM2_TOUCHKEY_CMD_LED_ON 0x10 #define TM2_TOUCHKEY_CMD_LED_ON 0x10
#define TM2_TOUCHKEY_CMD_LED_OFF 0x20 #define TM2_TOUCHKEY_CMD_LED_OFF 0x20
#define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3) #define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3)
...@@ -38,6 +40,10 @@ ...@@ -38,6 +40,10 @@
struct touchkey_variant { struct touchkey_variant {
u8 keycode_reg; u8 keycode_reg;
u8 base_reg; u8 base_reg;
u8 cmd_led_on;
u8 cmd_led_off;
bool no_reg;
bool fixed_regulator;
}; };
struct tm2_touchkey_data { struct tm2_touchkey_data {
...@@ -54,11 +60,22 @@ struct tm2_touchkey_data { ...@@ -54,11 +60,22 @@ struct tm2_touchkey_data {
static const struct touchkey_variant tm2_touchkey_variant = { static const struct touchkey_variant tm2_touchkey_variant = {
.keycode_reg = 0x03, .keycode_reg = 0x03,
.base_reg = 0x00, .base_reg = 0x00,
.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
}; };
static const struct touchkey_variant midas_touchkey_variant = { static const struct touchkey_variant midas_touchkey_variant = {
.keycode_reg = 0x00, .keycode_reg = 0x00,
.base_reg = 0x00, .base_reg = 0x00,
.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
};
static struct touchkey_variant aries_touchkey_variant = {
.no_reg = true,
.fixed_regulator = true,
.cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF,
}; };
static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
...@@ -71,15 +88,20 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, ...@@ -71,15 +88,20 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
if (brightness == LED_OFF) { if (brightness == LED_OFF) {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN; volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
data = TM2_TOUCHKEY_CMD_LED_OFF; data = touchkey->variant->cmd_led_off;
} else { } else {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX; volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
data = TM2_TOUCHKEY_CMD_LED_ON; data = touchkey->variant->cmd_led_on;
} }
regulator_set_voltage(touchkey->vdd, volt, volt); if (!touchkey->variant->fixed_regulator)
i2c_smbus_write_byte_data(touchkey->client, regulator_set_voltage(touchkey->vdd, volt, volt);
touchkey->variant->base_reg, data);
if (touchkey->variant->no_reg)
i2c_smbus_write_byte(touchkey->client, data);
else
i2c_smbus_write_byte_data(touchkey->client,
touchkey->variant->base_reg, data);
} }
static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
...@@ -112,8 +134,11 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) ...@@ -112,8 +134,11 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
int index; int index;
int i; int i;
data = i2c_smbus_read_byte_data(touchkey->client, if (touchkey->variant->no_reg)
touchkey->variant->keycode_reg); data = i2c_smbus_read_byte(touchkey->client);
else
data = i2c_smbus_read_byte_data(touchkey->client,
touchkey->variant->keycode_reg);
if (data < 0) { if (data < 0) {
dev_err(&touchkey->client->dev, dev_err(&touchkey->client->dev,
"failed to read i2c data: %d\n", data); "failed to read i2c data: %d\n", data);
...@@ -139,6 +164,14 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) ...@@ -139,6 +164,14 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
input_sync(touchkey->input_dev); input_sync(touchkey->input_dev);
out: out:
if (touchkey->variant->fixed_regulator &&
data & TM2_TOUCHKEY_BIT_PRESS_EV) {
/* touch turns backlight on, so make sure we're in sync */
if (touchkey->led_dev.brightness == LED_OFF)
tm2_touchkey_led_brightness_set(&touchkey->led_dev,
LED_OFF);
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -246,6 +279,9 @@ static int tm2_touchkey_probe(struct i2c_client *client, ...@@ -246,6 +279,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
return error; return error;
} }
if (touchkey->variant->fixed_regulator)
tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON);
return 0; return 0;
} }
...@@ -291,6 +327,9 @@ static const struct of_device_id tm2_touchkey_of_match[] = { ...@@ -291,6 +327,9 @@ static const struct of_device_id tm2_touchkey_of_match[] = {
}, { }, {
.compatible = "cypress,midas-touchkey", .compatible = "cypress,midas-touchkey",
.data = &midas_touchkey_variant, .data = &midas_touchkey_variant,
}, {
.compatible = "cypress,aries-touchkey",
.data = &aries_touchkey_variant,
}, },
{ }, { },
}; };
......
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