RK3399 clean shutdown issue
Subsystems (3)
cover RK3399 clean shutdown issue
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdf
Reboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.
If you have any input please share them.
Tested on SBC
Rock960 Model A
Odroid N1
Rock64
-Anand Moon
Anand Moon (8):
mfd: rk808: Refactor shutdown functions
mfd: rk808: use syscore for RK805 PMIC shutdown
mfd: rk808: use syscore for RK808 PMIC shutdown
mfd: rk808: use syscore for RK818 PMIC shutdown
mfd: rk808: cleanup unused function pointer
mfd: rk808: use common syscore for all PMCI for clean shutdown
arm64: rockchip: drop unused field from rk8xx i2c node
arm: rockchip: drop unused field from rk8xx i2c node
arch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - .../boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - .../boot/dts/rockchip/rk3368-px5-evb.dts | 1 - .../boot/dts/rockchip/rk3399-firefly.dts | 1 - .../boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - .../boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - .../boot/dts/rockchip/rk3399-leez-p710.dts | 1 - .../boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - .../boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 - .../boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - .../boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - .../boot/dts/rockchip/rk3399-rock960.dtsi | 1 - .../boot/dts/rockchip/rk3399-rockpro64.dts | 1 - .../boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - drivers/mfd/rk808.c | 144 +++++------------- include/linux/mfd/rk808.h | 2 - 32 files changed, 42 insertions(+), 134 deletions(-)
Signature · 1 line
2.24.0
RFC 1/8 mfd: rk808: Refactor shutdown functions
From: Daniel Schultz <[email protected]>
Since all shutdown functions have almost the same code, all logic from the shutdown functions can be refactored to a new function "rk808_update_bits", which can update a register by a given address and bitmask and value.
---
[rebased on latest kernel]
Modified the API to set the value.
This changes were submited with below patch.
[0] https://lore.kernel.org/patchwork/patch/937404/
--- drivers/mfd/rk808.c | 87 ++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 61 deletions(-)
drivers/mfd/rk808.c +26 -61
@@ -449,81 +449,52 @@ static const struct regmap_irq_chip rk818_irq_chip = {static struct i2c_client *rk808_i2c_client; -static void rk805_device_shutdown (void ) +static void rk808_update_bits (unsigned int reg,unsigned int mask, +unsigned int value) { -int ret;struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); +int ret; -if (!rk808) +if (!rk808) { +dev_warn (&rk808_i2c_client->dev, +"have no rk805/rk808/rk817/rk818, so do nothing here\n" );return ; + } - ret =regmap_update_bits (rk808->regmap, -RK805_DEV_CTRL_REG , -DEV_OFF ,DEV_OFF ); + ret =regmap_update_bits (rk808->regmap, reg, mask, value);if (ret) -dev_err (&rk808_i2c_client->dev,"Failed to shutdown device!\n" ); +dev_err (&rk808_i2c_client->dev, +"can't write to register 0x%x: %x!\n" , reg, ret); } -static void rk805_device_shutdown_prepare (void ) +static void rk805_device_shutdown (void ) { -int ret; -struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); - -if (!rk808) -return ; +rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF ); +} - ret =regmap_update_bits (rk808->regmap, -RK805_GPIO_IO_POL_REG , -SLP_SD_MSK ,SHUTDOWN_FUN ); -if (ret) -dev_err (&rk808_i2c_client->dev,"Failed to shutdown device!\n" ); +static void rk805_device_shutdown_prepare (void ) +{ +rk808_update_bits (RK805_GPIO_IO_POL_REG ,SLP_SD_MSK ,SHUTDOWN_FUN ); }static void rk808_device_shutdown (void ) { -int ret; -struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); - -if (!rk808) -return ; - - ret =regmap_update_bits (rk808->regmap, -RK808_DEVCTRL_REG , -DEV_OFF_RST ,DEV_OFF_RST ); -if (ret) -dev_err (&rk808_i2c_client->dev,"Failed to shutdown device!\n" ); +rk808_update_bits (RK808_DEVCTRL_REG ,DEV_OFF_RST ,DEV_OFF_RST ); }static void rk818_device_shutdown (void ) { -int ret; -struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); - -if (!rk808) -return ; - - ret =regmap_update_bits (rk808->regmap, -RK818_DEVCTRL_REG , -DEV_OFF ,DEV_OFF ); -if (ret) -dev_err (&rk808_i2c_client->dev,"Failed to shutdown device!\n" ); +rk808_update_bits (RK818_DEVCTRL_REG ,DEV_OFF ,DEV_OFF ); }static void rk8xx_syscore_shutdown (void ) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); -int ret;if (system_state ==SYSTEM_POWER_OFF && (rk808->variant ==RK809_ID || rk808->variant ==RK817_ID )) { - ret =regmap_update_bits (rk808->regmap, -RK817_SYS_CFG (3 ), -RK817_SLPPIN_FUNC_MSK , -SLPPIN_DN_FUN ); -if (ret) { -dev_warn (&rk808_i2c_client->dev, -"Cannot switch to power down function\n" ); - } +rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK , +SLPPIN_DN_FUN ); } }
@@ -720,41 +691,35 @@ static int rk808_remove(struct i2c_client *client)static int __maybe_unused rk8xx_suspend (struct device *dev) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); -int ret =0 ;switch (rk808->variant) {case RK809_ID :case RK817_ID : - ret =regmap_update_bits (rk808->regmap, -RK817_SYS_CFG (3 ), -RK817_SLPPIN_FUNC_MSK , -SLPPIN_SLP_FUN ); +rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK , +SLPPIN_SLP_FUN );break ;default :break ; } -return ret; +return 0 ; }static int __maybe_unused rk8xx_resume (struct device *dev) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); -int ret =0 ;switch (rk808->variant) {case RK809_ID :case RK817_ID : - ret =regmap_update_bits (rk808->regmap, -RK817_SYS_CFG (3 ), -RK817_SLPPIN_FUNC_MSK , -SLPPIN_NULL_FUN ); +rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK , +SLPPIN_NULL_FUN );break ;default :break ; } -return ret; +return 0 ; } static SIMPLE_DEV_PM_OPS(rk8xx_pm_ops, rk8xx_suspend, rk8xx_resume);
Signature · 1 line
2.24.0
Re: [RFCv1 1/8] mfd: rk808: Refactor shutdown functions
Quoted 11 lines · Anand Moon
From: Daniel Schultz <[email protected]>
Since all shutdown functions have almost the same code, all logic from the shutdown functions can be refactored to a new function "
rk808_update_bits", which can update a register by a given address and bitmask and value.Cc Heiko Stuebner <[email protected]>Signed-off-by Daniel Schultz <[email protected]>Signed-off-by Anand Moon <[email protected]>
Quoted 8 lines
---
[rebased on latest kernel]
Modified the API to set the value.
This changes were submited with below patch.
[0] https://lore.kernel.org/patchwork/patch/937404/--- drivers/mfd/rk808.c | 87 ++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 61 deletions(-)
Not sure what's happening with these (competing?) patch-sets. I'm not planning on getting involved until you guys have arrived at and agreed upon a single solution.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
RFC 2/8 mfd: rk808: use syscore for RK805 PMIC shutdown
In reply to Anand MoonUse common syscore_shutdown for RK805 PMIC to do clean I2C shutdown, drop the unused pm_pwroff_prep_fn and pm_pwroff_fn function pointers.
--- drivers/mfd/rk808.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/mfd/rk808.c +17 -16
@@ -467,16 +467,6 @@ static void rk808_update_bits(unsigned int reg, unsigned int mask, "can't write to register 0x%x: %x!\n", reg, ret); } -static void rk805_device_shutdown (void ) -{ -rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF ); -} - -static void rk805_device_shutdown_prepare (void ) -{ -rk808_update_bits (RK805_GPIO_IO_POL_REG ,SLP_SD_MSK ,SHUTDOWN_FUN ); -} -static void rk808_device_shutdown (void ) {rk808_update_bits (RK808_DEVCTRL_REG ,DEV_OFF_RST ,DEV_OFF_RST );
@@ -491,10 +481,23 @@ static void rk8xx_syscore_shutdown(void) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); -if (system_state ==SYSTEM_POWER_OFF && - (rk808->variant ==RK809_ID || rk808->variant ==RK817_ID )) { -rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK , -SLPPIN_DN_FUN ); +if (system_state ==SYSTEM_POWER_OFF ) { +dev_info (&rk808_i2c_client->dev,"System Shutdown Event\n" ); + +switch (rk808->variant) { +case RK805_ID : +rk808_update_bits (RK805_GPIO_IO_POL_REG , +SLP_SD_MSK ,SHUTDOWN_FUN ); +rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF ); +break ; +case RK809_ID : +case RK817_ID : +rk808_update_bits (RK817_SYS_CFG (3 ), +RK817_SLPPIN_FUNC_MSK ,SLPPIN_DN_FUN ); +break ; +default : +break ; + } } }
@@ -565,8 +568,6 @@ 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); - rk808->pm_pwroff_fn = rk805_device_shutdown; - rk808->pm_pwroff_prep_fn = rk805_device_shutdown_prepare;break ;case RK808_ID : rk808->regmap_cfg = &rk808_regmap_config;
Signature · 1 line
2.24.0
Re: [RFCv1 2/8] mfd: rk808: use syscore for RK805 PMIC shutdown
Quoted 3 lines · Anand Moon
Use common
syscore_shutdownfor RK805 PMIC to do clean I2C shutdown, drop the unusedpm_pwroff_prep_fnandpm_pwroff_fnfunction pointers.
Coincidentally, I've also been looking at RK805 for the sake of trying to get suspend to behave on my RK3328 box, and I've ended up with some slightly different cleanup patches - I'll tidy them up and post them for comparison as soon as I can.
Quoted 33 lines
Cc Heiko Stuebner <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/mfd/rk808.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)drivers/mfd/rk808.c +0
-12@@ -467,16 +467,6 @@ static void rk808_update_bits(unsigned int reg, unsigned int mask, "can't write to register 0x%x: %x!\n", reg, ret); } -static void rk805_device_shutdown (void ) -{ -rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF ); -} - -static void rk805_device_shutdown_prepare (void ) -{ -rk808_update_bits (RK805_GPIO_IO_POL_REG ,SLP_SD_MSK ,SHUTDOWN_FUN ); -} -static void rk808_device_shutdown (void ) {rk808_update_bits (RK808_DEVCTRL_REG ,DEV_OFF_RST ,DEV_OFF_RST );@@ -491,10 +481,23 @@ static void rk8xx_syscore_shutdown(void) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); -if (system_state ==SYSTEM_POWER_OFF && - (rk808->variant ==RK809_ID || rk808->variant ==RK817_ID )) {
drivers/mfd/rk808.c static void rk8xx_syscore_shutdown(void) · line 491
Quoted 10 lines
drivers/mfd/rk808.c +8
-2-rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK , -SLPPIN_DN_FUN ); +if (system_state ==SYSTEM_POWER_OFF ) { +dev_info (&rk808_i2c_client->dev,"System Shutdown Event\n" ); + +switch (rk808->variant) { +case RK805_ID : +rk808_update_bits (RK805_GPIO_IO_POL_REG , +SLP_SD_MSK ,SHUTDOWN_FUN ); +rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF );
Why this change? Shutdown via the SLEEP pin is working just fine on my box :/
Robin.
Quoted 22 lines
drivers/mfd/rk808.c +9
-2+break ; +case RK809_ID : +case RK817_ID : +rk808_update_bits (RK817_SYS_CFG (3 ), +RK817_SLPPIN_FUNC_MSK ,SLPPIN_DN_FUN ); +break ; +default : +break ; + } } }@@ -565,8 +568,6 @@ 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); - rk808->pm_pwroff_fn = rk805_device_shutdown; - rk808->pm_pwroff_prep_fn = rk805_device_shutdown_prepare;break ;case RK808_ID : rk808->regmap_cfg = &rk808_regmap_config;
Re: [RFCv1 2/8] mfd: rk808: use syscore for RK805 PMIC shutdown
Hi Robin,
Quoted 10 lines · Robin Murphy
Quoted 3 lines · Anand Moon
Use common
syscore_shutdownfor RK805 PMIC to do clean I2C shutdown, drop the unusedpm_pwroff_prep_fnandpm_pwroff_fnfunction pointers.Coincidentally, I've also been looking at RK805 for the sake of trying to get suspend to behave on my RK3328 box, and I've ended up with some slightly different cleanup patches - I'll tidy them up and post them for comparison as soon as I can.
No issue if their is better clean approach, I will definitely test that series.
Quoted 48 lines
Quoted 34 lines
Cc Heiko Stuebner <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/mfd/rk808.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)drivers/mfd/rk808.c +0
-12@@ -467,16 +467,6 @@ static void rk808_update_bits(unsigned int reg, unsigned int mask, "can't write to register 0x%x: %x!\n", reg, ret); } -static void rk805_device_shutdown (void ) -{ -rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF ); -} - -static void rk805_device_shutdown_prepare (void ) -{ -rk808_update_bits (RK805_GPIO_IO_POL_REG ,SLP_SD_MSK ,SHUTDOWN_FUN ); -} -static void rk808_device_shutdown (void ) {rk808_update_bits (RK808_DEVCTRL_REG ,DEV_OFF_RST ,DEV_OFF_RST );@@ -491,10 +481,23 @@ static void rk8xx_syscore_shutdown(void) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client); -if (system_state ==SYSTEM_POWER_OFF && - (rk808->variant ==RK809_ID || rk808->variant ==RK817_ID )) {drivers/mfd/rk808.c static void rk8xx_syscore_shutdown(void) · line 491
Quoted 10 lines
drivers/mfd/rk808.c +8
-2-rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK , -SLPPIN_DN_FUN ); +if (system_state ==SYSTEM_POWER_OFF ) { +dev_info (&rk808_i2c_client->dev,"System Shutdown Event\n" ); + +switch (rk808->variant) { +case RK805_ID : +rk808_update_bits (RK805_GPIO_IO_POL_REG , +SLP_SD_MSK ,SHUTDOWN_FUN ); +rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF );Why this change? Shutdown via the SLEEP pin is working just fine on my box :/
Quoted 1 line
Robin.
As per RK-805 datasheet [0] below.
For clean poweroff we need to set in DEV_CTRL_REG reg Bit 0 DEV_OFF: write “1” to turn down the PMU.
[0] http://files.pine64.org/doc/rock64/Rockchip_RK805_Datasheet_V1.1%C2%A020160921.pdf
-Anand
RFC 3/8 mfd: rk808: use syscore for RK808 PMIC shutdown
In reply to Anand MoonUse common syscore_shutdown for RK808 PMIC to do
clean I2C shutdown, drop the unused pm_pwroff_fn
function pointers.
--- drivers/mfd/rk808.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/mfd/rk808.c +4 -6
@@ -467,11 +467,6 @@ static void rk808_update_bits(unsigned int reg, unsigned int mask, "can't write to register 0x%x: %x!\n", reg, ret); } -static void rk808_device_shutdown (void ) -{ -rk808_update_bits (RK808_DEVCTRL_REG ,DEV_OFF_RST ,DEV_OFF_RST ); -} -static void rk818_device_shutdown (void ) {rk808_update_bits (RK818_DEVCTRL_REG ,DEV_OFF ,DEV_OFF );
@@ -490,6 +485,10 @@ static void rk8xx_syscore_shutdown(void) SLP_SD_MSK, SHUTDOWN_FUN);rk808_update_bits (RK805_DEV_CTRL_REG ,DEV_OFF ,DEV_OFF );break ; +case RK808_ID : +rk808_update_bits (RK808_DEVCTRL_REG , +DEV_OFF_RST ,DEV_OFF_RST ); +break ;case RK809_ID :case RK817_ID : rk808_update_bits(RK817_SYS_CFG(3),
@@ -576,7 +575,6 @@ static int rk808_probe(struct i2c_client *client, nr_pre_init_regs =ARRAY_SIZE (rk808_pre_init_reg); cells = rk808s; nr_cells =ARRAY_SIZE (rk808s); - rk808->pm_pwroff_fn = rk808_device_shutdown;break ;case RK818_ID : rk808->regmap_cfg = &rk818_regmap_config;
Signature · 1 line
2.24.0
RFC 4/8 mfd: rk808: use syscore for RK818 PMIC shutdown
In reply to Anand MoonUse common syscore_shutdown for RK818 PMIC to do
clean I2C shutdown, drop the unused pm_pwroff_fn
function pointers.
--- drivers/mfd/rk808.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mfd/rk808.c +3 -6
@@ -467,11 +467,6 @@ static void rk808_update_bits(unsigned int reg, unsigned int mask, "can't write to register 0x%x: %x!\n", reg, ret); } -static void rk818_device_shutdown (void ) -{ -rk808_update_bits (RK818_DEVCTRL_REG ,DEV_OFF ,DEV_OFF ); -} -static void rk8xx_syscore_shutdown (void ) {struct rk808 *rk808 =i2c_get_clientdata (rk808_i2c_client);
@@ -494,6 +489,9 @@ static void rk8xx_syscore_shutdown(void)rk808_update_bits (RK817_SYS_CFG (3 ),RK817_SLPPIN_FUNC_MSK ,SLPPIN_DN_FUN );break ; +case RK818_ID : +rk808_update_bits (RK818_DEVCTRL_REG ,DEV_OFF ,DEV_OFF ); +break ;default :break ; }
@@ -583,7 +581,6 @@ 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); - rk808->pm_pwroff_fn = rk818_device_shutdown;break ;case RK809_ID :case RK817_ID :
Signature · 1 line
2.24.0
RFC 5/8 mfd: rk808: cleanup unused function pointer
In reply to Anand MoonCleanup unused pm_poweroff_fn and pm_pwroff_prep_fn function, drop the unused rockchip,system-power-controller dts binding.
--- drivers/mfd/rk808.c | 28 ++-------------------------- include/linux/mfd/rk808.h | 2 -- 2 files changed, 2 insertions(+), 28 deletions(-)
drivers/mfd/rk808.c +2 -26
@@ -521,7 +521,7 @@ static int rk808_probe(struct i2c_client *client,const struct mfd_cell *cells;int nr_pre_init_regs;int nr_cells; -int pm_off =0 , msb, lsb; +int msb, lsb;unsigned char pmic_id_msb, pmic_id_lsb;int ret;int i;
@@ -641,18 +641,8 @@ static int rk808_probe(struct i2c_client *client, goto err_irq; } - pm_off =of_property_read_bool (np, -"rockchip,system-power-controller" ); -if (pm_off && !pm_power_off) { +if (!rk808_i2c_client) rk808_i2c_client = client; - pm_power_off = rk808->pm_pwroff_fn; - } - -if (pm_off && !pm_power_off_prepare) { -if (!rk808_i2c_client) - rk808_i2c_client = client; - pm_power_off_prepare = rk808->pm_pwroff_prep_fn; - }return 0 ;
@@ -667,20 +657,6 @@ static int rk808_remove(struct i2c_client *client)regmap_del_irq_chip (client->irq, rk808->irq_data); -/** -* pm_power_off may points to a function from another module. -* Check if the pointer is set by us and only then overwrite it. -*/ -if (rk808->pm_pwroff_fn && pm_power_off == rk808->pm_pwroff_fn) - pm_power_off =NULL ; - -/** -* As above, check if the pointer is set by us before overwrite. -*/ -if (rk808->pm_pwroff_prep_fn && - pm_power_off_prepare == rk808->pm_pwroff_prep_fn) - pm_power_off_prepare =NULL ; -return 0 ; }
include/linux/mfd/rk808.h +0 -2
@@ -620,7 +620,5 @@ struct rk808 {long variant;const struct regmap_config *regmap_cfg; const struct regmap_irq_chip *regmap_irq_chip; -void (*pm_pwroff_fn)(void ); - void (*pm_pwroff_prep_fn)(void); };#endif /* __LINUX_REGULATOR_RK808_H */
Signature · 1 line
2.24.0
RFC 6/8 mfd: rk808: use common syscore for all PMCI for clean shutdown
In reply to Anand MoonMove the register_syscore_ops to common location for all PMIC. Add missing unregister_syscore_ops in rk808_remove function.
--- drivers/mfd/rk808.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mfd/rk808.c +4 -1
@@ -590,7 +590,6 @@ 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); -register_syscore_ops (&rk808_syscore_ops);break ;default : dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
@@ -644,6 +643,8 @@ static int rk808_probe(struct i2c_client *client,if (!rk808_i2c_client) rk808_i2c_client = client; +register_syscore_ops (&rk808_syscore_ops); +return 0 ; err_irq:
@@ -657,6 +658,8 @@ static int rk808_remove(struct i2c_client *client)regmap_del_irq_chip (client->irq, rk808->irq_data); +unregister_syscore_ops (&rk808_syscore_ops); +return 0 ; }
Signature · 1 line
2.24.0
RFC 7/8 arm64: rockchip: drop unused field from rk8xx i2c node
In reply to Anand MoonDrop unused rockchip,system-power-controller from rk8xx i2c0 node.
--- arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - arch/arm64/boot/dts/rockchip/rk3368-px5-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - arch/arm64/boot/dts/rockchip/rk3399-leez-p710.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - arch/arm64/boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 - arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-rock960.dtsi | 1 - arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - 20 files changed, 20 deletions(-)
arch/arm64/boot/dts/rockchip/px30-evb.dts +0 -1
@@ -142,7 +142,6 @@ rk809: pmic@20 { interrupts = <7 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <0>; clock-output-names = "xin32k";
arch/arm64/boot/dts/rockchip/rk3328-a1.dts +0 -1
@@ -151,7 +151,6 @@ pmic@18 { interrupts = <RK_PA6 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3328-evb.dts +0 -1
@@ -103,7 +103,6 @@ rk805: rk805@18 { #gpio-cells = <2>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts +0 -1
@@ -175,7 +175,6 @@ rk805: pmic@18 { #gpio-cells = <2>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3328-rock64.dts +0 -1
@@ -180,7 +180,6 @@ rk805: rk805@18 { #gpio-cells = <2>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3368-geekbox.dts +0 -1
@@ -108,7 +108,6 @@ rk808: pmic@1b { pinctrl-0 = <&pmic_int>, <&pmic_sleep>; interrupt-parent = <&gpio0>; interrupts = <RK_PA5 IRQ_TYPE_LEVEL_LOW>; - rockchip,system-power-controller; vcc1-supply = <&vcc_sys>; vcc2-supply = <&vcc_sys>; vcc3-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi +0 -1
@@ -174,7 +174,6 @@ rk808: pmic@1b { #clock-cells = <1>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>, <&pmic_sleep>; - rockchip,system-power-controller; vcc1-supply = <&vcc_sys>; vcc2-supply = <&vcc_sys>; vcc3-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3368-px5-evb.dts +0 -1
@@ -68,7 +68,6 @@ rk808: pmic@1b { interrupts = <RK_PA5 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int>, <&pmic_sleep>; - rockchip,system-power-controller; vcc1-supply = <&vcc_sys>; vcc2-supply = <&vcc_sys>; vcc3-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +0 -1
@@ -278,7 +278,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm64/boot/dts/rockchip/rk3399-hugsun-x99.dts +0 -1
@@ -225,7 +225,6 @@ rk808: pmic@1b { interrupts = <21 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>; clock-output-names = "xin32k", "rtc_clko_wifi";
arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi +0 -1
@@ -301,7 +301,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vsys_3v3>;
arch/arm64/boot/dts/rockchip/rk3399-leez-p710.dts +0 -1
@@ -180,7 +180,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc5v0_sys>;
arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi +0 -1
@@ -241,7 +241,6 @@ rk808: pmic@1b { interrupts = <21 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc3v3_sys>;
arch/arm64/boot/dts/rockchip/rk3399-orangepi.dts +0 -1
@@ -241,7 +241,6 @@ rk808: pmic@1b { clock-output-names = "rtc_clko_soc", "rtc_clko_wifi"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc3v3_sys>;
arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi +0 -1
@@ -185,7 +185,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc5v0_sys>;
arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dtsi +0 -1
@@ -260,7 +260,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc3v3_sys>;
arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4.dts +0 -1
@@ -197,7 +197,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc5v0_sys>;
arch/arm64/boot/dts/rockchip/rk3399-rock960.dtsi +0 -1
@@ -169,7 +169,6 @@ rk808: pmic@1b { interrupts = <21 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>; clock-output-names = "xin32k", "rk808-clkout2";
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dts +0 -1
@@ -259,7 +259,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc5v0_sys>;
arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi +0 -1
@@ -228,7 +228,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
Signature · 1 line
2.24.0
RFC 8/8 arm: rockchip: drop unused field from rk8xx i2c node
In reply to Anand MoonDrop unused rockchip,system-power-controller from rk8xx i2c node.
--- arch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - 10 files changed, 10 deletions(-)
arch/arm/boot/dts/rk3036-kylin.dts +0 -1
@@ -118,7 +118,6 @@ rk808: pmic@1b { interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int &global_pwroff>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>; clock-output-names = "xin32k", "rk808-clkout2";
arch/arm/boot/dts/rk3188-px3-evb.dts +0 -1
@@ -88,7 +88,6 @@ rk808: pmic@1c { reg = <0x1c>; interrupt-parent = <&gpio0>; interrupts = <RK_PB3 IRQ_TYPE_LEVEL_LOW>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>; clock-output-names = "xin32k", "rk808-clkout2";
arch/arm/boot/dts/rk3288-evb-rk808.dts +0 -1
@@ -17,7 +17,6 @@ rk808: pmic@1b { interrupts = <RK_PA4 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int &global_pwroff>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>; clock-output-names = "xin32k", "rk808-clkout2";
arch/arm/boot/dts/rk3288-phycore-som.dtsi +0 -1
@@ -148,7 +148,6 @@ rk818: pmic@1c { interrupts = <4 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>;
arch/arm/boot/dts/rk3288-popmetal.dts +0 -1
@@ -168,7 +168,6 @@ rk808: pmic@1b { interrupts = <RK_PA4 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int &global_pwroff>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>; clock-output-names = "xin32k", "rk808-clkout2";
arch/arm/boot/dts/rk3288-tinker.dtsi +0 -1
@@ -154,7 +154,6 @@ rk808: pmic@1b { <&gpio0 12 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int &global_pwroff &dvs_1 &dvs_2>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm/boot/dts/rk3288-veyron.dtsi +0 -1
@@ -221,7 +221,6 @@ rk808: pmic@1b { interrupts = <RK_PA4 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pmic_int_l>; - rockchip,system-power-controller; wakeup-source; #clock-cells = <1>;
arch/arm/boot/dts/rk3288-vyasa.dts +0 -1
@@ -167,7 +167,6 @@ rk808: pmic@1b { clock-output-names = "xin32k", "rk808-clkout2"; pinctrl-names = "default"; pinctrl-0 = <&pmic_int &global_pwroff>; - rockchip,system-power-controller; wakeup-source; vcc1-supply = <&vcc_sys>;
arch/arm/boot/dts/rv1108-elgin-r1.dts +0 -1
@@ -67,7 +67,6 @@ rk805: pmic@18 { reg = <0x18>; interrupt-parent = <&gpio0>; interrupts = <RK_PB4 IRQ_TYPE_LEVEL_LOW>; - rockchip,system-power-controller; vcc1-supply = <&vcc_sys>; vcc2-supply = <&vcc_sys>;
arch/arm/boot/dts/rv1108-evb.dts +0 -1
@@ -80,7 +80,6 @@ rk805: pmic@18 { reg = <0x18>; interrupt-parent = <&gpio0>; interrupts = <RK_PB4 IRQ_TYPE_LEVEL_LOW>; - rockchip,system-power-controller; vcc1-supply = <&vcc_sys>; vcc2-supply = <&vcc_sys>;
Signature · 1 line
2.24.0
Heiko Stuebner
maintainerHi Anand,
Am Freitag, 6. Dezember 2019, 19:45:28 CET schrieb Anand Moon:
Quoted 16 lines
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdf
Quoted 5 lines
Reboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
The rk8xx pmics may not on all devices be responsible for powering down the device. That is what the system-power-controller dt-property is for.
So that property is there for a reason - to indicate that the pmic is responsible for power-off-handling.
Heiko
Quoted 52 lines
Tested on SBC
Rock960 Model A
Odroid N1
Rock64-Anand Moon
Anand Moon (8):
mfd: rk808: Refactor shutdown functions
mfd: rk808: use syscore for RK805 PMIC shutdown
mfd: rk808: use syscore for RK808 PMIC shutdown
mfd: rk808: use syscore for RK818 PMIC shutdown
mfd: rk808: cleanup unused function pointer
mfd: rk808: use common syscore for all PMCI for clean shutdown
arm64: rockchip: drop unused field from rk8xx i2c node
arm: rockchip: drop unused field from rk8xx i2c nodearch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - .../boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - .../boot/dts/rockchip/rk3368-px5-evb.dts | 1 - .../boot/dts/rockchip/rk3399-firefly.dts | 1 - .../boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - .../boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - .../boot/dts/rockchip/rk3399-leez-p710.dts | 1 - .../boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - .../boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 - .../boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - .../boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - .../boot/dts/rockchip/rk3399-rock960.dtsi | 1 - .../boot/dts/rockchip/rk3399-rockpro64.dts | 1 - .../boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - drivers/mfd/rk808.c | 144 +++++------------- include/linux/mfd/rk808.h | 2 - 32 files changed, 42 insertions(+), 134 deletions(-)
Hi Heiko,
Quoted 26 lines · Heiko Stuebner
Hi Anand,
Am Freitag, 6. Dezember 2019, 19:45:28 CET schrieb Anand Moon:
Quoted 16 lines
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdfQuoted 5 lines
Reboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
Quoted 8 lines
The rk8xx pmics may not on all devices be responsible for powering down the device. That is what the system-power-controller dt-property is for.
So that property is there for a reason - to indicate that the pmic is responsible for power-off-handling.
Heiko
Ok, my intent was to have common framework for
shutdown, restart, suspend, resume routines.
-Anand
Heiko Stuebner
maintainerAm Samstag, 7. Dezember 2019, 06:07:49 CET schrieb Anand Moon:
Quoted 32 lines
Hi Heiko,
Quoted 29 lines · Heiko Stuebner
Hi Anand,
Am Freitag, 6. Dezember 2019, 19:45:28 CET schrieb Anand Moon:
Quoted 16 lines
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdfQuoted 5 lines
Reboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
The rk8xx pmics may not on all devices be responsible for powering down the device. That is what the system-power-controller dt-property is for.
Quoted 8 lines
Quoted 5 lines
So that property is there for a reason - to indicate that the pmic is responsible for power-off-handling.
Heiko
Ok, my intent was to have common framework for
shutdown, restart, suspend, resume routines.
That is a great goal actually :-)
I guess just keep in mind that it should only handle power-off if instructed by the devicetree property.
Quoted 2 lines · Anand Moon
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
FWIW reboot problems on RK3399 have been tracked down to issues in upstream ATF, and are unrelated to the PMIC.
Quoted 2 lines
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
As mentioned elsewhere[1], although this is what the BSP kernel seems to do, and in practice it's unlikely to matter for the majority of devboard users like you and me, I still feel a bit uncomfortable with this solution for systems using ATF as in principle the secure world might want to know about orderly shutdowns, and this effectively makes every shutdown an unexpected power loss from secure software's point of view.
Robin.
[1] http://lists.infradead.org/pipermail/linux-rockchip/2019-December/028183.html
Quoted 67 lines
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdfReboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
Tested on SBC
Rock960 Model A
Odroid N1
Rock64-Anand Moon
Anand Moon (8):
mfd: rk808: Refactor shutdown functions
mfd: rk808: use syscore for RK805 PMIC shutdown
mfd: rk808: use syscore for RK808 PMIC shutdown
mfd: rk808: use syscore for RK818 PMIC shutdown
mfd: rk808: cleanup unused function pointer
mfd: rk808: use common syscore for all PMCI for clean shutdown
arm64: rockchip: drop unused field from rk8xx i2c node
arm: rockchip: drop unused field from rk8xx i2c nodearch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - .../boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - .../boot/dts/rockchip/rk3368-px5-evb.dts | 1 - .../boot/dts/rockchip/rk3399-firefly.dts | 1 - .../boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - .../boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - .../boot/dts/rockchip/rk3399-leez-p710.dts | 1 - .../boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - .../boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 - .../boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - .../boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - .../boot/dts/rockchip/rk3399-rock960.dtsi | 1 - .../boot/dts/rockchip/rk3399-rockpro64.dts | 1 - .../boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - drivers/mfd/rk808.c | 144 +++++------------- include/linux/mfd/rk808.h | 2 - 32 files changed, 42 insertions(+), 134 deletions(-)
Quoted 11 lines · Robin Murphy
Quoted 2 lines · Anand Moon
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
FWIW reboot problems on RK3399 have been tracked down to issues in upstream ATF, and are unrelated to the PMIC.
Quoted 2 lines
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
Quoted 8 lines
As mentioned elsewhere[1], although this is what the BSP kernel seems to do, and in practice it's unlikely to matter for the majority of devboard users like you and me, I still feel a bit uncomfortable with this solution for systems using ATF as in principle the secure world might want to know about orderly shutdowns, and this effectively makes every shutdown an unexpected power loss from secure software's point of view.
Robin.
Since ATF is operating completely in volatile memory, and shouldn't be touching hardware once it passes off control to the kernel anyways, what is the harm of pulling the rug out from under it?
If this idea is to prevent issues in the future, such as if ATF does gain the ability to preempt hardware control, then at that time ATF will need to be able to handle actually powering off devices using the same functionality.
But as we discussed previously, ATF doesn't have this capability, so in this case any board without a dedicated power-off gpio will be unable to power off at all.
Also it seems that giving ATF this functionality, with the current state of ATF, would be cost prohibitive.
I personally feel that allowing the kernel to do this is a solution to the problem we have now.
Quoted 76 lines
[1]
http://lists.infradead.org/pipermail/linux-rockchip/2019-December/028183.htmlQuoted 58 lines
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdfReboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
Tested on SBC
Rock960 Model A
Odroid N1
Rock64-Anand Moon
Anand Moon (8):
mfd: rk808: Refactor shutdown functions
mfd: rk808: use syscore for RK805 PMIC shutdown
mfd: rk808: use syscore for RK808 PMIC shutdown
mfd: rk808: use syscore for RK818 PMIC shutdown
mfd: rk808: cleanup unused function pointer
mfd: rk808: use common syscore for all PMCI for clean shutdown
arm64: rockchip: drop unused field from rk8xx i2c node
arm: rockchip: drop unused field from rk8xx i2c nodearch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - .../boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - .../boot/dts/rockchip/rk3368-px5-evb.dts | 1 - .../boot/dts/rockchip/rk3399-firefly.dts | 1 - .../boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - .../boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - .../boot/dts/rockchip/rk3399-leez-p710.dts | 1 - .../boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - .../boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 -Quoted 9 lines
.../boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - .../boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - .../boot/dts/rockchip/rk3399-rock960.dtsi | 1 - .../boot/dts/rockchip/rk3399-rockpro64.dts | 1 - .../boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - drivers/mfd/rk808.c | 144 +++++------------- include/linux/mfd/rk808.h | 2 - 32 files changed, 42 insertions(+), 134 deletions(-)_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Heiko Stübner
maintainerHi,
Am Montag, 9. Dezember 2019, 14:37:28 CET schrieb Peter Geis:
Quoted 19 lines · Robin Murphy
Quoted 18 lines · Anand Moon
Quoted 2 lines
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
FWIW reboot problems on RK3399 have been tracked down to issues in upstream ATF, and are unrelated to the PMIC.
Quoted 2 lines
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
As mentioned elsewhere[1], although this is what the BSP kernel seems to do, and in practice it's unlikely to matter for the majority of devboard users like you and me, I still feel a bit uncomfortable with this solution for systems using ATF as in principle the secure world might want to know about orderly shutdowns, and this effectively makes every shutdown an unexpected power loss from secure software's point of view.
Quoted 5 lines
Quoted 1 line
Robin.
Since ATF is operating completely in volatile memory, and shouldn't be touching hardware once it passes off control to the kernel anyways, what is the harm of pulling the rug out from under it?
Secure-world doesn't end with ATF :-)
There can also be an instance of OP-TEE or another TEE on top and they often actually do secure storage encrypted onto the hosts mass storage (see kernel's optee module).
Quoted 5 lines
If this idea is to prevent issues in the future, such as if ATF does gain the ability to preempt hardware control, then at that time ATF will need to be able to handle actually powering off devices using the same functionality.
Quoted 8 lines
But as we discussed previously, ATF doesn't have this capability, so in this case any board without a dedicated power-off gpio will be unable to power off at all.
Also it seems that giving ATF this functionality, with the current state of ATF, would be cost prohibitive.I personally feel that allowing the kernel to do this is a solution to the problem we have now.
For the rest I guess I'll just point to Robin's text and Ack under your system-power-controller patch ;-)
Heiko
Quoted 76 lines
Quoted 75 lines
[1]
http://lists.infradead.org/pipermail/linux-rockchip/2019-December/028183.htmlQuoted 58 lines
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdfReboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
Tested on SBC
Rock960 Model A
Odroid N1
Rock64-Anand Moon
Anand Moon (8):
mfd: rk808: Refactor shutdown functions
mfd: rk808: use syscore for RK805 PMIC shutdown
mfd: rk808: use syscore for RK808 PMIC shutdown
mfd: rk808: use syscore for RK818 PMIC shutdown
mfd: rk808: cleanup unused function pointer
mfd: rk808: use common syscore for all PMCI for clean shutdown
arm64: rockchip: drop unused field from rk8xx i2c node
arm: rockchip: drop unused field from rk8xx i2c nodearch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - .../boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - .../boot/dts/rockchip/rk3368-px5-evb.dts | 1 - .../boot/dts/rockchip/rk3399-firefly.dts | 1 - .../boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - .../boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - .../boot/dts/rockchip/rk3399-leez-p710.dts | 1 - .../boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - .../boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 -Quoted 9 lines
.../boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - .../boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - .../boot/dts/rockchip/rk3399-rock960.dtsi | 1 - .../boot/dts/rockchip/rk3399-rockpro64.dts | 1 - .../boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - drivers/mfd/rk808.c | 144 +++++------------- include/linux/mfd/rk808.h | 2 - 32 files changed, 42 insertions(+), 134 deletions(-)_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Quoted 21 lines · Peter Geis
Quoted 11 lines · Robin Murphy
Quoted 2 lines · Anand Moon
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
FWIW reboot problems on RK3399 have been tracked down to issues in upstream ATF, and are unrelated to the PMIC.
Quoted 2 lines
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
Quoted 8 lines
As mentioned elsewhere[1], although this is what the BSP kernel seems to do, and in practice it's unlikely to matter for the majority of devboard users like you and me, I still feel a bit uncomfortable with this solution for systems using ATF as in principle the secure world might want to know about orderly shutdowns, and this effectively makes every shutdown an unexpected power loss from secure software's point of view.
Robin.
Quoted 7 lines
Since ATF is operating completely in volatile memory, and shouldn't be touching hardware once it passes off control to the kernel anyways, what is the harm of pulling the rug out from under it?
If this idea is to prevent issues in the future, such as if ATF does gain the ability to preempt hardware control, then at that time ATF will need to be able to handle actually powering off devices using the same functionality.
It's not ATF itself I'm concerned about, but arbitrary Secure EL1 payloads. In theory, a TEE might want to do something like cycle keys or log events in a TPM (or just encrypted in an external SPI flash), or scrub secure DRAM for cold boot protection. I'm pretty sure none of us are running such a thing on our boards today, but an upstream solution really wants to be robust for the general case.
Quoted 8 lines
But as we discussed previously, ATF doesn't have this capability, so in this case any board without a dedicated power-off gpio will be unable to power off at all.
Also it seems that giving ATF this functionality, with the current state of ATF, would be cost prohibitive.I personally feel that allowing the kernel to do this is a solution to the problem we have now.
Sure - I do like your cool idea of using a custom reboot reason to handle a 'trusted' poweroff in the U-Boot SPL - but in the meantime anything would be a practical improvement over the current situation. I reckon this other patch[1] (this seems to be a popular issue all of a sudden!) looks like the neatest interim step.
Robin.
[1] http://lists.infradead.org/pipermail/linux-rockchip/2019-December/028245.html
Quoted 72 lines
Quoted 72 lines
Quoted 58 lines
For reference
RK805 PMCI data sheet:
[0] http://rockchip.fr/RK805%20datasheet%20V1.3.pdf
RK808 PMIC data sheet:
[1] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
RK817 PMIC data sheet:
[2] http://rockchip.fr/RK817%20datasheet%20V1.01.pdf
RK818 PMIC data sheet:
[3] http://rockchip.fr/RK818%20datasheet%20V1.0.pdfReboot issue:
My guess is that we need to some proper sequence of setting to PMCI to perform clean.If you have any input please share them.
Tested on SBC
Rock960 Model A
Odroid N1
Rock64-Anand Moon
Anand Moon (8):
mfd: rk808: Refactor shutdown functions
mfd: rk808: use syscore for RK805 PMIC shutdown
mfd: rk808: use syscore for RK808 PMIC shutdown
mfd: rk808: use syscore for RK818 PMIC shutdown
mfd: rk808: cleanup unused function pointer
mfd: rk808: use common syscore for all PMCI for clean shutdown
arm64: rockchip: drop unused field from rk8xx i2c node
arm: rockchip: drop unused field from rk8xx i2c nodearch/arm/boot/dts/rk3036-kylin.dts | 1 - arch/arm/boot/dts/rk3188-px3-evb.dts | 1 - arch/arm/boot/dts/rk3288-evb-rk808.dts | 1 - arch/arm/boot/dts/rk3288-phycore-som.dtsi | 1 - arch/arm/boot/dts/rk3288-popmetal.dts | 1 - arch/arm/boot/dts/rk3288-tinker.dtsi | 1 - arch/arm/boot/dts/rk3288-veyron.dtsi | 1 - arch/arm/boot/dts/rk3288-vyasa.dts | 1 - arch/arm/boot/dts/rv1108-elgin-r1.dts | 1 - arch/arm/boot/dts/rv1108-evb.dts | 1 - arch/arm64/boot/dts/rockchip/px30-evb.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-a1.dts | 1 - arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-roc-cc.dts | 1 - .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 1 - .../boot/dts/rockchip/rk3368-geekbox.dts | 1 - arch/arm64/boot/dts/rockchip/rk3368-lion.dtsi | 1 - .../boot/dts/rockchip/rk3368-px5-evb.dts | 1 - .../boot/dts/rockchip/rk3399-firefly.dts | 1 - .../boot/dts/rockchip/rk3399-hugsun-x99.dts | 1 - .../boot/dts/rockchip/rk3399-khadas-edge.dtsi | 1 - .../boot/dts/rockchip/rk3399-leez-p710.dts | 1 - .../boot/dts/rockchip/rk3399-nanopi4.dtsi | 1 - .../boot/dts/rockchip/rk3399-orangepi.dts | 1 - arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 1 -Quoted 9 lines
.../boot/dts/rockchip/rk3399-roc-pc.dtsi | 1 - .../boot/dts/rockchip/rk3399-rock-pi-4.dts | 1 - .../boot/dts/rockchip/rk3399-rock960.dtsi | 1 - .../boot/dts/rockchip/rk3399-rockpro64.dts | 1 - .../boot/dts/rockchip/rk3399-sapphire.dtsi | 1 - drivers/mfd/rk808.c | 144 +++++------------- include/linux/mfd/rk808.h | 2 - 32 files changed, 42 insertions(+), 134 deletions(-)_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Hi,
Quoted 16 lines · Robin Murphy
Quoted 15 lines · Anand Moon
Quoted 2 lines
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
FWIW reboot problems on RK3399 have been tracked down to issues in upstream ATF, and are unrelated to the PMIC.
Quoted 2 lines
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
As mentioned elsewhere[1], although this is what the BSP kernel seems to do, and in practice it's unlikely to matter for the majority of devboard users like you and me, I still feel a bit uncomfortable with this solution for systems using ATF as in principle the secure world might want to know about orderly shutdowns, and this effectively makes every shutdown an unexpected power loss from secure software's point of view.
Quoted 8 lines
Quoted 1 line
Robin.
Since ATF is operating completely in volatile memory, and shouldn't be touching hardware once it passes off control to the kernel anyways, what is the harm of pulling the rug out from under it?
If this idea is to prevent issues in the future, such as if ATF does gain the ability to preempt hardware control, then at that time ATF will need to be able to handle actually powering off devices using the same functionality.
As far as I know ATF implements PSCI, doesn't it? Thus I would assume that it should most definitely handle power off for all platforms as indicated by the presence of platform handlers in [1].
Quoted 8 lines
But as we discussed previously, ATF doesn't have this capability, so in this case any board without a dedicated power-off gpio will be unable to power off at all.
Also it seems that giving ATF this functionality, with the current state of ATF, would be cost prohibitive.I personally feel that allowing the kernel to do this is a solution to the problem we have now.
Maybe I'm missing something here but I'd suggest that implementing an i2c driver in the rockchip platform part of ATF using libfdt to find the PMIC from the devicetree would be the way to go.
[1] https://github.com/ARM-software/arm-trusted-firmware/blob/master/lib/psci/psci_system_off.c#L31
Hi Robin,
Quoted 7 lines · Robin Murphy
Quoted 2 lines · Anand Moon
Most of the RK3399 SBC boards do not perform clean shutdown and clean reboot.
FWIW reboot problems on RK3399 have been tracked down to issues in upstream ATF, and are unrelated to the PMIC.
Yes I am aware of this changes.
But, I have tired to study *RK808 datasheet V1.4* [0] below section *5.2.3 Power Channel Control/Monitor Registers*
for clean reboot I was going to try disable some bit in below into reboot handle in the future patch.
DCDC_EN_REGSLEEP_SET_OFF_REG1SLEEP_SET_OFF_REG2DCDC_UV_STS_REG
I was going see if this helps to do clean reboot. further more use this in suspend/resume operation.
[0] http://rockchip.fr/RK808%20datasheet%20V1.4.pdf
But I feed that their is some more issue with related to mmc or PCIe not able to cleanly release the resources while reboot which caused then to disable after reboot.
Quoted 11 lines
Quoted 3 lines
These patches try to help resolve the issue with proper shutdown by turning off the PMIC.
As mentioned elsewhere[1], although this is what the BSP kernel seems to do, and in practice it's unlikely to matter for the majority of devboard users like you and me, I still feel a bit uncomfortable with this solution for systems using ATF as in principle the secure world might want to know about orderly shutdowns, and this effectively makes every shutdown an unexpected power loss from secure software's point of view.
Quoted 5 lines
Robin.
[1]
http://lists.infradead.org/pipermail/linux-rockchip/2019-December/028183.html
Yes I have follow the mailing list and I read this thread. I am not aware of ATF complete architecture.
-Anand