[U-Boot] [PATCH 0/4] Add Basic support for RK808

The RK818 chip is a power management IC for multimedia and handheld devices. It contains the following components:
- Regulators - RTC - Clkout - battery support
This series patch just give it a basic support, to make rk818 board work.
Jacob Chen (4): power: pmic: append rk818 regs to rk808 power: pmic: rk808: add RK818 support power: regulator: rk808: replace vsel_bits with vsel_mask power: regulator: rk808: add rk818 support
drivers/power/pmic/rk808.c | 29 +++++++ drivers/power/regulator/rk808.c | 96 +++++++++++++++++----- include/power/rk808_pmic.h | 176 +++++++++++++++++++++++++++++++++------- 3 files changed, 249 insertions(+), 52 deletions(-)

Both RK808 and RK818 chips are using a similar register map, so we can reuse them.
I have also add reg prefix to exist registers, to keep them same style.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com ---
drivers/power/regulator/rk808.c | 18 ++--- include/power/rk808_pmic.h | 164 ++++++++++++++++++++++++++++++++-------- 2 files changed, 143 insertions(+), 39 deletions(-)
diff --git a/drivers/power/regulator/rk808.c b/drivers/power/regulator/rk808.c index adef8f5..f1a00c5 100644 --- a/drivers/power/regulator/rk808.c +++ b/drivers/power/regulator/rk808.c @@ -35,14 +35,14 @@ static const struct rk808_reg_info rk808_buck[] = { };
static const struct rk808_reg_info rk808_ldo[] = { - { 1800000, 100000, LDO1_ON_VSEL, 5, }, - { 1800000, 100000, LDO2_ON_VSEL, 5, }, - { 800000, 100000, LDO3_ON_VSEL, 4, }, - { 1800000, 100000, LDO4_ON_VSEL, 5, }, - { 1800000, 100000, LDO5_ON_VSEL, 5, }, - { 800000, 100000, LDO6_ON_VSEL, 5, }, - { 800000, 100000, LDO7_ON_VSEL, 5, }, - { 1800000, 100000, LDO8_ON_VSEL, 5, }, + { 1800000, 100000, REG_LDO1_ON_VSEL, 5, }, + { 1800000, 100000, REG_LDO2_ON_VSEL, 5, }, + { 800000, 100000, REG_LDO3_ON_VSEL, 4, }, + { 1800000, 100000, REG_LDO4_ON_VSEL, 5, }, + { 1800000, 100000, REG_LDO5_ON_VSEL, 5, }, + { 800000, 100000, REG_LDO6_ON_VSEL, 5, }, + { 800000, 100000, REG_LDO7_ON_VSEL, 5, }, + { 1800000, 100000, REG_LDO8_ON_VSEL, 5, }, };
@@ -69,7 +69,7 @@ static int _buck_set_enable(struct udevice *pmic, int buck, bool enable) buck--; mask = 1 << buck; if (enable) { - ret = pmic_clrsetbits(pmic, DCDC_ILMAX, 0, 3 << (buck * 2)); + 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); diff --git a/include/power/rk808_pmic.h b/include/power/rk808_pmic.h index fb0800b..d29c2b3 100644 --- a/include/power/rk808_pmic.h +++ b/include/power/rk808_pmic.h @@ -9,12 +9,37 @@ #define _PMIC_RK808_H_
enum { - REG_DCDC_EN = 0x23, + 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, @@ -23,7 +48,6 @@ enum { REG_VOUT_MON_TDB, REG_BUCK1_CONFIG, REG_BUCK1_ON_VSEL, - REG_BUCK1_SLP_VSEL, REG_BUCK1_DVS_VSEL, REG_BUCK2_CONFIG, @@ -32,37 +56,117 @@ enum { REG_BUCK2_DVS_VSEL, REG_BUCK3_CONFIG, REG_BUCK4_CONFIG, - REG_BUCK4_ON_VSEL, REG_BUCK4_SLP_VSEL, - LDO1_ON_VSEL = 0x3b, - LDO1_SLP_VSEL, - LDO2_ON_VSEL, - LDO2_SLP_VSEL, - LDO3_ON_VSEL, - - LDO3_SLP_VSEL, - LDO4_ON_VSEL, - LDO4_SLP_VSEL, - LDO5_ON_VSEL, - LDO5_SLP_VSEL, - LDO6_ON_VSEL, - LDO6_SLP_VSEL, - LDO7_ON_VSEL, - - LDO7_SLP_VSEL, - LDO8_ON_VSEL, - LDO8_SLP_VSEL, - DEVCTRL, - INT_STS1, - INT_STS_MSK1, - INT_STS2, - INT_STS_MSK2, - IO_POL, + 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 */ - DCDC_ILMAX = 0x90, - + 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, };

On 20 April 2017 at 21:34, Jacob Chen jacob-chen@iotwrt.com wrote:
Both RK808 and RK818 chips are using a similar register map, so we can reuse them.
I have also add reg prefix to exist registers, to keep them same style.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com
drivers/power/regulator/rk808.c | 18 ++--- include/power/rk808_pmic.h | 164 ++++++++++++++++++++++++++++++++-------- 2 files changed, 143 insertions(+), 39 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

The RK818 chip is a Power Management IC (PMIC) for multimedia and handheld devices.
For boards use rk818, the input current should be set in the early stage, before ddr initialization.
To use rk818,below configs should be enabled: CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_POWER_SUPPORT=y and rk818 device should probe in spl board_init_f.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com ---
drivers/power/pmic/rk808.c | 29 +++++++++++++++++++++++++++++ include/power/rk808_pmic.h | 12 ++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/drivers/power/pmic/rk808.c b/drivers/power/pmic/rk808.c index 3f5f316..2d764d9 100644 --- a/drivers/power/pmic/rk808.c +++ b/drivers/power/pmic/rk808.c @@ -80,6 +80,33 @@ static int rk808_bind(struct udevice *dev) } #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; + +#ifdef CONFIG_SPL_BUILD + if (priv->variant == RK818_ID) { + uint8_t txdata; + /* + * Increase USB input current selection to 2A and close charger + * when usb lower then 3.4V. + */ + txdata = 0x77; + rk808_write(dev, REG_USB_CTRL, &txdata, 1); + udelay(3); + } +#endif + + return 0; +} + static struct dm_pmic_ops rk808_ops = { .reg_count = rk808_reg_count, .read = rk808_read, @@ -88,6 +115,7 @@ static struct dm_pmic_ops rk808_ops = {
static const struct udevice_id rk808_ids[] = { { .compatible = "rockchip,rk808" }, + { .compatible = "rockchip,rk818" }, { } };
@@ -98,5 +126,6 @@ U_BOOT_DRIVER(pmic_rk808) = { #if CONFIG_IS_ENABLED(PMIC_CHILDREN) .bind = rk808_bind, #endif + .probe = rk808_probe, .ops = &rk808_ops, }; diff --git a/include/power/rk808_pmic.h b/include/power/rk808_pmic.h index d29c2b3..c370c32 100644 --- a/include/power/rk808_pmic.h +++ b/include/power/rk808_pmic.h @@ -170,12 +170,24 @@ enum { 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

Hi Jacob,
Am 21.04.2017 um 05:34 schrieb Jacob Chen:
The RK818 chip is a Power Management IC (PMIC) for multimedia and handheld devices.
For boards use rk818, the input current should be set in the early stage, before ddr initialization.
To use rk818,below configs should be enabled: CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_POWER_SUPPORT=y and rk818 device should probe in spl board_init_f.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com
drivers/power/pmic/rk808.c | 29 +++++++++++++++++++++++++++++ include/power/rk808_pmic.h | 12 ++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/drivers/power/pmic/rk808.c b/drivers/power/pmic/rk808.c index 3f5f316..2d764d9 100644 --- a/drivers/power/pmic/rk808.c +++ b/drivers/power/pmic/rk808.c @@ -80,6 +80,33 @@ static int rk808_bind(struct udevice *dev) } #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;
+#ifdef CONFIG_SPL_BUILD
- if (priv->variant == RK818_ID) {
uint8_t txdata;
/*
* Increase USB input current selection to 2A and close charger
* when usb lower then 3.4V.
*/
txdata = 0x77;
rk808_write(dev, REG_USB_CTRL, &txdata, 1);
udelay(3);
- }
I don't think this is the right place for this board specific setup. Not every RK818 based device has such a high power consumption and has to increase it's USB input current selection. You should move the USB_CTRL register write to board_init_f() and check for the board with #ifdef TARGET_XXX
Regards, Wadim
+#endif
- return 0;
+}
static struct dm_pmic_ops rk808_ops = { .reg_count = rk808_reg_count, .read = rk808_read, @@ -88,6 +115,7 @@ static struct dm_pmic_ops rk808_ops = {
static const struct udevice_id rk808_ids[] = { { .compatible = "rockchip,rk808" },
- { .compatible = "rockchip,rk818" }, { }
};
@@ -98,5 +126,6 @@ U_BOOT_DRIVER(pmic_rk808) = { #if CONFIG_IS_ENABLED(PMIC_CHILDREN) .bind = rk808_bind, #endif
- .probe = rk808_probe, .ops = &rk808_ops,
}; diff --git a/include/power/rk808_pmic.h b/include/power/rk808_pmic.h index d29c2b3..c370c32 100644 --- a/include/power/rk808_pmic.h +++ b/include/power/rk808_pmic.h @@ -170,12 +170,24 @@ enum { 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

Using mask is more flexible than bits.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com ---
drivers/power/regulator/rk808.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/drivers/power/regulator/rk808.c b/drivers/power/regulator/rk808.c index f1a00c5..441806c 100644 --- a/drivers/power/regulator/rk808.c +++ b/drivers/power/regulator/rk808.c @@ -20,36 +20,41 @@ #define ENABLE_DRIVER #endif
+/* Field Definitions */ +#define RK808_BUCK_VSEL_MASK 0x3f +#define RK808_BUCK4_VSEL_MASK 0xf +#define RK808_LDO_VSEL_MASK 0x1f + struct rk808_reg_info { uint min_uv; uint step_uv; s8 vsel_reg; - u8 vsel_bits; + u8 vsel_mask; };
static const struct rk808_reg_info rk808_buck[] = { - { 712500, 12500, REG_BUCK1_ON_VSEL, 6, }, - { 712500, 12500, REG_BUCK2_ON_VSEL, 6, }, - { 712500, 12500, -1, 6, }, - { 1800000, 100000, REG_BUCK4_ON_VSEL, 4, }, + { 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, 5, }, - { 1800000, 100000, REG_LDO2_ON_VSEL, 5, }, - { 800000, 100000, REG_LDO3_ON_VSEL, 4, }, - { 1800000, 100000, REG_LDO4_ON_VSEL, 5, }, - { 1800000, 100000, REG_LDO5_ON_VSEL, 5, }, - { 800000, 100000, REG_LDO6_ON_VSEL, 5, }, - { 800000, 100000, REG_LDO7_ON_VSEL, 5, }, - { 1800000, 100000, REG_LDO8_ON_VSEL, 5, }, + { 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 int _buck_set_value(struct udevice *pmic, int buck, int uvolt) { const struct rk808_reg_info *info = &rk808_buck[buck - 1]; - int mask = (1 << info->vsel_bits) - 1; + int mask = info->vsel_mask; int val;
if (info->vsel_reg == -1) @@ -85,7 +90,7 @@ static int buck_get_value(struct udevice *dev) { int buck = dev->driver_data - 1; const struct rk808_reg_info *info = &rk808_buck[buck]; - int mask = (1 << info->vsel_bits) - 1; + int mask = info->vsel_mask; int ret, val;
if (info->vsel_reg == -1) @@ -131,7 +136,7 @@ static int ldo_get_value(struct udevice *dev) { int ldo = dev->driver_data - 1; const struct rk808_reg_info *info = &rk808_ldo[ldo]; - int mask = (1 << info->vsel_bits) - 1; + int mask = info->vsel_mask; int ret, val;
if (info->vsel_reg == -1) @@ -148,7 +153,7 @@ static int ldo_set_value(struct udevice *dev, int uvolt) { int ldo = dev->driver_data - 1; const struct rk808_reg_info *info = &rk808_ldo[ldo]; - int mask = (1 << info->vsel_bits) - 1; + int mask = info->vsel_mask; int val;
if (info->vsel_reg == -1)

On 20 April 2017 at 21:34, Jacob Chen jacob-chen@iotwrt.com wrote:
Using mask is more flexible than bits.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com
drivers/power/regulator/rk808.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Can you also in a separate patch rename the driver to rk8xx.c or similar, so it is clear that it supports two chips?
- Simon

Add support for the rk818 regulator. The regulator module consists of 4 DCDCs, 9 LDOs, 1 switch and 1 BOOST converter which is used to power OTG and HDMI5V.
TODO: I don't know how to deal with BOOST and LDO9, so just ignore them now.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com ---
drivers/power/regulator/rk808.c | 55 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)
diff --git a/drivers/power/regulator/rk808.c b/drivers/power/regulator/rk808.c index 441806c..71ab76e 100644 --- a/drivers/power/regulator/rk808.c +++ b/drivers/power/regulator/rk808.c @@ -25,6 +25,12 @@ #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; @@ -50,10 +56,51 @@ static const struct rk808_reg_info rk808_ldo[] = { { 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 = &rk808_buck[buck - 1]; + const struct rk808_reg_info *info = get_buck_reg(pmic, buck - 1); int mask = info->vsel_mask; int val;
@@ -89,7 +136,7 @@ static int _buck_set_enable(struct udevice *pmic, int buck, bool enable) static int buck_get_value(struct udevice *dev) { int buck = dev->driver_data - 1; - const struct rk808_reg_info *info = &rk808_buck[buck]; + const struct rk808_reg_info *info = get_buck_reg(dev->parent, buck); int mask = info->vsel_mask; int ret, val;
@@ -135,7 +182,7 @@ static bool buck_get_enable(struct udevice *dev) static int ldo_get_value(struct udevice *dev) { int ldo = dev->driver_data - 1; - const struct rk808_reg_info *info = &rk808_ldo[ldo]; + const struct rk808_reg_info *info = get_ldo_reg(dev->parent, ldo); int mask = info->vsel_mask; int ret, val;
@@ -152,7 +199,7 @@ static int ldo_get_value(struct udevice *dev) static int ldo_set_value(struct udevice *dev, int uvolt) { int ldo = dev->driver_data - 1; - const struct rk808_reg_info *info = &rk808_ldo[ldo]; + const struct rk808_reg_info *info = get_ldo_reg(dev->parent, ldo); int mask = info->vsel_mask; int val;

Hi Jacob,
Am 21.04.2017 um 05:34 schrieb Jacob Chen:
Add support for the rk818 regulator. The regulator module consists of 4 DCDCs, 9 LDOs, 1 switch and 1 BOOST converter which is used to power OTG and HDMI5V.
TODO: I don't know how to deal with BOOST and LDO9, so just ignore them now.
you can handle the boost converter the same way you handle the buck converters. And there is nothing special about LDO9.
Regards, Wadim

On 20 April 2017 at 21:34, Jacob Chen jacob-chen@iotwrt.com wrote:
Add support for the rk818 regulator. The regulator module consists of 4 DCDCs, 9 LDOs, 1 switch and 1 BOOST converter which is used to power OTG and HDMI5V.
TODO: I don't know how to deal with BOOST and LDO9, so just ignore them now.
Signed-off-by: Jacob Chen jacob-chen@iotwrt.com
drivers/power/regulator/rk808.c | 55 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

ok - -wrong title.. It's Add Basic support for RK818
2017-04-21 11:34 GMT+08:00 Jacob Chen jacob-chen@iotwrt.com:
The RK818 chip is a power management IC for multimedia and handheld devices. It contains the following components:
- Regulators
- RTC
- Clkout
- battery support
This series patch just give it a basic support, to make rk818 board work.
Jacob Chen (4): power: pmic: append rk818 regs to rk808 power: pmic: rk808: add RK818 support power: regulator: rk808: replace vsel_bits with vsel_mask power: regulator: rk808: add rk818 support
drivers/power/pmic/rk808.c | 29 +++++++ drivers/power/regulator/rk808.c | 96 +++++++++++++++++----- include/power/rk808_pmic.h | 176 +++++++++++++++++++++++++++++++++------- 3 files changed, 249 insertions(+), 52 deletions(-)
-- 2.7.4
participants (4)
-
Jacob Chen
-
Jacob Chen
-
Simon Glass
-
Wadim Egorov