Skip to content

Commit e6827bc

Browse files
digetxlinusw
authored andcommitted
gpio: max77620: Initialize hardware state of interrupts
I noticed on Nexus 7 that after rebooting from downstream kernel to upstream, the GPIO interrupt is triggering non-stop despite interrupts being disabled for all of GPIOs. This happens because Nexus 7 uses a soft-reboot, meaning that bootloader should take care of resetting hardware, but the bootloader doesn't do it well. As a result, GPIO interrupt may be left ON at a boot time. Let's mask all GPIO interrupts at the driver's initialization time in order to resolve the issue. Signed-off-by: Dmitry Osipenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Laxman Dewangan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 15d9e7e commit e6827bc

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/gpio/gpio-max77620.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,30 @@ static int max77620_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
260260
return -ENOTSUPP;
261261
}
262262

263+
static int max77620_gpio_irq_init_hw(struct gpio_chip *gc)
264+
{
265+
struct max77620_gpio *gpio = gpiochip_get_data(gc);
266+
unsigned int i;
267+
int err;
268+
269+
/*
270+
* GPIO interrupts may be left ON after bootloader, hence let's
271+
* pre-initialize hardware to the expected state by disabling all
272+
* the interrupts.
273+
*/
274+
for (i = 0; i < MAX77620_GPIO_NR; i++) {
275+
err = regmap_update_bits(gpio->rmap, GPIO_REG_ADDR(i),
276+
MAX77620_CNFG_GPIO_INT_MASK, 0);
277+
if (err < 0) {
278+
dev_err(gpio->dev,
279+
"failed to disable interrupt: %d\n", err);
280+
return err;
281+
}
282+
}
283+
284+
return 0;
285+
}
286+
263287
static int max77620_gpio_probe(struct platform_device *pdev)
264288
{
265289
struct max77620_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -295,6 +319,7 @@ static int max77620_gpio_probe(struct platform_device *pdev)
295319
mgpio->gpio_chip.irq.chip = &max77620_gpio_irqchip;
296320
mgpio->gpio_chip.irq.default_type = IRQ_TYPE_NONE;
297321
mgpio->gpio_chip.irq.handler = handle_edge_irq;
322+
mgpio->gpio_chip.irq.init_hw = max77620_gpio_irq_init_hw,
298323
mgpio->gpio_chip.irq.threaded = true;
299324

300325
platform_set_drvdata(pdev, mgpio);

0 commit comments

Comments
 (0)