* [PATCH v4 1/2] gpio: pca953x: Drop unneeded ACPI_PTR() @ 2020-05-29 13:30 Andy Shevchenko 2020-05-29 13:30 ` [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 Andy Shevchenko 0 siblings, 1 reply; 5+ messages in thread From: Andy Shevchenko @ 2020-05-29 13:30 UTC (permalink / raw) To: linux-gpio, Linus Walleij, Bartosz Golaszewski; +Cc: Andy Shevchenko ACPI_PTR() becomes a no-op when !CONFIG_ACPI. This is not needed since we always have ID table enabled. Moreover, in the mentioned case compiler will complain about defined but not used variable. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- v4: reincluded to the series since had not been applied yet drivers/gpio/gpio-pca953x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 4bb3d3524bc7..1fca8dd7824f 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1176,7 +1176,7 @@ static struct i2c_driver pca953x_driver = { .name = "pca953x", .pm = &pca953x_pm_ops, .of_match_table = pca953x_dt_ids, - .acpi_match_table = ACPI_PTR(pca953x_acpi_ids), + .acpi_match_table = pca953x_acpi_ids, }, .probe = pca953x_probe, .remove = pca953x_remove, -- 2.26.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 2020-05-29 13:30 [PATCH v4 1/2] gpio: pca953x: Drop unneeded ACPI_PTR() Andy Shevchenko @ 2020-05-29 13:30 ` Andy Shevchenko 2020-06-01 8:40 ` Mika Westerberg 2020-06-05 13:56 ` Andy Shevchenko 0 siblings, 2 replies; 5+ messages in thread From: Andy Shevchenko @ 2020-05-29 13:30 UTC (permalink / raw) To: linux-gpio, Linus Walleij, Bartosz Golaszewski Cc: Andy Shevchenko, Mika Westerberg ACPI table on Intel Galileo Gen 2 has wrong pin number for IRQ resource of one of the I²C GPIO expanders. Since we know what that number is and luckily have GPIO bases fixed for SoC's controllers, we may use a simple DMI quirk to match the platform and retrieve GpioInt() pin on it for the expander in question. Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- v4: addressed some concerns, made code compact (Mika) drivers/gpio/gpio-pca953x.c | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 1fca8dd7824f..e2f637dbc61a 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -107,6 +107,79 @@ static const struct i2c_device_id pca953x_id[] = { }; MODULE_DEVICE_TABLE(i2c, pca953x_id); +#ifdef CONFIG_GPIO_PCA953X_IRQ + +#include <linux/dmi.h> +#include <linux/gpio.h> +#include <linux/list.h> + +static const struct dmi_system_id pca953x_dmi_acpi_irq_info[] = { + { + /* + * On Intel Galileo Gen 2 board the IRQ pin of one of + * the I²C GPIO expanders, which has GpioInt() resource, + * is provided as an absolute number instead of being + * relative. Since first controller (gpio-sch.c) and + * second (gpio-dwapb.c) are at the fixed bases, we may + * safely refer to the number in the global space to get + * an IRQ out of it. + */ + .matches = { + DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"), + }, + }, + {} +}; + +#ifdef CONFIG_ACPI +static int pca953x_acpi_get_pin(struct acpi_resource *ares, void *data) +{ + struct acpi_resource_gpio *agpio; + int *pin = data; + + if (acpi_gpio_get_irq_resource(ares, &agpio)) + *pin = agpio->pin_table[0]; + return 1; +} + +static int pca953x_acpi_find_pin(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + int pin = -ENOENT, ret; + LIST_HEAD(r); + + ret = acpi_dev_get_resources(adev, &r, pca953x_acpi_get_pin, &pin); + acpi_dev_free_resource_list(&r); + if (ret < 0) + return ret; + + return pin; +} +#else +static inline int pca953x_acpi_find_pin(struct device *dev) { return -ENXIO; } +#endif + +static int pca953x_acpi_get_irq(struct device *dev) +{ + int pin, ret; + + pin = pca953x_acpi_find_pin(dev); + if (pin < 0) + return pin; + + dev_info(dev, "Applying ACPI interrupt quirk (GPIO %d)\n", pin); + + if (!gpio_is_valid(pin)) + return -EINVAL; + + ret = gpio_request(pin, "pca953x interrupt"); + if (ret) + return ret; + + return gpio_to_irq(pin); +} +#endif + static const struct acpi_device_id pca953x_acpi_ids[] = { { "INT3491", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, { } @@ -752,6 +825,12 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base) DECLARE_BITMAP(irq_stat, MAX_LINE); int ret; + if (dmi_first_match(pca953x_dmi_acpi_irq_info)) { + ret = pca953x_acpi_get_irq(&client->dev); + if (ret > 0) + client->irq = ret; + } + if (!client->irq) return 0; -- 2.26.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 2020-05-29 13:30 ` [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 Andy Shevchenko @ 2020-06-01 8:40 ` Mika Westerberg 2020-06-01 9:03 ` Andy Shevchenko 2020-06-05 13:56 ` Andy Shevchenko 1 sibling, 1 reply; 5+ messages in thread From: Mika Westerberg @ 2020-06-01 8:40 UTC (permalink / raw) To: Andy Shevchenko; +Cc: linux-gpio, Linus Walleij, Bartosz Golaszewski On Fri, May 29, 2020 at 04:30:54PM +0300, Andy Shevchenko wrote: > ACPI table on Intel Galileo Gen 2 has wrong pin number for IRQ resource > of one of the I²C GPIO expanders. Since we know what that number is and > luckily have GPIO bases fixed for SoC's controllers, we may use a simple > DMI quirk to match the platform and retrieve GpioInt() pin on it for > the expander in question. > > Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com> I don't think this is needed since I did not suggest you to write this patch. I only gave a couple of review comments. > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 2020-06-01 8:40 ` Mika Westerberg @ 2020-06-01 9:03 ` Andy Shevchenko 0 siblings, 0 replies; 5+ messages in thread From: Andy Shevchenko @ 2020-06-01 9:03 UTC (permalink / raw) To: Mika Westerberg; +Cc: linux-gpio, Linus Walleij, Bartosz Golaszewski On Mon, Jun 01, 2020 at 11:40:23AM +0300, Mika Westerberg wrote: > On Fri, May 29, 2020 at 04:30:54PM +0300, Andy Shevchenko wrote: > > ACPI table on Intel Galileo Gen 2 has wrong pin number for IRQ resource > > of one of the I²C GPIO expanders. Since we know what that number is and > > luckily have GPIO bases fixed for SoC's controllers, we may use a simple > > DMI quirk to match the platform and retrieve GpioInt() pin on it for > > the expander in question. > > > > Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com> > > I don't think this is needed since I did not suggest you to write this > patch. I only gave a couple of review comments. You suggested the way to avoid a quirk which brings us to almost rewritten version of this. I think it's appropriate to put your tag, but if you insist, I'll remove it. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Thank you! -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 2020-05-29 13:30 ` [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 Andy Shevchenko 2020-06-01 8:40 ` Mika Westerberg @ 2020-06-05 13:56 ` Andy Shevchenko 1 sibling, 0 replies; 5+ messages in thread From: Andy Shevchenko @ 2020-06-05 13:56 UTC (permalink / raw) To: linux-gpio, Linus Walleij, Bartosz Golaszewski; +Cc: Mika Westerberg On Fri, May 29, 2020 at 04:30:54PM +0300, Andy Shevchenko wrote: > ACPI table on Intel Galileo Gen 2 has wrong pin number for IRQ resource > of one of the I²C GPIO expanders. Since we know what that number is and > luckily have GPIO bases fixed for SoC's controllers, we may use a simple > DMI quirk to match the platform and retrieve GpioInt() pin on it for > the expander in question. Since patch 1 from this series has been applied and I fixed few more bugs I sent recently the series of four fixes with this one included as v1. So, please, consider that one instead. I also applied Mika's tag. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-05 13:56 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-05-29 13:30 [PATCH v4 1/2] gpio: pca953x: Drop unneeded ACPI_PTR() Andy Shevchenko 2020-05-29 13:30 ` [PATCH v4 2/2] gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2 Andy Shevchenko 2020-06-01 8:40 ` Mika Westerberg 2020-06-01 9:03 ` Andy Shevchenko 2020-06-05 13:56 ` Andy Shevchenko
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.