From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56837C41535 for ; Fri, 22 Dec 2023 16:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cY0CYwjfSW+Y5YdKxcsZfiL6BMWo3ddYwL9bYheDUL8=; b=IWL8wo2rfCcNYi nLklLaXt5R+aDYA+k735XfGT+1Y7mzmVa35pZSfanrcOIit1ZIiA7s8P0CvPR4R8DmCrxpGpZ2N/N dWxVsG/tqM+HiXTx5r86nML2P/zQtGE8zRDvx684PDY+f5dxE5q72HPtw47iibp3GgzK4xmuEYfuO R178N5/UNei/AIFJuDqoVQbFDsTe/QizCQSYBrHn9cRWkXCgmjSfoiRKeUqednKWgk8lh/FkvYUZP RyKddwTNypldPtDg2vIfl4QN5fave2kb76mh+Tf/B0pOs6sy6IElBFJRRmnOhfKXX3Tn53TGqYG4Q gZ9SJ10GkYdr3hYLZ1yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGiM6-006OTC-0A; Fri, 22 Dec 2023 16:26:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGiM3-006ORl-2W for linux-arm-kernel@lists.infradead.org; Fri, 22 Dec 2023 16:26:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 38260C15; Fri, 22 Dec 2023 08:27:14 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 143433F738; Fri, 22 Dec 2023 08:26:24 -0800 (PST) Date: Fri, 22 Dec 2023 16:26:22 +0000 From: Cristian Marussi To: "Peng Fan (OSS)" Cc: Sudeep Holla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksii Moisieiev , Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Peng Fan Subject: Re: [PATCH 5/7] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Message-ID: References: <20231215-pinctrl-scmi-v1-0-0fe35e4611f7@nxp.com> <20231215-pinctrl-scmi-v1-5-0fe35e4611f7@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231215-pinctrl-scmi-v1-5-0fe35e4611f7@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231222_082631_914425_ACD3D06B X-CRM114-Status: GOOD ( 26.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Dec 15, 2023 at 07:56:33PM +0800, Peng Fan (OSS) wrote: > From: Oleksii Moisieiev > > Add basic implementation of the SCMI v3.2 pincontrol protocol. > > Signed-off-by: Oleksii Moisieiev > Co-developed-by: Peng Fan > Signed-off-by: Peng Fan > --- > MAINTAINERS | 6 + > drivers/firmware/arm_scmi/Makefile | 1 + > drivers/firmware/arm_scmi/driver.c | 2 + > drivers/firmware/arm_scmi/pinctrl.c | 927 ++++++++++++++++++++++++++++++++++ > drivers/firmware/arm_scmi/protocols.h | 1 + > include/linux/scmi_protocol.h | 46 ++ > 6 files changed, 983 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index b589218605b4..8d971adeee22 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -21180,6 +21180,12 @@ F: include/linux/sc[mp]i_protocol.h > F: include/trace/events/scmi.h > F: include/uapi/linux/virtio_scmi.h > > +SYSTEM CONTROL MANAGEMENT INTERFACE (SCMI) PINCTRL DRIVER > +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 a7bc4796519c..8e3874ff1544 100644 > --- a/drivers/firmware/arm_scmi/Makefile > +++ b/drivers/firmware/arm_scmi/Makefile > @@ -11,6 +11,7 @@ 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 += 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 3174da57d832..1cf9f5d4f7bd 100644 > --- a/drivers/firmware/arm_scmi/driver.c > +++ b/drivers/firmware/arm_scmi/driver.c > @@ -3057,6 +3057,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); > } > @@ -3074,6 +3075,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..a25c8edcedd2 > --- /dev/null > +++ b/drivers/firmware/arm_scmi/pinctrl.c > @@ -0,0 +1,927 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * System Control and Management Interface (SCMI) Pinctrl Protocol > + * > + * Copyright (C) 2023 EPAM > + */ > + > +#include > +#include I spotted this only later while looking at the SCMI Pinctrl driver... ...Get rid of this and please make these conversions in the SCMI pinctrl driver NOT here in the protocol layer....these ops should receive SCMI valid requests and should not have any need to invoke some other subsystem helpers to pack/unpack. See below.. > +#include > +#include [snip] > + > +static int scmi_pinctrl_config_set(const struct scmi_protocol_handle *ph, > + u32 selector, > + enum scmi_pinctrl_selector_type type, > + unsigned long *configs, unsigned int nr_configs) > +{ > + struct scmi_xfer *t; > + struct scmi_msg_conf_set *tx; > + u32 attributes; > + int ret, i; > + unsigned int configs_in_chunk, conf_num = 0; > + unsigned int chunk; > + int max_msg_size = ph->hops->get_max_msg_size(ph); > + > + if (!configs || type == FUNCTION_TYPE) > + return -EINVAL; > + > + ret = scmi_pinctrl_validate_id(ph, selector, type); > + if (ret) > + return ret; > + > + configs_in_chunk = (max_msg_size - sizeof(*tx)) / (sizeof(unsigned long) * 2); ^^ sizeof(__le32)) > + while (conf_num < nr_configs) { > + chunk = (nr_configs - conf_num > configs_in_chunk) ? configs_in_chunk : > + nr_configs - conf_num; > + > + ret = ph->xops->xfer_get_init(ph, PINCTRL_CONFIG_SET, > + sizeof(*tx) + chunk * 2 * sizeof(unsigned long), ^^ sizeof(__le32)) > + 0, &t); > + if (ret) > + return ret; > + > + tx = t->tx.buf; > + tx->identifier = cpu_to_le32(selector); > + attributes = FIELD_PREP(GENMASK(1, 0), type) | > + FIELD_PREP(GENMASK(9, 2), chunk); > + tx->attributes = cpu_to_le32(attributes); > + > + for (i = 0; i < chunk; i++) { > + tx->configs[i * 2] = cpu_to_le32(pinconf_to_config_param(configs[i])); This should be the bare config_type as received already in SCMI format as a param. > + tx->configs[i * 2 + 1] = > + cpu_to_le32(pinconf_to_config_argument(configs[i])); and here the config_values...this also means you will have to change the parameters to this function to pass a uint8_t *config_types uint32_t *config_values unsigne int num_configs or something like that....there is also a subtle need to remap the types from Pinctrl to SCMI in the pinctrl SCMI driver (I commented this on that patch) Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel