Skip to content

Commit eb44133

Browse files
andy-shevbrgl
authored andcommitted
gpio: pca953x: Set IRQ type when handle Intel Galileo Gen 2
The commit 0ea6839 ("gpio: dwapb: Convert driver to using the GPIO-lib-based IRQ-chip") indeliberately made a regression on how IRQ line from GPIO I²C expander is handled. I.e. it reveals that the quirk for Intel Galileo Gen 2 misses the part of setting IRQ type which previously was predefined by gpio-dwapb driver. Now, we have to reorganize the approach to call necessary parts, which can be done via ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk. Without this fix and with above mentioned change the kernel hangs on the first IRQ event with: gpio gpiochip3: Persistence not supported for GPIO 1 irq 32, desc: 62f8fb50, depth: 0, count: 0, unhandled: 0 ->handle_irq(): 41c7b0ab, handle_bad_irq+0x0/0x40 ->irq_data.chip(): e03f1e72, 0xc2539218 ->action(): 0ecc7e6f ->action->handler(): 8a3db21e, irq_default_primary_handler+0x0/0x10 IRQ_NOPROBE set unexpected IRQ trap at vector 20 Fixes: ba8c90c ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2") Depends-on: 0ea6839 ("gpio: dwapb: Convert driver to using the GPIO-lib-based IRQ-chip") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 8093902 commit eb44133

File tree

1 file changed

+23
-55
lines changed

1 file changed

+23
-55
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,29 @@ MODULE_DEVICE_TABLE(i2c, pca953x_id);
113113
#ifdef CONFIG_GPIO_PCA953X_IRQ
114114

115115
#include <linux/dmi.h>
116-
#include <linux/gpio.h>
117-
#include <linux/list.h>
116+
117+
static const struct acpi_gpio_params pca953x_irq_gpios = { 0, 0, true };
118+
119+
static const struct acpi_gpio_mapping pca953x_acpi_irq_gpios[] = {
120+
{ "irq-gpios", &pca953x_irq_gpios, 1, ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER },
121+
{ }
122+
};
123+
124+
static int pca953x_acpi_get_irq(struct device *dev)
125+
{
126+
int ret;
127+
128+
ret = devm_acpi_dev_add_driver_gpios(dev, pca953x_acpi_irq_gpios);
129+
if (ret)
130+
dev_warn(dev, "can't add GPIO ACPI mapping\n");
131+
132+
ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0);
133+
if (ret < 0)
134+
return ret;
135+
136+
dev_info(dev, "ACPI interrupt quirk (IRQ %d)\n", ret);
137+
return ret;
138+
}
118139

119140
static const struct dmi_system_id pca953x_dmi_acpi_irq_info[] = {
120141
{
@@ -133,59 +154,6 @@ static const struct dmi_system_id pca953x_dmi_acpi_irq_info[] = {
133154
},
134155
{}
135156
};
136-
137-
#ifdef CONFIG_ACPI
138-
static int pca953x_acpi_get_pin(struct acpi_resource *ares, void *data)
139-
{
140-
struct acpi_resource_gpio *agpio;
141-
int *pin = data;
142-
143-
if (acpi_gpio_get_irq_resource(ares, &agpio))
144-
*pin = agpio->pin_table[0];
145-
return 1;
146-
}
147-
148-
static int pca953x_acpi_find_pin(struct device *dev)
149-
{
150-
struct acpi_device *adev = ACPI_COMPANION(dev);
151-
int pin = -ENOENT, ret;
152-
LIST_HEAD(r);
153-
154-
ret = acpi_dev_get_resources(adev, &r, pca953x_acpi_get_pin, &pin);
155-
acpi_dev_free_resource_list(&r);
156-
if (ret < 0)
157-
return ret;
158-
159-
return pin;
160-
}
161-
#else
162-
static inline int pca953x_acpi_find_pin(struct device *dev) { return -ENXIO; }
163-
#endif
164-
165-
static int pca953x_acpi_get_irq(struct device *dev)
166-
{
167-
int pin, ret;
168-
169-
pin = pca953x_acpi_find_pin(dev);
170-
if (pin < 0)
171-
return pin;
172-
173-
dev_info(dev, "Applying ACPI interrupt quirk (GPIO %d)\n", pin);
174-
175-
if (!gpio_is_valid(pin))
176-
return -EINVAL;
177-
178-
ret = gpio_request(pin, "pca953x interrupt");
179-
if (ret)
180-
return ret;
181-
182-
ret = gpio_to_irq(pin);
183-
184-
/* When pin is used as an IRQ, no need to keep it requested */
185-
gpio_free(pin);
186-
187-
return ret;
188-
}
189157
#endif
190158

191159
static const struct acpi_device_id pca953x_acpi_ids[] = {

0 commit comments

Comments
 (0)