From patchwork Fri Oct 27 06:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13438135 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 2F2BFC25B6E for ; Fri, 27 Oct 2023 06:29:07 +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=xTkvuFk60OpToV2Wm0QYnHJBmhxuNFhLeYaF9jqdKEA=; b=FUpeWejZ8J7bdS 9qM5pTHZ9TsxSuG9sDSlLn7jnwccB+3UhghBcdEgfGSyX5BspS5WKX6/LNH7p5ladZp54lUIYr94Z WFbmHNeMODDdtYlys2kWrXto1Tlt6kU10Iu6l7RUUP+1Tft3e4bSYlah0wrwMRADeAcVpQhT9+80i xpUEcXwHjWzsNf6h8nha6fXpX80GxIjr8PkfOV1pNhnmfLSa6JGDwlsQvtwNZkIDTBLoNk0r7TpM1 dR0xuINXrZY8bCZAzS42DWuuHaBxREds5eaEJGtEv37x7B3IofY61cWkMMAYjMaPOdJBpwThkweDp +bkKFfrfibVcBzcJLrIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qwGKp-00FgZE-2W; Fri, 27 Oct 2023 06:28:43 +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 1qwGKk-00FgTs-1q for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2023 06:28:40 +0000 Received: from pps.filterd (m0174681.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39QL6OQP007652; Fri, 27 Oct 2023 06:28:15 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3tywqm92ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2023 06:28:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cE6Z9y7/hCmdaVpQBfSIQ3yi4ooE2LI1AJ04680mxZ0Ha/TYLwknSqDID9LsWT5fECAICvVJDGex1750xWHxm9H0Rzz4HeN4XNgoMAvTofr8D/jpXxD8z8SaqyScHQoDR7ISFR6gJgMAfKu4G2qdEeaf+/28CAD+MvAJkRtbqwBNL5LLAuhIQLaU3Msj7nhKsfAFA8lhc1A48/u5iSuKf6kdEiAglph5AychaiAOAUhExEGqtTDnY4QqyOeSNQf8f29ZrvHAuWSbBJ5vYw2agt0eFpUyaykqpdF+bYuPbsjPQHHqk5lIcwF+xHijyDwJjTEtxflXKp8wdwVrSbqqzg== 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=MaH5rN5sWId5OwaQsed7wER9u7G9/CZdNqWaDCZQQJA=; b=Ivq7cg5GOnTEragpMROq4AWEenMnwmkHGfJCJy0TN7TJjhMwnVRHwnaYY/HxHYDIxVqD/KwRJA9k7noQeChfm0bnLRp5Lj1kieACUURZykpTVQX3EIcxvhidJJwSr740n6s+n01ISO8JrYXmxhzIjS8NnrBlXpzNAcTNehIwR5vdwvanYbi22X426uvs1EbUtqkRz981UjriM1utXVz6Ijyi6zEWG5mP1/VjsnQta7Jwb+8sHmowU6pqCQtkIL0eAkXBn4arGSq5Cd2STL73hoappks6NIKbvZkvrwgn28HOf2sF9xoNf8V5v1K8KCpb3kcLSKQTXD0LN+QCTxFGeQ== 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=MaH5rN5sWId5OwaQsed7wER9u7G9/CZdNqWaDCZQQJA=; b=Vt6LB/7YXfdU4Esw0lUJy7dNRKzU+oqjIYjuxZCmLaiZZplF1XQnud+WVXdDLgA1fbv4tqQnllT3jpqGZC73YIIy5x+k4DXxBJ9wBC8WWS7zlvrNZ0Os7rKX8ImA/EqnqZhxedD/hKGJC5et17CtDUsxAHcZIV3JoT74nLYLmCvwvq1bNNodjjkZO7l/EpZhwe5Xs9ovq4Xc0czeQZfOStxBUFQtqqJkjkuexIglT668SHenE69kqKywthNfco6Fz0PmXy3l4Q+LDOfg6rmg+ge9L8Dk4lJkHTHe4J8nAtcbwYkWDfqNaXd7EWhd0GVScSejx2O8Npu+wGKJW0F7LQ== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by GV2PR03MB8876.eurprd03.prod.outlook.com (2603:10a6:150:c0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.23; Fri, 27 Oct 2023 06:28:09 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40%3]) with mapi id 15.20.6933.022; Fri, 27 Oct 2023 06:28:09 +0000 From: Oleksii Moisieiev To: "sudeep.holla@arm.com" CC: 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: [RFC v5 1/5] firmware: arm_scmi: Add optional flags to extended names helper Thread-Topic: [RFC v5 1/5] firmware: arm_scmi: Add optional flags to extended names helper Thread-Index: AQHaCJ7AzVEsErsWcEuaiaf9wSr68Q== Date: Fri, 27 Oct 2023 06:28:09 +0000 Message-ID: <318eb79c7e1ddb1f964a901e778a0475bf18c85b.1698353854.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_|GV2PR03MB8876:EE_ x-ms-office365-filtering-correlation-id: a6ed3b69-e123-4019-de96-08dbd6b5e350 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pyWZU/njM6rH2NQUOUqUShlnr45DnPz2r/GgyLKMbRjFCmmC5m+bLPgbndfKBl/HyrULPsuc4P8gNnzGo2MtvpeEooaU09o3CrvgT2C3H+TcbmWCD5Fx8p8qmiodsIHjcQOMyBcqN/VX4vgcdyoH4q+Z/DLakH9O68przhzzIMGPWP0cFoQHyLetuZ0bah/qD3uh/VuAOituGul8he7zVgjldpZWvoXQNLPwnssb1eJxDt5a2ExYsFnSF3vwNH4BlwKXzOIHADFfLfA9g0jvsjWb36el53sNHCS/PkDuVYQYsKu3wzJpNkOiynuhMK3f2ACU1LKdM/9m1F0CdEGCXEawcXhgskixZ/Mcv7eYi+M90SA9ufwzge8dYCk/W3eOUAsQFwW/C92+t+D8MwgrMha22acVW9bciueVSoSKjoZ4kBu3QomCckvIsl3+khfSj1L+aeXSWzG5PxGwU0AoowhX8Ygoevn6+p4Lv4RcZax/CO9dUyUxBcujZ0UyYg/TvcCRHXh5Roog4ICetLD5tOjalLP3gVmQwZ8beWZa+kmJPznnnFYG/z2X5n7Jd7G+DRLv9zlb4s2lCAEARCCouIlDbJzMrDIXdXBuV+WE701thljMVy+3wCN0SHYX3r4g 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:(13230031)(39860400002)(136003)(376002)(396003)(346002)(366004)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(2906002)(478600001)(6486002)(83380400001)(36756003)(86362001)(8936002)(7416002)(4326008)(8676002)(26005)(5660300002)(38070700009)(41300700001)(2616005)(66476007)(66556008)(66446008)(64756008)(66946007)(54906003)(91956017)(6916009)(316002)(76116006)(38100700002)(6512007)(122000001)(71200400001)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?X6i5UJAHpSRWtppo5y3kKL+?= =?iso-8859-1?q?0E8jRAWmW03VDPBWNaGr1rekS1BEzbcczus97YNdP9SaklsqaJTk0/7zlL4h?= =?iso-8859-1?q?82GRuDNdFfLl8nLmKVJhiMRwQ7cgT5Yqsw12nMvItFWn0VOcxKULNLrONV/u?= =?iso-8859-1?q?mJm78vaUF4Wh3HMNtFp876mDZPRB8sJ63i1+C0DCkxGfvjX3czV1nvvJkXhR?= =?iso-8859-1?q?SRNa6y020qZcT7gD8SrhBcsNl4g0aJod128rFmCjO+lLLNjvb78u1dbNKTWq?= =?iso-8859-1?q?gmXTwfSxV1HoCRtz0EPCrBYWA9x9Rpe8a2YiqznZnMgPtWgqKJA44+0dCtrM?= =?iso-8859-1?q?k8Ncf1zJ0/OD3sPPbDfg5YihYIsLyuXL8gFErk0Kq2nM87TLX+oKlrN/ZQTa?= =?iso-8859-1?q?GWI+DFVac2ecE+PbuKNjmNF/eu/RB7iwuLLb2Nh2oxwhUwTJn1NzUAt4ecVV?= =?iso-8859-1?q?3Ef9RbkMR8HZR4UXg2vFwfvP9LaM+w13P9GxmUXuAYgWfoTx8NYb17ues09G?= =?iso-8859-1?q?YL5MCJH/WfT5H2unNs36eLQ+IotlEygvBPJWwa47vwg6mDu9SqVin7RgsUEH?= =?iso-8859-1?q?BZN2r/vZ/co7N1T8sAmMOkFHOH4zL1nDW+44qKvRUj2jq0foII+cZ6P1CJSn?= =?iso-8859-1?q?oQFXXr5y6wO4wuss6qqHFpEltgJly9q21uaPaz1h2mrAJXp4UlvP8irQsptd?= =?iso-8859-1?q?gvCazyB/m5G+XX2EI0kdA0bFyCu568K8bKe0g3W3O9yEG783xsdBETNEZFTp?= =?iso-8859-1?q?4iJoaeRbKcmnAFlQC2EJP+ToqD3/e8a77UGhp5jo4yNZKrrAFH6NNUP9kKTs?= =?iso-8859-1?q?NpVby/aTLNIiZJvlgTL3P0Gysav7v3Grlt1YjhKCQvHCs2xrOmfDgww3Xff8?= =?iso-8859-1?q?L1m+Y/fuSC2ZcPtBbvLM26Togzl3nIhk9zXWHrMz6qXhZpuu5ar1N1sCW44C?= =?iso-8859-1?q?m2zQhWQ9tIv876RUf2WytpGDCXhZi0CdBGxVp0KwzzbiOefhPBbdlTYMOKwh?= =?iso-8859-1?q?O8ZWK1RGTCw7dlmKCWFaXkHF16a2BWNui/GzthAWY1Lx5KWh9fCNKfIKWLts?= =?iso-8859-1?q?CvDDeXTA5eEe7YF96sj+1K28FkyvJ0+Y6Q/wJWuRkerXwvryIcKXE6CIlTrP?= =?iso-8859-1?q?aqOm5AeGlwgHVPB2IU6nBul0KXrgwPhn1AVrv6sUrpUtEwbrm20dJldZyyUv?= =?iso-8859-1?q?oVBGYjPYe+JTrqpgfvnY2eaf4q0+3OQPUiLf+5hfE/2ki/vVgj8x5c7MRBNz?= =?iso-8859-1?q?rvj41fOwr6mD8cqhFVyHU7IuXxGXp2q/6SSrVylA+pNq6tyvaGW3MHZjvBNv?= =?iso-8859-1?q?nex3skFGBpI15Kc0on8MxYlaCCG4/Us9TRVtxE82mBX8vIj8S+ZGVKnr6ZnU?= =?iso-8859-1?q?iFyrox0Cpzsn0lo2Sb4WAR7TpBh7dSZgRSXpCopcfh7BWkr7ZNJzgExTXdLU?= =?iso-8859-1?q?Rw3FtfN1TMsAHWu0AgqP00TQ4EwqcC9A4bwDK8KKJVPNBvOqjgfMNGnpll0A?= =?iso-8859-1?q?RlShsJH3DD0yTLZ3wrN/38G3WlIcQoP/Jm3Jy66/dea2aHrPq2PMXLTt6qEv?= =?iso-8859-1?q?/2mcc1sXQSFTJNyrsAzSm4Cnd52nDVS7gr72QXracYcIDbwSHRdVG4hCU50m?= =?iso-8859-1?q?hnJIKeWU55AZq8aep9/rtpFmPGG0bD0cL2GVpGw=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: a6ed3b69-e123-4019-de96-08dbd6b5e350 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2023 06:28:09.3773 (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: yNeXCKdn2RJca+JxkjnGyo6EL7aJgM1STkEXE+b4F6dgp30Wze//NHDWONBJYggp0G+52XAyjq1acLrfaKXsNcXN4iFsdDx+2r+LOuuDe1E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR03MB8876 X-Proofpoint-ORIG-GUID: mph7srOMVquastlWr0Hbj4y-eFyNGCiV X-Proofpoint-GUID: mph7srOMVquastlWr0Hbj4y-eFyNGCiV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-27_03,2023-10-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1011 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 spamscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310270057 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_232838_742310_D8273FDA X-CRM114-Status: GOOD ( 16.43 ) 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 From: Cristian Marussi 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 | 7 +++++-- 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, 16 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..729201d8f935 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,8 @@ 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, 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 Fri Oct 27 06:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13438133 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 57BA6C25B6E for ; Fri, 27 Oct 2023 06:29:04 +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=L07qK2EgtlOKIkK9qWThgzsZLu0lrq2iNZ9O1Q5uSOc=; b=D0BBFeSvygSTdF AavK4eEPMLMfNom7b+vecVY4OAGUvjbKdf2CuDKXzODDaK3M6bfMkq4h4o80zhoryzEutXkfXbMf1 m0o54TX3SG5JWYaZ7pJQZFqwidnQOZHPZCFGfQwQofT0ohbdKsgB69C/2UNDUYI1pGXAYkFbns2+L qn2Xa5ND5uZxPHfODebGfaf/wWX3wrbG9ACMeQ6Wk5729+gpVx2g9bGqcGmUCaP4wASPaiGQMXAjA DG5mN5UZVUP+uql8qrVQ+VteLQF2ImhImHsN/X2Ew3M7pVjE2ICCicd6Z+9JNNmEp4hncnsygdG+C 1aRjb+vUjElT9R2q8Efg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qwGKn-00FgXu-37; Fri, 27 Oct 2023 06:28:41 +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 1qwGKe-00FgU6-0D for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2023 06:28:33 +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 39QImrEI030740; Fri, 27 Oct 2023 06:28:18 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3tywqjs3s5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2023 06:28:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LeMsslROfxilkcuLh+fg0XB2rPoc2qAnnHjcwYBPOxVC24Izxk+HAwfw86D2aUgWp6879ucq/hdgk6WMD3URoBuUdvQBzxpQ5xQHPPijjc/V2PyBJ3WUHvQqh0agm8NIlDBaqHlowyBN9WMGoqQPD7c+eDxxLeChRqgeums2TR19NG7yUVFpSomFxAsgWB1sA6f/kqyv1YTV4oul6H9VaD6kXzWxIG/+3zT75jUJWxEMQizbMiSiE6kM37emc9bvjyFMP71JSQ2wHJ8i7jBoYoQfg54bfVbsRokjwmwSGeSVl2dxpjorfAhbZavgEtxySAGcESlRj4MDQSNjrCFBUw== 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=OX/pUmFRfFtpnXc18StYNQ5BMGvgO5nozsyBZdbaWVk=; b=S0YOl4VWmWLZ/dzijm+gUHss7I+jp/CSmYu+7vr8SPS3k/Ynzx2depZcPH51aiBZ13Y2FmfCfGRz6SRNrnBee38WnJl4BlU/nKyFHeRLSesQ5JS1TkA2BKpVKOlHqeIIfeenAQVpd7fmwyij//qrBMa8Ys9CsQVhg3tNdT4S9VcxkZjkNT0IDrEsguNPAdV8IsO/r3GPp5N4g9uydNjqWDVFl7YZuFvQw4+PCv3iDpdyPD/jo98u7GQLZgoZfV/hkTX5THhMOYw9WHvkMuBvO/maOsZGo1lPkMCRqojMAQwWh1gaKCURWKdJOuvsOMpciUGaSqGigtfKUi0iRvdm0g== 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=OX/pUmFRfFtpnXc18StYNQ5BMGvgO5nozsyBZdbaWVk=; b=C9aiADKoblbKCy4RTeL96A05VOIywlFUklXjvx04FpdyQiTwpzD6dbW6zuuwgUChAOwEkFnlLR1oatc/7HpOR9lh/eCyJZ6YDqqjjQK6TNxd1caQXZD1NUl3cCrd+DH+IWPCPmmB8kT/34ng0ZX1RUcNsxrzULBIpSwH33ibDNdRtv/+qjQzmztoSsj24HROau8ivKlB81WC3JZQue8UPKOPFi7vG/BxQB4DIDKCxe7QppAXLAlhoJX9J+VbFBt5xqeAyXrYZ1hxAyk+Vr1e2ZS1n+tEFeMS4evUD8s5zKCBHmK4tJtcBoZUnXt5K85zA8vFj2yyi4yh+EISP0qBZg== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by GV2PR03MB8876.eurprd03.prod.outlook.com (2603:10a6:150:c0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.23; Fri, 27 Oct 2023 06:28:10 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40%3]) with mapi id 15.20.6933.022; Fri, 27 Oct 2023 06:28:10 +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: [RFC v5 2/5] drivers: firmware: scmi: Introduce scmi_get_max_msg_size function Thread-Topic: [RFC v5 2/5] drivers: firmware: scmi: Introduce scmi_get_max_msg_size function Thread-Index: AQHaCJ7BGAyc1OF/JE+gASJoTLvwfw== Date: Fri, 27 Oct 2023 06:28:09 +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_|GV2PR03MB8876:EE_ x-ms-office365-filtering-correlation-id: 48077160-9de9-44f2-2ca2-08dbd6b5e3bc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xWMJJYxPxTE+4QRYSzLpobI0h/toDlIlt4gGqMEalYNxrzl/Vapwch710BHZJX/ktFUitXli8hSBJZPKl7ahzMnQxkbkWZDYbBa1743QuJ0AofohAAEAWvWTkg8AwSlyzBJBX+tdG9Ix17XTjGbCynARvgpUz/A+Ncn8+8vo+r5gmPViLNIoUCMm6DzIthHUCyv1RWEa4nD2ecS0MfCip0CCJVhrqL/8Mx+QkT61njINaJcBIDCUi1FEeTWC/0y9NXAnaC8lrfXSPwzGYSCbItlnSqb4K40wEn21W+80mLgnRJ9T/u0bcFcYCmgSYs8fQEThI1GtiPl72Y4nzsHuaY6rBzeaopx96cMZHDPhhsCAiuvM/3Zx/izDmXg+AZpfrOYgik2kMtLmfO5WC04znS3b91NGyzWeFYF2rN6VZ7RnOxboDEt30QBT3HUDquzW8GYdep3HFA1c/VzDbhxKRlHPBbh5K+FBb+rOz8cFP4LTCplAz6z4P5YVg4Wnq13EXWv1TCRAuyNf+YdWGG0wWOuxO/zfCM1KJyYLWUj0HiPc2lBXUZn1e0l18o65gG971IRByO1+Iei3UbHymzIYOs5eDrOd3F12ADhpdNbRH8Rd9NEhmNq6/ZI46YNg5Tcc 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:(13230031)(39860400002)(136003)(376002)(396003)(346002)(366004)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(2906002)(478600001)(6486002)(83380400001)(36756003)(86362001)(8936002)(7416002)(4326008)(8676002)(26005)(5660300002)(38070700009)(41300700001)(2616005)(66476007)(66556008)(66446008)(64756008)(66946007)(54906003)(91956017)(6916009)(316002)(76116006)(38100700002)(6512007)(122000001)(71200400001)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?fmTm4Qr63sIyXY/CkOPkfYp?= =?iso-8859-1?q?Wj6zXZGiZI5OYxKFJDzpZcbrQh15MZP0Btc6bFY1pqkn0LLuzDOOLpCB4KIq?= =?iso-8859-1?q?HaFEO0f6Ado5VZ3v122lXMPEMHV30MzcQmIMwfoqOR9Bu7hSoJm63dXIVt8k?= =?iso-8859-1?q?eSEPDX2qCtfyV0X1ttlKYy/hz/C/JivkgcUuwQByisNS/xkA9KhBQHvr7MgT?= =?iso-8859-1?q?59B/ybvg+SlkIv9XzkT9ohLzcvKh+FZlOiv63bzro6WMAYCZXR1SbfxZomy2?= =?iso-8859-1?q?PUTza8JN2ADX4nASR+i7FvUXJy1Uo+PfGg8pgOiJs3Mg4vJKEW7d4mc5sZ3d?= =?iso-8859-1?q?EBlSx6f5IesrIAN26bwZqCSN/wLv4LahD15JzKUlccEKAen9ZoQ1fJryPo/Y?= =?iso-8859-1?q?VHqWOR3E2lYISz/7d6+BdQV6nG2EaGwv2q7xBFhNeYLR8y2Ji8B9Fs6DGDR5?= =?iso-8859-1?q?CasRN7iCUHO70yT1jJtsF44kIiAR1M/3/+kqwBvII1RAaDKE98GtPdDaDY/Y?= =?iso-8859-1?q?Ut9eL40xxk02aXktLDsaX4ViMCBVL8IHygR9LyOro69pMER77cZ6dkLMksZp?= =?iso-8859-1?q?+3KsAuQWnL22Z+Y4f8c1k4KP46w0I/PLg6CiWHLM47I3urXQmI/5K+CWVlO/?= =?iso-8859-1?q?d1QDXSJY1ld9KDqGCP94orI6JHG/VUI85FNu3r8OLUN7sK0xNm+eBbVKAyI2?= =?iso-8859-1?q?xxko1jB4yUQzMVhNJKkzu0nCWe5fM7wBj+zI8o0ULHzEoa95/c9Vv1Ta8890?= =?iso-8859-1?q?HCt5j0llVSsxp6HXZg/mrEhku+SEVIjaCAmgMd5oomxp3jwDRI/qtj9XNwqt?= =?iso-8859-1?q?Bl4RPnOpxSEmUMW8pK/w60doL4CaoRSxW6pHGzPsd4G+sPov8PZZtduMoE2D?= =?iso-8859-1?q?dd08wgIKxcaQ/z0tX3/lK+vqArnvaZIJLlNngMBEhnEWKnYd3vOsQiEeDtiI?= =?iso-8859-1?q?FIk6WZqbpvMJvYVnUf+08EYBFjTXQGLIR8QzL6rjRZY4fzZU4qrEV6q0B7M4?= =?iso-8859-1?q?qKHVlB4GWPkJxtdrbepvXgq956HZrYk+HjieIc2s4jNbFWdPW+ZSrqmGXcZl?= =?iso-8859-1?q?n5X1wbfKJBs/7xHbD/tXHwzuWPVobs81SIBTX83dcKTH7H9ciFm28G5bNpwf?= =?iso-8859-1?q?8rBzvhBHThYXf9tsMbZSGz8szRg5X3/+h+dLo2EFBTCaXzAYhjen8zIn+rCC?= =?iso-8859-1?q?oFdIDjDnQk+7Q6d48NdESlq1wDJf0D14Q4UMrs0vQHpjJ1Fzw8ca9l6ajjSa?= =?iso-8859-1?q?FK6WRj1FYCdHSWa+HJie0N88o2xCigg4U2t9Uyrw8uoDTcWSiLaSpepmY+TV?= =?iso-8859-1?q?iKdB+Eej6M9qiu/7F06rWm71jek3P964+w0Hwzxy0gneCwKHHuWGU8RqT1TZ?= =?iso-8859-1?q?GqiaBI8Q/fT5XFdaL7spyjbdkinAYEdfX7T3fBAUQxKwRUxOnJkxCsUh8px2?= =?iso-8859-1?q?+5uh8MJuLAJxLnWsifHhawDw3Wvwp6tDlVzmJEzcZl2kYQxwSsbvu7vDNfhI?= =?iso-8859-1?q?gOHw72lfrH0sW1ktFpndg3g+A5vyLM1pa+6Tron7/cxc+hnDHpqFnQCmdSdN?= =?iso-8859-1?q?n6mAcSGNooodsEjIKIhtrHT2pz6gwd1rr/hHeTo5olu+//ih2knoORd7Jusa?= =?iso-8859-1?q?8bAFl4vPVYrnchW4dBB5x8ZCTdmMp7bN19aoB3w=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: 48077160-9de9-44f2-2ca2-08dbd6b5e3bc X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2023 06:28:10.0980 (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: /UTKFYD92fNyNNuzxlSeyDG8ZZSdTn7KUebG7TonqS6SeG+KsfGTiCuoCcOlI1p2aMSImEEVA65QSG3l3qhj+evcCTxkMwNuOFXiNKs6DB0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR03MB8876 X-Proofpoint-GUID: Ia-1mDgvCKRQgMxCz0pythj_chJ1wzbr X-Proofpoint-ORIG-GUID: Ia-1mDgvCKRQgMxCz0pythj_chJ1wzbr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-27_03,2023-10-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 phishscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310270057 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_232832_106517_0A288DFE X-CRM114-Status: GOOD ( 13.80 ) 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 Current SCMI implementation supports only receiving arrays from the SCMI server and provides helpers to process received data. It uses msg_max_size value to determine maximum message size that can be transmitted via selected protocol. When sending arrays to SCMI server this value should be checked by the Client driver to prevent overflowing protocol buffers. That's why scmi_get_max_msg_size call was introduced. Signed-off-by: Oleksii Moisieiev --- drivers/firmware/arm_scmi/common.h | 3 +++ drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index c46dc5215af7..3db97f59bc59 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -286,6 +286,9 @@ int scmi_xfer_raw_inflight_register(const struct scmi_handle *handle, int scmi_xfer_raw_wait_for_message_response(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer, unsigned int timeout_ms); + +int scmi_get_max_msg_size(const struct scmi_protocol_handle *ph); + #ifdef CONFIG_ARM_SCMI_TRANSPORT_MAILBOX extern const struct scmi_desc scmi_mailbox_desc; #endif diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 729201d8f935..f15e9b2b21f3 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1152,6 +1152,22 @@ int scmi_xfer_raw_wait_for_message_response(struct scmi_chan_info *cinfo, return ret; } +/** + * scmi_get_max_msg_size - An helper to get currently configured + * maximum message size. + * + * @ph: SCMI protocol handle + * + * Return: Maximum message size for the current protocol. + */ +int scmi_get_max_msg_size(const struct scmi_protocol_handle *ph) +{ + const struct scmi_protocol_instance *pi = ph_to_pi(ph); + struct scmi_info *info = handle_to_scmi_info(pi->handle); + + return info->desc->max_msg_size; +} + /** * do_xfer() - Do one transfer * From patchwork Fri Oct 27 06:28:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13438136 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 A7981C25B6E for ; Fri, 27 Oct 2023 06:29:15 +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=sSH09ZXiipANAxg3itOAW2AiQj4v4NPi+Kj8hY+LXJY=; b=pKvMzLFQSOhfpt rdueASiFeVbsfKniJf11cJucJnIXIEYuA2UFmbxButYkwzCbbmkZNnFc6/O4H9ZoNpLqbLzkwsvTv uvSmfA+6iyW8KQrnwEGiyf6XCawNc6VwTmLw364LqEra/jKT/HleWPdalGSPJPDSeKVpLb82wbLWV fmNNvdgufLF70SgxlYttIZO38WulHSyU7KWeI9zhh/eCJWTt873IPUJhdlSWQ1wNEUXBv+RecYUJi 3JaSYZSyeBeXZ6lJrtH3/g8MuyksoMwyEG+HprBFV12tRygp5Y69zE1KOrHJVt2kHNOFyiA/6749c vlIcOj7eCMmqnnU6evdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qwGKo-00FgYG-1t; Fri, 27 Oct 2023 06:28:42 +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 1qwGKc-00FgU5-2S for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2023 06:28:34 +0000 Received: from pps.filterd (m0174681.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39QL6OQT007652; Fri, 27 Oct 2023 06:28:18 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3tywqm92ds-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2023 06:28:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XPk6tD0JuYSTyzzwnF7lT9yxbSYWaOXRus/c4s5dQTnMrXUkRUhysGBfRaMla86FbZafuQc5ASAXXsOFg1vvmMRnT2UvQFW9lOP4b7iClLouwiSqIrLPYUNna3408C/1gtCMnKdThES6P+JJaC1bJNWHeGPUZqNtBQ43JiJ7vt5unQF2q/A3oeNwCo0qTtzA/TcUlmBy+m1IG6e5X47G+QsuN3xGRlC+qqDroe/ZVbf0h2adti/68LhR9HThr3MJOpjNVmMUtttKXZwQTcOVIazTHFlnjlu2P6CNetzUd6F36ysLaWVrEsgTSh8BGKma2op1KBOQCF8cH3qAZzo18w== 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=NiJhqbJDGb5nQk51MEC4+J959pM4bvnOjwcGaqiFbII=; b=Qw7qnbdkrbisYji/o2ixQaXlf5UhpwGWNUYlWPC/RkmkcFtD9UmaQT+OJOqRgH0GVsfpSAYzlpRSxeCKc/+ZVZp9weCiXvWc7nLOwAIyGDwCvBtPIeuNaMstN4XSfPMUnsMB2gxBBSAHbaMP/ym2HJEiyulavqYrhGGyQhPik2JTXsGfsrO/ots1SLf7VthsEa+oX/1NpADJRBPzFkIMjb2jsLv7nAHv+iZwH5hfYQDB4/lsCCPtSCkFKhXekgOrWHlWA4EodFX9tskVnZ9PnOH29DXZP1NWYqzp57wGDEN7dA/57TOB1XKG7+e4qOaEHbV4YZoA4fZMV2lfqTWrYA== 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=NiJhqbJDGb5nQk51MEC4+J959pM4bvnOjwcGaqiFbII=; b=roA+LWqxK6NCgzaBhnIFe4exr7GinjON7ZaAPolgsZARqrHgUOIpVunI4tAbZl93OD+h8Ups89KlmwGyVkeY1tHECYpsscrJOqd1Sp9T4EuCsoiDmjPM3ctjY39NVIYIBucswdgybIxuNFEEaPhXmXGV2jMEnLyibsOAJ7fvqEEBz8IdmwKkk5OjC0yQCW/B4rK8m7LV53L15mQEbSPprxE/WOeqttf/4DJNgUfVoShrMOWwisxaI+ga2gbGVNgE6JTmgSA0TcYN0dUOUSGJJG98px3XPt7SzlH6luL7yVCtSc+OkmiLWj3JF8xLQQf20E3Fc8NtFHwnR6LSJ4jR8Q== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by GV2PR03MB8876.eurprd03.prod.outlook.com (2603:10a6:150:c0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.23; Fri, 27 Oct 2023 06:28:10 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40%3]) with mapi id 15.20.6933.022; Fri, 27 Oct 2023 06:28:10 +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: [RFC v5 3/5] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Thread-Topic: [RFC v5 3/5] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Thread-Index: AQHaCJ7BHuNsuhxPVE26Nd9OsaeoYw== Date: Fri, 27 Oct 2023 06:28:10 +0000 Message-ID: <7300b8804396075d2ae565f46de51a980ce846e6.1698353854.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_|GV2PR03MB8876:EE_ x-ms-office365-filtering-correlation-id: 3443c274-c8c9-408f-3cbe-08dbd6b5e42c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LSKWE6Od/PCXC2NHcsB3Cq4pueSyqojBjpekLJKOavYVJtSe8zlRY70BXMh5nIij+KQs7CsfzsCvssE5bzSJemFOOOByVtvBtYAQvojj8L34bswonLotndOmtK/Zc5fjCrsya0U+9AXTPyRGwB9Gl60tZLPPaWXQGT29L8JdW9lUTm07O46skavMLK9uQ+4l3ha/yJsgMqq0YQz2A2Q0MVWBQFlS7xNPlQ/sHCaL3TW7tXki+flr63y70LMo/DPLUqtK7Fu+0xuOhS/T5WviS9pOArwu3GlFS2/iR0INaIjVhz4Wrvo97e6ECtRBBZfb7oGUjcMfPP5+FW8oNs6TNqIU1UF6Ky+5UKhyW6nYnBXNMFsXyZtw+Bk7uRqjR9Ow0g7oI7QNqrIpEHYZ//3Kpy8cINzg/51h6eai8TWKH3NUj/WfVfQoi2DGm3bO7VW7zH+43mhhozWkUu5YQ5mDEdKiy9gZATsjrHrJBEEaM2BcJlAIWcFA09tPxjfmE8RMt9ZmFjdpePZxm3UY/t588WbTGzT16aDpfn7E89uAMdGwA4VwwoHKtF0aagzK07tyKDDhuhW1P7AyRXTHU/9EwXM4SpZFsG+BX8oOkE8z2TUyvxbsnyj4e8oMO4ZMF+wS 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:(13230031)(39860400002)(136003)(376002)(396003)(346002)(366004)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(2906002)(478600001)(6486002)(83380400001)(36756003)(86362001)(8936002)(7416002)(4326008)(30864003)(8676002)(26005)(5660300002)(38070700009)(41300700001)(2616005)(66476007)(66556008)(66446008)(64756008)(66946007)(54906003)(91956017)(6916009)(316002)(76116006)(38100700002)(6512007)(122000001)(71200400001)(6506007)(559001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?HiAcH20lHWYph71Dn1RWveB?= =?iso-8859-1?q?djE3Urv3oE6WvUwbUJej5A86+CcsP6Jss/ZczuquO+INZQB3PQPaFQny2kNY?= =?iso-8859-1?q?y9BwAAt4kQqrNqN3UQ9neNS8sF8MsYuv2sr67b6VNlC+6Kt87k9snqv83KZ9?= =?iso-8859-1?q?fqoN3jYQLyHcsmCz7YlRpMhittoimMZhT1Y/gG7KxgwqqCKZki0cNlHhgBW+?= =?iso-8859-1?q?zBHjVjWQQEGduz0SbZ865NPxDWbjmSYMZ7bDjY4qV594ZUVmuAKCDDc0hkHv?= =?iso-8859-1?q?fQske7c6xYhIcSVsMRjWQccOYdMuAh4Qj/+kx72MkaLirgvaApoiMk3fWcgE?= =?iso-8859-1?q?mPiVhrsFZMf2eOIm5MlhjoJONNUDFpDlfgestNKltaOWl9utyu3gZzCDA4LD?= =?iso-8859-1?q?O18PC7z2Z7FnK5j77C9IUAdMKWpd0f2dvAqvN7jLsbj7qdm2wpK1yvJHuFgE?= =?iso-8859-1?q?Eu/fJ/tNWLwLvSI1fvnqESAu3y3iThnyd8Cth18Dal4fEaSWr6oaKFRpU53F?= =?iso-8859-1?q?vMHg6S3DZKN5q+Gx0YFS+f0fPrD1qSwQ80/ZnbOm3WW+2nSk/TU8RuW7jez1?= =?iso-8859-1?q?5cKpQsNWWsDkOPFGuNlZq3kH3MOo5TPV0F+PWZJavEbwoqoasu3ITFRFz31R?= =?iso-8859-1?q?5yI8oamRR3jWcglp0gfr7NlEQivp3AvRDdEdyVUR4FuPnaIb2sMozK59zhKO?= =?iso-8859-1?q?VFtOfbTygXrAxOfk3l28i44Ey9COpzrKKlXrEk8F132PSeYiEYpQLImkXII5?= =?iso-8859-1?q?WWxMC668IWBMpgbHG6cvapCTGSTsQrrWZkq79EORNgaO1ieerf/B/4waPp6j?= =?iso-8859-1?q?/TohVWNrJIoZ9x/B/rtup+0FQIV0GhSqlt9v/tV/cmCzBpOnAHO2MROhY9cK?= =?iso-8859-1?q?aPmjfaCF1PZZsI0Ogdd1K3nuBMt2wAO1ZyfTcuI7q43DAXMT6O+6hseJciS5?= =?iso-8859-1?q?lRWLrYimd6WbH24vMHrPEE6e1qnuSqjUDS87G779PXus04KHc8k4MKfBAKta?= =?iso-8859-1?q?YJjOH55eswSp+RXsS6FYyWLvhWPD1U5+Pyvi0AD+13oCl1v6jhvYGs/4i/3t?= =?iso-8859-1?q?LDRNUIW7OIkf2oDCtE5KGJJKp63/Uhu7CopzxcSE7tvlnCmrOMRPYt58Cj8K?= =?iso-8859-1?q?VUk5L4qNVlsOax/ibcmBK8VQcFEzzZ+t9DbYNYkVSIz3Ig5IUXhOwpQnnJ2q?= =?iso-8859-1?q?q/TZg5so8aLVbR5u6g0ZZZCoA16b46Yd4cRxPtL8EZdghJaI6C/3vlTl7vb9?= =?iso-8859-1?q?3mU7XuUeLxPUaM4FeOJrb89zxzOnuZdO899iqiO2O8BY9mn2HbM+pjWrZpQ3?= =?iso-8859-1?q?JKTz5eW+Gcv3xqClxPrwsFE83DXUTNRK5Kkx/EblpwPcvA7uytlDrzpfkI74?= =?iso-8859-1?q?MVEgAJw0XfythKFxTYkNN4ilZoWk/EziQcefS3JNtDGIlASYtF//ZkAVqNh2?= =?iso-8859-1?q?17GDTd634pgfhfAQxwMDZfPGEAV5xXzkjuuyKLJBggUq3JIXS143rX1T9iiZ?= =?iso-8859-1?q?Jx5wk4nwicOu+9LmvpinMJ4iUxmp9AKRUW3RQnPllm+VBEdbsEVflftcuDsP?= =?iso-8859-1?q?9QnOoJdS8nnMGsIip855aMmXghyU3pL0sYGR25an5Yjj86FCAmJvufheYb3a?= =?iso-8859-1?q?M/JOGJFFRwdqaMdrMZV6X4+4zoOh0NC6QH2svwA=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: 3443c274-c8c9-408f-3cbe-08dbd6b5e42c X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2023 06:28:10.8481 (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: WuhZRD4/s4TCmqEBCgMXp3ZSyB4PN+fwp3ox6m9cJUbTJvaqIovx86fpGeZOyxpIM8fshjGpcWEgi7vRY7uW1FiIkqmqXv3nDNMg3/rYwvM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR03MB8876 X-Proofpoint-ORIG-GUID: kpNVAHKMbdirEcqjvrVdS02FZJUlmP5g X-Proofpoint-GUID: kpNVAHKMbdirEcqjvrVdS02FZJUlmP5g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-27_03,2023-10-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 spamscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310270057 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_232830_924103_5D713907 X-CRM114-Status: GOOD ( 19.58 ) 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 basic implementation of the SCMI v3.2 pincontrol protocol. Signed-off-by: Oleksii Moisieiev --- Changes v4 -> v5 - add new calls to scmi_protocol description for config_{get,set} Changes v3 -> v4 - Fixed MAINTAINERS file description - adjusted pinctrl ops position and callback names - add trailing coma in scmi_protocol list - removed unneeded pi checks - corrected selector check - resource allocation refactoring - scmi_*_info swap params to generate better code - style, add trailing coma in definitions --- MAINTAINERS | 6 + drivers/firmware/arm_scmi/Makefile | 2 +- drivers/firmware/arm_scmi/driver.c | 2 + drivers/firmware/arm_scmi/pinctrl.c | 922 ++++++++++++++++++++++++++ drivers/firmware/arm_scmi/protocols.h | 1 + include/linux/scmi_protocol.h | 47 ++ 6 files changed, 979 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/arm_scmi/pinctrl.c diff --git a/MAINTAINERS b/MAINTAINERS index 0dab9737ec16..2d81d00e5f4f 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 MANAGEMENT INTERFACE (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 f15e9b2b21f3..31a0da37eeb3 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -3040,6 +3040,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); } @@ -3057,6 +3058,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..e5cbd976b6ae --- /dev/null +++ b/drivers/firmware/arm_scmi/pinctrl.c @@ -0,0 +1,922 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System Control and Management Interface (SCMI) Pinctrl Protocol + * + * Copyright (C) 2023 EPAM + */ + +#include +#include +#include + +#include "common.h" +#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 configs[]; +}; + +struct scmi_msg_conf_get { + __le32 identifier; + __le32 attributes; +}; + +struct scmi_resp_conf_get { + __le32 num_configs; + __le32 configs[]; +}; + +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 { + char name[SCMI_MAX_STR_SIZE]; + bool present; + unsigned int *group_pins; + unsigned int nr_pins; +}; + +struct scmi_function_info { + char name[SCMI_MAX_STR_SIZE]; + bool present; + unsigned int *groups; + unsigned int nr_groups; +}; + +struct scmi_pin_info { + char name[SCMI_MAX_STR_SIZE]; + bool present; +}; + +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; + + 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_count_get(const struct scmi_protocol_handle *ph, + enum scmi_pinctrl_selector_type type) +{ + struct scmi_pinctrl_info *pi = ph->get_priv(ph); + + 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_count_get(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); +} + +struct scmi_conf_get_ipriv { + u32 selector; + enum scmi_pinctrl_selector_type type; + u8 all; + u8 *config_types; + unsigned long *config_values; +}; + +static void iter_pinctrl_conf_get_prepare_message(void *message, + unsigned int desc_index, + const void *priv) +{ + struct scmi_msg_conf_get *msg = message; + const struct scmi_conf_get_ipriv *p = priv; + u32 attributes; + + msg->identifier = cpu_to_le32(p->selector); + attributes = FIELD_PREP(BIT(18), p->all) | + FIELD_PREP(GENMASK(17, 16), p->type); + + if (p->all) + attributes |= FIELD_PREP(GENMASK(15, 8), desc_index); + else + attributes |= FIELD_PREP(GENMASK(7, 0), p->config_types[0]); + + msg->attributes = cpu_to_le32(attributes); + msg->identifier = cpu_to_le32(p->selector); +} + +static int iter_pinctrl_conf_get_update_state(struct scmi_iterator_state *st, + const void *response, void *priv) +{ + const struct scmi_resp_conf_get *r = response; + + st->num_returned = le32_get_bits(r->num_configs, GENMASK(7, 0)); + st->num_remaining = le32_get_bits(r->num_configs, GENMASK(31, 24)); + + return 0; +} + +static int iter_pinctrl_conf_get_process_response(const struct scmi_protocol_handle *ph, + const void *response, + struct scmi_iterator_state *st, void *priv) +{ + const struct scmi_resp_conf_get *r = response; + struct scmi_conf_get_ipriv *p = priv; + + if (!p->all) { + if (p->config_types[0] != + le32_get_bits(r->configs[st->loop_idx * 2], GENMASK(7, 0))) + return -EINVAL; + } else { + p->config_types[st->desc_index + st->loop_idx] = + le32_get_bits(r->configs[st->loop_idx * 2], GENMASK(7, 0)); + } + + p->config_values[st->desc_index + st->loop_idx] = + le32_to_cpu(r->configs[st->loop_idx * 2 + 1]); + + return 0; +} + +static int scmi_pinctrl_config_get(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + u8 config_type, unsigned long *config_value) +{ + int ret; + void *iter; + struct scmi_iterator_ops ops = { + .prepare_message = iter_pinctrl_conf_get_prepare_message, + .update_state = iter_pinctrl_conf_get_update_state, + .process_response = iter_pinctrl_conf_get_process_response, + }; + struct scmi_conf_get_ipriv ipriv = { + .selector = selector, + .type = type, + .all = 0, + .config_types = &config_type, + .config_values = config_value, + }; + + if (!config_value || type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, selector, type); + if (ret) + return ret; + + iter = ph->hops->iter_response_init(ph, &ops, 1, PINCTRL_CONFIG_GET, + sizeof(struct scmi_msg_conf_get), + &ipriv); + + if (IS_ERR(iter)) + return PTR_ERR(iter); + + return ph->hops->iter_response_run(iter); +} + +static int scmi_pinctrl_config_get_all(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + u16 size, u8 *config_types, + unsigned long *config_values) +{ + int ret; + void *iter; + struct scmi_iterator_ops ops = { + .prepare_message = iter_pinctrl_conf_get_prepare_message, + .update_state = iter_pinctrl_conf_get_update_state, + .process_response = iter_pinctrl_conf_get_process_response, + }; + struct scmi_conf_get_ipriv ipriv = { + .selector = selector, + .type = type, + .all = 1, + .config_types = config_types, + .config_values = config_values, + }; + + if (!config_values || !config_types || type == FUNCTION_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_CONFIG_GET, + sizeof(struct scmi_msg_conf_get), + &ipriv); + + if (IS_ERR(iter)) + return PTR_ERR(iter); + + return ph->hops->iter_response_run(iter); +} + +static int scmi_pinctrl_config_set(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, + unsigned int nr_configs, u8 *config_types, + unsigned long *config_values) +{ + struct scmi_xfer *t; + struct scmi_msg_conf_set *tx; + u32 attributes; + int ret, i; + unsigned int configs_in_chunk, conf_num = 0; + unsigned int chunk; + int max_msg_size = scmi_get_max_msg_size(ph); + + if (!config_types || !config_values || type == FUNCTION_TYPE) + return -EINVAL; + + ret = scmi_pinctrl_validate_id(ph, selector, type); + if (ret) + return ret; + + configs_in_chunk = (max_msg_size - sizeof(*tx)) / (sizeof(unsigned long) * 2); + while (conf_num < nr_configs) { + chunk = (nr_configs - conf_num > configs_in_chunk) ? configs_in_chunk : + nr_configs - conf_num; + + ret = ph->xops->xfer_get_init(ph, PINCTRL_CONFIG_SET, + sizeof(*tx) + chunk * 2 * sizeof(unsigned long), + 0, &t); + if (ret) + return ret; + + tx = t->tx.buf; + tx->identifier = cpu_to_le32(selector); + attributes = FIELD_PREP(GENMASK(1, 0), type) | + FIELD_PREP(GENMASK(9, 2), chunk); + tx->attributes = cpu_to_le32(attributes); + + for (i = 0; i < chunk; i++) { + tx->configs[i * 2] = cpu_to_le32(config_types[i]); + tx->configs[i * 2 + 1] = cpu_to_le32(config_values[i]); + } + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + if (ret) + break; + + conf_num += chunk; + } + + 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_pin_request(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_pin_free(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 = kmalloc_array(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) { + kfree(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 = ph->get_priv(ph); + + if (!name) + 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_group_pins_get(const struct scmi_protocol_handle *ph, + u32 selector, const unsigned int **pins, + unsigned int *nr_pins) +{ + struct scmi_pinctrl_info *pi = ph->get_priv(ph); + + if (!pins || !nr_pins) + 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 = kmalloc_array(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) { + kfree(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 = ph->get_priv(ph); + + if (!name) + 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_function_groups_get(const struct scmi_protocol_handle *ph, + u32 selector, + unsigned int *nr_groups, + const unsigned int **groups) +{ + struct scmi_pinctrl_info *pi = ph->get_priv(ph); + + if (!groups || !nr_groups) + 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_mux_set(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; + + if (!pin) + 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 = ph->get_priv(ph); + + if (!name) + 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_name_get(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 = { + .count_get = scmi_pinctrl_count_get, + .name_get = scmi_pinctrl_name_get, + .group_pins_get = scmi_pinctrl_group_pins_get, + .function_groups_get = scmi_pinctrl_function_groups_get, + .mux_set = scmi_pinctrl_mux_set, + .config_get = scmi_pinctrl_config_get, + .config_get_all = scmi_pinctrl_config_get_all, + .config_set = scmi_pinctrl_config_set, + .pin_request = scmi_pinctrl_pin_request, + .pin_free = scmi_pinctrl_pin_free, +}; + +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 = ph->get_priv(ph); + + for (i = 0; i < pi->nr_groups; i++) { + if (pi->groups[i].present) { + kfree(pi->groups[i].group_pins); + pi->groups[i].present = false; + } + } + + for (i = 0; i < pi->nr_functions; i++) { + if (pi->functions[i].present) { + kfree(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..a9f5398ea4cc 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -676,6 +676,52 @@ struct scmi_powercap_proto_ops { u32 *power_thresh_high); }; +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 + * + * @count_get: returns count of the registered elements in given type + * @name_get: returns name by index of given type + * @group_pins_get: returns the set of pins, assigned to the specified group + * @function_groups_get: returns the set of groups, assigned to the specified + * function + * @mux_set: set muxing function for groups of pins + * @config_get: returns configuration parameter for pin or group + * @config_set: sets the configuration parameter for pin or group + * @pin_request: aquire pin before selecting mux setting + * @pin_free: frees pin, acquired by request_pin call + */ +struct scmi_pinctrl_proto_ops { + int (*count_get)(const struct scmi_protocol_handle *ph, + enum scmi_pinctrl_selector_type type); + int (*name_get)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type, const char **name); + int (*group_pins_get)(const struct scmi_protocol_handle *ph, u32 selector, + const unsigned int **pins, unsigned int *nr_pins); + int (*function_groups_get)(const struct scmi_protocol_handle *ph, u32 selector, + unsigned int *nr_groups, const unsigned int **groups); + int (*mux_set)(const struct scmi_protocol_handle *ph, u32 selector, u32 group); + int (*config_get)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type, + u8 config_type, unsigned long *config_value); + int (*config_get_all)(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type, u16 size, + u8 *config_types, unsigned long *config_values); + int (*config_set)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type, + unsigned int nr_configs, u8 *config_type, + unsigned long *config_value); + int (*pin_request)(const struct scmi_protocol_handle *ph, u32 pin); + int (*pin_free)(const struct scmi_protocol_handle *ph, u32 pin); +}; + /** * struct scmi_notify_ops - represents notifications' operations provided by * SCMI core @@ -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 Fri Oct 27 06:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 13438134 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 4E668C25B47 for ; Fri, 27 Oct 2023 06:29:06 +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=sHrtLnHb+ECy+AU/8ma+7O9IkTA/uBsuTwlqydUembY=; b=mEI77p8Z4Xpqti /HvUa36/Kfg9QySRsSJirwcLLEFtnovMoiMiJs0aNKNP1obYQMiI6wCGp0raYMAeBUqusB0DBWLvg hULYNZzGpa67bjR/+z86Q6u/HKq/nggn08VW8aTstRa1fxVWDmpEr6zSzh4SO0MCdNjL6sKEAcQ1x Ps7nEsL3UbP8Rmqf+T80NUOiUlRlyzBSwhXW+LHth1s9Q1NRnRXKR06cVffzjv4agOJSWnn1jAr15 TbkUZABN+WKNxsB0H/h7lWN3I3TAWztM6zjGOLvWD8nvP2lUmlnBRcci6Z59IizifOyCEKFCgFyfy SSpK4qeR4YfF9/ZTygaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qwGKp-00FgYt-0a; Fri, 27 Oct 2023 06:28:43 +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 1qwGKe-00FgTz-2d for linux-arm-kernel@lists.infradead.org; Fri, 27 Oct 2023 06:28:34 +0000 Received: from pps.filterd (m0174681.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39QL6OQR007652; Fri, 27 Oct 2023 06:28:17 GMT Received: from eur04-he1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3tywqm92ds-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2023 06:28:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTZtOfn/K3Upb3PyYNhM+r/1fErsyufRwBZWpXiu1Uw12rDkVJ1VjwJzse0213UpPuvnUrS79QTUt8Bg4/vsZHwCJ/B6ztLvcQhq6v4LtFJNCM4OrPPAelWMaR64H36wkpefusO66Eito5K5D8XEu2lIh2cWCwBlxasYOJQkiObbFxNalLf41sfyMyiO/tUfUGfrlEATyghIO3pAyLROesw1tsTvXX8PT5fcPSgB6YNrFGECgeZO/JjkE8HVvbbls0OPOwckeKcktANvHnVk5EH4XaLMTPaadN3Fr2bZ0T/sCcLfkQBZt4/1RWKt0TOGUcttJjBA3T9iHFLWrehbsQ== 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=sqS/pUjPpEVLV51qYi6Phg2ZHA1nXvh5Cg65k9pOJy8=; b=UT3IV1iA9ylzq+V7AHEV8X9qfDrNvDi3sgUJ0kxUKQoK4vPqUMe9AwwuXneWl2CXJ2a/4WZUqAo5/hbzLGXp77U71+eW9NFvjFUzd3MOyiUxSoIxLcHWU1GUpiuUF3ZMBW/KtxIWcMcxbxaKl7w+GOgadPXB8dd5NNRMdg+UEUPVPKZ0gbmmnm2D94NXzU+azgFxvDN8TNGjf77j4HCkfqWBxUWeCcd1QTvF41IskJjwGapajokspRFyIhSO8oJBq/5TkMw12WWZdAQ2EZ8IbvfZ0WyzQma5flLOGRtmEW1GOzzsbrxMzcm61K4HeK2X1WMNVjwtSoh5D2Zq56uBmg== 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=sqS/pUjPpEVLV51qYi6Phg2ZHA1nXvh5Cg65k9pOJy8=; b=W3KhZCyquzzTHy/VRPnP+9MFM7HDHpBz+Z7nFQjh6jcHwWh65mzYSq2rC93A30K48Gz8wofwCjVVcg72wkJZ5dfbo00LLiPwz/s6f2HD3yJkU23iGxzjcPup8V3oWKuMOwJLZ7DPcEVHAN6Sf3juwzIoubyysEWzIIM1bxJ/HYiSxI9U1der9Dz1Q+x7qXq6/5KKy/+Qzx4aHq0P6nVEX0LvIIM9eVyV6wFpKVWXzEhZts2+rVp3BgcqqoWlHWjCvUqe+27gCyPwDL42v+hR2fLiL6H0nAxshcEv9oqbpf/FKjmfcOPDxAEVnNuycjjNmgT5oxx9qjtugbZLKir6wg== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by GV2PR03MB8876.eurprd03.prod.outlook.com (2603:10a6:150:c0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.23; Fri, 27 Oct 2023 06:28:11 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::2211:9053:228e:4e40%3]) with mapi id 15.20.6933.022; Fri, 27 Oct 2023 06:28:11 +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: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol Thread-Topic: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol Thread-Index: AQHaCJ7CNWHZc0R0IUas1KWQRTDeQw== Date: Fri, 27 Oct 2023 06:28:11 +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_|GV2PR03MB8876:EE_ x-ms-office365-filtering-correlation-id: 577086e1-406b-4be6-5fcd-08dbd6b5e490 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fzszHZeY9DfXxv03C4j84o1yiU5+1kLXRdEq8dJfnWL4p9Obfs9fB69PdJmBgck1wMEt64Wl0IETodU+ZRjG1NWo0K8wRM4Nfw0b2n3iYWVVRBl96I+oKpJVuiwQ8RxR+N7vC11A3zs2cq+OYvyQ4MYBF7sO86QI6ql9LMPVy8R67vzGgKMpP2CmeEF8kHECRSNeMTfd6nG3t9ovZKSElrHCk0kR0p+ovJUA0H+q68M8WTX/cthgxxSbNIcVN/ey2YnX2iXvY3B3ZopfaG1TcQX8jq6nlBV0fjTiaBV9kuDD79U829G1XM6NqhQtJ/lQpqAEfPduER2l2msI9kFniRPmMEI5qACRZkZO8SOIpROdOW1RMEehnrW7smutDjBvWVT5gpeRWRsFlkqy9zb8mySUtP/ECZHFNLDf7rR92gRRVAZt0PmaPar1ZbnYWuDj1JquBeZUVDvd84tXOA2to91+ZrKnUbg8fnq6Cce8SKtitB9nUsiR4qUDZCl1jKRte42ig2pXrhKYxiF2IhllubvROhNNq5X1R39dvpj20F5w0NZ64QkUSU+AQknQ5QB8BEKrnfWsnriPx+GFX5liDcmGdNw9PYmcvExvLudzngch8ezCrVLZHdxGbyvdc2FA 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:(13230031)(39860400002)(136003)(376002)(396003)(346002)(366004)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(2906002)(478600001)(6486002)(36756003)(86362001)(8936002)(7416002)(4326008)(8676002)(26005)(5660300002)(38070700009)(41300700001)(2616005)(66476007)(66556008)(66446008)(64756008)(66946007)(54906003)(91956017)(6916009)(316002)(76116006)(38100700002)(6512007)(122000001)(71200400001)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?OsK5GtJvzI9Tst3cplm2SQE?= =?iso-8859-1?q?LgmbgkjgVuDONXkOYutPvFHC8/MllV5JIFD4vPH8mYI9iFhEdUhrKAFFgKdX?= =?iso-8859-1?q?9Uk4p5Q/B32yeqfREjzosixyvv6jfEFg3gqmo2MJ1BD6nG/SvIG3HMOheCsB?= =?iso-8859-1?q?6HK5dXr3Nhkw8nG/i/HBtz4Xooas95douDMn3jfNXvn29QKN64BUjWzquI5n?= =?iso-8859-1?q?i/E7T2zEg3aHkzf0Nh9Qtsbknx/RVLTYxTHYLp6zJqJYzSO6IZhRhlgGOsLB?= =?iso-8859-1?q?YBpPwzCWLhHgvSNQTl/X2dLaLn1DbtxcAk5Oqiw2pulOFj/cUsMAt2OCanLt?= =?iso-8859-1?q?B0cldaFColN4TmWvGcLsr0X+quvgEwBYO4Ks4BQwgYR1VmnXeT7VjGV/SaqZ?= =?iso-8859-1?q?IhOICmqXjGYN0sFqDl6+pXp9OJs3YXncHbuavew1snxY4FJDmO4e4S5PC49A?= =?iso-8859-1?q?JPD3MNM+l+m+JA8O7ivJK7LF09c5Pbrn8bQ7KVEFwjxx2KEC0cpNoiZQRvMu?= =?iso-8859-1?q?vz341Vpp8yHcNBzd55OO+K0U8Tzh1GQO7npKvSj7VdwTXBF82JthaQ5x7Ar6?= =?iso-8859-1?q?QcTMtcAr4AfgUS8inEiUQe11QNH+MbcOKkKenvnl4ZsN2lmARt/zdKs/Fsmp?= =?iso-8859-1?q?hv7HannLOHJCiZD0tT2bbdD3Vg7CXZhDu9zPPJmpDlOGrgyrs731acTbP+p6?= =?iso-8859-1?q?RkNC63pfMjiu9H5JUKEXK+G1xqsQGFuPO5gcS0MLEAvj9gxIhT/GEBH6Z2sr?= =?iso-8859-1?q?IcDtQW8Zj59Tf4D5VWd6A0euSZrc5ynX6U6B55lIeGSvmLPPFKRNfkBxz03h?= =?iso-8859-1?q?1pHZXQ26u6TEtbPnQdlOJ1xdEZxYOiaPDxItpo1cJKrk5sul++SNKhFc9SLY?= =?iso-8859-1?q?OKa6ijMFiIRqYezKbpFnhjg9SFdwRe+bVFCfjT/BR0RDU0dAt4kNtn1q1J6T?= =?iso-8859-1?q?XpHLjGFub/YwCbk2Auvxaz+JarlcVqVtlCTG/bxHdnASnqIsxII0OarCrf3h?= =?iso-8859-1?q?BkHA/xyASAXtr8v9ZJQabU9F5h9QUij6lK79TfncHTxAUiwNzk1dxyTjeoUe?= =?iso-8859-1?q?rwzV8uKI1wGIDwhPVpHu05CGlYneKB961mDl1zeQM3JuEWDHQXpcPYdiistR?= =?iso-8859-1?q?RBaJ+ls9+8QPuc15yyZS7JjsmsXkjpHUzUH0QbGHJJkoJhg8W7K0Isc+GzuM?= =?iso-8859-1?q?lt09teoFxVenzifemma7hG8m8GLU+Dyj6PGDR4UjgTFXe/UHXW3/ChHSuiTF?= =?iso-8859-1?q?Buf1oWx9GVSln+UYhEtsSf2ptSn/Iqno61DFJC4+p50YeIEqtZ9Piv+sqwEa?= =?iso-8859-1?q?D0sXt/o3QTOc05lmlKDLYYYtBmOgVjcieNU4pxASqxilcq23PHfK86eOadJl?= =?iso-8859-1?q?x+ZETsDnyNbKewcakcsJn+7qP7UdjqKXySuYY0a/MiVEpnc5wod5hcabTpiL?= =?iso-8859-1?q?DiEY84hLGwArQvxskjPY4pk7zmIJiDIbMBXFPnN2qyekDywh+XPwI8iWxWls?= =?iso-8859-1?q?T1zP3xtChw0l1Bqp5kPdEg5nynNv5uo8vLvAMjc6ed6UDs5gvClziizoVU3E?= =?iso-8859-1?q?MtmKj5PMslzK/iNFTbjtY/HM1lwfLLOVZJUUi1lBkqAlRDkTn7dPGZ74lfRK?= =?iso-8859-1?q?6STvCkbQ6IiexUEgga5ktyyXnatJJ7G4xq/b7Ag=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: 577086e1-406b-4be6-5fcd-08dbd6b5e490 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Oct 2023 06:28:11.4209 (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: vAS49Q2enD6bhHMgDQqMMucAV9f1DhwFhgKls24Oa4dUUU9/lqtLPD+2otb8Tljd9lOS4uRes5CJFm6w6lBZXoPc9jtWbM3Np12zDH0kORc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR03MB8876 X-Proofpoint-ORIG-GUID: SfDDq3WxAfKPn_Qc-AP54mvIQ2SEanoS X-Proofpoint-GUID: SfDDq3WxAfKPn_Qc-AP54mvIQ2SEanoS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-27_03,2023-10-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 spamscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310270057 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_232833_014477_99E26F08 X-CRM114-Status: GOOD ( 12.02 ) 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 --- Changes v3 -> v4 - reworked protocol@19 format --- .../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..5318fe72354e 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: + type: object + allOf: + - $ref: "#/$defs/protocol-node" + - $ref: "../pinctrl/pinctrl.yaml" + unevaluatedProperties: false + + properties: + reg: + const: 0x19 + + '#pinctrl-cells': + const: 0 + + patternProperties: + '-pins$': + type: object + allOf: + - $ref: "../pinctrl/pincfg-node.yaml#" + - $ref: "../pinctrl/pinmux-node.yaml#" + unevaluatedProperties: false + + 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. + + required: + - reg + additionalProperties: false $defs: @@ -384,6 +417,26 @@ examples: scmi_powercap: protocol@18 { reg = <0x18>; }; + + scmi_pinctrl: protocol@19 { + reg = <0x19>; + #pinctrl-cells = <0>; + + i2c2-pins { + groups = "i2c2_a", "i2c2_b"; + function = "i2c2"; + }; + + mdio-pins { + groups = "avb_mdio"; + drive-strength = <24>; + }; + + keys_pins: keys-pins { + pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1"; + bias-pull-up; + }; + }; }; };