Skip to content

Commit 322a552

Browse files
Mr-Bossmandtor
authored andcommitted
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 <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 5fe1151 commit 322a552

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

Documentation/devicetree/bindings/input/cap11xx.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Required properties:
99
"microchip,cap1106"
1010
"microchip,cap1126"
1111
"microchip,cap1188"
12+
"microchip,cap1206"
1213

1314
reg: The I2C slave address of the device.
1415

drivers/input/keyboard/cap11xx.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,21 @@ struct cap11xx_hw_model {
9191
u8 product_id;
9292
unsigned int num_channels;
9393
unsigned int num_leds;
94+
bool no_gain;
9495
};
9596

9697
enum {
9798
CAP1106,
9899
CAP1126,
99100
CAP1188,
101+
CAP1206,
100102
};
101103

102104
static const struct cap11xx_hw_model cap11xx_devices[] = {
103-
[CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0 },
104-
[CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2 },
105-
[CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8 },
105+
[CAP1106] = { .product_id = 0x55, .num_channels = 6, .num_leds = 0, .no_gain = false },
106+
[CAP1126] = { .product_id = 0x53, .num_channels = 6, .num_leds = 2, .no_gain = false },
107+
[CAP1188] = { .product_id = 0x50, .num_channels = 8, .num_leds = 8, .no_gain = false },
108+
[CAP1206] = { .product_id = 0x67, .num_channels = 6, .num_leds = 0, .no_gain = true },
106109
};
107110

108111
static const struct reg_default cap11xx_reg_defaults[] = {
@@ -378,17 +381,24 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
378381
node = dev->of_node;
379382

380383
if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) {
381-
if (is_power_of_2(gain32) && gain32 <= 8)
384+
if (cap->no_gain)
385+
dev_warn(dev,
386+
"This version doesn't support sensor gain\n");
387+
else if (is_power_of_2(gain32) && gain32 <= 8)
382388
gain = ilog2(gain32);
383389
else
384390
dev_err(dev, "Invalid sensor-gain value %d\n", gain32);
385391
}
386392

387-
if (of_property_read_bool(node, "microchip,irq-active-high")) {
388-
error = regmap_update_bits(priv->regmap, CAP11XX_REG_CONFIG2,
389-
CAP11XX_REG_CONFIG2_ALT_POL, 0);
390-
if (error)
391-
return error;
393+
if (id->driver_data != CAP1206) {
394+
if (of_property_read_bool(node, "microchip,irq-active-high")) {
395+
error = regmap_update_bits(priv->regmap,
396+
CAP11XX_REG_CONFIG2,
397+
CAP11XX_REG_CONFIG2_ALT_POL,
398+
0);
399+
if (error)
400+
return error;
401+
}
392402
}
393403

394404
/* Provide some useful defaults */
@@ -398,11 +408,14 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
398408
of_property_read_u32_array(node, "linux,keycodes",
399409
priv->keycodes, cap->num_channels);
400410

401-
error = regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL,
402-
CAP11XX_REG_MAIN_CONTROL_GAIN_MASK,
403-
gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT);
404-
if (error)
405-
return error;
411+
if (!cap->no_gain) {
412+
error = regmap_update_bits(priv->regmap,
413+
CAP11XX_REG_MAIN_CONTROL,
414+
CAP11XX_REG_MAIN_CONTROL_GAIN_MASK,
415+
gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT);
416+
if (error)
417+
return error;
418+
}
406419

407420
/* Disable autorepeat. The Linux input system has its own handling. */
408421
error = regmap_write(priv->regmap, CAP11XX_REG_REPEAT_RATE, 0);
@@ -470,6 +483,7 @@ static const struct of_device_id cap11xx_dt_ids[] = {
470483
{ .compatible = "microchip,cap1106", },
471484
{ .compatible = "microchip,cap1126", },
472485
{ .compatible = "microchip,cap1188", },
486+
{ .compatible = "microchip,cap1206", },
473487
{}
474488
};
475489
MODULE_DEVICE_TABLE(of, cap11xx_dt_ids);
@@ -478,6 +492,7 @@ static const struct i2c_device_id cap11xx_i2c_ids[] = {
478492
{ "cap1106", CAP1106 },
479493
{ "cap1126", CAP1126 },
480494
{ "cap1188", CAP1188 },
495+
{ "cap1206", CAP1206 },
481496
{}
482497
};
483498
MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids);

0 commit comments

Comments
 (0)