Re: [PATCH v2 2/3] dt-bindings: regulator: document binding for MT6315 regulator

From: Rob Herring
Date: Tue Oct 20 2020 - 11:37:17 EST


On Tue, Oct 20, 2020 at 05:56:49PM +0800, Hsin-Hsiung Wang wrote:
> Add device tree binding information for MT6315 regulator driver.
> Example bindings for MT6315 are added.
>
> Signed-off-by: Hsin-Hsiung Wang <hsin-hsiung.wang@xxxxxxxxxxxx>
> ---
> .../regulator/mtk,mt6315-regulator.yaml | 88 +++++++++++++++++++
> include/dt-bindings/regulator/mtk,mt6315.h | 17 ++++
> 2 files changed, 105 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/regulator/mtk,mt6315-regulator.yaml
> create mode 100644 include/dt-bindings/regulator/mtk,mt6315.h
>
> diff --git a/Documentation/devicetree/bindings/regulator/mtk,mt6315-regulator.yaml b/Documentation/devicetree/bindings/regulator/mtk,mt6315-regulator.yaml
> new file mode 100644
> index 000000000000..457606800d5b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/mtk,mt6315-regulator.yaml
> @@ -0,0 +1,88 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/mtk,mt6315-regulator.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Mediatek MT6315 Regulator
> +
> +maintainers:
> + - Hsin-Hsiung Wang <hsin-hsiung.wang@xxxxxxxxxxxx>
> +
> +description: |
> + The MT6315 is a power management IC (PMIC) configurable with SPMI.
> + that contains 4 BUCKs output which can combine with each other
> + by different efuse settings.
> +
> +allOf:
> + - $ref: "regulator.yaml#"

This doesn't go here, but...

> +
> +properties:
> + $nodename:
> + pattern: "mt6315@[0-9]"
> + compatible:
> + enum:
> + - mediatek,mt6315_3-regulator
> + - mediatek,mt6315_6-regulator
> + - mediatek,mt6315_7-regulator

What's 3, 6, 7 mean?

> +
> + reg:
> + maxItems: 1
> +
> + regulators:
> + type: object
> + description: List of regulators and its properties
> +
> + patternProperties:
> + "^vbuck[1-4]$":
> + type: object

regulator.yaml ref goes here.

> +
> + properties:
> + regulator-name:
> + pattern: "^vbuck[1-4]$"
> + description:
> + should be "vbuck1", ..., "vbuck4"
> +
> + mtk,combined-regulator:
> + $ref: "/schemas/types.yaml#/definitions/uint32-array"

Wouldn't a phandle make more sense. And we have coupled regulator
binding that this may work for.

> + description: |
> + defines other bucks combined with this buck, must contain the following
> + values MT6315_VBUCK1, MT6315_VBUCK2, MT6315_VBUCK3, MT6315_VBUCK4
> +
> + unevaluatedProperties: false

'additionalProperties: false' would be better here.

> +
> +required:
> + - compatible
> + - reg
> + - regulators
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + /* This example shows that buck2 and buck4 are combined into buck1. */
> + #include <dt-bindings/regulator/mtk,mt6315.h>
> +
> + mt6315@6 {

pmic@6

> + compatible = "mediatek,mt6315_6-regulator";
> + reg = <0x6 0 0xb 1>;
> +
> + regulators {
> + vbuck1 {
> + regulator-compatible = "vbuck1";
> + regulator-min-microvolt = <300000>;
> + regulator-max-microvolt = <1193750>;
> + regulator-enable-ramp-delay = <256>;
> + regulator-allowed-modes = <0 1 2 4>;
> + mtk,combined-regulator = <MT6315_VBUCK2 MT6315_VBUCK4>;
> + };
> +
> + vbuck3 {
> + regulator-compatible = "vbuck3";
> + regulator-min-microvolt = <300000>;
> + regulator-max-microvolt = <1193750>;
> + regulator-enable-ramp-delay = <256>;
> + regulator-allowed-modes = <0 1 2 4>;
> + };
> + };
> + };
> diff --git a/include/dt-bindings/regulator/mtk,mt6315.h b/include/dt-bindings/regulator/mtk,mt6315.h
> new file mode 100644
> index 000000000000..6ed9b2b121db
> --- /dev/null
> +++ b/include/dt-bindings/regulator/mtk,mt6315.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2020 MediaTek Inc.
> + * Author: Hsin-Hsiung Wang <hsin-hsiung.wang@xxxxxxxxxxxx>
> + */
> +
> +#ifndef _DT_BINDINGS_REGULATOR_MTK_MT6315_H
> +#define _DT_BINDINGS_REGULATOR_MTK_MT6315_H
> +
> +/* Regulator ID */
> +#define MT6315_VBUCK1 1
> +#define MT6315_VBUCK2 2
> +#define MT6315_VBUCK3 3
> +#define MT6315_VBUCK4 4

I don't find these defines to be that helpful.

> +#define MT6315_VBUCK_MAX 5
> +
> +#endif /* _DT_BINDINGS_REGULATOR_MTK_MT6315_H */
> --
> 2.18.0