From patchwork Tue Jul 30 06:55:48 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: 13746771 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 085D8C3DA49 for ; Tue, 30 Jul 2024 06:57:05 +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=EKJWAB1OTG8Kbexfh6haTzUMXI oY00fqSMTomqaRqX+OWYQk2dPl/fdRwSSlsDfy7nkSEgdX5of3UZgJuir1Ex+RyYSAo3SR7OmTMx1 ZHQQpNnyFIUP+47Ilg0aX+csElExjayxEfZO/rou7zS4yH+8Fl+HgyQiuSqJpU4gtXa5BoFk5+ZZ4 K3fQh4UZz5um+Z7GFfmSnr+JBJ3ErddzivzO+HYQgwvEVoldhftWmuTnkjV5PWByUc0eSnuP3hQDj tYrJPSuWVWFxsT+JHF9pkHJ2lurq6cqlpjfUvtxKxNAou5ZxqwsdIY/t6AxhGQXUVYSRkSYB+yYMx /0S5ZLNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYgmy-0000000Dutm-3HRV; Tue, 30 Jul 2024 06:56:52 +0000 Received: from mail-dm6nam11on20601.outbound.protection.outlook.com ([2a01:111:f403:2415::601] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYgmM-0000000Dukx-2vjP for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 06:56:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yNKnD5nO+4JSze0UwOtIXIEuDVf3//jnZqcvYcWHQpjbdFa3JC32GtWH+Bp/cI15x+SZOzqHpEmuJBOG7XhmPEaawGGxTqxD9F7nD2lOkFCaV/VaNWgyPZfywthVWAe/EB/T8/yq416A24COj177OWY/I/BYf3mUCZlctOdnxzD4C98cpqb00KipBy2WnBFSciUbfcUqzk2aq6NAW14RHSxrC9UbTzBTSGvUdYpNX6ZoVQ57vOlw53BFbTnB+srMxdpnumku6Ip4KO569P2g8xsvdD/OnTtTLBj4WKNTC0OmImEpvPg+qRyxxtiaqbkje+swU78oXE4K30wbjW3jlA== 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=LgDalygN4xW7bbL51i+xXIFgkXv1eLLIN93Iqkc2+8pkVesbr0dh5N+esutrzy0X/IsvL2iGT6ixyEg0JrED5pinMybI7112A5YaM63r2jGfIJ48K+9lZeg8H/cHxmoEN7JaVZUJRrc598UB95G2ODI9hZg2RNSHlZZTK6A+3x2SIJa9rQNB56ASBPJll3JgtpmDgVyIHC3aHIjcHwIS38yJtNb2bjkJGo5Vrtbk61ucvRU2VSAtO3xxnTGawRRV35QPRuX6SjYgS0XHYpc+hXaVehVw1ffCIMTtZQWvu0E9uDX1YJEh/qC51kcJU2tWrGTJxygKFgVzcRn+pAi4Tw== 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=B9wFfaYs2q0xMQV3Rndh4TDFgaURy4MICmBcWrtscHZPo1vv8JWygmvoHxDFEju4XKMuignacm4ecDfjHXM5Z5dVrIPZpDT9g9FHHjJ10oLnDh22m+uuIfR6j7epbeqr0go12NFcMheEL7cZZevfPWNfDG/LCnqnaKmXqk3zQpQ= Received: from DS7PR03CA0102.namprd03.prod.outlook.com (2603:10b6:5:3b7::17) by MW4PR12MB7165.namprd12.prod.outlook.com (2603:10b6:303:21b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Tue, 30 Jul 2024 06:56:09 +0000 Received: from DS2PEPF00003440.namprd02.prod.outlook.com (2603:10b6:5:3b7:cafe::fc) by DS7PR03CA0102.outlook.office365.com (2603:10b6:5:3b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.34 via Frontend Transport; Tue, 30 Jul 2024 06:56:09 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS2PEPF00003440.mail.protection.outlook.com (10.167.18.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 30 Jul 2024 06:56:09 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 30 Jul 2024 01:56:07 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 30 Jul 2024 01:56:06 -0500 Received: from xhdlakshmis40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 30 Jul 2024 01:56:02 -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 v2 3/3] pinctrl: pinctrl-zynqmp: Add support for Versal platform Date: Tue, 30 Jul 2024 12:25:48 +0530 Message-ID: <20240730065548.1371518-4-sai.krishna.potthuri@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240730065548.1371518-1-sai.krishna.potthuri@amd.com> References: <20240730065548.1371518-1-sai.krishna.potthuri@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: sai.krishna.potthuri@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003440:EE_|MW4PR12MB7165:EE_ X-MS-Office365-Filtering-Correlation-Id: 55170644-7674-4eb5-6679-08dcb064b0fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026|7416014; X-Microsoft-Antispam-Message-Info: UH6CjGAA4h+GFMJL0tBQQKLBIvOxddR5GOGWGA98GMt8R0SSvsJ643dJa4u9+00woDzf5kkTmK6sCmHITZopA+TqdUX20/pqL/HwwaRiSjJBX69zpFO7iZxX52BFoaikEV6c9TcZOvkweN+5I9Fgm7eb3uqQ7xJEn+lAWNIsfSb/PiHE/EHI2LaSlot5XmOKvJGk6LCXEsE+2Aq52xWObEDetlRqxemVFdUUnZafGnCISS1ldCgZOtBHcfLkiF5baUjUqEODqtWAnqFJY6w7HO7Z/p+DzUTd44Y9iG2XZiIKfXpSIq2NpMOjhYpA99i0aJuBLgER3oUUvDRJaYTzz7/BJCBAyiaJjw/1I8k2AINNd+4gUVjw7cNLRMhyM4yy/hpDAyxtYp4kAqu1FqDJRqHxHOIOOxOea2zwlEwS4ewHsq0Qh5mpOz6VUCvleVIY3JPRU9kgMTt1grtQSvT2gPx9JQmZRO4kwnuo5I3NvgnxiZkbzwxxUWlpXJLHjN2FluKQaeU6u5E4Y5J+4WGO5qG2Fp/t5n47xQzWHCCEiWMRKEBq71RrW8xAepo1ojbieg6v7ZhPzpeDcIOxI4PQCmtFC/WbnUEPlqkEi8FrA7gnZ5ZX7sc8MJVzo9AoPwyHQdvbhU9YBdEkdqKMacKg7xo7mj+66mFv2r71pXzzJPz0QL3TQv5f6sgun658OSnYbaLXchPlRyvCtq1gn0pWEMr2JiNbKJgwfvNfrMeg1NBPSXJdvuo8lcfxmAvQk1TlrAM2mjUpjBZt8O1BcyOPx9N15Q9AAnwIMrnQW652AHXhO44Z0r6V/NxL4ARxM1B1DpxFiqB6CpkdOZOG4MqYRnUXjxfxEEp4hrswmLcojl6RfnJwFEdhlQlyz8vPP+YK+tFXsPVjqE0H/YN9iGBGYZF5NXqfFYYjwmQm5JMP/GGGHWEBdYyvNvUpvfh9/IgKZDmFEnpe02qRkhz3i9M4R2yBhUhZDBnVyClDVtxnG1Xu1V5N5hWgSEU+0cSyCWpkYXmJjn9AsDKr8+ARGzhbMaqGnjC/qGLdOGicQrP8VnC2jv1OLwA0J+0jSAYNdY0ID2nrD36HZy2DijWVe9bf113KhyvxUMzBuu3GwnChKOkFUfdJAhc2jRmiR9csITwZjJxgYGiAcmkNwi9rZBORLrAhBBS4Rz5PJv1/5LOHbQyiR6dtmqcjfUy2sbpi+EwrHAg2ExnHqld8oMnHp2Zv9pXXRxV8ntH/Y28s2n6txLtdG+BzoH0K+HYc3X4ckKvSE51yOMFR64LIIy0xRZiF5K4wfNpYU5XqhSXCPgoCZurrf0YosrdKnW9TgksJKcoq4nz8aziOIXMs+JDyWW26VRrvtxk+uGykCsqFqkQEYGFwXNZ2stHTvuYmN/jwMg3Igox+RMROv94TiGy4wy0+sQheVPJvRtCiiF7TMwV4fD3MP16Ek6s8Kt5eKutdgIrB X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 06:56:09.0689 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55170644-7674-4eb5-6679-08dcb064b0fb 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003440.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7165 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_235614_766052_5BC68F8A X-CRM114-Status: GOOD ( 23.40 ) 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);