Skip to contentSkip to conversation

regulator: Add support for Allwinner D1 LDOs

PATCH Superseded Samuel Holland 4 participants 26 messages Aug 15, 2022 – Aug 17, 2022

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

v3 cover regulator: Add support for Allwinner D1 LDOs

This series adds bindings and a driver for the two pairs of LDOs inside the Allwinner D1 SoC.

A binding and driver change is required for the SRAM controller, to accept the regulators device as its child node. The new example in the SRAM controller binding uses the compatible string added in this series:
https://lore.kernel.org/lkml/[email protected]/

Changes in v3:
- Add "reg" property to bindings
- Add "unevaluatedProperties: true" to regulator nodes
- Minor changes to regulator node name patterns
- Remove system-ldos example (now added in patch 3)
- Adjust control flow in sun20i_regulator_get_regmap() for clarity
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context
- Use decimal numbers for .n_voltages instead of field widths
- Get the regmap from the parent device instead of a property/phandle

Samuel Holland (4):
regulator: dt-bindings: Add Allwinner D1 LDOs
regulator: sun20i: Add support for Allwinner D1 LDOs
dt-bindings: sram: sunxi-sram: Add optional regulators child
soc: sunxi: sram: Only iterate over SRAM children

 .../allwinner,sun20i-d1-analog-ldos.yaml      |  74 ++++++
 .../allwinner,sun20i-d1-system-ldos.yaml      |  37 +++
 .../allwinner,sun4i-a10-system-control.yaml   |  29 +++
 drivers/regulator/Kconfig                     |   8 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/sun20i-regulator.c          | 232 ++++++++++++++++++
 drivers/soc/sunxi/sunxi_sram.c                |   3 +
 7 files changed, 384 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml
 create mode 100644 drivers/regulator/sun20i-regulator.c
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH v3 1/4 regulator: dt-bindings: Add Allwinner D1 LDOs

The Allwinner D1 SoC contains two pairs of in-package LDOs. One pair is for general purpose use. LDOA generally powers the board's 1.8 V rail. LDOB generally powers the in-package DRAM, where applicable.

The other pair of LDOs powers the analog power domains inside the SoC, including the audio codec, thermal sensor, and ADCs. These LDOs require a 0.9 V bandgap voltage reference. The calibration value for the voltage reference is stored in an eFuse, accessed via an NVMEM cell.

Neither LDO control register is in its own MMIO range; instead, each regulator device relies on a regmap/syscon exported by its parent.

---

Changes in v3:
- Add "reg" property to bindings
- Add "unevaluatedProperties: true" to regulator nodes
- Minor changes to regulator node name patterns
- Remove system-ldos example (now added in patch 3)

Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context

 .../allwinner,sun20i-d1-analog-ldos.yaml      | 74 +++++++++++++++++++
 .../allwinner,sun20i-d1-system-ldos.yaml      | 37 ++++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +74 -0
new file mode 100644
index 000000000000..d6964b44ef21
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-analog-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 Analog LDOs
+
+description:
+  Allwinner D1 contains a set of LDOs which are designed to supply analog power
+  inside and outside the SoC. They are controlled by a register within the audio
+  codec MMIO space, but which is not part of the audio codec clock/reset domain.
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-analog-ldos
+
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim
+
+patternProperties:
+  "^(a|hp)ldo$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - nvmem-cells
+  - nvmem-cell-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    audio-codec@2030000 {
+        compatible = "simple-mfd", "syscon";
+        reg = <0x2030000 0x1000>;
+        ranges;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        regulators@2030348 {
+            compatible = "allwinner,sun20i-d1-analog-ldos";
+            reg = <0x2030348 0x4>;
+            nvmem-cells = <&bg_trim>;
+            nvmem-cell-names = "bg_trim";
+
+            reg_aldo: aldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+
+            reg_hpldo: hpldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +37 -0
new file mode 100644
index 000000000000..e3e2810fb3d7
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 System LDOs
+
+description:
+  Allwinner D1 contains a pair of general-purpose LDOs which are designed to
+  supply power inside and outside the SoC. They are controlled by a register
+  within the system control MMIO space.
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-system-ldos
+
+  reg:
+    maxItems: 1
+
+patternProperties:
+  "^ldo[ab]$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+...
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

Am Montag, 15. August 2022, 06:34:32 CEST schrieb Samuel Holland:

Quoted 58 lines

The Allwinner D1 SoC contains two pairs of in-package LDOs. One pair is for general purpose use. LDOA generally powers the board's 1.8 V rail. LDOB generally powers the in-package DRAM, where applicable.

The other pair of LDOs powers the analog power domains inside the SoC, including the audio codec, thermal sensor, and ADCs. These LDOs require a 0.9 V bandgap voltage reference. The calibration value for the voltage reference is stored in an eFuse, accessed via an NVMEM cell.

Neither LDO control register is in its own MMIO range; instead, each regulator device relies on a regmap/syscon exported by its parent.

---

Changes in v3:
- Add "reg" property to bindings
- Add "unevaluatedProperties: true" to regulator nodes
- Minor changes to regulator node name patterns
- Remove system-ldos example (now added in patch 3)

Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context

 .../allwinner,sun20i-d1-analog-ldos.yaml      | 74 +++++++++++++++++++
 .../allwinner,sun20i-d1-system-ldos.yaml      | 37 ++++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +21 -0
new file mode 100644
index 000000000000..d6964b44ef21
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-analog-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 Analog LDOs
+
+description:
+  Allwinner D1 contains a set of LDOs which are designed to supply analog power
+  inside and outside the SoC. They are controlled by a register within the audio
+  codec MMIO space, but which is not part of the audio codec clock/reset domain.
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-analog-ldos
+

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim

aren't dashes "-" preferred over underscores "_" in string names?

Maybe even make this "bandgap-trim" for a bit more explanatory naming?

Heiko

#3 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

Quoted 73 lines · Heiko Stübner

Am Montag, 15. August 2022, 06:34:32 CEST schrieb Samuel Holland:

Quoted 58 lines

The Allwinner D1 SoC contains two pairs of in-package LDOs. One pair is for general purpose use. LDOA generally powers the board's 1.8 V rail. LDOB generally powers the in-package DRAM, where applicable.

The other pair of LDOs powers the analog power domains inside the SoC, including the audio codec, thermal sensor, and ADCs. These LDOs require a 0.9 V bandgap voltage reference. The calibration value for the voltage reference is stored in an eFuse, accessed via an NVMEM cell.

Neither LDO control register is in its own MMIO range; instead, each regulator device relies on a regmap/syscon exported by its parent.

---

Changes in v3:
- Add "reg" property to bindings
- Add "unevaluatedProperties: true" to regulator nodes
- Minor changes to regulator node name patterns
- Remove system-ldos example (now added in patch 3)

Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context

 .../allwinner,sun20i-d1-analog-ldos.yaml      | 74 +++++++++++++++++++
 .../allwinner,sun20i-d1-system-ldos.yaml      | 37 ++++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +21 -0
new file mode 100644
index 000000000000..d6964b44ef21
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-analog-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 Analog LDOs
+
+description:
+  Allwinner D1 contains a set of LDOs which are designed to supply analog power
+  inside and outside the SoC. They are controlled by a register within the audio
+  codec MMIO space, but which is not part of the audio codec clock/reset domain.
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-analog-ldos
+

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim

aren't dashes "-" preferred over underscores "_" in string names?

Quoted 2 lines

Maybe even make this "bandgap-trim" for a bit more explanatory naming?

In node names yes. In strings, I think there is no preference. At least I am not aware of it.

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

In reply to Samuel Holland
Quoted 42 lines · Samuel Holland

The Allwinner D1 SoC contains two pairs of in-package LDOs. One pair is for general purpose use. LDOA generally powers the board's 1.8 V rail. LDOB generally powers the in-package DRAM, where applicable.

The other pair of LDOs powers the analog power domains inside the SoC, including the audio codec, thermal sensor, and ADCs. These LDOs require a 0.9 V bandgap voltage reference. The calibration value for the voltage reference is stored in an eFuse, accessed via an NVMEM cell.

Neither LDO control register is in its own MMIO range; instead, each regulator device relies on a regmap/syscon exported by its parent.

---

Changes in v3:
- Add "reg" property to bindings
- Add "unevaluatedProperties: true" to regulator nodes
- Minor changes to regulator node name patterns
- Remove system-ldos example (now added in patch 3)

Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context

 .../allwinner,sun20i-d1-analog-ldos.yaml      | 74 +++++++++++++++++++
 .../allwinner,sun20i-d1-system-ldos.yaml      | 37 ++++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +5 -0
new file mode 100644
index 000000000000..d6964b44ef21
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-analog-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 15

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +10 -0
+
+title: Allwinner D1 Analog LDOs
+
+description:
+  Allwinner D1 contains a set of LDOs which are designed to supply analog power
+  inside and outside the SoC. They are controlled by a register within the audio
+  codec MMIO space, but which is not part of the audio codec clock/reset domain.
+
+maintainers:
+  - Samuel Holland <[email protected]>

Please follow the example schema. Order is: title, maintainers, description.

Quoted 25 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +25 -0
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-analog-ldos
+
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim
+
+patternProperties:
+  "^(a|hp)ldo$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +10 -0
+  - reg
+  - nvmem-cells
+  - nvmem-cell-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    audio-codec@2030000 {
+        compatible = "simple-mfd", "syscon";

This cannot be on its own. Both require device specific compatible.

Quoted 32 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +24 -0
+        reg = <0x2030000 0x1000>;
+        ranges;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        regulators@2030348 {
+            compatible = "allwinner,sun20i-d1-analog-ldos";
+            reg = <0x2030348 0x4>;
+            nvmem-cells = <&bg_trim>;
+            nvmem-cell-names = "bg_trim";
+
+            reg_aldo: aldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+
+            reg_hpldo: hpldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +2 -0
new file mode 100644
index 000000000000..e3e2810fb3d7
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 System LDOs
+
+description:
+  Allwinner D1 contains a pair of general-purpose LDOs which are designed to
+  supply power inside and outside the SoC. They are controlled by a register
+  within the system control MMIO space.

Fix order.

Quoted 13 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +13 -0
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-system-ldos
+
+  reg:
+    maxItems: 1
+
+patternProperties:

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 35

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10 -0
+  "^ldo[ab]$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false

Example please.

Best regards,
Krzysztof

author maintainer
#5 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

Quoted 85 lines · Krzysztof Kozlowski
Quoted 42 lines · Samuel Holland

The Allwinner D1 SoC contains two pairs of in-package LDOs. One pair is for general purpose use. LDOA generally powers the board's 1.8 V rail. LDOB generally powers the in-package DRAM, where applicable.

The other pair of LDOs powers the analog power domains inside the SoC, including the audio codec, thermal sensor, and ADCs. These LDOs require a 0.9 V bandgap voltage reference. The calibration value for the voltage reference is stored in an eFuse, accessed via an NVMEM cell.

Neither LDO control register is in its own MMIO range; instead, each regulator device relies on a regmap/syscon exported by its parent.

---

Changes in v3:
- Add "reg" property to bindings
- Add "unevaluatedProperties: true" to regulator nodes
- Minor changes to regulator node name patterns
- Remove system-ldos example (now added in patch 3)

Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context

 .../allwinner,sun20i-d1-analog-ldos.yaml      | 74 +++++++++++++++++++
 .../allwinner,sun20i-d1-system-ldos.yaml      | 37 ++++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml
 create mode 100644 Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +5 -0
new file mode 100644
index 000000000000..d6964b44ef21
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-analog-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 15

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +10 -0
+
+title: Allwinner D1 Analog LDOs
+
+description:
+  Allwinner D1 contains a set of LDOs which are designed to supply analog power
+  inside and outside the SoC. They are controlled by a register within the audio
+  codec MMIO space, but which is not part of the audio codec clock/reset domain.
+
+maintainers:
+  - Samuel Holland <[email protected]>

Please follow the example schema. Order is: title, maintainers, description.

Quoted 29 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +29 -0
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-analog-ldos
+
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim
+
+patternProperties:
+  "^(a|hp)ldo$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - nvmem-cells
+  - nvmem-cell-names
+
Quoted 8 lines

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 50

Quoted 6 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +6 -0
+unevaluatedProperties: false
+
+examples:
+  - |
+    audio-codec@2030000 {
+        compatible = "simple-mfd", "syscon";

This cannot be on its own. Both require device specific compatible.

Again, the device-specific compatible does not exist, because the binding for the audio codec has not been written (and it will be quite nontrivial).

So I can:
1) Leave the example as-is until the audio codec binding gets written, and fill in the specific compatible at that time.
2) Remove the example, with the reasoning that the example really belongs with the MFD parent (like for the other regulator). Then there will be no example until the audio codec binding is written.
3) Drop the analog LDOs from this series entirely, and some parts of the SoC (like thermal monitoring) cannot be added to the DTSI until the audio codec binding is written.

What do you think?

The same question applies for the D1 SoC DTSI, where I use this same construct.

(And technically this does validate with the current schema.)

Quoted 64 lines
Quoted 32 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +24 -0
+        reg = <0x2030000 0x1000>;
+        ranges;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        regulators@2030348 {
+            compatible = "allwinner,sun20i-d1-analog-ldos";
+            reg = <0x2030348 0x4>;
+            nvmem-cells = <&bg_trim>;
+            nvmem-cell-names = "bg_trim";
+
+            reg_aldo: aldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+
+            reg_hpldo: hpldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +2 -0
new file mode 100644
index 000000000000..e3e2810fb3d7
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 System LDOs
+
+description:
+  Allwinner D1 contains a pair of general-purpose LDOs which are designed to
+  supply power inside and outside the SoC. They are controlled by a register
+  within the system control MMIO space.

Fix order.

Quoted 18 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +18 -0
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-system-ldos
+
+  reg:
+    maxItems: 1
+
+patternProperties:
+  "^ldo[ab]$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
Quoted 8 lines

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +5 -0
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false

Example please.

Rob asked me to move the example to the parent binding, so I did. The example is added in patch 3.

Regards,
Samuel

#6 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

Quoted 51 lines · Samuel Holland
Quoted 29 lines
Quoted 29 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +29 -0
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-analog-ldos
+
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim
+
+patternProperties:
+  "^(a|hp)ldo$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - nvmem-cells
+  - nvmem-cell-names
+
Quoted 8 lines

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 50

Quoted 6 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +6 -0
+unevaluatedProperties: false
+
+examples:
+  - |
+    audio-codec@2030000 {
+        compatible = "simple-mfd", "syscon";

This cannot be on its own. Both require device specific compatible.

Again, the device-specific compatible does not exist, because the binding for the audio codec has not been written (and it will be quite nontrivial).

So I can:
1) Leave the example as-is until the audio codec binding gets written, and fill in the specific compatible at that time.
2) Remove the example, with the reasoning that the example really belongs with the MFD parent (like for the other regulator). Then there will be no example until the audio codec binding is written.
3) Drop the analog LDOs from this series entirely, and some parts of the SoC (like thermal monitoring) cannot be added to the DTSI until the audio codec binding is written.

Quoted 1 line

What do you think?

How about just removing the audio-codec node? The schema is about regulators, not audio-codec.

OTOH, if you have parent device schema, you could put the example only there. But as I understand, you don't have, right?

Quoted 2 lines

The same question applies for the D1 SoC DTSI, where I use this same construct.

This is not correct and should be fixed. Either you add the schema with compatible or please drop the device node from the DTSI.

Quoted 76 lines

(And technically this does validate with the current schema.)

Quoted 64 lines
Quoted 32 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +24 -0
+        reg = <0x2030000 0x1000>;
+        ranges;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        regulators@2030348 {
+            compatible = "allwinner,sun20i-d1-analog-ldos";
+            reg = <0x2030348 0x4>;
+            nvmem-cells = <&bg_trim>;
+            nvmem-cell-names = "bg_trim";
+
+            reg_aldo: aldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+
+            reg_hpldo: hpldo {
+                regulator-min-microvolt = <1800000>;
+                regulator-max-microvolt = <1800000>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +2 -0
new file mode 100644
index 000000000000..e3e2810fb3d7
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 System LDOs
+
+description:
+  Allwinner D1 contains a pair of general-purpose LDOs which are designed to
+  supply power inside and outside the SoC. They are controlled by a register
+  within the system control MMIO space.

Fix order.

Quoted 18 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +18 -0
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-system-ldos
+
+  reg:
+    maxItems: 1
+
+patternProperties:
+  "^ldo[ab]$":
+    type: object
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
Quoted 8 lines

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +5 -0
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false

Example please.

Quoted 2 lines

Rob asked me to move the example to the parent binding, so I did. The example is added in patch 3.

Yeah, I noticed it later. It's fine.

Best regards,
Krzysztof

author maintainer
#7 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

Quoted 21 lines · Krzysztof Kozlowski
Quoted 20 lines · Samuel Holland
Quoted 6 lines

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 50

Quoted 4 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4 -0
+examples:
+  - |
+    audio-codec@2030000 {
+        compatible = "simple-mfd", "syscon";

This cannot be on its own. Both require device specific compatible.

Again, the device-specific compatible does not exist, because the binding for the audio codec has not been written (and it will be quite nontrivial).

So I can:
1) Leave the example as-is until the audio codec binding gets written, and fill in the specific compatible at that time.
2) Remove the example, with the reasoning that the example really belongs with the MFD parent (like for the other regulator). Then there will be no example until the audio codec binding is written.
3) Drop the analog LDOs from this series entirely, and some parts of the SoC (like thermal monitoring) cannot be added to the DTSI until the audio codec binding is written.

Quoted 4 lines
Quoted 1 line

What do you think?

How about just removing the audio-codec node? The schema is about regulators, not audio-codec.

That works for me. I put the extra node there to signify that this is a MFD child and requires some parent node to work, but I suppose it is not that helpful to have.

Quoted 2 lines

OTOH, if you have parent device schema, you could put the example only there. But as I understand, you don't have, right?

Right.

Quoted 4 lines
Quoted 1 line

The same question applies for the D1 SoC DTSI, where I use this same construct.

This is not correct and should be fixed. Either you add the schema with compatible or please drop the device node from the DTSI.

That's what I was afraid of.

Regards,
Samuel

Quoted 1 line
Quoted 1 line

(And technically this does validate with the current schema.)

#8 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

Quoted 6 lines · Samuel Holland
Quoted 4 lines
Quoted 1 line

The same question applies for the D1 SoC DTSI, where I use this same construct.

This is not correct and should be fixed. Either you add the schema with compatible or please drop the device node from the DTSI.

That's what I was afraid of.

The bindings can grow, so you can add a bindings stub documenting compatibles (device + simple-mfd + syscon) and IO space, then later extend it. Of course it is preferred to add bindings as complete as possible, but incremental growing also works.

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

In reply to Samuel Holland
Quoted 18 lines · Samuel Holland
Quoted 4 lines

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 50

Quoted 2 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +2 -0
+    audio-codec@2030000 {
+        compatible = "simple-mfd", "syscon";

This cannot be on its own. Both require device specific compatible.

Again, the device-specific compatible does not exist, because the binding for the audio codec has not been written (and it will be quite nontrivial).

So I can:
1) Leave the example as-is until the audio codec binding gets written, and fill in the specific compatible at that time.
2) Remove the example, with the reasoning that the example really belongs with the MFD parent (like for the other regulator). Then there will be no example until the audio codec binding is written.
3) Drop the analog LDOs from this series entirely, and some parts of the SoC (like thermal monitoring) cannot be added to the DTSI until the audio codec binding is written.

Quoted 5 lines

What do you think?

The same question applies for the D1 SoC DTSI, where I use this same construct.

(And technically this does validate with the current schema.)

BTW, it validates only because of limitation in DT schema. Such combination is not allowed and I wonder if we can make the schema stricter...

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH v3 1/4] regulator: dt-bindings: Add Allwinner D1 LDOs

In reply to Samuel Holland
Quoted 14 lines · Samuel Holland
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +14 -0
+  reg:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: NVMEM cell for the calibrated bandgap reference trim value
+
+  nvmem-cell-names:
+    items:
+      - const: bg_trim
+
+patternProperties:
+  "^(a|hp)ldo$":
+    type: object

Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 45

Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +10 -0
+    $ref: regulator.yaml#
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - nvmem-cells
+  - nvmem-cell-names
+
+unevaluatedProperties: false

one more: this must be additionalProperties:false, because you do not reference any other schema in top level. Same in second file.

Best regards,
Krzysztof

author maintainer
#11 lore raw

PATCH v3 2/4 regulator: sun20i: Add support for Allwinner D1 LDOs

In reply to Samuel Holland

D1 contains two pairs of LDOs. Since they have similar bindings, and they always exist together, put them in a single driver.

The analog LDOs are relatively boring, with a single linear range. Their one quirk is that a bandgap reference must be calibrated for them to produce the correct voltage.

The system LDOs have the complication that their voltage step is not an integer, so a custom .list_voltage is needed to get the rounding right.

---

Changes in v3:
- Adjust control flow in sun20i_regulator_get_regmap() for clarity

Changes in v2:
- Use decimal numbers for .n_voltages instead of field widths
- Get the regmap from the parent device instead of a property/phandle

 drivers/regulator/Kconfig            |   8 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/sun20i-regulator.c | 232 +++++++++++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/regulator/sun20i-regulator.c
drivers/regulator/Kconfig +8 -0
index 23e3e4a35cc9..0c5727173fa0 100644
@@ -1262,6 +1262,14 @@ config REGULATOR_STW481X_VMMC
 	  This driver supports the internal VMMC regulator in the STw481x
 	  PMIC chips.
 
+config REGULATOR_SUN20I
+	tristate "Allwinner D1 internal LDOs"
+	depends on ARCH_SUNXI || COMPILE_TEST
+	depends on MFD_SYSCON && NVMEM
+	default ARCH_SUNXI
+	help
+	  This driver supports the internal LDOs in the Allwinner D1 SoC.
+
 config REGULATOR_SY7636A
 	tristate "Silergy SY7636A voltage regulator"
 	help
drivers/regulator/Makefile +1 -0
index fa49bb6cc544..5dff112eb015 100644
@@ -148,6 +148,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SUN20I) += sun20i-regulator.o
 obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
drivers/regulator/sun20i-regulator.c new file +232 -0

232 lines not on this page · raw message

Signature · 1 line
2.35.1
Reviewed-by Tested-by on v3 2/4
#12 lore raw

Re: [PATCH v3 2/4] regulator: sun20i: Add support for Allwinner D1 LDOs

Am Montag, 15. August 2022, 06:34:33 CEST schrieb Samuel Holland:

Quoted 63 lines

D1 contains two pairs of LDOs. Since they have similar bindings, and they always exist together, put them in a single driver.

The analog LDOs are relatively boring, with a single linear range. Their one quirk is that a bandgap reference must be calibrated for them to produce the correct voltage.

The system LDOs have the complication that their voltage step is not an integer, so a custom .list_voltage is needed to get the rounding right.

---

Changes in v3:
- Adjust control flow in sun20i_regulator_get_regmap() for clarity

Changes in v2:
- Use decimal numbers for .n_voltages instead of field widths
- Get the regmap from the parent device instead of a property/phandle

 drivers/regulator/Kconfig            |   8 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/sun20i-regulator.c | 232 +++++++++++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/regulator/sun20i-regulator.c
drivers/regulator/Kconfig +8 -0
index 23e3e4a35cc9..0c5727173fa0 100644
@@ -1262,6 +1262,14 @@ config REGULATOR_STW481X_VMMC
 	  This driver supports the internal VMMC regulator in the STw481x
 	  PMIC chips.
 
+config REGULATOR_SUN20I
+	tristate "Allwinner D1 internal LDOs"
+	depends on ARCH_SUNXI || COMPILE_TEST
+	depends on MFD_SYSCON && NVMEM
+	default ARCH_SUNXI
+	help
+	  This driver supports the internal LDOs in the Allwinner D1 SoC.
+
 config REGULATOR_SY7636A
 	tristate "Silergy SY7636A voltage regulator"
 	help
drivers/regulator/Makefile +1 -0
index fa49bb6cc544..5dff112eb015 100644
@@ -148,6 +148,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SUN20I) += sun20i-regulator.o
 obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
drivers/regulator/sun20i-regulator.c new file +0 -0
new file mode 100644
index 000000000000..46f3927d7d10

drivers/regulator/sun20i-regulator.c line 4

Quoted 4 lines
drivers/regulator/sun20i-regulator.c new file +4 -0
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2021-2022 Samuel Holland <[email protected]>
+//

nit: shouldn't the comment look like
/*
* Copyright (c) 2021-2022 Samuel Holland <[email protected]> */

otherwise looks great

author maintainer
#13 lore raw

Re: [PATCH v3 2/4] regulator: sun20i: Add support for Allwinner D1 LDOs

Quoted 65 lines · Heiko Stübner

Am Montag, 15. August 2022, 06:34:33 CEST schrieb Samuel Holland:

Quoted 64 lines

D1 contains two pairs of LDOs. Since they have similar bindings, and they always exist together, put them in a single driver.

The analog LDOs are relatively boring, with a single linear range. Their one quirk is that a bandgap reference must be calibrated for them to produce the correct voltage.

The system LDOs have the complication that their voltage step is not an integer, so a custom .list_voltage is needed to get the rounding right.

---

Changes in v3:
- Adjust control flow in sun20i_regulator_get_regmap() for clarity

Changes in v2:
- Use decimal numbers for .n_voltages instead of field widths
- Get the regmap from the parent device instead of a property/phandle

 drivers/regulator/Kconfig            |   8 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/sun20i-regulator.c | 232 +++++++++++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/regulator/sun20i-regulator.c
drivers/regulator/Kconfig +8 -0
index 23e3e4a35cc9..0c5727173fa0 100644
@@ -1262,6 +1262,14 @@ config REGULATOR_STW481X_VMMC
 	  This driver supports the internal VMMC regulator in the STw481x
 	  PMIC chips.
 
+config REGULATOR_SUN20I
+	tristate "Allwinner D1 internal LDOs"
+	depends on ARCH_SUNXI || COMPILE_TEST
+	depends on MFD_SYSCON && NVMEM
+	default ARCH_SUNXI
+	help
+	  This driver supports the internal LDOs in the Allwinner D1 SoC.
+
 config REGULATOR_SY7636A
 	tristate "Silergy SY7636A voltage regulator"
 	help
drivers/regulator/Makefile +1 -0
index fa49bb6cc544..5dff112eb015 100644
@@ -148,6 +148,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SUN20I) += sun20i-regulator.o
 obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
drivers/regulator/sun20i-regulator.c new file +1 -0
new file mode 100644
index 000000000000..46f3927d7d10
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0-only
Quoted 8 lines

drivers/regulator/sun20i-regulator.c line 4

Quoted 3 lines
drivers/regulator/sun20i-regulator.c new file +3 -0
+//
+// Copyright (c) 2021-2022 Samuel Holland <[email protected]>
+//

nit: shouldn't the comment look like
/*
* Copyright (c) 2021-2022 Samuel Holland <[email protected]> */

I have had multiple requests from maintainers to use the former style because it is more visually consistent. git grep '^// Copy' drivers sound returns over 1500 hits. But it doesn't really matter to me.

Regards,
Samuel

#14 lore raw

Re: [PATCH v3 2/4] regulator: sun20i: Add support for Allwinner D1 LDOs

Am Mittwoch, 17. August 2022, 10:28:40 CEST schrieb Samuel Holland:

Quoted 75 lines · Heiko Stübner
Quoted 65 lines

Am Montag, 15. August 2022, 06:34:33 CEST schrieb Samuel Holland:

Quoted 64 lines

D1 contains two pairs of LDOs. Since they have similar bindings, and they always exist together, put them in a single driver.

The analog LDOs are relatively boring, with a single linear range. Their one quirk is that a bandgap reference must be calibrated for them to produce the correct voltage.

The system LDOs have the complication that their voltage step is not an integer, so a custom .list_voltage is needed to get the rounding right.

---

Changes in v3:
- Adjust control flow in sun20i_regulator_get_regmap() for clarity

Changes in v2:
- Use decimal numbers for .n_voltages instead of field widths
- Get the regmap from the parent device instead of a property/phandle

 drivers/regulator/Kconfig            |   8 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/sun20i-regulator.c | 232 +++++++++++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/regulator/sun20i-regulator.c
drivers/regulator/Kconfig +8 -0
index 23e3e4a35cc9..0c5727173fa0 100644
@@ -1262,6 +1262,14 @@ config REGULATOR_STW481X_VMMC
 	  This driver supports the internal VMMC regulator in the STw481x
 	  PMIC chips.
 
+config REGULATOR_SUN20I
+	tristate "Allwinner D1 internal LDOs"
+	depends on ARCH_SUNXI || COMPILE_TEST
+	depends on MFD_SYSCON && NVMEM
+	default ARCH_SUNXI
+	help
+	  This driver supports the internal LDOs in the Allwinner D1 SoC.
+
 config REGULATOR_SY7636A
 	tristate "Silergy SY7636A voltage regulator"
 	help
drivers/regulator/Makefile +1 -0
index fa49bb6cc544..5dff112eb015 100644
@@ -148,6 +148,7 @@ obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
+obj-$(CONFIG_REGULATOR_SUN20I) += sun20i-regulator.o
 obj-$(CONFIG_REGULATOR_SY7636A) += sy7636a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
 obj-$(CONFIG_REGULATOR_SY8824X) += sy8824x.o
drivers/regulator/sun20i-regulator.c new file +1 -0
new file mode 100644
index 000000000000..46f3927d7d10
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0-only
Quoted 8 lines

drivers/regulator/sun20i-regulator.c line 4

Quoted 3 lines
drivers/regulator/sun20i-regulator.c new file +3 -0
+//
+// Copyright (c) 2021-2022 Samuel Holland <[email protected]>
+//

nit: shouldn't the comment look like
/*
* Copyright (c) 2021-2022 Samuel Holland <[email protected]> */

Quoted 3 lines

I have had multiple requests from maintainers to use the former style because it is more visually consistent. git grep '^// Copy' drivers sound returns over 1500 hits. But it doesn't really matter to me.

ok ... I guess that is something that's changing then :-)

I just looked into some drivers and the coding-style rst document, but I guess it's the maintainer's call how this should look.

author maintainer
#15 lore raw

PATCH v3 3/4 dt-bindings: sram: sunxi-sram: Add optional regulators child

In reply to Samuel Holland

Some sunxi SoCs have in-package regulators controlled by a register in the system control MMIO block. Allow a child node for these regulators in addition to SRAM child nodes.

---

Changes in v3:
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Changes in v2:
- New patch for v2

 .../allwinner,sun4i-a10-system-control.yaml   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +29 -0
index d64c1b28fb61..915ca85c3f10 100644
@@ -56,6 +56,10 @@ properties:
   ranges: true
 
 patternProperties:
+  "^regulators@[0-9a-f]+$":
+    $ref: /schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+    unevaluatedProperties: false
+
   "^sram@[a-z0-9]+":
     type: object
 
@@ -130,3 +134,28 @@ examples:
         };
       };
     };
+
+  - |
+    syscon@3000000 {
+      compatible = "allwinner,sun20i-d1-system-control";
+      reg = <0x3000000 0x1000>;
+      ranges;
+      #address-cells = <1>;
+      #size-cells = <1>;
+
+      regulators@3000150 {
+        compatible = "allwinner,sun20i-d1-system-ldos";
+        reg = <0x3000150 0x4>;
+
+        reg_ldoa: ldoa {
+          regulator-min-microvolt = <1800000>;
+          regulator-max-microvolt = <1800000>;
+        };
+
+        reg_ldob: ldob {
+          regulator-name = "vcc-dram";
+          regulator-min-microvolt = <1500000>;
+          regulator-max-microvolt = <1500000>;
+        };
+      };
+    };
Signature · 1 line
2.35.1
maintainer
#16 lore raw

Re: [PATCH v3 3/4] dt-bindings: sram: sunxi-sram: Add optional regulators child

Quoted 13 lines · Samuel Holland

Some sunxi SoCs have in-package regulators controlled by a register in the system control MMIO block. Allow a child node for these regulators in addition to SRAM child nodes.

---

Changes in v3:
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Quoted 6 lines

Changes in v2:
- New patch for v2

 .../allwinner,sun4i-a10-system-control.yaml   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.example.dtb:0:0: /example-1/syscon@3000000: failed to match any schema with compatible: ['allwinner,sun20i-d1-system-control']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#17 lore raw

Re: [PATCH v3 3/4] dt-bindings: sram: sunxi-sram: Add optional regulators child

Am Montag, 15. August 2022, 16:01:47 CEST schrieb Rob Herring:

Quoted 21 lines · Samuel Holland
Quoted 13 lines

Some sunxi SoCs have in-package regulators controlled by a register in the system control MMIO block. Allow a child node for these regulators in addition to SRAM child nodes.

---

Changes in v3:
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Quoted 6 lines

Changes in v2:
- New patch for v2

 .../allwinner,sun4i-a10-system-control.yaml   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
Quoted 7 lines

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.example.dtb:0:0: /example-1/syscon@3000000: failed to match any schema with compatible: ['allwinner,sun20i-d1-system-control']

This got added in
"dt-bindings: sram: sunxi-sram: Add D1 compatible string"

( https://lore.kernel.org/r/[email protected] )

Quoted 22 lines

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#18 lore raw

Re: [PATCH v3 3/4] dt-bindings: sram: sunxi-sram: Add optional regulators child

In reply to Samuel Holland
Quoted 24 lines · Samuel Holland

Some sunxi SoCs have in-package regulators controlled by a register in the system control MMIO block. Allow a child node for these regulators in addition to SRAM child nodes.

---

Changes in v3:
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Changes in v2:
- New patch for v2

 .../allwinner,sun4i-a10-system-control.yaml   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +0 -0
index d64c1b28fb61..915ca85c3f10 100644

Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml properties: · line 61

Quoted 6 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +3 -0
@@ -56,6 +56,10 @@ properties:
   ranges: true
 
 patternProperties:
+  "^regulators@[0-9a-f]+$":
+    $ref: /schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+    unevaluatedProperties: false

unevaluatedProperties is not needed. Your other schema does not allow anything else here.

Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml examples: · line 140

Quoted 12 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +5 -0
+
   "^sram@[a-z0-9]+":
     type: object
 
@@ -130,3 +134,28 @@ examples:
         };
       };
     };
+
+  - |
+    syscon@3000000 {
+      compatible = "allwinner,sun20i-d1-system-control";

Your other example uses simple-mfd, syscon... A bit confusing.

Quoted 11 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +11 -0
+      reg = <0x3000000 0x1000>;
+      ranges;
+      #address-cells = <1>;
+      #size-cells = <1>;
+
+      regulators@3000150 {
+        compatible = "allwinner,sun20i-d1-system-ldos";
+        reg = <0x3000150 0x4>;
+
+        reg_ldoa: ldoa {
+          regulator-min-microvolt = <1800000>;

Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml examples: · line 161

Quoted 10 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +10 -0
+          regulator-max-microvolt = <1800000>;
+        };
+
+        reg_ldob: ldob {
+          regulator-name = "vcc-dram";
+          regulator-min-microvolt = <1500000>;
+          regulator-max-microvolt = <1500000>;
+        };
+      };
+    };

Best regards,
Krzysztof

author maintainer
#19 lore raw

Re: [PATCH v3 3/4] dt-bindings: sram: sunxi-sram: Add optional regulators child

Quoted 27 lines · Krzysztof Kozlowski
Quoted 26 lines · Samuel Holland

Some sunxi SoCs have in-package regulators controlled by a register in the system control MMIO block. Allow a child node for these regulators in addition to SRAM child nodes.

---

Changes in v3:
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Changes in v2:
- New patch for v2

 .../allwinner,sun4i-a10-system-control.yaml   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +0 -0
index d64c1b28fb61..915ca85c3f10 100644
@@ -56,6 +56,10 @@ properties:
   ranges: true
 
Quoted 7 lines

Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml properties: · line 61

Quoted 4 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +3 -0
 patternProperties:
+  "^regulators@[0-9a-f]+$":
+    $ref: /schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+    unevaluatedProperties: false

unevaluatedProperties is not needed. Your other schema does not allow anything else here.

I can remove it. I added it because it looks like the dt-schema tools use it as an indicator that the matched properties are child nodes[1]. Maybe that is not relevant here?

Regards,
Samuel

[1]: https://github.com/devicetree-org/dt-schema/commit/b12b3737cabc

#20 lore raw

Re: [PATCH v3 3/4] dt-bindings: sram: sunxi-sram: Add optional regulators child

Quoted 36 lines · Samuel Holland
Quoted 27 lines · Krzysztof Kozlowski
Quoted 26 lines · Samuel Holland

Some sunxi SoCs have in-package regulators controlled by a register in the system control MMIO block. Allow a child node for these regulators in addition to SRAM child nodes.

---

Changes in v3:
- Require the regulators node to have a unit address
- Reference the regulator schema from the SRAM controller schema
- Move the system LDOs example to the SRAM controller schema
- Reorder the patches so the example passes validation

Changes in v2:
- New patch for v2

 .../allwinner,sun4i-a10-system-control.yaml   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +0 -0
index d64c1b28fb61..915ca85c3f10 100644
@@ -56,6 +56,10 @@ properties:
   ranges: true
 
Quoted 7 lines

Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml properties: · line 61

Quoted 4 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +3 -0
 patternProperties:
+  "^regulators@[0-9a-f]+$":
+    $ref: /schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
+    unevaluatedProperties: false

unevaluatedProperties is not needed. Your other schema does not allow anything else here.

Quoted 3 lines

I can remove it. I added it because it looks like the dt-schema tools use it as an indicator that the matched properties are child nodes[1]. Maybe that is not relevant here?

It is not relevant here as the other schema does not allow anything else.

Best regards,
Krzysztof

author maintainer
#21 lore raw

PATCH v3 4/4 soc: sunxi: sram: Only iterate over SRAM children

In reply to Samuel Holland

Now that a "regulators" child is accepted by the controller binding, the debugfs show routine must be explicitly limited to "sram" children.

---

(no changes since v2)

Changes in v2:
- New patch for v2

 drivers/soc/sunxi/sunxi_sram.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +3 -0
index 92f9186c1c42..6acaaeb65652 100644
@@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
 	seq_puts(s, "--------------------\n\n");
 
 	for_each_child_of_node(sram_dev->of_node, sram_node) {
+		if (!of_node_name_eq(sram_node, "sram"))
+			continue;
+
 		sram_addr_p = of_get_address(sram_node, 0, NULL, NULL);
 
 		seq_printf(s, "sram@%08x\n",
Signature · 1 line
2.35.1
Reviewed-by Tested-by on v3 4/4
#22 lore raw

Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children

Am Montag, 15. August 2022, 06:34:35 CEST schrieb Samuel Holland:

Quoted 4 lines

Now that a "regulators" child is accepted by the controller binding, the debugfs show routine must be explicitly limited to "sram" children.

#23 lore raw

Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children

In reply to Samuel Holland
Quoted 19 lines · Samuel Holland

Now that a "regulators" child is accepted by the controller binding, the debugfs show routine must be explicitly limited to "sram" children.

---

(no changes since v2)

Changes in v2:
- New patch for v2

 drivers/soc/sunxi/sunxi_sram.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +0 -0
index 92f9186c1c42..6acaaeb65652 100644

drivers/soc/sunxi/sunxi_sram.c static int sunxi_sram_show(struct seq_file *s, void *data) · line 123

Quoted 4 lines
drivers/soc/sunxi/sunxi_sram.c +1 -0
@@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
 	seq_puts(s, "--------------------\n\n");
 
 	for_each_child_of_node(sram_dev->of_node, sram_node) {
+		if (!of_node_name_eq(sram_node, "sram"))

You should not rely on node names. They can change in DTS. Why do you need to test for the name?

Best regards,
Krzysztof

#24 lore raw

Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children

Quoted 22 lines · Krzysztof Kozlowski
Quoted 21 lines · Samuel Holland

Now that a "regulators" child is accepted by the controller binding, the debugfs show routine must be explicitly limited to "sram" children.

---

(no changes since v2)

Changes in v2:
- New patch for v2

 drivers/soc/sunxi/sunxi_sram.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +0 -0
index 92f9186c1c42..6acaaeb65652 100644
@@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
 	seq_puts(s, "--------------------\n\n");
 
Quoted 6 lines

drivers/soc/sunxi/sunxi_sram.c static int sunxi_sram_show(struct seq_file *s, void *data) · line 123

Quoted 2 lines
drivers/soc/sunxi/sunxi_sram.c +1 -0
 	for_each_child_of_node(sram_dev->of_node, sram_node) {
+		if (!of_node_name_eq(sram_node, "sram"))

You should not rely on node names. They can change in DTS. Why do you need to test for the name?

Ah, it is not a device node but a child property, right? In such case, it's of course fine.

The device node names could change and should not be considered ABI (at least I hope should not...).

Best regards,
Krzysztof

author maintainer
#25 lore raw

Re: [PATCH v3 4/4] soc: sunxi: sram: Only iterate over SRAM children

Quoted 30 lines · Krzysztof Kozlowski
Quoted 22 lines · Krzysztof Kozlowski
Quoted 21 lines · Samuel Holland

Now that a "regulators" child is accepted by the controller binding, the debugfs show routine must be explicitly limited to "sram" children.

---

(no changes since v2)

Changes in v2:
- New patch for v2

 drivers/soc/sunxi/sunxi_sram.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/sunxi/sunxi_sram.c +0 -0
index 92f9186c1c42..6acaaeb65652 100644
@@ -120,6 +120,9 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
 	seq_puts(s, "--------------------\n\n");
 
Quoted 6 lines

drivers/soc/sunxi/sunxi_sram.c static int sunxi_sram_show(struct seq_file *s, void *data) · line 123

Quoted 2 lines
drivers/soc/sunxi/sunxi_sram.c +1 -0
 	for_each_child_of_node(sram_dev->of_node, sram_node) {
+		if (!of_node_name_eq(sram_node, "sram"))

You should not rely on node names. They can change in DTS. Why do you need to test for the name?

Quoted 2 lines

Ah, it is not a device node but a child property, right? In such case, it's of course fine.

It is a child node.

Quoted 2 lines

The device node names could change and should not be considered ABI (at least I hope should not...).

The node names are limited by patternProperties in the controller binding. I can check the child nodes for compatibility with "mmio-sram" if that is better.

Regards,
Samuel