Re: [PATCH v4 2/5] regulator: rk808: add RK809 and RK817 support.

2018-09-03 Thread Mark Brown
On Mon, Sep 03, 2018 at 06:00:26PM +0800, Tony Xie wrote:

> Add support for the rk809 and rk817 regulator driver.
> Their specifications are as follows:
> 1. The RK809 and RK809 consist of 5 DCDCs, 9 LDOs
>and have the same registers for these components except dcdc5.
> 2. The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
> 3. The RK817 has one switch but The Rk809 has two.
> 
> The output voltages are configurable and are meant to supply power
> to the main processor and other components.

Acked-by: Mark Brown 


signature.asc
Description: PGP signature


[PATCH v4 2/5] regulator: rk808: add RK809 and RK817 support.

2018-09-03 Thread Tony Xie
Add support for the rk809 and rk817 regulator driver.
Their specifications are as follows:
1. The RK809 and RK809 consist of 5 DCDCs, 9 LDOs
   and have the same registers for these components except dcdc5.
2. The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
3. The RK817 has one switch but The Rk809 has two.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Tony Xie 
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 657 ++--
 include/linux/mfd/rk808.h   |   3 +
 3 files changed, 634 insertions(+), 30 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 5dbccf5..27ff89f 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -716,11 +716,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK805/RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK805,RK808 and RK818.
+ PMIC RK805,RK809&RK817,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index 213b687..c70fbe2 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -36,6 +36,12 @@
 #define RK808_BUCK4_VSEL_MASK  0xf
 #define RK808_LDO_VSEL_MASK0x1f
 
+#define RK809_BUCK5_VSEL_MASK  0x7
+
+#define RK817_LDO_VSEL_MASK0x7f
+#define RK817_BOOST_VSEL_MASK  0x7
+#define RK817_BUCK_VSEL_MASK   0x7f
+
 #define RK818_BUCK_VSEL_MASK   0x3f
 #define RK818_BUCK4_VSEL_MASK  0x1f
 #define RK818_LDO_VSEL_MASK0x1f
@@ -65,30 +71,36 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
-#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
-   _vmask, _ereg, _emask, _etime)  \
-   [_id] = {   \
-   .name   = (_match), \
-   .supply_name= (_supply),\
-   .of_match   = of_match_ptr(_match), \
-   .regulators_node = of_match_ptr("regulators"),  \
-   .type   = REGULATOR_VOLTAGE,\
-   .id = (_id),\
-   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
-   .owner  = THIS_MODULE,  \
-   .min_uV = (_min) * 1000,\
-   .uV_step= (_step) * 1000,   \
-   .vsel_reg   = (_vreg),  \
-   .vsel_mask  = (_vmask), \
-   .enable_reg = (_ereg),  \
-   .enable_mask= (_emask), \
-   .enable_time= (_etime), \
-   .ops= &rk805_reg_ops,   \
+#define ENABLE_MASK(id)(BIT(id) | BIT(4 + (id)))
+#define DISABLE_VAL(id)(BIT(4 + (id)))
+
+#define RK817_BOOST_DESC(_id, _match, _supply, _min, _max, _step, _vreg,\
+   _vmask, _ereg, _emask, _enval, _disval, _etime, m_drop) \
+   {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),