Skip to contentSkip to conversation

firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support

RFC Superseded Oleksii Moisieiev 7 participants 26 messages Oct 27, 2023 – Nov 14, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v5 cover firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support

This RFC includes implementation of the new config_{get,set} according to the latest version of DEN0056E document (v3.2 beta2). Current RFC series covers the implementation of the SCMI protocol functions without integration to the pinctrl driver, which is under development. Please review changes to start the review process before I'll be ready to post complete v5 version.

This Patch series is intended to introduce the generic driver for
pin controls over SCMI protocol, provided in the latest beta version of DEN0056 [0].

On ARM-based systems, a separate Cortex-M based System Control Processor (SCP) provides control on pins, as well as with power, clocks, reset controllers. In this case, kernel should use one of the possible transports, described in [0] to access SCP and control clocks/power-domains etc. This driver is using SMC transport to communicate with SCP via SCMI protocol and access to the Pin Control Subsystem.

The provided driver consists of 2 parts:
- firmware/arm_scmi/pinctrl.c - the SCMI pinctrl protocol inmplementation responsible for the communication with SCP firmware.

- drivers/pinctrl/pinctrl-scmi.c - pinctrl driver, which is using pinctrl protocol implementation to access all necessary data.

Configuration:
The scmi-pinctrl driver can be configured using DT bindings. For example:

/ {
	cpu_scp_shm: scp-shmem@0x53FF0000 {
		compatible = "arm,scmi-shmem";
		reg = <0x0 0x53FF0000 0x0 0x1000>;
	};

	firmware {
		scmi {
			compatible = "arm,scmi-smc";
			arm,smc-id = <0x82000002>;
			shmem = <&cpu_scp_shm>;
			#address-cells = <1>;
			#size-cells = <0>;

			scmi_pinctrl: protocol@19 {
				reg = <0x18>;
				#pinctrl-cells = <0>;

				i2c2_pins: i2c2 {
					groups = "i2c2_a";
					function = "i2c2";
				};
			};
		};
	};
};
&pfc {
	/delete-node/i2c2;
};

So basically, it's enough to move pfc subnode, which configures pin group that should work through SCMI protocol to scmi_pinctrl node. The current driver implementation is using generic pinctrl dt_node format.

I've tested this driver on the Renesas H3ULCB Kingfisher board with pinctrl driver ported to the Arm-trusted-firmware. Unfortunately, not all hardware was possible to test because the Renesas pinctrl driver has gaps in pins and groups numeration, when Spec [0] requires pins, groups and functions numerations to be 0..n without gaps.

Also, sharing link to the ATF pinctrl driver I used for testing:
https://github.com/oleksiimoisieiev/arm-trusted-firmware/tree/pinctrl_rcar_m3_up

[0] https://developer.arm.com/documentation/den0056/latest

---
Changes v4 -> v5
- add new calls to scmi_protocol description for config_{get,set}
Changes v3 -> v4:
- Fixed MAINTAINERS file description
- adjusted pinctrl ops position and callback names
- add trailing coma in scmi_protocol list
- removed unneeded pi checks
- corrected selector check
- resource allocation refactoring
- scmi_*_info swap params to generate better code
- style, add trailing coma in definitions
- reworked protocol@19 format in device-tree bindings
- ordered config option and 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

Changes v2 -> v3:
- update get_name calls as suggested by Cristian Marussi
- fixing comments
- refactoring of the dt_bindings according to the comments
Changes v1 -> v2:
- rebase patches to the latest kernel version
- use protocol helpers in the pinctrl scmi protocol driver implementation
- reworked pinctrl_ops. Removed similar calls to simplify the interface
- implementation of the .instance_deinit callback to properly clean resources
- add description of the pinctrl protocol to the device-tree schema

---
Cristian Marussi (1):
firmware: arm_scmi: Add optional flags to extended names helper

Oleksii Moisieiev (4):
drivers: firmware: scmi: Introduce scmi_get_max_msg_size function
firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support
pinctrl: Implementation of the generic scmi-pinctrl driver
dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

 .../bindings/firmware/arm,scmi.yaml           |  53 +
 MAINTAINERS                                   |   7 +
 drivers/firmware/arm_scmi/Makefile            |   2 +-
 drivers/firmware/arm_scmi/clock.c             |   2 +-
 drivers/firmware/arm_scmi/common.h            |   3 +
 drivers/firmware/arm_scmi/driver.c            |  25 +-
 drivers/firmware/arm_scmi/perf.c              |   3 +-
 drivers/firmware/arm_scmi/pinctrl.c           | 922 ++++++++++++++++++
 drivers/firmware/arm_scmi/power.c             |   2 +-
 drivers/firmware/arm_scmi/powercap.c          |   2 +-
 drivers/firmware/arm_scmi/protocols.h         |   4 +-
 drivers/firmware/arm_scmi/reset.c             |   3 +-
 drivers/firmware/arm_scmi/sensors.c           |   2 +-
 drivers/firmware/arm_scmi/voltage.c           |   2 +-
 drivers/pinctrl/Kconfig                       |  11 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/pinctrl-scmi.c                | 445 +++++++++
 include/linux/scmi_protocol.h                 |  47 +
 18 files changed, 1525 insertions(+), 11 deletions(-)
 create mode 100644 drivers/firmware/arm_scmi/pinctrl.c
 create mode 100644 drivers/pinctrl/pinctrl-scmi.c
Signature · 1 line
2.25.1
#1 lore raw

RFC v5 1/5 firmware: arm_scmi: Add optional flags to extended names helper

From: Cristian Marussi <[email protected]>

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.

---
 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(-)
drivers/firmware/arm_scmi/clock.c +1 -1
index 96060bf90a24..e6e087686e8c 100644
@@ -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))
drivers/firmware/arm_scmi/driver.c +5 -2
index e7d97b59963b..729201d8f935 100644
@@ -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);
drivers/firmware/arm_scmi/perf.c +2 -1
index ecf5c4de851b..d85d4a0e3605 100644
@@ -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;
 }
drivers/firmware/arm_scmi/power.c +1 -1
index 356e83631664..077767d6e902 100644
@@ -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);
 	}
 
drivers/firmware/arm_scmi/powercap.c +1 -1
index 83b90bde755c..e7ea9210aae1 100644
@@ -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;
drivers/firmware/arm_scmi/protocols.h +2 -1
index 78e1a01eb656..b3c6314bb4b8 100644
@@ -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,
drivers/firmware/arm_scmi/reset.c +2 -1
index e9afa8cab730..7217fd7c6afa 100644
@@ -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;
 }
drivers/firmware/arm_scmi/sensors.c +1 -1
index 0b5853fa9d87..9952a7bc6682 100644
@@ -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);
drivers/firmware/arm_scmi/voltage.c +1 -1
index eaa8d944926a..36e2df77738c 100644
@@ -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;
Signature · 1 line
2.25.1
#2 lore raw

Re: [RFC v5 1/5] firmware: arm_scmi: Add optional flags to extended names helper

Quoted 6 lines · Oleksii Moisieiev

From: Cristian Marussi <[email protected]>

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.

Hi,

this patch of mine contained a bug in v4, for which I sent you a fix a while ago to include; since the patch is unchanged in v5 the bug is still
there: I'll reply to this mail thread with a new version of the whole patch that indeed will be easier to include in your series instead of this current buggy version.

Thanks,
Cristian

#3 lore raw

PATCH 1/1 firmware: arm_scmi: Add optional flags to extended names helper

In reply to Oleksii Moisieiev

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.

---
 drivers/firmware/arm_scmi/clock.c     |  2 +-
 drivers/firmware/arm_scmi/driver.c    | 12 ++++++++----
 drivers/firmware/arm_scmi/perf.c      |  2 +-
 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, 18 insertions(+), 12 deletions(-)
drivers/firmware/arm_scmi/clock.c +1 -1
index 96060bf90a24..e6e087686e8c 100644
@@ -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))
drivers/firmware/arm_scmi/driver.c +8 -4
index 87383c05424b..7c7545dea8c6 100644
@@ -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,19 +1446,22 @@ 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;
+	size_t txlen;
 	struct scmi_xfer *t;
 	struct scmi_msg_resp_domain_name_get *resp;
 
-	ret = ph->xops->xfer_get_init(ph, cmd_id, sizeof(res_id),
-				      sizeof(*resp), &t);
+	txlen = !flags ? sizeof(res_id) : sizeof(res_id) + sizeof(*flags);
+	ret = ph->xops->xfer_get_init(ph, cmd_id, txlen, sizeof(*resp), &t);
 	if (ret)
 		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);
drivers/firmware/arm_scmi/perf.c +1 -1
index c0cd556fbaae..0902b32dcecd 100644
@@ -288,7 +288,7 @@ 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,
-					    dom_info->id, dom_info->name,
+					    dom_info->id, NULL, dom_info->name,
 					    SCMI_MAX_STR_SIZE);
 
 	if (dom_info->level_indexing_mode) {
drivers/firmware/arm_scmi/power.c +1 -1
index 356e83631664..077767d6e902 100644
@@ -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);
 	}
 
drivers/firmware/arm_scmi/powercap.c +1 -1
index 244929cb4f3e..86c9a0b5a765 100644
@@ -270,7 +270,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;
drivers/firmware/arm_scmi/protocols.h +2 -1
index 78e1a01eb656..b3c6314bb4b8 100644
@@ -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,
drivers/firmware/arm_scmi/reset.c +2 -1
index e9afa8cab730..7217fd7c6afa 100644
@@ -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;
 }
drivers/firmware/arm_scmi/sensors.c +1 -1
index 0b5853fa9d87..9952a7bc6682 100644
@@ -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);
drivers/firmware/arm_scmi/voltage.c +1 -1
index eaa8d944926a..36e2df77738c 100644
@@ -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;
Signature · 7 lines
2.42.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw

Re: [PATCH] firmware: arm_scmi: Add optional flags to extended names helper

Quoted 4 lines · 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.

Hi Oleksii,

I posted this independently from your series:

https://lore.kernel.org/lkml/[email protected]

(and forgot to CC you :< ...)

Thanks,
Cristian

Quoted 161 lines
---
 drivers/firmware/arm_scmi/clock.c     |  2 +-
 drivers/firmware/arm_scmi/driver.c    | 12 ++++++++----
 drivers/firmware/arm_scmi/perf.c      |  2 +-
 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, 18 insertions(+), 12 deletions(-)
drivers/firmware/arm_scmi/clock.c +1 -1
index 96060bf90a24..e6e087686e8c 100644
@@ -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))
drivers/firmware/arm_scmi/driver.c +8 -4
index 87383c05424b..7c7545dea8c6 100644
@@ -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,19 +1446,22 @@ 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;
+	size_t txlen;
 	struct scmi_xfer *t;
 	struct scmi_msg_resp_domain_name_get *resp;
 
-	ret = ph->xops->xfer_get_init(ph, cmd_id, sizeof(res_id),
-				      sizeof(*resp), &t);
+	txlen = !flags ? sizeof(res_id) : sizeof(res_id) + sizeof(*flags);
+	ret = ph->xops->xfer_get_init(ph, cmd_id, txlen, sizeof(*resp), &t);
 	if (ret)
 		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);
drivers/firmware/arm_scmi/perf.c +1 -1
index c0cd556fbaae..0902b32dcecd 100644
@@ -288,7 +288,7 @@ 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,
-					    dom_info->id, dom_info->name,
+					    dom_info->id, NULL, dom_info->name,
 					    SCMI_MAX_STR_SIZE);
 
 	if (dom_info->level_indexing_mode) {
drivers/firmware/arm_scmi/power.c +1 -1
index 356e83631664..077767d6e902 100644
@@ -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);
 	}
 
drivers/firmware/arm_scmi/powercap.c +1 -1
index 244929cb4f3e..86c9a0b5a765 100644
@@ -270,7 +270,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;
drivers/firmware/arm_scmi/protocols.h +2 -1
index 78e1a01eb656..b3c6314bb4b8 100644
@@ -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,
drivers/firmware/arm_scmi/reset.c +2 -1
index e9afa8cab730..7217fd7c6afa 100644
@@ -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;
 }
drivers/firmware/arm_scmi/sensors.c +1 -1
index 0b5853fa9d87..9952a7bc6682 100644
@@ -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);
drivers/firmware/arm_scmi/voltage.c +1 -1
index eaa8d944926a..36e2df77738c 100644
@@ -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;
Signature · 1 line
2.42.0

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

RFC v5 2/5 drivers: firmware: scmi: Introduce scmi_get_max_msg_size function

In reply to Oleksii Moisieiev

Current SCMI implementation supports only receiving arrays from the SCMI server and provides helpers to process received data. It uses msg_max_size value to determine maximum message size that can be transmitted via selected protocol. When sending arrays to SCMI server this value should be checked by the Client driver to prevent overflowing protocol buffers.
That's why scmi_get_max_msg_size call was introduced.

---
 drivers/firmware/arm_scmi/common.h |  3 +++
 drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/firmware/arm_scmi/common.h +3 -0
index c46dc5215af7..3db97f59bc59 100644
@@ -286,6 +286,9 @@ int scmi_xfer_raw_inflight_register(const struct scmi_handle *handle,
 int scmi_xfer_raw_wait_for_message_response(struct scmi_chan_info *cinfo,
 					    struct scmi_xfer *xfer,
 					    unsigned int timeout_ms);
+
+int scmi_get_max_msg_size(const struct scmi_protocol_handle *ph);
+
 #ifdef CONFIG_ARM_SCMI_TRANSPORT_MAILBOX
 extern const struct scmi_desc scmi_mailbox_desc;
 #endif
drivers/firmware/arm_scmi/driver.c +16 -0
index 729201d8f935..f15e9b2b21f3 100644
@@ -1152,6 +1152,22 @@ int scmi_xfer_raw_wait_for_message_response(struct scmi_chan_info *cinfo,
 	return ret;
 }
 
+/**
+ * scmi_get_max_msg_size  - An helper to get currently configured
+ * maximum message size.
+ *
+ * @ph: SCMI protocol handle
+ *
+ * Return: Maximum message size for the current protocol.
+ */
+int scmi_get_max_msg_size(const struct scmi_protocol_handle *ph)
+{
+	const struct scmi_protocol_instance *pi = ph_to_pi(ph);
+	struct scmi_info *info = handle_to_scmi_info(pi->handle);
+
+	return info->desc->max_msg_size;
+}
+
 /**
  * do_xfer() - Do one transfer
  *
Signature · 1 line
2.25.1
#6 lore raw

Re: [RFC v5 2/5] drivers: firmware: scmi: Introduce scmi_get_max_msg_size function

Quoted 8 lines · Oleksii Moisieiev

Current SCMI implementation supports only receiving arrays from the SCMI server and provides helpers to process received data. It uses msg_max_size value to determine maximum message size that can be transmitted via selected protocol. When sending arrays to SCMI server this value should be checked by the Client driver to prevent overflowing protocol buffers.
That's why scmi_get_max_msg_size call was introduced.

Hi Oleksii,

indeed given the new variable sized v3.2 SCMI requests (instead of responses) this common helper is now needed for the protocols to be able to properly size and chunk their command requests, BUT this is a new core helper that has potentially to be available to any future protocol so it has to be exposed as a common helpers in helpers_ops (like iterators or extended_name helpers), if NOT this common method won't be available to protocols when compiled as distinct loadable modules (vendor-modules can be defined and built as LKM)

Thanks,
Cristian

#7 lore raw

Re: [RFC v5 2/5] drivers: firmware: scmi: Introduce scmi_get_max_msg_size function

Hi Cristian,

Just found an interesting note in the PINCTRL_CONFIG_SET command description:

The maximum value of this field is limited by
the transport used. The agent needs to specify
this field such that the entire command can be
accommodated within the transport chosen.

Furthermore, I observed the absence of a skip_configs parameter.

From my understanding, this implies that the maximum number of
configurations should not exceed the msg_max_size allowed by the protocol, enabling the transmission of only one message to the SCMI server at a time.

Given this constraint, it seems we might not require additional helper functions. We could potentially just verify against msg_max_size.

Best regards,
Oleksii

Quoted 24 lines · Cristian Marussi
Quoted 8 lines · Oleksii Moisieiev

Current SCMI implementation supports only receiving arrays from the SCMI server and provides helpers to process received data. It uses msg_max_size value to determine maximum message size that can be transmitted via selected protocol. When sending arrays to SCMI server this value should be checked by the Client driver to prevent overflowing protocol buffers.
That's why scmi_get_max_msg_size call was introduced.

Hi Oleksii,

indeed given the new variable sized v3.2 SCMI requests (instead of responses) this common helper is now needed for the protocols to be able to properly size and chunk their command requests, BUT this is a new core helper that has potentially to be available to any future protocol so it has to be exposed as a common helpers in helpers_ops (like iterators or extended_name helpers), if NOT this common method won't be available to protocols when compiled as distinct loadable modules (vendor-modules can be defined and built as LKM)

Thanks,
Cristian

#8 lore raw

Re: [RFC v5 2/5] drivers: firmware: scmi: Introduce scmi_get_max_msg_size function

Quoted 2 lines · Oleksii Moisieiev

Hi Cristian,

Hi,

Quoted 8 lines

Just found an interesting note in the PINCTRL_CONFIG_SET command description:

The maximum value of this field is limited by
the transport used. The agent needs to specify
this field such that the entire command can be
accommodated within the transport chosen.

Yes I am aware of that.

Quoted 7 lines

Furthermore, I observed the absence of a skip_configs parameter.

From my understanding, this implies that the maximum number of
configurations should not exceed the msg_max_size allowed by the protocol, enabling the transmission of only one message to the SCMI server at a time.

Yes that is correct, my understanding is that the transmitter is in charge of building a message whose payload can fit into the maximum message size allowed by the underlying configured transport.

Quoted 3 lines

Given this constraint, it seems we might not require additional helper functions. We could potentially just verify against msg_max_size.

Indeed for that reason the scmi_get_max_msg_size that you introduced is just enough since it allows you to peek into the transport and get the max_msg_size...the misunderstanding is around the fact that I was simply meaning that you should plug it into some new helper_ops so that yo can call it like:

  max_msg = ph->hops->get_max_msg_size(ph);

(like iterators or get_extended_name)

Because in this way you could use it also when the protocol is build as a loadable module, thing that now it is possible only for vendor defined protocols, but we could also easily switch all the base protocols to be selectable via Kconfig and =m in the future (if ever)

Your helper is fine by itself it is just that it cannot be called by a protocol defined to loaded as a module because the symbol is not exported and, indeed, we introduced the ph->hops thing just for this reason, i.e. to have a set of common protocol utilities that can be called even from loadable modules protocols without the need to export every single symbol.

The reference to iterators and extended_name was misleading probably...my bad...or I am still missing something :D

Thanks,
Cristian

#9 lore raw

RFC v5 3/5 firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support

In reply to Oleksii Moisieiev

Add basic implementation of the SCMI v3.2 pincontrol protocol.

---
Changes v4 -> v5
- add new calls to scmi_protocol description for config_{get,set}
Changes v3 -> v4
- Fixed MAINTAINERS file description
- adjusted pinctrl ops position and callback names
- add trailing coma in scmi_protocol list
- removed unneeded pi checks
- corrected selector check
- resource allocation refactoring
- scmi_*_info swap params to generate better code
- style, add trailing coma in definitions

---
 MAINTAINERS                           |   6 +
 drivers/firmware/arm_scmi/Makefile    |   2 +-
 drivers/firmware/arm_scmi/driver.c    |   2 +
 drivers/firmware/arm_scmi/pinctrl.c   | 922 ++++++++++++++++++++++++++
 drivers/firmware/arm_scmi/protocols.h |   1 +
 include/linux/scmi_protocol.h         |  47 ++
 6 files changed, 979 insertions(+), 1 deletion(-)
 create mode 100644 drivers/firmware/arm_scmi/pinctrl.c
MAINTAINERS +6 -0
index 0dab9737ec16..2d81d00e5f4f 100644
@@ -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 <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/firmware/arm_scmi/pinctrl.c
+
 SYSTEM RESET/SHUTDOWN DRIVERS
 M:	Sebastian Reichel <[email protected]>
 L:	[email protected]
drivers/firmware/arm_scmi/Makefile +1 -1
index b31d78fa66cc..603430ec0bfe 100644
@@ -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
drivers/firmware/arm_scmi/driver.c +2 -0
index f15e9b2b21f3..31a0da37eeb3 100644
@@ -3040,6 +3040,7 @@ static int __init scmi_driver_init(void)
 	scmi_voltage_register();
 	scmi_system_register();
 	scmi_powercap_register();
+	scmi_pinctrl_register();
 
 	return platform_driver_register(&scmi_driver);
 }
@@ -3057,6 +3058,7 @@ static void __exit scmi_driver_exit(void)
 	scmi_voltage_unregister();
 	scmi_system_unregister();
 	scmi_powercap_unregister();
+	scmi_pinctrl_unregister();
 
 	scmi_transports_exit();
 
drivers/firmware/arm_scmi/pinctrl.c new file +922 -0

922 lines not on this page · raw message

drivers/firmware/arm_scmi/protocols.h +1 -0
index b3c6314bb4b8..674f949354f9 100644
@@ -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 */
include/linux/scmi_protocol.h +47 -0

59 lines not on this page · raw message

Signature · 1 line
2.25.1
#10 lore raw
Quoted 4 lines · Oleksii Moisieiev

Add basic implementation of the SCMI v3.2 pincontrol protocol.

---

Hi Oleksii,

the new get/set v3.2 implementation seems finer to me at first sight. I'll try to test this next days and give you more feedback.

Thanks,
Cristian

#11 lore raw
Quoted 10 lines · Cristian Marussi
Quoted 4 lines · Oleksii Moisieiev

Add basic implementation of the SCMI v3.2 pincontrol protocol.

---

Hi Oleksii,

the new get/set v3.2 implementation seems finer to me at first sight. I'll try to test this next days and give you more feedback.

I don't think that this version addresses my comment yet:

https://lkml.iu.edu//hypermail/linux/kernel/2308.2/07483.html

I hope that it will be fixed in your *final* v5.

-Takahiro Akashi

Quoted 2 lines

Thanks,
Cristian

#12 lore raw
Quoted 9 lines · AKASHI Takahiro
Quoted 8 lines · Cristian Marussi
Quoted 4 lines · Oleksii Moisieiev

Add basic implementation of the SCMI v3.2 pincontrol protocol.

---

Hi Oleksii,

Quoted 8 lines
Quoted 2 lines

the new get/set v3.2 implementation seems finer to me at first sight. I'll try to test this next days and give you more feedback.

I don't think that this version addresses my comment yet:

https://lkml.iu.edu//hypermail/linux/kernel/2308.2/07483.html

I hope that it will be fixed in your *final* v5.

Oops, this comment should better go against patch#4/5.

Quoted 4 lines

-Takahiro Akashi

Quoted 2 lines

Thanks,
Cristian

#13 lore raw

RFC v5 4/5 pinctrl: Implementation of the generic scmi-pinctrl driver

In reply to Oleksii Moisieiev

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.

---
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 | 445 +++++++++++++++++++++++++++++++++
 4 files changed, 458 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-scmi.c
MAINTAINERS +1 -0
index 2d81d00e5f4f..c4e36f955e53 100644
@@ -20527,6 +20527,7 @@ M:	Oleksii Moisieiev <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	drivers/firmware/arm_scmi/pinctrl.c
+F:	drivers/pinctrl/pinctrl-scmi.c
 
 SYSTEM RESET/SHUTDOWN DRIVERS
 M:	Sebastian Reichel <[email protected]>
drivers/pinctrl/Kconfig +11 -0
index 5787c579dcf6..956cfe76fbc6 100644
@@ -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
drivers/pinctrl/Makefile +1 -0
index e196c6e324ad..25d67bac9ee0 100644
@@ -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
drivers/pinctrl/pinctrl-scmi.c new file +445 -0

445 lines not on this page · raw message

Signature · 1 line
2.25.1
#14 lore raw

RFC v5 5/5 dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

In reply to Oleksii Moisieiev

Add new SCMI v3.2 pinctrl protocol bindings definitions and example.

---
Changes v3 -> v4
- reworked protocol@19 format

---
 .../bindings/firmware/arm,scmi.yaml           | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +53 -0
index 5824c43e9893..5318fe72354e 100644
@@ -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;
+                };
+            };
         };
     };
 
Signature · 1 line
2.25.1
#15 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Quoted 16 lines · Oleksii Moisieiev

Add new SCMI v3.2 pinctrl protocol bindings definitions and example.

---
Changes v3 -> v4
- reworked protocol@19 format

---
 .../bindings/firmware/arm,scmi.yaml           | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +0 -0
index 5824c43e9893..5318fe72354e 100644

Documentation/devicetree/bindings/firmware/arm,scmi.yaml properties: · line 240

Quoted 8 lines
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +5 -0
@@ -233,6 +233,39 @@ properties:
       reg:
         const: 0x18
 
+  protocol@19:
+    type: object
+    allOf:
+      - $ref: "#/$defs/protocol-node"
+      - $ref: "../pinctrl/pinctrl.yaml"

This is a friendly reminder during the review process.

It seems my previous comments were not fully addressed. Maybe my feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.

Thank you.

It does not look like you tested the bindings, at least after quick look. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions). Maybe you need to update your dtschema and yamllint.

Best regards,
Krzysztof

#16 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Quoted 28 lines · Krzysztof Kozlowski
Quoted 16 lines · Oleksii Moisieiev

Add new SCMI v3.2 pinctrl protocol bindings definitions and example.

---
Changes v3 -> v4
- reworked protocol@19 format

---
  .../bindings/firmware/arm,scmi.yaml           | 53 +++++++++++++++++++
  1 file changed, 53 insertions(+)
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +0 -0
index 5824c43e9893..5318fe72354e 100644

Documentation/devicetree/bindings/firmware/arm,scmi.yaml properties: · line 240

Quoted 8 lines
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +5 -0
@@ -233,6 +233,39 @@ properties:
        reg:
          const: 0x18
 
+  protocol@19:
+    type: object
+    allOf:
+      - $ref: "#/$defs/protocol-node"
+      - $ref: "../pinctrl/pinctrl.yaml"

This is a friendly reminder during the review process.

Quoted 6 lines

It seems my previous comments were not fully addressed. Maybe my feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.

Thank you.

Hi Krzysztof,

I'm sorry for the inconvenience.
The intention behind sharing this RFC was to initiate the review process for the changes I've been making to the pinctrl driver, aligning it with the updates in the DEN0056E beta2 document.

I am still actively working on these changes, and I fully intend to address and resolve the binding issues and all previously mentioned comments in the final v5 patch series.

Best regards,
Oleksii.

Quoted 10 lines

It does not look like you tested the bindings, at least after quick look. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions). Maybe you need to update your dtschema and yamllint.

Best regards,
Krzysztof

maintainer
#17 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

In reply to Oleksii Moisieiev
Quoted 11 lines · Oleksii Moisieiev

Add new SCMI v3.2 pinctrl protocol bindings definitions and example.

---
Changes v3 -> v4
- reworked protocol@19 format

---
 .../bindings/firmware/arm,scmi.yaml           | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/firmware/arm,scmi.yaml:244:15: [error] string value is redundantly quoted with any quotes (quoted-strings) ./Documentation/devicetree/bindings/firmware/arm,scmi.yaml:258:19: [error] string value is redundantly quoted with any quotes (quoted-strings) ./Documentation/devicetree/bindings/firmware/arm,scmi.yaml:259:19: [error] string value is redundantly quoted with any quotes (quoted-strings)

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/e9285b4377242e4d888391be987cbb99caf8c573.1698353854.git.oleksii_moisieiev@epam.com

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#18 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

In reply to Oleksii Moisieiev

Documentation/devicetree/bindings/firmware/arm,scmi.yaml examples: · line 438

Quoted 4 lines · Oleksii Moisieiev
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +4 -0
+                keys_pins: keys-pins {
+                    pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
+                    bias-pull-up;
+                };

This is kind of interesting and relates to my question about naming groups and functions of GPIO pins.

Here we see four pins suspiciously named "GP_*" which I read as "generic purpose"
and they are not muxed to *any* function, yes pulled up.

I would have expected something like:

keys_pins: keys-pins {
groups = "GP_5_17_grp", "GP_5_20_grp", "GP_5_22_grp", "GP_2_1_grp"; function = "gpio";
pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1"; bias-pull-up;
};

I hope this illustrates what I see as a problem in not designing in GPIO as an explicit
function, I get the impression that these pins are GPIO because it is hardware default.

Yours,
Linus Walleij

#19 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Hi Arm folks,

Do you have any comment?
I expect that you have had some assumption when you defined SCMI pinctrl protocol specification.

Quoted 24 lines · Linus Walleij

Documentation/devicetree/bindings/firmware/arm,scmi.yaml examples: · line 438

Quoted 4 lines · On Fri, Oct 27, 2023 at 8:28???AM Oleksii Moisieiev…
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +4 -0
+                keys_pins: keys-pins {
+                    pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
+                    bias-pull-up;
+                };

This is kind of interesting and relates to my question about naming groups and functions of GPIO pins.

Here we see four pins suspiciously named "GP_*" which I read as "generic purpose"
and they are not muxed to *any* function, yes pulled up.

I would have expected something like:

keys_pins: keys-pins {
groups = "GP_5_17_grp", "GP_5_20_grp", "GP_5_22_grp", "GP_2_1_grp"; function = "gpio";
pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1"; bias-pull-up;
};

Quoted 4 lines

I hope this illustrates what I see as a problem in not designing in GPIO as an explicit
function, I get the impression that these pins are GPIO because it is hardware default.

If you want to stick to "explicit", we may rather introduce a pre-defined sub-node name, "gpio", in a device tree binding, i.e.

protocol@19 { // pinctrl protocol

      ... // other pinmux nodes

      scmi_gpio: gpio { // "gpio" is a fixed name
          keys-pins {
              pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
              bias-pull-up;
              // possibly input or output
          };
          input-pins {
              groups = "some group"; // any name
              input-mode;
          }
          output-pins {
              pins = "foo1", "foo2"; // any name
              output-mode;
          }
      }

}

It would indicate that all the succeeding nodes are for gpio definitions and *virtual* gpio pin numbers will be assigned in the order of appearances in "gpio" node. Then a client driver may refer to a gpio pin (say, GP_2_1?) like in the current manner:

  foo_device {
       ...
       reset-gpios = <&scmi_gpio 3 ...>;
  }

-Takahiro Akashi

Quoted 3 lines

Yours,
Linus Walleij

#20 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Quoted 7 lines · Takahiro Akashi

Hi Arm folks,

Do you have any comment?
I expect that you have had some assumption when you defined SCMI pinctrl protocol specification.

[CC Souvik]

@Souvik for context see:
https://lore.kernel.org/all/CACRpkdZ4GborirSpa3GK_PwMgCvY0ePEmZO+CwnLcP6nAdieow@mail.gmail.com/

Hi,

I am not sure what is the full story here, BUT the spec was mainly aimed at supporting PINCTRL in SCMI with the idea to then, later on, base GPIO on top of it, "easily" building on the PINCTRL spec features in the future with a separate series from the one Oleksii is working on...but it like seems the future is already here and maybe we have discovered something to be clarified...

Souvik/Oleksii can tell you better what were (if any) further assumptions related to GPIO on top on SCMI/PINCTRL, but the aim of this series was always to be just the basic Generic Pinctrl support when dealing with an SCMI server backend.

Regarding the current Pinctrl series by Oleksii, I would also notice that, indeed, some "non-spec-dictated" naming assumptions are ALREADY present somehow, because, currently, the spec and the pinctrl SCMI protocol layer speak/refer about pins/groups/functions, as usual, only in terms of numeric identifiers/IDs (with an associated name of course), while the pinctrl driver (thanks to the Linux pictrl subsystem layer) describes and refers anything in the DT in terms of names: so all of this really works only because the names used in the DT happen to match the names reported by the backend server.

My test DT uses just what Oleksii exemplified in the cover letter:

	pinctrl_i2c2: i2c2 {
		groups = "i2c2_a", "i2c2_b";
                function = "i2c2";
        };

	pinctrl_mdio: pins_mdio {
		groups = "avb_mdio";
                drive-strength = <24>;
        };

        keys_pins: keys {
		pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
                bias-pull-up;
        };

with a dummmy test driver referring to it, so as to trigger the drivers core to initialize the pinctrl stuff.

But all of this works just because, in the example of my emulated setup, my fake server exposes resources that are exactly named just as how the above DT expects pins/functions/pins to be named, because this is how the Generic Pinctrl subsystem in Linux is supposed to work, right ?

The difference is that the names, in the case of pinctrl-scmi, are not hardcoded in the specific pin-controller driver BUT are provided dynamically by the SCMI server at runtime.

And this is just a naming convention, between the Linux picntrl subsys AND the SCMI server, that allows the Linux Pinctrl subsys to map, under-hood, names to type/IDs as expected by the SCMI protocol layer (and by the spec):
so when you will define and describe a real platform with a DT, you will will have to provide your name references, knowing that the shipped platform SCMI fw will advertise exactly the same (or a superset of them)

As such, personally, I would find reasonable to use, equally, some conventional function name like 'gpio' to advertise and configure groups of pins as being used as GPIOs.

Maybe, though, both of these expected naming comventions should be explicitly stated in the spec: indeed if you look at some Sensor protocol extensions added in v3.0, in 4.7.2.5.1 "Sensor Axis Descriptors" regarding naming we say:

"It is recommended that the name ends with ‘_’ followed by the axis of the sensor in uppercase. For example, the name for the x-axis of a triaxial accelerometer could be “acc_X” or “_X”."

...so maybe some similar remarks could be added here.

Souvik is really the one who can have a say about the opportunity (or not) of these kind of explicit advised naming conventions on the spec, so I have CCed him.

Quoted 51 lines · Linus Walleij
Quoted 24 lines

Documentation/devicetree/bindings/firmware/arm,scmi.yaml examples: · line 438

Quoted 4 lines · On Fri, Oct 27, 2023 at 8:28???AM Oleksii Moisieiev…
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +4 -0
+                keys_pins: keys-pins {
+                    pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
+                    bias-pull-up;
+                };

This is kind of interesting and relates to my question about naming groups and functions of GPIO pins.

Here we see four pins suspiciously named "GP_*" which I read as "generic purpose"
and they are not muxed to *any* function, yes pulled up.

I would have expected something like:

keys_pins: keys-pins {
groups = "GP_5_17_grp", "GP_5_20_grp", "GP_5_22_grp", "GP_2_1_grp"; function = "gpio";
pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1"; bias-pull-up;
};

Quoted 4 lines

I hope this illustrates what I see as a problem in not designing in GPIO as an explicit
function, I get the impression that these pins are GPIO because it is hardware default.

If you want to stick to "explicit", we may rather introduce a pre-defined sub-node name, "gpio", in a device tree binding, i.e.

protocol@19 { // pinctrl protocol

      ... // other pinmux nodes

      scmi_gpio: gpio { // "gpio" is a fixed name
          keys-pins {
              pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
              bias-pull-up;
              // possibly input or output
          };
          input-pins {
              groups = "some group"; // any name
              input-mode;
          }
          output-pins {
              pins = "foo1", "foo2"; // any name
              output-mode;
          }
      }
Quoted 2 lines

}

I suppose your proposal of a specially named "gpio" node would be another way, BUT it would also mean describing something in the DT that could be discoverable dynamically querying the server (while making the above assumptions about conventions).

Thanks,
Cristian

#21 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Hi,

Quoted 23 lines · Cristian Marussi
Quoted 7 lines · Takahiro Akashi

Hi Arm folks,

Do you have any comment?
I expect that you have had some assumption when you defined SCMI pinctrl protocol specification.

[CC Souvik]

@Souvik for context see:
https://lore.kernel.org/all/CACRpkdZ4GborirSpa3GK_PwMgCvY0ePEmZO+CwnLcP6nAdieow@mail.gmail.com/

Hi,

I am not sure what is the full story here, BUT the spec was mainly aimed at supporting PINCTRL in SCMI with the idea to then, later on, base GPIO on top of it, "easily" building on the PINCTRL spec features in the future with a separate series from the one Oleksii is working on...but it like seems the future is already here and maybe we have discovered something to be clarified...

Quoted 4 lines

Souvik/Oleksii can tell you better what were (if any) further assumptions related to GPIO on top on SCMI/PINCTRL, but the aim of this series was always to be just the basic Generic Pinctrl support when dealing with an SCMI server backend.

The initial assumption always was that GPIOs can be considered as a specific function. Note that the spec does not define the types of function and leaves it to the DT binding (or driver) to figure out the function descriptions/names.

Quoted 48 lines

Regarding the current Pinctrl series by Oleksii, I would also notice that, indeed, some "non-spec-dictated" naming assumptions are ALREADY present somehow, because, currently, the spec and the pinctrl SCMI protocol layer speak/refer about pins/groups/functions, as usual, only in terms of numeric identifiers/IDs (with an associated name of course), while the pinctrl driver (thanks to the Linux pictrl subsystem layer) describes and refers anything in the DT in terms of names: so all of this really works only because the names used in the DT happen to match the names reported by the backend server.

My test DT uses just what Oleksii exemplified in the cover letter:

	pinctrl_i2c2: i2c2 {
		groups = "i2c2_a", "i2c2_b";
                 function = "i2c2";
         };

	pinctrl_mdio: pins_mdio {
		groups = "avb_mdio";
                 drive-strength = <24>;
         };

         keys_pins: keys {
		pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
                 bias-pull-up;
         };

with a dummmy test driver referring to it, so as to trigger the drivers core to initialize the pinctrl stuff.

But all of this works just because, in the example of my emulated setup, my fake server exposes resources that are exactly named just as how the above DT expects pins/functions/pins to be named, because this is how the Generic Pinctrl subsystem in Linux is supposed to work, right ?

The difference is that the names, in the case of pinctrl-scmi, are not hardcoded in the specific pin-controller driver BUT are provided dynamically by the SCMI server at runtime.

And this is just a naming convention, between the Linux picntrl subsys AND the SCMI server, that allows the Linux Pinctrl subsys to map, under-hood, names to type/IDs as expected by the SCMI protocol layer (and by the spec):
so when you will define and describe a real platform with a DT, you will will have to provide your name references, knowing that the shipped platform SCMI fw will advertise exactly the same (or a superset of them)

Quoted 3 lines

As such, personally, I would find reasonable to use, equally, some conventional function name like 'gpio' to advertise and configure groups of pins as being used as GPIOs.

As a general principle, we dont try to put naming conventions in the spec if it can be easily resolved via DT. If this is proving to be a hassle then we can "recommend" in the spec that pins which can only be GPIOs are named starting "GPIO". Similar for functions.

However looking at Linus' comments below, I am not sure we are at that stage yet?

Regards,
Souvik

Quoted 78 lines

Maybe, though, both of these expected naming comventions should be explicitly stated in the spec: indeed if you look at some Sensor protocol extensions added in v3.0, in 4.7.2.5.1 "Sensor Axis Descriptors" regarding naming we say:

"It is recommended that the name ends with ‘_’ followed by the axis of the sensor in uppercase. For example, the name for the x-axis of a triaxial accelerometer could be “acc_X” or “_X”."

...so maybe some similar remarks could be added here.

Souvik is really the one who can have a say about the opportunity (or not) of these kind of explicit advised naming conventions on the spec, so I have CCed him.

Quoted 44 lines · Linus Walleij
Quoted 24 lines

Documentation/devicetree/bindings/firmware/arm,scmi.yaml examples: · line 438

Quoted 4 lines · On Fri, Oct 27, 2023 at 8:28???AM Oleksii Moisieiev…
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +4 -0
+                keys_pins: keys-pins {
+                    pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
+                    bias-pull-up;
+                };

This is kind of interesting and relates to my question about naming groups and functions of GPIO pins.

Here we see four pins suspiciously named "GP_*" which I read as "generic purpose"
and they are not muxed to *any* function, yes pulled up.

I would have expected something like:

keys_pins: keys-pins {
   groups = "GP_5_17_grp", "GP_5_20_grp", "GP_5_22_grp", "GP_2_1_grp";
   function = "gpio";
   pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
   bias-pull-up;
};
Quoted 4 lines

I hope this illustrates what I see as a problem in not designing in GPIO as an explicit
function, I get the impression that these pins are GPIO because it is hardware default.

If you want to stick to "explicit", we may rather introduce a pre-defined sub-node name, "gpio", in a device tree binding, i.e.

   protocol@19 { // pinctrl protocol
       ... // other pinmux nodes

       scmi_gpio: gpio { // "gpio" is a fixed name
           keys-pins {
               pins = "GP_5_17", "GP_5_20", "GP_5_22", "GP_2_1";
               bias-pull-up;
               // possibly input or output
           };
           input-pins {
               groups = "some group"; // any name
Quoted 9 lines
               input-mode;
           }
           output-pins {
               pins = "foo1", "foo2"; // any name
               output-mode;
           }
       }
   }

I suppose your proposal of a specially named "gpio" node would be another way, BUT it would also mean describing something in the DT that could be discoverable dynamically querying the server (while making the above assumptions about conventions).

Thanks,
Cristian

#22 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Hi Souvik,

thanks for looking into this!

Quoted 4 lines · Souvik Chakravarty

The initial assumption always was that GPIOs can be considered as a specific function. Note that the spec does not define the types of function and leaves it to the DT binding (or driver) to figure out the function descriptions/names.

Does this mean that each system using pinctrl-SCMI will need to specify the available pins, groups and functions in a device tree binding? For e.g. DT validation using schema?

This creates the problem of where to put it since Documentation/devicetree/bindings/firmware/arm,scmi.yaml is all we have, and for schemas to be applicable the implicit assumption is that this is done per-compatible.

If we want to use device tree validation of the strings put into the pinctrl node we need to allow for a per-soc compatible under the pinctrl node like:

protocol@19 {
    compatible = "vendor,soc-scmi-pinctrl";

(...)

Then a DT schema can be made to match that and check it.

I'm uncertain about that because the SCMI binding has nothing like this at the moment, all the protocol nodes are pretty self-describing and don't seem to need any further configuration to be used, but pin control may be the first instance where we have to add some per-soc configuration into the protocol nodes :/

It's easy to do:

+ protocol@19:
+ type: object
+ allOf:
+ - $ref: "#/$defs/protocol-node"
+ - $ref: "../pinctrl/pinctrl.yaml"
+ unevaluatedProperties: false
+
+ properties:

compatible:
items:
- enum:
- vendor1,soc1-scmi-pinctrl
- vendor2,soc2-scmi-pinctrl
- vendor3,soc3-scmi-pinctrl

This should be enough for just establishing the different pin control configurations we can have in the device tree.

We are then able to put a more detailed schema for the specific SoC pin control, such as a list of valid groups and functions etc under the ordinary pinctrl bindings such as Documentation/devicetree/bindings/pinctrl/vendor1,soc1-scmi-pinctrl.yaml etc.

We should preferably put some pattern like this in place from day 1 so developers know what is expected here. A mock SoC is fine for the time being (we can delete it later when there are some serious ones).

I'm uncertain because it feels like a first thing, but I can't really think how it would work otherwise, part of me don't want to pollute the SCMI binding with any per-soc compatibles, but yet since these group and function strings will be per-soc I don't see any other way, if they are supposed to be validated with schema.

Yours,
Linus Walleij

#23 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Hi Linus,

Quoted 7 lines · Linus Walleij

Hi Souvik,

thanks for looking into this!

On Mon, Nov 13, 2023 at 1:56 PM Souvik Chakravarty <[email protected]> wrote:

Quoted 8 lines
Quoted 4 lines

The initial assumption always was that GPIOs can be considered as a specific function. Note that the spec does not define the types of function and leaves it to the DT binding (or driver) to figure out the function descriptions/names.

Does this mean that each system using pinctrl-SCMI will need to specify the available pins, groups and functions in a device tree binding? For e.g. DT validation using schema?

Sorry seems I made a typo above ("descriptions/names" should have been "description from names") which resulted in turning things on its head.

I really meant that the driver has to figure out the exact type or meaning of what the function does from its name. SCMI still continues to provide the list of pins/groups/functions and their names.

Regards,
Souvik

Quoted 63 lines

This creates the problem of where to put it since Documentation/devicetree/bindings/firmware/arm,scmi.yaml is all we have, and for schemas to be applicable the implicit assumption is that this is done per-compatible.

If we want to use device tree validation of the strings put into the pinctrl node we need to allow for a per-soc compatible under the pinctrl node like:

protocol@19 {
     compatible = "vendor,soc-scmi-pinctrl";

(...)

Then a DT schema can be made to match that and check it.

I'm uncertain about that because the SCMI binding has nothing like this at the moment, all the protocol nodes are pretty self-describing and don't seem to need any further configuration to be used, but pin control may be the first instance where we have to add some per-soc configuration into the protocol nodes :/

It's easy to do:

Documentation/devicetree/bindings/firmware/arm,scmi.yaml +8 -0
+  protocol@19:
+    type: object
+    allOf:
+      - $ref: "#/$defs/protocol-node"
+      - $ref: "../pinctrl/pinctrl.yaml"
+    unevaluatedProperties: false
+
+    properties:
 
         compatible:
             items:
               - enum:
                    - vendor1,soc1-scmi-pinctrl
                    - vendor2,soc2-scmi-pinctrl
                    - vendor3,soc3-scmi-pinctrl

This should be enough for just establishing the different pin control configurations we can have in the device tree.

We are then able to put a more detailed schema for the specific SoC pin control, such as a list of valid groups and functions etc under the ordinary pinctrl bindings such as Documentation/devicetree/bindings/pinctrl/vendor1,soc1-scmi-pinctrl.yaml etc.

We should preferably put some pattern like this in place from day 1 so developers know what is expected here. A mock SoC is fine for the time being (we can delete it later when there are some serious ones).

I'm uncertain because it feels like a first thing, but I can't really think how it would work otherwise, part of me don't want to pollute the SCMI binding with any per-soc compatibles, but yet since these group and function strings will be per-soc I don't see any other way, if they are supposed to be validated with schema.

Yours,
Linus Walleij

#24 lore raw

Re: [RFC v5 5/5] dt-bindings: firmware: arm,scmi: Add support for pinctrl protocol

Quoted 17 lines · Souvik Chakravarty
Quoted 7 lines · Linus Walleij

Hi Souvik,

thanks for looking into this!

On Mon, Nov 13, 2023 at 1:56 PM Souvik Chakravarty <[email protected]> wrote:

Quoted 8 lines
Quoted 4 lines

The initial assumption always was that GPIOs can be considered as a specific function. Note that the spec does not define the types of function and leaves it to the DT binding (or driver) to figure out the function descriptions/names.

Does this mean that each system using pinctrl-SCMI will need to specify the available pins, groups and functions in a device tree binding? For e.g. DT validation using schema?

Quoted 6 lines

Sorry seems I made a typo above ("descriptions/names" should have been "description from names") which resulted in turning things on its head.

I really meant that the driver has to figure out the exact type or meaning of what the function does from its name. SCMI still continues to provide the list of pins/groups/functions and their names.

Indeed, that's what I imagined.

I think the rest of my question spurred by the phrase "leaves it to the DT binding (or driver) to figure out" is actually something Oleksii needs to look into more than a question to you.

It should probably come as a review comment to the patch 5/5 itself.

Oleksii, what is your take on my question about DT schema validation for different SoCs?

Yours,
Linus Walleij

#25 lore raw
In reply to Oleksii Moisieiev

Hi Oleksii,

thanks for this patch, which still looks very good to me.

A question that was raised in discussion with Takahiro Akashi was how we identify pins that can be used for GPIO and if the spec or implementation has given any thought to that.

I can think of a few, such that:

1. Pins that can be used for GPIO all belong to some group - possibly even one group per pin such as "gpioA1", "gpioA2", "gpioA3" etc - that can be assigned a function named "gpio" or similar.

2. GPIO is seen as something external or "third usecase" that is handled by pin config, not by pin mux.

If it is 1 - which I find likely - it would be good to standardize the name of the function to be "gpio" and somehow make it clear that all pins that are desired to be used for GPIO need to have a (group, function) tuple pair such as ("gpio001", "gpio") that will put the pin into GPIO mode.

If the assumption is anything goes, i.e. a vendor could say something like ("io-group-99", "generic-io") to put a certain pin into GPIO mode, that is maybe not so optimal, because it's nice for the GPIO driver (which will come up) to be able to figure out by e.g. string name conventions that a pin is in GPIO mode, and which group and function that will put it into GPIO mode.

If this generality is not desired, having standard names for GPIO functions and groups is still going to be an upside, if it can be achieved. But maybe this isn't attainable at this point?

Yours,
Linus Walleij