]> git.sur5r.net Git - u-boot/commitdiff
power: rk808: rename to rk8xx
authorJacob Chen <jacob-chen@iotwrt.com>
Tue, 2 May 2017 06:54:52 +0000 (14:54 +0800)
committerSimon Glass <sjg@chromium.org>
Wed, 10 May 2017 19:37:22 +0000 (13:37 -0600)
Since this driver can be used for rk8xx series pmic,
let's rename rk808 to rk8xx, to make it clear.

Configs parts are done by sed -i "s/RK808/RK8XX/g" `grep RK808 -lr ./`

Signed-off-by: Jacob Chen <jacob-chen@iotwrt.com>
22 files changed:
arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
configs/chromebit_mickey_defconfig
configs/chromebook_jerry_defconfig
configs/chromebook_minnie_defconfig
configs/evb-rk3399_defconfig
configs/fennec-rk3288_defconfig
configs/firefly-rk3399_defconfig
configs/popmetal-rk3288_defconfig
configs/sandbox_defconfig
configs/sandbox_noblk_defconfig
configs/sandbox_spl_defconfig
configs/tinker-rk3288_defconfig
drivers/power/pmic/Kconfig
drivers/power/pmic/Makefile
drivers/power/pmic/rk808.c [deleted file]
drivers/power/pmic/rk8xx.c [new file with mode: 0644]
drivers/power/regulator/Kconfig
drivers/power/regulator/Makefile
drivers/power/regulator/rk808.c [deleted file]
drivers/power/regulator/rk8xx.c [new file with mode: 0644]
include/power/rk808_pmic.h [deleted file]
include/power/rk8xx_pmic.h [new file with mode: 0644]

index 8549b28243a9952c20afecc2d61852e3745d1772..2feda612054b9cc4582f5bce41c098e5f2e3738f 100644 (file)
@@ -24,7 +24,7 @@
 #include <asm/arch/sdram.h>
 #include <linux/err.h>
 #include <power/regulator.h>
-#include <power/rk808_pmic.h>
+#include <power/rk8xx_pmic.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -981,11 +981,11 @@ static int veyron_init(struct dram_info *priv)
                return ret;
 
        /* Slowly raise to max CPU voltage to prevent overshoot */
-       ret = rk808_spl_configure_buck(pmic, 1, 1200000);
+       ret = rk8xx_spl_configure_buck(pmic, 1, 1200000);
        if (ret)
                return ret;
        udelay(175);/* Must wait for voltage to stabilize, 2mV/us */
-       ret = rk808_spl_configure_buck(pmic, 1, 1400000);
+       ret = rk8xx_spl_configure_buck(pmic, 1, 1400000);
        if (ret)
                return ret;
        udelay(100);/* Must wait for voltage to stabilize, 2mV/us */
index 09a24776e8d533f511a232225bfc2a7e6de74c95..649ebf7568bcb3801ee6d660d8e4854abe9d290a 100644 (file)
@@ -54,10 +54,10 @@ CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_ROCKCHIP_RK3288=y
 CONFIG_DM_PMIC=y
 # CONFIG_SPL_PMIC_CHILDREN is not set
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index e254f408de500c7d0370cfdcd7a54a425887963c..6fc0dcc023f2c389c886f9b364fdfa648ca00bc5 100644 (file)
@@ -55,9 +55,9 @@ CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_ROCKCHIP_RK3288=y
 CONFIG_DM_PMIC=y
 # CONFIG_SPL_PMIC_CHILDREN is not set
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index 22e56b6d8573db12ac92d374c546320a26f99df2..ef333c001136ff7dae65da0e10b5e39153bd5e7a 100644 (file)
@@ -55,9 +55,9 @@ CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_ROCKCHIP_RK3288=y
 CONFIG_DM_PMIC=y
 # CONFIG_SPL_PMIC_CHILDREN is not set
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index 76401260311fb7b1ff2f3114d87786d953c2e3ea..fff816926a352d9ba19acc7fd992d40e0abdae9b 100644 (file)
@@ -42,10 +42,10 @@ CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_ROCKCHIP_RK3399=y
 CONFIG_DM_PMIC=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_REGULATOR_PWM=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index befba1882f6827ab057050ffd20cfccf3499fe1f..6a32a3a727bad07a6f26ae83a1f271e6e5e9f7b0 100644 (file)
@@ -49,9 +49,9 @@ CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_PINCTRL_ROCKCHIP_RK3288=y
 CONFIG_DM_PMIC=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index fcd33aea08b89ea13233cef82d5ed9cdcd5d8021..f30f131f34cf0c3faeaf6f40bf3e46d51238db39 100644 (file)
@@ -41,10 +41,10 @@ CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_ROCKCHIP_RK3399_PINCTRL=y
 CONFIG_DM_PMIC=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_REGULATOR_PWM=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index 748cda4f9c7ae1b1014f2cb0f5deec9bff42ac16..c9ad0c022d388e38984f0e9264f4f53c2ef0442f 100644 (file)
@@ -49,9 +49,9 @@ CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_PINCTRL_ROCKCHIP_RK3288=y
 CONFIG_DM_PMIC=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index 95630fc764a93055b21c4cd80363d217a5a40ecd..541705766487ccf6a2038957251bf04aca3716bb 100644 (file)
@@ -127,7 +127,7 @@ CONFIG_PMIC_ACT8846=y
 CONFIG_DM_PMIC_PFUZE100=y
 CONFIG_DM_PMIC_MAX77686=y
 CONFIG_PMIC_PM8916=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_PMIC_S2MPS11=y
 CONFIG_DM_PMIC_SANDBOX=y
 CONFIG_PMIC_S5M8767=y
@@ -137,7 +137,7 @@ CONFIG_REGULATOR_ACT8846=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_MAX77686=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_REGULATOR_S5M8767=y
 CONFIG_DM_REGULATOR_SANDBOX=y
 CONFIG_REGULATOR_TPS65090=y
index 26183afdd28c7af3f986df224c3a89f078a5e4ca..b30e16508f4444257bff5814ee999fea20d290c6 100644 (file)
@@ -131,7 +131,7 @@ CONFIG_PMIC_ACT8846=y
 CONFIG_DM_PMIC_PFUZE100=y
 CONFIG_DM_PMIC_MAX77686=y
 CONFIG_PMIC_PM8916=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_PMIC_S2MPS11=y
 CONFIG_DM_PMIC_SANDBOX=y
 CONFIG_PMIC_S5M8767=y
@@ -141,7 +141,7 @@ CONFIG_REGULATOR_ACT8846=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_MAX77686=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_REGULATOR_S5M8767=y
 CONFIG_DM_REGULATOR_SANDBOX=y
 CONFIG_REGULATOR_TPS65090=y
index 9324353016c3bc24ec05e49e838e035a23bc2b33..3061e5a9d9ae39c5be7678e4f3d79b8ae5d4eafb 100644 (file)
@@ -133,7 +133,7 @@ CONFIG_PMIC_ACT8846=y
 CONFIG_DM_PMIC_PFUZE100=y
 CONFIG_DM_PMIC_MAX77686=y
 CONFIG_PMIC_PM8916=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_PMIC_S2MPS11=y
 CONFIG_DM_PMIC_SANDBOX=y
 CONFIG_PMIC_S5M8767=y
@@ -143,7 +143,7 @@ CONFIG_REGULATOR_ACT8846=y
 CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_MAX77686=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_REGULATOR_S5M8767=y
 CONFIG_DM_REGULATOR_SANDBOX=y
 CONFIG_REGULATOR_TPS65090=y
index 28a1fd8321ebf379bdc3cdf0efa86b0b4165b4ca..bac801e755d0a98b20191562dc04b34ad2d2c3e0 100644 (file)
@@ -52,9 +52,9 @@ CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_PINCTRL_ROCKCHIP_RK3288=y
 CONFIG_DM_PMIC=y
-CONFIG_PMIC_RK808=y
+CONFIG_PMIC_RK8XX=y
 CONFIG_DM_REGULATOR_FIXED=y
-CONFIG_REGULATOR_RK808=y
+CONFIG_REGULATOR_RK8XX=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
index 4891b1704e8ba45eda39981d377746e6d821fa59..3f50c121571d5077b80bf07cc382128df84744c5 100644 (file)
@@ -28,7 +28,7 @@ config SPL_PMIC_CHILDREN
        This allows PMICs to support child devices (such as regulators) in
        SPL. This adds quite a bit of code so if you are not using this
        feature you can turn it off. In this case you may need a 'back door'
-       to call your regulator code (e.g. see rk808.c for direct functions
+       to call your regulator code (e.g. see rk8xx.c for direct functions
        for use in SPL).
 
 config PMIC_ACT8846
@@ -100,8 +100,8 @@ config PMIC_PM8916
 
        Driver binding info: doc/device-tree-bindings/pmic/pm8916.txt
 
-config PMIC_RK808
-       bool "Enable support for Rockchip PMIC RK808"
+config PMIC_RK8XX
+       bool "Enable support for Rockchip PMIC RK8XX"
        depends on DM_PMIC
        ---help---
        The Rockchip RK808 PMIC provides four buck DC-DC convertors, 8 LDOs,
index 5f1bef33cddc38142349a7a61a5677517b049f60..f409e3a0b36c3c368d01db316ca4b2b1a1e3b811 100644 (file)
@@ -15,7 +15,7 @@ obj-$(CONFIG_PMIC_ACT8846) += act8846.o
 obj-$(CONFIG_PMIC_AS3722) += as3722.o
 obj-$(CONFIG_PMIC_MAX8997) += max8997.o
 obj-$(CONFIG_PMIC_PM8916) += pm8916.o
-obj-$(CONFIG_PMIC_RK808) += rk808.o
+obj-$(CONFIG_PMIC_RK8XX) += rk8xx.o
 obj-$(CONFIG_PMIC_RN5T567) += rn5t567.o
 obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
 obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
diff --git a/drivers/power/pmic/rk808.c b/drivers/power/pmic/rk808.c
deleted file mode 100644 (file)
index 582e456..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2015 Google, Inc
- * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <fdtdec.h>
-#include <libfdt.h>
-#include <power/rk808_pmic.h>
-#include <power/pmic.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static const struct pmic_child_info pmic_children_info[] = {
-       { .prefix = "DCDC_REG", .driver = "rk808_buck"},
-       { .prefix = "LDO_REG", .driver = "rk808_ldo"},
-       { .prefix = "SWITCH_REG", .driver = "rk808_switch"},
-       { },
-};
-
-static int rk808_reg_count(struct udevice *dev)
-{
-       return RK808_NUM_OF_REGS;
-}
-
-static int rk808_write(struct udevice *dev, uint reg, const uint8_t *buff,
-                         int len)
-{
-       int ret;
-
-       ret = dm_i2c_write(dev, reg, buff, len);
-       if (ret) {
-               debug("write error to device: %p register: %#x!", dev, reg);
-               return ret;
-       }
-
-       return 0;
-}
-
-static int rk808_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
-{
-       int ret;
-
-       ret = dm_i2c_read(dev, reg, buff, len);
-       if (ret) {
-               debug("read error from device: %p register: %#x!", dev, reg);
-               return ret;
-       }
-
-       return 0;
-}
-
-#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
-static int rk808_bind(struct udevice *dev)
-{
-       const void *blob = gd->fdt_blob;
-       int regulators_node;
-       int children;
-
-       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
-                                            "regulators");
-       if (regulators_node <= 0) {
-               debug("%s: %s regulators subnode not found!", __func__,
-                     dev->name);
-               return -ENXIO;
-       }
-
-       debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
-
-       children = pmic_bind_children(dev, regulators_node, pmic_children_info);
-       if (!children)
-               debug("%s: %s - no child found\n", __func__, dev->name);
-
-       /* Always return success for this device */
-       return 0;
-}
-#endif
-
-static int rk808_probe(struct udevice *dev)
-{
-       struct rk808_priv *priv = dev_get_priv(dev);
-       uint8_t msb, lsb;
-
-       /* read Chip variant */
-       rk808_read(dev, ID_MSB, &msb, 1);
-       rk808_read(dev, ID_LSB, &lsb, 1);
-
-       priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
-
-       return 0;
-}
-
-static struct dm_pmic_ops rk808_ops = {
-       .reg_count = rk808_reg_count,
-       .read = rk808_read,
-       .write = rk808_write,
-};
-
-static const struct udevice_id rk808_ids[] = {
-       { .compatible = "rockchip,rk808" },
-       { .compatible = "rockchip,rk818" },
-       { }
-};
-
-U_BOOT_DRIVER(pmic_rk808) = {
-       .name = "rk808 pmic",
-       .id = UCLASS_PMIC,
-       .of_match = rk808_ids,
-#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
-       .bind = rk808_bind,
-#endif
-       .probe = rk808_probe,
-       .ops = &rk808_ops,
-};
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
new file mode 100644 (file)
index 0000000..394e2ff
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <libfdt.h>
+#include <power/rk8xx_pmic.h>
+#include <power/pmic.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct pmic_child_info pmic_children_info[] = {
+       { .prefix = "DCDC_REG", .driver = "rk8xx_buck"},
+       { .prefix = "LDO_REG", .driver = "rk8xx_ldo"},
+       { .prefix = "SWITCH_REG", .driver = "rk8xx_switch"},
+       { },
+};
+
+static int rk8xx_reg_count(struct udevice *dev)
+{
+       return RK808_NUM_OF_REGS;
+}
+
+static int rk8xx_write(struct udevice *dev, uint reg, const uint8_t *buff,
+                         int len)
+{
+       int ret;
+
+       ret = dm_i2c_write(dev, reg, buff, len);
+       if (ret) {
+               debug("write error to device: %p register: %#x!", dev, reg);
+               return ret;
+       }
+
+       return 0;
+}
+
+static int rk8xx_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+       int ret;
+
+       ret = dm_i2c_read(dev, reg, buff, len);
+       if (ret) {
+               debug("read error from device: %p register: %#x!", dev, reg);
+               return ret;
+       }
+
+       return 0;
+}
+
+#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
+static int rk8xx_bind(struct udevice *dev)
+{
+       const void *blob = gd->fdt_blob;
+       int regulators_node;
+       int children;
+
+       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
+                                            "regulators");
+       if (regulators_node <= 0) {
+               debug("%s: %s regulators subnode not found!", __func__,
+                     dev->name);
+               return -ENXIO;
+       }
+
+       debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
+
+       children = pmic_bind_children(dev, regulators_node, pmic_children_info);
+       if (!children)
+               debug("%s: %s - no child found\n", __func__, dev->name);
+
+       /* Always return success for this device */
+       return 0;
+}
+#endif
+
+static int rk8xx_probe(struct udevice *dev)
+{
+       struct rk8xx_priv *priv = dev_get_priv(dev);
+       uint8_t msb, lsb;
+
+       /* read Chip variant */
+       rk8xx_read(dev, ID_MSB, &msb, 1);
+       rk8xx_read(dev, ID_LSB, &lsb, 1);
+
+       priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+
+       return 0;
+}
+
+static struct dm_pmic_ops rk8xx_ops = {
+       .reg_count = rk8xx_reg_count,
+       .read = rk8xx_read,
+       .write = rk8xx_write,
+};
+
+static const struct udevice_id rk8xx_ids[] = {
+       { .compatible = "rockchip,rk808" },
+       { .compatible = "rockchip,rk818" },
+       { }
+};
+
+U_BOOT_DRIVER(pmic_rk8xx) = {
+       .name = "rk8xx pmic",
+       .id = UCLASS_PMIC,
+       .of_match = rk8xx_ids,
+#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
+       .bind = rk8xx_bind,
+#endif
+       .probe = rk8xx_probe,
+       .ops = &rk8xx_ops,
+};
index f870e8bcc9feae67aa0a0114d32478570da2de64..ef057e0e2fb318b619e55083c34a02d918596aef 100644 (file)
@@ -76,11 +76,11 @@ config DM_REGULATOR_GPIO
        features for gpio regulators. The driver implements get/set for
        voltage value.
 
-config REGULATOR_RK808
-       bool "Enable driver for RK808 regulators"
-       depends on DM_REGULATOR && PMIC_RK808
+config REGULATOR_RK8XX
+       bool "Enable driver for RK8XX regulators"
+       depends on DM_REGULATOR && PMIC_RK8XX
        ---help---
-       Enable support for the regulator functions of the RK808 PMIC. The
+       Enable support for the regulator functions of the RK8XX PMIC. The
        driver implements get/set api for the various BUCKS and LDOs supported
        by the PMIC device. This driver is controlled by a device tree node
        which includes voltage limits.
index 6002c88a6c17d80826fc5ce03ff26d69b4626cdf..3e01021b76abc274df623d73e1e1f72f1f4f2733 100644 (file)
@@ -12,7 +12,7 @@ obj-$(CONFIG_DM_REGULATOR_PFUZE100) += pfuze100.o
 obj-$(CONFIG_REGULATOR_PWM) += pwm_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o
-obj-$(CONFIG_REGULATOR_RK808) += rk808.o
+obj-$(CONFIG_REGULATOR_RK8XX) += rk8xx.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
 obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
diff --git a/drivers/power/regulator/rk808.c b/drivers/power/regulator/rk808.c
deleted file mode 100644 (file)
index 1ffe9dc..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (C) 2015 Google, Inc
- * Written by Simon Glass <sjg@chromium.org>
- *
- * Based on Rockchip's drivers/power/pmic/pmic_rk808.c:
- * Copyright (C) 2012 rockchips
- * zyw <zyw@rock-chips.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <power/rk808_pmic.h>
-#include <power/pmic.h>
-#include <power/regulator.h>
-
-#ifndef CONFIG_SPL_BUILD
-#define ENABLE_DRIVER
-#endif
-
-/* Field Definitions */
-#define RK808_BUCK_VSEL_MASK   0x3f
-#define RK808_BUCK4_VSEL_MASK  0xf
-#define RK808_LDO_VSEL_MASK    0x1f
-
-#define RK818_BUCK_VSEL_MASK           0x3f
-#define RK818_BUCK4_VSEL_MASK          0x1f
-#define RK818_LDO_VSEL_MASK            0x1f
-#define RK818_LDO3_ON_VSEL_MASK        0xf
-#define RK818_BOOST_ON_VSEL_MASK       0xe0
-
-struct rk808_reg_info {
-       uint min_uv;
-       uint step_uv;
-       s8 vsel_reg;
-       u8 vsel_mask;
-};
-
-static const struct rk808_reg_info rk808_buck[] = {
-       { 712500, 12500, REG_BUCK1_ON_VSEL, RK808_BUCK_VSEL_MASK, },
-       { 712500, 12500, REG_BUCK2_ON_VSEL, RK808_BUCK_VSEL_MASK, },
-       { 712500, 12500, -1, RK808_BUCK_VSEL_MASK, },
-       { 1800000, 100000, REG_BUCK4_ON_VSEL, RK808_BUCK4_VSEL_MASK, },
-};
-
-static const struct rk808_reg_info rk808_ldo[] = {
-       { 1800000, 100000, REG_LDO1_ON_VSEL, RK808_LDO_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO2_ON_VSEL, RK808_LDO_VSEL_MASK, },
-       { 800000, 100000, REG_LDO3_ON_VSEL, RK808_BUCK4_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO4_ON_VSEL, RK808_LDO_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO5_ON_VSEL, RK808_LDO_VSEL_MASK, },
-       { 800000, 100000, REG_LDO6_ON_VSEL, RK808_LDO_VSEL_MASK, },
-       { 800000, 100000, REG_LDO7_ON_VSEL, RK808_LDO_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO8_ON_VSEL, RK808_LDO_VSEL_MASK, },
-};
-
-static const struct rk808_reg_info rk818_buck[] = {
-       { 712500, 12500, REG_BUCK1_ON_VSEL, RK818_BUCK_VSEL_MASK, },
-       { 712500, 12500, REG_BUCK2_ON_VSEL, RK818_BUCK_VSEL_MASK, },
-       { 712500, 12500, -1, RK818_BUCK_VSEL_MASK, },
-       { 1800000, 100000, REG_BUCK4_ON_VSEL, RK818_BUCK4_VSEL_MASK, },
-};
-
-static const struct rk808_reg_info rk818_ldo[] = {
-       { 1800000, 100000, REG_LDO1_ON_VSEL, RK818_LDO_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO2_ON_VSEL, RK818_LDO_VSEL_MASK, },
-       { 800000, 100000, REG_LDO3_ON_VSEL, RK818_LDO3_ON_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO4_ON_VSEL, RK818_LDO_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO5_ON_VSEL, RK818_LDO_VSEL_MASK, },
-       { 800000, 100000, REG_LDO6_ON_VSEL, RK818_LDO_VSEL_MASK, },
-       { 800000, 100000, REG_LDO7_ON_VSEL, RK818_LDO_VSEL_MASK, },
-       { 1800000, 100000, REG_LDO8_ON_VSEL, RK818_LDO_VSEL_MASK, },
-};
-
-static const struct rk808_reg_info *get_buck_reg(struct udevice *pmic,
-                                            int num)
-{
-       struct rk808_priv *rk808 = dev_get_priv(pmic);
-       switch (rk808->variant) {
-       case RK818_ID:
-               return &rk818_buck[num];
-       default:
-               return &rk808_buck[num];
-       }
-}
-
-static const struct rk808_reg_info *get_ldo_reg(struct udevice *pmic,
-                                            int num)
-{
-       struct rk808_priv *rk808 = dev_get_priv(pmic);
-       switch (rk808->variant) {
-       case RK818_ID:
-               return &rk818_ldo[num - 1];
-       default:
-               return &rk808_ldo[num - 1];
-       }
-}
-
-static int _buck_set_value(struct udevice *pmic, int buck, int uvolt)
-{
-       const struct rk808_reg_info *info = get_buck_reg(pmic, buck - 1);
-       int mask = info->vsel_mask;
-       int val;
-
-       if (info->vsel_reg == -1)
-               return -ENOSYS;
-       val = (uvolt - info->min_uv) / info->step_uv;
-       debug("%s: reg=%x, mask=%x, val=%x\n", __func__, info->vsel_reg, mask,
-             val);
-
-       return pmic_clrsetbits(pmic, info->vsel_reg, mask, val);
-}
-
-static int _buck_set_enable(struct udevice *pmic, int buck, bool enable)
-{
-       uint mask;
-       int ret;
-
-       buck--;
-       mask = 1 << buck;
-       if (enable) {
-               ret = pmic_clrsetbits(pmic, REG_DCDC_ILMAX, 0, 3 << (buck * 2));
-               if (ret)
-                       return ret;
-               ret = pmic_clrsetbits(pmic, REG_DCDC_UV_ACT, 1 << buck, 0);
-               if (ret)
-                       return ret;
-       }
-
-       return pmic_clrsetbits(pmic, REG_DCDC_EN, mask, enable ? mask : 0);
-}
-
-#ifdef ENABLE_DRIVER
-static int buck_get_value(struct udevice *dev)
-{
-       int buck = dev->driver_data - 1;
-       const struct rk808_reg_info *info = get_buck_reg(dev->parent, buck);
-       int mask = info->vsel_mask;
-       int ret, val;
-
-       if (info->vsel_reg == -1)
-               return -ENOSYS;
-       ret = pmic_reg_read(dev->parent, info->vsel_reg);
-       if (ret < 0)
-               return ret;
-       val = ret & mask;
-
-       return info->min_uv + val * info->step_uv;
-}
-
-static int buck_set_value(struct udevice *dev, int uvolt)
-{
-       int buck = dev->driver_data;
-
-       return _buck_set_value(dev->parent, buck, uvolt);
-}
-
-static int buck_set_enable(struct udevice *dev, bool enable)
-{
-       int buck = dev->driver_data;
-
-       return _buck_set_enable(dev->parent, buck, enable);
-}
-
-static bool buck_get_enable(struct udevice *dev)
-{
-       int buck = dev->driver_data - 1;
-       int ret;
-       uint mask;
-
-       mask = 1 << buck;
-
-       ret = pmic_reg_read(dev->parent, REG_DCDC_EN);
-       if (ret < 0)
-               return ret;
-
-       return ret & mask ? true : false;
-}
-
-static int ldo_get_value(struct udevice *dev)
-{
-       int ldo = dev->driver_data - 1;
-       const struct rk808_reg_info *info = get_ldo_reg(dev->parent, ldo);
-       int mask = info->vsel_mask;
-       int ret, val;
-
-       if (info->vsel_reg == -1)
-               return -ENOSYS;
-       ret = pmic_reg_read(dev->parent, info->vsel_reg);
-       if (ret < 0)
-               return ret;
-       val = ret & mask;
-
-       return info->min_uv + val * info->step_uv;
-}
-
-static int ldo_set_value(struct udevice *dev, int uvolt)
-{
-       int ldo = dev->driver_data - 1;
-       const struct rk808_reg_info *info = get_ldo_reg(dev->parent, ldo);
-       int mask = info->vsel_mask;
-       int val;
-
-       if (info->vsel_reg == -1)
-               return -ENOSYS;
-       val = (uvolt - info->min_uv) / info->step_uv;
-       debug("%s: reg=%x, mask=%x, val=%x\n", __func__, info->vsel_reg, mask,
-             val);
-
-       return pmic_clrsetbits(dev->parent, info->vsel_reg, mask, val);
-}
-
-static int ldo_set_enable(struct udevice *dev, bool enable)
-{
-       int ldo = dev->driver_data - 1;
-       uint mask;
-
-       mask = 1 << ldo;
-
-       return pmic_clrsetbits(dev->parent, REG_LDO_EN, mask,
-                              enable ? mask : 0);
-}
-
-static bool ldo_get_enable(struct udevice *dev)
-{
-       int ldo = dev->driver_data - 1;
-       int ret;
-       uint mask;
-
-       mask = 1 << ldo;
-
-       ret = pmic_reg_read(dev->parent, REG_LDO_EN);
-       if (ret < 0)
-               return ret;
-
-       return ret & mask ? true : false;
-}
-
-static int switch_set_enable(struct udevice *dev, bool enable)
-{
-       int sw = dev->driver_data - 1;
-       uint mask;
-
-       mask = 1 << (sw + 5);
-
-       return pmic_clrsetbits(dev->parent, REG_DCDC_EN, mask,
-                              enable ? mask : 0);
-}
-
-static bool switch_get_enable(struct udevice *dev)
-{
-       int sw = dev->driver_data - 1;
-       int ret;
-       uint mask;
-
-       mask = 1 << (sw + 5);
-
-       ret = pmic_reg_read(dev->parent, REG_DCDC_EN);
-       if (ret < 0)
-               return ret;
-
-       return ret & mask ? true : false;
-}
-
-static int rk808_buck_probe(struct udevice *dev)
-{
-       struct dm_regulator_uclass_platdata *uc_pdata;
-
-       uc_pdata = dev_get_uclass_platdata(dev);
-
-       uc_pdata->type = REGULATOR_TYPE_BUCK;
-       uc_pdata->mode_count = 0;
-
-       return 0;
-}
-
-static int rk808_ldo_probe(struct udevice *dev)
-{
-       struct dm_regulator_uclass_platdata *uc_pdata;
-
-       uc_pdata = dev_get_uclass_platdata(dev);
-
-       uc_pdata->type = REGULATOR_TYPE_LDO;
-       uc_pdata->mode_count = 0;
-
-       return 0;
-}
-
-static int rk808_switch_probe(struct udevice *dev)
-{
-       struct dm_regulator_uclass_platdata *uc_pdata;
-
-       uc_pdata = dev_get_uclass_platdata(dev);
-
-       uc_pdata->type = REGULATOR_TYPE_FIXED;
-       uc_pdata->mode_count = 0;
-
-       return 0;
-}
-
-static const struct dm_regulator_ops rk808_buck_ops = {
-       .get_value  = buck_get_value,
-       .set_value  = buck_set_value,
-       .get_enable = buck_get_enable,
-       .set_enable = buck_set_enable,
-};
-
-static const struct dm_regulator_ops rk808_ldo_ops = {
-       .get_value  = ldo_get_value,
-       .set_value  = ldo_set_value,
-       .get_enable = ldo_get_enable,
-       .set_enable = ldo_set_enable,
-};
-
-static const struct dm_regulator_ops rk808_switch_ops = {
-       .get_enable = switch_get_enable,
-       .set_enable = switch_set_enable,
-};
-
-U_BOOT_DRIVER(rk808_buck) = {
-       .name = "rk808_buck",
-       .id = UCLASS_REGULATOR,
-       .ops = &rk808_buck_ops,
-       .probe = rk808_buck_probe,
-};
-
-U_BOOT_DRIVER(rk808_ldo) = {
-       .name = "rk808_ldo",
-       .id = UCLASS_REGULATOR,
-       .ops = &rk808_ldo_ops,
-       .probe = rk808_ldo_probe,
-};
-
-U_BOOT_DRIVER(rk808_switch) = {
-       .name = "rk808_switch",
-       .id = UCLASS_REGULATOR,
-       .ops = &rk808_switch_ops,
-       .probe = rk808_switch_probe,
-};
-#endif
-
-int rk808_spl_configure_buck(struct udevice *pmic, int buck, int uvolt)
-{
-       int ret;
-
-       ret = _buck_set_value(pmic, buck, uvolt);
-       if (ret)
-               return ret;
-
-       return _buck_set_enable(pmic, buck, true);
-}
diff --git a/drivers/power/regulator/rk8xx.c b/drivers/power/regulator/rk8xx.c
new file mode 100644 (file)
index 0000000..e655c2d
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * Based on Rockchip's drivers/power/pmic/pmic_rk808.c:
+ * Copyright (C) 2012 rockchips
+ * zyw <zyw@rock-chips.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <power/rk8xx_pmic.h>
+#include <power/pmic.h>
+#include <power/regulator.h>
+
+#ifndef CONFIG_SPL_BUILD
+#define ENABLE_DRIVER
+#endif
+
+/* Field Definitions */
+#define RK808_BUCK_VSEL_MASK   0x3f
+#define RK808_BUCK4_VSEL_MASK  0xf
+#define RK808_LDO_VSEL_MASK    0x1f
+
+#define RK818_BUCK_VSEL_MASK           0x3f
+#define RK818_BUCK4_VSEL_MASK          0x1f
+#define RK818_LDO_VSEL_MASK            0x1f
+#define RK818_LDO3_ON_VSEL_MASK        0xf
+#define RK818_BOOST_ON_VSEL_MASK       0xe0
+
+struct rk8xx_reg_info {
+       uint min_uv;
+       uint step_uv;
+       s8 vsel_reg;
+       u8 vsel_mask;
+};
+
+static const struct rk8xx_reg_info rk808_buck[] = {
+       { 712500, 12500, REG_BUCK1_ON_VSEL, RK808_BUCK_VSEL_MASK, },
+       { 712500, 12500, REG_BUCK2_ON_VSEL, RK808_BUCK_VSEL_MASK, },
+       { 712500, 12500, -1, RK808_BUCK_VSEL_MASK, },
+       { 1800000, 100000, REG_BUCK4_ON_VSEL, RK808_BUCK4_VSEL_MASK, },
+};
+
+static const struct rk8xx_reg_info rk808_ldo[] = {
+       { 1800000, 100000, REG_LDO1_ON_VSEL, RK808_LDO_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO2_ON_VSEL, RK808_LDO_VSEL_MASK, },
+       { 800000, 100000, REG_LDO3_ON_VSEL, RK808_BUCK4_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO4_ON_VSEL, RK808_LDO_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO5_ON_VSEL, RK808_LDO_VSEL_MASK, },
+       { 800000, 100000, REG_LDO6_ON_VSEL, RK808_LDO_VSEL_MASK, },
+       { 800000, 100000, REG_LDO7_ON_VSEL, RK808_LDO_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO8_ON_VSEL, RK808_LDO_VSEL_MASK, },
+};
+
+static const struct rk8xx_reg_info rk818_buck[] = {
+       { 712500, 12500, REG_BUCK1_ON_VSEL, RK818_BUCK_VSEL_MASK, },
+       { 712500, 12500, REG_BUCK2_ON_VSEL, RK818_BUCK_VSEL_MASK, },
+       { 712500, 12500, -1, RK818_BUCK_VSEL_MASK, },
+       { 1800000, 100000, REG_BUCK4_ON_VSEL, RK818_BUCK4_VSEL_MASK, },
+};
+
+static const struct rk8xx_reg_info rk818_ldo[] = {
+       { 1800000, 100000, REG_LDO1_ON_VSEL, RK818_LDO_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO2_ON_VSEL, RK818_LDO_VSEL_MASK, },
+       { 800000, 100000, REG_LDO3_ON_VSEL, RK818_LDO3_ON_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO4_ON_VSEL, RK818_LDO_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO5_ON_VSEL, RK818_LDO_VSEL_MASK, },
+       { 800000, 100000, REG_LDO6_ON_VSEL, RK818_LDO_VSEL_MASK, },
+       { 800000, 100000, REG_LDO7_ON_VSEL, RK818_LDO_VSEL_MASK, },
+       { 1800000, 100000, REG_LDO8_ON_VSEL, RK818_LDO_VSEL_MASK, },
+};
+
+static const struct rk8xx_reg_info *get_buck_reg(struct udevice *pmic,
+                                            int num)
+{
+       struct rk8xx_priv *priv = dev_get_priv(pmic);
+       switch (priv->variant) {
+       case RK818_ID:
+               return &rk818_buck[num];
+       default:
+               return &rk808_buck[num];
+       }
+}
+
+static const struct rk8xx_reg_info *get_ldo_reg(struct udevice *pmic,
+                                            int num)
+{
+       struct rk8xx_priv *priv = dev_get_priv(pmic);
+       switch (priv->variant) {
+       case RK818_ID:
+               return &rk818_ldo[num - 1];
+       default:
+               return &rk808_ldo[num - 1];
+       }
+}
+
+static int _buck_set_value(struct udevice *pmic, int buck, int uvolt)
+{
+       const struct rk8xx_reg_info *info = get_buck_reg(pmic, buck - 1);
+       int mask = info->vsel_mask;
+       int val;
+
+       if (info->vsel_reg == -1)
+               return -ENOSYS;
+       val = (uvolt - info->min_uv) / info->step_uv;
+       debug("%s: reg=%x, mask=%x, val=%x\n", __func__, info->vsel_reg, mask,
+             val);
+
+       return pmic_clrsetbits(pmic, info->vsel_reg, mask, val);
+}
+
+static int _buck_set_enable(struct udevice *pmic, int buck, bool enable)
+{
+       uint mask;
+       int ret;
+
+       buck--;
+       mask = 1 << buck;
+       if (enable) {
+               ret = pmic_clrsetbits(pmic, REG_DCDC_ILMAX, 0, 3 << (buck * 2));
+               if (ret)
+                       return ret;
+               ret = pmic_clrsetbits(pmic, REG_DCDC_UV_ACT, 1 << buck, 0);
+               if (ret)
+                       return ret;
+       }
+
+       return pmic_clrsetbits(pmic, REG_DCDC_EN, mask, enable ? mask : 0);
+}
+
+#ifdef ENABLE_DRIVER
+static int buck_get_value(struct udevice *dev)
+{
+       int buck = dev->driver_data - 1;
+       const struct rk8xx_reg_info *info = get_buck_reg(dev->parent, buck);
+       int mask = info->vsel_mask;
+       int ret, val;
+
+       if (info->vsel_reg == -1)
+               return -ENOSYS;
+       ret = pmic_reg_read(dev->parent, info->vsel_reg);
+       if (ret < 0)
+               return ret;
+       val = ret & mask;
+
+       return info->min_uv + val * info->step_uv;
+}
+
+static int buck_set_value(struct udevice *dev, int uvolt)
+{
+       int buck = dev->driver_data;
+
+       return _buck_set_value(dev->parent, buck, uvolt);
+}
+
+static int buck_set_enable(struct udevice *dev, bool enable)
+{
+       int buck = dev->driver_data;
+
+       return _buck_set_enable(dev->parent, buck, enable);
+}
+
+static bool buck_get_enable(struct udevice *dev)
+{
+       int buck = dev->driver_data - 1;
+       int ret;
+       uint mask;
+
+       mask = 1 << buck;
+
+       ret = pmic_reg_read(dev->parent, REG_DCDC_EN);
+       if (ret < 0)
+               return ret;
+
+       return ret & mask ? true : false;
+}
+
+static int ldo_get_value(struct udevice *dev)
+{
+       int ldo = dev->driver_data - 1;
+       const struct rk8xx_reg_info *info = get_ldo_reg(dev->parent, ldo);
+       int mask = info->vsel_mask;
+       int ret, val;
+
+       if (info->vsel_reg == -1)
+               return -ENOSYS;
+       ret = pmic_reg_read(dev->parent, info->vsel_reg);
+       if (ret < 0)
+               return ret;
+       val = ret & mask;
+
+       return info->min_uv + val * info->step_uv;
+}
+
+static int ldo_set_value(struct udevice *dev, int uvolt)
+{
+       int ldo = dev->driver_data - 1;
+       const struct rk8xx_reg_info *info = get_ldo_reg(dev->parent, ldo);
+       int mask = info->vsel_mask;
+       int val;
+
+       if (info->vsel_reg == -1)
+               return -ENOSYS;
+       val = (uvolt - info->min_uv) / info->step_uv;
+       debug("%s: reg=%x, mask=%x, val=%x\n", __func__, info->vsel_reg, mask,
+             val);
+
+       return pmic_clrsetbits(dev->parent, info->vsel_reg, mask, val);
+}
+
+static int ldo_set_enable(struct udevice *dev, bool enable)
+{
+       int ldo = dev->driver_data - 1;
+       uint mask;
+
+       mask = 1 << ldo;
+
+       return pmic_clrsetbits(dev->parent, REG_LDO_EN, mask,
+                              enable ? mask : 0);
+}
+
+static bool ldo_get_enable(struct udevice *dev)
+{
+       int ldo = dev->driver_data - 1;
+       int ret;
+       uint mask;
+
+       mask = 1 << ldo;
+
+       ret = pmic_reg_read(dev->parent, REG_LDO_EN);
+       if (ret < 0)
+               return ret;
+
+       return ret & mask ? true : false;
+}
+
+static int switch_set_enable(struct udevice *dev, bool enable)
+{
+       int sw = dev->driver_data - 1;
+       uint mask;
+
+       mask = 1 << (sw + 5);
+
+       return pmic_clrsetbits(dev->parent, REG_DCDC_EN, mask,
+                              enable ? mask : 0);
+}
+
+static bool switch_get_enable(struct udevice *dev)
+{
+       int sw = dev->driver_data - 1;
+       int ret;
+       uint mask;
+
+       mask = 1 << (sw + 5);
+
+       ret = pmic_reg_read(dev->parent, REG_DCDC_EN);
+       if (ret < 0)
+               return ret;
+
+       return ret & mask ? true : false;
+}
+
+static int rk8xx_buck_probe(struct udevice *dev)
+{
+       struct dm_regulator_uclass_platdata *uc_pdata;
+
+       uc_pdata = dev_get_uclass_platdata(dev);
+
+       uc_pdata->type = REGULATOR_TYPE_BUCK;
+       uc_pdata->mode_count = 0;
+
+       return 0;
+}
+
+static int rk8xx_ldo_probe(struct udevice *dev)
+{
+       struct dm_regulator_uclass_platdata *uc_pdata;
+
+       uc_pdata = dev_get_uclass_platdata(dev);
+
+       uc_pdata->type = REGULATOR_TYPE_LDO;
+       uc_pdata->mode_count = 0;
+
+       return 0;
+}
+
+static int rk8xx_switch_probe(struct udevice *dev)
+{
+       struct dm_regulator_uclass_platdata *uc_pdata;
+
+       uc_pdata = dev_get_uclass_platdata(dev);
+
+       uc_pdata->type = REGULATOR_TYPE_FIXED;
+       uc_pdata->mode_count = 0;
+
+       return 0;
+}
+
+static const struct dm_regulator_ops rk8xx_buck_ops = {
+       .get_value  = buck_get_value,
+       .set_value  = buck_set_value,
+       .get_enable = buck_get_enable,
+       .set_enable = buck_set_enable,
+};
+
+static const struct dm_regulator_ops rk8xx_ldo_ops = {
+       .get_value  = ldo_get_value,
+       .set_value  = ldo_set_value,
+       .get_enable = ldo_get_enable,
+       .set_enable = ldo_set_enable,
+};
+
+static const struct dm_regulator_ops rk8xx_switch_ops = {
+       .get_enable = switch_get_enable,
+       .set_enable = switch_set_enable,
+};
+
+U_BOOT_DRIVER(rk8xx_buck) = {
+       .name = "rk8xx_buck",
+       .id = UCLASS_REGULATOR,
+       .ops = &rk8xx_buck_ops,
+       .probe = rk8xx_buck_probe,
+};
+
+U_BOOT_DRIVER(rk8xx_ldo) = {
+       .name = "rk8xx_ldo",
+       .id = UCLASS_REGULATOR,
+       .ops = &rk8xx_ldo_ops,
+       .probe = rk8xx_ldo_probe,
+};
+
+U_BOOT_DRIVER(rk8xx_switch) = {
+       .name = "rk8xx_switch",
+       .id = UCLASS_REGULATOR,
+       .ops = &rk8xx_switch_ops,
+       .probe = rk8xx_switch_probe,
+};
+#endif
+
+int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt)
+{
+       int ret;
+
+       ret = _buck_set_value(pmic, buck, uvolt);
+       if (ret)
+               return ret;
+
+       return _buck_set_enable(pmic, buck, true);
+}
diff --git a/include/power/rk808_pmic.h b/include/power/rk808_pmic.h
deleted file mode 100644 (file)
index c370c32..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2015 Google, Inc
- * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef _PMIC_RK808_H_
-#define _PMIC_RK808_H_
-
-enum {
-       REG_SECONDS                     = 0x00,
-       REG_MINUTES,
-       REG_HOURS,
-       REG_DAYS,
-       REG_MONTHS,
-       REG_YEARS,
-       REG_WEEKS,
-       REG_ALARM_SECONDS,
-       REG_ALARM_MINUTES,
-       REG_ALARM_HOURS,
-       REG_ALARM_DAYS,
-       REG_ALARM_MONTHS,
-       REG_ALARM_YEARS,
-
-       REG_RTC_CTRL                    = 0x10,
-       REG_RTC_STATUS,
-       REG_RTC_INT,
-       REG_RTC_COMP_LSB,
-       REG_RTC_COMP_MSB,
-
-       ID_MSB                          = 0x17,
-       ID_LSB,
-
-       REG_CLK32OUT                    = 0x20,
-       REG_VB_MON,
-       REG_THERMAL,
-       REG_DCDC_EN,
-       REG_LDO_EN,
-       REG_SLEEP_SET_OFF1,
-       REG_SLEEP_SET_OFF2,
-       REG_DCDC_UV_STS,
-       REG_DCDC_UV_ACT,
-       REG_LDO_UV_STS,
-       REG_LDO_UV_ACT,
-       REG_DCDC_PG,
-       REG_LDO_PG,
-       REG_VOUT_MON_TDB,
-       REG_BUCK1_CONFIG,
-       REG_BUCK1_ON_VSEL,
-       REG_BUCK1_SLP_VSEL,
-       REG_BUCK1_DVS_VSEL,
-       REG_BUCK2_CONFIG,
-       REG_BUCK2_ON_VSEL,
-       REG_BUCK2_SLP_VSEL,
-       REG_BUCK2_DVS_VSEL,
-       REG_BUCK3_CONFIG,
-       REG_BUCK4_CONFIG,
-       REG_BUCK4_ON_VSEL,
-       REG_BUCK4_SLP_VSEL,
-       REG_BOOST_CONFIG_REG,
-       REG_LDO1_ON_VSEL,
-       REG_LDO1_SLP_VSEL,
-       REG_LDO2_ON_VSEL,
-       REG_LDO2_SLP_VSEL,
-       REG_LDO3_ON_VSEL,
-       REG_LDO3_SLP_VSEL,
-       REG_LDO4_ON_VSEL,
-       REG_LDO4_SLP_VSEL,
-       REG_LDO5_ON_VSEL,
-       REG_LDO5_SLP_VSEL,
-       REG_LDO6_ON_VSEL,
-       REG_LDO6_SLP_VSEL,
-       REG_LDO7_ON_VSEL,
-       REG_LDO7_SLP_VSEL,
-       REG_LDO8_ON_VSEL,
-       REG_LDO8_SLP_VSEL,
-       REG_DEVCTRL,
-       REG_INT_STS1,
-       REG_INT_STS_MSK1,
-       REG_INT_STS2,
-       REG_INT_STS_MSK2,
-       REG_IO_POL,
-       REG_OTP_VDD_EN,
-       REG_H5V_EN,
-       REG_SLEEP_SET_OFF,
-       REG_BOOST_LDO9_ON_VSEL,
-       REG_BOOST_LDO9_SLP_VSEL,
-       REG_BOOST_CTRL,
-
-       /* Not sure what this does */
-       REG_DCDC_ILMAX                  = 0x90,
-       REG_CHRG_COMP                   = 0x9a,
-       REG_SUP_STS                     = 0xa0,
-       REG_USB_CTRL,
-       REG1_CHRG_CTRL,
-       REG2_CHRG_CTRL,
-       REG3_CHRG_CTRL,
-       REG_BAT_CTRL,
-       REG_BAT_HTS_TS1,
-       REG_BAT_LTS_TS1,
-       REG_BAT_HTS_TS2,
-       REG_BAT_LTS_TS2,
-       REG_TS_CTRL,
-       REG_ADC_CTRL,
-       REG_ON_SOURCE,
-       REG_OFF_SOURCE,
-       REG_GGCON,
-       REG_GGSTS,
-       REG_FRAME_SMP_INTERV,
-       REG_AUTO_SLP_CUR_THR,
-       REG3_GASCNT_CAL,
-       REG2_GASCNT_CAL,
-       REG1_GASCNT_CAL,
-       REG0_GASCNT_CAL,
-       REG3_GASCNT,
-       REG2_GASCNT,
-       REG1_GASCNT,
-       REG0_GASCNT,
-       REGH_BAT_CUR_AVG,
-       REGL_BAT_CUR_AVG,
-       REGH_TS1_ADC,
-       REGL_TS1_ADC,
-       REGH_TS2_ADC,
-       REGL_TS2_ADC,
-       REGH_BAT_OCV,
-       REGL_BAT_OCV,
-       REGH_BAT_VOL,
-       REGL_BAT_VOL,
-       REGH_RELAX_ENTRY_THRES,
-       REGL_RELAX_ENTRY_THRES,
-       REGH_RELAX_EXIT_THRES,
-       REGL_RELAX_EXIT_THRES,
-       REGH_RELAX_VOL1,
-       REGL_RELAX_VOL1,
-       REGH_RELAX_VOL2,
-       REGL_RELAX_VOL2,
-       REGH_BAT_CUR_R_CALC,
-       REGL_BAT_CUR_R_CALC,
-       REGH_BAT_VOL_R_CALC,
-       REGL_BAT_VOL_R_CALC,
-       REGH_CAL_OFFSET,
-       REGL_CAL_OFFSET,
-       REG_NON_ACT_TIMER_CNT,
-       REGH_VCALIB0,
-       REGL_VCALIB0,
-       REGH_VCALIB1,
-       REGL_VCALIB1,
-       REGH_IOFFSET,
-       REGL_IOFFSET,
-       REG_SOC,
-       REG3_REMAIN_CAP,
-       REG2_REMAIN_CAP,
-       REG1_REMAIN_CAP,
-       REG0_REMAIN_CAP,
-       REG_UPDAT_LEVE,
-       REG3_NEW_FCC,
-       REG2_NEW_FCC,
-       REG1_NEW_FCC,
-       REG0_NEW_FCC,
-       REG_NON_ACT_TIMER_CNT_SAVE,
-       REG_OCV_VOL_VALID,
-       REG_REBOOT_CNT,
-       REG_POFFSET,
-       REG_MISC_MARK,
-       REG_HALT_CNT,
-       REGH_CALC_REST,
-       REGL_CALC_REST,
-       SAVE_DATA19,
-       RK808_NUM_OF_REGS,
-};
-
-enum {
-       RK805_ID = 0x8050,
-       RK808_ID = 0x0000,
-       RK818_ID = 0x8180,
-};
-
-#define RK8XX_ID_MSK   0xfff0
-
-struct rk808_reg_table {
-       char *name;
-       u8 reg_ctl;
-       u8 reg_vol;
-};
-
-struct rk808_priv {
-       int variant;
-};
-
-int rk808_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
-
-#endif
diff --git a/include/power/rk8xx_pmic.h b/include/power/rk8xx_pmic.h
new file mode 100644 (file)
index 0000000..589f8c4
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _PMIC_RK8XX_H_
+#define _PMIC_RK8XX_H_
+
+enum {
+       REG_SECONDS                     = 0x00,
+       REG_MINUTES,
+       REG_HOURS,
+       REG_DAYS,
+       REG_MONTHS,
+       REG_YEARS,
+       REG_WEEKS,
+       REG_ALARM_SECONDS,
+       REG_ALARM_MINUTES,
+       REG_ALARM_HOURS,
+       REG_ALARM_DAYS,
+       REG_ALARM_MONTHS,
+       REG_ALARM_YEARS,
+
+       REG_RTC_CTRL                    = 0x10,
+       REG_RTC_STATUS,
+       REG_RTC_INT,
+       REG_RTC_COMP_LSB,
+       REG_RTC_COMP_MSB,
+
+       ID_MSB                          = 0x17,
+       ID_LSB,
+
+       REG_CLK32OUT                    = 0x20,
+       REG_VB_MON,
+       REG_THERMAL,
+       REG_DCDC_EN,
+       REG_LDO_EN,
+       REG_SLEEP_SET_OFF1,
+       REG_SLEEP_SET_OFF2,
+       REG_DCDC_UV_STS,
+       REG_DCDC_UV_ACT,
+       REG_LDO_UV_STS,
+       REG_LDO_UV_ACT,
+       REG_DCDC_PG,
+       REG_LDO_PG,
+       REG_VOUT_MON_TDB,
+       REG_BUCK1_CONFIG,
+       REG_BUCK1_ON_VSEL,
+       REG_BUCK1_SLP_VSEL,
+       REG_BUCK1_DVS_VSEL,
+       REG_BUCK2_CONFIG,
+       REG_BUCK2_ON_VSEL,
+       REG_BUCK2_SLP_VSEL,
+       REG_BUCK2_DVS_VSEL,
+       REG_BUCK3_CONFIG,
+       REG_BUCK4_CONFIG,
+       REG_BUCK4_ON_VSEL,
+       REG_BUCK4_SLP_VSEL,
+       REG_BOOST_CONFIG_REG,
+       REG_LDO1_ON_VSEL,
+       REG_LDO1_SLP_VSEL,
+       REG_LDO2_ON_VSEL,
+       REG_LDO2_SLP_VSEL,
+       REG_LDO3_ON_VSEL,
+       REG_LDO3_SLP_VSEL,
+       REG_LDO4_ON_VSEL,
+       REG_LDO4_SLP_VSEL,
+       REG_LDO5_ON_VSEL,
+       REG_LDO5_SLP_VSEL,
+       REG_LDO6_ON_VSEL,
+       REG_LDO6_SLP_VSEL,
+       REG_LDO7_ON_VSEL,
+       REG_LDO7_SLP_VSEL,
+       REG_LDO8_ON_VSEL,
+       REG_LDO8_SLP_VSEL,
+       REG_DEVCTRL,
+       REG_INT_STS1,
+       REG_INT_STS_MSK1,
+       REG_INT_STS2,
+       REG_INT_STS_MSK2,
+       REG_IO_POL,
+       REG_OTP_VDD_EN,
+       REG_H5V_EN,
+       REG_SLEEP_SET_OFF,
+       REG_BOOST_LDO9_ON_VSEL,
+       REG_BOOST_LDO9_SLP_VSEL,
+       REG_BOOST_CTRL,
+
+       /* Not sure what this does */
+       REG_DCDC_ILMAX                  = 0x90,
+       REG_CHRG_COMP                   = 0x9a,
+       REG_SUP_STS                     = 0xa0,
+       REG_USB_CTRL,
+       REG1_CHRG_CTRL,
+       REG2_CHRG_CTRL,
+       REG3_CHRG_CTRL,
+       REG_BAT_CTRL,
+       REG_BAT_HTS_TS1,
+       REG_BAT_LTS_TS1,
+       REG_BAT_HTS_TS2,
+       REG_BAT_LTS_TS2,
+       REG_TS_CTRL,
+       REG_ADC_CTRL,
+       REG_ON_SOURCE,
+       REG_OFF_SOURCE,
+       REG_GGCON,
+       REG_GGSTS,
+       REG_FRAME_SMP_INTERV,
+       REG_AUTO_SLP_CUR_THR,
+       REG3_GASCNT_CAL,
+       REG2_GASCNT_CAL,
+       REG1_GASCNT_CAL,
+       REG0_GASCNT_CAL,
+       REG3_GASCNT,
+       REG2_GASCNT,
+       REG1_GASCNT,
+       REG0_GASCNT,
+       REGH_BAT_CUR_AVG,
+       REGL_BAT_CUR_AVG,
+       REGH_TS1_ADC,
+       REGL_TS1_ADC,
+       REGH_TS2_ADC,
+       REGL_TS2_ADC,
+       REGH_BAT_OCV,
+       REGL_BAT_OCV,
+       REGH_BAT_VOL,
+       REGL_BAT_VOL,
+       REGH_RELAX_ENTRY_THRES,
+       REGL_RELAX_ENTRY_THRES,
+       REGH_RELAX_EXIT_THRES,
+       REGL_RELAX_EXIT_THRES,
+       REGH_RELAX_VOL1,
+       REGL_RELAX_VOL1,
+       REGH_RELAX_VOL2,
+       REGL_RELAX_VOL2,
+       REGH_BAT_CUR_R_CALC,
+       REGL_BAT_CUR_R_CALC,
+       REGH_BAT_VOL_R_CALC,
+       REGL_BAT_VOL_R_CALC,
+       REGH_CAL_OFFSET,
+       REGL_CAL_OFFSET,
+       REG_NON_ACT_TIMER_CNT,
+       REGH_VCALIB0,
+       REGL_VCALIB0,
+       REGH_VCALIB1,
+       REGL_VCALIB1,
+       REGH_IOFFSET,
+       REGL_IOFFSET,
+       REG_SOC,
+       REG3_REMAIN_CAP,
+       REG2_REMAIN_CAP,
+       REG1_REMAIN_CAP,
+       REG0_REMAIN_CAP,
+       REG_UPDAT_LEVE,
+       REG3_NEW_FCC,
+       REG2_NEW_FCC,
+       REG1_NEW_FCC,
+       REG0_NEW_FCC,
+       REG_NON_ACT_TIMER_CNT_SAVE,
+       REG_OCV_VOL_VALID,
+       REG_REBOOT_CNT,
+       REG_POFFSET,
+       REG_MISC_MARK,
+       REG_HALT_CNT,
+       REGH_CALC_REST,
+       REGL_CALC_REST,
+       SAVE_DATA19,
+       RK808_NUM_OF_REGS,
+};
+
+enum {
+       RK805_ID = 0x8050,
+       RK808_ID = 0x0000,
+       RK818_ID = 0x8180,
+};
+
+#define RK8XX_ID_MSK   0xfff0
+
+struct rk8xx_reg_table {
+       char *name;
+       u8 reg_ctl;
+       u8 reg_vol;
+};
+
+struct rk8xx_priv {
+       int variant;
+};
+
+int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
+
+#endif