regulator: support the HiSilicon STB PMOC voltage rails
Subsystems (2)
cover regulator: support the HiSilicon STB PMOC voltage rails
HiSilicon STB SoCs regulate their CPU and core supplies with PWM outputs of the PMOC block feeding an external converter on the board. This adds the binding for those registers and a driver for them.
David Yang (2):
dt-bindings: regulator: add HiSilicon STB voltage regulator
regulator: histb: add voltage regulator driver
.../regulator/hisilicon,histb-volt.yaml | 58 +++++++ MAINTAINERS | 7 + drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/histb-regulator.c | 163 ++++++++++++++++++ 5 files changed, 236 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml create mode 100644 drivers/regulator/histb-regulator.c
Signature · 1 line
2.53.0
PATCH 1/2 dt-bindings: regulator: add HiSilicon STB voltage regulator
The PMOC block of the HiSilicon STB SoCs drives an external converter with a PWM signal. Document the binding.
--- .../regulator/hisilicon,histb-volt.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml new file +58 -0
@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/hisilicon,histb-volt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HiSilicon STB voltage regulator + +maintainers: + - David Yang <[email protected]> + +description: | + HiSilicon STB SoCs provide PWM outputs in the PMOC block which drive an + external converter. The signal is filtered into a DC level between 0 V and + 3.3 V which is summed into the feedback input of the converter, so a rail + follows the average level of the PWM signal and its voltage is set by the duty + cycle. + + Where the duty cycle maps to in volts is a property of the board, not of the + SoC: the endpoints come from the resistors of the filter and from the + reference voltage of the converter. The datasheets therefore tabulate a + different pair of endpoints for each converter of their reference designs + (0.65 V to 1.15 V for the Hi3798cv200, 0.7 V to 1.25 V for the Hi3798mv200), + and a board built to its own schematic has to describe its own. + regulator-min-microvolt and regulator-max-microvolt are those endpoints of + the linear range, and the regulator has no other source of calibration. + +properties: + compatible: + enum: + - hisilicon,hi3798cv200-volt + - hisilicon,hi3798mv100-volt + - hisilicon,hi3798mv200-volt + + reg: + maxItems: 1 + +required: + - compatible + - reg + - regulator-min-microvolt + - regulator-max-microvolt + +allOf: + - $ref: regulator.yaml# + +unevaluatedProperties: false + +examples: + - | + vddcpu: regulator@8a23018 { + compatible = "hisilicon,hi3798mv200-volt"; + reg = <0x8a23018 0x4>; + regulator-name = "vdd-cpu"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + };
Signature · 1 line
2.53.0
Re: [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator
Quoted 15 lines · David Yang
The PMOC block of the HiSilicon STB SoCs drives an external converter with a PWM signal. Document the binding.
Signed-off-by David Yang <[email protected]>--- .../regulator/hisilicon,histb-volt.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yamlDocumentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml new file +0
-0
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml line 4
Quoted 4 lines
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml new file +4
-0@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/hisilicon,histb-volt.yaml#
Filename matching a compatible please.
pw-bot: changes-requested
Quoted 19 lines
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml new file +19
-0+$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HiSilicon STB voltage regulator + +maintainers: + - David Yang <[email protected]> + +description: | + HiSilicon STB SoCs provide PWM outputs in the PMOC block which drive an + external converter. The signal is filtered into a DC level between 0 V and + 3.3 V which is summed into the feedback input of the converter, so a rail + follows the average level of the PWM signal and its voltage is set by the duty + cycle. + + Where the duty cycle maps to in volts is a property of the board, not of the + SoC: the endpoints come from the resistors of the filter and from the + reference voltage of the converter. The datasheets therefore tabulate a + different pair of endpoints for each converter of their reference designs + (0.65 V to 1.15 V for the Hi3798cv200, 0.7 V to 1.25 V for the Hi3798mv200),
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml line 33
Quoted 10 lines
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml new file +10
-0+ and a board built to its own schematic has to describe its own. + regulator-min-microvolt and regulator-max-microvolt are those endpoints of + the linear range, and the regulator has no other source of calibration. + +properties: + compatible: + enum: + - hisilicon,hi3798cv200-volt + - hisilicon,hi3798mv100-volt + - hisilicon,hi3798mv200-volt
Please note in your commit message what makes the programming model of these devices incompatible, otherwise please make use of fallback compatibles.
Thanks,
Conor.
Quoted 28 lines
Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml new file +25
-0+ + reg: + maxItems: 1 + +required: + - compatible + - reg + - regulator-min-microvolt + - regulator-max-microvolt + +allOf: + - $ref: regulator.yaml# + +unevaluatedProperties: false + +examples: + - | + vddcpu: regulator@8a23018 { + compatible = "hisilicon,hi3798mv200-volt"; + reg = <0x8a23018 0x4>; + regulator-name = "vdd-cpu"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + };Signature · 1 line
2.53.0
PATCH 2/2 regulator: histb: add voltage regulator driver
In reply to David YangAdd a driver for the voltage rails on HiSilicon STB SoCs which are controlled by the PMOC block through a PWM signal, as described by the hisilicon,histb-volt binding.
--- MAINTAINERS | 7 ++ drivers/regulator/Kconfig | 7 ++ drivers/regulator/Makefile | 1 + drivers/regulator/histb-regulator.c | 163 ++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 drivers/regulator/histb-regulator.c
MAINTAINERS +7 -0
@@ -11910,6 +11910,13 @@ S: Maintained F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml F: drivers/mfd/hi6421-spmi-pmic.c +HISILICON STB VOLTAGE REGULATOR DRIVER +M: David Yang <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml +F: drivers/regulator/histb-regulator.c + HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT M: Weili Qian <[email protected]> S: Maintained
drivers/regulator/Kconfig +7 -0
@@ -487,6 +487,13 @@ config REGULATOR_HI6421V600 HiSilicon Hi6421v600 PMU / Codec IC. This is used on Kirin 3670 boards, like HiKey 970. +config REGULATOR_HISTB + tristate "HiSilicon STB voltage regulator support" + depends on ARCH_HISI || COMPILE_TEST + help + This driver provides support for the voltage regulators of the + HiSilicon STB SoCs, including Hi3798cv200, Hi3798mv100, Hi3798mv200. + config REGULATOR_ISL9305 tristate "Intersil ISL9305 regulator" depends on I2C
drivers/regulator/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o obj-$(CONFIG_REGULATOR_HI6421V530) += hi6421v530-regulator.o obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o +obj-$(CONFIG_REGULATOR_HISTB) += histb-regulator.o obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o obj-$(CONFIG_REGULATOR_FP9931) += fp9931.o
drivers/regulator/histb-regulator.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 2/2] regulator: histb: add voltage regulator driver
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] regulator: histb: set_voltage may apply voltage exceeding max_uV constraint --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] regulator: histb: set_voltage may apply voltage exceeding max_uV constraint --
commit 800fca6de780a18cd0c58b4d9fc8681fea0944fb
Author: David Yang <[email protected]>
regulator: histb: add voltage regulator driver
Add a driver for the voltage rails on HiSilicon STB SoCs which are controlled by the PMOC block through a PWM signal, as described by the hisilicon,histb-volt binding.
Quoted 5 lines
drivers/regulator/histb-regulator.c new file +0
-0
[ ... ]
Quoted 12 lines
drivers/regulator/histb-regulator.c new file +12
-0+static int histb_regulator_set_voltage (struct regulator_dev *rdev,int min_uV, +int max_uV,unsigned int *selector) +{ +struct histb_regulator *priv =rdev_get_drvdata (rdev); +unsigned int duty; +u32 val; + +if (min_uV >= priv->max_uV) + duty =0 ; +else if (min_uV <= priv->min_uV) + duty =HISTB_PWM_PERIOD ; +else
drivers/regulator/histb-regulator.c line 88
Quoted 10 lines
drivers/regulator/histb-regulator.c new file +10
-0+/* rounding down keeps the output at or above the request */ + duty =DIV_ROUND_DOWN_ULL ((u64)(priv->max_uV - min_uV) * +HISTB_PWM_PERIOD , + priv->max_uV - priv->min_uV); + + val =FIELD_PREP (HISTB_DUTY , duty +1 ) | +FIELD_PREP (HISTB_PERIOD ,HISTB_PWM_PERIOD +1 ); +writel_relaxed (val, priv->base); + +return 0 ;
[Severity: High]
Could this rounding logic result in applying an output voltage that exceeds the max_uV limit?
Because a smaller duty cycle yields a higher physical voltage, rounding down the duty cycle ensures the output voltage is at or above min_uV. However, if the exact requested voltage range does not perfectly align with one of the 240 PWM steps, the resulting physical voltage might exceed the strict max_uV constraint requested by the consumer.
Should the driver verify if the achieved physical voltage violates max_uV and return -EINVAL here instead of applying the setting and unconditionally returning success?
Quoted 1 line
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 2/2] regulator: histb: add voltage regulator driver
Quoted 55 lines · On Fri, Oct 9, 2026 at 12:06 AM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] regulator: histb:set_voltagemay apply voltage exceedingmax_uVconstraint --commit
800fca6de780a18cd0c58b4d9fc8681fea0944fb
Author: David Yang <[email protected]>regulator: histb: add voltage regulator driver
Add a driver for the voltage rails on HiSilicon STB SoCs which are controlled by the PMOC block through a PWM signal, as described by the hisilicon,histb-volt binding.
Quoted 5 lines
drivers/regulator/histb-regulator.c new file +0
-0[ ... ]
Quoted 12 lines
drivers/regulator/histb-regulator.c new file +12
-0+static int histb_regulator_set_voltage (struct regulator_dev *rdev,int min_uV, +int max_uV,unsigned int *selector) +{ +struct histb_regulator *priv =rdev_get_drvdata (rdev); +unsigned int duty; +u32 val; + +if (min_uV >= priv->max_uV) + duty =0 ; +else if (min_uV <= priv->min_uV) + duty =HISTB_PWM_PERIOD ; +else drivers/regulator/histb-regulator.c line 88
Quoted 10 lines
drivers/regulator/histb-regulator.c new file +10
-0+/* rounding down keeps the output at or above the request */ + duty =DIV_ROUND_DOWN_ULL ((u64)(priv->max_uV - min_uV) * +HISTB_PWM_PERIOD , + priv->max_uV - priv->min_uV); + + val =FIELD_PREP (HISTB_DUTY , duty +1 ) | +FIELD_PREP (HISTB_PERIOD ,HISTB_PWM_PERIOD +1 ); +writel_relaxed (val, priv->base); + +return 0 ;[Severity: High]
Could this rounding logic result in applying an output voltage that exceeds themax_uVlimit?Because a smaller duty cycle yields a higher physical voltage, rounding down the duty cycle ensures the output voltage is at or above
min_uV. However, if the exact requested voltage range does not perfectly align with one of the 240 PWM steps, the resulting physical voltage might exceed the strictmax_uVconstraint requested by the consumer.
Quoted 3 lines
Should the driver verify if the achieved physical voltage violates
max_uVand return-EINVALhere instead of applying the setting and unconditionally returning success?
The counter spans 240 steps, so a request off the grid is at most one step (2.3 mV over a 550 mV range) high. Rejecting a 240-step miss would just break DVFS: single-cell opp-microvolt is a zero-width window.
Quoted 4 lines
Quoted 1 line
+}
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2