2023-01-03 13:51:29

by Jiri Valek - 2N

[permalink] [raw]
Subject: [PATCH 0/2] Input: cap11xx add support for cap1203, cap1293 and cap1298

PATCH 1 - add compatible string for new models
PATCH 2 - add support for new models into driver

Jiri Valek - 2N (2):
dt-bindings: input: microchip,cap11xx: add cap1203, cap1293 and
cap1298
Input: cap11xx - add support for cap1203, cap1293 and cap1298

.../bindings/input/microchip,cap11xx.yaml | 3 +++
drivers/input/keyboard/cap11xx.c | 20 +++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)

--
2.25.1


2023-01-03 14:01:31

by Jiri Valek - 2N

[permalink] [raw]
Subject: [PATCH 1/2] dt-bindings: input: microchip,cap11xx: add cap1203, cap1293 and cap1298

Add support for cap1203, cap1293 and cap1298.

Signed-off-by: Jiri Valek - 2N <[email protected]>
---
Documentation/devicetree/bindings/input/microchip,cap11xx.yaml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml b/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
index 67d4d8f86a2d..08ca993b94c4 100644
--- a/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
+++ b/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
@@ -20,6 +20,9 @@ properties:
- microchip,cap1126
- microchip,cap1188
- microchip,cap1206
+ - microchip,cap1203
+ - microchip,cap1293
+ - microchip,cap1298

reg:
maxItems: 1
--
2.25.1

2023-01-03 14:04:03

by Jiri Valek - 2N

[permalink] [raw]
Subject: [PATCH 2/2] Input: cap11xx - add support for cap1203, cap1293 and cap1298

Add basic support for more CAP1xxx sensors.
All models from CAP1xxx family are register-compatible.
Some advanced features are not used and disabled by default.

Signed-off-by: Jiri Valek - 2N <[email protected]>
---
drivers/input/keyboard/cap11xx.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
index 79afd0386e3f..ae226fb4fabd 100644
--- a/drivers/input/keyboard/cap11xx.c
+++ b/drivers/input/keyboard/cap11xx.c
@@ -99,6 +99,9 @@ enum {
CAP1126,
CAP1188,
CAP1206,
+ CAP1203,
+ CAP1293,
+ CAP1298
};

static const struct cap11xx_hw_model cap11xx_devices[] = {
@@ -106,6 +109,9 @@ static const struct cap11xx_hw_model cap11xx_devices[] = {
[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 },
+ [CAP1203] = { .product_id = 0x6d, .num_channels = 3, .num_leds = 0, .no_gain = true },
+ [CAP1293] = { .product_id = 0x6f, .num_channels = 3, .num_leds = 0, .no_gain = false },
+ [CAP1298] = { .product_id = 0x71, .num_channels = 8, .num_leds = 0, .no_gain = false },
};

static const struct reg_default cap11xx_reg_defaults[] = {
@@ -377,7 +383,8 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
if (error < 0)
return error;

- dev_info(dev, "CAP11XX detected, revision 0x%02x\n", rev);
+ dev_info(dev, "CAP11XX detected, model %s, revision 0x%02x\n",
+ id->name, rev);
node = dev->of_node;

if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) {
@@ -390,7 +397,10 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
dev_err(dev, "Invalid sensor-gain value %d\n", gain32);
}

- if (id->driver_data != CAP1206) {
+ if ((id->driver_data != CAP1206) ||
+ (id->driver_data != CAP1203) ||
+ (id->driver_data != CAP1293) ||
+ (id->driver_data != CAP1298)) {
if (of_property_read_bool(node, "microchip,irq-active-high")) {
error = regmap_update_bits(priv->regmap,
CAP11XX_REG_CONFIG2,
@@ -484,6 +494,9 @@ static const struct of_device_id cap11xx_dt_ids[] = {
{ .compatible = "microchip,cap1126", },
{ .compatible = "microchip,cap1188", },
{ .compatible = "microchip,cap1206", },
+ { .compatible = "microchip,cap1203", },
+ { .compatible = "microchip,cap1293", },
+ { .compatible = "microchip,cap1298", },
{}
};
MODULE_DEVICE_TABLE(of, cap11xx_dt_ids);
@@ -493,6 +506,9 @@ static const struct i2c_device_id cap11xx_i2c_ids[] = {
{ "cap1126", CAP1126 },
{ "cap1188", CAP1188 },
{ "cap1206", CAP1206 },
+ { "cap1203", CAP1203 },
+ { "cap1293", CAP1293 },
+ { "cap1298", CAP1298 },
{}
};
MODULE_DEVICE_TABLE(i2c, cap11xx_i2c_ids);
--
2.25.1

2023-01-04 04:57:54

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] Input: cap11xx - add support for cap1203, cap1293 and cap1298

Hi Jiri,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on dtor-input/next]
[also build test WARNING on dtor-input/for-linus krzk-dt/for-next robh/for-next linus/master v6.2-rc2 next-20221226]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jiri-Valek-2N/dt-bindings-input-microchip-cap11xx-add-cap1203-cap1293-and-cap1298/20230103-214328
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20230103134105.736346-3-jiriv%40axis.com
patch subject: [PATCH 2/2] Input: cap11xx - add support for cap1203, cap1293 and cap1298
config: x86_64-randconfig-a014-20230102
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/e3f771deec5bca758424af619e7e322a3c6f3d1e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jiri-Valek-2N/dt-bindings-input-microchip-cap11xx-add-cap1203-cap1293-and-cap1298/20230103-214328
git checkout e3f771deec5bca758424af619e7e322a3c6f3d1e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/input/keyboard/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/input/keyboard/cap11xx.c:400:35: warning: overlapping comparisons always evaluate to true [-Wtautological-overlap-compare]
if ((id->driver_data != CAP1206) ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
1 warning generated.


vim +400 drivers/input/keyboard/cap11xx.c

329
330 static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
331 {
332 const struct i2c_device_id *id = i2c_client_get_device_id(i2c_client);
333 struct device *dev = &i2c_client->dev;
334 struct cap11xx_priv *priv;
335 struct device_node *node;
336 const struct cap11xx_hw_model *cap;
337 int i, error, irq, gain = 0;
338 unsigned int val, rev;
339 u32 gain32;
340
341 if (id->driver_data >= ARRAY_SIZE(cap11xx_devices)) {
342 dev_err(dev, "Invalid device ID %lu\n", id->driver_data);
343 return -EINVAL;
344 }
345
346 cap = &cap11xx_devices[id->driver_data];
347 if (!cap || !cap->num_channels) {
348 dev_err(dev, "Invalid device configuration\n");
349 return -EINVAL;
350 }
351
352 priv = devm_kzalloc(dev,
353 struct_size(priv, keycodes, cap->num_channels),
354 GFP_KERNEL);
355 if (!priv)
356 return -ENOMEM;
357
358 priv->regmap = devm_regmap_init_i2c(i2c_client, &cap11xx_regmap_config);
359 if (IS_ERR(priv->regmap))
360 return PTR_ERR(priv->regmap);
361
362 error = regmap_read(priv->regmap, CAP11XX_REG_PRODUCT_ID, &val);
363 if (error)
364 return error;
365
366 if (val != cap->product_id) {
367 dev_err(dev, "Product ID: Got 0x%02x, expected 0x%02x\n",
368 val, cap->product_id);
369 return -ENXIO;
370 }
371
372 error = regmap_read(priv->regmap, CAP11XX_REG_MANUFACTURER_ID, &val);
373 if (error)
374 return error;
375
376 if (val != CAP11XX_MANUFACTURER_ID) {
377 dev_err(dev, "Manufacturer ID: Got 0x%02x, expected 0x%02x\n",
378 val, CAP11XX_MANUFACTURER_ID);
379 return -ENXIO;
380 }
381
382 error = regmap_read(priv->regmap, CAP11XX_REG_REVISION, &rev);
383 if (error < 0)
384 return error;
385
386 dev_info(dev, "CAP11XX detected, model %s, revision 0x%02x\n",
387 id->name, rev);
388 node = dev->of_node;
389
390 if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) {
391 if (cap->no_gain)
392 dev_warn(dev,
393 "This version doesn't support sensor gain\n");
394 else if (is_power_of_2(gain32) && gain32 <= 8)
395 gain = ilog2(gain32);
396 else
397 dev_err(dev, "Invalid sensor-gain value %d\n", gain32);
398 }
399
> 400 if ((id->driver_data != CAP1206) ||
401 (id->driver_data != CAP1203) ||
402 (id->driver_data != CAP1293) ||
403 (id->driver_data != CAP1298)) {
404 if (of_property_read_bool(node, "microchip,irq-active-high")) {
405 error = regmap_update_bits(priv->regmap,
406 CAP11XX_REG_CONFIG2,
407 CAP11XX_REG_CONFIG2_ALT_POL,
408 0);
409 if (error)
410 return error;
411 }
412 }
413
414 /* Provide some useful defaults */
415 for (i = 0; i < cap->num_channels; i++)
416 priv->keycodes[i] = KEY_A + i;
417
418 of_property_read_u32_array(node, "linux,keycodes",
419 priv->keycodes, cap->num_channels);
420
421 if (!cap->no_gain) {
422 error = regmap_update_bits(priv->regmap,
423 CAP11XX_REG_MAIN_CONTROL,
424 CAP11XX_REG_MAIN_CONTROL_GAIN_MASK,
425 gain << CAP11XX_REG_MAIN_CONTROL_GAIN_SHIFT);
426 if (error)
427 return error;
428 }
429
430 /* Disable autorepeat. The Linux input system has its own handling. */
431 error = regmap_write(priv->regmap, CAP11XX_REG_REPEAT_RATE, 0);
432 if (error)
433 return error;
434
435 priv->idev = devm_input_allocate_device(dev);
436 if (!priv->idev)
437 return -ENOMEM;
438
439 priv->idev->name = "CAP11XX capacitive touch sensor";
440 priv->idev->id.bustype = BUS_I2C;
441 priv->idev->evbit[0] = BIT_MASK(EV_KEY);
442
443 if (of_property_read_bool(node, "autorepeat"))
444 __set_bit(EV_REP, priv->idev->evbit);
445
446 for (i = 0; i < cap->num_channels; i++)
447 __set_bit(priv->keycodes[i], priv->idev->keybit);
448
449 __clear_bit(KEY_RESERVED, priv->idev->keybit);
450
451 priv->idev->keycode = priv->keycodes;
452 priv->idev->keycodesize = sizeof(priv->keycodes[0]);
453 priv->idev->keycodemax = cap->num_channels;
454
455 priv->idev->id.vendor = CAP11XX_MANUFACTURER_ID;
456 priv->idev->id.product = cap->product_id;
457 priv->idev->id.version = rev;
458
459 priv->idev->open = cap11xx_input_open;
460 priv->idev->close = cap11xx_input_close;
461
462 error = cap11xx_init_leds(dev, priv, cap->num_leds);
463 if (error)
464 return error;
465
466 input_set_drvdata(priv->idev, priv);
467
468 /*
469 * Put the device in deep sleep mode for now.
470 * ->open() will bring it back once the it is actually needed.
471 */
472 cap11xx_set_sleep(priv, true);
473
474 error = input_register_device(priv->idev);
475 if (error)
476 return error;
477
478 irq = irq_of_parse_and_map(node, 0);
479 if (!irq) {
480 dev_err(dev, "Unable to parse or map IRQ\n");
481 return -ENXIO;
482 }
483
484 error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
485 IRQF_ONESHOT, dev_name(dev), priv);
486 if (error)
487 return error;
488
489 return 0;
490 }
491

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (7.80 kB)
config (159.04 kB)
Download all attachments

2023-01-04 14:16:24

by Jiri Valek - 2N

[permalink] [raw]
Subject: [PATCH v2 0/2] Input: cap11xx add support for cap1203, cap1293 and cap1298

PATCH 1 - add compatible string for new models
PATCH 2 - add support for new models into driver

Changes in v2:
- Fixed if statement in PATCH 2.

Jiri Valek - 2N (2):
dt-bindings: input: microchip,cap11xx: add cap1203, cap1293 and
cap1298
Input: cap11xx - add support for cap1203, cap1293 and cap1298

.../bindings/input/microchip,cap11xx.yaml | 3 +++
drivers/input/keyboard/cap11xx.c | 19 +++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)

--
2.25.1

2023-01-04 14:17:36

by Jiri Valek - 2N

[permalink] [raw]
Subject: [PATCH v2 1/2] dt-bindings: input: microchip,cap11xx: add cap1203, cap1293 and cap1298

Add support for cap1203, cap1293 and cap1298.

Signed-off-by: Jiri Valek - 2N <[email protected]>
---
Documentation/devicetree/bindings/input/microchip,cap11xx.yaml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml b/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
index 67d4d8f86a2d..08ca993b94c4 100644
--- a/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
+++ b/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
@@ -20,6 +20,9 @@ properties:
- microchip,cap1126
- microchip,cap1188
- microchip,cap1206
+ - microchip,cap1203
+ - microchip,cap1293
+ - microchip,cap1298

reg:
maxItems: 1
--
2.25.1

2023-01-06 07:30:19

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 2/2] Input: cap11xx - add support for cap1203, cap1293 and cap1298

Hi Jiri,

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jiri-Valek-2N/dt-bindings-input-microchip-cap11xx-add-cap1203-cap1293-and-cap1298/20230103-214328
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20230103134105.736346-3-jiriv%40axis.com
patch subject: [PATCH 2/2] Input: cap11xx - add support for cap1203, cap1293 and cap1298
config: loongarch-randconfig-m031-20230101
compiler: loongarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
drivers/input/keyboard/cap11xx.c:400 cap11xx_i2c_probe() warn: was && intended here instead of ||?

vim +400 drivers/input/keyboard/cap11xx.c

c77fd0a42b24ac Matt Ranostay 2014-10-31 390 if (!of_property_read_u32(node, "microchip,sensor-gain", &gain32)) {
322a552e195508 Jesse Taube 2021-11-02 391 if (cap->no_gain)
322a552e195508 Jesse Taube 2021-11-02 392 dev_warn(dev,
322a552e195508 Jesse Taube 2021-11-02 393 "This version doesn't support sensor gain\n");
322a552e195508 Jesse Taube 2021-11-02 394 else if (is_power_of_2(gain32) && gain32 <= 8)
c77fd0a42b24ac Matt Ranostay 2014-10-31 395 gain = ilog2(gain32);
c77fd0a42b24ac Matt Ranostay 2014-10-31 396 else
c77fd0a42b24ac Matt Ranostay 2014-10-31 397 dev_err(dev, "Invalid sensor-gain value %d\n", gain32);
c77fd0a42b24ac Matt Ranostay 2014-10-31 398 }
c77fd0a42b24ac Matt Ranostay 2014-10-31 399
e3f771deec5bca Jiri Valek - 2N 2023-01-03 @400 if ((id->driver_data != CAP1206) ||
e3f771deec5bca Jiri Valek - 2N 2023-01-03 401 (id->driver_data != CAP1203) ||
e3f771deec5bca Jiri Valek - 2N 2023-01-03 402 (id->driver_data != CAP1293) ||
e3f771deec5bca Jiri Valek - 2N 2023-01-03 403 (id->driver_data != CAP1298)) {

Yep. && isntead of ||. ->driver_data can't be equal to *all* of
those at the same time.

6bdd2fd1ed6f66 Matt Ranostay 2014-10-31 404 if (of_property_read_bool(node, "microchip,irq-active-high")) {
322a552e195508 Jesse Taube 2021-11-02 405 error = regmap_update_bits(priv->regmap,
322a552e195508 Jesse Taube 2021-11-02 406 CAP11XX_REG_CONFIG2,
322a552e195508 Jesse Taube 2021-11-02 407 CAP11XX_REG_CONFIG2_ALT_POL,
322a552e195508 Jesse Taube 2021-11-02 408 0);
6bdd2fd1ed6f66 Matt Ranostay 2014-10-31 409 if (error)
6bdd2fd1ed6f66 Matt Ranostay 2014-10-31 410 return error;
6bdd2fd1ed6f66 Matt Ranostay 2014-10-31 411 }
322a552e195508 Jesse Taube 2021-11-02 412 }
6bdd2fd1ed6f66 Matt Ranostay 2014-10-31 413
c77fd0a42b24ac Matt Ranostay 2014-10-31 414 /* Provide some useful defaults */
7609a5e973c43a Matt Ranostay 2014-10-31 415 for (i = 0; i < cap->num_channels; i++)

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

2023-01-08 21:59:09

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] dt-bindings: input: microchip,cap11xx: add cap1203, cap1293 and cap1298

On Wed, Jan 04, 2023 at 02:59:50PM +0100, Jiri Valek - 2N wrote:
> Add support for cap1203, cap1293 and cap1298.
>
> Signed-off-by: Jiri Valek - 2N <[email protected]>
> ---
> Documentation/devicetree/bindings/input/microchip,cap11xx.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml b/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
> index 67d4d8f86a2d..08ca993b94c4 100644
> --- a/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
> +++ b/Documentation/devicetree/bindings/input/microchip,cap11xx.yaml
> @@ -20,6 +20,9 @@ properties:
> - microchip,cap1126
> - microchip,cap1188
> - microchip,cap1206
> + - microchip,cap1203
> + - microchip,cap1293
> + - microchip,cap1298

Maintain alphabetical order please.

>
> reg:
> maxItems: 1
> --
> 2.25.1
>
>

2023-01-10 11:05:20

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Input: cap11xx add support for cap1203, cap1293 and cap1298

On 04/01/2023 14:59, Jiri Valek - 2N wrote:
> PATCH 1 - add compatible string for new models
> PATCH 2 - add support for new models into driver
>

Do not attach (thread) your patchsets to some other threads (unrelated
or older versions). This buries them deep in the mailbox and might
interfere with applying entire sets.


Best regards,
Krzysztof