mfd: rk808: add on/off source dump

Show the reason of this power on and last shutdown.

Change-Id: Id540433065859a0c3f4817ed66e295b7c6dfccb5
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen
2019-11-01 17:54:38 +08:00
committed by Tao Huang
parent 481aa22003
commit 1035f13de8

View File

@@ -1152,10 +1152,12 @@ static int rk808_probe(struct i2c_client *client,
const struct rk808_reg_data *pre_init_reg;
const struct regmap_irq_chip *battery_irq_chip = NULL;
const struct mfd_cell *cells;
unsigned char pmic_id_msb, pmic_id_lsb;
u8 on_source = 0, off_source = 0;
unsigned int on, off;
int pm_off = 0, msb, lsb;
int nr_pre_init_regs;
int nr_cells;
int pm_off = 0, msb, lsb;
unsigned char pmic_id_msb, pmic_id_lsb;
int ret;
int i;
void (*of_property_prepare_fn)(struct rk808 *rk808,
@@ -1201,6 +1203,8 @@ static int rk808_probe(struct i2c_client *client,
nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
cells = rk805s;
nr_cells = ARRAY_SIZE(rk805s);
on_source = RK805_ON_SOURCE_REG;
off_source = RK805_OFF_SOURCE_REG;
suspend_reg = rk805_suspend_reg;
suspend_reg_num = ARRAY_SIZE(rk805_suspend_reg);
resume_reg = rk805_resume_reg;
@@ -1225,6 +1229,8 @@ static int rk808_probe(struct i2c_client *client,
nr_pre_init_regs = ARRAY_SIZE(rk816_pre_init_reg);
cells = rk816s;
nr_cells = ARRAY_SIZE(rk816s);
on_source = RK816_ON_SOURCE_REG;
off_source = RK816_OFF_SOURCE_REG;
suspend_reg = rk816_suspend_reg;
suspend_reg_num = ARRAY_SIZE(rk816_suspend_reg);
resume_reg = rk816_resume_reg;
@@ -1238,6 +1244,8 @@ static int rk808_probe(struct i2c_client *client,
nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
cells = rk818s;
nr_cells = ARRAY_SIZE(rk818s);
on_source = RK818_ON_SOURCE_REG;
off_source = RK818_OFF_SOURCE_REG;
suspend_reg = rk818_suspend_reg;
suspend_reg_num = ARRAY_SIZE(rk818_suspend_reg);
resume_reg = rk818_resume_reg;
@@ -1252,6 +1260,8 @@ static int rk808_probe(struct i2c_client *client,
nr_pre_init_regs = ARRAY_SIZE(rk817_pre_init_reg);
cells = rk817s;
nr_cells = ARRAY_SIZE(rk817s);
on_source = RK817_ON_SOURCE_REG;
off_source = RK817_OFF_SOURCE_REG;
register_syscore_ops(&rk808_syscore_ops);
suspend_reg = rk817_suspend_reg;
suspend_reg_num = ARRAY_SIZE(rk817_suspend_reg);
@@ -1277,6 +1287,23 @@ static int rk808_probe(struct i2c_client *client,
return PTR_ERR(rk808->regmap);
}
if (on_source && off_source) {
ret = regmap_read(rk808->regmap, on_source, &on);
if (ret) {
dev_err(&client->dev, "read 0x%x failed\n", on_source);
return ret;
}
ret = regmap_read(rk808->regmap, off_source, &off);
if (ret) {
dev_err(&client->dev, "read 0x%x failed\n", off_source);
return ret;
}
dev_info(&client->dev, "source: on=0x%02x, off=0x%02x\n",
on, off);
}
if (!client->irq) {
dev_err(&client->dev, "No interrupt support, no core IRQ\n");
return -EINVAL;