Skip to contentSkip to conversation

Add Basic support for RK818

PATCH New Jacob Chen 3 participants 13 messages May 2, 2017 – May 3, 2017

Subsystems (3)
lore
Share & tools
lore

Jacob Chen

author
#0 lore raw

v2 cover Add Basic support for RK818

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.

Changes in v2:
- remove input current selection in probe, it should be configured in board_init_f by manual.
- rename rk808 to rk8xx

Jacob Chen (5):
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
power: rk808: rename to rk8xx

 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c |   6 +-
 configs/chromebit_mickey_defconfig           |   4 +-
 configs/chromebook_jerry_defconfig           |   4 +-
 configs/chromebook_minnie_defconfig          |   4 +-
 configs/fennec-rk3288_defconfig              |   4 +-
 configs/popmetal-rk3288_defconfig            |   4 +-
 configs/sandbox_defconfig                    |   4 +-
 configs/sandbox_noblk_defconfig              |   4 +-
 configs/sandbox_spl_defconfig                |   4 +-
 configs/tinker-rk3288_defconfig              |   4 +-
 drivers/power/pmic/Kconfig                   |   6 +-
 drivers/power/pmic/Makefile                  |   2 +-
 drivers/power/pmic/{rk808.c => rk8xx.c}      |  52 +++++---
 drivers/power/regulator/Kconfig              |   8 +-
 drivers/power/regulator/Makefile             |   2 +-
 drivers/power/regulator/{rk808.c => rk8xx.c} | 142 +++++++++++++-------
 include/power/rk808_pmic.h                   |  77 -----------
 include/power/rk8xx_pmic.h                   | 193 +++++++++++++++++++++++++++
 18 files changed, 354 insertions(+), 170 deletions(-)
 rename drivers/power/pmic/{rk808.c => rk8xx.c} (59%)
 rename drivers/power/regulator/{rk808.c => rk8xx.c} (55%)
 delete mode 100644 include/power/rk808_pmic.h
 create mode 100644 include/power/rk8xx_pmic.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/5 power: pmic: append rk818 regs to rk808

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.

---

Changes in v2: None

 drivers/power/regulator/rk808.c |  18 ++---
 include/power/rk808_pmic.h      | 164 ++++++++++++++++++++++++++++++++--------
 2 files changed, 143 insertions(+), 39 deletions(-)
drivers/power/regulator/rk808.c +9 -9
index adef8f5..f1a00c5 100644
@@ -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);
include/power/rk808_pmic.h +134 -30

190 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v2 2/5 power: pmic: rk808: add RK818 support

In reply to 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.

---

Changes in v2:
- remove input current selection in probe, it should be configured in board_init_f by manual.

 drivers/power/pmic/rk808.c | 16 ++++++++++++++++
 include/power/rk808_pmic.h | 12 ++++++++++++
 2 files changed, 28 insertions(+)
drivers/power/pmic/rk808.c +16 -0
index 3f5f316..582e456 100644
@@ -80,6 +80,20 @@ 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;
+
+	return 0;
+}
+
 static struct dm_pmic_ops rk808_ops = {
 	.reg_count = rk808_reg_count,
 	.read = rk808_read,
@@ -88,6 +102,7 @@ static struct dm_pmic_ops rk808_ops = {
 
 static const struct udevice_id rk808_ids[] = {
 	{ .compatible = "rockchip,rk808" },
+	{ .compatible = "rockchip,rk818" },
 	{ }
 };
 
@@ -98,5 +113,6 @@ U_BOOT_DRIVER(pmic_rk808) = {
 #if CONFIG_IS_ENABLED(PMIC_CHILDREN)
 	.bind = rk808_bind,
 #endif
+	.probe = rk808_probe,
 	.ops = &rk808_ops,
 };
include/power/rk808_pmic.h +12 -0
index d29c2b3..c370c32 100644
@@ -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
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH v2 3/5 power: regulator: rk808: replace vsel_bits with vsel_mask

In reply to Jacob Chen

Using mask is more flexible than bits.

---

Changes in v2: None

 drivers/power/regulator/rk808.c | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)
drivers/power/regulator/rk808.c +22 -17
index f1a00c5..441806c 100644
@@ -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)
Signature · 1 line
2.7.4
author
#8 lore raw

PATCH v2 4/5 power: regulator: rk808: add rk818 support

In reply to 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.

---

Changes in v2: None

 drivers/power/regulator/rk808.c | 55 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)
drivers/power/regulator/rk808.c +51 -4
index 441806c..71ab76e 100644
@@ -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;
 
Signature · 1 line
2.7.4
author
#11 lore raw

PATCH v2 5/5 power: rk808: rename to rk8xx

In reply to Jacob Chen

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 ./

---

Changes in v2:
- rename rk808 to rk8xx

 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c |  6 +--
 configs/chromebit_mickey_defconfig           |  4 +-
 configs/chromebook_jerry_defconfig           |  4 +-
 configs/chromebook_minnie_defconfig          |  4 +-
 configs/fennec-rk3288_defconfig              |  4 +-
 configs/popmetal-rk3288_defconfig            |  4 +-
 configs/sandbox_defconfig                    |  4 +-
 configs/sandbox_noblk_defconfig              |  4 +-
 configs/sandbox_spl_defconfig                |  4 +-
 configs/tinker-rk3288_defconfig              |  4 +-
 drivers/power/pmic/Kconfig                   |  6 +--
 drivers/power/pmic/Makefile                  |  2 +-
 drivers/power/pmic/{rk808.c => rk8xx.c}      | 46 +++++++++---------
 drivers/power/regulator/Kconfig              |  8 ++--
 drivers/power/regulator/Makefile             |  2 +-
 drivers/power/regulator/{rk808.c => rk8xx.c} | 70 ++++++++++++++--------------
 include/power/{rk808_pmic.h => rk8xx_pmic.h} | 10 ++--
 17 files changed, 93 insertions(+), 93 deletions(-)
 rename drivers/power/pmic/{rk808.c => rk8xx.c} (65%)
 rename drivers/power/regulator/{rk808.c => rk8xx.c} (82%)
 rename include/power/{rk808_pmic.h => rk8xx_pmic.h} (95%)
arch/arm/mach-rockchip/rk3288/sdram_rk3288.c +3 -3
index 8549b28..2feda61 100644
@@ -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 */
configs/chromebit_mickey_defconfig +2 -2
index 7b212ff..5d14c1b 100644
@@ -54,10 +54,10 @@ CONFIG_SPL_PINCTRL=y
 CONFIG_ROCKCHIP_RK3288_PINCTRL=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
configs/chromebook_jerry_defconfig +2 -2
index 8bb73a0..72b5ae7 100644
@@ -55,9 +55,9 @@ CONFIG_SPL_PINCTRL=y
 CONFIG_ROCKCHIP_RK3288_PINCTRL=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
configs/chromebook_minnie_defconfig +2 -2
index 497d7f5..5706a1a 100644
@@ -55,9 +55,9 @@ CONFIG_SPL_PINCTRL=y
 CONFIG_ROCKCHIP_RK3288_PINCTRL=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
configs/fennec-rk3288_defconfig +2 -2
index bfc3917..51152da 100644
@@ -49,9 +49,9 @@ CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_ROCKCHIP_RK3288_PINCTRL=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
configs/popmetal-rk3288_defconfig +2 -2
index dfc84b9..f8130b2 100644
@@ -50,9 +50,9 @@ CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_ROCKCHIP_RK3288_PINCTRL=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
configs/sandbox_defconfig +2 -2
index 01f6f5d..b6fafe1 100644
@@ -122,7 +122,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
@@ -132,7 +132,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
configs/sandbox_noblk_defconfig +2 -2
index 10e12bf..bd332db 100644
@@ -126,7 +126,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
@@ -136,7 +136,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
configs/sandbox_spl_defconfig +2 -2
index 896b15d..380d03b 100644
@@ -128,7 +128,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
@@ -138,7 +138,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
configs/tinker-rk3288_defconfig +2 -2
index db87333..84e2d22 100644
@@ -49,9 +49,9 @@ CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_ROCKCHIP_RK3288_PINCTRL=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
drivers/power/pmic/Kconfig +3 -3
index 03fea07..f34291f 100644
@@ -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
@@ -92,8 +92,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,
drivers/power/pmic/Makefile +1 -1
index 40240c7..23990ff 100644
@@ -14,7 +14,7 @@ obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
 obj-$(CONFIG_PMIC_ACT8846) += act8846.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
drivers/power/pmic/rk8xx.c renamed from drivers/power/pmic/rk808.c +23 -23

100 lines not on this page · raw message

drivers/power/regulator/Kconfig +4 -4
index f870e8b..ef057e0 100644
@@ -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.
drivers/power/regulator/Makefile +1 -1
index 6002c88..3e01021 100644
@@ -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
drivers/power/regulator/rk8xx.c renamed from drivers/power/regulator/rk808.c +35 -35

196 lines not on this page · raw message

include/power/rk8xx_pmic.h renamed from include/power/rk808_pmic.h +5 -5
similarity index 95%
rename from include/power/rk808_pmic.h
rename to include/power/rk8xx_pmic.h
index c370c32..589f8c4 100644
@@ -5,8 +5,8 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#ifndef _PMIC_RK808_H_
-#define _PMIC_RK808_H_
+#ifndef _PMIC_RK8XX_H_
+#define _PMIC_RK8XX_H_
 
 enum {
 	REG_SECONDS			= 0x00,
@@ -178,16 +178,16 @@ enum {
 
 #define RK8XX_ID_MSK	0xfff0
 
-struct rk808_reg_table {
+struct rk8xx_reg_table {
 	char *name;
 	u8 reg_ctl;
 	u8 reg_vol;
 };
 
-struct rk808_priv {
+struct rk8xx_priv {
 	int variant;
 };
 
-int rk808_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
+int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
 
 #endif
Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 4/5 power: regulator: rk808: add rk818 support

In reply to Jacob Chen

2017-05-02 14:54 GMT+08:00 Jacob Chen <[email protected]>:

Quoted 113 lines

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.

---

Changes in v2: None

 drivers/power/regulator/rk808.c | 55 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)
drivers/power/regulator/rk808.c +51 -5
index 441806c..71ab76e 100644
@@ -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;
 
--
Quoted 2 lines

2.7.4

It have some toubles to support DCDC_BOOST, since it don't use num as suffix. The problem about LDO9 is that it don't have same register map with others, and i don't want to change much code...
We only need a basic support, i think it's ok to ignore them.

#4 lore raw

PATCH v2 2/5 power: pmic: rk808: add RK818 support

In reply to Jacob Chen

2017-05-02 14:54 GMT+08:00 Jacob Chen <[email protected]>:

Quoted 6 lines

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.

Quoted 7 lines

---

Changes in v2:
- remove input current selection in probe, it should be configured in board_init_f by manual.

Maybe we'd better provide a function here, like rk808_spl_configure_buck It could be rk8xx_spl_init(pmic, parm....)

Quoted 76 lines
 drivers/power/pmic/rk808.c | 16 ++++++++++++++++
 include/power/rk808_pmic.h | 12 ++++++++++++
 2 files changed, 28 insertions(+)
drivers/power/pmic/rk808.c +16 -0
index 3f5f316..582e456 100644
@@ -80,6 +80,20 @@ 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;
+
+       return 0;
+}
+
 static struct dm_pmic_ops rk808_ops = {
        .reg_count = rk808_reg_count,
        .read = rk808_read,
@@ -88,6 +102,7 @@ static struct dm_pmic_ops rk808_ops = {
 
 static const struct udevice_id rk808_ids[] = {
        { .compatible = "rockchip,rk808" },
+       { .compatible = "rockchip,rk818" },
        { }
 };
 
@@ -98,5 +113,6 @@ U_BOOT_DRIVER(pmic_rk808) = {
 #if CONFIG_IS_ENABLED(PMIC_CHILDREN)
        .bind = rk808_bind,
 #endif
+       .probe = rk808_probe,
        .ops = &rk808_ops,
 };
include/power/rk808_pmic.h +12 -1
index d29c2b3..c370c32 100644
@@ -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
--

2.7.4

#12 lore raw

PATCH v2 5/5 power: rk808: rename to rk8xx

In reply to Jacob Chen

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 ./

---

Changes in v2:
- rename rk808 to rk8xx

 arch/arm/mach-rockchip/rk3288/sdram_rk3288.c |  6 +--
 configs/chromebit_mickey_defconfig           |  4 +-
 configs/chromebook_jerry_defconfig           |  4 +-
 configs/chromebook_minnie_defconfig          |  4 +-
 configs/fennec-rk3288_defconfig              |  4 +-
 configs/popmetal-rk3288_defconfig            |  4 +-
 configs/sandbox_defconfig                    |  4 +-
 configs/sandbox_noblk_defconfig              |  4 +-
 configs/sandbox_spl_defconfig                |  4 +-
 configs/tinker-rk3288_defconfig              |  4 +-
 drivers/power/pmic/Kconfig                   |  6 +--
 drivers/power/pmic/Makefile                  |  2 +-
 drivers/power/pmic/{rk808.c => rk8xx.c}      | 46 +++++++++---------
 drivers/power/regulator/Kconfig              |  8 ++--
 drivers/power/regulator/Makefile             |  2 +-
 drivers/power/regulator/{rk808.c => rk8xx.c} | 70 ++++++++++++++--------------
 include/power/{rk808_pmic.h => rk8xx_pmic.h} | 10 ++--
 17 files changed, 93 insertions(+), 93 deletions(-)
 rename drivers/power/pmic/{rk808.c => rk8xx.c} (65%)
 rename drivers/power/regulator/{rk808.c => rk8xx.c} (82%)
 rename include/power/{rk808_pmic.h => rk8xx_pmic.h} (95%)

Applied to u-boot-rockchip/next, thanks!

#10 lore raw

PATCH v2 4/5 power: regulator: rk808: add rk818 support

In reply to Jacob Chen

2017-05-02 14:54 GMT+08:00 Jacob Chen <[email protected]>:

Quoted 6 lines

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.

Quoted 9 lines

---

Changes in v2: None

 drivers/power/regulator/rk808.c | 55 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)

Applied to u-boot-rockchip/next, thanks!

#5 lore raw

PATCH v2 2/5 power: pmic: rk808: add RK818 support

In reply to Jacob Chen

2017-05-02 14:54 GMT+08:00 Jacob Chen <[email protected]>:

Quoted 6 lines

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.

Quoted 7 lines

---

Changes in v2:
- remove input current selection in probe, it should be configured in board_init_f by manual.

Maybe we'd better provide a function here, like rk808_spl_configure_buck It could be rk8xx_spl_init(pmic, parm....)

Quoted 4 lines
 drivers/power/pmic/rk808.c | 16 ++++++++++++++++
 include/power/rk808_pmic.h | 12 ++++++++++++
 2 files changed, 28 insertions(+)

Applied to u-boot-rockchip/next, thanks!

#2 lore raw

PATCH v2 1/5 power: pmic: append rk818 regs to rk808

In reply to Jacob Chen

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.

---

Changes in v2: None

 drivers/power/regulator/rk808.c |  18 ++---
 include/power/rk808_pmic.h      | 164 ++++++++++++++++++++++++++++++++--------
 2 files changed, 143 insertions(+), 39 deletions(-)

Applied to u-boot-rockchip/next, thanks!