mfd: rk808: restore the OTP value to POWER_EN register of rk817/rk809

rk817/rk809 must restore the PMIC_POWER_EN OTP value before the system reboot.

Change-Id: I2ccfbb4d47eb41cdcea048111873b6ab85477d64
Signed-off-by: Shengfei Xu <xsf@rock-chips.com>
This commit is contained in:
Shengfei Xu
2019-01-30 11:09:16 +08:00
committed by Tao Huang
parent e57a003936
commit eefa54c0db
2 changed files with 20 additions and 4 deletions

View File

@@ -1048,6 +1048,23 @@ static int rk817_reboot_notifier_handler(struct notifier_block *nb,
struct rk817_reboot_data_t *data;
int ret;
struct device *dev;
int value, power_en_active0, power_en_active1;
data = container_of(nb, struct rk817_reboot_data_t, reboot_notifier);
dev = &data->rk808->i2c->dev;
regmap_read(data->rk808->regmap, RK817_POWER_EN_SAVE0,
&power_en_active0);
regmap_read(data->rk808->regmap, RK817_POWER_EN_SAVE1,
&power_en_active1);
value = power_en_active0 & 0x0f;
regmap_write(data->rk808->regmap, RK817_POWER_EN_REG(0), value | 0xf0);
value = (power_en_active0 & 0xf0) >> 4;
regmap_write(data->rk808->regmap, RK817_POWER_EN_REG(1), value | 0xf0);
value = power_en_active1 & 0x0f;
regmap_write(data->rk808->regmap, RK817_POWER_EN_REG(2), value | 0xf0);
value = (power_en_active1 & 0xf0) >> 4;
regmap_write(data->rk808->regmap, RK817_POWER_EN_REG(3), value | 0xf0);
if (action != SYS_RESTART)
return NOTIFY_OK;
@@ -1055,8 +1072,6 @@ static int rk817_reboot_notifier_handler(struct notifier_block *nb,
if (!cmd || !strlen(cmd) || !strcmp(cmd, "normal"))
return NOTIFY_OK;
data = container_of(nb, struct rk817_reboot_data_t, reboot_notifier);
dev = &data->rk808->i2c->dev;
ret = regmap_update_bits(data->rk808->regmap, RK817_SYS_CFG(3),
RK817_RST_FUNC_MSK, RK817_RST_FUNC_REG);
@@ -1101,8 +1116,6 @@ static void rk817_of_property_prepare(struct rk808 *rk808, struct device *dev)
dev_info(dev, "support pmic reset mode:%d,%d\n", ret, func);
if (val & RK817_RST_FUNC_REG)
return;
rk817_reboot_data.rk808 = rk808;
rk817_reboot_data.reboot_notifier.notifier_call =
rk817_reboot_notifier_handler;

View File

@@ -825,6 +825,9 @@ enum rk809_reg_id {
#define RK817_RTC_COMP_LSB_REG 0x10
#define RK817_RTC_COMP_MSB_REG 0x11
#define RK817_POWER_EN_SAVE0 0x99
#define RK817_POWER_EN_SAVE1 0xa4
#define RK817_POWER_EN_REG(i) (0xb1 + (i))
#define RK817_POWER_SLP_EN_REG(i) (0xb5 + (i))