Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1226883rdb; Mon, 2 Oct 2023 03:17:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxRajl+OL6GhihMoIIV2et+Df8WNnbmp0FRmWVQsDhE5crI3enfcedEB5GkyC5O3vaKZQC X-Received: by 2002:a17:903:32c5:b0:1c0:c0af:ba59 with SMTP id i5-20020a17090332c500b001c0c0afba59mr10689522plr.34.1696241850095; Mon, 02 Oct 2023 03:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696241850; cv=none; d=google.com; s=arc-20160816; b=BuVDN6+Obi08lYHUK7kRk2YgBaSF9jbvlC0gi9cltb9EyWpPu13sbf5nX/XachkycG bkO/86rpyya7bf2nzDSGO1/IhhU0rOGOE1t9d83R3JKDi7ogCKQ6qnuoxE9ys+jYMKrM feSBliKIRg3f/qoBjjjnifqTMC6akxyTtTWi707cKoP1jZnvZf/eL/AOzGzggANlrlXj I9Wh4I3DUcOBQh3k7BIuSVT8/KaNQ4bbDXNtfc2Oi1VutZNjM2NLXDyEdN6SAbtd1ZOX kkTDPmtQKkfjAjrMO4oZ9f2l7E8EFRIGh/iNsm+iDAxBtRMcvgfxlhxB5OXyQIJrHeyK 32NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=w6lSGzMYmbvQIYpVjiyxdxEmD3PDo3maFv/Yj2jKXkA=; fh=Wql28Enjdf1zHFo5JejCkcWrY0uAQdJfnIi7S4I+O0M=; b=gB9aG2BXZPZlGY0s8rexUFGnMnXwVCfB00FiaPfxUOB3461tJeJWj6rkVfwNmWTeXj bA7WNzFBhnqSA9sx18NStPqBRAq8uxDahU/mhgYa0GqRFIBQQnjIn05lD0PpcV1OUaBv jlLqr1LBbh3N2F01IfHed1VfoDW7Lb6qdby6/ykqQEMXal9Ma6nPWs7EtTwleDpPSUka bccKuOdHw5CgP+6rY3gMykF08Hu/3YybXuhXNcMPNTEKkCLsz/zIIgztwVw+8Jh5g/in VMIA8Dx9Vcm1PyBhyHn1mfWlNy5d/Vn4khCnpYwFqxrSXctGCr9UFAphHtklLuUkkWLu +z/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=gyK3ViCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ld12-20020a170902facc00b001c3671d3151si25392817plb.92.2023.10.02.03.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 03:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=gyK3ViCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id E3A048057E7B; Mon, 2 Oct 2023 02:04:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235950AbjJBJEp (ORCPT + 99 others); Mon, 2 Oct 2023 05:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235974AbjJBJEn (ORCPT ); Mon, 2 Oct 2023 05:04:43 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1859CE9 for ; Mon, 2 Oct 2023 02:04:38 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id ada2fe7eead31-45456121514so3686020137.0 for ; Mon, 02 Oct 2023 02:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696237478; x=1696842278; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w6lSGzMYmbvQIYpVjiyxdxEmD3PDo3maFv/Yj2jKXkA=; b=gyK3ViCxB5CiK7cAFiaPb/6seSebdH7OUrotGMBqaF+yMjWGH3EEqLvyIqKlTgCQdC 8cgX8x0zt2Zvx188KUUlL//un6jrwNUlV7PQaCBX2HCt16AKCgAlApyXEkHfyQL2Twyf +3ZDx2w2ZuiXpyFYj78R86tqlsTEc0ihmQYlN0OXf9yBkGU4L6rsk4CoGXLYBDKMghco fsexOMU+zFejkPr9Z1MxCxfQwSKNq2vR+FtZ+PGRKIUf7QYknI6Odc3HlBfsnxeX8rLT l6Ndz1IS+YlkrpHG8ejPKXaCCr/ayn63wuzJLKJ2HF8By4Yop1E2sGHHy2wvyDbcTDRt 1U4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696237478; x=1696842278; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w6lSGzMYmbvQIYpVjiyxdxEmD3PDo3maFv/Yj2jKXkA=; b=Fp1pZs+Tjv4HTJt0whVYk7s7cED6gVatKze+mKah99mliPndxrA37ye0Wm3gszuEad 91DuBYrVWxkCgZzfRH3BXUPztZnCJj8u6ZIEorA33jyDdE2jG6inmt4gz7yEfhMRc07k QWACik1r3U0gqPdA5XZSCqN6/RJnKh7wTUTQgXNIBYlNEuS4njfNA42q3I5ICWYPycwl lUUa9apq6N22KvTmSyVskFiuyq15FeYz9ojqsaHRGQmtGHPACOH398iFdRxTHqu3M4+e +3AL32oOGg4X9S5KPLlMkmqpBTZ+oeORgd1SEoRcMSemplGNoGWJg6Yj/jRdQ4pngtQu sTcw== X-Gm-Message-State: AOJu0YxlJT5peIqh8uBQv/SWddDXsjb9XMqaM6Ypd7BSDW6qoX/nJZJq DVI/vftDDrlGXW0I7rWKJ54IFiABukuUqNkTNAZJYA== X-Received: by 2002:a67:ed4e:0:b0:452:5798:64bd with SMTP id m14-20020a67ed4e000000b00452579864bdmr7520196vsp.35.1696237477855; Mon, 02 Oct 2023 02:04:37 -0700 (PDT) MIME-Version: 1.0 References: <20231001-vf610-gpio-v5-0-8d873a8f224a@nxp.com> <20231001-vf610-gpio-v5-4-8d873a8f224a@nxp.com> In-Reply-To: <20231001-vf610-gpio-v5-4-8d873a8f224a@nxp.com> From: Bartosz Golaszewski Date: Mon, 2 Oct 2023 11:04:27 +0200 Message-ID: Subject: Re: [PATCH v5 4/7] gpio: vf610: add i.MX8ULP of_device_id entry To: "Peng Fan (OSS)" Cc: Linus Walleij , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stefan Agner , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Marco Felsch , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 02:04:48 -0700 (PDT) On Sun, Oct 1, 2023 at 10:23=E2=80=AFAM 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 tre= e > 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 =3D { > + .have_dual_base =3D true, > +}; > + > static const struct fsl_gpio_soc_data imx_data =3D { > .have_paddr =3D true, > + .have_dual_base =3D true, > +}; > + > +static const struct fsl_gpio_soc_data imx8ulp_data =3D { > + .have_paddr =3D true, > }; > > static const struct of_device_id vf610_gpio_dt_ids[] =3D { > - { .compatible =3D "fsl,vf610-gpio", .data =3D NULL, }, > + { .compatible =3D "fsl,vf610-gpio", .data =3D &vf610_data }= , > { .compatible =3D "fsl,imx7ulp-gpio", .data =3D &imx_data, }, > + { .compatible =3D "fsl,imx8ulp-gpio", .data =3D &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 =3D devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); > if (!port) > return -ENOMEM; > > port->sdata =3D of_device_get_match_data(dev); > - port->base =3D devm_platform_ioremap_resource(pdev, 0); > - if (IS_ERR(port->base)) > - return PTR_ERR(port->base); > > - port->gpio_base =3D devm_platform_ioremap_resource(pdev, 1); > - if (IS_ERR(port->gpio_base)) > - return PTR_ERR(port->gpio_base); > + dual_base =3D 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? Bart > + (device_is_compatible(dev, "fsl,imx8ulp-gpio")))) > + dual_base =3D true; > + > + if (dual_base) { > + port->base =3D devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(port->base)) > + return PTR_ERR(port->base); > + > + port->gpio_base =3D devm_platform_ioremap_resource(pdev, = 1); > + if (IS_ERR(port->gpio_base)) > + return PTR_ERR(port->gpio_base); > + } else { > + port->base =3D devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(port->base)) > + return PTR_ERR(port->base); > + > + port->gpio_base =3D port->base + IMX8ULP_GPIO_BASE_OFF; > + port->base =3D port->base + IMX8ULP_BASE_OFF; > + } > > port->irq =3D platform_get_irq(pdev, 0); > if (port->irq < 0) > > -- > 2.37.1 >