[PATCH v2 1/2] gpio: davinci: use controller-specific MMIO for BINTEN
From: Sahaj Chaudhari
Date: Tue Nov 24 2026 - 08:37:07 EST
The file-global gpio_base can be overwritten when probes for multiple
DaVinci GPIO controllers overlap. The later IRQ setup can then write the
BINTEN register of a different controller.
Derive the BINTEN address from the current controller's mapped bank
instead of shared global state.
Fixes: 118150f22d6b ("gpio: davinci: move to platform device")
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Signed-off-by: Sahaj Chaudhari <sahaj123.sc@xxxxxxxxx>
---
Changes in v2:
- Rebase onto GPIO gpio/for-next after the devm_kzalloc_obj() conversion.
The fix itself is unchanged.
- Add Linus Walleij's Reviewed-by.
Previous version:
https://lore.kernel.org/all/20261109194910.2282454-2-sahaj123.sc@xxxxxxxxx/
Testing:
- ARM64 W=1 driver build and mocked nested-probe regression passed.
- Instrumented AM642 baseline selected two wrong BINTEN targets during
forced probe interleaving; the fixed series selected all three correctly.
See the cover letter for test scope and limitations.
drivers/gpio/gpio-davinci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index b80c1a27d591..7961ddee9f40 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -43,7 +43,6 @@ typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
#define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */
-static void __iomem *gpio_base;
static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0};
struct davinci_gpio_irq_data {
@@ -168,6 +167,7 @@ static int davinci_gpio_probe(struct platform_device *pdev)
unsigned int ngpio, nbank, nirq, gpio_unbanked;
struct davinci_gpio_controller *chips;
struct device *dev = &pdev->dev;
+ void __iomem *gpio_base;
/*
* The gpio banks conceptually expose a segmented bitmap,
@@ -586,7 +586,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
* BINTEN -- per-bank interrupt enable. genirq would also let these
* bits be set/cleared dynamically.
*/
- writel_relaxed(binten, gpio_base + BINTEN);
+ writel_relaxed(binten, chips->regs[0] - offset_array[0] + BINTEN);
return 0;
}
--
2.43.0