mbox series

[0/2] gpio: pca953x: Add interrupt mask support for pca953x chips

Message ID 20221010132007.924810-1-levente.revesz@eilabs.com
Headers show
Series gpio: pca953x: Add interrupt mask support for pca953x chips | expand

Message

Révész, Levente Oct. 10, 2022, 1:20 p.m. UTC
Hello,

Some chips in the pca953x family have an interrupt mask register in
addition to the standard 4 registers:

    0: INPUT
    1: OUTPUT
    2: POLARITY
    3: CONFIGURATION
    4: INTERRUPT MASK

Chips with this register:

    - pca9505
    - pca9506
    - pca9698

The interrupt mask register defaults to all interrupts disabled, so
interrupts are unusable unless the driver sets this register.

Interrupt masking is already implemented for pcal chips. That
implementation could be extended to support this register as well.

This patch series adds support for the interrupt mask register in
mentioned pca chips.

Note 1:

    Interrupt support for the pca9698 is not enabled currently, so the
    interrupt mask support has not been turned on either. An additional
    patch in this series could enable support for it, although I have no
    hardware to test with.

Kind regards,
Levente

Levente Révész (2):
  gpio: pca953x: Generalize interrupt mask register handling
  gpio: pca953x: Add interrupt mask support for chips with the standard
    register set

 drivers/gpio/gpio-pca953x.c | 81 +++++++++++++++++++++++++------------
 1 file changed, 56 insertions(+), 25 deletions(-)

Comments

Linus Walleij Oct. 17, 2022, 10:02 a.m. UTC | #1
On Mon, Oct 10, 2022 at 3:23 PM Levente Révész
<levente.revesz@eilabs.com> wrote:

> Some chips in the pca953x family have an interrupt mask register in
> addition to the standard 4 registers:
>
>     0: INPUT
>     1: OUTPUT
>     2: POLARITY
>     3: CONFIGURATION
>     4: INTERRUPT MASK
>
> Chips with this register:
>
>     - pca9505
>     - pca9506
>     - pca9698
>
> The interrupt mask register defaults to all interrupts disabled, so
> interrupts are unusable unless the driver sets this register.
>
> Interrupt masking is already implemented for pcal chips. That
> implementation could be extended to support this register as well.
>
> This patch series adds support for the interrupt mask register in
> mentioned pca chips.

Added some PCA953x users to the To-line, lots of people use
this driver so please review!

Yours,
Linus Walleij
Révész, Levente Oct. 19, 2022, 10:15 a.m. UTC | #2
On Monday, October 17, 2022 7:31 PM, Andy Shevchenko wrote:
> At first glance I think this needs two prerequisite patches:
>
> 1) convert _TYPE from bits to plain numbers, so we will have room
>    for up to 16 types;
>
> 2) Introducing PCAL953X_TYPE.
>
> After this is done, the current series will be neater.

Thanks for the suggestions!

I have started implementing this change:

    * Convert _TYPE from bits to 4 bit integer

    * Define 4 chip types: PCA953X_TYPE, PCAL953X_TYPE,
                           PCAL653X_TYPE, PCA957X_TYPE

The PCA_PCAL bit is redundant, we know which chip is PCAL from their
chip type. Remove the PCA_PCAL bit and the PCA_LATCH_INT mask.

The now modified bits were also used in the acpi_device_id
initialization:

    static const struct acpi_device_id pca953x_acpi_ids[] = {
        { "INT3491", 16 | PCA953X_TYPE | PCA_LATCH_INT, },
        { }
    };
    MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids);

I do not understand what is happening in this snippet. 
What should be the id?

---
Best regards,
Levente