From patchwork Tue Jun 6 16:22:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13269440 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 C7BB4C7EE24 for ; Tue, 6 Jun 2023 16:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=60KLG2RuoCyoCaSMAoevFKtkhBaJylp038geKuw1S5E=; b=r2Ey7SzRm0yX+a P1cjSgNyaBVD7CcaIrr9FZoUiThvazdhd5Lfr+B32Ermml1rZoB1yX2VFDmz4Vmq7pMXWHN3ajuxz v/gCDLulcZ8fcMNgq+ZwWdWj5D5QFuHRwMG1iTuN2ZAO9yyOmNGEQAIIZYHpQC5TomI+Vv/GP9nYi c77h4kXGxA4sZ4MlEzXpvX9qSXqCGGzeEc2Vf0SmrHx2bd3gdjwRo64YytvxNWyVg/1MusevRu6fF X2HrEKOp/vobPhePgMSzf0kPxjnONyX8CM8jcrOdHL4jM8wT45WvI024UmziNWnS0sgqD8KFQpeC2 qfTtboNFcC7UGZj3/IeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSL-002PKR-2J; Tue, 06 Jun 2023 16:22:49 +0000 Received: from mx0a-0039f301.pphosted.com ([148.163.133.242]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSI-002PI9-0s for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 16:22:48 +0000 Received: from pps.filterd (m0174676.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356F1eiE030721; Tue, 6 Jun 2023 16:22:33 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2057.outbound.protection.outlook.com [104.47.13.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3r229jsu66-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 16:22:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CVxLtCYJM7NNfoFHkuSgjkH/X19CPqiqfoBCRqc+AoZ+7PTmT/qtApPYHL5OSiuRG1LRw29/MFQJrofk6OhJZnB5gNzWS5cnk7AHksmJBQSUUkDG0XLQluPqgUE/9naln5il9axoZRKKAdgBWsSXU3qN22HssfUAeYdyNxHkiyK+PKFBA0jktRG615me75a+Kg38mtGJPSGqoIDP4P9LyEtbO3HNRWKGqwPiMfILbEZuNymSbyDgkjgzcJ5inspHkFbt1u4yUKUKnrtc+r7Ibt7ueuGbAMHT6uPlCT1c6bvEPsitkajCVEU4WAslADi1Ta/ETLjOR03eAdTFjkFhYg== 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=S1vg2H0gwnIiA0XBcxRAHjKtXu/CVSVIZptf9NvQcQY=; b=mp4LVV/jSgZZH0WxzhnmlUEXQWzjY8zMQJYffnY5xfgajwPyrpq/RQruQGuJ77CTLVgynNkfSJx8jr/xkpgaNnjV+7kX6QsrDiDb8Is1Hj8r7V3wU9kDym5fkYGZ3rw5G2cy9AU+TYuuamb1/NKnl2oNRIDuSCK36lwwDMlQgP0rLD3I2xuqJPPwY9QeVPvHiy8IJwaTO9fdfLtK0JrBz+LXXkNRFErRWkPf95+p+2WZL1HxSqDgxl8Dv3am5ZDqvI6unl4nXj5f4AGtcR6CLTTK/8VfufBBeIq8Rmdr5xxhrrjhmU59KT9siBhQ2bmqeVZQA7T2wNTcPqAB3WWC/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S1vg2H0gwnIiA0XBcxRAHjKtXu/CVSVIZptf9NvQcQY=; b=Tl4bV4PoqI3268+TbE3SgnKPocjrbjxlrELcaYkJwlcZHY+EKEi2F+GDqZkQKKLFf5I/yFHgIV7JcrY8ie95ECY6LsT2jNKcH9CNlYhYkYcdq+1B0rLZI58YAPT6rZ2sx4mYfIfsJ8hQoy46fgnmYWJtySPh8xC6xlRadwvTxivPDsyXCNrmCCh546co7ybzPUIBJ6lr/8k800ykBBR9jNl96zYVlp3n4Utb7tiLc9vcjgiyHf95wwPA9aNCQ1oKNbmZoDINXpUqD6wwB2PRY69fuFcC/YfjyyprHyc/l8ik3iGjS1wKPiovvuS37RG4pkCpTpihTJBLeZeAG0PuUQ== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by DB4PR03MB8708.eurprd03.prod.outlook.com (2603:10a6:10:380::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 16:22:27 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5%4]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 16:22:27 +0000 From: Oleksii Moisieiev To: "sudeep.holla@arm.com" CC: Oleksii Moisieiev , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" Subject: [PATCH v3 1/4] firmware: arm_scmi: Add optional flags to extended names helper Thread-Topic: [PATCH v3 1/4] firmware: arm_scmi: Add optional flags to extended names helper Thread-Index: AQHZmJMV0Z/bArOidE+HuMEc9wmXMQ== Date: Tue, 6 Jun 2023 16:22:27 +0000 Message-ID: <2ad06a5582bb31e16fe2f497e15cb41e8455e863.1686063941.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR03MB7136:EE_|DB4PR03MB8708:EE_ x-ms-office365-filtering-correlation-id: afd4a14b-03eb-4e2b-eb0a-08db66aa381d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nQUU2i2Cuuc+r2RgtYqrvSYciZ1Mzb+JPC+dgxtbMbVAo0zGNapQb5DpDz/bNLlMkkX27vG01Pl1Mp1ozUFKNQhVtttGvNFSdjiJF+QjSdMew24ZPfkYP8vwuyg7+bsfclN3Tfr+SIHP0cDRZwQ7qN6Ly0OdROtG0Weg6E8TlYHGdI+Vl2+EDSOuu56GsHTBk1lHnqpmBznPz+w9SYs37Vd8VBI3wxV21veSPGabLkJLwQ89TCcZE4zQtHge6jPboYPoLh3cKxlr/KimwGjIULVjZyHQlq8p54+F7nYt+UiT0CmPRr+EOQGNYZKj7O/MvlFh9Lpwrflj5CbOySdYQY/FvFckquT+F/YPbSS77Xm/ElDNqtAyAdc3ZSjUkeFC3xIFjUGGlUmse9+RPCcO38gCchWYHODaP9OLqnUtLul/mcslMEcX5WB0j3mXQepHLBWlSp81U6swJ56/H1F3o2Aw8AAn1zMwCGA7pkpXEUzAvReP+pildaJDuRck/1CUY5k7vR+5fO/5eUaa/GMiEYsfmPEFAd0Iw76AtP4//JXwHXAknpBTa6D5Icg0zG82fQ5BIvwDodrvmC3/x4ljwwtqKh4TcdrDfyfp9i89BOpJJ3NUVWhessau565MrnVa x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(39860400002)(396003)(346002)(376002)(451199021)(6512007)(6506007)(26005)(2616005)(83380400001)(186003)(66476007)(66446008)(122000001)(66556008)(66946007)(64756008)(76116006)(2906002)(6486002)(71200400001)(8936002)(38100700002)(7416002)(38070700005)(86362001)(5660300002)(36756003)(54906003)(8676002)(91956017)(478600001)(6916009)(316002)(4326008)(41300700001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?BhQsKZ/irtkz66VaWYWXvrB?= =?iso-8859-1?q?y5XKpi32kpty8+aTbb6D8Ita1JKssKAjnITQblHrmqFYHBUILOniDJ/20r5U?= =?iso-8859-1?q?dBDzqwgyFODP1FE9JV3uLKI/+iOQ1yrrBqyz+pYTLDW9QINoWJKWxOQm57BU?= =?iso-8859-1?q?qUQLy7eRAwfq8j4R8JmzHkMbSrLWwerNA+FH5WpkV+xB5uhqQsRY1JrR8wkh?= =?iso-8859-1?q?Nii1f8dpDag7XS4PahNPJ7sfQC/1Z/lt1HexZaZ7dKhmtugiZtC/UZZ2bG//?= =?iso-8859-1?q?y1koFCiEszQ7V0YAjeTDYb6IwFJZoGVVzbgSR1blBXayvacGcUMz9PJlxaF2?= =?iso-8859-1?q?+uBsIQrMy8IjNQ3JcPg3nTvgxALPf2Na2+8LyCPDsGLJDzuxBhJ56OjoeOcl?= =?iso-8859-1?q?6JLFoag1FBprfjPfb0BB19zs5GSXsp2p0vYGcyg8bL6Ikua5QfotSD3jCHtF?= =?iso-8859-1?q?hxUwqB33q/N8qzUIy8L/ONtEVV3IOFqYhmP4YYyutv0sOds6NrnRilkedA+S?= =?iso-8859-1?q?Q/Z9MF82ciGIaKfIIyevsAZScR5QPR63KtfPqop5Qck048Wfhsgd1Cn7Sqnm?= =?iso-8859-1?q?NFiLg0sbkevtGPUV0Q47+6foWIKMW4rA/gC7Wy5bViM0qI27G9eLTWOzp7L8?= =?iso-8859-1?q?RtC+vTvOQ+P8lR9MUQT8VpLgb4y3anjViXw5oN45/Zjcr6OB4s2toD20B90e?= =?iso-8859-1?q?zJbF9vZ11OXYxNJy7p1JfZAzTx0H8LHv02XL91UGbf6+jqXuL9W7pYeIX+jF?= =?iso-8859-1?q?tzDZGZQJWsf1sa2fpSJXlNg0Fk3vriEH+bAxLZ5xZ12HPkALfgFosepT5trK?= =?iso-8859-1?q?c/XaOYpLxjFI5lLOjt2LrqxnCG8YM1PveOlQ7stAmpdW9Ulw4Wqireew4nBD?= =?iso-8859-1?q?ElZKHpT+9E5OqK+t7g3OGyn5zX85L/tCzCSgUtvTYZ8FsVXNU+jy9uzzGH+d?= =?iso-8859-1?q?M99IyGOIfkhEaD/XkJMGozil0+uzLZtpdcoWOZDiLGs5/HSc+8TF2I3KNl7E?= =?iso-8859-1?q?FgMZrSTOl7tv4J7z1uysYt+8+Iwtca30BBlFW7eQNxHG500exNbtHq6oBsAt?= =?iso-8859-1?q?iOa0WLEch4OnaEaG5hCPxiwouSzeSpMUXsJKgoVBdOJ1eqFRqU3edoq/wNBA?= =?iso-8859-1?q?8UB/AsA+5l0IHNiU0VIp7DxI8yWAuprFnHui3lBpf8O/YBQB8KbWe6DWIpdC?= =?iso-8859-1?q?rB1OHL7AIpnuBSZUHDXomNC2YOzohpzEQ5wkdUNphA653MexTURTwQdRuORu?= =?iso-8859-1?q?DrNav670HyzdTqvaXxG5ejQzdvtIqKlm8Gav7wxsbOgmSL4u012wPwDSMPFT?= =?iso-8859-1?q?Ykz2TEMMhR1mNxgWlChmdFq6T5RTPgFfjvsrJwAmKqinvGaSKN3LzB2ACprw?= =?iso-8859-1?q?YYyU3pJgqmPsyd/iNivWYIp+FUd0HM51LUEkYn44ll8+zIyHtKGHLiHm1XaN?= =?iso-8859-1?q?ssgrAWMfUsgkfKUnOf4/7IaVk1wAGSsoFa10uNy93Ji3ygYko7nb4YbRgCZA?= =?iso-8859-1?q?sfalr8sz9A8lqmw9ZEinUbb0Wy8Nj9oa3KHgIiJNFvwFfiwOGuBA2ZSlJ3gw?= =?iso-8859-1?q?7a4hZULThY3wb42qTXzeqyJCA8NthWYk5zHgnjRhIgli1dT8ifrnqDUdyAlt?= =?iso-8859-1?q?jxp5v/XuxRu+iOBggS71wZFEoexgzIlG/hnl03w=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afd4a14b-03eb-4e2b-eb0a-08db66aa381d X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2023 16:22:27.3498 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JY6c3FlgFjevhd22FDSHPqVzXDkFgOLPoaHpt/7W87htxEciffQCNr9pzGaaUELerJg2oGqIEY9Qe5OkTdywMLgd/urpEt9a9cjxlsr1j8o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR03MB8708 X-Proofpoint-GUID: F11GTAlSEEFoV_rky7jqY6gLqbPHG1wb X-Proofpoint-ORIG-GUID: F11GTAlSEEFoV_rky7jqY6gLqbPHG1wb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_12,2023-06-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 spamscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060140 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_092246_314945_A9485B77 X-CRM114-Status: GOOD ( 18.03 ) 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 Some recently added SCMI protocols needs an additional flags parameter to be able to properly configure the command used to query the extended name of a resource. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/clock.c | 2 +- drivers/firmware/arm_scmi/driver.c | 8 ++++++-- drivers/firmware/arm_scmi/perf.c | 3 ++- drivers/firmware/arm_scmi/power.c | 2 +- drivers/firmware/arm_scmi/powercap.c | 2 +- drivers/firmware/arm_scmi/protocols.h | 3 ++- drivers/firmware/arm_scmi/reset.c | 3 ++- drivers/firmware/arm_scmi/sensors.c | 2 +- drivers/firmware/arm_scmi/voltage.c | 2 +- 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 96060bf90a24..e6e087686e8c 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -169,7 +169,7 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x2) { if (SUPPORTS_EXTENDED_NAMES(attributes)) ph->hops->extended_name_get(ph, CLOCK_NAME_GET, clk_id, - clk->name, + NULL, clk->name, SCMI_MAX_STR_SIZE); if (SUPPORTS_RATE_CHANGED_NOTIF(attributes)) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index e7d97b59963b..5be931a07c84 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1438,6 +1438,7 @@ struct scmi_msg_resp_domain_name_get { * @ph: A protocol handle reference. * @cmd_id: The specific command ID to use. * @res_id: The specific resource ID to use. + * @flags: A pointer to specific flags to use, if any. * @name: A pointer to the preallocated area where the retrieved name will be * stored as a NULL terminated string. * @len: The len in bytes of the @name char array. @@ -1445,8 +1446,8 @@ struct scmi_msg_resp_domain_name_get { * Return: 0 on Succcess */ static int scmi_common_extended_name_get(const struct scmi_protocol_handle *ph, - u8 cmd_id, u32 res_id, char *name, - size_t len) + u8 cmd_id, u32 res_id, u32 *flags, + char *name, size_t len) { int ret; struct scmi_xfer *t; @@ -1458,6 +1459,9 @@ static int scmi_common_extended_name_get(const struct scmi_protocol_handle *ph, goto out; put_unaligned_le32(res_id, t->tx.buf); + if (flags) + put_unaligned_le32(*flags, + (u8 *)t->tx.buf + sizeof(res_id)); resp = t->rx.buf; ret = ph->xops->do_xfer(ph, t); diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index ecf5c4de851b..d85d4a0e3605 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -237,7 +237,8 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 && SUPPORTS_EXTENDED_NAMES(flags)) ph->hops->extended_name_get(ph, PERF_DOMAIN_NAME_GET, domain, - dom_info->name, SCMI_MAX_STR_SIZE); + NULL, dom_info->name, + SCMI_MAX_STR_SIZE); return ret; } diff --git a/drivers/firmware/arm_scmi/power.c b/drivers/firmware/arm_scmi/power.c index 356e83631664..077767d6e902 100644 --- a/drivers/firmware/arm_scmi/power.c +++ b/drivers/firmware/arm_scmi/power.c @@ -133,7 +133,7 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph, if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 && SUPPORTS_EXTENDED_NAMES(flags)) { ph->hops->extended_name_get(ph, POWER_DOMAIN_NAME_GET, - domain, dom_info->name, + domain, NULL, dom_info->name, SCMI_MAX_STR_SIZE); } diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c index 83b90bde755c..e7ea9210aae1 100644 --- a/drivers/firmware/arm_scmi/powercap.c +++ b/drivers/firmware/arm_scmi/powercap.c @@ -268,7 +268,7 @@ scmi_powercap_domain_attributes_get(const struct scmi_protocol_handle *ph, */ if (!ret && SUPPORTS_EXTENDED_NAMES(flags)) ph->hops->extended_name_get(ph, POWERCAP_DOMAIN_NAME_GET, - domain, dom_info->name, + domain, NULL, dom_info->name, SCMI_MAX_STR_SIZE); return ret; diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h index 78e1a01eb656..b3c6314bb4b8 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -256,7 +256,8 @@ struct scmi_fc_info { */ struct scmi_proto_helpers_ops { int (*extended_name_get)(const struct scmi_protocol_handle *ph, - u8 cmd_id, u32 res_id, char *name, size_t len); + u8 cmd_id, u32 res_id, u32 *flags, char *name, + size_t len); void *(*iter_response_init)(const struct scmi_protocol_handle *ph, struct scmi_iterator_ops *ops, unsigned int max_resources, u8 msg_id, diff --git a/drivers/firmware/arm_scmi/reset.c b/drivers/firmware/arm_scmi/reset.c index e9afa8cab730..7217fd7c6afa 100644 --- a/drivers/firmware/arm_scmi/reset.c +++ b/drivers/firmware/arm_scmi/reset.c @@ -128,7 +128,8 @@ scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph, if (!ret && PROTOCOL_REV_MAJOR(version) >= 0x3 && SUPPORTS_EXTENDED_NAMES(attributes)) ph->hops->extended_name_get(ph, RESET_DOMAIN_NAME_GET, domain, - dom_info->name, SCMI_MAX_STR_SIZE); + NULL, dom_info->name, + SCMI_MAX_STR_SIZE); return ret; } diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 0b5853fa9d87..9952a7bc6682 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -644,7 +644,7 @@ iter_sens_descr_process_response(const struct scmi_protocol_handle *ph, if (PROTOCOL_REV_MAJOR(si->version) >= 0x3 && SUPPORTS_EXTENDED_NAMES(attrl)) ph->hops->extended_name_get(ph, SENSOR_NAME_GET, s->id, - s->name, SCMI_MAX_STR_SIZE); + NULL, s->name, SCMI_MAX_STR_SIZE); if (s->extended_scalar_attrs) { s->sensor_power = le32_to_cpu(sdesc->power); diff --git a/drivers/firmware/arm_scmi/voltage.c b/drivers/firmware/arm_scmi/voltage.c index eaa8d944926a..36e2df77738c 100644 --- a/drivers/firmware/arm_scmi/voltage.c +++ b/drivers/firmware/arm_scmi/voltage.c @@ -242,7 +242,7 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, if (SUPPORTS_EXTENDED_NAMES(attributes)) ph->hops->extended_name_get(ph, VOLTAGE_DOMAIN_NAME_GET, - v->id, v->name, + v->id, NULL, v->name, SCMI_MAX_STR_SIZE); if (SUPPORTS_ASYNC_LEVEL_SET(attributes)) v->async_level_set = true; From patchwork Tue Jun 6 16:22:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13269442 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 BCEBDC7EE29 for ; Tue, 6 Jun 2023 16:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=KdY4LLF05+EAZeojX2VQ9EHyMHiFCg1d66TOcv1yBQM=; b=iNtRPXSlUF/HaZ 4G57WejUbL7MB0Z0TONQzXf5aB+WAUN0QvyMQCtFN0HvT0L1NCWIev12UpQ+NYNMzyISMZd6izsUe hzuwD3scf48K4Q409rp/Ew/i+4mH152nszv5gFn5DDtZqb1DT4hVvcDkD6pg7Sa30MYWiJUdvOMLZ /dCX0xSifryJCqZdP+NH42/h7GlXD2pn9cZxAyGfq03cJzvC6zpLabE2sGnVLc6vthnkTJ/k6rtJ9 P+Q1wqF8lXdgEZiJrzRBeDwPZPHbgbTzNVb8iD0/0OBOHuQSDAWFXwEKEhtWhNBgHM4pIq6azCR3j E0uqVKMktkOrXxZ55wOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSR-002PO7-1u; Tue, 06 Jun 2023 16:22:55 +0000 Received: from mx0a-0039f301.pphosted.com ([148.163.133.242]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSL-002PJy-0k for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 16:22:52 +0000 Received: from pps.filterd (m0174676.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356F1eiF030721; Tue, 6 Jun 2023 16:22:34 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2057.outbound.protection.outlook.com [104.47.13.57]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3r229jsu66-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 16:22:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JCKbQ6tl/RRGp9NJ2K6OfXW/TbuG8y9TtX3GG70d23a8jKKfi1g4YOov25Hkp4Xy0Wj1HHSoxJ3gya2iv4fl3sUy+9/9qz8Mvq9IHxWcPp5o8LlnGOSzuBmv/DHwSQEbpPg9bZsC5ypYS442pfkt7OGi7mg0f1fxnXl6KjsQ0zKG2G3fuLfr9VgNcdUiqzkTdevrQn3OTAhxvWyAajgtmoJ88i+wHIs1uPX4acflrjOV/RI3gQj1tr8kT6yDH9P5pm3bX6GDU/gzyhQkkoQa3DraBCciokBY30HYcdUJXRsJpW2bq3VHAlVzxZZpbsalIQXrI/YXStpe8/gsjl2+Gw== 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=Qy5IamwpQPH4r3Ot6D9NYABpiNwrTZ+HXvTjh4sTqGc=; b=i4w3qKMik4j55hWn6RdfcnDd98LV5ZcBS27T58C3zNhNWAYw1cmua6u7zMgzs0VrWaLnecxZTEFjYeKZWyWhDI3qAJNLZdrjmn5W/jYyEPrUuAnDDPqvqQ/9DjW3rxr7Or9jdF2QjDdt2GPHoEOlFc/OK8vjRIp9gE/oZQfAOxan6IDNf28cdkNVGmEGV7LFGKJ6kXpENalYWRhPRf13wwgqT4ap6r+mweW8iKXujInnhPjHfMGMk4nlQg51kYe03UiXk6eOf7w0rq0gKjocXyUIhpCVegF2TFaz6MfBxxVDYEIEI1eRpxKYASB+Rdsq62m1ZsIYkYVZwS79Aif1ag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qy5IamwpQPH4r3Ot6D9NYABpiNwrTZ+HXvTjh4sTqGc=; b=Trj6w0hS7+R/FNszQYwm8MbPrCdwi1/NXcgzezrDhup4UFpHX/kMkmfmP9+o8ZexDubMql1rU9x9Wf4wFHJW6v7GgxSV6U2EmR126YC1l/dl1aJS9sUgbWfKg8izLl6FIHC/ojeDl09TI18icqZZWNR+0AiwkgpBWc1/Zp1Dh+sHz1RVmD4pJKkEcV7bF6sj1LK0TINAktef41dixswWfpSIu3smWA7cA5vvk2ZhsyisTkHbsJ5U7/hBGIPSAPrR4zlZv9hKK9FTYt4SsPFHngMsVU0tKTuXzkrQuuH00TUgw8O2wAGt3S4G05vTNkyWBbmiCKoZ4uFjY9NmOqwMVg== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by DB4PR03MB8708.eurprd03.prod.outlook.com (2603:10a6:10:380::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 16:22:28 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5%4]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 16:22:28 +0000 From: Oleksii Moisieiev To: "sudeep.holla@arm.com" CC: Oleksii Moisieiev , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" Subject: [PATCH v3 2/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Thread-Topic: [PATCH v3 2/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Thread-Index: AQHZmJMVZdZ9jTlnl0a4bbb/rGp54A== Date: Tue, 6 Jun 2023 16:22:27 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR03MB7136:EE_|DB4PR03MB8708:EE_ x-ms-office365-filtering-correlation-id: 99a61ef3-8853-4c65-0c01-08db66aa3863 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QWp2KThgXD93vGlQF+v8tLzSge2WIbzD/y3/JrpArCLb2UWwkp+EANLBZNZutIPdypXBwlnwLVA3WAoPOPntHSwJMBp60Nh8lbnoFnz2Jl1u6tZVRc6dD+qpUoV/paKCKxEtUsQiLQkkZvtkCosSYzQUtFk2MnV/RFRmIBmnKmqetLmhTyCGd1YvCbIgz6DQ+awYoNc33tEX2QO9id9S9P/ENqYfLlkUJmoDlm/oyL4u7cIo7N+3FS9qa9lna83WPbEpHCWGubzMDQdwB3WfmY9jqTwe2CWiSlIMC2gesvmWGqxDcp8SLjcSxSJOgZwzNvT8bnOkEIln6d4ZnC5xlBK56G+CoabRzaDSXjWOXyfdmBf6xwxByDnim+03h8ej8QOhbT1h4jrMyAr8IUVkKCr8ReHvLYqGjywNIYJquqZr6zrYW8pONzQqzFMbJ/D4YOh2e2nb1QWakM5QvYGEAUSsbOSBj+tAnK9AHFqmRB4zmE/CKCjQtdT5L7tetE2jMsWdiM9OxfHcnf3B1w6OU7jn1InEdbzMfi98M/NxwPyxeXIuMex7FpRkzJpDlJapyOwVJVevkJRCItFJICeJKzmhWtjiJWeimyQl/GuNNBoIxFOABTxGrO0VXfVZJlFn x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(39860400002)(396003)(346002)(376002)(451199021)(6512007)(6506007)(26005)(2616005)(83380400001)(186003)(66476007)(66446008)(122000001)(30864003)(66556008)(66946007)(64756008)(76116006)(2906002)(6486002)(71200400001)(8936002)(38100700002)(7416002)(38070700005)(86362001)(5660300002)(36756003)(54906003)(8676002)(91956017)(478600001)(6916009)(316002)(4326008)(41300700001)(559001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?V9O+EsWZqtLSNhbyKbiW6R1?= =?iso-8859-1?q?lSbjS2r/vo+xZyJhd3b7fCWbYht8gPQ8qhuAzeqoInx+RtHTGh5w/fQW7Qgw?= =?iso-8859-1?q?OHuWnGm2YfyBG9NLw6C4iAewcRmZHm3zMSVJmnO7U1zK866+nBQB0657MDUd?= =?iso-8859-1?q?3vvS06oK+34+mkdQXUBIuqilqkoPi/bLOUTAjpTes/BOP7s69/V6vr2E/PrP?= =?iso-8859-1?q?uCLnIn3zGo+wkAavRlpFNqvt4m3TF6xmR+Aebvu6TIczJxyt/NHZ0SOFIS7G?= =?iso-8859-1?q?UJhdhq0R5k7fnR5f0X8Z14Veo3JYImBStJzXEU1ONNLpwrg79e3G71Xb9pFo?= =?iso-8859-1?q?H4j1qnSFgZMptKCXyfQ56JtD0BdPBna3K5yY1/T+GZpJ//rJcIDW8nI+g153?= =?iso-8859-1?q?5HLMbBNoItLDv0TDvFRPunAYI9Q30jTzTgUd9Je4WMi3RZiI4cnI2Ve4zg9k?= =?iso-8859-1?q?zc2IRC6s95BcrGn4m30eNuzRyXarC9Fas2v3r46G6XFHpFSAe5VZXOlIR3d0?= =?iso-8859-1?q?BgEvbnMgoXUZJVY3PoRiZcle4lh8KoDr1Jm/j7xFyxzBU3PYqPAmMdekkWAq?= =?iso-8859-1?q?XvnOC5im3HosAfatyU74SYoAmFf3eUCFoPvxNuXjX+S71WfFiZl0vg5C2i0s?= =?iso-8859-1?q?4msA2scOYrCAK828yRGe/1hhVAqU7UU5cfCIIiD5i3MnGL4IuOBeLlMqJXW/?= =?iso-8859-1?q?5poOKZrQNCA3xDWNN7DqmVhZNroIP8j7ZFCXdfRGpj7bVlvjs1vTxOIjH27k?= =?iso-8859-1?q?FpvAEBIqx/DS+c8+PSnj54y+gBB97UC0xbsX7Ei7iJlRPQo8GMCyNrD2D/Nt?= =?iso-8859-1?q?lpf6KpAZZAaiP6urazM+iMAq+2CHNbu9oDZT4jgM4llRzrLoWBpEnwb6+i1f?= =?iso-8859-1?q?nWHxoAREPnkDuD9zskOMCegL8EO0316+34V4DtcMJ8Wlp0cxnPdHC4DkEO14?= =?iso-8859-1?q?bP35HiZn86l2ab4o36PRrvBDfLqR2B+kWQx3XGuhzasoJ9RKjqH1uDLAsL/g?= =?iso-8859-1?q?Hj+7UiYIoYyzCr8MsQPOZIvNtcvSHs6TOVmhpeyzM1DinrrzcSXG/dCgPs55?= =?iso-8859-1?q?QaalOeBfJT2fOROkbLA4ttSXMOMTbisScVW7fiTvR1qs1Vk6PaKitxiTZNMc?= =?iso-8859-1?q?tQ+QZCR4n/aAlNheh0lan+5Dc5y65aZA94dEnw8I1z20bpwRedDICHqNdc8y?= =?iso-8859-1?q?uwK0CGROC9LulU/znoxC4pVcSoGgmuxHIslnWEJ+RVY6+bxhn/Pv9kUCfHWo?= =?iso-8859-1?q?J5ImtGqkYB5Ba5sRtPsilBDZjlBGqppODv1S+12ULB03dCuqAFwPwPsVBKpo?= =?iso-8859-1?q?xlLDgbkEb+wCXXEn5LsXLYCJQwxVQBUT9cXlBQzeSWkWz4GjN0njSPtHUMFB?= =?iso-8859-1?q?/D9MoOYA7Q4r3exZcVbPPkK/m6Y7JANJLm9pZ+OwB/j2ChwhYSDePbldulrT?= =?iso-8859-1?q?FXcg4Vc9V4pOl1qutKdMLvrp3fh5WIS2ezWyAgOU58b2EowKagKRSN6nWtBN?= =?iso-8859-1?q?+s1/OmcNcmTOp8nFhPAAQ6avf793JjOgdQfHtRSX07mnexqlavycmLve4Z7s?= =?iso-8859-1?q?mWnSWoMz75YoXus06YML/RXWTZgpww5nzeFFUxUu6xcTvKj+O7EJb9QeKLmi?= =?iso-8859-1?q?AYLef/s4X7MkDz3en6b1fbbHc2A0jR7JpC2fkHg=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99a61ef3-8853-4c65-0c01-08db66aa3863 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2023 16:22:27.9251 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mrTr7zEWL6+C5zgcWO4cLNGoFMovREkdZXZetFHgnNfBzfvZ4smeyk9LoDURex5mHF/Oi5ucYKoq3FPT4CV5+47pWL1RQ7hbK9dGMlXOrZM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR03MB8708 X-Proofpoint-GUID: X2RToP8dzqUpTtZWx6muOr6mZ8yKyBrq X-Proofpoint-ORIG-GUID: X2RToP8dzqUpTtZWx6muOr6mZ8yKyBrq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_12,2023-06-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 spamscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060140 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_092249_297550_9CAC3ACD X-CRM114-Status: GOOD ( 20.14 ) 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 scmi: Introduce pinctrl SCMI protocol driver Add basic implementation of the SCMI v3.2 pincontrol protocol excluding GPIO support. All pinctrl related callbacks and operations are exposed in the include/linux/scmi_protocol.h Signed-off-by: Oleksii Moisieiev --- MAINTAINERS | 6 + drivers/firmware/arm_scmi/Makefile | 2 +- drivers/firmware/arm_scmi/driver.c | 2 + drivers/firmware/arm_scmi/pinctrl.c | 836 ++++++++++++++++++++++++++ drivers/firmware/arm_scmi/protocols.h | 1 + include/linux/scmi_protocol.h | 47 ++ 6 files changed, 893 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/arm_scmi/pinctrl.c diff --git a/MAINTAINERS b/MAINTAINERS index 0dab9737ec16..297b2512963d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20522,6 +20522,12 @@ F: include/linux/sc[mp]i_protocol.h F: include/trace/events/scmi.h F: include/uapi/linux/virtio_scmi.h +PINCTRL DRIVER FOR SYSTEM CONTROL & POWER/MANAGEMENT INTERFACE (SCPI/SCMI) +M: Oleksii Moisieiev +L: linux-arm-kernel@lists.infradead.org +S: Maintained +F: drivers/firmware/arm_scmi/pinctrl.c + SYSTEM RESET/SHUTDOWN DRIVERS M: Sebastian Reichel L: linux-pm@vger.kernel.org diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index b31d78fa66cc..603430ec0bfe 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -10,7 +10,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o -scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o +scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o pinctrl.o scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 5be931a07c84..a9fd337b9596 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -3025,6 +3025,7 @@ static int __init scmi_driver_init(void) scmi_voltage_register(); scmi_system_register(); scmi_powercap_register(); + scmi_pinctrl_register(); return platform_driver_register(&scmi_driver); } @@ -3042,6 +3043,7 @@ static void __exit scmi_driver_exit(void) scmi_voltage_unregister(); scmi_system_unregister(); scmi_powercap_unregister(); + scmi_pinctrl_unregister(); scmi_transports_exit(); diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scmi/pinctrl.c new file mode 100644 index 000000000000..fc0fcc26dfb6 --- /dev/null +++ b/drivers/firmware/arm_scmi/pinctrl.c @@ -0,0 +1,836 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System Control and Management Interface (SCMI) Pinctrl Protocol + * + * Copyright (C) 2023 EPAM + */ + +#include +#include +#include + +#include "protocols.h" + +#define REG_TYPE_BITS GENMASK(9, 8) +#define REG_CONFIG GENMASK(7, 0) + +#define GET_GROUPS_NR(x) le32_get_bits((x), GENMASK(31, 16)) +#define GET_PINS_NR(x) le32_get_bits((x), GENMASK(15, 0)) +#define GET_FUNCTIONS_NR(x) le32_get_bits((x), GENMASK(15, 0)) + +#define EXT_NAME_FLAG(x) le32_get_bits((x), BIT(31)) +#define NUM_ELEMS(x) le32_get_bits((x), GENMASK(15, 0)) + +#define REMAINING(x) le32_get_bits((x), GENMASK(31, 16)) +#define RETURNED(x) le32_get_bits((x), GENMASK(11, 0)) + +enum scmi_pinctrl_protocol_cmd { + PINCTRL_ATTRIBUTES = 0x3, + PINCTRL_LIST_ASSOCIATIONS = 0x4, + PINCTRL_CONFIG_GET = 0x5, + PINCTRL_CONFIG_SET = 0x6, + PINCTRL_FUNCTION_SELECT = 0x7, + PINCTRL_REQUEST = 0x8, + PINCTRL_RELEASE = 0x9, + PINCTRL_NAME_GET = 0xa, + PINCTRL_SET_PERMISSIONS = 0xb +}; + +struct scmi_msg_conf_set { + __le32 identifier; + __le32 attributes; + __le32 config_value; +}; + +struct scmi_msg_conf_get { + __le32 identifier; + __le32 attributes; +}; + +struct scmi_msg_pinctrl_protocol_attributes { + __le32 attributes_low; + __le32 attributes_high; +}; + +struct scmi_msg_pinctrl_attributes { + __le32 identifier; + __le32 flags; +}; + +struct scmi_resp_pinctrl_attributes { + __le32 attributes; + u8 name[SCMI_SHORT_NAME_MAX_SIZE]; +}; + +struct scmi_msg_pinctrl_list_assoc { + __le32 identifier; + __le32 flags; + __le32 index; +}; + +struct scmi_resp_pinctrl_list_assoc { + __le32 flags; + __le16 array[]; +}; + +struct scmi_msg_func_set { + __le32 identifier; + __le32 function_id; + __le32 flags; +}; + +struct scmi_msg_request { + __le32 identifier; + __le32 flags; +}; + +struct scmi_group_info { + bool present; + char name[SCMI_MAX_STR_SIZE]; + unsigned int *group_pins; + unsigned int nr_pins; +}; + +struct scmi_function_info { + bool present; + char name[SCMI_MAX_STR_SIZE]; + unsigned int *groups; + unsigned int nr_groups; +}; + +struct scmi_pin_info { + bool present; + char name[SCMI_MAX_STR_SIZE]; +}; + +struct scmi_pinctrl_info { + u32 version; + int nr_groups; + int nr_functions; + int nr_pins; + struct scmi_group_info *groups; + struct scmi_function_info *functions; + struct scmi_pin_info *pins; +}; + +static int scmi_pinctrl_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_pinctrl_info *pi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_pinctrl_protocol_attributes *attr; + + if (!pi) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, + 0, sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + pi->nr_functions = GET_FUNCTIONS_NR(attr->attributes_high); + pi->nr_groups = GET_GROUPS_NR(attr->attributes_low); + pi->nr_pins = GET_PINS_NR(attr->attributes_low); + } + + ph->xops->xfer_put(ph, t); + return ret; +} + +static int scmi_pinctrl_get_count(const struct scmi_protocol_handle *ph, + enum scmi_pinctrl_selector_type type) +{ + struct scmi_pinctrl_info *pi; + + pi = ph->get_priv(ph); + if (!pi) + return -ENODEV; + + switch (type) { + case PIN_TYPE: + return pi->nr_pins; + case GROUP_TYPE: + return pi->nr_groups; + case FUNCTION_TYPE: + return pi->nr_functions; + default: + return -EINVAL; + } +} + +static int scmi_pinctrl_validate_id(const struct scmi_protocol_handle *ph, + u32 identifier, + enum scmi_pinctrl_selector_type type) +{ + int value; + + value = scmi_pinctrl_get_count(ph, type); + if (value < 0) + return value; + + if (identifier >= value) + return -EINVAL; + + return 0; +} + +static int scmi_pinctrl_attributes(const struct scmi_protocol_handle *ph, + enum scmi_pinctrl_selector_type type, + u32 selector, char *name, + unsigned int *n_elems) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_pinctrl_attributes *tx; + struct scmi_resp_pinctrl_attributes *rx; + + if (!name) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, selector, type); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_ATTRIBUTES, sizeof(*tx), + sizeof(*rx), &t); + if (ret) + return ret; + + tx = t->tx.buf; + rx = t->rx.buf; + tx->identifier = cpu_to_le32(selector); + tx->flags = cpu_to_le32(type); + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + if (n_elems) + *n_elems = NUM_ELEMS(rx->attributes); + + strscpy(name, rx->name, SCMI_SHORT_NAME_MAX_SIZE); + } + + ph->xops->xfer_put(ph, t); + + /* + * If supported overwrite short name with the extended one; + * on error just carry on and use already provided short name. + */ + if (!ret && EXT_NAME_FLAG(rx->attributes)) + ph->hops->extended_name_get(ph, PINCTRL_NAME_GET, selector, + (u32 *)&type, name, + SCMI_MAX_STR_SIZE); + return ret; +} + +struct scmi_pinctrl_ipriv { + u32 selector; + enum scmi_pinctrl_selector_type type; + unsigned int *array; +}; + +static void iter_pinctrl_assoc_prepare_message(void *message, + unsigned int desc_index, + const void *priv) +{ + struct scmi_msg_pinctrl_list_assoc *msg = message; + const struct scmi_pinctrl_ipriv *p = priv; + + msg->identifier = cpu_to_le32(p->selector); + msg->flags = cpu_to_le32(p->type); + /* Set the number of OPPs to be skipped/already read */ + msg->index = cpu_to_le32(desc_index); +} + +static int iter_pinctrl_assoc_update_state(struct scmi_iterator_state *st, + const void *response, void *priv) +{ + const struct scmi_resp_pinctrl_list_assoc *r = response; + + st->num_returned = RETURNED(r->flags); + st->num_remaining = REMAINING(r->flags); + + return 0; +} + +static int +iter_pinctrl_assoc_process_response(const struct scmi_protocol_handle *ph, + const void *response, + struct scmi_iterator_state *st, void *priv) +{ + const struct scmi_resp_pinctrl_list_assoc *r = response; + struct scmi_pinctrl_ipriv *p = priv; + + p->array[st->desc_index + st->loop_idx] = + le16_to_cpu(r->array[st->loop_idx]); + + return 0; +} + +static int scmi_pinctrl_list_associations(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + u16 size, unsigned int *array) +{ + int ret; + void *iter; + struct scmi_iterator_ops ops = { + .prepare_message = iter_pinctrl_assoc_prepare_message, + .update_state = iter_pinctrl_assoc_update_state, + .process_response = iter_pinctrl_assoc_process_response, + }; + struct scmi_pinctrl_ipriv ipriv = { + .selector = selector, + .type = type, + .array = array, + }; + + if (!array || !size || type == PIN_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, selector, type); + if (ret) + return ret; + + iter = ph->hops->iter_response_init(ph, &ops, size, + PINCTRL_LIST_ASSOCIATIONS, + sizeof(struct scmi_msg_pinctrl_list_assoc), + &ipriv); + + if (IS_ERR(iter)) + return PTR_ERR(iter); + + return ph->hops->iter_response_run(iter); +} + +static int scmi_pinctrl_get_config(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + u8 config_type, unsigned long *config_value) +{ + int ret; + u32 attributes; + struct scmi_xfer *t; + struct scmi_msg_conf_get *tx; + + if (!config_value || type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, selector, type); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_CONFIG_GET, sizeof(*tx), + sizeof(__le32), &t); + if (ret) + return ret; + + tx = t->tx.buf; + tx->identifier = cpu_to_le32(selector); + attributes = FIELD_PREP(REG_TYPE_BITS, type) | + FIELD_PREP(REG_CONFIG, config_type); + tx->attributes = cpu_to_le32(attributes); + + ret = ph->xops->do_xfer(ph, t); + if (!ret) + *config_value = get_unaligned_le32(t->rx.buf); + + ph->xops->xfer_put(ph, t); + return ret; +} + +static int scmi_pinctrl_set_config(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + u8 config_type, unsigned long config_value) +{ + struct scmi_xfer *t; + struct scmi_msg_conf_set *tx; + u32 attributes = 0; + int ret; + + if (type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, selector, type); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_CONFIG_SET, + sizeof(*tx), 0, &t); + if (ret) + return ret; + + tx = t->tx.buf; + tx->identifier = cpu_to_le32(selector); + attributes = FIELD_PREP(REG_TYPE_BITS, type) | + FIELD_PREP(REG_CONFIG, config_type); + tx->attributes = cpu_to_le32(attributes); + tx->config_value = cpu_to_le32(config_value); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + return ret; +} + +static int scmi_pinctrl_function_select(const struct scmi_protocol_handle *ph, + u32 identifier, + enum scmi_pinctrl_selector_type type, + u32 function_id) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_func_set *tx; + + if (type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, identifier, type); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_FUNCTION_SELECT, + sizeof(*tx), 0, &t); + if (ret) + return ret; + + tx = t->tx.buf; + tx->identifier = cpu_to_le32(identifier); + tx->function_id = cpu_to_le32(function_id); + tx->flags = cpu_to_le32(type); + + ret = ph->xops->do_xfer(ph, t); + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_pinctrl_request(const struct scmi_protocol_handle *ph, + u32 identifier, + enum scmi_pinctrl_selector_type type) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_request *tx; + + if (type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, identifier, type); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_REQUEST, sizeof(*tx), + 0, &t); + + tx = t->tx.buf; + tx->identifier = cpu_to_le32(identifier); + tx->flags = cpu_to_le32(type); + + ret = ph->xops->do_xfer(ph, t); + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_pinctrl_request_pin(const struct scmi_protocol_handle *ph, + u32 pin) +{ + return scmi_pinctrl_request(ph, pin, PIN_TYPE); +} + +static int scmi_pinctrl_free(const struct scmi_protocol_handle *ph, + u32 identifier, + enum scmi_pinctrl_selector_type type) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_request *tx; + + if (type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, identifier, type); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_RELEASE, + sizeof(*tx), 0, &t); + + tx = t->tx.buf; + tx->identifier = cpu_to_le32(identifier); + tx->flags = cpu_to_le32(type); + + ret = ph->xops->do_xfer(ph, t); + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_pinctrl_free_pin(const struct scmi_protocol_handle *ph, u32 pin) +{ + return scmi_pinctrl_free(ph, pin, PIN_TYPE); +} + +static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *ph, + u32 selector, + struct scmi_group_info *group) +{ + int ret; + + if (!group) + return -EINVAL; + + ret = scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, + group->name, + &group->nr_pins); + if (ret) + return ret; + + if (!group->nr_pins) { + dev_err(ph->dev, "Group %d has 0 elements", selector); + return -ENODATA; + } + + group->group_pins = devm_kmalloc_array(ph->dev, group->nr_pins, + sizeof(*group->group_pins), + GFP_KERNEL); + if (!group->group_pins) + return -ENOMEM; + + ret = scmi_pinctrl_list_associations(ph, selector, GROUP_TYPE, + group->nr_pins, group->group_pins); + if (ret) { + devm_kfree(ph->dev, group->group_pins); + return ret; + } + + group->present = true; + return 0; +} + +static int scmi_pinctrl_get_group_name(const struct scmi_protocol_handle *ph, + u32 selector, const char **name) +{ + struct scmi_pinctrl_info *pi; + + if (!name) + return -EINVAL; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + if (selector > pi->nr_groups) + return -EINVAL; + + if (!pi->groups[selector].present) { + int ret; + + ret = scmi_pinctrl_get_group_info(ph, selector, + &pi->groups[selector]); + if (ret) + return ret; + } + + *name = pi->groups[selector].name; + + return 0; +} + +static int scmi_pinctrl_get_group_pins(const struct scmi_protocol_handle *ph, + u32 selector, const unsigned int **pins, + unsigned int *nr_pins) +{ + struct scmi_pinctrl_info *pi; + + if (!pins || !nr_pins) + return -EINVAL; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + if (selector > pi->nr_groups) + return -EINVAL; + + if (!pi->groups[selector].present) { + int ret; + + ret = scmi_pinctrl_get_group_info(ph, selector, + &pi->groups[selector]); + if (ret) + return ret; + } + + *pins = pi->groups[selector].group_pins; + *nr_pins = pi->groups[selector].nr_pins; + + return 0; +} + +static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handle *ph, + u32 selector, + struct scmi_function_info *func) +{ + int ret; + + if (!func) + return -EINVAL; + + ret = scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, + func->name, + &func->nr_groups); + if (ret) + return ret; + + if (!func->nr_groups) { + dev_err(ph->dev, "Function %d has 0 elements", selector); + return -ENODATA; + } + + func->groups = devm_kmalloc_array(ph->dev, func->nr_groups, + sizeof(*func->groups), + GFP_KERNEL); + if (!func->groups) + return -ENOMEM; + + ret = scmi_pinctrl_list_associations(ph, selector, FUNCTION_TYPE, + func->nr_groups, func->groups); + if (ret) { + devm_kfree(ph->dev, func->groups); + return ret; + } + + func->present = true; + return 0; +} + +static int scmi_pinctrl_get_function_name(const struct scmi_protocol_handle *ph, + u32 selector, const char **name) +{ + struct scmi_pinctrl_info *pi; + + if (!name) + return -EINVAL; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + if (selector > pi->nr_functions) + return -EINVAL; + + if (!pi->functions[selector].present) { + int ret; + + ret = scmi_pinctrl_get_function_info(ph, selector, + &pi->functions[selector]); + if (ret) + return ret; + } + + *name = pi->functions[selector].name; + return 0; +} + +static int scmi_pinctrl_get_function_groups(const struct scmi_protocol_handle *ph, + u32 selector, + unsigned int *nr_groups, + const unsigned int **groups) +{ + struct scmi_pinctrl_info *pi; + + if (!groups || !nr_groups) + return -EINVAL; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + if (selector > pi->nr_functions) + return -EINVAL; + + if (!pi->functions[selector].present) { + int ret; + + ret = scmi_pinctrl_get_function_info(ph, selector, + &pi->functions[selector]); + if (ret) + return ret; + } + + *groups = pi->functions[selector].groups; + *nr_groups = pi->functions[selector].nr_groups; + + return 0; +} + +static int scmi_pinctrl_set_mux(const struct scmi_protocol_handle *ph, + u32 selector, u32 group) +{ + return scmi_pinctrl_function_select(ph, group, GROUP_TYPE, + selector); +} + +static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph, + u32 selector, struct scmi_pin_info *pin) +{ + int ret; + struct scmi_pinctrl_info *pi; + + if (!pin) + return -EINVAL; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, + pin->name, NULL); + if (ret) + return ret; + + pin->present = true; + return 0; +} + +static int scmi_pinctrl_get_pin_name(const struct scmi_protocol_handle *ph, + u32 selector, const char **name) +{ + struct scmi_pinctrl_info *pi; + + if (!name) + return -EINVAL; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + if (selector > pi->nr_pins) + return -EINVAL; + + if (!pi->pins[selector].present) { + int ret; + + ret = scmi_pinctrl_get_pin_info(ph, selector, + &pi->pins[selector]); + if (ret) + return ret; + } + + *name = pi->pins[selector].name; + + return 0; +} + +static int scmi_pinctrl_get_name(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + const char **name) +{ + switch (type) { + case PIN_TYPE: + return scmi_pinctrl_get_pin_name(ph, selector, name); + case GROUP_TYPE: + return scmi_pinctrl_get_group_name(ph, selector, name); + case FUNCTION_TYPE: + return scmi_pinctrl_get_function_name(ph, selector, name); + default: + return -EINVAL; + } +} + +static const struct scmi_pinctrl_proto_ops pinctrl_proto_ops = { + .get_count = scmi_pinctrl_get_count, + .get_name = scmi_pinctrl_get_name, + .get_group_pins = scmi_pinctrl_get_group_pins, + .get_function_groups = scmi_pinctrl_get_function_groups, + .set_mux = scmi_pinctrl_set_mux, + .get_config = scmi_pinctrl_get_config, + .set_config = scmi_pinctrl_set_config, + .request_pin = scmi_pinctrl_request_pin, + .free_pin = scmi_pinctrl_free_pin +}; + +static int scmi_pinctrl_protocol_init(const struct scmi_protocol_handle *ph) +{ + int ret; + u32 version; + struct scmi_pinctrl_info *pinfo; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_dbg(ph->dev, "Pinctrl Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL); + if (!pinfo) + return -ENOMEM; + + ret = scmi_pinctrl_attributes_get(ph, pinfo); + if (ret) + return ret; + + pinfo->pins = devm_kcalloc(ph->dev, pinfo->nr_pins, + sizeof(*pinfo->pins), + GFP_KERNEL); + if (!pinfo->pins) + return -ENOMEM; + + pinfo->groups = devm_kcalloc(ph->dev, pinfo->nr_groups, + sizeof(*pinfo->groups), + GFP_KERNEL); + if (!pinfo->groups) + return -ENOMEM; + + pinfo->functions = devm_kcalloc(ph->dev, pinfo->nr_functions, + sizeof(*pinfo->functions), + GFP_KERNEL); + if (!pinfo->functions) + return -ENOMEM; + + pinfo->version = version; + + return ph->set_priv(ph, pinfo); +} + +static int scmi_pinctrl_protocol_deinit(const struct scmi_protocol_handle *ph) +{ + int i; + struct scmi_pinctrl_info *pi; + + pi = ph->get_priv(ph); + if (!pi) + return -EINVAL; + + for (i = 0; i < pi->nr_groups; i++) + if (pi->groups[i].present) { + devm_kfree(ph->dev, pi->groups[i].group_pins); + pi->groups[i].present = false; + } + + for (i = 0; i < pi->nr_functions; i++) + if (pi->functions[i].present) { + devm_kfree(ph->dev, pi->functions[i].groups); + pi->functions[i].present = false; + } + + return 0; +} + +static const struct scmi_protocol scmi_pinctrl = { + .id = SCMI_PROTOCOL_PINCTRL, + .owner = THIS_MODULE, + .instance_init = &scmi_pinctrl_protocol_init, + .instance_deinit = &scmi_pinctrl_protocol_deinit, + .ops = &pinctrl_proto_ops, +}; + +DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(pinctrl, scmi_pinctrl) diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h index b3c6314bb4b8..674f949354f9 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -346,5 +346,6 @@ DECLARE_SCMI_REGISTER_UNREGISTER(sensors); DECLARE_SCMI_REGISTER_UNREGISTER(voltage); DECLARE_SCMI_REGISTER_UNREGISTER(system); DECLARE_SCMI_REGISTER_UNREGISTER(powercap); +DECLARE_SCMI_REGISTER_UNREGISTER(pinctrl); #endif /* _SCMI_PROTOCOLS_H */ diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 0ce5746a4470..97631783a5a4 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -735,6 +735,52 @@ struct scmi_notify_ops { struct notifier_block *nb); }; +enum scmi_pinctrl_selector_type { + PIN_TYPE = 0, + GROUP_TYPE, + FUNCTION_TYPE +}; + +/** + * struct scmi_pinctrl_proto_ops - represents the various operations provided + * by SCMI Pinctrl Protocol + * + * @get_count: returns count of the registered elements in given type + * @get_name: returns name by index of given type + * @get_group_pins: returns the set of pins, assigned to the specified group + * @get_function_groups: returns the set of groups, assigned to the specified + * function + * @set_mux: set muxing function for groups of pins + * @get_config: returns configuration parameter for pin or group + * @set_config: sets the configuration parameter for pin or group + * @request_pin: aquire pin before selecting mux setting + * @free_pin: frees pin, acquired by request_pin call + */ +struct scmi_pinctrl_proto_ops { + int (*get_count)(const struct scmi_protocol_handle *ph, + enum scmi_pinctrl_selector_type type); + int (*get_name)(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + const char **name); + int (*get_group_pins)(const struct scmi_protocol_handle *ph, + u32 selector, + const unsigned int **pins, unsigned int *nr_pins); + int (*get_function_groups)(const struct scmi_protocol_handle *ph, + u32 selector, unsigned int *nr_groups, + const unsigned int **groups); + int (*set_mux)(const struct scmi_protocol_handle *ph, u32 selector, + u32 group); + int (*get_config)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type, + u8 config_type, unsigned long *config_value); + int (*set_config)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type, + u8 config_type, unsigned long config_value); + int (*request_pin)(const struct scmi_protocol_handle *ph, u32 pin); + int (*free_pin)(const struct scmi_protocol_handle *ph, u32 pin); +}; + /** * struct scmi_handle - Handle returned to ARM SCMI clients for usage. * @@ -783,6 +829,7 @@ enum scmi_std_protocol { SCMI_PROTOCOL_RESET = 0x16, SCMI_PROTOCOL_VOLTAGE = 0x17, SCMI_PROTOCOL_POWERCAP = 0x18, + SCMI_PROTOCOL_PINCTRL = 0x19, }; enum scmi_system_events { From patchwork Tue Jun 6 16:22:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13269443 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 2F70EC7EE2A for ; Tue, 6 Jun 2023 16:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=TLnplqMFQt6MumTRTE6BHaRdDTz63xtd3fZV0NGDUiE=; b=V4+GQxPbLUNfjN CT6ccuTlRne2hQaRvCGldsPxiU/g1XImollW+oMPUBbrjRa/9f1PkfbpJKK9Jj3bx1lV8afINbke0 xPHZvar9886P6SYey9VW8OLdrgRgfhfFE+dNkqit3t5T8ukUC9y3A4q3aozPSxKlgfbG3IF4yiiZn 3/eSiMF46O/uAxf/DscPuWKGH/7SftkvtPGhwaqve8hBSdumPwpNTGrZtCr+gr++KBXH9YDDyL57o Fzs4vkZ9Rjh8+FctSHF/KRxlF3RKTF52hojYoO9eQimsB7bbT11Gv7OHUmp4DzRQsyP5TTmMQlCqh e1HN4VuFxWvnfci2bQ1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSY-002PS8-0k; Tue, 06 Jun 2023 16:23:02 +0000 Received: from mx0b-0039f301.pphosted.com ([148.163.137.242]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSQ-002PMs-31 for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 16:22:58 +0000 Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356G3feh006627; Tue, 6 Jun 2023 16:22:48 GMT Received: from eur02-db5-obe.outbound.protection.outlook.com (mail-db5eur02lp2112.outbound.protection.outlook.com [104.47.11.112]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3r2804r2hw-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 16:22:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iFzalSxQwR6F3GhoO2pGHlarxArqU17CVwRVGWPX4WUUYCkaLt8n55H7JkG7qJAYB53gdxQPocPvbUNZvrPndhff4qGUfCGQ3tOrOMC/v3NwoB/+Mbl+48TKuumUJuHQhG8CM1waAa9wBemE+H2pOSV8Xqs46RXt7+rJEahZNIb0RW4lXMSmS//vcphGMxLSSE+Qa0n5JzsS4pUVG//zzVWy70pk/nd/4OkrgOtVPeSbGLJzcCM3GHlOA49NwfQXaKE/NT4halBZzGksmRTLw/XeUzkTMHF7raeXJdFmE0kqfstJK5NkLKSms9YKS95s5tfQ+OIczdRE9uVLbYU9/Q== 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=faOtSIQclsBzPLgaqj9sZP2ojMc6mCeoFaCdceBh4rI=; b=errdl5Hn/qkQniPV34M45oX95MvXh19m9AIyl0kYsGs68ZevM1pxbpOTC8KU5TkHM+01MvwqhoVEDsgp1mlzwCITeN40MJxadkmoElDQkOpv/ttoLzQi3Zi16KzofGz6+t84JMqVs/JsLMfBHs/f0FtlGszeb/NxnC7Oxq8zoW+VxLkBhgyf7r7UNldWRif85TfgjdqA+vxpRHS9W6wo+eA9VEab1EQp66U0x9Ed7PFzoPr2vgtvHNhlzgeq9sMf0NPjqPatK8RiEv055QPeN8MPaIbWPGavhixub+TVkEdfSa8B6r34hdu0RpuHYydL9ouLYvtJ5gvhVXSPXFzWPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=faOtSIQclsBzPLgaqj9sZP2ojMc6mCeoFaCdceBh4rI=; b=Sb7bYUfXRrOnMrmcvZ3gN618jujDg45cbiiuPVyl0IOmCoeSYFMtnFW3bRCSrFwddCkycCJ61oQsMisLU2BuFWVlPQld7anbZVI8aFdqYGe+rbMXW1lmabGGKayhEo8DXuzcX4Ms1p6IclL3GwLqI3PZOo9q0kGicAM+JWh9KAn0nadvN/Ti3Z4C45vflPxQqKdnVdJPnYwXR3buVIZ7pUEifxJYUKGtc1LR8I1je4Ev7jZDtE1HlkuIC9yEnKuYN3q/J3f7hKEtKAepV/3LyiEVTOnpfTZerkZEB/9quYQrrCIgW0K59eujqB+WnQGoCkWadn6rQ80Gzd7vgPKPow== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PAVPR03MB9383.eurprd03.prod.outlook.com (2603:10a6:102:308::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 16:22:28 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5%4]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 16:22:28 +0000 From: Oleksii Moisieiev To: "sudeep.holla@arm.com" CC: Oleksii Moisieiev , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" Subject: [PATCH v3 3/4] pinctrl: Implementation of the generic scmi-pinctrl driver Thread-Topic: [PATCH v3 3/4] pinctrl: Implementation of the generic scmi-pinctrl driver Thread-Index: AQHZmJMWFmItseqHB0qRWKbh+9Pp/A== Date: Tue, 6 Jun 2023 16:22:28 +0000 Message-ID: <43109a0f2f362222fca79e2afd15c46ed9a32977.1686063941.git.oleksii_moisieiev@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR03MB7136:EE_|PAVPR03MB9383:EE_ x-ms-office365-filtering-correlation-id: be86b4b2-2c40-4ea9-a3f9-08db66aa389e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IYAzymepBfqUIl5G2UXND/XLG8zridnNB4NwZaAjntl3cwDuABFp13tD0Oemur6p9+g3P3qRZRD7hfAmj53O7spAa2Kgx50ixLniuBuEtDG7QIf84YSpUUnBLzTnY4QSHMB29qVSsiA5clI35HK9D+qyOKuBFaz51aPR4pFEjUrK43EusHnc1zIF1zWTWuRYJFWrIKdxtjz5q9TBtOHFgHlZLBBYilMKDkQTlm2yGJgsqO8swkzL3xGZLZO3cStN+/z9rlW7pGHhMXyG93SMxkBWBwNNXhN/VX5NT+f0P9ar75dxHKzOHlW5wPxG5A624P/oSD1BKUo9bFezNdV1cJTJkiFYsdHUf+tFmxT+T8wY+KhMhfDRRCjOoL8CneKlk1dn//4Y9vYi4FtQ3t+sYogPPcoG0+KOpVCMEFVlMx+44/2ef/KzgUwyKBOtoNJPvH4YFH4wkf6iqWiwCa7rDswqtWKi9w1zkKl2OUBl/OE4lrNTx10Ta3ct4mTKfcqaxaZSCXaETsuA0mPxunWBwerYnyWwgBAf8XvUZ77DWiiG0WRGhOgdMYlqLCW5ReX+lbk6wvqTET71rRQQED0oS5+mG3SGRwoMN2BR2M9qBK2d3fMBoT8GPlGvlkQUSFwTI5gSmzYQ4JQtbjnbHpXJqA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(39860400002)(396003)(376002)(346002)(451199021)(83380400001)(38100700002)(86362001)(38070700005)(122000001)(478600001)(91956017)(41300700001)(71200400001)(6486002)(54906003)(5660300002)(8676002)(66476007)(64756008)(66946007)(76116006)(6916009)(4326008)(8936002)(66446008)(66556008)(316002)(2906002)(30864003)(7416002)(2616005)(26005)(6506007)(6512007)(36756003)(186003)(41533002)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?4vdGYK8vMXdaOePQ8oXXgKZ?= =?iso-8859-1?q?OL2WZ32TxVAEDDnsFImAjB3AUONGuyaQGT06OSFb0c4/miUiKkGl98mBxxKZ?= =?iso-8859-1?q?LmLmSQC7gjBM+mz5A24qcjZTAnNEy9aPkqhQBgr59fUFrv9O45ZyL1e8cIWe?= =?iso-8859-1?q?e6XoMzO1TMrAnuwQ6dbeQIIjVO0TkDzOnll27Gz/Uh+ypgPQ/oI8Vk1NEW+V?= =?iso-8859-1?q?bEGXNsIZtSSpjM/HvCZaUD09Fjyyas/ggruzzMUuMEOQKhxGdtS3h0YDGXdf?= =?iso-8859-1?q?PJHvuJ6j3zuGq2TGnDB9L2/uNLAbWuF2Z22yttP0zXsIR/B8u2B/9arKzQ4T?= =?iso-8859-1?q?tvOND445baSQcFyCk+JB1jvNS4FQxGPP+XGCZ9iXMTtThWhpjVMeRm1kF0E3?= =?iso-8859-1?q?MyWo/SY3ZM2ZGagtw9qnNtTTtxCVX/i0YqJskD2eLVf/mly3QnmauFuAceq8?= =?iso-8859-1?q?Jb739HKvauHxrRrZ2kiGFWArA6UcWXBvX4SwCtTwyg+G9tgT/mh6z7Un642D?= =?iso-8859-1?q?dpfBUsjkTHKvh7WUFVEiGN5Kp4QCiRwNcz+HvElzZry8bnyVQMSkMEAVAxhk?= =?iso-8859-1?q?A+xd6F46F/OE0MiSlBmSqEdZdV8DOXXnQdEswuFlAhYWTrUG9tv0tCW5qMBh?= =?iso-8859-1?q?vCQmePyxc2VdiPNjc84TgWllgfNRNwxdW7PbUwsmMsn4I7oh+TVuYYTOFa6N?= =?iso-8859-1?q?WCzOJTtlXa+kZTZewA49AJiMZ0ij4BCoi8zgYy1PIYtgqv3CmBVWdldvKQ9i?= =?iso-8859-1?q?z5qLd2QbE/KJJ2OWaT8+9ggYj8fV9qULwJk9TsFc7Ccp198UKMw9JwEUdd/M?= =?iso-8859-1?q?jDPmb30IKrCtj4KSTcK0kYgbLRJK76fNcAxL/dVtTMnjiGlCZBjRvSaeC4cp?= =?iso-8859-1?q?fmuSQF3pbWkwHUAu/klUsA/MV+jDXxWXyJrU0Ame86MY+JgsyxrucIZqNXni?= =?iso-8859-1?q?+vitRr81eYRJgpNylVdwCPkekphOGtmhh/plGU1TWmgDY3D/QtSrTT9DKVIo?= =?iso-8859-1?q?20ZSzHcj3ADeWxxnUkaiaGmGFZLPtQmSVeWDQ1Fv6RRkxc/FBbvTgMiStzfy?= =?iso-8859-1?q?RWufkg5m9AwclYZXRjPr/AsAlxr1NChEt7zV/Yf2lR6F7TyXh932m7KQKuS6?= =?iso-8859-1?q?tnzAW/zPwA1gZcanDJeQkA6jV7Yeh/KPjLQmW7M45DOjwu68kYaQU4vXVKbE?= =?iso-8859-1?q?palrXPWF/ErP43r1IWLQYIjc0h3MOatdv/aztzd/Gao8cSIqqls+qIWone47?= =?iso-8859-1?q?vSDjLHv1OR1ozfzm+Ts1xXRqf63L9ViG2HvTfjRcKDbcbJcElNvznu1GZGtP?= =?iso-8859-1?q?i369jnz1hpOK5jdBcwC79fOzhCqlJRHIWsD4Hde9JA/gP8ffQRG3RZiFkW1e?= =?iso-8859-1?q?6uSpBP3PPumoDFDSNDspPslyl22YV1v1+RYSjlbRX5oPEG0rWIBeKC+vlal5?= =?iso-8859-1?q?8rWO7Br8ZL3IlFXqQJkxZExS+JyUFVsvVn0lkz9l4QTvWFzjIJEiK/JXNBpj?= =?iso-8859-1?q?xtMWUinaioTjKICeDJ+mSCdYNO//IhsnNlypay+cVzSUEeqdEv4qJnREDa3v?= =?iso-8859-1?q?wXHkVhNZL6/2AW7m07BrhfyikPYjcd+jbjSAsPn1Mh6jgCfKz2qFS/T4AyqF?= =?iso-8859-1?q?4yMa182sfkqUJBxqukju5nu0r1++xpA4VaiLfOQ=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: be86b4b2-2c40-4ea9-a3f9-08db66aa389e X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2023 16:22:28.3104 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oN95VVAGXXI6j1uvBPAh/nFJfe/Hhglq6UuTBAPfiFfSmmlnwhIpBkzKdflGKbpPOcZcYhv/xpopcmLb7GBuBpwr/7JfEs84CLwCHeRdc88= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR03MB9383 X-Proofpoint-GUID: wcNcKG9udto040MADMD3PaEdnqwDMELq X-Proofpoint-ORIG-GUID: wcNcKG9udto040MADMD3PaEdnqwDMELq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_12,2023-06-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 impostorscore=0 adultscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060141 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_092255_097473_B8E3396E X-CRM114-Status: GOOD ( 23.46 ) 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 scmi-pinctrl driver implements pinctrl driver interface and using SCMI protocol to redirect messages from pinctrl subsystem SDK to SCP firmware, which does the changes in HW. This setup expects SCP firmware (or similar system, such as ATF) to be installed on the platform, which implements pinctrl driver for the specific platform. SCMI-Pinctrl driver should be configured from the device-tree and uses generic device-tree mappings for the configuration. Signed-off-by: Oleksii Moisieiev --- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-scmi.c | 554 +++++++++++++++++++++++++++++++++ 4 files changed, 567 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-scmi.c diff --git a/MAINTAINERS b/MAINTAINERS index 297b2512963d..91883955fc1a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20527,6 +20527,7 @@ M: Oleksii Moisieiev L: linux-arm-kernel@lists.infradead.org S: Maintained F: drivers/firmware/arm_scmi/pinctrl.c +F: drivers/pinctrl/pinctrl-scmi.c SYSTEM RESET/SHUTDOWN DRIVERS M: Sebastian Reichel diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 5787c579dcf6..c4680a2c5e13 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -546,4 +546,15 @@ source "drivers/pinctrl/uniphier/Kconfig" source "drivers/pinctrl/visconti/Kconfig" source "drivers/pinctrl/vt8500/Kconfig" +config PINCTRL_SCMI + tristate "Pinctrl driver controlled via SCMI interface" + depends on ARM_SCMI_PROTOCOL || COMPILE_TEST + select PINMUX + select GENERIC_PINCONF + help + This driver provides support for pinctrl which is controlled + by firmware that implements the SCMI interface. + It uses SCMI Message Protocol to interact with the + firmware providing all the pinctrl controls. + endif diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index e196c6e324ad..b932a116e6a0 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_PINCTRL_SX150X) += pinctrl-sx150x.o obj-$(CONFIG_PINCTRL_TB10X) += pinctrl-tb10x.o obj-$(CONFIG_PINCTRL_ZYNQMP) += pinctrl-zynqmp.o obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o +obj-$(CONFIG_PINCTRL_SCMI) += pinctrl-scmi.o obj-y += actions/ obj-$(CONFIG_ARCH_ASPEED) += aspeed/ diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c new file mode 100644 index 000000000000..e46dffa652c6 --- /dev/null +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -0,0 +1,554 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System Control and Power Interface (SCMI) Protocol based pinctrl driver + * + * Copyright (C) 2023 EPAM + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "pinctrl-utils.h" +#include "core.h" +#include "pinconf.h" + +#define DRV_NAME "scmi-pinctrl" + +static const struct scmi_pinctrl_proto_ops *pinctrl_ops; + +struct scmi_pinctrl_funcs { + unsigned int num_groups; + const char **groups; +}; + +struct scmi_pinctrl { + struct device *dev; + struct scmi_protocol_handle *ph; + struct pinctrl_dev *pctldev; + struct pinctrl_desc pctl_desc; + struct scmi_pinctrl_funcs *functions; + unsigned int nr_functions; + char **groups; + unsigned int nr_groups; + struct pinctrl_pin_desc *pins; + unsigned int nr_pins; +}; + +static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev) +{ + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return -EINVAL; + + return pinctrl_ops->get_count(pmx->ph, GROUP_TYPE); +} + +static const char *pinctrl_scmi_get_group_name(struct pinctrl_dev *pctldev, + unsigned int selector) +{ + int ret; + const char *name; + struct scmi_pinctrl *pmx; + + if (!pctldev) + return NULL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return NULL; + + ret = pinctrl_ops->get_name(pmx->ph, selector, GROUP_TYPE, &name); + if (ret) { + dev_err(pmx->dev, "get name failed with err %d", ret); + return NULL; + } + + return name; +} + +static int pinctrl_scmi_get_group_pins(struct pinctrl_dev *pctldev, + unsigned int selector, + const unsigned int **pins, + unsigned int *num_pins) +{ + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return -EINVAL; + + return pinctrl_ops->get_group_pins(pmx->ph, selector, + pins, num_pins); +} + +#ifdef CONFIG_OF +static int pinctrl_scmi_dt_node_to_map(struct pinctrl_dev *pctldev, + struct device_node *np_config, + struct pinctrl_map **map, + u32 *num_maps) +{ + return pinconf_generic_dt_node_to_map(pctldev, np_config, map, + num_maps, PIN_MAP_TYPE_INVALID); +} + +static void pinctrl_scmi_dt_free_map(struct pinctrl_dev *pctldev, + struct pinctrl_map *map, u32 num_maps) +{ + kfree(map); +} + +#endif /* CONFIG_OF */ + +static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = { + .get_groups_count = pinctrl_scmi_get_groups_count, + .get_group_name = pinctrl_scmi_get_group_name, + .get_group_pins = pinctrl_scmi_get_group_pins, +#ifdef CONFIG_OF + .dt_node_to_map = pinctrl_scmi_dt_node_to_map, + .dt_free_map = pinctrl_scmi_dt_free_map, +#endif +}; + +static int pinctrl_scmi_get_functions_count(struct pinctrl_dev *pctldev) +{ + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return -EINVAL; + + return pinctrl_ops->get_count(pmx->ph, FUNCTION_TYPE); +} + +static const char *pinctrl_scmi_get_function_name(struct pinctrl_dev *pctldev, + unsigned int selector) +{ + int ret; + const char *name; + struct scmi_pinctrl *pmx; + + if (!pctldev) + return NULL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return NULL; + + ret = pinctrl_ops->get_name(pmx->ph, selector, FUNCTION_TYPE, &name); + if (ret) { + dev_err(pmx->dev, "get name failed with err %d", ret); + return NULL; + } + + return name; +} + +static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev, + unsigned int selector, + const char * const **groups, + unsigned int * const num_groups) +{ + const unsigned int *group_ids; + int ret, i; + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph || !groups || !num_groups) + return -EINVAL; + + if (selector < pmx->nr_functions && + pmx->functions[selector].num_groups) { + *groups = (const char * const *)pmx->functions[selector].groups; + *num_groups = pmx->functions[selector].num_groups; + return 0; + } + + ret = pinctrl_ops->get_function_groups(pmx->ph, selector, + &pmx->functions[selector].num_groups, + &group_ids); + if (ret) { + dev_err(pmx->dev, "Unable to get function groups, err %d", ret); + return ret; + } + + *num_groups = pmx->functions[selector].num_groups; + if (!*num_groups) + return -EINVAL; + + pmx->functions[selector].groups = + devm_kcalloc(pmx->dev, *num_groups, + sizeof(*pmx->functions[selector].groups), + GFP_KERNEL); + if (!pmx->functions[selector].groups) + return -ENOMEM; + + for (i = 0; i < *num_groups; i++) { + pmx->functions[selector].groups[i] = + pinctrl_scmi_get_group_name(pmx->pctldev, + group_ids[i]); + if (!pmx->functions[selector].groups[i]) { + ret = -ENOMEM; + goto error; + } + } + + *groups = (const char * const *)pmx->functions[selector].groups; + + return 0; + +error: + devm_kfree(pmx->dev, pmx->functions[selector].groups); + + return ret; +} + +static int pinctrl_scmi_func_set_mux(struct pinctrl_dev *pctldev, + unsigned int selector, unsigned int group) +{ + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return -EINVAL; + + return pinctrl_ops->set_mux(pmx->ph, selector, group); +} + +static int pinctrl_scmi_request(struct pinctrl_dev *pctldev, + unsigned int offset) +{ + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return -EINVAL; + + return pinctrl_ops->request_pin(pmx->ph, offset); +} + +static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset) +{ + struct scmi_pinctrl *pmx; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph) + return -EINVAL; + + return pinctrl_ops->free_pin(pmx->ph, offset); +} + +static const struct pinmux_ops pinctrl_scmi_pinmux_ops = { + .request = pinctrl_scmi_request, + .free = pinctrl_scmi_free, + .get_functions_count = pinctrl_scmi_get_functions_count, + .get_function_name = pinctrl_scmi_get_function_name, + .get_function_groups = pinctrl_scmi_get_function_groups, + .set_mux = pinctrl_scmi_func_set_mux, +}; + +static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev, + unsigned int _pin, + unsigned long *config) +{ + int ret; + struct scmi_pinctrl *pmx; + enum pin_config_param config_type; + unsigned long config_value; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph || !config) + return -EINVAL; + + config_type = pinconf_to_config_param(*config); + + ret = pinctrl_ops->get_config(pmx->ph, _pin, PIN_TYPE, config_type, + &config_value); + if (ret) + return ret; + + *config = pinconf_to_config_packed(config_type, config_value); + + return 0; +} + +static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev, + unsigned int _pin, + unsigned long *configs, + unsigned int num_configs) +{ + int i, ret; + struct scmi_pinctrl *pmx; + enum pin_config_param config_type; + unsigned long config_value; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph || !configs || num_configs == 0) + return -EINVAL; + + for (i = 0; i < num_configs; i++) { + config_type = pinconf_to_config_param(configs[i]); + config_value = pinconf_to_config_argument(configs[i]); + + ret = pinctrl_ops->set_config(pmx->ph, _pin, PIN_TYPE, config_type, + config_value); + if (ret) { + dev_err(pmx->dev, "Error parsing config %ld\n", + configs[i]); + break; + } + } + + return ret; +} + +static int pinctrl_scmi_pinconf_group_set(struct pinctrl_dev *pctldev, + unsigned int group, + unsigned long *configs, + unsigned int num_configs) +{ + int i, ret; + struct scmi_pinctrl *pmx; + enum pin_config_param config_type; + unsigned long config_value; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph || !configs || num_configs == 0) + return -EINVAL; + + for (i = 0; i < num_configs; i++) { + config_type = pinconf_to_config_param(configs[i]); + config_value = pinconf_to_config_argument(configs[i]); + + ret = pinctrl_ops->set_config(pmx->ph, group, GROUP_TYPE, + config_type, config_value); + if (ret) { + dev_err(pmx->dev, "Error parsing config = %ld", + configs[i]); + break; + } + } + + return ret; +}; + +static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev, + unsigned int _pin, + unsigned long *config) +{ + int ret; + struct scmi_pinctrl *pmx; + enum pin_config_param config_type; + unsigned long config_value; + + if (!pctldev) + return -EINVAL; + + pmx = pinctrl_dev_get_drvdata(pctldev); + + if (!pmx || !pmx->ph || !config) + return -EINVAL; + + config_type = pinconf_to_config_param(*config); + + ret = pinctrl_ops->get_config(pmx->ph, _pin, GROUP_TYPE, + config_type, &config_value); + if (ret) + return ret; + + *config = pinconf_to_config_packed(config_type, config_value); + + return 0; +} + +static const struct pinconf_ops pinctrl_scmi_pinconf_ops = { + .is_generic = true, + .pin_config_get = pinctrl_scmi_pinconf_get, + .pin_config_set = pinctrl_scmi_pinconf_set, + .pin_config_group_set = pinctrl_scmi_pinconf_group_set, + .pin_config_group_get = pinctrl_scmi_pinconf_group_get, + .pin_config_config_dbg_show = pinconf_generic_dump_config, +}; + +static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx, + unsigned int *nr_pins, + const struct pinctrl_pin_desc **pins) +{ + int ret, i; + + if (!pmx || !pmx->ph) + return -EINVAL; + + if (!pins || !nr_pins) + return -EINVAL; + + if (pmx->nr_pins) { + *pins = pmx->pins; + *nr_pins = pmx->nr_pins; + return 0; + } + + *nr_pins = pinctrl_ops->get_count(pmx->ph, PIN_TYPE); + + pmx->nr_pins = *nr_pins; + pmx->pins = devm_kmalloc_array(pmx->dev, *nr_pins, sizeof(*pmx->pins), + GFP_KERNEL); + if (!pmx->pins) + return -ENOMEM; + + for (i = 0; i < *nr_pins; i++) { + pmx->pins[i].number = i; + ret = pinctrl_ops->get_name(pmx->ph, i, PIN_TYPE, + &pmx->pins[i].name); + if (ret) { + dev_err(pmx->dev, "Can't get name for pin %d: rc %d", + i, ret); + goto err_free; + } + } + + *pins = pmx->pins; + dev_dbg(pmx->dev, "got pins %d", *nr_pins); + + return 0; + err_free: + devm_kfree(pmx->dev, pmx->pins); + pmx->nr_pins = 0; + + return ret; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_PINCTRL, "pinctrl" }, + { } +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static int scmi_pinctrl_probe(struct scmi_device *sdev) +{ + int ret; + struct scmi_pinctrl *pmx; + const struct scmi_handle *handle; + struct scmi_protocol_handle *ph; + + if (!sdev || !sdev->handle) + return -EINVAL; + + handle = sdev->handle; + + pinctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PINCTRL, &ph); + if (IS_ERR(pinctrl_ops)) + return PTR_ERR(pinctrl_ops); + + pmx = devm_kzalloc(&sdev->dev, sizeof(*pmx), GFP_KERNEL); + if (!pmx) + return -ENOMEM; + + pmx->ph = ph; + + pmx->dev = &sdev->dev; + pmx->pctl_desc.name = DRV_NAME; + pmx->pctl_desc.owner = THIS_MODULE; + pmx->pctl_desc.pctlops = &pinctrl_scmi_pinctrl_ops; + pmx->pctl_desc.pmxops = &pinctrl_scmi_pinmux_ops; + pmx->pctl_desc.confops = &pinctrl_scmi_pinconf_ops; + + ret = pinctrl_scmi_get_pins(pmx, &pmx->pctl_desc.npins, + &pmx->pctl_desc.pins); + if (ret) + return ret; + + ret = devm_pinctrl_register_and_init(&sdev->dev, &pmx->pctl_desc, pmx, + &pmx->pctldev); + if (ret) { + dev_err_probe(&sdev->dev, ret, "Failed to register pinctrl\n"); + return ret; + } + + pmx->nr_functions = pinctrl_scmi_get_functions_count(pmx->pctldev); + pmx->nr_groups = pinctrl_scmi_get_groups_count(pmx->pctldev); + + if (pmx->nr_functions) { + pmx->functions = + devm_kcalloc(&sdev->dev, pmx->nr_functions, + sizeof(*pmx->functions), + GFP_KERNEL); + if (!pmx->functions) + return -ENOMEM; + } + + if (pmx->nr_groups) { + pmx->groups = + devm_kcalloc(&sdev->dev, pmx->nr_groups, + sizeof(*pmx->groups), + GFP_KERNEL); + if (!pmx->groups) + return -ENOMEM; + } + + return pinctrl_enable(pmx->pctldev); +} + +static struct scmi_driver scmi_pinctrl_driver = { + .name = DRV_NAME, + .probe = scmi_pinctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_pinctrl_driver); + +MODULE_AUTHOR("Oleksii Moisieiev "); +MODULE_DESCRIPTION("ARM SCMI pin controller driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Jun 6 16:22:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13269441 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 B63B4C7EE32 for ; Tue, 6 Jun 2023 16:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: 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=ZxnQW7YxPv+uitAZeTGIaXOoeUPozD/+7vP04WTPB2M=; b=VX8RiF6ifilBVT 6sOabTP+XtPr/HLthV85BBJHXZKR0QhdMcRsdEoNtqZIRKMgDCdVhz7rPl5vgPR+P5Ys5HIAW1Ome 6pEkgJs3VMkslZlhOHKxtbV0PNpFP0UkAJUV4ycA9yg6qZPr3A0SKMKKsdZnFJYZkQ/KUkYCBSiE+ sRm+H8wNR4fknK2tiZaUnO1LlLUbeABBDe/Mu0TaCjyOOm1g/zqLduRwVsLDKghaBveo9GkBYWwE/ A3ITpM9m8wL95iTdmy6olIMgLOmgBRy3M7EtJXF0Kr8ymVtgydGNVaKFnU4I4vKSpjtlhYu0J+37a bqRlAElv59lTu8RlGbtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSU-002PPX-1C; Tue, 06 Jun 2023 16:22:58 +0000 Received: from mx0b-0039f301.pphosted.com ([148.163.137.242]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZSQ-002PMf-31 for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 16:22:56 +0000 Received: from pps.filterd (m0174680.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356G3fee006627; Tue, 6 Jun 2023 16:22:47 GMT Received: from eur02-db5-obe.outbound.protection.outlook.com (mail-db5eur02lp2112.outbound.protection.outlook.com [104.47.11.112]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3r2804r2hw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jun 2023 16:22:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EQJixJ3k7j17ZvnICaTg75pwRLb4D8507lQROfXen5t6qFVtkmStS74C4zlrGk5AwbpvfzfWLbJXBKG4cthC2/Fb2lvv3j9uviw2sA3htcYyWhcqV6GVOyO9xRrrKjYQj8ef0e9Gm/eFZQ3Z8/lMPq+VoeikuPqOpCjHyLZxgDYMDT0gLGO2bxvd7FlV7MDHsT7LZuE//bRAZu3mgWKvGU7GcXnpUXepxLruU7I5w7Jvpw7l9dcWct3kQikQzH4xRUWyFjU3hY7I3K+jhK0hh8lvr09bQVkX8LE7IQjW++NkRMRzfGz/Oqgsol+lOgdut4+UxsVomM8ZPMkLflwnZg== 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=IPyoM93CIg05EExfADs14Sex6K6txv6z7yh4h8HoPVU=; b=JgdTi7c5D6nShM3KFPvkp7UlN60EPDS4tIx1PtQjNdUHf9K9gHlIvV86ssIKy2C+LB/usdHQ5iybwKHC0DJ+pc4mzCl0KYKFa6l8hS3vyKBYE8MKVrDgqxAt6ut7fyotw18fWRDhBPt1bzDFerP+1EKzy97EiO8UYVFrhKiVjK28ZNkwEYt8EcxjM9i4AmHB+sJ9EK/qLLN2UI4we2vILEZOa0BJ4AGkLQvNx3MesHMZ+nq1ISjbn/pLdLtl7P7jdPf6GkAMCyIIE/xsZL4vsQLDtLlR+N2m8XmGb5aPlfWi+PtFe3/ZHZ4VlQMsIoJqg3srmeyvJQwhh6LdxVVKjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPyoM93CIg05EExfADs14Sex6K6txv6z7yh4h8HoPVU=; b=L9M7NlpAL1dJHwl3zvUdhdct3RA/uVezTPUEa4dZt9WCs+2s+UkKs0JOlD3NiUKod+0V2nGPFrAZz9XQ5PrzY39M2CXZWdYmH5h8krpqROzX2RGxN/jQ69H8lx0seY0/0lcV47vFz7wyJH0mhyg+NCL9hkiyze/oU5YvVab7Li/ujHOS5v3UUaf5VdaVm0IWrOHB7ETqf7HvGMnvF6O2NnUJ9AkftiAYxbc6R7RL+PewjQdEadTzXFlwtV5hBsTgWfqibOMhuvc+ly8+rIIRUcwy5UkBU0kpO2q/LV6DElNJ+cd5UZ7ZBb5uIFqnX68IzOwio8gq3SUU7ZEKuXYZcA== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by PAVPR03MB9383.eurprd03.prod.outlook.com (2603:10a6:102:308::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 16:22:28 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::528d:e0b6:ecc6:25e5%4]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 16:22:28 +0000 From: Oleksii Moisieiev To: "sudeep.holla@arm.com" CC: Oleksii Moisieiev , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" Subject: [PATCH v3 4/4] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol Thread-Topic: [PATCH v3 4/4] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol Thread-Index: AQHZmJMWJkxtIOd1SkGZy3MMJWizGg== Date: Tue, 6 Jun 2023 16:22:28 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR03MB7136:EE_|PAVPR03MB9383:EE_ x-ms-office365-filtering-correlation-id: 59b85e82-598e-49e1-0078-08db66aa38df x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fnaQAf9+y7OqzCgdgQrG3UzF4eeGd9/fsVXgeGMd3RhcyjMtDk8Qt4B2oZRC20AjPPdWnXRLnxxhlnyFZd6UIYrANrvLRvPHMyPjUWV2xGGU8PYcKCEFhmlBzER2Ryq9p+6OgWW4ox/3awieRSTtvbiY2UyBJhX2Xqlr48PxW3kjCYP7zbkaa/VPHM/9K9lTjdrrF9EniF1RbBp5SdJTMplgbpgvdtsTCm/YLLURGFh9JQM+GBfIYLnnfXfLIWIwGd/zpOBXH71CiFstwxoqAxe7ZMc/NoYh4ZhREzfzqpOBVkdFgpGSa0OltW2Ixrw7dPkCJnxV7Cv4/5OMo9FwsasCZVtmO9J8TyTl8NJ6E1R54nVB1PMq3+npP4MoYghJ07eUOJnvQWja62ki0X3XG5r6px/e2vVJDsBEXTbUkiWqQ9psR8KO+kf0TPI1xjaKOThjmEnTrcAquS/E5/PLFtHyty4xMlJTFfh9/6fOgjo5YX9HybNgvQX9nzQDqj8+bdI6r3auLv0v/ppn2EkmcqUI5sGwNSnFOTF15KTDiWgZsYkWO/T9FtpAUoZFW6IrGwj166/atYbCLd2NDz8GuImjf23UYLPoKvxdSDkQk/6ZezmX+C9yF6dUyTBYF3D8 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR03MB7136.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(39860400002)(396003)(376002)(346002)(451199021)(38100700002)(86362001)(38070700005)(122000001)(478600001)(91956017)(41300700001)(71200400001)(6486002)(54906003)(5660300002)(8676002)(66476007)(64756008)(66946007)(76116006)(6916009)(4326008)(8936002)(66446008)(66556008)(316002)(2906002)(7416002)(2616005)(26005)(6506007)(6512007)(36756003)(186003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?/BmKN2/Ax6Y5H3KwL3zWa5I?= =?iso-8859-1?q?u84U4IiPFHIECnZ95fs+6oxR95F6UEUuCSNXbsOgr80VH18t9aP7uKNueuNO?= =?iso-8859-1?q?EDN7vvOnUouf+tmUdJp+k6yKlxKcsHPlKpheykv1eEcFCYAxYz7bSMqaI53a?= =?iso-8859-1?q?w+yiwqBAg94Xq7FxuJ9MzLmaEYeat0P6xZrsnTdTwKFdDledSHl3QOAjZ62C?= =?iso-8859-1?q?yp92j0XvVj2GSg7MOfWSz6cmBKnKuWDT7ofRyPVVUkDW7FKaU/G7J/hStwMj?= =?iso-8859-1?q?gb3oft6kUOeRIeC36B2S8y15L24f0vpJuk2/2RNaerfCi8JZnbMOVzoDDk0s?= =?iso-8859-1?q?LBCElDEISAs4M48aAP/wJfmARpFLbAzGt+ykfwChdGIl991dpo9ERcQosm8v?= =?iso-8859-1?q?xgx65qbUD3WHeuF5ERKrVZRPti9VbfJ3C+kJ/sQ1rKaGOEVNY5AkXwNKnKWm?= =?iso-8859-1?q?CgjDICiaR3PffsWnCqxncfN+lVobBtp0b7xQ/KGvX4IALez3+7laQoh8UhV8?= =?iso-8859-1?q?CggVecmwmscE1l5vMZInx1TGAPf5e3/+OVBhyhQk/Q1ya8byOTyo8AC60phH?= =?iso-8859-1?q?MF9xEDc93XaUs2y3InV1s2zdDtjdeR4ohx25kcUKesYTc1s/2l3ydFKJJRQN?= =?iso-8859-1?q?eG5PC9AVTPNG6RJrlwBargQAvXypg8pXIKwIyYIodbJ0sVSymUC7OaHv4ODd?= =?iso-8859-1?q?8geFX1+jlhXQXcCSyJy3N1oyy50kE1KMRbEOSD0ie79yzPAiYcCRS0OzlOFo?= =?iso-8859-1?q?FLPhzfU7YqVrAmxI44N1aFYY1ab6MiTNTxovHEoa9xi3ZNYk33b8AwNzqeb/?= =?iso-8859-1?q?QhzgerBBYUtsTkCPWhmD6EDni5fwOM7PA8Wzut+rLRSKOnfS11Lg+gjrC5NJ?= =?iso-8859-1?q?NGaeSDwhUX6F/4uGJ0ypzU0uI8zBErfKIpoYGjzuMOsBBUUfGjtogCItLkFQ?= =?iso-8859-1?q?aF5xzoKacZQlJ9LHALj8lqM3CR/jIqHn49xlsJPNc4JZhAPKUEIzuBgN9LhP?= =?iso-8859-1?q?5XlDTBUZp3W9rFZMzah46N4z2cRXUOPawLA/t05AX/VOw9VBpK+9zVVC7/9f?= =?iso-8859-1?q?hFhTVqtQaRE2Kr2PqARE50LNv1NvOorDctQRBeRbyEvfwR7AFuFGBeB2iEQM?= =?iso-8859-1?q?HuWzdsnVe6jrhRt89bpz7jdnxTF0JdRPwePZCtovScRSoGh1T7owvMx8LY8B?= =?iso-8859-1?q?OiiME6MnHx+UGnufnyYlRp05PnRsfX3bE9JHexLr7lHHVu626dxmzftweLMh?= =?iso-8859-1?q?wGINPwRPDU8GsGpUlH+JGBnhMYg5ZILHbXdAcncPEmF6zpc8ccGbwxDLyLU3?= =?iso-8859-1?q?wmUoQf1hIEAozNKp9q8R41lMQyN4EM2mBZOWWsUgxe7mdndHfWI92GhUcj/p?= =?iso-8859-1?q?W0POqkPIliaG/b2o9bnaAR/GvbW3AdiRjMnmP6x1P2tVS0CePYGTyoBpF5vY?= =?iso-8859-1?q?691RJckb7xERiscuRIWN/HVenai70ynTz1qplrUySjXr61E+sWCYqQBFUnab?= =?iso-8859-1?q?zv37IfjEX5X1YmAlUUsPHkRi/UMxbUmUio2AC6l3Ya2qJmnhdZCU04/XbcDK?= =?iso-8859-1?q?DCOZW69JtOZ7MNHfAJGn5FDHjmYHkWZi7J040F8AeSxjC6Q0jDftsOLI5DOT?= =?iso-8859-1?q?USydUoB1r3jzqPIm/vGB16BF4zxz6kE0I//SxMw=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR03MB7136.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59b85e82-598e-49e1-0078-08db66aa38df X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jun 2023 16:22:28.7228 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mg3GCMSTf75ZTvi9TQAPCHt1vuqCJmH4vD7ze8Hzus+W3kciS5SwLSlT44UfUz3297QZc2UyMNqbKKqYCj10nXuDM8+Cjzo2F69LNRKoPbo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR03MB9383 X-Proofpoint-GUID: QgVRBiERD4BkcpQ3nj8aX8SMvmGa8gl9 X-Proofpoint-ORIG-GUID: QgVRBiERD4BkcpQ3nj8aX8SMvmGa8gl9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_12,2023-06-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 impostorscore=0 adultscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060141 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_092255_095508_10BADCAA X-CRM114-Status: GOOD ( 13.21 ) 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 new SCMI v3.2 pinctrl protocol bindings definitions and example. Signed-off-by: Oleksii Moisieiev Reviewed-by: Linus Walleij --- .../bindings/firmware/arm,scmi.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 5824c43e9893..a19aa184bbd1 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -233,6 +233,39 @@ properties: reg: const: 0x18 + protocol@19: + $ref: '#/$defs/protocol-node' + + properties: + reg: + const: 0x19 + + '#pinctrl-cells': + const: 0 + + allOf: + - $ref: /schemas/pinctrl/pinctrl.yaml# + + required: + - reg + + additionalProperties: + anyOf: + - type: object + allOf: + - $ref: /schemas/pinctrl/pincfg-node.yaml# + - $ref: /schemas/pinctrl/pinmux-node.yaml# + + description: + A pin multiplexing sub-node describe how to configure a + set of pins is some desired function. + A single sub-node may define several pin configurations. + This sub-node is using default pinctrl bindings to configure + pin multiplexing and using SCMI protocol to apply specified + configuration using SCMI protocol. + + unevaluatedProperties: false + additionalProperties: false $defs: @@ -384,6 +417,26 @@ examples: scmi_powercap: protocol@18 { reg = <0x18>; }; + + scmi_pinctrl: protocol@19 { + reg = <0x19>; + #pinctrl-cells = <0>; + + i2c2 { + groups = "i2c2_a", "i2c2_b"; + function = "i2c2"; + }; + + pins_mdio { + groups = "avb_mdio"; + drive-strength = <24>; + }; + + keys_pins: keys { + pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1"; + bias-pull-up; + }; + }; }; };