mbox series

[RFC,v2,0/2] Introducing generic SCMI pinctrl driver implementation

Message ID cover.1682513390.git.oleksii_moisieiev@epam.com
Headers show
Series Introducing generic SCMI pinctrl driver implementation | expand

Message

Oleksii Moisieiev April 26, 2023, 1:26 p.m. UTC
This RFC patch series is intended to introduce the potential 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.

This implementation still reqires some features, such as gpio support, but I've posted it as RFC to
start the discussion regarding the driver format.

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

---
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

---
Oleksii Moisieiev (3):
  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           |  77 ++
 MAINTAINERS                                   |   7 +
 drivers/firmware/arm_scmi/Makefile            |   3 +-
 drivers/firmware/arm_scmi/driver.c            |   2 +
 drivers/firmware/arm_scmi/pinctrl.c           | 932 ++++++++++++++++++
 drivers/firmware/arm_scmi/protocols.h         |   1 +
 drivers/pinctrl/Kconfig                       |   9 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/pinctrl-scmi.c                | 578 +++++++++++
 include/linux/scmi_protocol.h                 |  47 +
 10 files changed, 1656 insertions(+), 1 deletion(-)
 create mode 100644 drivers/firmware/arm_scmi/pinctrl.c
 create mode 100644 drivers/pinctrl/pinctrl-scmi.c

Comments

Michal Simek April 27, 2023, 7:07 a.m. UTC | #1
On 4/26/23 15:26, Oleksii Moisieiev wrote:
> Add new SCMI v3.2 pinctrl protocol bindings definitions and example.
> 
> Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
> ---
>   .../bindings/firmware/arm,scmi.yaml           | 77 +++++++++++++++++++
>   1 file changed, 77 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
> index 2f7c51c75e85..41ba5b8d8151 100644
> --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
> +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
> @@ -212,6 +212,63 @@ properties:
>         reg:
>           const: 0x18
>   
> +  protocol@19:
> +    $ref: '#/$defs/protocol-node'
> +
> +    properties:
> +      reg:
> +        const: 0x19
> +
> +      '#pinctrl-cells':
> +        const: 0
> +

As I said. pinctrl has also gpio part and based on discussion with SCMI guys 
this protocol can be also used for simple gpio. That's why here should be also 
listed #gpio-cells to be able to use this functionality.

And for complete implementation it should be also added to driver it but of 
course this can be added later by separate patch.

Thanks,
Michal
Oleksii Moisieiev April 27, 2023, 7:19 a.m. UTC | #2
On 27.04.23 10:07, Michal Simek wrote:
> 
> 
> On 4/26/23 15:26, Oleksii Moisieiev wrote:
>> Add new SCMI v3.2 pinctrl protocol bindings definitions and example.
>>
>> Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
>> ---
>>   .../bindings/firmware/arm,scmi.yaml           | 77 +++++++++++++++++++
>>   1 file changed, 77 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml 
>> b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
>> index 2f7c51c75e85..41ba5b8d8151 100644
>> --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
>> +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
>> @@ -212,6 +212,63 @@ properties:
>>         reg:
>>           const: 0x18
>> +  protocol@19:
>> +    $ref: '#/$defs/protocol-node'
>> +
>> +    properties:
>> +      reg:
>> +        const: 0x19
>> +
>> +      '#pinctrl-cells':
>> +        const: 0
>> +
> 
> As I said. pinctrl has also gpio part and based on discussion with SCMI 
> guys this protocol can be also used for simple gpio. That's why here 
> should be also listed #gpio-cells to be able to use this functionality.
> 
> And for complete implementation it should be also added to driver it but 
> of course this can be added later by separate patch.
> 
> Thanks,
> Michal
> 

Hi Michal,

The plan is to add gpio support as the separate patch on top of this 
patch series.

Oleksii.