Skip to contentSkip to conversation

dt-bindings: pinctrl: microchip,pic32mzda-pinctrl: Convert to DT schema

PATCH Superseded Udaya Kiran Challa 3 participants 3 messages Jul 19 – Jul 21

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 dt-bindings: pinctrl: microchip,pic32mzda-pinctrl: Convert to DT schema

Convert Microchip PIC32 Pin Controller devicetree binding from legacy text format to DT schema.

---
Changelog:
Changes since v2:
- Add container node for grouped pin configuration sub-nodes
- Correct regex patterns of direct and nested child nodes
- Fix interrupts values in uart2 example

Link to v2:https://lore.kernel.org/all/[email protected]/

Changes since v1:
- Add interrupts and clocks to uart2 example to satisfy uart schema validation
- Corect regex patterns to accept standard DT node naming conventions
- Add function property to top-level pin configuration nodes
- Remove restrictive enum from function property to support all mux functions

Link to v1:https://lore.kernel.org/all/[email protected]/

---
 .../pinctrl/microchip,pic32-pinctrl.txt       |  60 -------
 .../pinctrl/microchip,pic32mzda-pinctrl.yaml  | 153 ++++++++++++++++++
 2 files changed, 153 insertions(+), 60 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic32-pinctrl.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/microchip,pic32-pinctrl.txt deleted +0 -60
deleted file mode 100644
index 51efd2085113..000000000000
@@ -1,60 +0,0 @@
-* Microchip PIC32 Pin Controller
-
-Please refer to pinctrl-bindings.txt, ../gpio/gpio.txt, and
-../interrupt-controller/interrupts.txt for generic information regarding
-pin controller, GPIO, and interrupt bindings.
-
-PIC32 'pin configuration node' is a node of a group of pins which can be
-used for a specific device or function. This node represents configurations of
-pins, optional function, and optional mux related configuration.
-
-Required properties for pin controller node:
- - compatible: "microchip,pic32mada-pinctrl"
- - reg: Address range of the pinctrl registers.
- - clocks: Clock specifier (see clock bindings for details)
-
-Required properties for pin configuration sub-nodes:
- - pins: List of pins to which the configuration applies.
-
-Optional properties for pin configuration sub-nodes:
-----------------------------------------------------
- - function: Mux function for the specified pins.
- - bias-pull-up: Enable weak pull-up.
- - bias-pull-down: Enable weak pull-down.
- - input-enable: Set the pin as an input.
- - output-low: Set the pin as an output level low.
- - output-high: Set the pin as an output level high.
- - microchip,digital: Enable digital I/O.
- - microchip,analog: Enable analog I/O.
-
-Example:
-
-pic32_pinctrl: pinctrl@1f801400{
-	#address-cells = <1>;
-	#size-cells = <1>;
-	compatible = "microchip,pic32mzda-pinctrl";
-	reg = <0x1f801400 0x400>;
-	clocks = <&rootclk PB1CLK>;
-
-	pinctrl_uart2: pinctrl_uart2 {
-		uart2-tx {
-			pins = "G9";
-			function = "U2TX";
-			microchip,digital;
-			output-low;
-		};
-		uart2-rx {
-			pins = "B0";
-			function = "U2RX";
-			microchip,digital;
-			input-enable;
-		};
-	};
-};
-
-uart2: serial@1f822200 {
-	compatible = "microchip,pic32mzda-uart";
-	reg = <0x1f822200 0x50>;
-	pinctrl-names = "default";
-	pinctrl-0 = <&pinctrl_uart2>;
-};
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The regular expressions used for matching pin configuration nodes contain invalid syntax…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The regular expressions used for matching pin configuration nodes contain invalid syntax (negative lookaheads unsupported by the RE2 engine) and overly restrictive patterns that reject standard Device Tree node naming conventions. --

--- Patch [1]: [PATCH v3] dt-bindings: pinctrl: microchip,pic32mzda-pinctrl: Convert to DT schema --- commit e4c63aad2379e3c473b66cca58b14faae98c368f
Author: Udaya Kiran Challa <[email protected]>

dt-bindings: pinctrl: microchip,pic32mzda-pinctrl: Convert to DT schema

Convert Microchip PIC32 Pin Controller devicetree binding from legacy text format to DT schema.

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +0 -0
new file mode 100644
index 0000000000000..7a36e5ff61ddf
@@ -0,0 +1,153 @@

[ ... ]

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 34

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +5 -0
+  '#size-cells':
+    const: 1
+
+patternProperties:
+  '^(?!pinctrl_)[a-z]+[0-9]*_[a-z0-9_]+$':

[Severity: Medium]
Will this negative lookahead cause a schema compilation error during make dt_binding_check?

The dt-schema tool requires RE2-compatible regexes, which do not support negative lookaheads. Additionally, strictly requiring an underscore in the node name violates standard Device Tree node naming conventions.

Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +2 -0
+    type: object
+    $ref: pinmux-node.yaml#

[ ... ]

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 67

Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +3 -0
+    unevaluatedProperties: false
+
+  '^pinctrl_[a-z0-9_-]+$|^[a-z]+[0-9]+-[0-9]+$':

[Severity: Medium]
Is this pattern too restrictive for container nodes?

By requiring a pinctrl_ prefix or strictly ending in a number, this pattern rejects valid generic node names like uart-pins, which could break schema validation for conformant device trees.

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 73

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +6 -0
+    type: object
+    description: |
+      Container node for grouped pin configuration sub-nodes.
+
+    patternProperties:
+      '^[a-z]+[0-9]+-[a-z]+$':

[Severity: Medium]
Does this child sub-node pattern improperly reject standard single-instance interfaces?

The regex requires a number before a hyphen, which means valid generic names like spi-mosi will fail to match.

Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +2 -0
+        type: object
+        $ref: pinmux-node.yaml#

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Udaya Kiran Challa
Quoted 101 lines · Udaya Kiran Challa

Convert Microchip PIC32 Pin Controller devicetree binding from legacy text format to DT schema.

---
Changelog:
Changes since v2:
- Add container node for grouped pin configuration sub-nodes
- Correct regex patterns of direct and nested child nodes
- Fix interrupts values in uart2 example

Link to v2:https://lore.kernel.org/all/[email protected]/

Changes since v1:
- Add interrupts and clocks to uart2 example to satisfy uart schema validation
- Corect regex patterns to accept standard DT node naming conventions
- Add function property to top-level pin configuration nodes
- Remove restrictive enum from function property to support all mux functions

Link to v1:https://lore.kernel.org/all/[email protected]/

---
 .../pinctrl/microchip,pic32-pinctrl.txt       |  60 -------
 .../pinctrl/microchip,pic32mzda-pinctrl.yaml  | 153 ++++++++++++++++++
 2 files changed, 153 insertions(+), 60 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic32-pinctrl.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/microchip,pic32-pinctrl.txt deleted +0 -60
deleted file mode 100644
index 51efd2085113..000000000000
@@ -1,60 +0,0 @@
-* Microchip PIC32 Pin Controller
-
-Please refer to pinctrl-bindings.txt, ../gpio/gpio.txt, and
-../interrupt-controller/interrupts.txt for generic information regarding
-pin controller, GPIO, and interrupt bindings.
-
-PIC32 'pin configuration node' is a node of a group of pins which can be
-used for a specific device or function. This node represents configurations of
-pins, optional function, and optional mux related configuration.
-
-Required properties for pin controller node:
- - compatible: "microchip,pic32mada-pinctrl"
- - reg: Address range of the pinctrl registers.
- - clocks: Clock specifier (see clock bindings for details)
-
-Required properties for pin configuration sub-nodes:
- - pins: List of pins to which the configuration applies.
-
-Optional properties for pin configuration sub-nodes:
-----------------------------------------------------
- - function: Mux function for the specified pins.
- - bias-pull-up: Enable weak pull-up.
- - bias-pull-down: Enable weak pull-down.
- - input-enable: Set the pin as an input.
- - output-low: Set the pin as an output level low.
- - output-high: Set the pin as an output level high.
- - microchip,digital: Enable digital I/O.
- - microchip,analog: Enable analog I/O.
-
-Example:
-
-pic32_pinctrl: pinctrl@1f801400{
-	#address-cells = <1>;
-	#size-cells = <1>;
-	compatible = "microchip,pic32mzda-pinctrl";
-	reg = <0x1f801400 0x400>;
-	clocks = <&rootclk PB1CLK>;
-
-	pinctrl_uart2: pinctrl_uart2 {
-		uart2-tx {
-			pins = "G9";
-			function = "U2TX";
-			microchip,digital;
-			output-low;
-		};
-		uart2-rx {
-			pins = "B0";
-			function = "U2RX";
-			microchip,digital;
-			input-enable;
-		};
-	};
-};
-
-uart2: serial@1f822200 {
-	compatible = "microchip,pic32mzda-uart";
-	reg = <0x1f822200 0x50>;
-	pinctrl-names = "default";
-	pinctrl-0 = <&pinctrl_uart2>;
-};
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +2 -0
new file mode 100644
index 000000000000..7a36e5ff61dd
@@ -0,0 +1,153 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/pinctrl/microchip,pic32mzda-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip PIC32 Pin Controller
+
+maintainers:
+  - Linus Walleij <[email protected]>
+
+description: |

Don't need '|' here.

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +10 -0
+  PIC32 pin configuration node is a node of a group of pins which can be used
+  for a specific device or function. This node represents configurations of
+  pins, optional function, and optional mux related configuration.
+
+properties:
+  compatible:
+    const: microchip,pic32mzda-pinctrl
+
+  reg:
+    maxItems: 1

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +9 -0
+
+  clocks:
+    maxItems: 1
+
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1

These 2 aren't needed. No 'reg' in the child nodes.

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 40

Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +9 -0
+
+patternProperties:
+  '^(?!pinctrl_)[a-z]+[0-9]*_[a-z0-9_]+$':
+    type: object
+    $ref: pinmux-node.yaml#
+
+    properties:
+      pins:
+        description: |

Don't need '|' here.

Quoted 13 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +13 -0
+          List of pins to which the configuration applies.
+        items:
+          type: string
+        minItems: 1
+
+      function: true
+
+      bias-pull-up: true
+      bias-pull-down: true
+      input-enable: true
+      output-low: true
+      output-high: true
+

Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml line 63

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +10 -0
+      microchip,digital:
+        description: Enable digital I/O.
+        type: boolean
+
+      microchip,analog:
+        description: Enable analog I/O.
+        type: boolean
+
+    required:
+      - pins

Put all this under a $defs entry and then do:

additionalProperties:
oneOf:
- additionalProperties:
$ref: $defs/pin-node
- $ref: $defs/pin-node

Rob