Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2383522rdb; Tue, 3 Oct 2023 22:05:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXpLCmr4clreLMChu9rMIb3u0FQqmvv5ql5hjgOsZUlcseDIKYOdg19sRKlhTQ6T4egHdp X-Received: by 2002:a05:6870:1d1:b0:1d5:bda7:1314 with SMTP id n17-20020a05687001d100b001d5bda71314mr1525116oad.33.1696395905173; Tue, 03 Oct 2023 22:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696395905; cv=none; d=google.com; s=arc-20160816; b=qNdPCe/RmLOPxn1fxSSK+ay7NX4neMl9Xx2/n+13jyuhMxFKkvklwq4oYlxYehtonC m1RhcnZg7fAqW2UzMNgPafp6i+jylTmbraXCqFwRce0kJ1EhihEE5djQMfHmPLbsh7hk 18chU8ae8Q3itcS9xdKCni81qg2INvzU2i0iBmTa2OP7ZS+qWqBaCDaSLCfXdFf/oL4z ddUJwOX8kIGEMv8L1yU7SCklU4jvBhJdjL+2jcUkJu8Kajn16p4KeHrNCJEokDx0gIKX RgM/QWE8d5sl7jXLMyPMzRiqHYG0POAb+QWnbwTItHbimWcu2beBUX6KonxSKhwzbXXA t2Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7JiqqVStoXUmQ0fF8C+6UDNsohh2swY4zX4S089S7sc=; fh=IIYbwir19pPyco8o7Pfov09Gw1p0tx2xtjiO1aw+iwg=; b=ODcFhSI/hM85qqjPtZc1gbRT8AElSORDVj1tnn56F41jc43ZS960mphvXd2L+9TeW8 Se2Bdee2kKDFaDs1Atu/sZO78UpK6illW2K1tGCaS82HoE+5+hUaRJsALsa+6+5dD9ou zSCetRHGe1u+G8widzRWSQsuVLETnhnEv6nkpBXltg8iCNN5XgJxdAfANmj/afAl7kP5 nXNVNjCjNvaN5U8irWkT7MDgRQqKixSxte2zhzo9XGmrldnBFR4KJ6+CmInFfZtSbKFb +LZ3gUS9L7g5IweXe5rm2oi6AppVbcy32M/lKRkoVyXt5A5AfbbSxH6mH+f+nqNb4yRV RFHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id fc21-20020a056a002e1500b0068a4ba92eafsi3194988pfb.54.2023.10.03.22.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 22:05:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 78518802781F; Tue, 3 Oct 2023 22:05:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241319AbjJDFEz (ORCPT + 99 others); Wed, 4 Oct 2023 01:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241314AbjJDFEx (ORCPT ); Wed, 4 Oct 2023 01:04:53 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE34B8 for ; Tue, 3 Oct 2023 22:04:49 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qnu3i-0002VK-99; Wed, 04 Oct 2023 07:04:30 +0200 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qnu3g-00Ax5H-J1; Wed, 04 Oct 2023 07:04:28 +0200 Received: from mfe by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qnu3g-00ChlX-Fh; Wed, 04 Oct 2023 07:04:28 +0200 Date: Wed, 4 Oct 2023 07:04:28 +0200 From: Marco Felsch To: Peng Fan Cc: Bartosz Golaszewski , "Peng Fan (OSS)" , Linus Walleij , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stefan Agner , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , dl-linux-imx , "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v5 4/7] gpio: vf610: add i.MX8ULP of_device_id entry Message-ID: <20231004050428.o7l2e23xjcjkzzck@pengutronix.de> References: <20231001-vf610-gpio-v5-0-8d873a8f224a@nxp.com> <20231001-vf610-gpio-v5-4-8d873a8f224a@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 22:05:02 -0700 (PDT) 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) > > wrote: > > > > > > From: Peng Fan > > > > > > 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 > > > --- > > > 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 > > >