RE: [PATCH v2 2/3] gpio: Add support for TPS68470 GPIOs

From: Mani, Rajmohan
Date: Wed Jul 05 2017 - 21:49:46 EST

Hi Andy and all,

Thanks for your patience.

> >
> > Main points (some I already told in an answer to Sakari's mail):
> > 1. Consider 2 GPIO chips over 1.
> I am looking into this.

For the second GPIO chip, the call to acpi_attach_data() fails with AE_ALREADY_EXISTS, as below with 4.12 rc3 kernel.

acpi_ns_attach_data() fails with AE_ALREADY_EXISTS for the second GPIO chip.
/* We only allow one attachment per handler */ drivers/acpi/acpica/nsobject.c

Also, I tried the following experiment, since we know the number of GPIOs for the second GPIO chip is 3, just to see if I can get further along after a successful call to acpi_attach_data().

Since the acpi_gpio_chip_dh is used as the handler in all acpi_gpiochip_* calls, I tried to use another handler (acpi_gpio_chip_dh2). But now, as expected, acpi_gpiochip_request_regions() failed inside acpi_gpiochip_add(), as only one OpRegion handler can be installed for a given OpRegion code. Due to this, when I try to set the GPIO 9 (which is now GPIO 2 of the second GPIO chip of 2 GPIO chips implementation), the OpRegion handler is called with the information / region_context pointer of the first GPIO chip, which is not desired.

It sounds like there are 2 issues with the 2 GPIO chips implementation.

1) How to get acpi_ns_attach_data() done successfully for the second GPIO chip, given the observation above and

2) How to get the GPIO OpRegion handler to be called with the right GPIO chip information / region_context pointer

I need pointers to make further progress here.

> > 2. Fix FIXME(s).
> Leaving this on, until I see how this can be fixed.

These FIXME code will be removed from the driver, as we are working to get this done through platform firmware.

> > 3. If there is hardware bug we should work around it must be clarified.
> Ack
> If this is about initializing the GPIOs with zero, I have removed this code for
> now.
> > 4. You missed Linus' comments here (switch to the data pointer inside
> > GPIO chip and remove platform driver data stuff from the driver).
> >
> I have fixed this with v3