Skip to content

Commit ea5b4c6

Browse files
Swark-AxiadoBartosz Golaszewski
authored andcommitted
gpio: cadence: Add quirk for Axiado AX3000 platform
On the Axiado AX3000 platform, pinmux and pin configuration (such as direction and output enable) are configured by the hardware/firmware at boot time before Linux boots. To prevent conflicts, introduce a platform-specific quirk triggered by the "axiado,ax3000-gpio" compatible string. When this quirk is active, the driver will skip its default initialization of pinmux configuration and direction settings during probe. Co-developed-by: Tzu-Hao Wei <twei@axiado.com> Signed-off-by: Tzu-Hao Wei <twei@axiado.com> Signed-off-by: Swark Yang <syang@axiado.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://lore.kernel.org/r/20260109-axiado-ax3000-cadence-gpio-support-v2-1-fc1e28edf68a@axiado.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent a88d958 commit ea5b4c6

1 file changed

Lines changed: 45 additions & 11 deletions

File tree

drivers/gpio/gpio-cadence.c

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/*
44
* Copyright 2017-2018 Cadence
5+
* Copyright (C) 2025 Axiado Corporation.
56
*
67
* Authors:
78
* Jan Kotas <jank@cadence.com>
@@ -31,10 +32,23 @@
3132
#define CDNS_GPIO_IRQ_VALUE 0x28
3233
#define CDNS_GPIO_IRQ_ANY_EDGE 0x2c
3334

35+
struct cdns_gpio_quirks {
36+
bool skip_init;
37+
};
38+
3439
struct cdns_gpio_chip {
3540
struct gpio_generic_chip gen_gc;
3641
void __iomem *regs;
3742
u32 bypass_orig;
43+
const struct cdns_gpio_quirks *quirks;
44+
};
45+
46+
static const struct cdns_gpio_quirks cdns_default_quirks = {
47+
.skip_init = false,
48+
};
49+
50+
static const struct cdns_gpio_quirks ax3000_gpio_quirks = {
51+
.skip_init = true,
3852
};
3953

4054
static int cdns_gpio_request(struct gpio_chip *chip, unsigned int offset)
@@ -141,6 +155,19 @@ static const struct irq_chip cdns_gpio_irqchip = {
141155
GPIOCHIP_IRQ_RESOURCE_HELPERS,
142156
};
143157

158+
static const struct of_device_id cdns_of_ids[] = {
159+
{
160+
.compatible = "axiado,ax3000-gpio",
161+
.data = &ax3000_gpio_quirks
162+
},
163+
{
164+
.compatible = "cdns,gpio-r1p02",
165+
.data = &cdns_default_quirks
166+
},
167+
{ /* sentinel */ },
168+
};
169+
MODULE_DEVICE_TABLE(of, cdns_of_ids);
170+
144171
static int cdns_gpio_probe(struct platform_device *pdev)
145172
{
146173
struct gpio_generic_chip_config config = { };
@@ -165,6 +192,10 @@ static int cdns_gpio_probe(struct platform_device *pdev)
165192
return -EINVAL;
166193
}
167194

195+
cgpio->quirks = device_get_match_data(&pdev->dev);
196+
if (!cgpio->quirks)
197+
cgpio->quirks = &cdns_default_quirks;
198+
168199
/*
169200
* Set all pins as inputs by default, otherwise:
170201
* gpiochip_lock_as_irq:
@@ -173,8 +204,15 @@ static int cdns_gpio_probe(struct platform_device *pdev)
173204
* so it needs to be changed before gpio_generic_chip_init() is called.
174205
*/
175206
dir_prev = ioread32(cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
176-
iowrite32(GENMASK(num_gpios - 1, 0),
177-
cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
207+
208+
/*
209+
* The AX3000 platform performs the required configuration at boot time
210+
* before Linux boots, so this quirk disables pinmux initialization.
211+
*/
212+
if (!cgpio->quirks->skip_init) {
213+
iowrite32(GENMASK(num_gpios - 1, 0),
214+
cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
215+
}
178216

179217
config.dev = &pdev->dev;
180218
config.sz = 4;
@@ -240,9 +278,11 @@ static int cdns_gpio_probe(struct platform_device *pdev)
240278
/*
241279
* Enable gpio outputs, ignored for input direction
242280
*/
243-
iowrite32(GENMASK(num_gpios - 1, 0),
244-
cgpio->regs + CDNS_GPIO_OUTPUT_EN);
245-
iowrite32(0, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
281+
if (!cgpio->quirks->skip_init) {
282+
iowrite32(GENMASK(num_gpios - 1, 0),
283+
cgpio->regs + CDNS_GPIO_OUTPUT_EN);
284+
iowrite32(0, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
285+
}
246286

247287
platform_set_drvdata(pdev, cgpio);
248288
return 0;
@@ -260,12 +300,6 @@ static void cdns_gpio_remove(struct platform_device *pdev)
260300
iowrite32(cgpio->bypass_orig, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
261301
}
262302

263-
static const struct of_device_id cdns_of_ids[] = {
264-
{ .compatible = "cdns,gpio-r1p02" },
265-
{ /* sentinel */ },
266-
};
267-
MODULE_DEVICE_TABLE(of, cdns_of_ids);
268-
269303
static struct platform_driver cdns_gpio_driver = {
270304
.driver = {
271305
.name = "cdns-gpio",

0 commit comments

Comments
 (0)