Skip to contentSkip to conversation

power: pmic: rk8xx: Fix power-on source check in SPL

PATCH In review Jonas Karlman 3 participants 5 messages Aug 3, 2023 – Sep 27, 2023 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 power: pmic: rk8xx: Fix power-on source check in SPL

The commit 30975fb73d51 ("rockchip: Add option to prevent booting on power plug-in") introduce an option to prevent booting a device when the device was powered on due to power plug-in instead of pressing a power button.

This feature works by checking the power-on source during PMIC probe and powers off the device if power-on source was power plug-in. This check currently runs very late at PMIC probe in U-Boot proper.

Fix so that the power-on source check can work at probe time in SPL. Also enable probe after bind and remove the PMIC banner in SPL.

With this we can use ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON and SPL_PMIC_RK8XX to power off the device very quickly after TPL instead of after TF-A and U-Boot proper has been loaded and run.

DDR V1.18 f366f69a7d typ 23/07/17-15:48:58
ln
LP4/4x derate en, other dram:1x trefi
ddrconfig:7
LPDDR4X, 324MHz
BW=32 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=16 Size=8192MB

change to: 324MHz
clk skew:0x64

change to: 528MHz
clk skew:0x58

change to: 780MHz
clk skew:0x58

change to: 1056MHz(final freq)
clk skew:0x40
out
Power Off due to plug-in event

Fixes 30975fb73d51 ("rockchip: Add option to prevent booting on power plug-in")
---
 drivers/power/pmic/rk8xx.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/power/pmic/rk8xx.c +13 -7
index 25ef621f8df4..4e3a17337eee 100644
@@ -156,6 +156,10 @@ static int rk8xx_bind(struct udevice *dev)
 	if (!children)
 		debug("%s: %s - no child found\n", __func__, dev->name);
 
+	if (IS_ENABLED(CONFIG_SPL_BUILD) &&
+	    IS_ENABLED(CONFIG_ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
 	/* Always return success for this device */
 	return 0;
 }
@@ -236,14 +240,16 @@ static int rk8xx_probe(struct udevice *dev)
 		      pmic_reg_read(dev, init_data[i].reg));
 	}
 
-	printf("PMIC:  RK%x ", show_variant);
+	if (!IS_ENABLED(CONFIG_SPL_BUILD)) {
+		printf("PMIC:  RK%x ", show_variant);
+		if (on_source && off_source)
+			printf("(on=0x%02x, off=0x%02x)",
+			       pmic_reg_read(dev, on_source),
+			       pmic_reg_read(dev, off_source));
+		printf("\n");
+	}
 
-	if (on_source && off_source)
-		printf("(on=0x%02x, off=0x%02x)",
-		       pmic_reg_read(dev, on_source),
-		       pmic_reg_read(dev, off_source));
-	printf("\n");
-	if (CONFIG_IS_ENABLED(ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON))
+	if (IS_ENABLED(CONFIG_ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON))
 		rk8xx_off_for_plugin(dev);
 
 	return 0;
Signature · 1 line
2.41.0
#1 lore raw

PATCH 2/2 rockchip: rk356x-u-boot: Add bootph-all to i2c0_xfer pinctrl node

A RK8XX PMIC is typically using i2c0 on RK356x devices. Add bootph-all to required pinctrl nodes to simplify use of the prevent booting on power plug-in option in SPL.

With the following Kconfig options and nodes in u-boot.dtsi the prevent booting on power plug-in option can work in SPL.

CONFIG_ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON=y
CONFIG_SPL_I2C=y
CONFIG_SPL_POWER=y
CONFIG_SPL_PINCTRL=y
CONFIG_SPL_PMIC_RK8XX=y

  &i2c0 {
  	bootph-pre-ram;
  };
  
  &rk817 {
  	bootph-pre-ram;
  
  	regulators {
  		bootph-pre-ram;
  	};
  };
---
 arch/arm/dts/rk356x-u-boot.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/dts/rk356x-u-boot.dtsi +8 -0
index d21b18205220..fe7de0dd4bc8 100644
@@ -64,6 +64,10 @@
 	bootph-all;
 };
 
+&pcfg_pull_none_smt {
+	bootph-all;
+};
+
 &pcfg_pull_none {
 	bootph-all;
 };
@@ -100,6 +104,10 @@
 	bootph-all;
 };
 
+&i2c0_xfer {
+	bootph-all;
+};
+
 &sdmmc0_bus4 {
 	bootph-all;
 };
Signature · 1 line
2.41.0
#2 lore raw

Re: [PATCH 2/2] rockchip: rk356x-u-boot: Add bootph-all to i2c0_xfer pinctrl node

Hi Jonas,

Quoted 4 lines · Jonas Karlman

A RK8XX PMIC is typically using i2c0 on RK356x devices. Add bootph-all to required pinctrl nodes to simplify use of the prevent booting on power plug-in option in SPL.

I'd say this should be added to device-specific DTSes whenever appropriate and not to the SoC-specific DTSI. Not everybody's following to the letter the reference design. This also unnecessarily increases the size of the SPL DTSes for boards which aren't following the reference design.

Cheers,
Quentin

#3 lore raw

Re: [PATCH 2/2] rockchip: rk356x-u-boot: Add bootph-all to i2c0_xfer pinctrl node

Hi Quentin,

Quoted 8 lines · Quentin Schulz

Hi Jonas,

Quoted 4 lines · Jonas Karlman

A RK8XX PMIC is typically using i2c0 on RK356x devices. Add bootph-all to required pinctrl nodes to simplify use of the prevent booting on power plug-in option in SPL.

Quoted 5 lines

I'd say this should be added to device-specific DTSes whenever appropriate and not to the SoC-specific DTSI. Not everybody's following to the letter the reference design. This also unnecessarily increases the size of the SPL DTSes for boards which aren't following the reference design.

This only help ensures that the default pinctrl defined in rk356x.dtsi for i2c0 would be included in SPL dtb when the i2c0 node is enabled.

The size change is negligible, my Pine64 Quartz64-A u-boot-spl.dtb increase 185 bytes, from 5392 to 5577. And with u-boot-spl.bin at 139 KB SPL can grow an additional 117 KB until we reach size limit.

I mainly wanted to remove the need for duplicate definition in board u-boot.dtsi for upcoming devices like Pine64 PineNote and PineTab2.

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] rockchip: rk356x-u-boot: Add bootph-all to i2c0_xfer pinctrl node

In reply to Jonas Karlman
Quoted 25 lines · Jonas Karlman

A RK8XX PMIC is typically using i2c0 on RK356x devices. Add bootph-all to required pinctrl nodes to simplify use of the prevent booting on power plug-in option in SPL.

With the following Kconfig options and nodes in u-boot.dtsi the prevent booting on power plug-in option can work in SPL.

   CONFIG_ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON=y
   CONFIG_SPL_I2C=y
   CONFIG_SPL_POWER=y
   CONFIG_SPL_PINCTRL=y
   CONFIG_SPL_PMIC_RK8XX=y

   &i2c0 {
   	bootph-pre-ram;
   };
   
   &rk817 {
   	bootph-pre-ram;
   
   	regulators {
   		bootph-pre-ram;
   	};
   };
Quoted 1 line

Thanks,
- Kever

Quoted 30 lines
---
  arch/arm/dts/rk356x-u-boot.dtsi | 8 ++++++++
  1 file changed, 8 insertions(+)
arch/arm/dts/rk356x-u-boot.dtsi +8 -0
index d21b18205220..fe7de0dd4bc8 100644
@@ -64,6 +64,10 @@
  	bootph-all;
  };
 
+&pcfg_pull_none_smt {
+	bootph-all;
+};
+
  &pcfg_pull_none {
  	bootph-all;
  };
@@ -100,6 +104,10 @@
  	bootph-all;
  };
 
+&i2c0_xfer {
+	bootph-all;
+};
+
  &sdmmc0_bus4 {
  	bootph-all;
  };