Skip to contentSkip to conversation

RK3399 clean shutdown issue

RFC In review Anand Moon 6 participants 21 messages Dec 6, 2019 – Dec 16, 2019

Subsystems (3)
lore
Share & tools
lore

Anand Moon

author
#0 lore raw

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
author
#1 lore raw

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
index a69a6742ecdc..e637f5bcc8bb 100644
@@ -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
#2 lore raw

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.

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
author
#3 lore raw

RFC 2/8 mfd: rk808: use syscore for RK805 PMIC shutdown

In reply to Anand Moon

Use common syscore_shutdown for RK805 PMIC to do clean I2C shutdown, drop the unused pm_pwroff_prep_fn and pm_pwroff_fn function pointers.

Cc Heiko Stuebner <[email protected]>
---
 drivers/mfd/rk808.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/mfd/rk808.c +17 -16
index e637f5bcc8bb..713d989064ba 100644
@@ -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
#4 lore raw

Re: [RFCv1 2/8] mfd: rk808: use syscore for RK805 PMIC shutdown

Quoted 3 lines · Anand Moon

Use common syscore_shutdown for RK805 PMIC to do clean I2C shutdown, drop the unused pm_pwroff_prep_fn and pm_pwroff_fn function 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]>
---
  drivers/mfd/rk808.c | 33 +++++++++++++++++----------------
  1 file changed, 17 insertions(+), 16 deletions(-)
drivers/mfd/rk808.c +0 -12
index e637f5bcc8bb..713d989064ba 100644
@@ -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;
author
#5 lore raw

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_shutdown for RK805 PMIC to do clean I2C shutdown, drop the unused pm_pwroff_prep_fn and pm_pwroff_fn function 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]>
---
  drivers/mfd/rk808.c | 33 +++++++++++++++++----------------
  1 file changed, 17 insertions(+), 16 deletions(-)
drivers/mfd/rk808.c +0 -12
index e637f5bcc8bb..713d989064ba 100644
@@ -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

author
#6 lore raw

RFC 3/8 mfd: rk808: use syscore for RK808 PMIC shutdown

In reply to Anand Moon

Use common syscore_shutdown for RK808 PMIC to do
clean I2C shutdown, drop the unused pm_pwroff_fn
function pointers.

Cc Heiko Stuebner <[email protected]>
---
 drivers/mfd/rk808.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/mfd/rk808.c +4 -6
index 713d989064ba..0a098fbdf112 100644
@@ -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
author
#7 lore raw

RFC 4/8 mfd: rk808: use syscore for RK818 PMIC shutdown

In reply to Anand Moon

Use common syscore_shutdown for RK818 PMIC to do
clean I2C shutdown, drop the unused pm_pwroff_fn
function pointers.

Cc Heiko Stuebner <[email protected]>
---
 drivers/mfd/rk808.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mfd/rk808.c +3 -6
index 0a098fbdf112..4b3b90dad4f8 100644
@@ -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
author
#8 lore raw

RFC 5/8 mfd: rk808: cleanup unused function pointer

In reply to Anand Moon

Cleanup unused pm_poweroff_fn and pm_pwroff_prep_fn function, drop the unused rockchip,system-power-controller dts binding.

Cc Heiko Stuebner <[email protected]>
---
 drivers/mfd/rk808.c       | 28 ++--------------------------
 include/linux/mfd/rk808.h |  2 --
 2 files changed, 2 insertions(+), 28 deletions(-)
drivers/mfd/rk808.c +2 -26
index 4b3b90dad4f8..9a7be379946a 100644
@@ -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
index a59bf323f713..e07f6e61cd38 100644
@@ -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
author
#9 lore raw

RFC 6/8 mfd: rk808: use common syscore for all PMCI for clean shutdown

In reply to Anand Moon

Move the register_syscore_ops to common location for all PMIC. Add missing unregister_syscore_ops in rk808_remove function.

Cc Heiko Stuebner <[email protected]>
---
 drivers/mfd/rk808.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mfd/rk808.c +4 -1
index 9a7be379946a..54f3999e4948 100644
@@ -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
author
#10 lore raw

RFC 7/8 arm64: rockchip: drop unused field from rk8xx i2c node

In reply to Anand Moon

Drop unused rockchip,system-power-controller from rk8xx i2c0 node.

Cc Heiko Stuebner <[email protected]>
---
 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
index 936ed7d71ffc..6f51b5f1b17a 100644
@@ -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
index 76b49f573101..97fdf654fe7e 100644
@@ -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
index 49c4b96da3d4..f1db204e4e0c 100644
@@ -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
index 8d553c92182a..27318c1a57be 100644
@@ -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
index 62936b432f9a..ccb0baa2eae9 100644
@@ -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
index 1d0778ff217c..af3ac89156fd 100644
@@ -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
index e17311e09082..9d5d674735ea 100644
@@ -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
index 231db0305a03..5c154b20d6d4 100644
@@ -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
index c706db0ee9ec..3df29a7c5091 100644
@@ -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
index c133e8d64b2a..174b4e34f23e 100644
@@ -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
index 4944d78a0a1c..f638d00adfd9 100644
@@ -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
index 73be38a53796..5e5ed71d29cd 100644
@@ -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
index b788ae4f47f0..f9f25a663d98 100644
@@ -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
index 0541dfce924d..f04a755416dd 100644
@@ -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
index c1edca3872c7..1f1998b80e7f 100644
@@ -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
index 7e07dae33d0f..0fabebd7244c 100644
@@ -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
index 188d9dfc297b..3dbbb19b29bc 100644
@@ -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
index c7d48d41e184..a6592b22bbb4 100644
@@ -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
index 7f4b2eba31d4..2b6379c18153 100644
@@ -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
index 1bc1579674e5..66aa905766e2 100644
@@ -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
author
#11 lore raw

RFC 8/8 arm: rockchip: drop unused field from rk8xx i2c node

In reply to Anand Moon

Drop unused rockchip,system-power-controller from rk8xx i2c node.

Cc Heiko Stuebner <[email protected]>
---
 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
index fb3cf005cc90..0a7290ab718d 100644
@@ -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
index c32e1d441cf7..334fa510995c 100644
@@ -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
index 16788209625b..4b280c4b4850 100644
@@ -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
index 77a47b9b756d..2076566a2c97 100644
@@ -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
index 6a51940398b5..251668fee14d 100644
@@ -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
index 0aeef23ca3db..15fc1caca852 100644
@@ -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
index 7525e3dd1fc1..d7663ebc798f 100644
@@ -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
index ba06e9f97ddc..98e48ecb473e 100644
@@ -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
index b1db924710c8..39acc472774d 100644
@@ -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
index 30f3d0470ad9..e21817237792 100644
@@ -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
maintainer
#12 lore raw
In reply to Anand Moon

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.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 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(-)
author
#13 lore raw

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.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.

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

maintainer
#14 lore raw

Am 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.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.

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.

#15 lore raw
In reply to Anand Moon
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.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(-)
#16 lore raw
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.html

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.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 -
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

maintainer
#17 lore raw

Hi,

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.html

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.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 -
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

#18 lore raw
In reply to Peter Geis
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.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 -
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

#19 lore raw
In reply to Peter Geis

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

author
#20 lore raw
In reply to Robin Murphy

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_REG
SLEEP_SET_OFF_REG1
SLEEP_SET_OFF_REG2
DCDC_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