pinctrl: add syscon-backed packed-field pinctrl driver and DT bindings
Subsystems (3)
cover pinctrl: add syscon-backed packed-field pinctrl driver and DT bindings
This work follows earlier review discussions around extending pinctrl-single for bit-per-mux / packed-field controllers. Based on feedback from Linus Walleij and Tony Lindgren, the direction was changed towards introducing a separate targeted driver instead of further increasing the complexity of pinctrl-single.
The prior pinctrl-single series is at:
https://lore.kernel.org/all/20260123-upstream_pinctrl_single-v2-0-40f8063cc5a2@aspeedtech.com/
This series is a replacement of that approach., targeted pinctrl driver for controllers where pinmux and/or pin configuration are represented as fixed-width fields packed sequentially within shared registers (packed-field / bit-per-pin style controllers).
Although pinctrl-single contains support for some bit-per-mux use cases, it was originally designed around direct MMIO ownership and has grown in complexity over time. For SoCs where the pin controller lives inside a larger SCU/syscon register block, using syscon + regmap-mmio provides a clearer ownership model and naturally avoids MMIO resource conflicts.
The new driver is designed to be instantiated as a subnode of a syscon device (e.g. SCU). It obtains a regmap from the parent and uses the child node 'reg' as a window into the syscon register space.
This series includes:
1. A generic Devicetree binding for packed-field pin controllers.
2. The new pinctrl-packed driver (derived from pinctrl-single).
---
Billy Tsai (2):
dt-bindings: pinctrl: Add pinctrl-packed
pinctrl: add syscon-backed packed-field pin controller driver
.../bindings/pinctrl/pinctrl-packed.yaml | 166 +++ drivers/pinctrl/Kconfig | 13 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-packed.c | 1168 ++++++++++++++++++++ 4 files changed, 1348 insertions(+)
---
base-commit: ea24857a76ad90632f86f1e8c8465f96c9f2e407
change-id: 20260211-pinctrl-single-bit-da213f282c95
Best regards,
Signature · 1 line
Billy Tsai <[email protected]>
RFC PATCH 1/2 dt-bindings: pinctrl: Add pinctrl-packed
Add a Devicetree binding for a generic pin controller where pinmux and/or pin configuration are represented as fixed-width fields packed sequentially within shared registers.
The binding targets controllers that are typically exposed as subnodes of a syscon node and accessed via regmap-mmio through the parent.
--- .../bindings/pinctrl/pinctrl-packed.yaml | 166 +++++++++++++++++++++ 1 file changed, 166 insertions(+)
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +166 -0
@@ -0,0 +1,166 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/pinctrl-packed.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic Pin Controller with Packed-Field Registers + +maintainers: + - Billy Tsai <[email protected]> + +description: + This binding describes pin controller hardware where pinmux and/or + pin configuration fields are represented as fixed-width fields packed + sequentially within shared registers. + + Such controllers are commonly embedded within a larger system control + unit (SCU) register block and may be exposed as subnodes of a syscon + device. + + Conceptually, this model is related to the pinctrl-single binding, + but instead of describing individual register offsets via + <offset, value, mask> tuples, the hardware provides fixed-width, + per-pin fields packed linearly within shared registers. + +properties: + compatible: + oneOf: + - enum: + - pinctrl-packed + - pinconf-packed + + reg: + maxItems: 1 + + '#pinctrl-cells': + description: + The pinctrl provider uses standard state nodes referenced by pinctrl-N + properties; consumers do not pass per-pin arguments via phandle. + const: 1 + + pinctrl-packed,function-mask: + description: Mask of the allowed register bits for a single pin. + $ref: /schemas/types.yaml#/definitions/uint32 + + pinctrl-packed,gpio-range: + description: Optional list of pin base, nr pins & gpio function. + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + items: + - description: phandle of a gpio-range node + - description: pin base + - description: number of pins + - description: gpio function + +patternProperties: + '-pins(-[0-9]+)?$|-pin$': + type: object + additionalProperties: false + + properties: + pinctrl-packed,pins: + description: Array of pin index and function selector pairs. + $ref: /schemas/types.yaml#/definitions/uint32-array + + pinctrl-packed,bias-pullup: + description: Optional bias pull-up configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 4 + items: + - description: Input value. + - description: Enabled pull-up bits. + - description: Disabled pull-up bits. + - description: Pull-up mask. + additionalItems: false + + pinctrl-packed,bias-pulldown: + description: Optional bias pull-down configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 4 + items: + - description: Input value. + - description: Enabled pull-down bits. + - description: Disabled pull-down bits. + - description: Pull-down mask. + additionalItems: false + + pinctrl-packed,drive-strength: + description: Optional drive strength configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Drive strength value. + - description: Drive strength mask. + additionalItems: false + + pinctrl-packed,input-schmitt: + description: Optional input Schmitt trigger configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Schmitt trigger value. + - description: Schmitt trigger mask. + additionalItems: false + + pinctrl-packed,input-schmitt-enable: + description: Optional input Schmitt enable configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 4 + items: + - description: Input value. + - description: Enable bits. + - description: Disable bits. + - description: Schmitt mask. + additionalItems: false + + pinctrl-packed,low-power-mode: + description: Optional low power mode configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Low power value. + - description: Low power mask. + additionalItems: false + + pinctrl-packed,slew-rate: + description: Optional slew rate configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Slew rate value. + - description: Slew rate mask. + additionalItems: false + +required: + - compatible + - reg + - "#pinctrl-cells" + - pinctrl-packed,function-mask + +additionalProperties: false + +allOf: + - $ref: pinctrl.yaml# + +examples: + - | + syscon@0 { + compatible = "syscon", "simple-mfd"; + reg = <0x0 0x1000>; + ranges; + #address-cells = <1>; + #size-cells = <1>; + + pinctrl@400 { + compatible = "pinctrl-packed"; + reg = <0x400 0x80>; + #pinctrl-cells = <1>; + pinctrl-packed,function-mask = <0xf>; + + uart0-pins { + /* <pin_index function_select> pairs */ + pinctrl-packed,pins = <0 2>, <1 2>; + }; + }; + };
Signature · 1 line
2.34.1
Re: [PATCH RFC 1/2] dt-bindings: pinctrl: Add pinctrl-packed
Quoted 32 lines · Billy Tsai
Add a Devicetree binding for a generic pin controller where pinmux and/or pin configuration are represented as fixed-width fields packed sequentially within shared registers.
The binding targets controllers that are typically exposed as subnodes of a syscon node and accessed via regmap-mmio through the parent.
Signed-off-by Billy Tsai <[email protected]>--- .../bindings/pinctrl/pinctrl-packed.yaml | 166 +++++++++++++++++++++ 1 file changed, 166 insertions(+)Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +14
-0@@ -0,0 +1,166 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/pinctrl-packed.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic Pin Controller with Packed-Field Registers + +maintainers: + - Billy Tsai <[email protected]> + +description: + This binding describes pin controller hardware where pinmux and/or + pin configuration fields are represented as fixed-width fields packed
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 24
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +10
-0+ sequentially within shared registers. + + Such controllers are commonly embedded within a larger system control + unit (SCU) register block and may be exposed as subnodes of a syscon + device. + + Conceptually, this model is related to the pinctrl-single binding, + but instead of describing individual register offsets via + <offset, value, mask> tuples, the hardware provides fixed-width, + per-pin fields packed linearly within shared registers.
Why this cannot be part of pinctrl-single then? Why all these properties are needed? I imagine that you need them to customize the generic binding to your device and that would be counter argument - generic bindings are too generic so people need to grow them with hundreds properties (see the very simple binding of simple audio card).
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 28
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +4
-0+ +properties: + compatible: + oneOf:
Drop oneOf
Quoted 24 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +24
-0+ - enum: + - pinctrl-packed + - pinconf-packed + + reg: + maxItems: 1 + + '#pinctrl-cells': + description: + The pinctrl provider uses standard state nodes referenced by pinctrl-N + properties; consumers do not pass per-pin arguments via phandle. + const: 1 + + pinctrl-packed,function-mask: + description: Mask of the allowed register bits for a single pin. + $ref: /schemas/types.yaml#/definitions/uint32 + + pinctrl-packed,gpio-range: + description: Optional list of pin base, nr pins & gpio function. + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + items: + - description: phandle of a gpio-range node + - description: pin base
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 62
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +10
-0+ - description: number of pins + - description: gpio function + +patternProperties: + '-pins(-[0-9]+)?$|-pin$': + type: object + additionalProperties: false + + properties: + pinctrl-packed,pins:
No, use standard pinctrl properties.
Quoted 77 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +77
-0+ description: Array of pin index and function selector pairs. + $ref: /schemas/types.yaml#/definitions/uint32-array + + pinctrl-packed,bias-pullup: + description: Optional bias pull-up configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 4 + items: + - description: Input value. + - description: Enabled pull-up bits. + - description: Disabled pull-up bits. + - description: Pull-up mask. + additionalItems: false + + pinctrl-packed,bias-pulldown: + description: Optional bias pull-down configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 4 + items: + - description: Input value. + - description: Enabled pull-down bits. + - description: Disabled pull-down bits. + - description: Pull-down mask. + additionalItems: false + + pinctrl-packed,drive-strength: + description: Optional drive strength configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Drive strength value. + - description: Drive strength mask. + additionalItems: false + + pinctrl-packed,input-schmitt: + description: Optional input Schmitt trigger configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Schmitt trigger value. + - description: Schmitt trigger mask. + additionalItems: false + + pinctrl-packed,input-schmitt-enable: + description: Optional input Schmitt enable configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 4 + items: + - description: Input value. + - description: Enable bits. + - description: Disable bits. + - description: Schmitt mask. + additionalItems: false + + pinctrl-packed,low-power-mode: + description: Optional low power mode configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Low power value. + - description: Low power mask. + additionalItems: false + + pinctrl-packed,slew-rate: + description: Optional slew rate configuration. + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + items: + - description: Slew rate value. + - description: Slew rate mask. + additionalItems: false + +required: + - compatible + - reg + - "#pinctrl-cells" + - pinctrl-packed,function-mask
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 149
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +10
-0+ +additionalProperties: false + +allOf: + - $ref: pinctrl.yaml# + +examples: + - | + syscon@0 { + compatible = "syscon", "simple-mfd";
This is not allowed and you will have warnings here, which means you did not test the binding correctly (completely). Not even needed here, drop entire node.
Best regards,
Krzysztof
Linus Walleij
maintainerRe: [PATCH RFC 1/2] dt-bindings: pinctrl: Add pinctrl-packed
In reply to Billy TsaiHi Billy,
thanks for your patch!
This approach is better than trying to extend pinctrl-single in my opinion, but it has a bit of road to cover.
Quoted 8 lines · Billy Tsai
Add a Devicetree binding for a generic pin controller where pinmux and/or pin configuration are represented as fixed-width fields packed sequentially within shared registers.
The binding targets controllers that are typically exposed as subnodes of a syscon node and accessed via regmap-mmio through the parent.
Signed-off-by Billy Tsai <[email protected]>
(...)
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 31
Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +6
-0+properties: + compatible: + oneOf: + - enum: + - pinctrl-packed + - pinconf-packed
Why do you need two? Can't you just use one, pinctrl-packed.
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 44
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +3
-0+ pinctrl-packed,function-mask: + description: Mask of the allowed register bits for a single pin. + $ref: /schemas/types.yaml#/definitions/uint32
To me this could be static data in the driver but I guess the whole point is to do what pinctrl-single is doing and store all of this information in the device tree, because reasons.
I guess the DT binding maintainers need to decide on this and also what to name it.
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 54
Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +9
-0+ pinctrl-packed,gpio-range: + description: Optional list of pin base, nr pins & gpio function. + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + items: + - description: phandle of a gpio-range node + - description: pin base + - description: number of pins + - description: gpio function
Just use the standard gpio-range.
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 64
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +8
-0+patternProperties: + '-pins(-[0-9]+)?$|-pin$': + type: object + additionalProperties: false + properties: + pinctrl-packed,pins: + description: Array of pin index and function selector pairs. + $ref: /schemas/types.yaml#/definitions/uint32-array
Just use pinmux = <...>; from pinmux-node.yaml
(make sure to use the ref include.)
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml line 126
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-packed.yaml new file +7
-0+ pinctrl-packed,bias-pullup: + pinctrl-packed,bias-pulldown: + pinctrl-packed,drive-strength: + pinctrl-packed,input-schmitt: + pinctrl-packed,input-schmitt-enable: + pinctrl-packed,low-power-mode: + pinctrl-packed,slew-rate:
Just use the existing configs frompincfg-node.yaml and abstain from any new
inventions here.
Yours,
Linus Walleij
RFC PATCH 2/2 pinctrl: add syscon-backed packed-field pin controller driver
In reply to Billy TsaiIntroduce a new pinctrl driver for controllers where pinmux and/or pin configuration fields are represented as fixed-width packed fields within shared registers.
The driver is designed to be used as a child of a syscon node and obtains a regmap from the parent, avoiding direct MMIO ownership and allowing shared access to SCU-style register blocks.
This driver is derived from pinctrl-single but reworked as a standalone implementation focused on packed-field controllers.
--- drivers/pinctrl/Kconfig | 13 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-packed.c | 1168 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1182 insertions(+)
drivers/pinctrl/Kconfig +13 -0
@@ -443,6 +443,19 @@ config PINCTRL_OCELOT If conpiled as a module, the module name will be pinctrl-ocelot. +config PINCTRL_PACKED + tristate "Packed-field type device tree based pinctrl driver" + depends on OF + depends on HAS_IOMEM + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GENERIC_PINCONF + help + This selects the device tree based generic pinctrl driver with + fixed-width packed-field register layout. + The driver is derived from pinctrl-single but reworked as a standalone + implementation focused on packed-field controllers. + config PINCTRL_PALMAS tristate "Pinctrl driver for the PALMAS Series MFD devices" depends on OF && MFD_PALMAS
drivers/pinctrl/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_PINCTRL_MCP23S08) += pinctrl-mcp23s08.o obj-$(CONFIG_PINCTRL_MICROCHIP_SGPIO) += pinctrl-microchip-sgpio.o obj-$(CONFIG_PINCTRL_MLXBF3) += pinctrl-mlxbf3.o obj-$(CONFIG_PINCTRL_OCELOT) += pinctrl-ocelot.o +obj-$(CONFIG_PINCTRL_PACKED) += pinctrl-packed.o obj-$(CONFIG_PINCTRL_PALMAS) += pinctrl-palmas.o obj-$(CONFIG_PINCTRL_PEF2256) += pinctrl-pef2256.o obj-$(CONFIG_PINCTRL_PIC32) += pinctrl-pic32.o
drivers/pinctrl/pinctrl-packed.c new file +1168 -0
1,168 lines not on this page · raw message
Signature · 1 line
2.34.1