From patchwork Sun Oct 1 08:27:55 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: 729099 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 47374E748E9 for ; Sun, 1 Oct 2023 08:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234564AbjJAIXs (ORCPT ); Sun, 1 Oct 2023 04:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234576AbjJAIXs (ORCPT ); Sun, 1 Oct 2023 04:23:48 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2065.outbound.protection.outlook.com [40.107.21.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E9911B; Sun, 1 Oct 2023 01:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l3Za+OfG33BffKw7MNF01hVeVC4mPnK2z73Bv9p2E6pPPqS/CsIp+f7g9nccKhi3j58/LVI3fjotIkOEFZtGLG73iyXBof8ajR34hNEMMad3FEE1FTiDn5+LbYCizkbwzXie4pN6PCrBI8c6wcgNpkrR0GqLe/EflAhh3N+bAG+dHEkRFua++a9nKwLYw9i5vSyGal7vWoXSBcBv4aVeYt9lq36r6Gs0k3Z2LD5cIRaXPadGn9wR+jDElKo8j+T5/u9QQTlOFUW9rdnleeh8bgLDJnMf82nxtNQgoZKCkWfXISeC63BYf5rGQXacUTNUsxOEXqcQLugvt3KDVIz2iA== 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=mr7sQz1yoHoDuwKLC2NruYcIIU1j0vmnjyNrB72diAQ=; b=DGUJNp8VD+e+09cU1R6fT8AOJW50rh8RvoFV36m5yYV6IS2xFluvTibbCajKtG3amrhR5ZraZvkFZnzN4rXME6J739rn/Q9UVdnhmNtcHU1BEXOHd7JnlIR+4K/FBCt28l2foZ/cZThyb6AwY6jZFmO6yTysI7fxYYZ+0wzEGYxMi7BZnGyoIbLHamPzd0sA46D1A7jJsGZRg0BvsmaMoU4R/EQI+Kd1Y+04V6721ggbNfvnv2QrGN8icaZ4SrotGkZoDxuxQF0845l0I456bhxWQN8/xEe2oUo8miuqo3yIVHpPgn3u0gWa/+aFNyxvFQGEpLGE2CFPrIkEEgb1Mw== 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=mr7sQz1yoHoDuwKLC2NruYcIIU1j0vmnjyNrB72diAQ=; b=TemXA3fwm0L0NDzSUnu3wOsguaL6tGUtcXmX8Mi109NXCMIx4Hb4nuLBSB9m/v/D/VB1c0bbF93nCSm5L8bK47dZKsd/6VorOyTM9nidmFJ/JyTAl2v4OApVruu+q3dpX+OM2KBqZqRVPTHMmvkXtPB4OamgOfDYToj2NfuvOh8= 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 PR3PR04MB7417.eurprd04.prod.outlook.com (2603:10a6:102:8e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Sun, 1 Oct 2023 08:23:38 +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.6838.024; Sun, 1 Oct 2023 08:23:38 +0000 From: "Peng Fan (OSS)" Date: Sun, 01 Oct 2023 16:27:55 +0800 Subject: [PATCH v5 4/7] gpio: vf610: add i.MX8ULP of_device_id entry Message-Id: <20231001-vf610-gpio-v5-4-8d873a8f224a@nxp.com> References: <20231001-vf610-gpio-v5-0-8d873a8f224a@nxp.com> In-Reply-To: <20231001-vf610-gpio-v5-0-8d873a8f224a@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 , Marco Felsch 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=1696148883; l=3444; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=F3ztsSlGWjYD7DS0l/EdF5KdUwt2G4UpUATZtl+c9F4=; b=KegxZZA5ODS4A6WjEfyRVj6thifs1w4UZjMjP9asJG7GUhUggfSs/8EIHD/jtC54xnc/YlAc9 uQAdHW//zQCBMrr9QjeUWr9c99ON7nCFdUl7zJGdUr/Aqia1aGegznk X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0131.apcprd02.prod.outlook.com (2603:1096:4:188::6) 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_|PR3PR04MB7417:EE_ X-MS-Office365-Filtering-Correlation-Id: 36104f56-5653-4af9-5dfe-08dbc257b6b5 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: RX2//Lzc2NGi/TYjs+cALM9CzWWfqEj+PGBLwP2q2M3Ytlh59HXSVOJuJh/n/tGqijUcvj3eEgY9r8QU7ULBmZRnOmGaehR1Ewsa1rUajdMjYBdgMdiWzZPwpOREOdhnx/H78V4wszl5JnxPPSDQh1RwUAd1VvVTYeQPsnzofjBZQKGznNOrqJ4wOCV1WUjE/FTrTE0JpX/Y5QRBn5fISMSvB/CQo4HBqYvOOqnvaaeklU3jd9yja4WxkvGjkAsiQWusbB1cjQw4ey695qrMdhPPd7UfS2TFCUUlpu9sK2uBGBE8rO2NVdMkz28ZoNt43Rd/x5GylX7m+cH/aDOAd80hcjmWzo9ZYtqSosnX/hev4hBbjiIiKPYIakvtNNo2XfxTT7fbvUzESD9pGnAfvb1CyFdFkJdprmFbW3V6vO4g24O392KB2t2GK2OLSf+z4BicWz6PIeEMlf38846iRgc2nmXVz4+sT6R4iwT+7tIapIMduSCRrdJlAhZz+EM2J0w3qNUTGhDg1p/nF6nJrPudUeAVYAjxxiRfECpSdvxZgZrIy/L3NIyWlAj+1LyOBkX+bOA3Dy2/JpuXeFq+xsAGtHBPC8QxR1antwqwBWiqv/okcWtFG4Mm9vcJQUSW0ztuzApH82LhM2ddwCbdNA== 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)(39860400002)(346002)(366004)(396003)(376002)(136003)(230922051799003)(64100799003)(1800799009)(451199024)(186009)(41300700001)(316002)(26005)(2906002)(110136005)(7416002)(8676002)(5660300002)(66556008)(66476007)(66946007)(8936002)(4326008)(478600001)(6666004)(6486002)(52116002)(6506007)(9686003)(6512007)(36756003)(86362001)(83380400001)(38100700002)(38350700002)(921005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/mI46jB9+H0IYxzLpxzaIuk8Oh9Z?= =?utf-8?q?/+fcL1nrZSXjuhl/y8S/Z2OEjPLETioy2KGTsdEA2XLZrJRAiNxmki9sGckIk2pm1?= =?utf-8?q?aa19darJ9HTqBKYDH0Gjv1BPZNE2I31wF/QySZZZynlF5m6kQaPKbUas+0uwPl6HF?= =?utf-8?q?2oJpmNpxs4GcPSVP3He43nB/B06Yzglz9o4I/1Ih7VMIV8TsQ/e5vThXidzcadoc3?= =?utf-8?q?WRn942g/DshaSv/R+BnALs6CNLnWPfkfEeQu2JNM8dZJXLWBfJYNykG4R4OCChyTj?= =?utf-8?q?8SoIGiEpbzuX4xdqovhZ3IEiHFQi2m64fKHkxOwCURIWPCXyRtrCJLnf5P5eMDQ+a?= =?utf-8?q?b16pPP4G67UAra1h8dv6GxuJgPgTcvdVc/uCmgNV8hpEkVEWPJ7Cf6TX9HbLDTBPH?= =?utf-8?q?ZiBm2RwJpv31Q2CA72vPYiuLiuCKnQ7OkucG3y7W4tb7/eVNZhHMIqZZoyydeDUdh?= =?utf-8?q?DbOOQoFMe6azZAOwsDBTXzdm9AkO1nJ2JifJndb42mGEdPHYFW2bBQjfg1jJHgiyE?= =?utf-8?q?0t+gBFO0RZA+6hEQuncMMiMQC7QMT8lY1HcZGQQfGm9X99l+fSqeC9Obpkq9uLo7v?= =?utf-8?q?dVCE0QeugYIC7/k2kxzE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Zk+RIIHQXCtbnlBNbJnArIlm1rxbCwNFkKRS0x?= =?utf-8?q?3rQ+4ATe7iiQ?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36104f56-5653-4af9-5dfe-08dbc257b6b5 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2023 08:23:38.7723 (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: 6nAJ7SA4rjCwjNgleYgipbcvFzeocv7SPUBGsTXTNG08qelmKityjSXhlTF6Rv128ytyw5TZi+3GJaf359vNuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7417 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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") || + (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)