From patchwork Tue Aug 8 18:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 132902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2415817vqr; Tue, 8 Aug 2023 14:54:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLDHzIGzd7MuZKDaU7Nn9lVWYwA7D8JO34TPV+VRClUCubZ9+yv91IFWLm7FmunesiBgnO X-Received: by 2002:a2e:7c16:0:b0:2b9:ef0a:7d4b with SMTP id x22-20020a2e7c16000000b002b9ef0a7d4bmr596464ljc.31.1691531649108; Tue, 08 Aug 2023 14:54:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691531649; cv=pass; d=google.com; s=arc-20160816; b=P3lmyD8n04ycJgUUwtbEfqzKvAWlYbWTIY0pZowZh+y9/EDqKZJWCxgugAB5k++Kxd AyaowPCpcSnCekN+o21Fr9/Pmks+e/ovLxBhKIEYFNoeitvMP9YkPPeMSbvbldsMTx5m ctmqTQjaeCS8w/PyZQrzFkfOzvnhtsG1EfDGGrAgAiemdBaIPRKotQimLsomi0EHOI5P gKDOf7TIo7VClSjk4W+MATF6YHTxGuaUEGYLlauRFqiKE7EH0cSG4pQLpkjXIJoALd8h KuWnl1HWgiaxRZLVYROXMVXEi5h5ko8KSiB701j1gbdS0ZncNTlaK+7mu3XmyFt1Njvv g2xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=MaH5rN5sWId5OwaQsed7wER9u7G9/CZdNqWaDCZQQJA=; fh=AInAN8B9g5lsjSuaUou/O2i2E4YA6PbqSzb87dr12wk=; b=sXBaB08jdnhdH1RkYnhOTuYidC5NF9AIUjIiPD8htlagmKRszQtabu4UxNbzLPxIkF 5l2D1f0vn680xvjGPg/G6bSL4zlgvg2Gf0iiNtBxF3h4EEpyxPPQw28HWh+uXfCpMSFB TzT/DmRuIQi/tg5Kxl7+/G+MdBUU32YAMSe6MvlrC4DIGmSz7ODqGIfR8wU/UUqt30u1 brrpclxOQG5LpV+Q69TzUxjy68FoEhKEKXBO6UKdu2YKd9edmj2BQykHzNC6ITsx/KAu slIU161CrieJIw6HfIbRKzwuCiUCfSHfl1f+XUFkCHWnBoZGvHs+lmRFLl4ca41DdlGB diNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=iHfOIw+q; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qq8-20020a17090720c800b00994b9c51cafsi7829114ejb.717.2023.08.08.14.53.45; Tue, 08 Aug 2023 14:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=iHfOIw+q; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234101AbjHHUFt (ORCPT + 99 others); Tue, 8 Aug 2023 16:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbjHHUFh (ORCPT ); Tue, 8 Aug 2023 16:05:37 -0400 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 823BE995D9; Tue, 8 Aug 2023 11:25:56 -0700 (PDT) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 378E6eOw003021; Tue, 8 Aug 2023 18:25:40 GMT Received: from eur01-ve1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2057.outbound.protection.outlook.com [104.47.1.57]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3sbpek1ayb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 18:25:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vm1xO9o/0faYpe/b8ttcyEIxbtB+BqwbBULgLtVgLnWaNyuH7oczShozymmK3g/VxieFQNsgbKjSNZ12QAaxCkZ5c+Io0G4FZJVOrkTZP4ZKZTBnV/j+t8hQj5SQuVhiHtkANsAOVuynM2c0IX29sFAEmY/B4U5QhsOm3xm/pMes9tKiEPjJfdLEchAPe/vonAZsAV3ere62GBwPpRlJWwOiiGCaltJeWC8bwLs7ohaDeLDAWwD6omWQ1J61lmSmirPCV4ZcviJPDss5NZYGzxikD5vKBenGIVNp3yuyXlkHBYCCKH4QWPNoaHPxQFCnJLxIPls0cCHbHviWwuq80Q== 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=PY4km3YboOW91K5olEAD9X/uELWEnZnlSHjZVSMy9BH0L/jHrDjGQXbQfDR/9q8b1XSpeLg2Bt/LetblXSm5j0azgEBpJagmF03ZMoNs54oqRQvlU9gKxw0BZv/sGd5EfoGRA4HM3TNvrR6RLhRAnzDUNNfiGQIGWDJSWSppghgwrNc+lt51+oN+sqnSaMjqycS1VpLjzrc4Ey7Uiv1VzH0y9pqnWdpVoc9p2UJnWsEpBX/wGzkvHjkuUoeOrC5nuCzA9ja+C5Q5XVFPrtVe/+xVKlwFzJ6tqMK7JniBTR+HbxDTZS/lQk9k5xbGYjOr5DA5/vcKLZhu4qNZLjW61w== 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=iHfOIw+qJ7S/Xux5Nbhx3Nl9FooWw0kkrajPAWJoaPIFIvsLVXpmMVTknkY5JXm4X4tAWzVWKYhdQ1tAQ+DVVTSf7WNRTImXy5JrA90OyTwKJwC/nW+tncK/6eguivTFmID/Y26EG09guomdlR3NhiXWYpjGVHJUOqBQXcx2gQ8TlrbB/xYjpvmNpkJ0o6xaV5Ves8Xk8NDw2coUNmeXyNn6DyLJTx0dqZ46zRoO1HBEbgdZWPLx/5KdLa7SJw/tACmA0w6qrSfaPAyREDmwdJTMIPRZF3rGy40F4/qlCdeusYoD+YD8C8Pdd/k7XZ17a8Osa3rHFaMKOj8EMLQXbg== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by AS4PR03MB8458.eurprd03.prod.outlook.com (2603:10a6:20b:519::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Tue, 8 Aug 2023 18:25:35 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 18:25:35 +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: [PATCH v4 1/4] firmware: arm_scmi: Add optional flags to extended names helper Thread-Topic: [PATCH v4 1/4] firmware: arm_scmi: Add optional flags to extended names helper Thread-Index: AQHZyiW5rkl1KYxbi0Wgd/91X3ABeg== Date: Tue, 8 Aug 2023 18:25:35 +0000 Message-ID: <318eb79c7e1ddb1f964a901e778a0475bf18c85b.1691518313.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_|AS4PR03MB8458:EE_ x-ms-office365-filtering-correlation-id: 7f130943-ae34-4d59-7275-08db983cdbb8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OHRHvAN4xfiBrM41iJSHkpeSywR837AuRs83aAZVH0AWGOsHzcFp7pZDvfavWazIy0jMKNU3BTZ65MrBt/fAJKUOmVuLZxb/CAXt8q6zF/9fWJqJi3+pbXsgMYjnNT1IjJPv/qkV+HAC27RETT9672CSYPEneG3moXDxH71QpD2aD6vsvJIQXiNvOERl8TIPkTYl/UOfm+GptkeV7BpNVFt/PkT3o6QYNu6kV9kprsNlQCtcfHO7ttOiYHRmUPlUzc2S+qyUC8IClgFdAuH6lPtKdLWd7tECV3CrNUfupaWGLUwiO/ZhWFw33cdyzQU6RAwQA/RTNPWik/KSTkSlNZxA9VLWsicdpABx9Aek8/ZQEGkb0MYC+qB+4aNPn6q9gjDEt+1Wrl5bPvUNfiM0N3NtvbfSyg1u1UkOdCgnUmXegGxj1SLcakgCmE99OBqysCrSrpRykCgI6lFsKZOHwjIHyLCBSNo0IuYWl+CPEgDBB6HPbP0Awt3SWzYVlwfbz+T7v27yAv2bmwEX4zj3w48cMXpMXUuAOhTczmmZXbc39YwN4f7yxSESszlW9Qcmx2tHCtn36MQLyOE6kodQULgNKGlYTEx3BwGqinnX73lvsNlqbhuZPtJ7HPVycHH8 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)(39860400002)(396003)(376002)(366004)(346002)(136003)(451199021)(1800799003)(186006)(7416002)(38070700005)(8936002)(8676002)(5660300002)(64756008)(4326008)(6916009)(41300700001)(316002)(83380400001)(86362001)(2906002)(6512007)(6486002)(71200400001)(2616005)(6506007)(26005)(36756003)(76116006)(66476007)(91956017)(66556008)(66946007)(66446008)(478600001)(122000001)(54906003)(38100700002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?1jkEJ8og7DIZMAtuX5HVBTQ?= =?iso-8859-1?q?zFBn8ihwT0ZIWlSA9VdNSZ12UQQEyPJcbFXIrmmSzgHlFCujiR0R/IVmeA/v?= =?iso-8859-1?q?fkion6LjL1dlZLgQRftPz1aQFbNoQAP39NAnbinHzYumYT+RY/t0VEqLKG6Y?= =?iso-8859-1?q?ZdSuNDGJIzyvGZAwvvOMyrKXp6HNH3swZQRgEsT7lYTNeqbr5Ww0otMJgJGt?= =?iso-8859-1?q?YDeHm162AEn1/Qo9f6UiIaGjTzHqZyvMFiKLVga890O+oaq5FY9DIkYfnpPc?= =?iso-8859-1?q?5tLHQFl8VIKV44W0zIV0o6S8clKuYmvZsHVB77+9RuytK22JjdObMmImiMJn?= =?iso-8859-1?q?mEmULEcFL6BQJggxjBZdPITje2pcUdQZiUhC/v6qdEM2MOwn5Cb+pm5hV7KP?= =?iso-8859-1?q?77LDXcsnopmL6EzR48TF8+vt41UgPXCAXgxI0wd8U+bJ+C/sCjmdMTdSdLvh?= =?iso-8859-1?q?Q2FYOBuaVPH7q2EOW4eUS/LHu4OYkDr0AnLC5XjNzBqkmp14EPejrrBg04ym?= =?iso-8859-1?q?V/1IBzeLOLl9qCoGskj41HSGT5PH9grmPFf6fFQfk+l4Kd+N2mNEupRPIcNa?= =?iso-8859-1?q?VlewP8UG5EfIgSjH69h9E5BuyppOQQma6/6eZLP5nzBmNoisMKjBKRe6LuG6?= =?iso-8859-1?q?BO9sk2ShMr/HNuq4HzfpnFzMz7taZMWzA3yGFbsp8cFgAKo5AxzwmmuS/jAk?= =?iso-8859-1?q?FX1AzVsTj5MkoW0NcyU4nt7V49n8BjE9q0PVLllV5qRoZuRYa3aUgEaH59PP?= =?iso-8859-1?q?W1La1JZhatym1QlDrCnvHbdYOKrk/TKNpxd8akAUNm12uU1WcllAO4fH8Uba?= =?iso-8859-1?q?ZW+1+t4oh457kRm4QyUleuULHFpcyUjeuo7hpRJFqOisSqlUH/RGyeeeoxIs?= =?iso-8859-1?q?lSpQ8bUesowV4Iwyzn1seOZ4unnz4ffIrWlVlR48M0XoFcwFXSuQFja6H1Ov?= =?iso-8859-1?q?SHf6MYnau0o2FJkBh5J2MwrdGTgwLKPHlVaqpyZhmXs/XmdNv19fau8bHUEN?= =?iso-8859-1?q?LhaiWzHKwqApaFeVlpsk1ItEKRbAHfseLpibOkl+CTZ5t1GpyXhibUJ+zd3U?= =?iso-8859-1?q?CK5jIlS5OTgofhm1Af1m99jYL/Eagtfldx5GLMEQkMF2U8nLRZbVl2TORYUH?= =?iso-8859-1?q?LithGiwR7UqFdPsJRuORuvBYjnOGHO/jcjP8yOWcYeeZowxuOVhQJY0UhZ6+?= =?iso-8859-1?q?gtA0Jq8vOFAWm3A65unCrX4AjSdT1qhK1zGVrjgXOqXp/QEYYVolwmKD95r2?= =?iso-8859-1?q?WRmICl8YYwxm366j/iMKt9n+724Xr0x9G2Yc3kR6/9eoeAmzNM/ouSWtn1hL?= =?iso-8859-1?q?KJIr2gKQ1UKmlderBc4TKZrLWhIm+y/dDDway9K9cU9kCUOzaT40iZ/cvsc6?= =?iso-8859-1?q?D337V6RaX6W7xscwjGCiVeqAd36vrWMBwtEE4Wn2mj6y71tFy6QasJl1L3Uq?= =?iso-8859-1?q?Gpaw5qIhrsbHNQT5DnQSFRmCs5GbcGdbuZ+fF45YKh3KhsngL22lQNliPWSk?= =?iso-8859-1?q?w4893+dBYUjad2mH+EIA2+ifiUOU+z4QIDGo3aet2xUo8Svk4eQ1meMZiBCC?= =?iso-8859-1?q?Fr7HulHssANxqjMBmwtRWCCU0RoFTf40N+FivNAFvf8mA/L435H4b0wpvm6B?= =?iso-8859-1?q?MlLer7/HU3qW29jcaOKggMwZ5ngY74Y0YGI5IlQ=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: 7f130943-ae34-4d59-7275-08db983cdbb8 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2023 18:25:35.2439 (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: lSLfYJ1pUEQnctTvE7pQL5SDVVkwJlwr+v2rvT4p3KSPODfem3TrPGOXIZ9AfXCd4dTlRa8J9q6Mv8SUWkpMj/W0GRRASyOat5XdrVYE4A4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8458 X-Proofpoint-ORIG-GUID: TsTa_T6U3ZHwAWEuMa_mFDjaKvI4kGFf X-Proofpoint-GUID: TsTa_T6U3ZHwAWEuMa_mFDjaKvI4kGFf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_15,2023-08-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080163 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773699490485280273 X-GMAIL-MSGID: 1773699490485280273 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 Tue Aug 8 18:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 132964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2452786vqr; Tue, 8 Aug 2023 16:21:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaccYAA+x212eo/ioWNr2XCP9+KqAC7QWsnTzLJCszEol04u/gt1FOgEINp4ZJwnHyDXhj X-Received: by 2002:a05:6a21:329b:b0:13e:fbee:a5d1 with SMTP id yt27-20020a056a21329b00b0013efbeea5d1mr1137741pzb.37.1691536861799; Tue, 08 Aug 2023 16:21:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691536861; cv=pass; d=google.com; s=arc-20160816; b=rDjjCqEDSIy0nd4mkGs1A3Ev+645Yela1tcUbgEY7WPTWB6GbxGPe621DjTffnLbfd P0yZg9bZ42We/n+4lxwVF6voJAXcd886U0XCmICQMdRfu6Q3THVjwdsUwjutSpEIz871 WZYYBQSYCh4C0IAfKjtaKOCG7iyFzSFqLgWSqWUdHhbsjSF6n2K01jik1kv8bqHmhtov Q+3Etgy2XD49xo3tYdgA+xuYGEwfLzq7KkyUBuMG/5REMnmuv+4Z8xOO3I6QWwe1oLa6 27YuYRhh7ba9PpCcjbgpR956qAPqxmo2EICHXNm/m/OhuoYIJOAJYXb+Ts9b3Clpbg3N 6abA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=+F1XrR7yfWjYQqJzvPiM3QMAnesCkkVwTqGks+SvCM8=; fh=vflWZHm4Y6JaGnSJ8w8old6H319do8x1b8YHds2pp6A=; b=g1GFenypoYcTKqQtPcwAgqL9KHnzbuRCA8JUB5a9XMuaDdqwrPRVSrEQnRmHOGdc4s fAul3fPubjUZXV/iGXgTLzcNBsZQCttmyItrMOlw5wgIryFWShVMwk1YX3ebSxZAdsRR hTh0wGZjA60+rSSHmuo7bZNahQnw3g8w4M949vLNmBsfOfCAULnk6XNDIjw2DygfaIlS ifLBkbuF1FxfiakY0nHmYhp1pYZSFC9aAT1JeuJ9T6tCxXOeClETGpk8p4uEg/x3ufBV 06Hddvcu535AqGu/CbbjDoRPTWbYfHLZdppBeTmLb2TJz/gxyy+FBofT7hXqGSGDllCG KB4Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=H8SEX41K; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a056a0024c800b00686f9554bd2si8161058pfv.140.2023.08.08.16.20.47; Tue, 08 Aug 2023 16:21:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=H8SEX41K; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236042AbjHHVPY (ORCPT + 99 others); Tue, 8 Aug 2023 17:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236285AbjHHVPM (ORCPT ); Tue, 8 Aug 2023 17:15:12 -0400 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FEC2995F0; Tue, 8 Aug 2023 11:25:59 -0700 (PDT) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 378E6eP1003021; Tue, 8 Aug 2023 18:25:42 GMT Received: from eur01-ve1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2057.outbound.protection.outlook.com [104.47.1.57]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3sbpek1ayb-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 18:25:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZ/A8DkHLhLsj4zfidkLOvfLRvWVP6CTJusFF0znqlFJzOHdRNQOtGhXcTLKz2fRyMcFfX4dkN0YIaVbo7FmE6mH/mPOQ0ZKj/nbvwxR9fct7FEXTJPWWDRv7HcMa6wPkFYbSzEJ5mdt0WlxosX5+j7hWZd9Wey0jOb/iRYoU/C7+aujNp/W10manXWZ83wyjP8HYuXfGlc37MPABj0D6aiQ53npxpqfXVhUHDIpNdPBh9BUiL0mYIP60JHAJY+x+db6ZX7edo2p2aFjPcBLtTS+PoTbn5ics0dxNdBQvh6br178T3BCiR+ivCngZvhSjTIuHfzHzK6BEc27vCAWFg== 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=+F1XrR7yfWjYQqJzvPiM3QMAnesCkkVwTqGks+SvCM8=; b=eEP+qnpfE/Tjnhz+NpUPb+gxhCaaJ7RSHZBjCzoXoeW4J18NAUO5kVwCaeIn8tA8RyH/TmKWm95QHrzoeEUwlHPw8uBKramMzQwo3PLg242yk8ftPBN8i/h++GpaVFF9V6y58djt/o3suYSBDoEunwI0qoPMqvZjVy0e8odlsAHz0UFtKA8gqOLneKH6+XPiTfVkSjNDdmFqO0XNeAiW6WMyFwZy38RiUrWtyna6zT7/SjjUQUz1UeXG5rBri1lw8tT2JIFen5Ypl/EWykPmQ1KAmKx19SL6XhW8MqTzXm1WKrQWxmpVcjAxKRNR1K07P9TpmLZUtAK19rQq0YkLxw== 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=+F1XrR7yfWjYQqJzvPiM3QMAnesCkkVwTqGks+SvCM8=; b=H8SEX41K55i5tAh7T1FjxHwHozz5sMsDExStHTmdP6fJxhy571qBwuF0DQ1dEcpRbZ9SlUC1siJnZph1lHcoPqftnZcGCb+6TIpQ2aeQGUqWEqV/kY/d2MkI8CDJCm0veOqon20gUGozMtk5lbpRDlVZxF/2XruBc8vfWQdT5EzJOdtRbuW6EABhQjp6lhE7A3shmDxRcwTIjZVll6SdLsMFi/UZLLCxmMorUdfwVRiY9rmlozBPmjpCfvKAo9bivuFH4PHYI8QxQ9vwUkETVdyS2qtFsNIUJsTkPlyQ4viQgpd0ECA/PrI/EM2c5/Av/guSHVSautbsrtu3Osv/sg== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by AS4PR03MB8458.eurprd03.prod.outlook.com (2603:10a6:20b:519::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Tue, 8 Aug 2023 18:25:35 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 18:25:35 +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 v4 2/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Thread-Topic: [PATCH v4 2/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Thread-Index: AQHZyiW5O6qQsCkaZE+uwCtArOPMQA== Date: Tue, 8 Aug 2023 18:25:35 +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_|AS4PR03MB8458:EE_ x-ms-office365-filtering-correlation-id: 5bf622e4-f164-4afb-6f2a-08db983cdbd7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AuJ3H8UNO/XBOKkxv+JSrcj8V8hTHpCSZbQLt5ZJuiRAp/L4bfMaJzbRBibsrq8tEhrUmofN8TAcKVNIIF7N1Tk/Uj4EPHPXaIIeiTCK9FQ05u9m5jkHRd09NrpukcSkk1vgTfUnf77Qf8nRHzxu5TJwx+Zbs1XuhZJYK/fH0BdIrlgYrxWjmU6A15C47Nx96K2hMzOHQMO+CRTnK9psvwSZa+NvV1uxGuwYaKp+04P3f5ArBSvMKZvKmOGHGE0u/m5BLkNO+4JNZtjjg6mHNxH0KNyRG4lBeUD6lHz3wMx3j2h65zGoFvd5X2lgJllhE7JXv00WrbbkgNyLEhRZVOtzsI+V1IL0CvFl6DP/LY52IISz4BiYJWK8fwJrZUPnIuD4HLHtdEhuq5O5Nq2K+eBus2W/IlnrLFcbLTwF2qv5zdul6qyHsZaAC3gWkuN7od45u/kjwjrKdJM8kDNPq5GAxWNor+1U2YqVucaI3sCs0bvBLFfEfJpQs1ufZ1uvNEKgNKPuqh9ucCr9Ka/R3YgeGsiZfab3kB94COx6stZSpzkRxGmv4PPbSkn3ONn0HCjEcHhljwPVknAN/xdzxhFgZs8cRRG4vK8UatMeweZ+QT4r9VcxFLpX06nf4gHg 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)(39860400002)(396003)(376002)(366004)(346002)(136003)(451199021)(1800799003)(186006)(7416002)(38070700005)(8936002)(8676002)(5660300002)(64756008)(4326008)(6916009)(41300700001)(316002)(83380400001)(86362001)(30864003)(2906002)(6512007)(6486002)(71200400001)(2616005)(6506007)(26005)(36756003)(76116006)(66476007)(91956017)(66556008)(66946007)(66446008)(478600001)(122000001)(54906003)(38100700002)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?lAMovaUBhncou3zTuQe8GQy?= =?iso-8859-1?q?1oZYerSCN7VoSN60JK2uEK0yLbAhTu5I5PJSssDBooBNhAaGfaPIuRZ9MXSw?= =?iso-8859-1?q?I8L31SjRHCVH1LeuDMCNyyQS8sNmJ3nR3R+SF1aQY07pluIeVXc0IzF88fUo?= =?iso-8859-1?q?uANn2mWQbIe93+1asFcyqnt/+vz8jD1vAVqLs48FbJ1rSC11iiTa4KD/TSSx?= =?iso-8859-1?q?u7HwrSUlv5fCiN8VqH4ejerrtu7AdNdKr/KLIEGgsbo6x8B8wVH13zQDtund?= =?iso-8859-1?q?x9kOqbjctNAT0vaP8j95b9TtSyxnCbZUyj4YiNrcVIOqpg050+D9+9xf9APf?= =?iso-8859-1?q?G8nkwPcwt9cBQ+1g9BjenLpRwfhASqBId4B5VBBKTzIxvSGWXEY4eA5mnAmz?= =?iso-8859-1?q?Knm7koPWaTrmobOhO97NDKcEVGEYhHSRrjt67MSl+8PGIiFw1tp7GvQd1aYH?= =?iso-8859-1?q?ufdX/FhHMqufrxpRF49UQigoLqrPadlyAkzyJr6PANZRXAJMSZhO1wUyjUBv?= =?iso-8859-1?q?95U81GSoOpNo7WwNF5ILxPbe+sjzEvFg/yJsRgUQSCSQy4+V3jOWO1AI9vdi?= =?iso-8859-1?q?u81mwkVlXHJzWsnTm/GfFP3hKqNeKBE7JOEqoB7hP/ujpLoyAYyyNyBvZqC6?= =?iso-8859-1?q?cdw29/Hu1OpWCXbT9dw5IxB4p3bMk0fKTYIlFDgQNJFq1GcTuaFQfga84+s2?= =?iso-8859-1?q?hoiKaBGXpxmMZ2+j7CYbOk5zML6Fy/8FC6VHiMb7eZak0VfVgMVSbWvgyawL?= =?iso-8859-1?q?E+bnDGFVz9P2cBdVB2/Jamajwjt/znuxvHDqr9uZpfFoOdbp0u07Mqifm5uO?= =?iso-8859-1?q?v61zl7/zZ8ls1w4zdNUrcQWk9rxT5w0qMJpFzvM+lKLDBouYtxZ2kyGXWJA9?= =?iso-8859-1?q?tuQljvv2XHHoudvulgu4W8ZAkVNpo2RSgDrlC83D9Iu2c8wvKeDG3u0x0+/N?= =?iso-8859-1?q?mtwpfhHXDhdjqc5AYFAIEWCgORN0+pM+/pu+OL5qlwAs6KRhUSpEIUmqz2L2?= =?iso-8859-1?q?KyGDaQ/6Lrik5MYLSgcveg2M8COtjRLvGtMFbnhzejfJTz4icxIkEDFGQOUQ?= =?iso-8859-1?q?u8fFvN+OTkHi7tV35hG/kvW0W6LExV4+6TH/AWmbLEddqf02hZqFEunsXzo0?= =?iso-8859-1?q?ro4qZ8S+uYL0pfNa020NnOo0tlNBo47DU2yA7sH4U/WbXcX3txvCTiBcJPIB?= =?iso-8859-1?q?AKbhWgYNVrA7iJKEN2sa2bQN61UYP4l/p1MfmlgAjKF9KxgtpOof+jAmiIer?= =?iso-8859-1?q?JgbRHKQowZ51k6jOfL9NrJrklZ6WvkaFHlkl/okm4/hUc3FtmKdB7Q85h0D8?= =?iso-8859-1?q?RrcWHSTecwD3MA9tjpe+8LO+crpSeMWQnri0DzuI1YzwXyVehf6GAYivTivU?= =?iso-8859-1?q?58z4LLqFKlYKKgi1C1/u4BmqiDpDRM8vdhEFVmg0DMQ6RBv3U8m8visowev3?= =?iso-8859-1?q?gwkelXo/Ke32NjS1MWQHwuoSkC4irv+HZD4IM/ChVZU8Bp6w2q63qSaCjS7T?= =?iso-8859-1?q?EbNB1I+FlL1zXH2R4yw9eKjLK85utRJzEc8dIOaseuovcW3kxKe3wHsBS3Ah?= =?iso-8859-1?q?4JkEYG7yYLDkISPxReK505ETZFkhsFTXwUX7/MLCLELbqXgTt4nTWjmn1HD7?= =?iso-8859-1?q?ZB+qFiGO6O20ca5UgylmaRX2GeDwFZV4U+sNXvA=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: 5bf622e4-f164-4afb-6f2a-08db983cdbd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2023 18:25:35.5985 (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: 9SPR42z2ttg1pK//2fPb1+VYQ+geqqmGjC5p1vKIvtlymrpGgLejrq2xbN59zV9+Y06u7/UidiOVX5ptWV3QQHSY6OXoVyfrVX9xNK8xiIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8458 X-Proofpoint-ORIG-GUID: 8kBzIMb5DoGLP60te3lY3IIa_HP45srk X-Proofpoint-GUID: 8kBzIMb5DoGLP60te3lY3IIa_HP45srk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_15,2023-08-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080163 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773699789188416683 X-GMAIL-MSGID: 1773704956741915713 Add basic implementation of the SCMI v3.2 pincontrol protocol. Signed-off-by: Oleksii Moisieiev --- 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 | 791 ++++++++++++++++++++++++++ drivers/firmware/arm_scmi/protocols.h | 1 + include/linux/scmi_protocol.h | 42 ++ 6 files changed, 843 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 729201d8f935..03686bff000e 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -3024,6 +3024,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); } @@ -3041,6 +3042,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..868a2f9821be --- /dev/null +++ b/drivers/firmware/arm_scmi/pinctrl.c @@ -0,0 +1,791 @@ +// 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 { + 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); +} + +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; + 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_config_set(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_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_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..11bb69479076 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -676,6 +676,47 @@ 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_set)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type, + 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 +824,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 Aug 8 18:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 132891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2412447vqr; Tue, 8 Aug 2023 14:45:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXujAPjGD8jby+fCzRx7C3E3yRDbj6zr/Se0zxcbQcNpdN+2jxHbTV57njXH/rbX7nMA6B X-Received: by 2002:a05:6a21:6d8a:b0:140:8537:85c1 with SMTP id wl10-20020a056a216d8a00b00140853785c1mr894504pzb.28.1691531147530; Tue, 08 Aug 2023 14:45:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691531147; cv=pass; d=google.com; s=arc-20160816; b=WroKua4j3fBkAi8ggupb/m+z6WpT7PACuKnzsGQdwxuNA4gMYftrqwnkaEsKuG+irr cmHfLQJHbdInQnQjuIORT5MCmkZExRK3WAZMZqn3un2nuNRQLmpp7BLo2pAYUfS3q0Ke upY/DAodBkDWhZnSVKhljkVgHxQsNkilT6MFVMKHzbWXkRx5qE/a42lawLiHaCqJOLZI xyP2pYGdMmWaYTQBYTmuFFBZhGAsfrjVg6mpI7hA/AQxtiFKJWatQrxAYOeiIz0YK4dM ulfyfxd9TaFCQOOkq1Pb99nQ5/Yl9jlScUPLjVUdSZ2NG7I0V18qozo+yXw7A4YWvqD0 mqMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=XbXUf6iwHQKvVKz2R1zpycWz3RU1c3HEs95mk4A/Ogo=; fh=vflWZHm4Y6JaGnSJ8w8old6H319do8x1b8YHds2pp6A=; b=CbrVpHG9WrKAyyKCQlcV8CfrWRRyOxSbrQ5atYCUHc9OfdQtvswjMn9ELt/dvbsX3s Se70gWhyY2S5eTc65xeYKBysjHf8pra/SnBEFb2nxjfn6xIVSSbYsVIuQAQxO8gk8VMn qXQ9ZzPK2u/ncwiDGi0IEOWi2rs8DVqM6ptmDRjEzDjyzkqdEIUyiglP+XnuVrAadW4O KUgHP2wozTmMEE6ZwoiyoxTZBjVsdC6yyl2M152o0KJ30HfxcS3+MdEr+aSjRK7LXJsA nbMIoO6XiyKp8w+xIjBawT2RQMQbH96tUemErsw8hKNv/ZIeCcnqEQ+Y0RuSBdXf6g6A lrZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=jd5Y+bkJ; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce11-20020a056a002a0b00b006878b4cb984si7813431pfb.36.2023.08.08.14.45.34; Tue, 08 Aug 2023 14:45:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=jd5Y+bkJ; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbjHHUFz (ORCPT + 99 others); Tue, 8 Aug 2023 16:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbjHHUFl (ORCPT ); Tue, 8 Aug 2023 16:05:41 -0400 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A21995E9; Tue, 8 Aug 2023 11:25:58 -0700 (PDT) Received: from pps.filterd (m0174683.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 378E6eP0003021; Tue, 8 Aug 2023 18:25:41 GMT Received: from eur01-ve1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2057.outbound.protection.outlook.com [104.47.1.57]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3sbpek1ayb-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 18:25:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KdvVdeu+RU6Sc6eEUsbQjPdeVbu4Oo/GL+N/cjKYEWq/hNPZy5i3vyRgvVQnwXFV9uSRgVHyYpp+v0QW3UIVfHeEl9zMENpzq1MZj4vGw+QPe7pgieG94vifryT71V7i6Nko8/YQ0XSGPoiY2tN9IIAkz1zOb0xN4KxaNKjMjriV3WkNDzJLKFVQFOIyrQKaeGLgq6mZJqAuL6qoSE0rgl+6kasQ3MCFo5wUnEn4mFz+gYxyyFhrkBmNxZbzZacFl7Aki1EJ7rtUds0vQ/uoLLkkJ/w5IdBwGHizVH733GB6Gz22uZGtbQ4kEiVEm4eOnWJNmY7SaqOdgdYAOUkL3w== 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=XbXUf6iwHQKvVKz2R1zpycWz3RU1c3HEs95mk4A/Ogo=; b=mlZQYLRRY1ztGDCnNw79cLA88Omio/p3Hrmr+sy/0CB+uZgUn2eqRXCkWbIoFU/wk6icz7L0vvVdeVyYbDmT/0sHnnxJJTeMIE5kp84+YHXV4ikBQiYJi27nkshztYsCQM3HTNai1oITINgAH4kGMK66F9pzg1e3gVUMfjwU2BHmslTE+Lxrew/8JpSm6yilwLO9zjUUkgEJlXHAtuSMdjSUjBa2RHjf4zoUglkfvfn3kM4N6dRFrl92Ipryi06l3GtLdpVB/sGv/u6JW+Oc8bVMqGVi0Q+HhwomTYvgSmakxIkcdA3Gex/3NfzFvnbUoY7oBSSBQURWP1IsimRlAw== 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=XbXUf6iwHQKvVKz2R1zpycWz3RU1c3HEs95mk4A/Ogo=; b=jd5Y+bkJ17z9ysfVUFujCdfvl3uv224F6pU1Jy61PFevwJwRhow3AqrD/cY6s+8w2yUtd4Wlc9tAdhmWZTvQC5blCIHpA/1tM0YvxvjjiVW2blZZT7M9hf0MCo69T9BeIKngva4SsxPDaTSMlArRIjJnrM8pUYTzgCqQ3DTKOTuuEqrrp+jm8IPEwbp/yzPAdCDdfPNZ0qzoLqd2jwvFxlKKpX9SAT0IxNQ/YkPzsdH/0kPHjKSK+jxaTHcew71TapnWil6wYrVo8GghqoQhllopiEjMrAXmVeC3np3B9KgnHwDupuSR/wO9+Cq70HKUgFUawgkerMlh2fmOZ33ekQ== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by AS4PR03MB8458.eurprd03.prod.outlook.com (2603:10a6:20b:519::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Tue, 8 Aug 2023 18:25:36 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 18:25:36 +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 v4 3/4] pinctrl: Implementation of the generic scmi-pinctrl driver Thread-Topic: [PATCH v4 3/4] pinctrl: Implementation of the generic scmi-pinctrl driver Thread-Index: AQHZyiW530DOZaR1WkuogwXI6KprGQ== Date: Tue, 8 Aug 2023 18:25:35 +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_|AS4PR03MB8458:EE_ x-ms-office365-filtering-correlation-id: 36488059-eb23-43e5-1bf4-08db983cdc07 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ie2vWbt50+c1Iu8/IB9XDqw4kkSvPHKdQ1YQ4DipyEFIE852iywu3JPV02Eq1R67A8tu+nvQkreGD+O7h0ndQ/mIq5BpjuEP2jVC2y2n/d6SnRjzRCtMUMyraWwvy47hHKx9eZoXED8k8Lw/4KHZsz38Dq5WOwVdYcIatQFAe+fXuS7pdB0NcTSqp4pyjyFekMnHoNbWN+qqDyln0tHqH9SF7l7+bg+epEa8WQonhM73exmfFWpCXK2cPZ5Gah6da0PQnXGHyDDy3tqMFefBqiy/py+Hot+xnGAp2pUnz9Xh5cguhM3jLqgi0XzKO9Lblv0ELZ1NidvxBKvVsHVhf9h2/p+T53xo+wKBECy0yHQM9F/SMEnPNky8e3VmW8tc035EqngtKLlckHWeydre25MDNCIcU3BxW+BZgmnRfiIektNPMwHMAzQUdriyI+fJpWoul6rgXBksk6QOXUPYslVxPABgaRy/I54U/Kj7rRWMsfyfLXxkifYAtd5KN+sXcPyJi/BDqPluzanFcmiDrmJeP1XxW9hvSey8Xc4qutEHfr+22QHRq+1QIE5XQlphjyeFjm9hBf3QDB/d2gtsl5/OyyCJZTcwU0AKc2fK79CxPTLqQQ3rxzBgwTc1vPKEIi326PCh6o+pX0DZbgFybw== 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)(39860400002)(396003)(376002)(366004)(346002)(136003)(451199021)(1800799003)(186006)(7416002)(38070700005)(8936002)(8676002)(5660300002)(64756008)(4326008)(6916009)(41300700001)(316002)(83380400001)(86362001)(30864003)(2906002)(6512007)(6486002)(71200400001)(2616005)(6506007)(26005)(36756003)(76116006)(66476007)(91956017)(66556008)(66946007)(66446008)(478600001)(122000001)(54906003)(38100700002)(41533002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?I5j7qVA8Wr7xJ/s9hHbB4y5?= =?iso-8859-1?q?jO6FobDks/6P5NTxAoqWF2aovgBTQ62seeq1XP3rFITAKv/wa1BenajZZDDz?= =?iso-8859-1?q?pld7/szI6QEUnGdwwDBDnzuLKPU53e1AcwzwtsFC3BBXIhQio2AGRanGTheG?= =?iso-8859-1?q?c+FNP01hosMEvpHXl1/jYdxaigQDKVdFaFwmz/aLD6DMq8EZvycH9EJW95tD?= =?iso-8859-1?q?Jwv5qZvz8GNEAGRH3ajwWlQ/XgrbyytF0UbNsCO54aUL7arFkzBUvWLfx9QV?= =?iso-8859-1?q?h81ecqk6J7FS7HAux3bnMPeFApp6kg/QTP8SdP0xUoYCDK3iehWRQgN/2TKy?= =?iso-8859-1?q?wco5+59WQN5iDOJgkcV6KCv6p/ETtxC88EeOnEsifELa9H7aVSIv9EJvUenx?= =?iso-8859-1?q?DaWx0rQnN9n92YEGP4W+x28ssUi+k1DjAoEUwfbPv8TzNnmybZ8Cfmo6i4Ov?= =?iso-8859-1?q?AjTnZ3H6Imz7lpu3aqRifYRSgvC8p8y69Bp26TvdoN3MvbgxGAxi4zkeShG0?= =?iso-8859-1?q?cbiai93DLbwe++NcbmkpPkE9QaJkkfvvviOC+wLVmKbD7zVtvBU0HnLarAAK?= =?iso-8859-1?q?3u+w8nsuS6P0wvVRcrvYZz2eeWOB//RFfjD4iwCtYx90sIWWaV3I5erRqdbI?= =?iso-8859-1?q?5bl1GeXUvr+PUkts+11leBdowPatxhy3CeVCPLlGaMul549r0Me5IQr0VoAe?= =?iso-8859-1?q?Rti+WsQUYd59WMEeAuQoqMPFn6J2ZAjJgc/fi6EEkbzA9jFV0iNeVVDgJdvK?= =?iso-8859-1?q?mcKyDa0OsT5uucG6CkNHmj5Sd5JzvoyOfI2x6y8kDIShdEWfhI3wUCHgIJ4i?= =?iso-8859-1?q?tzaanxgaUd0xjFALRTVZg2PHVMgDV9FYiOF9mX8GMkSn2JpJspyfVxC1+u5q?= =?iso-8859-1?q?RWG4PES36HLfD52fb7yqiYsKnBaWtmuDddpOK+WT+SKiGQ6x4BkrfTykqQhd?= =?iso-8859-1?q?BF0tstdV81WsgdxkauHTslN+q+uaH+rP7t6Q52s/58nH0GSF8DoKCxTJrGK9?= =?iso-8859-1?q?Q6LUcFhArGe3ChujBR4js0uPWIOzhqVxk0JzUpVLDi3KxJMLgTin6f/eTxI0?= =?iso-8859-1?q?rXrfxd69VYJEuyDKYXOlgiAwTUsvo5tEjVzmPIAbVvlySRdrYYwv1x9NoEXz?= =?iso-8859-1?q?El4VNQzCpOFzyCsGpPwp90R1TY5ur8usmrghKwH4XMG9KoSjifiPZP7N3ACq?= =?iso-8859-1?q?vZuSPvOttY0/FL3jR3Pi7X1TYe4V8T9E20CxWxxVMuwhnYdeOxVoBNSctKF7?= =?iso-8859-1?q?G8eLI+9qvdrO4DEoP8E/DOyZujj5r9OARSfRd7+d7G17/GAeXK5P6VvRY0x6?= =?iso-8859-1?q?eAnclZW4FDDllYX+HD8YjJO5lWV6IWzgQreYgs7UAgLIblROO7th5LiQYvuW?= =?iso-8859-1?q?4jrqgahdWmuAUAEaknFtsixjeDIcZNpKQDW32fZ3FxBG1iUhHOxhZozB7fPu?= =?iso-8859-1?q?+PDHmF7ZqQl2BB0oG84TOfDiNnkhi187f/peE5aBDH/p9GLuRpZbbOIob4uf?= =?iso-8859-1?q?ilsoLwgNcoEMRTelYrCmzYD66JmA4vXgbgneeveRf4gTZa8/vlr9lED1dTeG?= =?iso-8859-1?q?AUA2BcYpJh/G++yoYULD9rbJIVt2e7oztj10xkwJMXx7jtvnO8pk7mC4Q2t5?= =?iso-8859-1?q?h3moLqL6jP4QDn9/xbj9nhyt3to35Dmr6KK09wg=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: 36488059-eb23-43e5-1bf4-08db983cdc07 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2023 18:25:35.9350 (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: mTONncRb8eJhbCMYqJzlHbxBUzjvClmpon8LU9m21wVVahZeWuh9kzIio54fNVV6OIMTN1v8+RxS5z7cXWKdnPSzHbn1lguUyF4YwWEgcCs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR03MB8458 X-Proofpoint-ORIG-GUID: 8egXJJ6ajsGjn_JGVIC3-ibR57kgAJGH X-Proofpoint-GUID: 8egXJJ6ajsGjn_JGVIC3-ibR57kgAJGH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_15,2023-08-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080163 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773698964790562402 X-GMAIL-MSGID: 1773698964790562402 scmi-pinctrl driver implements pinctrl driver interface and using SCMI protocol to redirect messages from pinctrl subsystem SDK to SCMI platform firmware, which does the changes in HW. Signed-off-by: Oleksii Moisieiev Reviewed-by: Linus Walleij --- Changes v3 -> v4 - ordered config option alphabetically - ordered object file alphabetically - rephrased PINCTRL_SCMI config description - formatting fixes, removed blank lines after get_drvdata call - code style adjustments - add set_drvdata call - removed goto label - refactoring of the devm resource management - removed pctldev != NULL check - fix parameter name in pinconf-group-get - probe function refactoring - removed unneeded pmx checks --- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-scmi.c | 442 +++++++++++++++++++++++++++++++++ 4 files changed, 455 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-scmi.c diff --git a/MAINTAINERS b/MAINTAINERS index 2d81d00e5f4f..c4e36f955e53 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..956cfe76fbc6 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -428,6 +428,17 @@ config PINCTRL_ROCKCHIP help This support pinctrl and GPIO driver for Rockchip SoCs. +config PINCTRL_SCMI + tristate "Pinctrl driver using SCMI protocol 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. + config PINCTRL_SINGLE tristate "One-register-per-pin type device tree based pinctrl driver" depends on OF diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index e196c6e324ad..25d67bac9ee0 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_PINCTRL_PIC32) += pinctrl-pic32.o obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o obj-$(CONFIG_PINCTRL_RK805) += pinctrl-rk805.o obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o +obj-$(CONFIG_PINCTRL_SCMI) += pinctrl-scmi.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o obj-$(CONFIG_PINCTRL_STMFX) += pinctrl-stmfx.o diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c new file mode 100644 index 000000000000..a9304402ddf1 --- /dev/null +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -0,0 +1,442 @@ +// 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 = pinctrl_dev_get_drvdata(pctldev); + + return pinctrl_ops->count_get(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 = pinctrl_dev_get_drvdata(pctldev); + + ret = pinctrl_ops->name_get(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 = pinctrl_dev_get_drvdata(pctldev); + + return pinctrl_ops->group_pins_get(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 = pinctrl_dev_get_drvdata(pctldev); + + return pinctrl_ops->count_get(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 = pinctrl_dev_get_drvdata(pctldev); + + ret = pinctrl_ops->name_get(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 = pinctrl_dev_get_drvdata(pctldev); + + if (!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->function_groups_get(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 err_free; + } + } + + *groups = (const char * const *)pmx->functions[selector].groups; + + return 0; + +err_free: + 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 = pinctrl_dev_get_drvdata(pctldev); + + return pinctrl_ops->mux_set(pmx->ph, selector, group); +} + +static int pinctrl_scmi_request(struct pinctrl_dev *pctldev, unsigned int offset) +{ + struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); + + return pinctrl_ops->pin_request(pmx->ph, offset); +} + +static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset) +{ + struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); + + return pinctrl_ops->pin_free(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 = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param config_type; + unsigned long config_value; + + if (!config) + return -EINVAL; + + config_type = pinconf_to_config_param(*config); + + ret = pinctrl_ops->config_get(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 = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param config_type; + unsigned long config_value; + + if (!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->config_set(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 = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param config_type; + unsigned long config_value; + + if (!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->config_set(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 group, + unsigned long *config) +{ + int ret; + struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param config_type; + unsigned long config_value; + + if (!config) + return -EINVAL; + + config_type = pinconf_to_config_param(*config); + + ret = pinctrl_ops->config_get(pmx->ph, group, 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 (!pins || !nr_pins) + return -EINVAL; + + if (pmx->nr_pins) { + *pins = pmx->pins; + *nr_pins = pmx->nr_pins; + return 0; + } + + *nr_pins = pinctrl_ops->count_get(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->name_get(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); + pmx->nr_pins = 0; + return ret; + } + } + + *pins = pmx->pins; + dev_dbg(pmx->dev, "got pins %d", *nr_pins); + + return 0; +} + +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 device *dev = &sdev->dev; + 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(dev, sizeof(*pmx), GFP_KERNEL); + if (!pmx) + return -ENOMEM; + + pmx->ph = ph; + + pmx->dev = 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(dev, &pmx->pctl_desc, pmx, &pmx->pctldev); + if (ret) + return dev_err_probe(dev, ret, "Failed to register pinctrl\n"); + + 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(dev, pmx->nr_functions, sizeof(*pmx->functions), + GFP_KERNEL); + if (!pmx->functions) + return -ENOMEM; + } + + if (pmx->nr_groups) { + pmx->groups = + devm_kcalloc(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 Aug 8 18:25:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Moisieiev X-Patchwork-Id: 132936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2436839vqr; Tue, 8 Aug 2023 15:41:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeTbAQP4zaVL7If6ItiNp0HZ9TphoAFlwvypNVugH9rzdLpOTVzs1olFPcO2fQLVIZAYDI X-Received: by 2002:a05:6a21:7782:b0:13e:1945:8873 with SMTP id bd2-20020a056a21778200b0013e19458873mr969762pzc.37.1691534504951; Tue, 08 Aug 2023 15:41:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691534504; cv=pass; d=google.com; s=arc-20160816; b=ptEjshBICjAiAdrq3c1GxaGqzvZCcfkum7AMVvrQZUwKQrrGlGBwfWYt5wBCVIWuMu LBSwvtLyFzxtOm9EPX8viHX89w2Er58ze5Ex+Ekzete0AKQZi8DIlKjFBtzEDZc9O9Jn LGP+vCjqDJwhwQ9VMSoA7qbpUzfrPtVKrmRq/jHOExROJVJiKhgreDS5Yak3YrWT+vGn 2imVqxl47/5jRBVDJil4hYtINcZTXEuOJzjcGCP4uTbA379Ljss5TvdIKPTmaFDCHWlp cvgjBiBeV2aBmJa28XSLtRvm+4R+wD4c9rv3tSipx5S7BSdElhov4nOdJpQ4SWFPqvu5 2QXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=sqS/pUjPpEVLV51qYi6Phg2ZHA1nXvh5Cg65k9pOJy8=; fh=vflWZHm4Y6JaGnSJ8w8old6H319do8x1b8YHds2pp6A=; b=CR0W8Ak7msvLkAgUiM8pqYA6lyhLxhR/oStz05+xav2doXI+yGWNOsbQjUXnHMBmeZ r6wMq63U5sxLKOvp+gSSl7P9zFghTWD0lf8s5cMg9j5/0Qw5db+xXly0h5YMOQYKvcYw jEHZXBhejOpDS6d4KYskpcPKD31yJmIu1L/i68PqE35iOMU6grbt3FOkAJuQbv7KS5Bn G/MKLP9AFTYBy9oYCZG7saMF8zsvhDEa0YH+L5Oi2nYsY1rWqIR0ns3mSGG5JGDdgIOm unUdD4mjEybru1q4U7agRcxZd/wa1hWepM/4RqDc5VL/wv8r7k2broenbYfjnrvwpDJX 2sIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=EnzxwfoF; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a63da04000000b005573ea250f0si5112139pgh.116.2023.08.08.15.41.32; Tue, 08 Aug 2023 15:41:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@epam.com header.s=selector2 header.b=EnzxwfoF; arc=pass (i=1 spf=pass spfdomain=epam.com dkim=pass dkdomain=epam.com dmarc=pass fromdomain=epam.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=epam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229643AbjHHUGL (ORCPT + 99 others); Tue, 8 Aug 2023 16:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233530AbjHHUFr (ORCPT ); Tue, 8 Aug 2023 16:05:47 -0400 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 319621194C; Tue, 8 Aug 2023 11:25:56 -0700 (PDT) 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 378E6hV0002285; Tue, 8 Aug 2023 18:25:39 GMT Received: from eur02-db5-obe.outbound.protection.outlook.com (mail-db5eur02lp2104.outbound.protection.outlook.com [104.47.11.104]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3sbknk2902-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 18:25:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LHGpC6+zThipRjLw4v9JdByWgixYNAKjrmUR1498xT1wo5Ni46/mscIbmWFCB1cegzaSorwfi/WHEJ+x1WXm5WwYGV5/1e5wP9stg80WGeiYUiGk6JvDP3drsTHRRG0P01ORrKAluAWGxLRi7jtfHpipkbSVeS0c8EBZC/Nx7bkQnSMfbi2xvReUjvp4tRAhAeeiAGLVX0cFKGNeOYIhFtC86cilx73O/bcC4xsask5uvW61ZvP4B9hDPeyRZErtMZOEgGLhCL9RyvIYbaT9DBkk8uFQDHw/B9ToxuLhneHIbJUIlBE6xKfVcMikXWBfumMdgbQ1beidKHNxh1zEXg== 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=iDXhPSMMtUM/xvkAwCda1bUxdm6p2bC0mxoIXsLy2d2e4c0M0EiLcnGom0DTD0NxwtfHxsvXcRq3GuRlGGlblgQPEjBwUZibBYr4gA0003ypl4kWNe7AxgJz54a6bfRjhGO9weOy9GdQypthFMmBFNWHOFvL/mMRxe53QQ9kGPCAY6/n7Wbdccx2hdvNwFM3xS+nPHf2IzhKIFsPxT4frCZ6293eXysnVJ7TPeEB4QRXBYx4EfeCPHO7vouaXvRBSI47h+pJoqg3AMJbSSmJjKTvcOY2zcewB2goSqN/unFk90oHGRss31gzbVsyysbWpz5P52AJnOntzrdI3D7XtA== 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=EnzxwfoFbsVHscA4AAY4u5gLhAbwuQsg/ihamJ3B031QFoihAzhgUeBkgjHbF0ze3DlWfHkM0xb7qeQkPdC/aMcm/Ql2Cg8CWnNmL48R+S093Mq2y4pstUPm1ekoaPpOGIucr2gUk1L0WVA0atItR4wRdQiaiJMVmIALszuyf/6A1gQdKNwUp9OqOu9EXBFOHea17LTbRLqnlgFrSFQTB3ndEFqxS4+bSQEJBBnhhQ2/36J8uZybPF2hlfV1n8lzuOwcWJ7YaBB4WYeHWJrDJg+49Ao7XTq9J6tOVyID3m8jG45qKE9va6MFUaG5LXXDwhY4FcwgpjCCFLZvVqspfQ== Received: from PA4PR03MB7136.eurprd03.prod.outlook.com (2603:10a6:102:ea::23) by AS1PR03MB8151.eurprd03.prod.outlook.com (2603:10a6:20b:4c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Tue, 8 Aug 2023 18:25:36 +0000 Received: from PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26]) by PA4PR03MB7136.eurprd03.prod.outlook.com ([fe80::ccb5:5aee:f10d:ab26%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 18:25:36 +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 v4 4/4] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol Thread-Topic: [PATCH v4 4/4] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol Thread-Index: AQHZyiW58zfrIydQN0ew8q6pi6gRRQ== Date: Tue, 8 Aug 2023 18:25:36 +0000 Message-ID: <1dcf25b5c6b16b7138534e3c13827287f7c644cf.1691518314.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_|AS1PR03MB8151:EE_ x-ms-office365-filtering-correlation-id: 0e90bda9-000d-4c78-0461-08db983cdc32 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Qh6egbmjtu6LJc4zrZ6ZLXWnjJgykdyMNmu/OOEQMPskC9mQpsWOXsOfpiRZHnmxDLsOAuRk18y7/TZMF0W0HXEvCcClvZwj5Jd+Cf3KqLg/MGLi6807Yp//2Ow9pCLalj3yzAw//SkUSmCKMimb4r2/shfyMJ1cSsvBdyrQxg5b2EdPOdDQQu5rtC2u0IH5oYw9Mela5ijRpw5o9QKPpYOI+BW+9dkr4fP5sDtSvkvI66d3hb2B2L0iprzGqBAFkzOPw4T+Vc7j7tjmgAdEKI58t+OGUhe7RihB9LpgTJx4I5EIxQHiySg5bCWErTR1srVEWdPfanb46HrSO01DIkry4yI5SXOp0Zjsf/cknSSHF5m6aKAjSlGS0dxHN2tOACBpLk0nXMrXbay56U6bKMV/BhSG78HxJsbgORwtdNzyfKPa6Sw874o6WvxIDZshzUnqhkI4thlaEzBh6tOgN2YnMFllpmbaGj5Y1kmzvas9j3zmiGXZN0GO11tIdx5XczafDJOEJyJnfWind5DlDTDqqSXVFufpey/LSyEU8jiC9+5edz32IdyUquLiQy1wh5iv41BvbAH0QzsSVsJYjr8NUm983acY1FcHTEzOrObidu0FzUyX/IA36XzBQ3mO 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)(346002)(376002)(396003)(39860400002)(366004)(1800799003)(186006)(451199021)(2616005)(6506007)(26005)(6512007)(71200400001)(6486002)(36756003)(122000001)(478600001)(54906003)(38100700002)(66476007)(66946007)(66556008)(66446008)(91956017)(76116006)(64756008)(4326008)(6916009)(316002)(41300700001)(8676002)(8936002)(5660300002)(38070700005)(7416002)(2906002)(86362001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?wSfnDCz2poAL1d4ErvHy953?= =?iso-8859-1?q?PfjBXEh2qh33Vr8hs3hjHQmTOOLMpqeJBp2FQipmAowFaE0Okojm6+OzmJnp?= =?iso-8859-1?q?j/pqUlW+ewgKIiOgog9Ucesrcvmp7n0hhnNGw+GL40cQFIMZTLQsBjrtf9Da?= =?iso-8859-1?q?eK+hTVlYi9/q4IWinCOYImSjHrkFUqp6qXpUwYvnBgOmAl4Scc15ZmbuczzO?= =?iso-8859-1?q?XoRtDk581KxXEiKVPLb3a0tiElBPNaP/qxb6iHFeNBXDHutmK0S9XboOAVYm?= =?iso-8859-1?q?b6ApO48i/M0jbZw90S5OQ2h/G1hf1/yhdfURytpQVp+hm8mev34RySKSzoYf?= =?iso-8859-1?q?vkmbdYcCqUKiwUp9a5ICWx2nvad+U0FZfwMLEKCoOuZuq8QF9OyJmTUPCRY9?= =?iso-8859-1?q?38V3F/6n5KNqnCsujQfG6r7v+eYm+cGwBPVRcv84R1cZ6PEqtwT5hlgt60OR?= =?iso-8859-1?q?/+nLpAB4200onQqxPScqx6t7musVBe2/bQrRkSns+m1MEbHu5BgBSjlPjyx2?= =?iso-8859-1?q?u4/tkP5nwJNuVZjYZChqLchyjIUuvV8PtMaPbPW/E3vsgMqSaSNm7Rm+y80i?= =?iso-8859-1?q?bNMWnu+Nr6FRBJamXlXJX08Urwq9kPW+oqoNjArCkMVm9nl2/P7n4NsHN8D4?= =?iso-8859-1?q?S3UjzgQbkkAMMsTD8sZTk67o4UPVAQ8rV4bjXwHes2YLSI0CfBXCvk8fqDVZ?= =?iso-8859-1?q?AL4vI3h5T6ZVqAnHlDQ+egD5IgSyf2djPXpepUGH2wLNQdt7SzpGMbOhbney?= =?iso-8859-1?q?UBZmk1kw8UTXESDeGDMA6lFvIePFjJr69WhZsI/faEx+rEb4g9u3qU62HMIu?= =?iso-8859-1?q?Iyp78+UHcuSEbUZ5GkePzIPCwk05klcpnnhI7XwOb48F3LOm64EVq1O4/C+P?= =?iso-8859-1?q?o02BDTVfUZWxrgBLyQ11byCgDtmNNqs7f82tNcT93dDgMxu/LzPWu6kmM3pl?= =?iso-8859-1?q?S4qqQlX0/m0o3fQKaIHNORIW+OpPNYmCs33IUmAXEqbjyZBXXkmNxLu3Bejx?= =?iso-8859-1?q?mmYBMujP51SDwB/3ybrxc2kWebEjCat+u0Jf4QkAMkG1XuHcdJXVIDpqvfOI?= =?iso-8859-1?q?YYMZncUd9G/+pHa2DEgR0M8Nc9T41+3VyH7SbfS5G/JF8qGje3ddL/jCIwhw?= =?iso-8859-1?q?8cwp6pi+2GrX746PnCiMK5TyHEQ0wyRyZbCDHFNyzG+m+azCrRlR1UciDSYo?= =?iso-8859-1?q?DGMBNUy8aRvMi4/FniAx5U3ztPgw5VsaZrp2iN7dmpyQFuAV+TpTwyE+J2Mm?= =?iso-8859-1?q?6sj4oeUqW2D/h0bUV291dKzq6G/lJwhVlJqz+w5HlLnKxGEaZwel7d4b4y5E?= =?iso-8859-1?q?Zcxmy0Yhjjhi51ly6SQkkbiZUV9ILCx+9pwMiVGtMvTrXMszCfciu8s7tHqp?= =?iso-8859-1?q?4Rh1fR4r6tV4wO5SOZZaDZ7GqrJJ4Csv4R5+UF4/sjZxXoTuHgnlfCenZ//b?= =?iso-8859-1?q?Zm3MBE8hF943NWfPM7GAZXNbQI+VwrfVf0HmuxRmX6pv+eRLu/V7XNsTdOW1?= =?iso-8859-1?q?fXJwxafoqHOZBvleChwmpJZnNVIFFrie+MOSxOkxM08xqlMS1AclttapzNq7?= =?iso-8859-1?q?6kGMpiOvhNO/4Hzsd4S03eK+SaK1wRyY+hVGzx06XgAO3fBO1IrF/q5Yu5nZ?= =?iso-8859-1?q?L3WygpFUyZa5X9ecT1o38aA5M002pVnA3jJ2G+Q=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: 0e90bda9-000d-4c78-0461-08db983cdc32 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2023 18:25:36.2462 (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: QtjjaAMWTFWP7ShPdGFf+SZv44HZ8QfErgj7wTqXsPyVGzZ3JB2Y2NQwsbsu1UthOiD6X5FeQWNp+pZH46Oo1ukVVcoY9U+4BVTbuF9wAmo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR03MB8151 X-Proofpoint-GUID: A4k1w-RHrJqVYQQHTo7eoat-HVZ23Xcd X-Proofpoint-ORIG-GUID: A4k1w-RHrJqVYQQHTo7eoat-HVZ23Xcd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-08_15,2023-08-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 clxscore=1011 priorityscore=1501 mlxscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308080163 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773702484876565364 X-GMAIL-MSGID: 1773702484876565364 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; + }; + }; }; };