[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MesW=pf9K4OcgZHn3iyULLf0ysRrFx51cj82JCeugcHWw@mail.gmail.com>
Date: Fri, 2 Jan 2026 11:29:31 +0100
From: Bartosz Golaszewski <brgl@...nel.org>
To: Swark Yang <syang@...ado.com>
Cc: Linus Walleij <linus.walleij@...aro.org>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, Tzu-Hao Wei <twei@...ado.com>,
Prasad Bolisetty <pbolisetty@...ado.com>
Subject: Re: [PATCH 1/2] gpio: cadence: Add quirk for Axiado AX3000 platform
On Tue, Dec 23, 2025 at 8:30 AM Swark Yang <syang@...ado.com> wrote:
>
> 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@...ado.com>
> Signed-off-by: Tzu-Hao Wei <twei@...ado.com>
> Signed-off-by: Swark Yang <syang@...ado.com>
> Signed-off-by: Prasad Bolisetty <pbolisetty@...ado.com>
> ---
> drivers/gpio/gpio-cadence.c | 53 +++++++++++++++++++++++++++++++++++----------
> 1 file changed, 42 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpio/gpio-cadence.c b/drivers/gpio/gpio-cadence.c
> index b75734ca22dd..b9f39566b0f9 100644
> --- a/drivers/gpio/gpio-cadence.c
> +++ b/drivers/gpio/gpio-cadence.c
> @@ -6,6 +6,9 @@
> * Authors:
> * Jan Kotas <jank@...ence.com>
> * Boris Brezillon <boris.brezillon@...e-electrons.com>
> + *
> + * Copyright (C) 2025 Axiado Corporation.
Move this to where the original copyright is.
> + *
> */
>
> #include <linux/cleanup.h>
> @@ -31,12 +34,18 @@
> #define CDNS_GPIO_IRQ_VALUE 0x28
> #define CDNS_GPIO_IRQ_ANY_EDGE 0x2c
>
> +#define CDNS_GPIO_QUIRKS_SKIP_PINMUX_CFG BIT(1)
> +
> struct cdns_gpio_chip {
> struct gpio_generic_chip gen_gc;
> void __iomem *regs;
> u32 bypass_orig;
> };
>
> +struct cdns_platform_data {
> + u32 quirks;
> +};
> +
> static int cdns_gpio_request(struct gpio_chip *chip, unsigned int offset)
> {
> struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);
> @@ -141,6 +150,16 @@ static const struct irq_chip cdns_gpio_irqchip = {
> GPIOCHIP_IRQ_RESOURCE_HELPERS,
> };
>
> +static const struct cdns_platform_data ax3000_gpio_def = {
> + .quirks = CDNS_GPIO_QUIRKS_SKIP_PINMUX_CFG, };
Didn't checkpatch complain about the trailing bracket? Please move it
to the next line.
> +
> +static const struct of_device_id cdns_of_ids[] = {
> + { .compatible = "axiado,ax3000-gpio", .data = &ax3000_gpio_def },
> + { .compatible = "cdns,gpio-r1p02" },
> + { /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, cdns_of_ids);
> +
> static int cdns_gpio_probe(struct platform_device *pdev)
> {
> struct gpio_generic_chip_config config = { };
> @@ -148,6 +167,8 @@ static int cdns_gpio_probe(struct platform_device *pdev)
> int ret, irq;
> u32 dir_prev;
> u32 num_gpios = 32;
> + bool skip_pinmux_cfg = false;
> + const struct of_device_id *match;
> struct clk *clk;
>
> cgpio = devm_kzalloc(&pdev->dev, sizeof(*cgpio), GFP_KERNEL);
> @@ -165,6 +186,13 @@ static int cdns_gpio_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> + match = of_match_node(cdns_of_ids, pdev->dev.of_node);
Just use device_get_match_data().
> + if (match && match->data) {
> + const struct cdns_platform_data *data = match->data;
> +
> + skip_pinmux_cfg = data->quirks & CDNS_GPIO_QUIRKS_SKIP_PINMUX_CFG;
> + }
> +
> /*
> * Set all pins as inputs by default, otherwise:
> * gpiochip_lock_as_irq:
> @@ -173,8 +201,15 @@ static int cdns_gpio_probe(struct platform_device *pdev)
> * so it needs to be changed before gpio_generic_chip_init() is called.
> */
> dir_prev = ioread32(cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
> - iowrite32(GENMASK(num_gpios - 1, 0),
> - cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
> +
> + /*
> + * The AX3000 platform performs the required configuration at boot time
> + * before Linux boots, so this quirk disables pinmux initialization.
> + */
> + if (!skip_pinmux_cfg) {
> + iowrite32(GENMASK(num_gpios - 1, 0),
> + cgpio->regs + CDNS_GPIO_DIRECTION_MODE);
> + }
>
> config.dev = &pdev->dev;
> config.sz = 4;
> @@ -240,9 +275,11 @@ static int cdns_gpio_probe(struct platform_device *pdev)
> /*
> * Enable gpio outputs, ignored for input direction
> */
> - iowrite32(GENMASK(num_gpios - 1, 0),
> - cgpio->regs + CDNS_GPIO_OUTPUT_EN);
> - iowrite32(0, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
> + if (!skip_pinmux_cfg) {
> + iowrite32(GENMASK(num_gpios - 1, 0),
> + cgpio->regs + CDNS_GPIO_OUTPUT_EN);
> + iowrite32(0, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
> + }
>
> platform_set_drvdata(pdev, cgpio);
> return 0;
> @@ -260,12 +297,6 @@ static void cdns_gpio_remove(struct platform_device *pdev)
> iowrite32(cgpio->bypass_orig, cgpio->regs + CDNS_GPIO_BYPASS_MODE);
> }
>
> -static const struct of_device_id cdns_of_ids[] = {
> - { .compatible = "cdns,gpio-r1p02" },
> - { /* sentinel */ },
> -};
> -MODULE_DEVICE_TABLE(of, cdns_of_ids);
> -
> static struct platform_driver cdns_gpio_driver = {
> .driver = {
> .name = "cdns-gpio",
>
> --
> 2.25.1
>
Bart
Powered by blists - more mailing lists