Skip to contentSkip to conversation

Add Unisoc's SC2730 regulator support

PATCH In review Chunyan Zhang 3 participants 9 messages Oct 8, 2021 – Sep 28, 2022

Subsystems (3)
lore
Share & tools
lore

Chunyan Zhang

author reviewer
#0 lore raw

v2 cover Add Unisoc's SC2730 regulator support

From: Chunyan Zhang <[email protected]>

Changes since v1:
* Addressed Mark's comments:
- Removed debugfs things from SC2730 driver and deleted sc2730_regulator_remove() which deal with debugfs only;
- Changed to use C++ style comments on the head of driver.
* Added Rob's Reviewed-by for bindings changes.

Chunyan Zhang (1):
dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Zhongfa Wang (1):
regulator: Add Unisoc's SC2730 regulator driver

 .../regulator/sprd,sc2730-regulator.yaml      |  61 +++
 drivers/regulator/Kconfig                     |  10 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/sc2730-regulator.c          | 404 ++++++++++++++++++
 4 files changed, 476 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml
 create mode 100644 drivers/regulator/sc2730-regulator.c
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH v2 1/2 regulator: Add Unisoc's SC2730 regulator driver

From: Zhongfa Wang <[email protected]>

Add SC2730 regulator driver which is used on Unisoc's UMS512 SoC.

---
 drivers/regulator/Kconfig            |  10 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/sc2730-regulator.c | 404 +++++++++++++++++++++++++++
 3 files changed, 415 insertions(+)
 create mode 100644 drivers/regulator/sc2730-regulator.c
drivers/regulator/Kconfig +10 -0
index 4fd13b06231f..e1ecfc703a07 100644
@@ -1110,6 +1110,16 @@ config REGULATOR_S5M8767
 	 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
 	 supports DVS mode with 8bits of output voltage control.
 
+config REGULATOR_SC2730
+	tristate "Spreadtrum SC2730 power regulator driver"
+	depends on MFD_SC27XX_PMIC || COMPILE_TEST
+	help
+	  This driver provides support for the voltage regulators on the
+	  SC2730 PMIC.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called sc2730-regulator.
+
 config REGULATOR_SC2731
 	tristate "Spreadtrum SC2731 power regulator driver"
 	depends on MFD_SC27XX_PMIC || COMPILE_TEST
drivers/regulator/Makefile +1 -0
index 9e382b50a5ef..22ffdbde88d7 100644
@@ -133,6 +133,7 @@ obj-$(CONFIG_REGULATOR_RTQ6752)	+= rtq6752-regulator.o
 obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
+obj-$(CONFIG_REGULATOR_SC2730) += sc2730-regulator.o
 obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o
 obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
 obj-$(CONFIG_REGULATOR_SLG51000) += slg51000-regulator.o
drivers/regulator/sc2730-regulator.c new file +404 -0

404 lines not on this page · raw message

Signature · 1 line
2.25.1
author reviewer
#2 lore raw

PATCH v2 2/2 dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

SC2730 is used on Unisoc's UMS512 SoC, it integrates low-voltage and low quiescent current DCDC/LDO.

---
 .../regulator/sprd,sc2730-regulator.yaml      | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml
Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml new file +61 -0
new file mode 100644
index 000000000000..6d1bec03eb52
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2019-2021 Unisoc Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/regulator/sprd,sc2730-regulator.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Unisoc SC2730 Voltage Regulators Device Tree Bindings
+
+maintainers:
+  - Orson Zhai <[email protected]>
+  - Baolin Wang <[email protected]>
+  - Chunyan Zhang <[email protected]>
+
+properties:
+  compatible:
+    const: sprd,sc2730-regulator
+
+  reg:
+    maxItems: 1
+
+patternProperties:
+  "^(DCDC|BUCK|LDO)_.+":
+    # Child node
+    type: object
+    description: dcdc/buck/ldo regulator nodes(s).
+    $ref: "regulator.yaml#"
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    pmic {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      regulators@1800 {
+        compatible = "sprd,sc2730-regulator";
+        reg = <0x1800>;
+
+        DCDC_CPU {
+          regulator-name = "vddcpu";
+          regulator-min-microvolt = <200000>;
+          regulator-max-microvolt = <1596875>;
+          regulator-ramp-delay = <25000>;
+          regulator-always-on;
+        };
+
+        LDO_VDDWCN {
+          regulator-name = "vddwcn";
+          regulator-min-microvolt = <900000>;
+          regulator-max-microvolt = <1845000>;
+          regulator-ramp-delay = <25000>;
+        };
+      };
+    };
+...
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH v2 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml line 17

Quoted 3 lines · Chunyan Zhang
Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml new file +3 -0
+properties:
+  compatible:
+    const: sprd,sc2730-regulator

I still don't understand why this MFD subfunction for a specific device is a separate binding with a separate compatible string, the issues I mentioned previously with this just encoding current Linux internals into the DT rather than describing the device still apply.

author reviewer
#4 lore raw

Re: [PATCH v2 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Hi Mark,

Sorry for the late response.
[1] is the v1 on which we had some discussion. I hope that can help recall the issue below.

Quoted 11 lines · Mark Brown

Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml line 17

Quoted 3 lines · Chunyan Zhang
Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml new file +3 -0
+properties:
+  compatible:
+    const: sprd,sc2730-regulator

I still don't understand why this MFD subfunction for a specific device is a separate binding with a separate compatible string, the issues I mentioned previously with this just encoding current Linux internals into the DT rather than describing the device still apply.

I understand your point. But like I described previously [1], if we still use the current solution (i.e. use devm_of_platform_populate() to register MFD subdevices), a compatible string is required. I'm open to switching to other solutions, do you have some suggestions?

Thanks,
Chunyan

[1] https://lkml.org/lkml/2021/9/29/1166

#5 lore raw

Re: [PATCH v2 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Quoted 19 lines · Chunyan Zhang

Hi Mark,

Sorry for the late response.
[1] is the v1 on which we had some discussion. I hope that can help recall the issue below.

Quoted 11 lines · Mark Brown

Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml line 17

Quoted 3 lines · Chunyan Zhang
Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml new file +3 -0
+properties:
+  compatible:
+    const: sprd,sc2730-regulator

I still don't understand why this MFD subfunction for a specific device is a separate binding with a separate compatible string, the issues I mentioned previously with this just encoding current Linux internals into the DT rather than describing the device still apply.

Quoted 4 lines

I understand your point. But like I described previously [1], if we still use the current solution (i.e. use devm_of_platform_populate() to register MFD subdevices), a compatible string is required. I'm open to switching to other solutions, do you have some suggestions?

Many IPs encompassing multiple functions are described that way in DT. I don't have the details for *this* device to hand, so my comments here aren't specific to this use-case, but describing each function individually does describe the H/W accurately, which is all DT calls for.

Can you imagine describing an SoC, which can be considered as a huge MFD, with only a single node?

Does the regulator functionality have it's own bank of registers?

Signature · 1 line
DEPRECATED: Please use [email protected]
maintainer
#6 lore raw

Re: [PATCH v2 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Quoted 7 lines · Lee Jones
Quoted 4 lines · Chunyan Zhang

I understand your point. But like I described previously [1], if we still use the current solution (i.e. use devm_of_platform_populate() to register MFD subdevices), a compatible string is required. I'm open to switching to other solutions, do you have some suggestions?

Quoted 5 lines

Many IPs encompassing multiple functions are described that way in DT. I don't have the details for *this* device to hand, so my comments here aren't specific to this use-case, but describing each function individually does describe the H/W accurately, which is all DT calls for.

If people want to describe the individual regulators that'd be less of an issue, it's mainly when you're nesting what's effectively another MFD within a parent MFD that it's just noise that's being added to the DT.

Quoted 2 lines

Can you imagine describing an SoC, which can be considered as a huge MFD, with only a single node?

Honestly we should be arranging things so they're more like that, at least using overlays for the internals of the SoC so you don't have to rebuild the whole DT for updates to the SoC internals.

#7 lore raw

Re: [PATCH v2 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Quoted 14 lines · Mark Brown
Quoted 7 lines · Lee Jones
Quoted 4 lines · Chunyan Zhang

I understand your point. But like I described previously [1], if we still use the current solution (i.e. use devm_of_platform_populate() to register MFD subdevices), a compatible string is required. I'm open to switching to other solutions, do you have some suggestions?

Quoted 5 lines

Many IPs encompassing multiple functions are described that way in DT. I don't have the details for *this* device to hand, so my comments here aren't specific to this use-case, but describing each function individually does describe the H/W accurately, which is all DT calls for.

Quoted 4 lines

If people want to describe the individual regulators that'd be less of an issue, it's mainly when you're nesting what's effectively another MFD within a parent MFD that it's just noise that's being added to the DT.

As I say, I haven't studied this use-case.

These comments were designed to be more generic.

What do you mean by nested MFDs?

Quoted 6 lines
Quoted 2 lines

Can you imagine describing an SoC, which can be considered as a huge MFD, with only a single node?

Honestly we should be arranging things so they're more like that, at least using overlays for the internals of the SoC so you don't have to rebuild the whole DT for updates to the SoC internals.

Right, there would be one device root node. However each function; clock providers, regulator controllers, PWMs, GPIOs, networking (various), reset, watchdog, etc would have their own nodes. Rather than attempting to describe everything in the parent's node.

Signature · 1 line
DEPRECATED: Please use [email protected]
maintainer
#8 lore raw

Re: [PATCH v2 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator

Quoted 7 lines · Lee Jones
Quoted 4 lines · Mark Brown

If people want to describe the individual regulators that'd be less of an issue, it's mainly when you're nesting what's effectively another MFD within a parent MFD that it's just noise that's being added to the DT.

Quoted 5 lines

As I say, I haven't studied this use-case.

These comments were designed to be more generic.

What do you mean by nested MFDs?

Given that individual regulators tend to be separate physical IPs in the chip if you create a single device tree node that lumps them together you still need to also represent the individual regulators as well so that collection is functioning like a MFD does except not on a chip boundary.

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

Can you imagine describing an SoC, which can be considered as a huge MFD, with only a single node?

Honestly we should be arranging things so they're more like that, at least using overlays for the internals of the SoC so you don't have to rebuild the whole DT for updates to the SoC internals.

Right, there would be one device root node. However each function; clock providers, regulator controllers, PWMs, GPIOs, networking (various), reset, watchdog, etc would have their own nodes. Rather than attempting to describe everything in the parent's node.

We don't split things up by function, we split them up by IP - we don't just allocate a compatible for all the networking related functionality simply because there's a networking subsystem in Linux for example.