regulator: Add support for Allwinner D1 LDOs
Subsystems (3)
Samuel Holland
maintainerv2 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 preparatory binding and driver change is required for the SRAM controller, so the regulators device can be its child node.
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):
dt-bindings: sram: sunxi-sram: Add optional regulators child
soc: sunxi: sram: Only iterate over SRAM children
regulator: dt-bindings: Add Allwinner D1 LDOs
regulator: sun20i: Add support for Allwinner D1 LDOs
.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 +++++ .../allwinner,sun4i-a10-system-control.yaml | 3 + drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/sun20i-regulator.c | 232 ++++++++++++++++++ drivers/soc/sunxi/sunxi_sram.c | 3 + 7 files changed, 369 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
Samuel Holland
maintainerPATCH v2 1/4 dt-bindings: sram: sunxi-sram: Add optional regulators child
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 v2:
- New patch for v2
.../bindings/sram/allwinner,sun4i-a10-system-control.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +3 -0
@@ -56,6 +56,9 @@ properties: ranges: true + regulators: + type: object + patternProperties: "^sram@[a-z0-9]+": type: object
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH v2 1/4] dt-bindings: sram: sunxi-sram: Add optional regulators child
Quoted 18 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.
Signed-off-by Samuel Holland <[email protected]>---
Changes in v2:
- New patch for v2.../bindings/sram/allwinner,sun4i-a10-system-control.yaml | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +0
-0
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml properties: · line 60
Quoted 5 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +2
-0@@ -56,6 +56,9 @@ properties: ranges: true + regulators: + type: object
This should reference the regulator schema.
Also, it's preferred to have 1 complete example here rather than piecemeal examples in each child schema.
Quoted 8 lines
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml +1
-0+ patternProperties: "^sram@[a-z0-9]+": type: objectSignature · 1 line
2.35.1
Samuel Holland
maintainerPATCH v2 2/4 soc: sunxi: sram: Only iterate over SRAM children
In reply to Samuel HollandNow that a "regulators" child is accepted by the controller binding, the debugfs show routine must be explicitly limited to "sram" children. Otherwise, it will crash because the "regulators" node has no address.
---
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
@@ -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
Samuel Holland
maintainerPATCH v2 3/4 regulator: dt-bindings: Add Allwinner D1 LDOs
In reply to Samuel HollandThe 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 v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context
.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++++++++++++++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 ++++++++++++++++ 2 files changed, 122 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 +65 -0
@@ -0,0 +1,65 @@ +# 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 + + nvmem-cells: + items: + - description: NVMEM cell for the calibrated bandgap reference trim value + + nvmem-cell-names: + items: + - const: bg_trim + +patternProperties: + "^(aldo|hpldo)$": + type: object + $ref: regulator.yaml# + +required: + - compatible + - nvmem-cells + - nvmem-cell-names + +unevaluatedProperties: false + +examples: + - | + audio-codec@2030000 { + compatible = "simple-mfd", "syscon"; + reg = <0x2030000 0x1000>; + + regulators { + compatible = "allwinner,sun20i-d1-analog-ldos"; + 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 +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH v2 3/4] regulator: dt-bindings: Add Allwinner D1 LDOs
Quoted 19 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.
Signed-off-by Samuel Holland <[email protected]>---
Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context
Quoted 6 lines
.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++++++++++++++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 ++++++++++++++++ 2 files changed, 122 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
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/regulator/allwinner,sun20i-d1-system-ldos.example.dtb:0:0: /example-0/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.
Rob Herring
maintainerRe: [PATCH v2 3/4] regulator: dt-bindings: Add Allwinner D1 LDOs
In reply to Samuel HollandQuoted 52 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.
Signed-off-by Samuel Holland <[email protected]>---
Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++++++++++++++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 ++++++++++++++++ 2 files changed, 122 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.yamlDocumentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +21
-0@@ -0,0 +1,65 @@ +# 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+ nvmem-cells: + items: + - description: NVMEM cell for the calibrated bandgap reference trim value + + nvmem-cell-names: + items: + - const: bg_trim + +patternProperties: + "^(aldo|hpldo)$":
'^(a|hp)ldo$'
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +2
-0+ type: object + $ref: regulator.yaml#
unevaluatedProperties: false
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 45
Quoted 12 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +12
-0+ +required: + - compatible + - nvmem-cells + - nvmem-cell-names + +unevaluatedProperties: false + +examples: + - | + audio-codec@2030000 { + compatible = "simple-mfd", "syscon";
Needs a specific compatible. Obviously there's some other functionality here if this is an 'audio-codec'.
'simple-mfd' also means the child nodes have zero dependence on the parent node and its resources.
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 49
Quoted 4 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4
-0+ reg = <0x2030000 0x1000>; + + regulators { + compatible = "allwinner,sun20i-d1-analog-ldos";
Is there a defined set of registers for these regulators? If so, put them into 'reg'.
Quoted 35 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +16
-0+ 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 +13
-0@@ -0,0 +1,57 @@ +# 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. +
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10
-0+maintainers: + - Samuel Holland <[email protected]> + +properties: + compatible: + enum: + - allwinner,sun20i-d1-system-ldos + +patternProperties: + "^(ldoa|ldob)$":
'^ldo[ab]$'
Any reason the naming is not consistent with 'ldo' as the prefix or suffix?
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 25
Quoted 2 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +2
-0+ type: object + $ref: regulator.yaml#
unevaluatedProperties: false
Quoted 36 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +32
-0+ +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + syscon@3000000 { + compatible = "allwinner,sun20i-d1-system-control"; + reg = <0x3000000 0x1000>; + ranges; + #address-cells = <1>; + #size-cells = <1>; + + regulators { + compatible = "allwinner,sun20i-d1-system-ldos"; + + 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
Samuel Holland
maintainerRe: [PATCH v2 3/4] regulator: dt-bindings: Add Allwinner D1 LDOs
Hi Rob,
Thanks again for your review.
Quoted 71 lines · Rob Herring
Quoted 52 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.
Signed-off-by Samuel Holland <[email protected]>---
Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++++++++++++++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 ++++++++++++++++ 2 files changed, 122 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.yamlDocumentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +21
-0@@ -0,0 +1,65 @@ +# 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+ nvmem-cells: + items: + - description: NVMEM cell for the calibrated bandgap reference trim value + + nvmem-cell-names: + items: + - const: bg_trim + +patternProperties: + "^(aldo|hpldo)$":'^(a|hp)ldo$'
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +2
-0+ type: object + $ref: regulator.yaml#unevaluatedProperties: false
Quoted 15 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 45
Quoted 12 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +12
-0+ +required: + - compatible + - nvmem-cells + - nvmem-cell-names + +unevaluatedProperties: false + +examples: + - | + audio-codec@2030000 { + compatible = "simple-mfd", "syscon";Needs a specific compatible. Obviously there's some other functionality here if this is an 'audio-codec'.
I am not yet ready to submit the binding or driver for the audio codec, as I still need to work out the details for jack detection (and some other issues). If I added the specific audio codec compatible now, without the properties required for the sound driver, that would create backward compatibility issues, right?
My intention is to add the specific compatible along with the ASoC support.
Quoted 2 lines
'simple-mfd' also means the child nodes have zero dependence on the parent node and its resources.
That is correct. The regulators have zero dependencies on the audio codec resources (clocks/resets/etc.). The _only_ relationship is the overlapping address of the MMIO register.
Quoted 7 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 49
Quoted 4 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4
-0+ reg = <0x2030000 0x1000>; + + regulators { + compatible = "allwinner,sun20i-d1-analog-ldos";Is there a defined set of registers for these regulators? If so, put them into 'reg'.
What do you suggest for 'ranges' in the parent device? I ask because the SRAM/system controller binding requires an empty 'ranges' property.
With empty 'ranges', the child has to compute the relative address for use with the parent's regmap, but maybe that is okay?
Quoted 48 lines
Quoted 35 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +16
-0+ 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 +13
-0@@ -0,0 +1,57 @@ +# 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. +Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10
-0+maintainers: + - Samuel Holland <[email protected]> + +properties: + compatible: + enum: + - allwinner,sun20i-d1-system-ldos + +patternProperties: + "^(ldoa|ldob)$":'^ldo[ab]$'
Quoted 2 lines
Any reason the naming is not consistent with 'ldo' as the prefix or suffix?
All four names match the pin names from the SoC datasheet.
Quoted 4 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 25
Quoted 2 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +2
-0+ type: object + $ref: regulator.yaml#unevaluatedProperties: false
I will fix these for v3.
Regards,
Samuel
Quoted 36 lines
Quoted 36 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +32
-0+ +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + syscon@3000000 { + compatible = "allwinner,sun20i-d1-system-control"; + reg = <0x3000000 0x1000>; + ranges; + #address-cells = <1>; + #size-cells = <1>; + + regulators { + compatible = "allwinner,sun20i-d1-system-ldos"; + + 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
Jernej Škrabec
maintainerRe: [PATCH v2 3/4] regulator: dt-bindings: Add Allwinner D1 LDOs
Dne četrtek, 04. avgust 2022 ob 05:03:07 CEST je Samuel Holland napisal(a):
Quoted 105 lines
Hi Rob,
Thanks again for your review.
Quoted 78 lines · Rob Herring
Quoted 63 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.
Signed-off-by Samuel Holland <[email protected]>---
Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++++++++++++++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 ++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yamlcreate mode 100644Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml>>
diff --git a/Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yamlb/Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yamlnew file mode 100644
index 000000000000..19c984ef4e53
---/dev/null
+++
b/Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analogDocumentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4
-1-ldos.yaml @@ -0,0 +1,65 @@ +# 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 new file +5
-0+ +title: Allwinner D1 Analog LDOs + +description: + Allwinner D1 contains a set of LDOs which are designed to supplyanalog 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. +
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +11
-0+maintainers: + - Samuel Holland <[email protected]> + +properties: + compatible: + enum: + - allwinner,sun20i-d1-analog-ldos + + nvmem-cells: + items: + - description: NVMEM cell for the calibrated bandgap referencetrim value +
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 31
Quoted 7 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +6
-0+ nvmem-cell-names: + items: + - const: bg_trim + +patternProperties: + "^(aldo|hpldo)$":'^(a|hp)ldo$'
Review
Quoted 3 lines
(quoted diff) +2
-0+ type: object + $ref: regulator.yaml#unevaluatedProperties: false
Quoted 1 line
Quoted 15 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 45
Quoted 12 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +12
-0+ +required: + - compatible + - nvmem-cells + - nvmem-cell-names + +unevaluatedProperties: false + +examples: + - | + audio-codec@2030000 { + compatible = "simple-mfd", "syscon";Needs a specific compatible. Obviously there's some other functionality here if this is an 'audio-codec'.
I am not yet ready to submit the binding or driver for the audio codec, as I still need to work out the details for jack detection (and some other issues). If I added the specific audio codec compatible now, without the properties required for the sound driver, that would create backward compatibility issues, right?
Quoted 8 lines
My intention is to add the specific compatible along with the ASoC support.
Quoted 2 lines
'simple-mfd' also means the child nodes have zero dependence on the parent node and its resources.
That is correct. The regulators have zero dependencies on the audio codec resources (clocks/resets/etc.). The _only_ relationship is the overlapping address of the MMIO register.
LDO registers are at the end of analogue codec MMIO space, right? We can easily split that to separate device, like it's been done for A20 timer & watchdog.
Best regards,
Jernej
Quoted 115 lines
Quoted 8 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 49
Quoted 5 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4
-0+ reg = <0x2030000 0x1000>; + + regulators { + compatible = "allwinner,sun20i-d1-analog-ldos";Is there a defined set of registers for these regulators? If so, put them into 'reg'.
What do you suggest for 'ranges' in the parent device? I ask because the SRAM/system controller binding requires an empty 'ranges' property.
With empty 'ranges', the child has to compute the relative address for use with the parent's regmap, but maybe that is okay?
Quoted 50 lines
Quoted 49 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +16
-0+ 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>; + }; + }; + }; + +...diff --git a/Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system
-ldos.yamlb/Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yamlnew file mode 100644
index 000000000000..c95030a827d6
---/dev/null
+++
b/Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-systemDocumentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4
-1-ldos.yaml @@ -0,0 +1,57 @@ +# 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#Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +5
-0+ +title: Allwinner D1 System LDOs + +description: + Allwinner D1 contains a pair of general-purpose LDOs which aredesigned to + supply power inside and outside the SoC. They are controlled by a register + within the system control MMIO space.
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10
-0+ +maintainers: + - Samuel Holland <[email protected]> + +properties: + compatible: + enum: + - allwinner,sun20i-d1-system-ldos + +patternProperties:Quoted 5 lines
Quoted 1 line
+ "^(ldoa|ldob)$":
'^ldo[ab]$'
Any reason the naming is not consistent with 'ldo' as the prefix or suffix?
All four names match the pin names from the SoC datasheet.
Quoted 4 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ type: object + $ref: regulator.yaml#unevaluatedProperties: false
I will fix these for v3.
Regards,
SamuelQuoted 32 lines
Quoted 32 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +32
-0+ +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + syscon@3000000 { + compatible = "allwinner,sun20i-d1-system-control"; + reg = <0x3000000 0x1000>; + ranges; + #address-cells = <1>; + #size-cells = <1>; + + regulators { + compatible = "allwinner,sun20i-d1-system-ldos"; + + 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>; + }; + }; + }; + +...
Samuel Holland
maintainerRe: [PATCH v2 3/4] regulator: dt-bindings: Add Allwinner D1 LDOs
Quoted 10 lines · Jernej Škrabec
Quoted 6 lines
Quoted 2 lines
'simple-mfd' also means the child nodes have zero dependence on the parent node and its resources.
That is correct. The regulators have zero dependencies on the audio codec resources (clocks/resets/etc.). The _only_ relationship is the overlapping address of the MMIO register.
LDO registers are at the end of analogue codec MMIO space, right? We can easily split that to separate device, like it's been done for A20 timer & watchdog.
No, there are some audio-related registers after the LDO register ("POWER_REG" in the D1 and V853 manuals). So it is not possible to cleanly split the MMIO region.
Regards,
Samuel
Rob Herring
maintainerRe: [PATCH v2 3/4] regulator: dt-bindings: Add Allwinner D1 LDOs
In reply to Samuel HollandQuoted 92 lines · Samuel Holland
Hi Rob,
Thanks again for your review.
Quoted 71 lines · Rob Herring
Quoted 52 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.
Signed-off-by Samuel Holland <[email protected]>---
Changes in v2:
- Remove syscon property from bindings
- Update binding examples to fix warnings and provide context.../allwinner,sun20i-d1-analog-ldos.yaml | 65 +++++++++++++++++++ .../allwinner,sun20i-d1-system-ldos.yaml | 57 ++++++++++++++++ 2 files changed, 122 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.yamlDocumentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +21
-0@@ -0,0 +1,65 @@ +# 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+ nvmem-cells: + items: + - description: NVMEM cell for the calibrated bandgap reference trim value + + nvmem-cell-names: + items: + - const: bg_trim + +patternProperties: + "^(aldo|hpldo)$":'^(a|hp)ldo$'
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +2
-0+ type: object + $ref: regulator.yaml#unevaluatedProperties: false
Quoted 15 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 45
Quoted 12 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +12
-0+ +required: + - compatible + - nvmem-cells + - nvmem-cell-names + +unevaluatedProperties: false + +examples: + - | + audio-codec@2030000 { + compatible = "simple-mfd", "syscon";Needs a specific compatible. Obviously there's some other functionality here if this is an 'audio-codec'.
Quoted 5 lines
I am not yet ready to submit the binding or driver for the audio codec, as I still need to work out the details for jack detection (and some other issues). If I added the specific audio codec compatible now, without the properties required for the sound driver, that would create backward compatibility issues, right?
Only if something used it.
Quoted 8 lines
My intention is to add the specific compatible along with the ASoC support.
Quoted 2 lines
'simple-mfd' also means the child nodes have zero dependence on the parent node and its resources.
That is correct. The regulators have zero dependencies on the audio codec resources (clocks/resets/etc.). The _only_ relationship is the overlapping address of the MMIO register.
Okay.
Quoted 11 lines
Quoted 8 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml line 49
Quoted 5 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +4
-0+ reg = <0x2030000 0x1000>; + + regulators { + compatible = "allwinner,sun20i-d1-analog-ldos";Is there a defined set of registers for these regulators? If so, put them into 'reg'.
What do you suggest for 'ranges' in the parent device? I ask because the SRAM/system controller binding requires an empty 'ranges' property.
I think you are misreading 'ranges: true'. That just means the property can be present, not that it's type is boolean.
Quoted 2 lines
With empty 'ranges', the child has to compute the relative address for use with the parent's regmap, but maybe that is okay?
We should probably have some sort of 'address to regmap offset' helper that works no matter what ranges has.
In most cases, while I require 'reg', unless the child nodes use a mixed up set of registers, Linux doesn't currently use 'reg'. You can also just hardcode the offsets in your driver.
Quoted 48 lines
Quoted 48 lines
Quoted 35 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-analog-ldos.yaml new file +16
-0+ 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 +13
-0@@ -0,0 +1,57 @@ +# 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. +Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/regulator/allwinner,sun20i-d1-system-ldos.yaml new file +10
-0+maintainers: + - Samuel Holland <[email protected]> + +properties: + compatible: + enum: + - allwinner,sun20i-d1-system-ldos + +patternProperties: + "^(ldoa|ldob)$":'^ldo[ab]$'
Quoted 4 lines
Quoted 2 lines
Any reason the naming is not consistent with 'ldo' as the prefix or suffix?
All four names match the pin names from the SoC datasheet.
Good enough for me.
Rob
Samuel Holland
maintainerPATCH v2 4/4 regulator: sun20i: Add support for Allwinner D1 LDOs
In reply to Samuel HollandD1 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 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
@@ -1234,6 +1234,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
@@ -145,6 +145,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