devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Peng Fan <peng.fan@nxp.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	"Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andy@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Stefan Agner <stefan@agner.ch>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v5 4/7] gpio: vf610: add i.MX8ULP of_device_id entry
Date: Wed, 4 Oct 2023 07:04:28 +0200	[thread overview]
Message-ID: <20231004050428.o7l2e23xjcjkzzck@pengutronix.de> (raw)
In-Reply-To: <DU0PR04MB9417594B2DFDA6056AEC4CB988C5A@DU0PR04MB9417.eurprd04.prod.outlook.com>

Hi Peng,

On 23-10-02, Peng Fan wrote:
> > Subject: Re: [PATCH v5 4/7] gpio: vf610: add i.MX8ULP of_device_id entry
> > 
> > On Sun, Oct 1, 2023 at 10:23 AM Peng Fan (OSS) <peng.fan@oss.nxp.com>
> > wrote:
> > >
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > i.MX8ULP/93 GPIO supports similar feature as i.MX7ULP GPIO, but
> > > i.MX8ULP is actually not hardware compatible with i.MX7ULP. i.MX8ULP
> > > only has one register base, not two bases. i.MX8ULP and i.MX93
> > > actually has two interrupts for each gpio controller, one for
> > > Trustzone non-secure world, one for secure world.
> > >
> > > Although the Linux Kernel driver gpio-vf610.c could work with
> > > fsl,imx7ulp-gpio compatible, it is based on some tricks did in device
> > > tree with some offset added to base address.
> > >
> > > Add a new of_device_id entry for i.MX8ULP. But to make the driver
> > > could also support old bindings, check the compatible string first,
> > > before check the device data.
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > >  drivers/gpio/gpio-vf610.c | 47
> > > ++++++++++++++++++++++++++++++++++++++++-------
> > >  1 file changed, 40 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
> > > index dbc7ba0ee72c..8e12706c0b22 100644
> > > --- a/drivers/gpio/gpio-vf610.c
> > > +++ b/drivers/gpio/gpio-vf610.c
> > > @@ -25,6 +25,7 @@
> > >  struct fsl_gpio_soc_data {
> > >         /* SoCs has a Port Data Direction Register (PDDR) */
> > >         bool have_paddr;
> > > +       bool have_dual_base;
> > >  };
> > >
> > >  struct vf610_gpio_port {
> > > @@ -60,13 +61,26 @@ struct vf610_gpio_port {
> > >  #define PORT_INT_EITHER_EDGE   0xb
> > >  #define PORT_INT_LOGIC_ONE     0xc
> > >
> > > +#define IMX8ULP_GPIO_BASE_OFF  0x40
> > > +#define IMX8ULP_BASE_OFF       0x80
> > > +
> > > +static const struct fsl_gpio_soc_data vf610_data = {
> > > +       .have_dual_base = true,
> > > +};
> > > +
> > >  static const struct fsl_gpio_soc_data imx_data = {
> > >         .have_paddr = true,
> > > +       .have_dual_base = true,
> > > +};
> > > +
> > > +static const struct fsl_gpio_soc_data imx8ulp_data = {
> > > +       .have_paddr = true,
> > >  };
> > >
> > >  static const struct of_device_id vf610_gpio_dt_ids[] = {
> > > -       { .compatible = "fsl,vf610-gpio",       .data = NULL, },
> > > +       { .compatible = "fsl,vf610-gpio",       .data = &vf610_data },
> > >         { .compatible = "fsl,imx7ulp-gpio",     .data = &imx_data, },
> > > +       { .compatible = "fsl,imx8ulp-gpio",     .data = &imx8ulp_data, },
> > >         { /* sentinel */ }
> > >  };
> > >
> > > @@ -263,19 +277,38 @@ static int vf610_gpio_probe(struct
> > platform_device *pdev)
> > >         struct gpio_irq_chip *girq;
> > >         int i;
> > >         int ret;
> > > +       bool dual_base;
> > >
> > >         port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> > >         if (!port)
> > >                 return -ENOMEM;
> > >
> > >         port->sdata = of_device_get_match_data(dev);
> > > -       port->base = devm_platform_ioremap_resource(pdev, 0);
> > > -       if (IS_ERR(port->base))
> > > -               return PTR_ERR(port->base);
> > >
> > > -       port->gpio_base = devm_platform_ioremap_resource(pdev, 1);
> > > -       if (IS_ERR(port->gpio_base))
> > > -               return PTR_ERR(port->gpio_base);
> > > +       dual_base = port->sdata->have_dual_base;
> > > +
> > > +       /* support old compatible strings */
> > > +       if (device_is_compatible(dev, "fsl,imx7ulp-gpio") &&
> > > +           (device_is_compatible(dev, "fsl,imx93-gpio") ||
> > 
> > Why not just add this compatible to vf610_gpio_dt_ids?
> 
> "fsl,imx93-gpio", "fsl,imx7ulp-gpio" is not a correct entry
> combination. This is to support legacy old compatible
> strings.

The "/* support old compatible strings */" may a bit misleading here?
Should we be a bit more verbose for the reader of the code, e.g.:

		/*
		 * Handle legacy compatible combinations which used two
		 * reg values for the i.MX8ULP and i.MX93.
		 */

Regards,
  Marco

> 
> Thanks,
> Peng.
> > 
> > Bart
> > 
> > > +           (device_is_compatible(dev, "fsl,imx8ulp-gpio"))))
> > > +               dual_base = true;
> > > +
> > > +       if (dual_base) {
> > > +               port->base = devm_platform_ioremap_resource(pdev, 0);
> > > +               if (IS_ERR(port->base))
> > > +                       return PTR_ERR(port->base);
> > > +
> > > +               port->gpio_base = devm_platform_ioremap_resource(pdev, 1);
> > > +               if (IS_ERR(port->gpio_base))
> > > +                       return PTR_ERR(port->gpio_base);
> > > +       } else {
> > > +               port->base = devm_platform_ioremap_resource(pdev, 0);
> > > +               if (IS_ERR(port->base))
> > > +                       return PTR_ERR(port->base);
> > > +
> > > +               port->gpio_base = port->base + IMX8ULP_GPIO_BASE_OFF;
> > > +               port->base = port->base + IMX8ULP_BASE_OFF;
> > > +       }
> > >
> > >         port->irq = platform_get_irq(pdev, 0);
> > >         if (port->irq < 0)
> > >
> > > --
> > > 2.37.1
> > >

  reply	other threads:[~2023-10-04  5:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-01  8:27 [PATCH v5 0/7] gpio: update i.MX93/8ULP and support i.MX95 Peng Fan (OSS)
2023-10-01  8:27 ` [PATCH v5 1/7] dt-bindings: gpio: vf610: update gpio-ranges Peng Fan (OSS)
2023-10-01  8:27 ` [PATCH v5 2/7] dt-bindings: gpio: vf610: correct i.MX8ULP and i.MX93 Peng Fan (OSS)
2023-10-01  8:27 ` [PATCH v5 3/7] dt-bindings: gpio: vf610: add i.MX95 compatible Peng Fan (OSS)
2023-10-01  8:27 ` [PATCH v5 4/7] gpio: vf610: add i.MX8ULP of_device_id entry Peng Fan (OSS)
2023-10-02  9:04   ` Bartosz Golaszewski
2023-10-02  9:43     ` Peng Fan
2023-10-04  5:04       ` Marco Felsch [this message]
2023-10-01  8:27 ` [PATCH v5 5/7] gpio: vf610: simplify code by dropping data check Peng Fan (OSS)
2023-10-01  8:27 ` [PATCH v5 6/7] arm64: dts: imx8ulp: update gpio node Peng Fan (OSS)
2023-10-10  1:44   ` Shawn Guo
2023-10-01  8:27 ` [PATCH v5 7/7] arm64: dts: imx93: " Peng Fan (OSS)
2023-10-10  1:44   ` Shawn Guo
2023-10-05 17:54 ` [PATCH v5 0/7] gpio: update i.MX93/8ULP and support i.MX95 Bartosz Golaszewski
2023-10-10  1:35 ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231004050428.o7l2e23xjcjkzzck@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=andy@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=stefan@agner.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).