Skip to contentSkip to conversation

regulator: rt6160: Add DT binding document for Richtek RT6160

PATCH Superseded cy_huang 2 participants 3 messages Jun 1, 2021

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

cy_huang

author
#0 lore raw

PATCH v5 1/2 regulator: rt6160: Add DT binding document for Richtek RT6160

From: ChiYuan Huang <[email protected]>

Add DT binding document for Richtek RT6160 voltage regulator.

---
since v4
- Add Reviewed-by.

since v3
- Move all regulator related properties to the upper node.

since v2
- Move buckboost node from patternProperties to Properties.

---
 .../regulator/richtek,rt6160-regulator.yaml        | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rt6160-regulator.yaml
Documentation/devicetree/bindings/regulator/richtek,rt6160-regulator.yaml new file +61 -0
new file mode 100644
index 00000000..0534b0d
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/richtek,rt6160-regulator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT6160 BuckBoost converter
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  The RT6160 is a high-efficiency buck-boost converter that can provide
+  up to 3A output current from 2025mV to 5200mV. And it support the wide
+  input voltage range from 2200mV to 5500mV.
+
+  Datasheet is available at
+  https://www.richtek.com/assets/product_file/RT6160A/DS6160A-00.pdf
+
+allOf:
+  - $ref: regulator.yaml#
+
+properties:
+  compatible:
+    enum:
+      - richtek,rt6160
+
+  reg:
+    maxItems: 1
+
+  enable-gpios:
+    description: A connection of the 'enable' gpio line.
+    maxItems: 1
+
+  richtek,vsel-active-low:
+    description: |
+      Used to indicate the 'vsel' pin active level. if not specified, use
+      high active level as the default.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      rt6160@75 {
+        compatible = "richtek,rt6160";
+        reg = <0x75>;
+        enable-gpios = <&gpio26 2 0>;
+        regulator-name = "rt6160-buckboost";
+        regulator-min-microvolt = <2025000>;
+        regulator-max-microvolt = <5200000>;
+      };
+    };
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v5 2/2 regulator: rt6160: Add support for Richtek RT6160

From: ChiYuan Huang <[email protected]>

Add support for Richtek RT6160 voltage regulator. It can provide up to 3A output current within the adjustable voltage from 2025mV to 5200mV. It integrate a buckboost converter to support wide input voltage range from 2200mV to 5500mV.

---
since v5
- Add 'enable" gpio control into regulator enable/disable.
- Refine regulator ramp delay ops.
- Due to 'enable' gpio H to L cause register reset, use regcache.

since v4
- Add of_node into regulator_config to fix regulator_get by device tree node parsing.

since v3
- Use more header file like as of_regulator.h and property.h.
- Change the parsing string from 'richtek,vsel_active_low' to 'richtek,vsel-active-low'.
- Use of_get_regulator_init_data to get the regulator init_data.

since v2
- Fix W=1 warning for of_device_id.

---
 drivers/regulator/Kconfig            |  11 ++
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/rt6160-regulator.c | 327 +++++++++++++++++++++++++++++++++++
 3 files changed, 339 insertions(+)
 create mode 100644 drivers/regulator/rt6160-regulator.c
drivers/regulator/Kconfig +11 -0
index 9d84d92..4fe7ddc 100644
@@ -1030,6 +1030,17 @@ config REGULATOR_RT5033
 	  RT5033 PMIC. The device supports multiple regulators like
 	  current source, LDO and Buck.
 
+config REGULATOR_RT6160
+	tristate "Richtek RT6160 BuckBoost voltage regulator"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  This adds support for voltage regulator in Richtek RT6160.
+	  This device automatically change voltage output mode from
+	  Buck or Boost. The mode transistion depend on the input source voltage.
+	  The wide output range is from 2025mV to 5200mV and can be used on most
+	  common application scenario.
+
 config REGULATOR_RTMV20
 	tristate "RTMV20 Laser Diode Regulator"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 580b015..5b2c93e 100644
@@ -124,6 +124,7 @@ obj-$(CONFIG_REGULATOR_ROHM)	+= rohm-regulator.o
 obj-$(CONFIG_REGULATOR_RT4801)	+= rt4801-regulator.o
 obj-$(CONFIG_REGULATOR_RT4831)	+= rt4831-regulator.o
 obj-$(CONFIG_REGULATOR_RT5033)	+= rt5033-regulator.o
+obj-$(CONFIG_REGULATOR_RT6160)	+= rt6160-regulator.o
 obj-$(CONFIG_REGULATOR_RTMV20)	+= rtmv20-regulator.o
 obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
drivers/regulator/rt6160-regulator.c new file +327 -0

327 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v5 2/2] regulator: rt6160: Add support for Richtek RT6160

Thank you for the patch! Perhaps something to improve:

Hi cy_huang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on regulator/for-next]
[also build test WARNING on v5.13-rc4 next-20210601]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/cy_huang/regulator-rt6160-Add-DT-binding-document-for-Richtek-RT6160/20210601-143438
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f3badc2fd9e7db2b077313371d7b408291a1bb3f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cy_huang/regulator-rt6160-Add-DT-binding-document-for-Richtek-RT6160/20210601-143438 git checkout f3badc2fd9e7db2b077313371d7b408291a1bb3f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from include/linux/device.h:15,

                    from include/linux/acpi.h:15,
                    from include/linux/i2c.h:13,
                    from drivers/regulator/rt6160-regulator.c:5:
   drivers/regulator/rt6160-regulator.c: In function 'rt6160_probe':
>> drivers/regulator/rt6160-regulator.c:269:22: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
     269 |   dev_err(&i2c->dev, "Failed to init regmap (%d)\n", PTR_ERR(priv->regmap));
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/regulator/rt6160-regulator.c:269:3: note: in expansion of macro 'dev_err'
     269 |   dev_err(&i2c->dev, "Failed to init regmap (%d)\n", PTR_ERR(priv->regmap));
         |   ^~~~~~~
   drivers/regulator/rt6160-regulator.c:269:47: note: format string is defined here
     269 |   dev_err(&i2c->dev, "Failed to init regmap (%d)\n", PTR_ERR(priv->regmap));
         |                                              ~^
         |                                               |
         |                                               int
         |                                              %ld

vim +269 drivers/regulator/rt6160-regulator.c

243
244 static int rt6160_probe(struct i2c_client *i2c)
245 {
246 struct rt6160_priv *priv;
247 struct regulator_config regulator_cfg = {};
248 struct regulator_dev *rdev;
249 unsigned int devid;
250 int ret;
251
252 priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
253 if (!priv)
254 return -ENOMEM;
255
256 priv->vsel_active_low = device_property_present(&i2c->dev, "richtek,vsel-active-low");
257
258 priv->enable_gpio = devm_gpiod_get_optional(&i2c->dev, "enable", GPIOD_OUT_HIGH);
259 if (IS_ERR(priv->enable_gpio)) {
260 dev_err(&i2c->dev, "Failed to get 'enable' gpio\n");
261 return PTR_ERR(priv->enable_gpio);
262 }
263 priv->enable_state = true;
264
265 usleep_range(RT6160_I2CRDY_TIMEUS, RT6160_I2CRDY_TIMEUS + 100);
266
267 priv->regmap = devm_regmap_init_i2c(i2c, &rt6160_regmap_config);
268 if (IS_ERR(priv->regmap)) {

 > 269			dev_err(&i2c->dev, "Failed to init regmap (%d)\n", PTR_ERR(priv->regmap));

270 return PTR_ERR(priv->regmap);
271 }
272
273 ret = regmap_read(priv->regmap, RT6160_REG_DEVID, &devid);
274 if (ret)
275 return ret;
276
277 if ((devid & RT6160_VID_MASK) != RT6160_VENDOR_ID) {
278 dev_err(&i2c->dev, "VID not correct [0x%02x]\n", devid);
279 return -ENODEV;
280 }
281
282 priv->desc.name = "rt6160-buckboost";
283 priv->desc.type = REGULATOR_VOLTAGE;
284 priv->desc.owner = THIS_MODULE;
285 priv->desc.min_uV = RT6160_VOUT_MINUV;
286 priv->desc.uV_step = RT6160_VOUT_STPUV;
287 priv->desc.vsel_reg = RT6160_REG_VSELH;
288 priv->desc.vsel_mask = RT6160_VSEL_MASK;
289 priv->desc.n_voltages = RT6160_N_VOUTS;
290 priv->desc.of_map_mode = rt6160_of_map_mode;
291 priv->desc.ops = &rt6160_regulator_ops;
292 if (priv->vsel_active_low)
293 priv->desc.vsel_reg = RT6160_REG_VSELL;
294
295 regulator_cfg.dev = &i2c->dev;
296 regulator_cfg.of_node = i2c->dev.of_node;
297 regulator_cfg.regmap = priv->regmap;
298 regulator_cfg.driver_data = priv;
299 regulator_cfg.init_data = of_get_regulator_init_data(&i2c->dev, i2c->dev.of_node,
300 &priv->desc);
301
302 rdev = devm_regulator_register(&i2c->dev, &priv->desc, &regulator_cfg);
303 if (IS_ERR(rdev)) {
304 dev_err(&i2c->dev, "Failed to register regulator\n");
305 return PTR_ERR(rdev);
306 }
307
308 return 0;
309 }
310

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org