From patchwork Tue Sep 3 11:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Potthuri, Sai Krishna" X-Patchwork-Id: 13788538 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3E66CD3420 for ; Tue, 3 Sep 2024 11:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/mgQnQujlDRhyvJfjgDxSZYbzQSOlQeubMM4Tmo472w=; b=25up4IudOc/7XhFfCQF+0o8cvU RUfMs59y0pvdPmnUnqe97DJmoVxpgvtn9O9op2hGi2UAGMCCUxHR11OdHL3MdGP5BShm0m2fJ+Xr9 oiYM0nmsFU4+IfDrHUCFjfQjAX2vc54V0zN5Zkf9p0N6QPGpopHZiiJMH5jvgg7zJKK1/O0ji5kxE 4ZnUxcs+D9k0SD1LKHA5QwG4INgLXPaKulNAOs/SPWUKvbPj98sjFy92A0GFhBPO/DI7xoFEL4t0R w9SrLE4SEpKbVfaQySDO2VS1PTeSQoSdYAQ1hleeA48yjw/DFEmtt5qUwdThFsNbot9CLVUHASBmk RJz6mhjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slRRG-0000000HU9F-2VkK; Tue, 03 Sep 2024 11:11:10 +0000 Received: from mail-co1nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2416::600] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slRO0-0000000HTUo-06hB for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 11:08:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WjDBb30Vdd+dsXp11OvA5avd0tqOAnUYqp9bVTQUOj4+S7MSj4YIAGzDZOkGo5R0vZzqYQIKQCDkpEJsIsVPPkiI3716iwYP/T6dwrLKONOQvSG+qvRJkPoEoJv8RgJ4l5kE0laJGQBNZiV5mZOIK+07dT0UQ0/7hc9NvZgCP+7s30BLYOHnFq/1/aFViONdnLz/ffMlaxeS86Ds+S6rxK/UbbJeL5cTkipvQ8lHCj/JlyOodx6bqEO0PMiHHnJJZMIiPXJBbr4SSmadrCfSV2HEeOmpmVoGGlKA2DjYPE3qvlZDAaGFMBKYtlOd6gwqhVqOujfrOhFfJUZdTITzaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/mgQnQujlDRhyvJfjgDxSZYbzQSOlQeubMM4Tmo472w=; b=UYaSpJ1c+q0oYDbyDYFDwYWz72b6x//FzMNJ5H0Mkey2XeJv5YXOkt/X2hqXF3BIeY/WXtqqOXWLFJ676Hj2CODyYAE8P9XEj3xY2OXBTweWOa/EWeWFaWEZPFjBYpDFYdelpZBTF9pD8w9RdrimZjkVeeMAVmrC344k2Fj0p4DMu+I846gRiPNRLio1jR5f7pxUPSEq2xvOGWlbZBzn6pAS3SU/DlTOSQyjDJ8ZrR3g5j62nxl9dOfY3eqfAsvJIoGUqpABTYQprEV745nD2LJJzjRYiiuNZy978rOK4dZJHPFZr1N9mtwPpYnpOrkw81Pin3tG33xU3EtAfkGHsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linaro.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/mgQnQujlDRhyvJfjgDxSZYbzQSOlQeubMM4Tmo472w=; b=IAaK8WdP6HLlIad8XyRKqfTzYMfemBIG4IDyzdcN9H85ZRtogC4CL0F+4r3r9Dwmhc+Wh7l3X1K2eh6N0+Cpz4qSdJBN2nK32seRlR0CctgrbA3ILKi8lk9jJy49dwo0JF/LXXb4YpOJNwbhgHoc67Sv9pX3SUpgQsZlERw2JHE= Received: from BY5PR04CA0012.namprd04.prod.outlook.com (2603:10b6:a03:1d0::22) by LV3PR12MB9120.namprd12.prod.outlook.com (2603:10b6:408:1a3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Tue, 3 Sep 2024 11:07:41 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:a03:1d0:cafe::8b) by BY5PR04CA0012.outlook.office365.com (2603:10b6:a03:1d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.26 via Frontend Transport; Tue, 3 Sep 2024 11:07:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Tue, 3 Sep 2024 11:07:40 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 06:07:36 -0500 Received: from xhdlakshmis40.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 3 Sep 2024 06:07:32 -0500 From: Sai Krishna Potthuri To: Linus Walleij , Michal Simek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jay Buddhabhatti , Praveen Teja Kundanala , Greg Kroah-Hartman CC: , , , , , , Sai Krishna Potthuri Subject: [PATCH v4 3/3] pinctrl: pinctrl-zynqmp: Add support for Versal platform Date: Tue, 3 Sep 2024 16:37:17 +0530 Message-ID: <20240903110717.2283362-4-sai.krishna.potthuri@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903110717.2283362-1-sai.krishna.potthuri@amd.com> References: <20240903110717.2283362-1-sai.krishna.potthuri@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: sai.krishna.potthuri@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CE5:EE_|LV3PR12MB9120:EE_ X-MS-Office365-Filtering-Correlation-Id: fa7ee561-c35e-4d1a-30e0-08dccc08a0ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: HBHP6sxVC5b4/s/CKcTTA23pIJpWCZNhq0cFHos9avO6ospvFd5H9GvaV1fSNejjooRE3lakbXuTarC29aMSPpsHBRUSK86TdubpG4XDh7pCX8DiL6kyQZ0Qpeh4nyxGxBkVz3YV2Mfxonh3BQFuA7GprkosQwKvv1sjSgOJvjPYRyZofc0Fe395PAu0DLpvjW7odWe0VRUhAMPZ/yqqBDam+50Yv7r6BpunT6BDE4eJlKVp++3Y3RWLzZugVuW+O6Q9lammWZsd2R7D/LbAiGA+8uaaKOIHKEu/c/nhU8Nd9kUN8FxKbgwLOk8p4tV5vX8ju6WVOXG2nT/Nu5JuBUVHWfBNbX2EYFQ7SNFLk7PXyJehnbVBfeVYHGhBvtazkKeYkMFf1eb4DGNmw24z0+muJ7u5ux1B7LPPJ4Su9dYEXnryQTqvdDpWGZTzw4TmMYnKpSiSu8tGSaJqgpTumseI+3YRy4S+Lf83dZAaxyANzgMza2b+ky3aPtLbklYJcjCUUnxHAnePROuMq4OwXZrpnwssRul/0A+vzjuKseTZTF7mkXlnScP78i+FHbYJMvbyMm4EEXIPvXvRO/HFRdxFdpdC2BvDzs/UKSgZMwRMo3+wcnqYGGbVg5dvC0FOjyOH/N7KL40xrs6EFVUhflQp6T6qGMdGe7JIr2pkP98MAd7C3EyIzMGd5xiJZiGxtvWCWUgprNZMa/6Ss74V9CDtS9e8TrRj0Nu/xIUn5i676ZRg4284I7kGTNICOKahJv8Zi2Lcacnsw9E7TWgfIB2WA/C1mAi8ZbRL5V8DDPUU59JZ5ncnpBUk0IxsHd3VhueD1mavs1pzgwcYvSHQRtZEjImWBNVth/6Bw091qPPE+57IZ7hHt3FU4a2Qh1IVV5kofHau0CMzQ11sXgBFmQuqJiobHmpGJD/bdIwiepqOorHaEzgkIGFlGqqtzpqdnxz+t/lQtE18LY1W1Gv+3+PhKEZMENifVjeOnDUjV6okeY9LbR9v+setTHIKf084ehL63rpPv6nEYoI5vh9kxexqR5fZh4PSe1QvAw8Bjf0d5YmlmEZaPfpNsi4oYd6A4teh8PYaiXeo7LpnbMg8xswR40bDQL/fZGoziRvDXQU7L5H4RPR+kZ2Gh7Qx73uRLPbysOqBjIWegj2bI72+U/WPnPJhpo/RD6MdVr8bH1X5dBj+86Zk9SmRGLKOWvt+VSi8x3V+RLN/tKI0Sh5dTWGDevZY0aVZ/HqDYsntjmEHH9UbNBCrLMEH9K26qbCOzxLzeDe3TPJ7Vc/OoDxeLKQON658fJ8kkGXnSqGBHDyPWL7OgDhqrCmf1JhR0xD0Pc6Ah7Qb5gv7vyW0CspdKyQ2iqF6sNrsfDDgiwP218nCesFsk4gB8EtOu2XC0vJ7cGRnTH00dX0/65sfaY8g60agXDTLKOHPuxV2EK4dPkQj4C1d5caeCOLKT7rzeOWj X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 11:07:40.5936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa7ee561-c35e-4d1a-30e0-08dccc08a0ae X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9120 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_040748_097375_E19D0C14 X-CRM114-Status: GOOD ( 23.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add Pinctrl support for Xilinx Versal platform. Driver checks for firmware support to retrieve the Pin information, if it is supported then proceed further otherwise it returns error saying operation not supported. Latest Xilinx Platform Management Firmware must be used to make use of the Pinctrl driver for Versal platform. Signed-off-by: Sai Krishna Potthuri --- drivers/pinctrl/pinctrl-zynqmp.c | 97 ++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-zynqmp.c b/drivers/pinctrl/pinctrl-zynqmp.c index 3c6d56fdb8c9..2b9f8db49a15 100644 --- a/drivers/pinctrl/pinctrl-zynqmp.c +++ b/drivers/pinctrl/pinctrl-zynqmp.c @@ -10,6 +10,7 @@ #include +#include #include #include #include @@ -44,6 +45,12 @@ #define DRIVE_STRENGTH_8MA 8 #define DRIVE_STRENGTH_12MA 12 +#define VERSAL_LPD_PIN_PREFIX "LPD_MIO" +#define VERSAL_PMC_PIN_PREFIX "PMC_MIO" + +#define VERSAL_PINCTRL_ATTR_NODETYPE_MASK GENMASK(19, 14) +#define VERSAL_PINCTRL_NODETYPE_LPD_MIO BIT(0) + /** * struct zynqmp_pmux_function - a pinmux function * @name: Name of the pin mux function @@ -93,6 +100,8 @@ struct zynqmp_pctrl_group { }; static struct pinctrl_desc zynqmp_desc; +static u32 family_code; +static u32 sub_family_code; static int zynqmp_pctrl_get_groups_count(struct pinctrl_dev *pctldev) { @@ -596,8 +605,12 @@ static int zynqmp_pinctrl_prepare_func_groups(struct device *dev, u32 fid, if (!groups[resp[i]].name) return -ENOMEM; - for (pin = 0; pin < groups[resp[i]].npins; pin++) - __set_bit(groups[resp[i]].pins[pin], used_pins); + for (pin = 0; pin < groups[resp[i]].npins; pin++) { + if (family_code == ZYNQMP_FAMILY_CODE) + __set_bit(groups[resp[i]].pins[pin], used_pins); + else + __set_bit((u8)groups[resp[i]].pins[pin] - 1, used_pins); + } } } done: @@ -873,6 +886,70 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev, return 0; } +static int versal_pinctrl_get_attributes(u32 pin_idx, u32 *response) +{ + struct zynqmp_pm_query_data qdata = {0}; + u32 payload[PAYLOAD_ARG_CNT]; + int ret; + + qdata.qid = PM_QID_PINCTRL_GET_ATTRIBUTES; + qdata.arg1 = pin_idx; + + ret = zynqmp_pm_query_data(qdata, payload); + if (ret) + return ret; + + memcpy(response, &payload[1], sizeof(*response)); + + return 0; +} + +static int versal_pinctrl_prepare_pin_desc(struct device *dev, + const struct pinctrl_pin_desc **zynqmp_pins, + unsigned int *npins) +{ + u32 lpd_mio_pins = 0, attr, nodetype; + struct pinctrl_pin_desc *pins, *pin; + int ret, i; + + ret = zynqmp_pm_is_function_supported(PM_QUERY_DATA, PM_QID_PINCTRL_GET_ATTRIBUTES); + if (ret) + return ret; + + ret = zynqmp_pinctrl_get_num_pins(npins); + if (ret) + return ret; + + pins = devm_kzalloc(dev, sizeof(*pins) * *npins, GFP_KERNEL); + if (!pins) + return -ENOMEM; + + for (i = 0; i < *npins; i++) { + ret = versal_pinctrl_get_attributes(i, &attr); + if (ret) + return ret; + + pin = &pins[i]; + pin->number = attr; + nodetype = FIELD_GET(VERSAL_PINCTRL_ATTR_NODETYPE_MASK, attr); + if (nodetype == VERSAL_PINCTRL_NODETYPE_LPD_MIO) { + pin->name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", + VERSAL_LPD_PIN_PREFIX, i); + lpd_mio_pins++; + } else { + pin->name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", + VERSAL_PMC_PIN_PREFIX, i - lpd_mio_pins); + } + + if (!pin->name) + return -ENOMEM; + } + + *zynqmp_pins = pins; + + return 0; +} + static int zynqmp_pinctrl_probe(struct platform_device *pdev) { struct zynqmp_pinctrl *pctrl; @@ -882,9 +959,18 @@ static int zynqmp_pinctrl_probe(struct platform_device *pdev) if (!pctrl) return -ENOMEM; - ret = zynqmp_pinctrl_prepare_pin_desc(&pdev->dev, - &zynqmp_desc.pins, - &zynqmp_desc.npins); + ret = zynqmp_pm_get_family_info(&family_code, &sub_family_code); + if (ret < 0) + return ret; + + if (family_code == ZYNQMP_FAMILY_CODE) { + ret = zynqmp_pinctrl_prepare_pin_desc(&pdev->dev, &zynqmp_desc.pins, + &zynqmp_desc.npins); + } else { + ret = versal_pinctrl_prepare_pin_desc(&pdev->dev, &zynqmp_desc.pins, + &zynqmp_desc.npins); + } + if (ret) { dev_err(&pdev->dev, "pin desc prepare fail with %d\n", ret); return ret; @@ -907,6 +993,7 @@ static int zynqmp_pinctrl_probe(struct platform_device *pdev) static const struct of_device_id zynqmp_pinctrl_of_match[] = { { .compatible = "xlnx,zynqmp-pinctrl" }, + { .compatible = "xlnx,versal-pinctrl" }, { } }; MODULE_DEVICE_TABLE(of, zynqmp_pinctrl_of_match);