Skip to content

Commit

Permalink
power: pmic: rk805: support rk805 pmic
Browse files Browse the repository at this point in the history
The RK805 are a Power Management IC (PMIC) for multimedia
and handheld devices. They contains the following components:
    - Regulators(4*BUCKs, 3*LDOs)
    - RTC
    - Clocking

Signed-off-by: Elaine Zhang <[email protected]>
Reviewed-by: Kever Yang <[email protected]>
  • Loading branch information
Elaine Zhang authored and keveryang committed Nov 10, 2019
1 parent addd062 commit b622807
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/power/pmic/rk8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static struct dm_pmic_ops rk8xx_ops = {
};

static const struct udevice_id rk8xx_ids[] = {
{ .compatible = "rockchip,rk805" },
{ .compatible = "rockchip,rk808" },
{ .compatible = "rockchip,rk816" },
{ .compatible = "rockchip,rk818" },
Expand Down
17 changes: 17 additions & 0 deletions drivers/power/regulator/rk8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@
/*
* Ramp delay
*/
#define RK805_RAMP_RATE_OFFSET 3
#define RK805_RAMP_RATE_MASK (3 << RK805_RAMP_RATE_OFFSET)
#define RK805_RAMP_RATE_3MV_PER_US (0 << RK805_RAMP_RATE_OFFSET)
#define RK805_RAMP_RATE_6MV_PER_US (1 << RK805_RAMP_RATE_OFFSET)
#define RK805_RAMP_RATE_12_5MV_PER_US (2 << RK805_RAMP_RATE_OFFSET)
#define RK805_RAMP_RATE_25MV_PER_US (3 << RK805_RAMP_RATE_OFFSET)
#define RK808_RAMP_RATE_OFFSET 3

#define RK808_RAMP_RATE_MASK (3 << RK808_RAMP_RATE_OFFSET)
#define RK808_RAMP_RATE_2MV_PER_US (0 << RK808_RAMP_RATE_OFFSET)
#define RK808_RAMP_RATE_4MV_PER_US (1 << RK808_RAMP_RATE_OFFSET)
Expand Down Expand Up @@ -131,6 +138,7 @@ static const struct rk8xx_reg_info *get_buck_reg(struct udevice *pmic,
struct rk8xx_priv *priv = dev_get_priv(pmic);

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
switch (num) {
case 0:
Expand Down Expand Up @@ -185,6 +193,7 @@ static int _buck_set_enable(struct udevice *pmic, int buck, bool enable)
struct rk8xx_priv *priv = dev_get_priv(pmic);

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
if (buck >= 4) {
buck -= 4;
Expand Down Expand Up @@ -246,6 +255,7 @@ static int _buck_get_enable(struct udevice *pmic, int buck)
int ret = 0;

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
if (buck >= 4) {
mask = 1 << (buck - 4);
Expand Down Expand Up @@ -277,6 +287,7 @@ static int _buck_set_suspend_enable(struct udevice *pmic, int buck, bool enable)
struct rk8xx_priv *priv = dev_get_priv(pmic);

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
mask = 1 << buck;
ret = pmic_clrsetbits(pmic, RK816_REG_DCDC_SLP_EN, mask,
Expand All @@ -302,6 +313,7 @@ static int _buck_get_suspend_enable(struct udevice *pmic, int buck)
uint mask;

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
mask = 1 << buck;
val = pmic_reg_read(pmic, RK816_REG_DCDC_SLP_EN);
Expand Down Expand Up @@ -330,6 +342,7 @@ static const struct rk8xx_reg_info *get_ldo_reg(struct udevice *pmic,
struct rk8xx_priv *priv = dev_get_priv(pmic);

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
return &rk816_ldo[num];
case RK818_ID:
Expand All @@ -346,6 +359,7 @@ static int _ldo_get_enable(struct udevice *pmic, int ldo)
int ret = 0;

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
if (ldo >= 4) {
mask = 1 << (ldo - 4);
Expand Down Expand Up @@ -377,6 +391,7 @@ static int _ldo_set_enable(struct udevice *pmic, int ldo, bool enable)
int ret = 0;

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
if (ldo >= 4) {
ldo -= 4;
Expand Down Expand Up @@ -409,6 +424,7 @@ static int _ldo_set_suspend_enable(struct udevice *pmic, int ldo, bool enable)
int ret = 0;

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
mask = 1 << ldo;
ret = pmic_clrsetbits(pmic, RK816_REG_LDO_SLP_EN, mask,
Expand All @@ -432,6 +448,7 @@ static int _ldo_get_suspend_enable(struct udevice *pmic, int ldo)
uint mask;

switch (priv->variant) {
case RK805_ID:
case RK816_ID:
mask = 1 << ldo;
val = pmic_reg_read(pmic, RK816_REG_LDO_SLP_EN);
Expand Down
1 change: 1 addition & 0 deletions include/power/rk8xx_pmic.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ enum {
};

enum {
RK805_ID = 0x8050,
RK808_ID = 0x0000,
RK816_ID = 0x8160,
RK818_ID = 0x8180,
Expand Down

0 comments on commit b622807

Please sign in to comment.