dt-bindings: pinctrl: support specifying pins
Subsystems (3)
RFC PATCH 1/1 dt-bindings: pinctrl: support specifying pins
From: Rafał Miłecki <[email protected]>
Add support for "pins" node with pin@ subnodes. This allows specifying all pins (and their names) at DT level.
---
While working with pinctrl in Linux I started wondering if we could start specifying pins in DT instead of Linux drivers. When working with DT we usually avoid hardcoding hardware description in drivers so it isn't clear to me why it doesn't apply to pins.
Please let me know if this makes sense. If by some chance I'm correct I think that specifying groups and functions could follow too.
FWIW: I didn't start working on Linux reading pins from DT yet.
--- .../bindings/pinctrl/brcm,ns-pinmux.yaml | 12 +++++++++- .../devicetree/bindings/pinctrl/pinctrl.yaml | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pinctrl/brcm,ns-pinmux.yaml +11 -1
@@ -74,7 +74,7 @@ required: - reg - reg-names -additionalProperties: false +unevaluatedProperties: false examples: - |
@@ -83,6 +83,16 @@ examples: reg = <0x1800c1c0 0x24>; reg-names = "cru_gpio_control"; + pins { + #address-cells = <1>; + #size-cells = <0>; + + pin@0 { + reg = <0>; + label = "spi_clk"; + }; + }; + spi-pins { function = "spi"; groups = "spi_grp";
Documentation/devicetree/bindings/pinctrl/pinctrl.yaml +23 -0
@@ -42,4 +42,27 @@ properties: This property can be set either globally for the pin controller or in child nodes for individual pin group control. + pins: + type: object + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + "^pin@[0-9a-z]+$": + type: object + + properties: + reg: + description: Pin number + + label: + description: Pin name + $ref: /schemas/types.yaml#/definitions/string + + additionalProperties: false + additionalProperties: true
Signature · 1 line
2.31.1
Quoted 4 lines · Rafał Miłecki
While working with pinctrl in Linux I started wondering if we could start specifying pins in DT instead of Linux drivers. When working with DT we usually avoid hardcoding hardware description in drivers so it isn't clear to me why it doesn't apply to pins.
Historically this is what pinctrl-single.c does. Documentation/devicetree/bindings/pinctrl/pinctrl-single.txt
At the time we created pin control there was a bit back-and-forth and the conclusion was that there is not one-size-fits all for pin defines.
The reason TI (Tony) wanted to push the information into DT was that what he gets is a number of unprocessed ASIC datasets, that are then turned into tables with a script. Header files or DTS source alike, but some kind of tables.
At the time (2011?) it was unclear what kind of data should go into e.g. header and data files in the kernel (modules) and what should go into the DT. So the approach to put pin information into the DT was allowed for pinctrl-single.
The way I have understood it, DT maintainers have since gotten a bit wary about (ab)using the DT as a container for "anything data" and prefer that drivers contain details and derive these from compatible strings.
As of today, IIUC the DT maintainers are against this scheme.
That said, the topic is open in a way. Some people are also annoyed that some graphics drivers just ask Torvalds to pull 100.000+ lines of register defnes in some merge windows. The data has to go somewhere.
Yours,
Linus Walleij
Rob Herring
maintainerQuoted 6 lines · Linus Walleij
Quoted 4 lines · Rafał Miłecki
While working with pinctrl in Linux I started wondering if we could start specifying pins in DT instead of Linux drivers. When working with DT we usually avoid hardcoding hardware description in drivers so it isn't clear to me why it doesn't apply to pins.
I thought we were...
Quoted 16 lines
Historically this is what
pinctrl-single.cdoes.Documentation/devicetree/bindings/pinctrl/pinctrl-single.txtAt the time we created pin control there was a bit back-and-forth and the conclusion was that there is not one-size-fits all for pin defines.
The reason TI (Tony) wanted to push the information into DT was that what he gets is a number of unprocessed ASIC datasets, that are then turned into tables with a script. Header files or DTS source alike, but some kind of tables.
At the time (2011?) it was unclear what kind of data should go into e.g. header and data files in the kernel (modules) and what should go into the DT. So the approach to put pin information into the DT was allowed for pinctrl-single.
Quoted 6 lines
The way I have understood it, DT maintainers have since gotten a bit wary about (ab)using the DT as a container for "anything data" and prefer that drivers contain details and derive these from compatible strings.
As of today, IIUC the DT maintainers are against this scheme.
The question is more can the data be static (complete) and correct? That doesn't work for quirk properties nor entire clock trees with a node per clock.
Pins? Maybe. That's a flat thing and you should know all the pins up front.
Rob
Quoted 11 lines · Linus Walleij
At the time (2011?) it was unclear what kind of data should go into e.g. header and data files in the kernel (modules) and what should go into the DT. So the approach to put pin information into the DT was allowed for pinctrl-single.
The way I have understood it, DT maintainers have since gotten a bit wary about (ab)using the DT as a container for "anything data" and prefer that drivers contain details and derive these from compatible strings.
As of today, IIUC the DT maintainers are against this scheme.
We have some newish tools now compared 2011 though with #pinctrl-cells. And we now have also GENERIC_PINCTRL_GROUPS, GENERIC_PINMUX_FUNCTIONS and GENERIC_PINCONF :)
The problem with the pinctrl-single binding is that it uses the hardware specific mux values in addition to the mux register offsets. IMO the values should use Linux generic pinctrl defines instead. Just like we do for the gpio and interrupt bindings. And then the generic pinctrl binding would be very similar to the interrupts-extended binding for example.
And with a generic pinctrl binding pinctrl-single could be updated to parse the generic binding naturally too in addition to the legacy binding.
Quoted 4 lines
That said, the topic is open in a way. Some people are also annoyed that some graphics drivers just ask Torvalds to pull 100.000+ lines of register defnes in some merge windows. The data has to go somewhere.
Yes and the amount of SoC specific LOC under drivers/pinctrl is pretty staggering already.
With all that SoC specific data built into the kernel, it's like going camping with all your pants stuffed into your car instead of just the pants you need :)
We only need the SoC specific data for the booted SoC, so devicetree and loadable modules makes more sense there compared to the current built-in setup.
Regards,
Tony
Quoted 36 lines · Tony Lindgren
Quoted 11 lines · Linus Walleij
At the time (2011?) it was unclear what kind of data should go into e.g. header and data files in the kernel (modules) and what should go into the DT. So the approach to put pin information into the DT was allowed for pinctrl-single.
The way I have understood it, DT maintainers have since gotten a bit wary about (ab)using the DT as a container for "anything data" and prefer that drivers contain details and derive these from compatible strings.
As of today, IIUC the DT maintainers are against this scheme.
We have some newish tools now compared 2011 though with #pinctrl-cells. And we now have also
GENERIC_PINCTRL_GROUPS,GENERIC_PINMUX_FUNCTIONSandGENERIC_PINCONF:)The problem with the pinctrl-single binding is that it uses the hardware specific mux values in addition to the mux register offsets. IMO the values should use Linux generic pinctrl defines instead. Just like we do for the gpio and interrupt bindings. And then the generic pinctrl binding would be very similar to the interrupts-extended binding for example.
And with a generic pinctrl binding pinctrl-single could be updated to parse the generic binding naturally too in addition to the legacy binding.
Quoted 4 lines
That said, the topic is open in a way. Some people are also annoyed that some graphics drivers just ask Torvalds to pull 100.000+ lines of register defnes in some merge windows. The data has to go somewhere.
Yes and the amount of SoC specific LOC under
drivers/pinctrlis pretty staggering already.
Quoted 7 lines
With all that SoC specific data built into the kernel, it's like going camping with all your pants stuffed into your car instead of just the pants you need :)
We only need the SoC specific data for the booted SoC, so devicetree and loadable modules makes more sense there compared to the current built-in setup.
I'm against putting that into DT and here is why.
DT is the thing that describes the _platform_. While it's fine to put GPIO expander thingy (and we actually do this with labeling schema for GPIOs, right?), the SoC level of things is a _hardware_ and with all flexibility the DT gives us we will definitely have a deviations on _different_ platforms with _the same_ SoC! To work around this we must have a validation of the pin names and their functions in many places.
And last but not least the copying it in tons of DT feels like a duplication effort.,
AFAIU the topic, the pin control lacks labeling schema that will provide the view from the platform perspective, while driver provides from HW perspective.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines
We only need the SoC specific data for the booted SoC, so devicetree and loadable modules makes more sense there compared to the current built-in setup.
Quoted 8 lines
I'm against putting that into DT and here is why.
DT is the thing that describes the _platform_. While it's fine to put GPIO expander thingy (and we actually do this with labeling schema for GPIOs, right?), the SoC level of things is a _hardware_ and with all flexibility the DT gives us we will definitely have a deviations on _different_ platforms with
_thesame_SoC! To work around this we must have a validation of the pin names and their functions in many places.
I think you are misunderstanding what I mean here. Certainly the driver needs to know how to deal with the SoC specific hardware. And that we can easily do that in quite easily already. The device tree data I'm describing would be similar to the interrupts with instance offset and generic mux flags.
See for example the driver for drivers/pinctrl/ti/pinctrl-ti-iodelay.c. For that driver we have the instance and picosecond iodelay values in the devicetree, and with #nr-pinctrl cells there could be some generic pinctrl mux flags. We are missing the generic pinctrl flags part AFAIK.
Quoted 2 lines
And last but not least the copying it in tons of DT feels like a duplication effort.,
Hmm I don't think we have any of that for what I'm describing. But please take a look at the iodelay example above, maybe I'm not following.
Quoted 3 lines
AFAIU the topic, the pin control lacks labeling schema that will provide the view from the platform perspective, while driver provides from HW perspective.
Agreed we need a generic labeling schema.
Regards,
Tony
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines
We only need the SoC specific data for the booted SoC, so devicetree and loadable modules makes more sense there compared to the current built-in setup.
I'm against putting that into DT and here is why.
Quoted 8 lines
Quoted 6 lines
DT is the thing that describes the _platform_. While it's fine to put GPIO expander thingy (and we actually do this with labeling schema for GPIOs, right?), the SoC level of things is a _hardware_ and with all flexibility the DT gives us we will definitely have a deviations on _different_ platforms with
_thesame_SoC! To work around this we must have a validation of the pin names and their functions in many places.I think you are misunderstanding what I mean here.
Ah, okay. Thanks for explaining!
Quoted 23 lines
Certainly the driver
needs to know how to deal with the SoC specific hardware. And that we can easily do that in quite easily already. The device tree data I'm describing would be similar to the interrupts with instance offset and generic mux flags.See for example the driver for
drivers/pinctrl/ti/pinctrl-ti-iodelay.c. For that driver we have the instance and picosecond iodelay values in the devicetree, and with #nr-pinctrl cells there could be some generic pinctrl mux flags. We are missing the generic pinctrl flags part AFAIK.Quoted 2 lines
And last but not least the copying it in tons of DT feels like a duplication effort.,
Hmm I don't think we have any of that for what I'm describing. But please take a look at the iodelay example above, maybe I'm not following.
Quoted 3 lines
AFAIU the topic, the pin control lacks labeling schema that will provide the view from the platform perspective, while driver provides from HW perspective.
Agreed we need a generic labeling schema.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rob Herring
maintainerQuoted 35 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Add support for "pins" node with pin@ subnodes. This allows specifying all pins (and their names) at DT level.
Signed-off-by Rafał Miłecki <[email protected]>---
While working with pinctrl in Linux I started wondering if we could start specifying pins in DT instead of Linux drivers. When working with DT we usually avoid hardcoding hardware description in drivers so it isn't clear to me why it doesn't apply to pins.Please let me know if this makes sense. If by some chance I'm correct I think that specifying groups and functions could follow too.
FWIW: I didn't start working on Linux reading pins from DT yet.
--- .../bindings/pinctrl/brcm,ns-pinmux.yaml | 12 +++++++++- .../devicetree/bindings/pinctrl/pinctrl.yaml | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/pinctrl/brcm,ns-pinmux.yaml +1
-1@@ -74,7 +74,7 @@ required: - reg - reg-names -additionalProperties: false +unevaluatedProperties: false examples: - |
Documentation/devicetree/bindings/pinctrl/brcm,ns-pinmux.yaml examples: · line 91
Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/brcm,ns-pinmux.yaml +6
-0@@ -83,6 +83,16 @@ examples: reg = <0x1800c1c0 0x24>; reg-names = "cru_gpio_control"; + pins { + #address-cells = <1>; + #size-cells = <0>; + + pin@0 { + reg = <0>;
Where does 'reg' value come from?
Documentation/devicetree/bindings/pinctrl/brcm,ns-pinmux.yaml examples: · line 93
Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/brcm,ns-pinmux.yaml +2
-0+ label = "spi_clk"; + };
If you just want a list of pins names, then why not just a list of names?
Rob