Re: [PATCH] regulator: Add support for RT4801 Display Bias regulator driver

2020-08-14 Thread Rob Herring
On Fri, 14 Aug 2020 13:59:33 +0800, cy_huang wrote:
> From: ChiYuan Huang 
> 
> Adds support for the RT4801 DSV. It has two regulators (DSVP/DSVN) with an I2C
> interface. DSVP/DSVN can provide the display panel module for the 
> positive/negative
> voltage range from (+/-)4V to (+/-)6V.
> ---
>  .../regulator/richtek,rt4801-regulator.yaml|  80 
>  drivers/regulator/Kconfig  |   7 +
>  drivers/regulator/Makefile |   1 +
>  drivers/regulator/rt4801-regulator.c   | 223 
> +
>  4 files changed, 311 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml
>  create mode 100644 drivers/regulator/rt4801-regulator.c
> 


My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml:
 additionalProperties: ['enable-gpios'] is not of type 'object', 'boolean'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml:
 additionalProperties: ['enable-gpios'] is not valid under any of the given 
schemas (Possible causes of the failure):

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml:
 additionalProperties: ['enable-gpios'] is not of type 'object'

make[1]: *** [Documentation/devicetree/bindings/Makefile:19: 
Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.example.dts]
 Error 1
make[1]: *** Waiting for unfinished jobs
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml:
 ignoring, error in schema: additionalProperties
warning: no schema found in file: 
./Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml
make: *** [Makefile:1334: dt_binding_check] Error 2


See https://patchwork.ozlabs.org/patch/1344633

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master 
--upgrade

Please check and re-submit.



Re: [PATCH] regulator: Add support for RT4801 Display Bias regulator driver

2020-08-14 Thread Mark Brown
On Fri, Aug 14, 2020 at 01:59:33PM +0800, cy_huang wrote:
> From: ChiYuan Huang 
> 
> Adds support for the RT4801 DSV. It has two regulators (DSVP/DSVN) with an I2C
> interface. DSVP/DSVN can provide the display panel module for the 
> positive/negative
> voltage range from (+/-)4V to (+/-)6V.
> ---

You need to provide a Signed-off-by - see submitting-patches.rst for
details on what that is and why it is important.  I can't do anything
with this without one.

>  .../regulator/richtek,rt4801-regulator.yaml|  80 
>  drivers/regulator/Kconfig  |   7 +

The DT bindings should be in a separate patch.


signature.asc
Description: PGP signature


[PATCH] regulator: Add support for RT4801 Display Bias regulator driver

2020-08-13 Thread cy_huang
From: ChiYuan Huang 

Adds support for the RT4801 DSV. It has two regulators (DSVP/DSVN) with an I2C
interface. DSVP/DSVN can provide the display panel module for the 
positive/negative
voltage range from (+/-)4V to (+/-)6V.
---
 .../regulator/richtek,rt4801-regulator.yaml|  80 
 drivers/regulator/Kconfig  |   7 +
 drivers/regulator/Makefile |   1 +
 drivers/regulator/rt4801-regulator.c   | 223 +
 4 files changed, 311 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml
 create mode 100644 drivers/regulator/rt4801-regulator.c

diff --git 
a/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml 
b/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml
new file mode 100644
index ..28d30e2
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt4801-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT4801 Display Bias regulators
+
+maintainers:
+  - ChiYuan Huang 
+
+description: |
+  Regulator nodes should be named to DSVP and DSVN. The
+  definition for each of these nodes is defined using the standard
+  binding for regulators at
+  Documentation/devicetree/bindings/regulator/regulator.txt.
+  Datasheet is available at
+  https://www.richtek.com/assets/product_file/RT4801H/DS4801H-00.pdf
+
+#The valid names for RT4801 regulator nodes are:
+#DSVP, DSVN
+
+properties:
+  compatible:
+enum:
+  - richtek,rt4801
+
+  reg:
+maxItems: 1
+
+  enable-gpios:
+description: GPIOs to use to enable DSVP/DSVN regulator.
+  The first one is ENP to enable DSVP, and second one is ENM to enable 
DSVN.
+  Number of GPIO in the array list could be 1 or 2.
+  If only one gpio is specified, only one gpio used to control ENP/ENM.
+  Else both are spefied, DSVP/DSVN could be controlled individually.
+  Othersie, this property not specified. treat both as always-on regulator.
+minItems: 1
+maxItems: 2
+
+patternProperties:
+  "^DSV(P|N)$":
+type: object
+$ref: regulator.yaml#
+description:
+  Properties for single display bias regulator.
+
+required:
+  - compatible
+  - reg
+
+additionalProperties:
+  - enable-gpios
+
+examples:
+  - |
+i2c {
+#address-cells = <1>;
+#size-cells = <0>;
+
+rt4801@73 {
+compatible = "richtek,rt4801";
+reg = <0x73>;
+enable-gpios = < 2 0>, < 3 0>;
+
+dsvp: DSVP {
+regulator-name = "rt4801,dsvp";
+regulator-min-microvolt = <400>;
+regulator-max-microvolt = <600>;
+regulator-boot-on;
+};
+dsvn: DSVN {
+regulator-name = "rt4801,dsvn";
+regulator-min-microvolt = <400>;
+regulator-max-microvolt = <600>;
+regulator-boot-on;
+};
+
+};
+};
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index de17ef7..2786f11 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -894,6 +894,13 @@ config REGULATOR_RN5T618
 config REGULATOR_ROHM
tristate
 
+config REGULATOR_RT4801
+   tristate "Richtek RT4801 Regulators"
+   depends on I2C
+   help
+ This adds support for voltage regulators in Richtek RT4801 Display 
Bias IC.
+ The device supports two regulators (DSVP/DSVN).
+
 config REGULATOR_RT5033
tristate "Richtek RT5033 Regulators"
depends on MFD_RT5033
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index d8d3ecf..d091e52d 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -111,6 +111,7 @@ obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
 obj-$(CONFIG_REGULATOR_RK808)   += rk808-regulator.o
 obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
 obj-$(CONFIG_REGULATOR_ROHM)   += rohm-regulator.o
+obj-$(CONFIG_REGULATOR_RT4801) += rt4801-regulator.o
 obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
 obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
diff --git a/drivers/regulator/rt4801-regulator.c 
b/drivers/regulator/rt4801-regulator.c
new file mode 100644
index ..0ddc670
--- /dev/null
+++ b/drivers/regulator/rt4801-regulator.c
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RT4801_REG_VOP 0x00
+#define RT4801_REG_VON 0x01
+#define RT4801_REG_APPS0x03
+
+#define VOUT_MASK  0x1F
+
+#define MIN_UV 400
+#define STEP_UV10
+#define MAX_UV 600