Skip to content

Commit 6e3ddca

Browse files
TonyXie06rkhuangtao
authored andcommitted
mfd: rk808: Set only resetting pmic register for 817&809.
If the system needs hold register values when system will reboot. need to set only resetting pmic register for 817&809 forcedly. Change-Id: Ib4b850c86ec3079cd7e374bc96460ee1532854a2 Signed-off-by: Tony Xie <tony.xie@rock-chips.com>
1 parent cea2a68 commit 6e3ddca

1 file changed

Lines changed: 47 additions & 4 deletions

File tree

drivers/mfd/rk808.c

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MFD core driver for Rockchip RK808
33
*
4-
* Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
4+
* Copyright (c) 2014-2018, Fuzhou Rockchip Electronics Co., Ltd
55
*
66
* Author: Chris Zhong <zyw@rock-chips.com>
77
* Author: Zhang Qing <zhangqing@rock-chips.com>
@@ -24,6 +24,7 @@
2424
#include <linux/mfd/core.h>
2525
#include <linux/module.h>
2626
#include <linux/of_device.h>
27+
#include <linux/reboot.h>
2728
#include <linux/regmap.h>
2829
#include <linux/syscore_ops.h>
2930

@@ -1029,11 +1030,44 @@ static int rk817_pinctrl_init(struct device *dev, struct rk808 *rk808)
10291030
return 0;
10301031
}
10311032

1032-
static void rk817_of_property_prepare(struct regmap *regmap, struct device *dev)
1033+
struct rk817_reboot_data_t {
1034+
struct rk808 *rk808;
1035+
struct notifier_block reboot_notifier;
1036+
};
1037+
1038+
static struct rk817_reboot_data_t rk817_reboot_data;
1039+
1040+
static int rk817_reboot_notifier_handler(struct notifier_block *nb,
1041+
unsigned long action, void *cmd)
1042+
{
1043+
struct rk817_reboot_data_t *data;
1044+
int ret;
1045+
struct device *dev;
1046+
1047+
if (action != SYS_RESTART)
1048+
return NOTIFY_OK;
1049+
1050+
if (!cmd || !strlen(cmd) || !strcmp(cmd, "normal"))
1051+
return NOTIFY_OK;
1052+
1053+
data = container_of(nb, struct rk817_reboot_data_t, reboot_notifier);
1054+
dev = &data->rk808->i2c->dev;
1055+
1056+
ret = regmap_update_bits(data->rk808->regmap, RK817_SYS_CFG(3),
1057+
RK817_RST_FUNC_MSK, RK817_RST_FUNC_REG);
1058+
if (ret)
1059+
dev_err(dev, "reboot: force RK817_RST_FUNC_REG error!\n");
1060+
else
1061+
dev_info(dev, "reboot: force RK817_RST_FUNC_REG ok!\n");
1062+
return NOTIFY_OK;
1063+
}
1064+
1065+
static void rk817_of_property_prepare(struct rk808 *rk808, struct device *dev)
10331066
{
10341067
u32 inner;
10351068
int ret, func, msk, val;
10361069
struct device_node *np = dev->of_node;
1070+
struct regmap *regmap = rk808->regmap;
10371071

10381072
ret = of_property_read_u32_index(np, "fb-inner-reg-idxs", 0, &inner);
10391073
if (!ret && inner == RK817_ID_DCDC3)
@@ -1061,6 +1095,15 @@ static void rk817_of_property_prepare(struct regmap *regmap, struct device *dev)
10611095
regmap_update_bits(regmap, RK817_SYS_CFG(3), msk, val);
10621096

10631097
dev_info(dev, "support pmic reset mode:%d,%d\n", ret, func);
1098+
1099+
if (val & RK817_RST_FUNC_REG)
1100+
return;
1101+
rk817_reboot_data.rk808 = rk808;
1102+
rk817_reboot_data.reboot_notifier.notifier_call =
1103+
rk817_reboot_notifier_handler;
1104+
ret = register_reboot_notifier(&rk817_reboot_data.reboot_notifier);
1105+
if (ret)
1106+
dev_err(dev, "failed to register reboot nb\n");
10641107
}
10651108

10661109
static struct kobject *rk8xx_kobj;
@@ -1095,7 +1138,7 @@ static int rk808_probe(struct i2c_client *client,
10951138
int ret, i, pm_off = 0;
10961139
unsigned int on, off;
10971140
u8 pmic_id_msb = RK808_ID_MSB, pmic_id_lsb = RK808_ID_LSB;
1098-
void (*of_property_prepare_fn)(struct regmap *regmap,
1141+
void (*of_property_prepare_fn)(struct rk808 *rk808,
10991142
struct device *dev) = NULL;
11001143
int (*pinctrl_init)(struct device *dev, struct rk808 *rk808) = NULL;
11011144

@@ -1246,7 +1289,7 @@ static int rk808_probe(struct i2c_client *client,
12461289
}
12471290

12481291
if (of_property_prepare_fn)
1249-
of_property_prepare_fn(rk808->regmap, &client->dev);
1292+
of_property_prepare_fn(rk808, &client->dev);
12501293

12511294
i2c_set_clientdata(client, rk808);
12521295
rk808->i2c = client;

0 commit comments

Comments
 (0)