From 322a552e19550872eb9f3a54330a5f615db42916 Mon Sep 17 00:00:00 2001 From: Jesse Taube Date: Tue, 2 Nov 2021 16:55:49 -0700 Subject: Input: cap11xx - add support for cap1206 According to the datasheet "The CAP1206 is pin- and register-compatible with the CAP1106, with the exception of the GAIN[1:0] bits and ALT_POL bit"(57). So, this patch aims to disable them as they are no longer used. Signed-off-by: Jesse Taube Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/cap11xx.c | 43 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'drivers/input') diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c index 688e2bef682e..7c85343cd32f 100644 --- a/drivers/input/keyboard/cap11xx.c +++ b/drivers/input/keyboard/cap11xx.c @@ -91,18 +91,21 @@ struct cap11xx_hw_model { u8 product_id; unsigned int num_channels; unsigned int num_leds; + bool no_gain; }; enum { CAP1106, CAP1126, CAP1188, + CAP1206, }; static const struct cap11xx_hw_model cap11xx_devices[] = { - [CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0 }, - [CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2 }, - [CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8 }, + [CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0, .no_gain = false }, + [CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2, .no_gain = false }, + [CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8, .no_gain = false }, + [CAP1206] = { .product_id = 0x67, .num_channels = 6, .num_leds = 0, .no_gain = true }, }; static const struct reg_default cap11xx_reg_defaults[] = { @@ -378,17 +381,24 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client, node = dev->of_node; if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) { - if (is_power_of_2(gain32) && gain32 <= 8) + if (cap->no_gain) + dev_warn(dev, + "This version doesn't support sensor gain\n"); + else if (is_power_of_2(gain32) && gain32 <= 8) gain = ilog2(gain32); else dev_err(dev, "Invalid sensor-gain value %d\n", gain32); } - if (of_property_read_bool(node, "microchip,irq-active-high")) { - error = regmap_update_bits(priv->regmap, CAP11XX_REG_CONFIG2, - CAP11XX_REG_CONFIG2_ALT_POL, 0); - if (error) - return error; + if (id->driver_data != CAP1206) { + if (of_property_read_bool(node, "microchip,irq-active-high")) { + error = regmap_update_bits(priv->regmap, + CAP11XX_REG_CONFIG2, + CAP11XX_REG_CONFIG2_ALT_POL, + 0); + if (error) + return error; + } } /* Provide some useful defaults */ @@ -398,11 +408,14 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client, of_property_read_u32_array(node, "linux,keycodes", priv->keycodes, cap->num_channels); - error = regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL, - CAP11XX_REG_MAIN_CONTROL_GAIN_MASK, - gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT); - if (error) - return error; + if (!cap->no_gain) { + error = regmap_update_bits(priv->regmap, + CAP11XX_REG_MAIN_CONTROL, + CAP11XX_REG_MAIN_CONTROL_GAIN_MASK, + gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT); + if (error) + return error; + } /* Disable autorepeat. The Linux input system has its own handling. */ error = regmap_write(priv->regmap, CAP11XX_REG_REPEAT_RATE, 0); @@ -470,6 +483,7 @@ static const struct of_device_id cap11xx_dt_ids[] = { { .compatible = "microchip,cap1106", }, { .compatible = "microchip,cap1126", }, { .compatible = "microchip,cap1188", }, + { .compatible = "microchip,cap1206", }, {} }; MODULE_DEVICE_TABLE(of, cap11xx_dt_ids); @@ -478,6 +492,7 @@ static const struct i2c_device_id cap11xx_i2c_ids[] = { { "cap1106", CAP1106 }, { "cap1126", CAP1126 }, { "cap1188", CAP1188 }, + { "cap1206", CAP1206 }, {} }; MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids); -- cgit v1.2.3-59-g8ed1b