* [PATCH 0/2] regulator: support the HiSilicon STB PMOC voltage rails
@ 2026-10-08 15:57 David Yang
2026-10-08 15:57 ` [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator David Yang
2026-10-08 15:57 ` [PATCH 2/2] regulator: histb: add voltage regulator driver David Yang
0 siblings, 2 replies; 4+ messages in thread
From: David Yang @ 2026-10-08 15:57 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: David Yang, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
linux-kernel, devicetree
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
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator
2026-10-08 15:57 [PATCH 0/2] regulator: support the HiSilicon STB PMOC voltage rails David Yang
@ 2026-10-08 15:57 ` David Yang
2026-10-09 18:50 ` Conor Dooley
2026-10-08 15:57 ` [PATCH 2/2] regulator: histb: add voltage regulator driver David Yang
1 sibling, 1 reply; 4+ messages in thread
From: David Yang @ 2026-10-08 15:57 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: David Yang, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
linux-kernel, devicetree
The PMOC block of the HiSilicon STB SoCs drives an external converter
with a PWM signal. Document the binding.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
.../regulator/hisilicon,histb-volt.yaml | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
diff --git a/Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml b/Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
new file mode 100644
index 000000000000..34deee17d034
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
@@ -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 <mmyangfl@gmail.com>
+
+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;
+ };
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] regulator: histb: add voltage regulator driver
2026-10-08 15:57 [PATCH 0/2] regulator: support the HiSilicon STB PMOC voltage rails David Yang
2026-10-08 15:57 ` [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator David Yang
@ 2026-10-08 15:57 ` David Yang
1 sibling, 0 replies; 4+ messages in thread
From: David Yang @ 2026-10-08 15:57 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: David Yang, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
linux-kernel, devicetree
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.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
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
diff --git a/MAINTAINERS b/MAINTAINERS
index 65e8a4b5c90b..a77731922891 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <mmyangfl@gmail.com>
+L: linux-kernel@vger.kernel.org
+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 <qianweili@huawei.com>
S: Maintained
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 89789ac7a786..210130783f72 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -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
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 5a764cec8df8..9fa44d180458 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -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
diff --git a/drivers/regulator/histb-regulator.c b/drivers/regulator/histb-regulator.c
new file mode 100644
index 000000000000..77073a646e49
--- /dev/null
+++ b/drivers/regulator/histb-regulator.c
@@ -0,0 +1,163 @@
+// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
+/*
+ * Regulator driver for the PWM controlled voltage regulators of HiSilicon STB
+ * SoCs
+ *
+ * May work on Hi3716mv410/420 Hi3796mv100/200 Hi3798cv200/mv100/mv200 but not
+ * throughly tested
+ *
+ * Copyright (c) 2026 David Yang
+ */
+
+#include <linux/bitfield.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/math64.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
+
+/*
+ * Duty cycle + 1 and period + 1 are counted in periods of the oscillator
+ * clock (usually 24 MHz), and a larger duty cycle means a lower output
+ * voltage.
+ */
+#define HISTB_DUTY GENMASK(31, 16)
+#define HISTB_PERIOD GENMASK(15, 0)
+
+/* 24 MHz / 240 = 100 kHz, arbitrarily chosen but should be enough */
+#define HISTB_PWM_PERIOD 240
+
+struct histb_regulator {
+ struct regulator_desc desc;
+ void __iomem *base;
+ int min_uV;
+ int max_uV;
+};
+
+static int histb_regulator_get_voltage(struct regulator_dev *rdev)
+{
+ struct histb_regulator *priv = rdev_get_drvdata(rdev);
+ u32 val;
+ u32 period;
+ u32 duty;
+ u64 uV;
+
+ val = readl_relaxed(priv->base);
+ period = FIELD_GET(HISTB_PERIOD, val);
+ duty = FIELD_GET(HISTB_DUTY, val);
+
+ /* an empty counter range leaves the output high */
+ if (duty <= 1 || period <= 1)
+ return priv->max_uV;
+
+ duty--;
+ period--;
+ if (duty >= period)
+ return priv->min_uV;
+
+ uV = (u64)(priv->max_uV - priv->min_uV) * duty;
+
+ return priv->max_uV - DIV_ROUND_CLOSEST_ULL(uV, period);
+}
+
+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
+ /* 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;
+}
+
+static const struct regulator_ops histb_regulator_ops = {
+ .get_voltage = histb_regulator_get_voltage,
+ .set_voltage = histb_regulator_set_voltage,
+};
+
+static int histb_regulator_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct histb_regulator *priv;
+ struct regulator_init_data *init_data;
+ struct regulator_config config = {};
+ struct regulator_dev *rdev;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ init_data = of_get_regulator_init_data(dev, dev->of_node, &priv->desc);
+ if (!init_data)
+ return -ENOMEM;
+
+ priv->min_uV = init_data->constraints.min_uV;
+ priv->max_uV = init_data->constraints.max_uV;
+ if (priv->min_uV <= 0 || priv->max_uV <= priv->min_uV) {
+ dev_err(dev, "invalid voltage range (%d..%d uV)\n",
+ priv->min_uV, priv->max_uV);
+ return -EINVAL;
+ }
+
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(priv->base))
+ return PTR_ERR(priv->base);
+
+ priv->desc.name = dev_name(dev);
+ priv->desc.type = REGULATOR_VOLTAGE;
+ priv->desc.ops = &histb_regulator_ops;
+ priv->desc.owner = THIS_MODULE;
+ priv->desc.continuous_voltage_range = true;
+
+ config.dev = dev;
+ config.init_data = init_data;
+ config.driver_data = priv;
+ config.of_node = dev->of_node;
+
+ rdev = devm_regulator_register(dev, &priv->desc, &config);
+ if (IS_ERR(rdev))
+ return dev_err_probe(dev, PTR_ERR(rdev),
+ "failed to register %s\n",
+ priv->desc.name);
+
+ return 0;
+}
+
+static const struct of_device_id histb_regulator_of_match[] = {
+ { .compatible = "hisilicon,hi3798cv200-volt" },
+ { .compatible = "hisilicon,hi3798mv100-volt" },
+ { .compatible = "hisilicon,hi3798mv200-volt" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, histb_regulator_of_match);
+
+static struct platform_driver histb_regulator_driver = {
+ .probe = histb_regulator_probe,
+ .driver = {
+ .name = "histb-regulator",
+ .of_match_table = histb_regulator_of_match,
+ },
+};
+module_platform_driver(histb_regulator_driver);
+
+MODULE_DESCRIPTION("HiSilicon STB PWM voltage regulator driver");
+MODULE_AUTHOR("David Yang <mmyangfl@gmail.com>");
+MODULE_LICENSE("Dual MIT/GPL");
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator
2026-10-08 15:57 ` [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator David Yang
@ 2026-10-09 18:50 ` Conor Dooley
0 siblings, 0 replies; 4+ messages in thread
From: Conor Dooley @ 2026-10-09 18:50 UTC (permalink / raw)
To: David Yang
Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-kernel, devicetree
[-- Attachment #1: Type: text/plain, Size: 3114 bytes --]
On Thu, Oct 08, 2026 at 11:57:24PM +0800, David Yang wrote:
> The PMOC block of the HiSilicon STB SoCs drives an external converter
> with a PWM signal. Document the binding.
>
> Signed-off-by: David Yang <mmyangfl@gmail.com>
> ---
> .../regulator/hisilicon,histb-volt.yaml | 58 +++++++++++++++++++
> 1 file changed, 58 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
>
> diff --git a/Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml b/Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
> new file mode 100644
> index 000000000000..34deee17d034
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/hisilicon,histb-volt.yaml
> @@ -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
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: HiSilicon STB voltage regulator
> +
> +maintainers:
> + - David Yang <mmyangfl@gmail.com>
> +
> +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
Please note in your commit message what makes the programming model of
these devices incompatible, otherwise please make use of fallback
compatibles.
Thanks,
Conor.
> +
> + 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;
> + };
> --
> 2.53.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-09 18:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 15:57 [PATCH 0/2] regulator: support the HiSilicon STB PMOC voltage rails David Yang
2026-10-08 15:57 ` [PATCH 1/2] dt-bindings: regulator: add HiSilicon STB voltage regulator David Yang
2026-10-09 18:50 ` Conor Dooley
2026-10-08 15:57 ` [PATCH 2/2] regulator: histb: add voltage regulator driver David Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®