regulator: Add Unisoc's SC2730 regulator driver
Subsystems (3)
Chunyan Zhang
reviewerPATCH 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 | 502 +++++++++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 drivers/regulator/sc2730-regulator.c
drivers/regulator/Kconfig +10 -0
@@ -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
@@ -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 +502 -0
502 lines not on this page · raw message
Signature · 1 line
2.25.1
Chunyan Zhang
reviewerPATCH 2/2 dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator
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
@@ -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
Chunyan Zhang
reviewerPATCH 2/2 dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator
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
@@ -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
Re: [PATCH 2/2] dt-bindings: regulator: Add bindings for Unisoc's SC2730 regulator
Quoted 11 lines · 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.
Signed-off-by Chunyan Zhang <[email protected]>--- .../regulator/sprd,sc2730-regulator.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/sprd,sc2730-regulator.yaml
Mark Brown
maintainerdrivers/regulator/sc2730-regulator.c line 4
Quoted 6 lines · Chunyan Zhang
+++
b/drivers/regulator/sc2730-regulator.cdrivers/regulator/sc2730-regulator.c new file +4
-0@@ -0,0 +1,502 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2021 Unisoc Inc. +*/
Please make the entire comment a C++ one so things look more intentional.
Quoted 5 lines
drivers/regulator/sc2730-regulator.c new file +4
-0+static int debugfs_enable_get (void *data,u64 *val) +{ +struct regulator_dev *rdev = data; +
drivers/regulator/sc2730-regulator.c line 402
Quoted 10 lines
drivers/regulator/sc2730-regulator.c new file +8
-0+static int debugfs_enable_set (void *data,u64 val) +{ +struct regulator_dev *rdev = data; + +static int debugfs_voltage_get (void *data,u64 *val) +{ +static int debugfs_voltage_set (void *data,u64 val) +{
If these were to be implemented they should be in the core as there's nothing device specific about them (the read side is there), please remove them from the driver.
drivers/regulator/sc2730-regulator.c line 489
Quoted 5 lines
drivers/regulator/sc2730-regulator.c new file +5
-0+static const struct of_device_id sc2730_regulator_match[] = { + { .compatible ="sprd,sc2730-regulator" }, + {}, +}; +MODULE_DEVICE_TABLE (of, sc2730_regulator_match);
Since this is a part of a MFD I'd not expect it to have a compatible string?
Chunyan Zhang
reviewerQuoted 12 lines · Mark Brown
drivers/regulator/sc2730-regulator.c line 4
Quoted 6 lines · Chunyan Zhang
+++
b/drivers/regulator/sc2730-regulator.cdrivers/regulator/sc2730-regulator.c new file +4
-0@@ -0,0 +1,502 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2021 Unisoc Inc. +*/ Please make the entire comment a C++ one so things look more intentional.
Ok.
Quoted 14 lines
Quoted 13 lines
drivers/regulator/sc2730-regulator.c new file +10
-0+static int debugfs_enable_get (void *data,u64 *val) +{ +struct regulator_dev *rdev = data; + +static int debugfs_enable_set (void *data,u64 val) +{ +struct regulator_dev *rdev = data; + +static int debugfs_voltage_get (void *data,u64 *val) +{
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static int debugfs_voltage_set(void *data, u64 val) +{If these were to be implemented they should be in the core as there's nothing device specific about them (the read side is there), please remove them from the driver.
Ok.
Quoted 9 lines
drivers/regulator/sc2730-regulator.c line 489
Quoted 6 lines
drivers/regulator/sc2730-regulator.c new file +5
-0+static const struct of_device_id sc2730_regulator_match[] = { + { .compatible ="sprd,sc2730-regulator" }, + {}, +}; +MODULE_DEVICE_TABLE (of, sc2730_regulator_match);Since this is a part of a MFD I'd not expect it to have a compatible string?
Since we switched to use devm_of_platform_populate() [1] to register MFD subdevices, compatible is required, IIUC.
[1] https://elixir.bootlin.com/linux/latest/source/drivers/mfd/sprd-sc27xx-spi.c#L199
Thanks for the review,
Chunyan
Mark Brown
maintainerQuoted 7 lines · Chunyan Zhang
Quoted 2 lines · Mark Brown
Since this is a part of a MFD I'd not expect it to have a compatible string?
Since we switched to use
devm_of_platform_populate()[1] to register MFD subdevices, compatible is required, IIUC.
I'm not sure that's a good fit for these regulators, we don't gain any extra information from the compatible here.
Chunyan Zhang
reviewer+Lee Jones
Quoted 4 lines · Mark Brown
Quoted 1 line · Chunyan Zhang
On Tue, 28 Sept 2021 at 19:31, Mark Brown <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Since this is a part of a MFD I'd not expect it to have a compatible string?
Since we switched to use
devm_of_platform_populate()[1] to register MFD subdevices, compatible is required, IIUC.I'm not sure that's a good fit for these regulators, we don't gain any extra information from the compatible here.
Humm... regulators cannot be probed without compatible for this case, except we have a list of mfd_cells which include compatible and driver name in sc27xx_spi (mfd) driver.
On different platforms, sc27xx_spi consists of different sub-devices with different compatible string, to avoid adding mfd_cells to sc27xx_spi driver each time we add a new platform support, we changed to use devm_of_platform_populate() which can automatically register sun-devices listed in devicetree.
The above is my understand, please correct me if I'm missing something @Lee Jones
Thanks,
Chunyan
Mark Brown
maintainerQuoted 8 lines · Chunyan Zhang
On different platforms,
sc27xx_spiconsists of different sub-devices with different compatible string, to avoid addingmfd_cellstosc27xx_spidriver each time we add a new platform support, we changed to usedevm_of_platform_populate()which can automatically register sun-devices listed in devicetree.The above is my understand, please correct me if I'm missing something @Lee Jones
Right, so my pushback here is that it's not clear to me that avoiding adding compatibles to the MFD is a strong enough goal to justify creating ABI - it's hard to see the upsides. This is particularly the case here where the subdevice is really a random collection of devices that's particularly likely to change between variants and more likely that other OSs would want something different so it's even harder to achieve reuse.