public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [RFC 0/6] firmware: scmi: add SCMI pinctrl protocol support
@ 2023-09-06  2:40 AKASHI Takahiro
  2023-09-06  2:40 ` [RFC 1/6] firmware: scmi: fix protocol enumeration logic AKASHI Takahiro
                   ` (6 more replies)
  0 siblings, 7 replies; 25+ messages in thread
From: AKASHI Takahiro @ 2023-09-06  2:40 UTC (permalink / raw)
  To: u-boot
  Cc: etienne.carriere, michal.simek, sjg, linus.walleij,
	Oleksii_Moisieiev, AKASHI Takahiro

This is an RFC and meant to get feedback from other developers as
- the specification (pinctrl part) is still in a draft
- the upstream patch for linux, including dt bindings, is still WIP
- I'm not confident the drivers are generic enough to cover most HWs
- The tests ("ut") doesn't cover all the features yet


This patch series allows users to access SCMI pin control protocol provided
by SCMI server (platform). See SCMI specification document v3.2 beta 2[1]
for more details about SCMI pin control protocol.

The implementation consists of two layers:
- basic helper functions for SCMI pin control protocol
  in drivers/firmware/scmi/pinctrl.c (patch#2)
- DM-compliant pinctrl/gpio drivers, which utilizes the helper functions,
  in drivers/pinctrl/pinctrl-scmi.c (patch#3,#4)

[1] https://developer.arm.com/documentation/den0056/e/?lang=en

DT bindings
===========
Upstream pinctrl patch for linux defines the bindings in [2] though
it doesn't say much.
I expect that my implementation basically complies with U-Boot's generic
bindings described in [3], but not all the features are verified.

As for gpio, unless you hard-code pin assignments directly in a device
driver, my implementation allows the following alternatives in DT.
Either way, we may need an additional binding description for gpio.

(A)
    scmi {
        ... // other protocols
        scmi_pinctrl: protocol@19 { // Pin control protocol
            ...
            {pinmux definitions}... // if any, including GPIO?
        }
    }
    scmi_gpio: scmi_gpio {
        compatible = "arm,scmi-gpio-generic";
        gpio-controller;
        #gpio-cells = <2>;
        gpio-ranges = <&scmi_pinctrl 0 5 4>,
                      <&scmi_pinctrl 4 0 0>;
        gpio-ranges-group-names = "",
                                  "ANOTHER_GPIO_GROUP";
    }
    some_device {
        ...
        reset-gpios = <&scmi_gpio 0 GPIO_ACTIVE_HIGH>;
    }
(B)
    scmi {
        ... // other protocols
        scmi_pinctrl: protocol@19 { // Pin control protocol
            ...
            {pinmux definitions}... // if any, including GPIO?

            scmi_gpio: scmi_gpio {
		// no need for "compatible"
                gpio-controller;
                #gpio-cells = <2>;
                gpio-ranges = <&scmi_pinctrl 0 5 4>,
                              <&scmi_pinctrl 4 0 0>;
                gpio-ranges-group-names = "",
                                          "ANOTHER_GPIO_GROUP";
            }
        }
    }
    some_device {
        ...
        reset-gpios = <&scmi_gpio 0 GPIO_ACTIVE_HIGH>;
    }
(C)
    if "gpio-ranges" is missing in gpio definition, assume 1:1 mapping,
    i.e. use a native pinctrl pin number (5).
    some_device {
        ...
        reset-gpios = <&scmi_gpio 5 GPIO_ACTIVE_HIGH>;
    }


[2] https://lkml.iu.edu/hypermail/linux/kernel/2308.1/01084.html
[3] <u-boot>/doc/device-tree-bindings/pinctrl/pinctrl-bindings.txt
    <u-boot>/doc/device-tree-bindings/gpio/gpio.txt

Test
====
The patch series was tested on the following platforms:
* sandbox ("ut dm pinmux" and manually using gpio command)


Prerequisite:
=============
* This patch series is based on my WIP "Base protocol support" patches
  on v2023.10-rc3. You can fetch the whole code from [4].

[4] https://git.linaro.org/people/takahiro.akashi/u-boot.git
    branch:scmi/pinctrl


Patches:
========
Patch#1: Add SCMI base protocol driver
Patch#2-#4: Add drivers
Patch#5-#6: Test related


Change history:
===============
RFC (Sep 6, 2023)
* initial release as RFC

AKASHI Takahiro (6):
  firmware: scmi: fix protocol enumeration logic
  firmware: scmi: add pinctrl protocol support
  pinctrl: add scmi driver
  gpio: add scmi driver based on pinctrl
  firmware: scmi: add pseudo pinctrl protocol support on sandbox
  test: dm: add SCMI pinctrl test

 arch/sandbox/dts/test.dts                  |  115 +++
 cmd/scmi.c                                 |    1 +
 drivers/firmware/scmi/Kconfig              |    3 +
 drivers/firmware/scmi/Makefile             |    1 +
 drivers/firmware/scmi/pinctrl.c            |  412 ++++++++
 drivers/firmware/scmi/sandbox-scmi_agent.c |  722 +++++++++++++
 drivers/firmware/scmi/scmi_agent-uclass.c  |   18 +-
 drivers/pinctrl/Kconfig                    |   11 +
 drivers/pinctrl/Makefile                   |    1 +
 drivers/pinctrl/pinctrl-scmi.c             | 1071 ++++++++++++++++++++
 include/scmi_agent-uclass.h                |    2 +
 include/scmi_protocols.h                   |  435 ++++++++
 test/dm/scmi.c                             |   62 ++
 13 files changed, 2852 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/scmi/pinctrl.c
 create mode 100644 drivers/pinctrl/pinctrl-scmi.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2023-09-22 18:29 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-06  2:40 [RFC 0/6] firmware: scmi: add SCMI pinctrl protocol support AKASHI Takahiro
2023-09-06  2:40 ` [RFC 1/6] firmware: scmi: fix protocol enumeration logic AKASHI Takahiro
2023-09-10 19:13   ` Simon Glass
2023-09-11  4:58     ` AKASHI Takahiro
2023-09-06  2:40 ` [RFC 2/6] firmware: scmi: add pinctrl protocol support AKASHI Takahiro
2023-09-06  2:40 ` [RFC 3/6] pinctrl: add scmi driver AKASHI Takahiro
2023-09-10 19:13   ` Simon Glass
2023-09-11  5:14     ` AKASHI Takahiro
2023-09-06  2:40 ` [RFC 4/6] gpio: add scmi driver based on pinctrl AKASHI Takahiro
2023-09-06 14:56   ` Michal Simek
2023-09-06 23:37     ` AKASHI Takahiro
2023-09-07 12:23   ` Simon Glass
2023-09-08  4:32     ` AKASHI Takahiro
2023-09-10 19:13       ` Simon Glass
2023-09-11  5:38         ` AKASHI Takahiro
2023-09-06  2:40 ` [RFC 5/6] firmware: scmi: add pseudo pinctrl protocol support on sandbox AKASHI Takahiro
2023-09-10 19:13   ` Simon Glass
2023-09-11  5:23     ` AKASHI Takahiro
2023-09-06  2:40 ` [RFC 6/6] test: dm: add SCMI pinctrl test AKASHI Takahiro
2023-09-10 19:13   ` Simon Glass
2023-09-11  5:47     ` AKASHI Takahiro
2023-09-22 18:27       ` Simon Glass
2023-09-06  3:09 ` [RFC 0/6] firmware: scmi: add SCMI pinctrl protocol support Fabio Estevam
2023-09-07  9:58   ` AKASHI Takahiro
2023-09-08 12:14     ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox