@@ -91,18 +91,21 @@ struct cap11xx_hw_model {
91
91
u8 product_id ;
92
92
unsigned int num_channels ;
93
93
unsigned int num_leds ;
94
+ bool no_gain ;
94
95
};
95
96
96
97
enum {
97
98
CAP1106 ,
98
99
CAP1126 ,
99
100
CAP1188 ,
101
+ CAP1206 ,
100
102
};
101
103
102
104
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 },
106
109
};
107
110
108
111
static const struct reg_default cap11xx_reg_defaults [] = {
@@ -378,17 +381,24 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
378
381
node = dev -> of_node ;
379
382
380
383
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 )
382
388
gain = ilog2 (gain32 );
383
389
else
384
390
dev_err (dev , "Invalid sensor-gain value %d\n" , gain32 );
385
391
}
386
392
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
+ }
392
402
}
393
403
394
404
/* Provide some useful defaults */
@@ -398,11 +408,14 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
398
408
of_property_read_u32_array (node , "linux,keycodes" ,
399
409
priv -> keycodes , cap -> num_channels );
400
410
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
+ }
406
419
407
420
/* Disable autorepeat. The Linux input system has its own handling. */
408
421
error = regmap_write (priv -> regmap , CAP11XX_REG_REPEAT_RATE , 0 );
@@ -470,6 +483,7 @@ static const struct of_device_id cap11xx_dt_ids[] = {
470
483
{ .compatible = "microchip,cap1106" , },
471
484
{ .compatible = "microchip,cap1126" , },
472
485
{ .compatible = "microchip,cap1188" , },
486
+ { .compatible = "microchip,cap1206" , },
473
487
{}
474
488
};
475
489
MODULE_DEVICE_TABLE (of , cap11xx_dt_ids );
@@ -478,6 +492,7 @@ static const struct i2c_device_id cap11xx_i2c_ids[] = {
478
492
{ "cap1106" , CAP1106 },
479
493
{ "cap1126" , CAP1126 },
480
494
{ "cap1188" , CAP1188 },
495
+ { "cap1206" , CAP1206 },
481
496
{}
482
497
};
483
498
MODULE_DEVICE_TABLE (i2c , cap11xx_i2c_ids );
0 commit comments