mfd: rk808: add reboot support to rk808.c
Subsystems (2)
PATCH v5 1/1 mfd: rk808: add reboot support to rk808.c
This adds reboot support to the rk808 pmic driver and enables it for the rk809 and rk817 devices.
This only enables if the rockchip,system-power-controller flag is set.
---
Changelog:
V5:
- Fix length of error print.
V4:
- reorder rk808_restart_notify (Thanks Dmitry)
- drop of_property_read_bool before unregister (Good catch Frank)
V3: Thanks Dmitry!
- Adjust priority to be in line with other pmic drivers
- Move ret handling to case switch
- Make default registration debug
- Add unregister function on removal
V2:
- Squash the patch from Frank Wunderlich for rk809 support.
- Remove support for the rk805, rk808, and rk818 devices.
- Only register the reset handler for supported devices.
- Remove unnecessary dev_err and dev_warn statements.
- Register the reset handler directly
drivers/mfd/rk808.c | 44 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rk808.h | 1 + 2 files changed, 45 insertions(+)
drivers/mfd/rk808.c +44 -0
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/of_device.h> #include <linux/regmap.h> +#include <linux/reboot.h> struct rk808_reg_data {int addr;
@@ -543,6 +544,7 @@ static void rk808_pm_power_off(void) reg =RK808_DEVCTRL_REG , bit =DEV_OFF_RST ;break ; +case RK809_ID :case RK817_ID : reg =RK817_SYS_CFG (3 ); bit =DEV_OFF ;
@@ -559,6 +561,34 @@ static void rk808_pm_power_off(void)dev_err (&rk808_i2c_client->dev,"Failed to shutdown device!\n" ); } +static int rk808_restart_notify (struct notifier_block *this,unsigned long mode,void *cmd) +{ +struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); +unsigned int reg, bit; +int ret; + +switch (rk808->variant) { +case RK809_ID : +case RK817_ID : + reg =RK817_SYS_CFG (3 ); + bit =DEV_RST ; +break ; + +default : +return NOTIFY_DONE ; + } + ret =regmap_update_bits (rk808->regmap, reg, bit, bit); +if (ret) +dev_err (&rk808_i2c_client->dev,"Failed to restart device!\n" ); + +return NOTIFY_DONE ; +} + +static struct notifier_block rk808_restart_handler = { + .notifier_call = rk808_restart_notify, + .priority =192 , +}; +static void rk8xx_shutdown (struct i2c_client *client) {struct rk808 *rk808 =i2c_get_clientdata (client);
@@ -727,6 +757,18 @@ static int rk808_probe(struct i2c_client *client,if (of_property_read_bool (np,"rockchip,system-power-controller" )) { rk808_i2c_client = client; pm_power_off = rk808_pm_power_off; + +switch (rk808->variant) { +case RK809_ID : +case RK817_ID : + ret =register_restart_handler (&rk808_restart_handler); +if (ret) +dev_warn (&client->dev,"failed to register rst handler, %d\n" , ret); +break ; +default : +dev_dbg (&client->dev,"pmic controlled board reset not supported\n" ); +break ; + } }return 0 ;
@@ -749,6 +791,8 @@ static int rk808_remove(struct i2c_client *client)if (pm_power_off == rk808_pm_power_off) pm_power_off =NULL ; +unregister_restart_handler (&rk808_restart_handler); +return 0 ; }
include/linux/mfd/rk808.h +1 -0
@@ -373,6 +373,7 @@ enum rk805_reg {#define SWITCH2_EN BIT(6)#define SWITCH1_EN BIT(5)#define DEV_OFF_RST BIT(3) +#define DEV_RST BIT(2)#define DEV_OFF BIT(0)#define RTC_STOP BIT(0)
Signature · 1 line
2.25.1
Lee Jones
AppliedQuoted 29 lines · Peter Geis
This adds reboot support to the rk808 pmic driver and enables it for the rk809 and rk817 devices.
This only enables if the rockchip,system-power-controller flag is set.Signed-off-by Peter Geis <[email protected]>Signed-off-by Frank Wunderlich <[email protected]>Reviewed-by Dmitry Osipenko <[email protected]>Acked-for-mfd-by Lee Jones <[email protected]>---
Changelog:
V5:
- Fix length of error print.V4:
- reorderrk808_restart_notify(Thanks Dmitry)
- dropof_property_read_boolbefore unregister (Good catch Frank)V3: Thanks Dmitry!
- Adjust priority to be in line with other pmic drivers
- Move ret handling to case switch
- Make default registration debug
- Add unregister function on removalV2:
- Squash the patch from Frank Wunderlich for rk809 support.
- Remove support for the rk805, rk808, and rk818 devices.
- Only register the reset handler for supported devices.
- Remove unnecessarydev_erranddev_warnstatements.
- Register the reset handler directly
Quoted 3 lines
drivers/mfd/rk808.c | 44 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/rk808.h | 1 + 2 files changed, 45 insertions(+)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog