Skip to contentSkip to conversation

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

PATCH Superseded Udaya Kiran Challa 2 participants 2 messages Jul 7

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 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  | 145 ++++++++++++++++++
 2 files changed, 145 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 +145 -0

145 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: - [High] The regular expressions used for matching pin configuration nodes are fundamentally flawed…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The regular expressions used for matching pin configuration nodes are fundamentally flawed, intercepting standard devicetree properties and improperly restricting valid node names. --

--- Patch [1]: [PATCH v2] dt-bindings: pinctrl: microchip,pic32mzda-pinctrl: Convert to DT schema --- commit 016f4a5779d5338a039594d73c69d1421ff3e20f
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 4 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +0 -0
new file mode 100644

[ ... ]

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +5 -0
+properties:
+  compatible:
+    const: microchip,pic32mzda-pinctrl
+
+  reg:

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

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

[Severity: High]
Are these properties usable given the regex constraints on child nodes?

Since the patternProperties regexes below forbid the '@' symbol, it doesn't appear possible to create child nodes with unit addresses to utilize this address space mapping.

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

Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +3 -0
+patternProperties:
+  '^[a-z0-9]+[_-][a-z0-9_-]*$':
+    type: object

[Severity: High]
Could this regex unintentionally intercept standard properties?

In JSON schema, patternProperties evaluates against every key in the object, including property names. Because this regex matches any string with a dash or underscore, standard properties like "pinctrl-names" or "gpio-controller" will match it and be forced to validate as an object. This will cause dt_binding_check to fail when they are used.

Additionally, does this pattern inadvertently prevent the use of standard generic node names that don't contain dashes (like "uart" or "tx")? Since additionalProperties is false, names without dashes will be rejected.

Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +4 -0
+    description: |
+      Pin configuration node with pin muxing and configuration properties.
+      Can be either a direct pin configuration node or a container node
+      with child pin configuration nodes.

[ ... ]

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
+    patternProperties:
+      '^(?!bias-|input-|output-)[a-z0-9]+[_-][a-z0-9_-]*$':
+        type: object

[Severity: High]
Similar to the parent node pattern, will this regex incorrectly intercept standard devicetree properties that contain dashes, and reject standard generic node names without dashes?

Also, does this negative lookahead incorrectly reject valid devicetree node names just because they happen to start with "bias-", "input-", or "output-"?

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/microchip,pic32mzda-pinctrl.yaml new file +6 -0
+        description: |
+          Child pin configuration node.
+
+        properties:
+          pins:
+            items:

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1