From patchwork Mon Sep 18 08:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 724307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBED0CD37B0 for ; Mon, 18 Sep 2023 08:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240445AbjIRIOM (ORCPT ); Mon, 18 Sep 2023 04:14:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240768AbjIRINy (ORCPT ); Mon, 18 Sep 2023 04:13:54 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2040.outbound.protection.outlook.com [40.107.6.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91CC9CCD; Mon, 18 Sep 2023 01:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXdCe7QYaA3DC0mgod3AeJkkk7E/3jg91WNxRWvKQrr4VHc9scy/JrtMM0ol65WzMMvLTvgKKe2YnhBAKbaVEFAhzCLp1lXWGb33fI1+AgkoYvhxH5XsgmEYpW6zAcPOmG5kzfWEHi1Wv1VhIOAbB4e8es2nmV4cA+EFNayOSil/sG2b9+HnyQMtaOKimmVo0CcjAHj4dH14K8aUC78E3+y2yLaqSiK9GFcHahD1LkVAKKg92gdokCotlldKz4hTic6WtQhPep7ISRdZGgoIbk1+IaInA9gVqxKC3l9/9Im8PAK9var9rSbQiifQ97O5C2rNzp49VL1fCSFeG3PLmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U44AIPwM+ReyZbAGkQOUHn8DaaTMrFWFFP3j5j+CWfk=; b=UN/O/0fcZvB9C6MRoK3fcKk+NlDQg438wT3ElILuDI5SeMqXUcKoKcuARE561wimxxR5VKSV5OzyYNaHF8xv8oG+jiv6haleT/VjmjjHzqUUpi3AWmTrKT+BCSizYui+VrBrDdqdP418/NZS/NKLvx5PwD569McsfUomj/tkXSZcn4RQTMf4ruTjcO36hG+cTZyjoVQ9MYalWQBW/1cDyRX+O975412OzuUmXHH0jbuEPcw8UupLxYcQwb3FuNAC/fQZNDbX6DhSlJ7e8MkumY8g7GuWK9yB0KWo8q+dFU018/YbQ1yQtXStLNVmLkkXB2iqHPEh8e8ThKnL9f25sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U44AIPwM+ReyZbAGkQOUHn8DaaTMrFWFFP3j5j+CWfk=; b=CLt4as1O/rv4bdKIXM07vDITm0Z23H2bpK1UVsNJWvOHETwoK6RPozmWzdChnSNK2WdnTztXfAIl8WVWeu0OFydcUiKL26TgfYAtm1fSIhBUsWHGBvjJihkB1OHMhr+k7WUX4g9lgEPd491IUY1JEwfctP2aiM9m1qSfh9einz0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB7133.eurprd04.prod.outlook.com (2603:10a6:800:126::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.24; Mon, 18 Sep 2023 08:12:04 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b%3]) with mapi id 15.20.6792.026; Mon, 18 Sep 2023 08:12:04 +0000 From: "Peng Fan (OSS)" Date: Mon, 18 Sep 2023 16:16:08 +0800 Subject: [PATCH v3 4/6] gpio: vf610: add i.MX8ULP of_device_id entry Message-Id: <20230918-vf610-gpio-v3-4-ada82a17adc5@nxp.com> References: <20230918-vf610-gpio-v3-0-ada82a17adc5@nxp.com> In-Reply-To: <20230918-vf610-gpio-v3-0-ada82a17adc5@nxp.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stefan Agner , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695024993; l=3349; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=KIwUQXLlZAXkxFxtSdDA1eXGhBoOZN8UxphNKaoctdo=; b=mTPX5KPAlBjMnK0Y0+bWHGDEiHXY82PTK0EyR6zz39BLQXOZ3GPVQLn3/oMtdmTMCwXSbGHRM 6AI3ni4tvl+DJvfcdhLmc1LW0pPZelFuVT4f4plSvyCnXFMWLziVSLU X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG3P274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::22) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB7133:EE_ X-MS-Office365-Filtering-Correlation-Id: b5b6d033-be69-4447-8f9d-08dbb81ef150 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1WjqIuLTAAoZKtaXw448QH20EBKaftx8oFqSOfoTnhqAYfuEoTPC0GJE8qWhpdWzC/cyhbzRJuT6g4lB94rpMWZWnZDItT0KL8brhth7h72CRI7k3P5zcc0K1paLiIzx2ORaEX9BWTZE/9c73NUaVvUA6YTOVCyglYzA57KtpdpkBsFtmkyn7p6CIDLMDvl3FE0fVv1+GBeJHXHSUwSSfGf8ESCsdydhVTCjCwST8xVu3DN2ct+3Bj4ORW4zWek9EjBvf/KH5k+2rtRIiJ6VT1xslXuvOGxXxYLUnrwdtP9aRA5wQfkx3B74puo/3tnPd0Ns6vVdXEr78SVCvvfUptWYV0BdPp0JvY9Bnj3GZWAGhn+D3EuvvEmhttiIH1sb99W6McnJdnl6ZlDx3bSmprxvf0LWGWHL0R3EKU5wdqvXPK4uVm+WqAlHFjNFnSAGV8YcaVWkxYfhrFWOyDA25orjNVSDJtg3+OaRRbpspOhZioMOx1lxAZLf0iwotfqWKCzgeGB35tcdzpWXl5Xh8zX5irYuDErDVHSLbDEoROtWBpOHuJt805mpwPd3LZJCIoidUb2PqmJBaLKzb21DSt5hFixRu0xmsYKQbWkhBGizuUtPFKCAcDinjz9pbnLhnru0IEJ6RkUURzjNKAj//A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(376002)(39860400002)(396003)(366004)(136003)(186009)(1800799009)(451199024)(2906002)(7416002)(5660300002)(8936002)(4326008)(8676002)(26005)(41300700001)(316002)(66476007)(66946007)(66556008)(110136005)(478600001)(36756003)(52116002)(6486002)(6506007)(83380400001)(6512007)(9686003)(38100700002)(38350700002)(921005)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PIdKSFKpJY/mnHOx3Zr/3Dcws6Xr?= =?utf-8?q?XdoPJrMDmVQQi7Ie5ayWEIbseuSaioMZ2IlDJ37N1wUzgmcvoX9X3YCtSaeoX2mdp?= =?utf-8?q?P9Ho3duZ6NsNe4uL1MEiKQSqvb1hll6E0qvYKrK0iRqjWeIVZxcxmSIcNO9v7y++8?= =?utf-8?q?AUrgqAokthUxtFSPGWUKmyr9v9KC24x4AYJ3G/A5dKI5wKoEAPrvqS1IvCqgS0VPb?= =?utf-8?q?2AQh5SB++1P2HR/+PZ+E168SryzTd6fz/NP8bNK6dNRmluP2LKe9UF9WP7Muxuz8V?= =?utf-8?q?AIuvejaYz23p/mlgYJKOatSknOQBetogDJhHR8gXcE6miqUXi8NVtoAHmBeR8QPuB?= =?utf-8?q?lVzUP4UOQIMKfhvw9JDpVd72dQ5texnYP6YMWpMke4muOaXtsf15KDASe3wE0h4JG?= =?utf-8?q?ltjaIPsTrhpJSN0AoaGG385qhi7C7WpoNn9onip13r//AbSEEq2FTtdgLw8AyAFC3?= =?utf-8?q?8DcsY+Ki+zzA35SNupEXCF2V12vf8a3lQ31nBTFuhg+rB9MsVhel7EEj8cdDjXv60?= =?utf-8?q?sg0RXB4lQSFMd8n5/RZArK25uyG2yQK0wW+cS2JCl0+/58A6y5BN0UPmMqm5DFdmk?= =?utf-8?q?m2lS2LnXawkxrlPNej3U7Yb7nqpYptx+0uxsYGIDhBeCPnp9mG9+BYE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utf-8?q?a8F+XfpDYzke?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5b6d033-be69-4447-8f9d-08dbb81ef150 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 08:12:04.1753 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: l/lmeqamCOyBvFwx78/9xnFsJEUbtt9I6bYQnEHcflzo4GpF3vYGgAU9sCztOFS6en5chs7Uz5h5HFui/Sl0+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7133 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Peng Fan i.MX8ULP GPIO supports similar feature as i.MX7ULP GPIO, but i.MX8ULP is not compatible with i.MX7ULP per binding doc. i.MX8ULP only has one register base, not two base. 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 | 55 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index dbc7ba0ee72c..ef2455093708 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 is_imx8ulp; }; struct vf610_gpio_port { @@ -60,13 +61,22 @@ 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 imx_data = { .have_paddr = true, }; +static const struct fsl_gpio_soc_data imx8ulp_data = { + .have_paddr = true, + .is_imx8ulp = true, +}; + static const struct of_device_id vf610_gpio_dt_ids[] = { { .compatible = "fsl,vf610-gpio", .data = NULL, }, { .compatible = "fsl,imx7ulp-gpio", .data = &imx_data, }, + { .compatible = "fsl,imx8ulp-gpio", .data = &imx8ulp_data, }, { /* sentinel */ } }; @@ -255,6 +265,42 @@ static void vf610_gpio_disable_clk(void *data) clk_disable_unprepare(data); } +static int vf610_gpio_map_base(struct platform_device *pdev, struct vf610_gpio_port *port) +{ + struct device *dev = &pdev->dev; + bool dual_base; + + /* support old compatible strings */ + if (device_is_compatible(dev, "fsl,imx7ulp-gpio") && + (device_is_compatible(dev, "fsl,imx93-gpio") || + (device_is_compatible(dev, "fsl,imx8ulp-gpio")))) { + dual_base = true; + } else if (port->sdata && port->sdata->is_imx8ulp) { + dual_base = false; + } else { + 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; + } + + return 0; +} + static int vf610_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -269,13 +315,10 @@ static int vf610_gpio_probe(struct platform_device *pdev) 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); + ret = vf610_gpio_map_base(pdev, port); + if (ret) + return ret; port->irq = platform_get_irq(pdev, 0); if (port->irq < 0)