Commit 322a552e authored by Jesse Taube's avatar Jesse Taube Committed by Dmitry Torokhov

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: default avatarJesse Taube <mr.bossman075@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 5fe11512
...@@ -9,6 +9,7 @@ Required properties: ...@@ -9,6 +9,7 @@ Required properties:
"microchip,cap1106" "microchip,cap1106"
"microchip,cap1126" "microchip,cap1126"
"microchip,cap1188" "microchip,cap1188"
"microchip,cap1206"
reg: The I2C slave address of the device. reg: The I2C slave address of the device.
......
...@@ -91,18 +91,21 @@ struct cap11xx_hw_model { ...@@ -91,18 +91,21 @@ struct cap11xx_hw_model {
u8 product_id; u8 product_id;
unsigned int num_channels; unsigned int num_channels;
unsigned int num_leds; unsigned int num_leds;
bool no_gain;
}; };
enum { enum {
CAP1106, CAP1106,
CAP1126, CAP1126,
CAP1188, CAP1188,
CAP1206,
}; };
static const struct cap11xx_hw_model cap11xx_devices[] = { static const struct cap11xx_hw_model cap11xx_devices[] = {
[CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0 }, [CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0, .no_gain = false },
[CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2 }, [CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2, .no_gain = false },
[CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8 }, [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[] = { static const struct reg_default cap11xx_reg_defaults[] = {
...@@ -378,17 +381,24 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client, ...@@ -378,17 +381,24 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
node = dev->of_node; node = dev->of_node;
if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) { 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); gain = ilog2(gain32);
else else
dev_err(dev, "Invalid sensor-gain value %d\n", gain32); dev_err(dev, "Invalid sensor-gain value %d\n", gain32);
} }
if (of_property_read_bool(node, "microchip,irq-active-high")) { if (id->driver_data != CAP1206) {
error = regmap_update_bits(priv->regmap, CAP11XX_REG_CONFIG2, if (of_property_read_bool(node, "microchip,irq-active-high")) {
CAP11XX_REG_CONFIG2_ALT_POL, 0); error = regmap_update_bits(priv->regmap,
if (error) CAP11XX_REG_CONFIG2,
return error; CAP11XX_REG_CONFIG2_ALT_POL,
0);
if (error)
return error;
}
} }
/* Provide some useful defaults */ /* Provide some useful defaults */
...@@ -398,11 +408,14 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client, ...@@ -398,11 +408,14 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
of_property_read_u32_array(node, "linux,keycodes", of_property_read_u32_array(node, "linux,keycodes",
priv->keycodes, cap->num_channels); priv->keycodes, cap->num_channels);
error = regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL, if (!cap->no_gain) {
CAP11XX_REG_MAIN_CONTROL_GAIN_MASK, error = regmap_update_bits(priv->regmap,
gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT); CAP11XX_REG_MAIN_CONTROL,
if (error) CAP11XX_REG_MAIN_CONTROL_GAIN_MASK,
return error; gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT);
if (error)
return error;
}
/* Disable autorepeat. The Linux input system has its own handling. */ /* Disable autorepeat. The Linux input system has its own handling. */
error = regmap_write(priv->regmap, CAP11XX_REG_REPEAT_RATE, 0); error = regmap_write(priv->regmap, CAP11XX_REG_REPEAT_RATE, 0);
...@@ -470,6 +483,7 @@ static const struct of_device_id cap11xx_dt_ids[] = { ...@@ -470,6 +483,7 @@ static const struct of_device_id cap11xx_dt_ids[] = {
{ .compatible = "microchip,cap1106", }, { .compatible = "microchip,cap1106", },
{ .compatible = "microchip,cap1126", }, { .compatible = "microchip,cap1126", },
{ .compatible = "microchip,cap1188", }, { .compatible = "microchip,cap1188", },
{ .compatible = "microchip,cap1206", },
{} {}
}; };
MODULE_DEVICE_TABLE(of, cap11xx_dt_ids); MODULE_DEVICE_TABLE(of, cap11xx_dt_ids);
...@@ -478,6 +492,7 @@ static const struct i2c_device_id cap11xx_i2c_ids[] = { ...@@ -478,6 +492,7 @@ static const struct i2c_device_id cap11xx_i2c_ids[] = {
{ "cap1106", CAP1106 }, { "cap1106", CAP1106 },
{ "cap1126", CAP1126 }, { "cap1126", CAP1126 },
{ "cap1188", CAP1188 }, { "cap1188", CAP1188 },
{ "cap1206", CAP1206 },
{} {}
}; };
MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids); MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids);
......
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