Suspend to RAM support for K3 J7200
Subsystems (2)
cover Suspend to RAM support for K3 J7200
This series is the U-Boot part of the work to add the suspend to RAM support for the K3 J7200 EVM board.
During the boot R5 SPL makes a copy of DM-Firmware in memory. Resume detection is done by reading a magic value in a pmic register (set by DM-Firmware).
If a resume is detected, R5 SPL run the exit retention sequence of the DDR. Then it restores TF-A in SRAM (it saved itself to DDR), and load DM-Firmware using the copy done during the boot (fit image processing is skipped).
The copy of TF-A/DM-Firmware, the SPL stack and malloc are located in a reserved memory region (for the kernel point of view) to avoid any memory corruption.
A test_enter_sleep command was implemented to be able to test the suspend sequence from U-Boot. It is only for test, the resume will not work.
Gowtham Tammana (1):
DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm
Gregory CLEMENT (3):
configs: j7200_evm_r5: Used reserved memory in DDR for stack
configs: j7200_evm_r5: Move address used for allocation in the
reserved space
cmd: test_enter_suspend: Add test_enter_suspend command
Thomas Richard (5):
board: ti: j721e: Add resume detection for J7200
ram: k3-ddrss: Add exit retention support
board: ti: j721e: Add the missing part of exit retention for k3-ddrss
(J7200)
board: ti: j721e: During resume spl restores TF-A and DM-Firmware
arm: mach-k3: j7200: Skip fit processing when resuming
.../arm/dts/k3-j7200-r5-common-proc-board.dts | 17 +- arch/arm/mach-k3/common.c | 37 ++- arch/arm/mach-k3/include/mach/j721e_spl.h | 29 ++ arch/arm/mach-k3/sysfw-loader.c | 16 +- board/ti/j721e/evm.c | 79 +++++ cmd/Kconfig | 7 + cmd/boot.c | 8 + configs/j7200_evm_r5_defconfig | 4 +- drivers/firmware/psci.c | 23 ++ drivers/ram/k3-ddrss/k3-ddrss.c | 302 ++++++++++++++++++ include/command.h | 2 + 11 files changed, 514 insertions(+), 10 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/9 DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm
From: Gowtham Tammana <[email protected]>
Add pmic tps659413 node needed for ESM error event handling.
---
arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/arm/dts/k3-j7200-r5-common-proc-board.dts +14 -3
@@ -249,13 +249,24 @@ &wkup_i2c0 { bootph-pre-ram; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <400000>; + + tps659413: tps659413@48 { + compatible = "ti,tps659413"; + reg = <0x48>; + bootph-pre-ram; + + regulators_a: regulators { + bootph-pre-ram; + }; + }; + lp876441: lp876441@4c { compatible = "ti,lp876441"; reg = <0x4c>; bootph-pre-ram; - pinctrl-names = "default"; - pinctrl-0 = <&wkup_i2c0_pins_default>; - clock-frequency = <400000>; regulators: regulators { bootph-pre-ram;
Signature · 1 line
2.39.2
Re: [PATCH 1/9] DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm
Quoted 47 lines · Thomas Richard
From: Gowtham Tammana <[email protected]>
Add pmic tps659413 node needed for ESM error event handling.
Signed-off-by Gowtham Tammana <[email protected]>Signed-off-by Neha Malcom Francis <[email protected]>Signed-off-by Thomas Richard <[email protected]>---
arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)arch/arm/dts/k3-j7200-r5-common-proc-board.dts +14
-3@@ -249,13 +249,24 @@ &wkup_i2c0 { bootph-pre-ram; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <400000>; + + tps659413: tps659413@48 { + compatible = "ti,tps659413"; + reg = <0x48>; + bootph-pre-ram; + + regulators_a: regulators { + bootph-pre-ram; + }; + }; + lp876441: lp876441@4c { compatible = "ti,lp876441"; reg = <0x4c>; bootph-pre-ram; - pinctrl-names = "default"; - pinctrl-0 = <&wkup_i2c0_pins_default>; - clock-frequency = <400000>; regulators: regulators { bootph-pre-ram;Signature · 1 line
2.39.2
Please send these changes upstream linux kernel.
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Re: [PATCH 1/9] DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm
Quoted 43 lines · Nishanth Menon
Quoted 42 lines · Thomas Richard
From: Gowtham Tammana <[email protected]>
Add pmic tps659413 node needed for ESM error event handling.
Signed-off-by Gowtham Tammana <[email protected]>Signed-off-by Neha Malcom Francis <[email protected]>Signed-off-by Thomas Richard <[email protected]>---
arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)arch/arm/dts/k3-j7200-r5-common-proc-board.dts +14
-3@@ -249,13 +249,24 @@ &wkup_i2c0 { bootph-pre-ram; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <400000>; + + tps659413: tps659413@48 { + compatible = "ti,tps659413"; + reg = <0x48>; + bootph-pre-ram; + + regulators_a: regulators { + bootph-pre-ram; + }; + }; + lp876441: lp876441@4c { compatible = "ti,lp876441"; reg = <0x4c>; bootph-pre-ram; - pinctrl-names = "default"; - pinctrl-0 = <&wkup_i2c0_pins_default>; - clock-frequency = <400000>;
Quoted 7 lines
Quoted 5 lines
arch/arm/dts/k3-j7200-r5-common-proc-board.dts +0
-0regulators: regulators { bootph-pre-ram;Signature · 1 line
2.39.2Please send these changes upstream linux kernel.
Hi Nishanth,
I found this series
(https://lore.kernel.org/all/[email protected]/)
which includes a patch to create the two pmic nodes for j7200 target. It matches exactly my needs.
I found it was merged in TI linux kernel
https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi?h=ti-linux-6.1.y&id=0b3a445305b24aafba567909dac75961a0e8908c)
But referring to your answer
(https://lore.kernel.org/all/[email protected]/)
this series will not be merged upstream as is.
Should I send a single patch to declare pmics only for J7200 ? Could I just send a minimal definition of the pmics, or should I send a full definition (including regulators) ?
Regards,
Thomas
Re: [PATCH 1/9] DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm
Quoted 54 lines · Thomas Richard
Quoted 43 lines · Nishanth Menon
Quoted 42 lines · Thomas Richard
From: Gowtham Tammana <[email protected]>
Add pmic tps659413 node needed for ESM error event handling.
Signed-off-by Gowtham Tammana <[email protected]>Signed-off-by Neha Malcom Francis <[email protected]>Signed-off-by Thomas Richard <[email protected]>---
arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)arch/arm/dts/k3-j7200-r5-common-proc-board.dts +14
-3@@ -249,13 +249,24 @@ &wkup_i2c0 { bootph-pre-ram; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <400000>; + + tps659413: tps659413@48 { + compatible = "ti,tps659413"; + reg = <0x48>; + bootph-pre-ram; + + regulators_a: regulators { + bootph-pre-ram; + }; + }; + lp876441: lp876441@4c { compatible = "ti,lp876441"; reg = <0x4c>; bootph-pre-ram; - pinctrl-names = "default"; - pinctrl-0 = <&wkup_i2c0_pins_default>; - clock-frequency = <400000>;Quoted 7 lines
Quoted 5 lines
arch/arm/dts/k3-j7200-r5-common-proc-board.dts +0
-0regulators: regulators { bootph-pre-ram;Signature · 1 line
2.39.2Please send these changes upstream linux kernel.
Hi Nishanth,
Quoted 7 lines
I found this series
(https://lore.kernel.org/all/[email protected]/)
which includes a patch to create the two pmic nodes for j7200 target. It matches exactly my needs.I found it was merged in TI linux kernel
https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi?h=ti-linux-6.1.y&id=0b3a445305b24aafba567909dac75961a0e8908c)
I will skip commenting on TI vendor kernel and bootloader stuff.
Quoted 10 lines
But referring to your answer
(https://lore.kernel.org/all/[email protected]/)
this series will not be merged upstream as is.Should I send a single patch to declare pmics only for J7200 ? Could I just send a minimal definition of the pmics, or should I send a full definition (including regulators) ?
It will be good to discuss kernel patches in kernel.org mailing lists :)
But yeah - that series was pretty much close to getting merged before I had to drop when testing I do failed. If we are doing it, we'd need to do as a full definition (including regulators).. Though, I am disappointed at TI dropping the ball on this (Udit/Praneeth: hint - this is blocking additional progress).
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
PATCH 2/9 configs: j7200_evm_r5: Used reserved memory in DDR for stack
In reply to Thomas RichardFrom: Gregory CLEMENT <[email protected]>
When resuming from suspend to ram, we load again the DM firmware. However, we have to be sure to not modify the memory used by Linux.
Currently the SPL stack in DDR was in place that could be used by Linux. Instead of it use a memory address that is located in a reserved location that won't be used by Linux.
---
configs/j7200_evm_r5_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/j7200_evm_r5_defconfig +1 -1
@@ -20,7 +20,7 @@ CONFIG_DM_RESET=y CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y CONFIG_SPL_DRIVERS_MISC=y -CONFIG_SPL_STACK_R_ADDR=0x82000000 +CONFIG_SPL_STACK_R_ADDR=0xa5300000 CONFIG_SPL_FS_FAT=y CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_SPL_SPI_FLASH_SUPPORT=y
Signature · 1 line
2.39.2
PATCH 3/9 configs: j7200_evm_r5: Move address used for allocation in the reserved space
In reply to Thomas RichardFrom: Gregory CLEMENT <[email protected]>
Else it could corrupt the memory of Linux when exiting suspend to ram.
---
configs/j7200_evm_r5_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/j7200_evm_r5_defconfig +1 -1
@@ -39,7 +39,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SYS_SPL_MALLOC=y CONFIG_HAS_CUSTOM_SPL_MALLOC_START=y -CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x84000000 +CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0xa5400000 CONFIG_SYS_SPL_MALLOC_SIZE=0x1000000 CONFIG_SPL_EARLY_BSS=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
Signature · 1 line
2.39.2
PATCH 4/9 board: ti: j721e: Add resume detection for J7200
In reply to Thomas RichardAdd the capability to detect a resume.
To detect the resume, SPL searches a magic value (0xBA) in a register of PMICA.
This value is set by DM-Firmware during the suspend sequence.
Based on the work of Gregory CLEMENT <[email protected]>
---
board/ti/j721e/evm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
board/ti/j721e/evm.c +54 -0
@@ -22,6 +22,9 @@#include <spl.h> #include <dm.h> #include <dm/uclass-internal.h> +#if (IS_ENABLED (CONFIG_SPL_BUILD ) &&IS_ENABLED (CONFIG_TARGET_J7200_R5_EVM )) +#include <power/pmic.h> +#endif #include "../common/board_detect.h"
@@ -528,6 +531,57 @@ err_free_gpio: } } +#if (IS_ENABLED (CONFIG_SPL_BUILD ) &&IS_ENABLED (CONFIG_TARGET_J7200_R5_EVM )) + +#define SCRATCH_PAD_REG_3 0xCB + +#define MAGIC_SUSPEND 0xBA + +static int resuming =-1 ; + +int board_is_resuming (void ) +{ +struct udevice *pmica, *pmicb; +int ret; + +if (resuming >=0 ) + goto end; + + ret =uclass_get_device_by_name (UCLASS_PMIC , +"tps659413@48" , &pmica); +if (ret) { +printf ("Getting PMICA init failed: %d\n" , ret); + resuming =0 ; + goto end; + } +debug ("%s: PMICA is detected (%s)\n" , __func__, pmica->name); + + ret =uclass_get_device_by_name (UCLASS_PMIC , +"lp876441@4c" , &pmicb); +if (ret) { +printf ("Getting PMICB init failed: %d\n" , ret); + resuming =0 ; + goto end; + } +debug ("%s: PMICB is detected (%s)\n" , __func__, pmicb->name); + +if ((pmic_reg_read (pmica,SCRATCH_PAD_REG_3 ) ==MAGIC_SUSPEND )) { + resuming =1 ; +debug ("%s: board is resuming\n" , __func__); + +/* clean magic suspend */ +if (pmic_reg_write (pmica,SCRATCH_PAD_REG_3 ,0 )) +printf ("Failed to clean magic value for suspend detection in PMICA\n" ); + }else { + resuming =0 ; +debug ("%s: board is booting (no resume detected)\n" , __func__); + } +end: +return resuming; +} + +#endif /* CONFIG_SPL_BUILD && CONFIG_TARGET_J7200_R5_EVM */ +void spl_board_init (void ) {#if defined(CONFIG_ESM_K3 ) || defined(CONFIG_ESM_PMIC )
Signature · 1 line
2.39.2
PATCH 5/9 ram: k3-ddrss: Add exit retention support
In reply to Thomas RichardAdd the exit retention support.
The enter retention is done by DM-Firmware.
A part of the exit retention sequence is specific to the board. It is done in board_k3_ddrss_lpddr4_release_retention.
Based on the work of Gregory CLEMENT <[email protected]>
---
drivers/ram/k3-ddrss/k3-ddrss.c | 302 ++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+)
drivers/ram/k3-ddrss/k3-ddrss.c +302 -0
@@ -413,6 +413,303 @@ static int k3_ddrss_ofdata_to_priv(struct udevice *dev)return ret; } +void __weak board_k3_ddrss_lpddr4_release_retention (void ) {} + +int __weak board_is_resuming (void ) +{ +return 0 ; +} + +#define PLL12_CTRL 0x0068C020 + +#define k3_ddrss_readreg (k3_ddrss, block, shift, reg, pt) do { \ + u32 offset = 0U; \ + u32 result = 0U; \ + TH_OFFSET_FROM_REG(reg, shift, offset); \ + result = k3_ddrss->driverdt->readreg(&k3_ddrss->pd, block, offset, pt); \ + if (result > 0U) { \ + printf("%s: Failed to read %s\n", __func__, xstr(reg)); \ + hang(); \ + } \ + } while (0) + +#define k3_ddrss_writereg (k3_ddrss, block, shift, reg, value) do { \ + u32 offset = 0U; \ + u32 result = 0U; \ + TH_OFFSET_FROM_REG(reg, shift, offset); \ + result = k3_ddrss->driverdt->writereg(&k3_ddrss->pd, block, offset, value); \ + if (result > 0U) { \ + printf("%s: Failed to write %s\n", __func__, xstr(reg)); \ + hang(); \ + } \ + } while (0) + +#define k3_ddrss_readreg_ctl (ddrss, reg, pt) \ + k3_ddrss_readreg(ddrss, LPDDR4_CTL_REGS, CTL_SHIFT, reg, pt) + +#define k3_ddrss_readreg_pi (ddrss, reg, pt) \ + k3_ddrss_readreg(ddrss, LPDDR4_PHY_INDEP_REGS, PI_SHIFT, reg, pt) + +#define k3_ddrss_readreg_phy (ddrss, reg, pt) \ + k3_ddrss_readreg(ddrss, LPDDR4_PHY_REGS, PHY_SHIFT, reg, pt) + +#define k3_ddrss_writereg_ctl (ddrss, reg, value) \ + k3_ddrss_writereg(ddrss, LPDDR4_CTL_REGS, CTL_SHIFT, reg, value) + +#define k3_ddrss_writereg_pi (ddrss, reg, value) \ + k3_ddrss_writereg(ddrss, LPDDR4_PHY_INDEP_REGS, PI_SHIFT, reg, value) + +#define k3_ddrss_writereg_phy (ddrss, reg, value) \ + k3_ddrss_writereg(ddrss, LPDDR4_PHY_REGS, PHY_SHIFT, reg, value) + +#define k3_ddrss_set_ctl (k3_ddrss, reg, mask) do { \ + u32 val; \ + k3_ddrss_readreg_ctl(ddrss, reg, &val); \ + val |= mask; \ + k3_ddrss_writereg_ctl(ddrss, reg, val); \ + } while (0) + +#define k3_ddrss_clr_ctl (k3_ddrss, reg, mask) do { \ + u32 val; \ + k3_ddrss_readreg_ctl(ddrss, reg, &val); \ + val &= ~(mask); \ + k3_ddrss_writereg_ctl(ddrss, reg, val); \ + } while (0) + +#define k3_ddrss_set_pi (k3_ddrss, reg, mask) do { \ + u32 val; \ + k3_ddrss_readreg_pi(ddrss, reg, &val); \ + val |= mask; \ + k3_ddrss_writereg_pi(ddrss, reg, val); \ + } while (0) + +#define k3_ddrss_clr_pi (k3_ddrss, reg, mask) do { \ + u32 val; \ + k3_ddrss_readreg_pi(ddrss, reg, &val); \ + val &= ~(mask); \ + k3_ddrss_writereg_pi(ddrss, reg, val); \ + } while (0) + +#define k3_ddrss_set_phy (ddrss, reg, mask) do { \ + u32 val; \ + k3_ddrss_readreg_phy(ddrss, reg, &val); \ + val |= mask; \ + k3_ddrss_writereg_phy(ddrss, reg, val); \ + } while (0) + +#define k3_ddrss_clr_phy (ddrss, reg, mask) do { \ + u32 val; \ + k3_ddrss_readreg_phy(ddrss, reg, &val); \ + val &= ~(mask); \ + k3_ddrss_writereg_phy(ddrss, reg, val); \ + } while (0) + +static void k3_ddrss_lpddr4_exit_retention (struct k3_ddrss_desc *ddrss) +{ +u32 regval; +unsigned long tmo; +volatile unsigned int val; + +/* disable auto entry / exit */ +k3_ddrss_clr_ctl (ddrss,LPDDR4__LP_STATE_CS0__REG , (0xF <<24 ) | (0xF <<16 )); + +/* Configure DFI Interface, DDR retention exit occurs through PHY */ +k3_ddrss_readreg_phy (ddrss,LPDDR4__PHY_SET_DFI_INPUT_0__REG , ®val); + regval &= ~0xF0F ;// Set DFI_Input_1 = 0 + regval |=0x01 ;// Set DFI Input_0 = 1 +k3_ddrss_writereg_phy (ddrss,LPDDR4__PHY_SET_DFI_INPUT_0__REG , regval); + +/* PWRUP_SREFRESH_EXIT = 1 */ +k3_ddrss_set_ctl (ddrss,LPDDR4__PWRUP_SREFRESH_EXIT__REG ,0x1 ); + +/* PI_PWRUP_SREFRESH_EXIT = 0 */ +k3_ddrss_clr_ctl (ddrss,LPDDR4__PI_COL_DIFF__REG ,0x1 <<16 ); + +/* DFIBUS_BOOT_FREQ = 0 */ +k3_ddrss_clr_ctl (ddrss,LPDDR4__DFIBUS_BOOT_FREQ__REG ,0x3 ); + +/* DFIBUS_FREQ_INIT = 2 */ +k3_ddrss_readreg_ctl (ddrss,LPDDR4__PHY_INDEP_TRAIN_MODE__REG , ®val); + regval &= ~(0x3 <<24 ); + regval |= (0x1 <<24 ); +k3_ddrss_writereg_ctl (ddrss,LPDDR4__PHY_INDEP_TRAIN_MODE__REG , regval); + +/* Force Leveling during Initialization, Enable Link Training */ + +/* PI_INIT_LVL_EN = 1 */ +k3_ddrss_set_pi (ddrss,LPDDR4__PI_NORMAL_LVL_SEQ__REG , (1 <<8 )); + +/* PI_DRAM_INIT_EN = 0 */ +k3_ddrss_clr_pi (ddrss,LPDDR4__PI_DLL_RST__REG , (0x1 <<8 )); + +/* PI_DFI_PHYMSTR_STATE_SEL_R = 1 (force memory into self-refresh) */ +k3_ddrss_set_pi (ddrss,LPDDR4__PI_DFI_VERSION__REG , (1 <<24 )); + +/* PHY_INDEP_INIT_MODE = 0 */ +k3_ddrss_clr_ctl (ddrss,LPDDR4__PHY_INDEP_TRAIN_MODE__REG , (0x1 <<16 )); +/* PHY_INDEP_TRAIN_MODE = 1 */ +k3_ddrss_set_ctl (ddrss,LPDDR4__PHY_INDEP_TRAIN_MODE__REG ,0x1 ); + +/* PI_INIT_WORK_FREQ = 1 */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_INIT_WORK_FREQ__REG , ®val); + regval &= ~0x1F ; + regval |=0x01 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_INIT_WORK_FREQ__REG , regval); + +/* PI_FREQ_MAP[2:0] */ +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_FREQ_MAP__REG ,0x03 ); + +/* Training/leveling configurations for different frequency set points */ + +/* PI_CALVL_EN_F0 = 01b; PI_CALVL_EN_F1 = 01b; PI_CALVL_EN_F2 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_CALVL_EN_F0__REG , ®val); + regval &= ~0x030303 ; + regval |=0x010101 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_CALVL_EN_F0__REG , regval); + +/* PI_WRLVL_EN_F0 = 00b; PI_WRLVL_EN_F1 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_TDFI_CTRL_DELAY_F1__REG , ®val); + regval &= ~0x03030000 ; + regval |=0x01000000 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_TDFI_CTRL_DELAY_F1__REG , regval); + +/* PI_WRLVL_EN_F2 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_WRLVL_EN_F2__REG , ®val); + regval &= ~0x03 ; + regval |=0x01 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_WRLVL_EN_F2__REG , regval); + +/* PI_RDLVL_EN_F0 = 00b; PI_RDLVL_EN_F1 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F0__REG , ®val); + regval &= ~0x030003 ; + regval |=0x010000 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F0__REG , regval); + +/* PI_RDLVL_EN_F2 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F2__REG , ®val); + regval &= ~0x03 ; + regval |=0x01 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F2__REG , regval); + +/* PI_RDLVL_GATE_EN_F0 = 00b; PI_RDLVL_GATE_EN_F1 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F0__REG , ®val); + regval &= ~0x03000300 ; + regval |=0x01000000 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F0__REG , regval); + +/* PI_RDLVL_GATE_EN_F2 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F2__REG , ®val); + regval &= ~0x0300 ; + regval |=0x0100 ; +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_RDLVL_EN_F2__REG , regval); + +/* PI_WDQLVL_EN_F0 = 00b */ +k3_ddrss_clr_pi (ddrss,LPDDR4__PI_WDQLVL_VREF_DELTA_F0__REG , (0x3 <<8 )); + +/* PI_WDQLVL_EN_F1 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_WDQLVL_VREF_DELTA_F1__REG , ®val); + regval &= ~(0x3 <<24 ); + regval |= (0x1 <<24 ); +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_WDQLVL_VREF_DELTA_F1__REG , regval); + +/* PI_WDQLVL_EN_F2 = 01b */ +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_WDQLVL_VREF_DELTA_F2__REG , ®val); + regval &= ~(0x3 <<8 ); + regval |= (0x1 <<8 ); +k3_ddrss_writereg_pi (ddrss,LPDDR4__PI_WDQLVL_VREF_DELTA_F2__REG , regval); + + *(unsigned int *)PLL12_CTRL |=0x80000000 ; + val = *(volatile unsigned int *)PLL12_CTRL ; + +if ((val &0x80000000 ) !=0x80000000 ) + val = *(volatile unsigned int *)PLL12_CTRL ; + +board_k3_ddrss_lpddr4_release_retention (); + +/* LPC_SR_PHYMSTR_EN */ +k3_ddrss_clr_ctl (ddrss,LPDDR4__LPC_SR_CTRLUPD_EN__REG , (0x1 <<16 )); +/* PI_START=1 */ +k3_ddrss_set_pi (ddrss,LPDDR4__PI_START__REG ,0x01 ); +/* START=1 */ +k3_ddrss_set_ctl (ddrss,LPDDR4__START__REG ,0x01 ); + +debug ("%s: PPL12 = %x\n" , __func__, *(volatile unsigned int *)PLL12_CTRL ); + ddrss->ddr_fhs_cnt =5 ; +k3_lpddr4_freq_update (ddrss); +debug ("%s: PPL12 = %x\n" , __func__, *(volatile unsigned int *)PLL12_CTRL ); + + tmo =timer_get_us () +100000 ; +do { +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_INT_STATUS__REG , ®val); +debug ("%s: DDRSS_PI_79 = %x\n" , __func__, regval); +if (timer_get_us () > tmo) { +printf ("%s:%d timeout error\n" , __func__, __LINE__); +hang (); + } + }while ((regval & (1 <<0 )) ==0x00 ); + + tmo =timer_get_us () +4000 ; +do { +k3_ddrss_readreg_ctl (ddrss,LPDDR4__INT_STATUS_0__REG , ®val); +if (timer_get_us () > tmo) { +printf ("%s:%d timeout error\n" , __func__, __LINE__); +hang (); + } + }while ((regval & (1 <<9 )) ==0x00 ); + +k3_ddrss_readreg_pi (ddrss,LPDDR4__PI_INT_STATUS__REG , ®val); +debug ("%s: PI interrupt status: 0x%08x\n" , __func__, regval); + +k3_ddrss_readreg_ctl (ddrss,LPDDR4__INT_STATUS_0__REG , ®val); +debug ("%s: Controller interrupt status: 0x%08x\n" , __func__, regval); + +debug ("%s: Successfully exited Retention\n" , __func__); + +k3_ddrss_readreg_ctl (ddrss,LPDDR4__LP_STATE_CS0__REG , ®val); +debug ("%s: LP State: 0x%08x\n" , __func__, regval); + +k3_ddrss_writereg_ctl (ddrss,LPDDR4__INT_ACK_0__REG , (0x1 <<10 )); + +k3_ddrss_readreg_ctl (ddrss,LPDDR4__CKSRX_F1__REG , ®val); + regval &= ~(0x7F <<24 ); + regval |= (0x2 <<24 );// set low power mode exit +k3_ddrss_writereg_ctl (ddrss,LPDDR4__CKSRX_F1__REG , regval); + +k3_ddrss_readreg_ctl (ddrss,LPDDR4__LP_STATE_CS0__REG , ®val); +debug ("%s: LP State: 0x%08x\n" , __func__, regval); + +/* wait until low power operation has been completed */ + tmo =timer_get_us () +4000 ; +do { +k3_ddrss_readreg_ctl (ddrss,LPDDR4__INT_STATUS_0__REG , ®val); +if (timer_get_us () > tmo) { +printf ("%s:%d timeout error\n" , __func__, __LINE__); +hang (); + } + }while ((regval & (0x1 <<10 )) ==0 ); + +k3_ddrss_readreg_ctl (ddrss,LPDDR4__LP_STATE_CS0__REG , ®val); +debug ("%s: LP State: 0x%08x\n" , __func__, regval); + +k3_ddrss_writereg_ctl (ddrss,LPDDR4__INT_ACK_0__REG , (0x1 <<10 )); + +/* +* bit 6 / 14 -- lp_state valid +* bits 13:8 / 5:0 0x0F SRPD Long with Mem and Controller Clk Gating +*/ + tmo =timer_get_us () +4000 ; +do { +k3_ddrss_readreg_ctl (ddrss,LPDDR4__LP_STATE_CS0__REG , ®val); +if (timer_get_us () > tmo) { +printf ("%s:%d timeout error\n" , __func__, __LINE__); +hang (); + } + }while ((regval &0x4F4F ) !=0x4040 ); + +k3_ddrss_readreg_ctl (ddrss,LPDDR4__LP_STATE_CS0__REG , ®val); +debug ("%s: LP State: 0x%08x\n" , __func__, regval); +} +void k3_lpddr4_probe (struct k3_ddrss_desc *ddrss) {u32 status =0U ;
@@ -637,6 +934,11 @@ static int k3_ddrss_probe(struct udevice *dev)if (ret)return ret; +if (board_is_resuming ()) { +k3_ddrss_lpddr4_exit_retention (ddrss); +return 0 ; + } +k3_lpddr4_start (ddrss);if (ddrss->ti_ecc_enabled) {
Signature · 1 line
2.39.2
Re: [PATCH 5/9] ram: k3-ddrss: Add exit retention support
Hi Thomas!
On October 16, 2023 thus sayeth Thomas Richard:
Quoted 5 lines
Add the exit retention support.
The enter retention is done by DM-Firmware.
A part of the exit retention sequence is specific to the board. It is done inboard_k3_ddrss_lpddr4_release_retention.
Quoted 9 lines
Based on the work of Gregory CLEMENT <[email protected]>
Signed-off-by Thomas Richard <[email protected]>Signed-off-by Gregory CLEMENT <[email protected]>---
drivers/ram/k3-ddrss/k3-ddrss.c | 302 ++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+)
Do you mind putting this behind some type of Kconfig option? For the am62* class of devices the amount of SRAM we have is really stretched thin. I'm worried this may put us over the top.
~Bryan
Re: [PATCH 5/9] ram: k3-ddrss: Add exit retention support
Quoted 14 lines · Bryan Brattlof
Hi Thomas!
On October 16, 2023 thus sayeth Thomas Richard:
Quoted 11 lines
Add the exit retention support.
The enter retention is done by DM-Firmware.
A part of the exit retention sequence is specific to the board. It is done inboard_k3_ddrss_lpddr4_release_retention.Based on the work of Gregory CLEMENT <[email protected]>
Signed-off-by Thomas Richard <[email protected]>Signed-off-by Gregory CLEMENT <[email protected]>---
Quoted 7 lines
Quoted 3 lines
drivers/ram/k3-ddrss/k3-ddrss.c | 302 ++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+)Do you mind putting this behind some type of
Kconfigoption? For the am62* class of devices the amount of SRAM we have is really stretched thin. I'm worried this may put us over the top.
Hi Bryan,
Maybe I could put this behind the Kconfig option K3_J721E_DDRSS. K3_J721E_DDRSS is set if SOC_K3_J721E or SOC_K3_J721S2, and later SOC_K3_J784S4
(https://elixir.bootlin.com/u-boot/latest/source/drivers/ram/Kconfig#L65).
For now it was only tested on J7200, but we can assume that most of the code will be valid for J721S2 (and later J784S4).
And the code will not be compiled for am6*.
Regards,
Thomas
Quoted 2 lines
~Bryan
PATCH 6/9 board: ti: j721e: Add the missing part of exit retention for k3-ddrss (J7200)
In reply to Thomas RichardAdd the board specific part of the exit retention sequence for k3-ddrss
Based on the work of Gregory CLEMENT <[email protected]>
---
board/ti/j721e/evm.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
board/ti/j721e/evm.c +26 -1
@@ -533,15 +533,22 @@ err_free_gpio:#if (IS_ENABLED (CONFIG_SPL_BUILD ) &&IS_ENABLED (CONFIG_TARGET_J7200_R5_EVM )) +static struct udevice *pmica; +static struct udevice *pmicb; + +#define GPIO_OUT_1 0x3D +#define SCRATCH_PAD_REG_3 0xCB#define MAGIC_SUSPEND 0xBA +#define DDR_RET_VAL BIT(1) +#define DDR_RET_CLK BIT(2) +static int resuming =-1 ;int board_is_resuming (void ) { -struct udevice *pmica, *pmicb;int ret;if (resuming >=0 )
@@ -580,6 +587,24 @@ end: return resuming; } +void board_k3_ddrss_lpddr4_release_retention (void ) +{ +int regval; + +/* Set DDR_RET Signal Low on PMIC B */ + regval =pmic_reg_read (pmicb,GPIO_OUT_1 ) & ~DDR_RET_VAL ; + +pmic_reg_write (pmicb,GPIO_OUT_1 , regval); + +/* Now toggle the CLK of the latch for DDR ret */ +pmic_reg_write (pmicb,GPIO_OUT_1 , regval |DDR_RET_CLK ); +pmic_reg_write (pmicb,GPIO_OUT_1 , regval & ~(DDR_RET_CLK )); +pmic_reg_write (pmicb,GPIO_OUT_1 , regval |DDR_RET_CLK ); +pmic_reg_write (pmicb,GPIO_OUT_1 , regval & ~(DDR_RET_CLK )); + +pmic_reg_write (pmica,0x86 ,0x3 ); +} +#endif /* CONFIG_SPL_BUILD && CONFIG_TARGET_J7200_R5_EVM */ void spl_board_init (void )
Signature · 1 line
2.39.2
PATCH 7/9 board: ti: j721e: During resume spl restores TF-A and DM-Firmware
In reply to Thomas RichardDuring the boot a copy of DM-Firmware is done in a reserved memory area before it starts.
When resuming, R5 SPL uses this copy of DM-Firmware instead of the fit image.
TF-A which saved itself in this same memory area, is restored in SRAM by R5 SPL.
Based on the work of Gregory CLEMENT <[email protected]>
---
arch/arm/mach-k3/common.c | 37 ++++++++++++++++++++++- arch/arm/mach-k3/include/mach/j721e_spl.h | 29 ++++++++++++++++++ arch/arm/mach-k3/sysfw-loader.c | 9 ++++-- 3 files changed, 71 insertions(+), 4 deletions(-)
arch/arm/mach-k3/common.c +36 -1
@@ -26,6 +26,7 @@#include <env.h> #include <elf.h> #include <soc.h> +#include <hang.h> #if IS_ENABLED (CONFIG_SYS_K3_SPL_ATF ) enum {
@@ -221,6 +222,11 @@ void release_resources_for_core_shutdown(void) } } +__weak int board_is_resuming (void ) +{ +return 0 ; +} +void __noreturn jump_to_image_no_args (struct spl_image_info *spl_image) {typedef void __noreturn (*image_entry_noargs_t )(void );
@@ -235,6 +241,25 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)if (ret)panic ("rproc failed to be initialized (%d)\n" , ret); +if (board_is_resuming ()) { +#if IS_ENABLED (CONFIG_SOC_K3_J721E ) +if (!valid_elf_image (LPM_DM_SAVE )) +panic ("%s: DM-Firmware image is not valid, it cannot be loaded\n" , + __func__); + + loadaddr =load_elf_image_phdr (LPM_DM_SAVE ); + +memcpy ((void *)BL31_START , (void *)LPM_BL31_SAVE ,BL31_SIZE ); + + ret =rproc_load (1 , *(ulong *)(LPM_BL31_SAVE +BL31_SIZE ),BL31_SIZE ); +if (ret) +panic ("%s: ATF failed to load on rproc (%d)\n" , __func__, ret); + +debug ("%s: jumping to address %x\n" , __func__, loadaddr); + goto start_arm64; +#endif + } +init_env ();if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) {
@@ -289,8 +314,18 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) loadaddr =load_elf_image_phdr (loadaddr); }else { loadaddr = fit_image_info[IMAGE_ID_DM_FW ].image_start; -if (valid_elf_image (loadaddr)) +if (valid_elf_image (loadaddr)) { loadaddr =load_elf_image_phdr (loadaddr); +#if IS_ENABLED (CONFIG_SOC_K3_J721E ) +if (fit_image_info[IMAGE_ID_DM_FW ].image_len > (BUFFER_ADDR -LPM_DM_SAVE )) +log_warning ("%s\n: Not enough space to save DM-Firmware" , + __func__); +else +memcpy ((void *)LPM_DM_SAVE , + (void *)fit_image_info[IMAGE_ID_DM_FW ].image_start, + fit_image_info[IMAGE_ID_DM_FW ].image_len); +#endif + } }debug ("%s: jumping to address %x\n" , __func__, loadaddr);
arch/arm/mach-k3/include/mach/j721e_spl.h +29 -0
@@ -42,4 +42,33 @@#define K3_PRIMARY_BOOTMODE 0x0#define K3_BACKUP_BOOTMODE 0x1 +/* Starting buffer address is 1MB before the stack address in DDR */ +#define BUFFER_ADDR (CONFIG_SPL_STACK_R_ADDR - SZ_1M) + +/* BL31 TF-A is in the SRAM */ +#define BL31_START 0x70000000 + +/* This is actually the whole size of the SRAM */ +#define BL31_SIZE 0x20000 + +/* This address belongs to a reserved memory region for the point of view of +* Linux, U-boot SPL must use the same address to restore TF-A and resume +* entry point address +*/ +#define LPM_SAVE 0xA5000000 +#define LPM_BL31_SAVE LPM_SAVE +#define LPM_DM_SAVE LPM_BL31_SAVE + BL31_SIZE + __SIZEOF_POINTER__ + +/* Check if the copy of TF-A and DM-Firmware in DRAM does not overlap an +* over memory section. +* The resume address of TF-A is also saved in DRAM. +* At build time we don't know the DM-Firmware size, so we keep 512k to +* save it. +*/ +#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_TARGET_J7200_R5_EVM ) +#if ((LPM_DM_SAVE +SZ_512K ) >BUFFER_ADDR ) +#error Not enough space to save DM-Firmware, TF-A and context for S2R +#endif +#endif +#endif
arch/arm/mach-k3/sysfw-loader.c +6 -3
@@ -84,13 +84,16 @@ static bool sysfw_loaded;static void *sysfw_load_address;/* -* Populate SPL hook to override the default load address used by the SPL -* loader function with a custom address for SYSFW loading. +* Populate SPL hook to override the default load address used by the +* SPL loader function with a custom address for SYSFW loading. In +* other case use also a custom address located in a reserved memory +* region. It ensures that Linux memory won't be corrupted by SPL during +* suspend to ram. */ struct legacy_img_hdr *spl_get_load_buffer (ssize_t offset,size_t size) {if (sysfw_loaded) -return (struct legacy_img_hdr *)(CONFIG_TEXT_BASE + offset); +return (struct legacy_img_hdr *)(BUFFER_ADDR + offset);else if (sysfw_load_address)return sysfw_load_address;else
Signature · 1 line
2.39.2
PATCH 8/9 arm: mach-k3: j7200: Skip fit processing when resuming
In reply to Thomas RichardNo need to process fit image during resume.
All needed parts are already available in DRAM.
Based on the work of Gregory CLEMENT <[email protected]>
---
arch/arm/mach-k3/sysfw-loader.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/mach-k3/sysfw-loader.c +6 -1
@@ -100,6 +100,11 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)panic ("SYSFW load address not defined!" ); } +__weak int board_is_resuming (void ) +{ +return 0 ; +} +/* * Populate SPL hook to skip the default SPL loader FIT post-processing steps * during SYSFW loading and return to the calling function so we can perform
@@ -107,7 +112,7 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)*/ bool spl_load_simple_fit_skip_processing (void ) { -return !sysfw_loaded; +return board_is_resuming () ? true : !sysfw_loaded; } static int fit_get_data_by_name(const void *fit, int images, const char *name,
Signature · 1 line
2.39.2
PATCH 9/9 cmd: test_enter_suspend: Add test_enter_suspend command
In reply to Thomas RichardFrom: Gregory CLEMENT <[email protected]>
Add test_enter_suspend command using PSCI.
This command is only to test suspend sequence from U-Boot. The resume will not work.
---
cmd/Kconfig | 7 +++++++ cmd/boot.c | 8 ++++++++ drivers/firmware/psci.c | 23 +++++++++++++++++++++++ include/command.h | 2 ++ 4 files changed, 40 insertions(+)
cmd/Kconfig +7 -0
@@ -1450,6 +1450,13 @@ config CMD_POWEROFF help Poweroff/Shutdown the system +config CMD_TEST_ENTER_SUSPEND + bool "test enter suspend" + depends on ARM + select ARM_SMCCC + help + Command to test the suspend sequence (only for test) + config CMD_READ bool "read - Read binary data from a partition" help
cmd/boot.c +8 -0
@@ -70,3 +70,11 @@ U_BOOT_CMD("" );#endif + +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +U_BOOT_CMD ( + test_enter_suspend,1 ,0 , do_test_enter_suspend, +"Test the enter SUSPEND sequence of the device" , +"" +); +#endif
drivers/firmware/psci.c +23 -0
@@ -23,6 +23,9 @@#include <linux/libfdt.h> #include <linux/printk.h> #include <linux/psci.h> +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +#include <cpu_func.h> +#endif #define DRIVER_NAME "psci"
@@ -303,6 +306,26 @@ int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) }#endif +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +int do_test_enter_suspend (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{ +do_psci_probe (); + +puts ("suspend ...\n" ); +puts ("disable dcache\n" ); + +dcache_disable (); + +/* ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND */ +invoke_psci_fn (PSCI_0_2_FN64 (14 ), (unsigned long )do_test_enter_suspend,0 ,0 ); + +dcache_enable (); + +log_err ("Suspend failed or not supported on this platform\n" ); +return CMD_RET_FAILURE ; +} +#endif +static const struct udevice_id psci_of_match[] = { { .compatible ="arm,psci" }, { .compatible ="arm,psci-0.2" },
include/command.h +2 -0
@@ -177,6 +177,8 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);int do_poweroff (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_test_enter_suspend (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]);unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]);
Signature · 1 line
2.39.2
Re: [PATCH 9/9] cmd: test_enter_suspend: Add test_enter_suspend command
Quoted 71 lines · Thomas Richard
From: Gregory CLEMENT <[email protected]>
Add
test_enter_suspendcommand using PSCI.
This command is only to test suspend sequence from U-Boot. The resume will not work.Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Thomas Richard <[email protected]>---
cmd/Kconfig | 7 +++++++ cmd/boot.c | 8 ++++++++ drivers/firmware/psci.c | 23 +++++++++++++++++++++++ include/command.h | 2 ++ 4 files changed, 40 insertions(+)cmd/Kconfig +7
-0@@ -1450,6 +1450,13 @@ config CMD_POWEROFF help Poweroff/Shutdown the system +config CMD_TEST_ENTER_SUSPEND + bool "test enter suspend" + depends on ARM + select ARM_SMCCC + help + Command to test the suspend sequence (only for test) + config CMD_READ bool "read - Read binary data from a partition" helpcmd/boot.c +8
-0@@ -70,3 +70,11 @@ U_BOOT_CMD("" );#endif + +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +U_BOOT_CMD ( + test_enter_suspend,1 ,0 , do_test_enter_suspend, +"Test the enter SUSPEND sequence of the device" , +"" +); +#endif drivers/firmware/psci.c +5
-0@@ -23,6 +23,9 @@#include <linux/libfdt.h> #include <linux/printk.h> #include <linux/psci.h> +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +#include <cpu_func.h> +#endif #define DRIVER_NAME "psci"@@ -303,6 +306,26 @@ int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) }#endif +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +int do_test_enter_suspend (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[])
drivers/firmware/psci.c int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) · line 320
Quoted 10 lines
drivers/firmware/psci.c +10
-0+{ +do_psci_probe (); + +puts ("suspend ...\n" ); +puts ("disable dcache\n" ); + +dcache_disable (); + +/* ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND */ +invoke_psci_fn (PSCI_0_2_FN64 (14 ), (unsigned long )do_test_enter_suspend,0 ,0 );
Suspend exists on other architectures, too. E.g. OpenSBI provides an implementation for RISC-V. It would be preferable to add suspend as a value to enum enum sysreset_t. Then that functionality can be implemented in sysreset_psci.c sysreset_sbi.c, and others.
The command should simply be called 'suspend'.
Best regards
Heinrich
Quoted 24 lines
drivers/firmware/psci.c +8
-0+ +dcache_enable (); + +log_err ("Suspend failed or not supported on this platform\n" ); +return CMD_RET_FAILURE ; +} +#endif +static const struct udevice_id psci_of_match[] = { { .compatible ="arm,psci" }, { .compatible ="arm,psci-0.2" },include/command.h +2
-0@@ -177,6 +177,8 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);int do_poweroff (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_test_enter_suspend (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]);unsigned long do_go_exec (ulong (*entry)(int ,char *const []),int argc,char *const argv[]);
Re: [PATCH 9/9] cmd: test_enter_suspend: Add test_enter_suspend command
Quoted 91 lines · Heinrich Schuchardt
Quoted 74 lines · Thomas Richard
From: Gregory CLEMENT <[email protected]>
Add
test_enter_suspendcommand using PSCI.
This command is only to test suspend sequence from U-Boot. The resume will not work.Signed-off-by Gregory CLEMENT <[email protected]>Signed-off-by Thomas Richard <[email protected]>---
cmd/Kconfig | 7 +++++++ cmd/boot.c | 8 ++++++++
drivers/firmware/psci.c| 23 +++++++++++++++++++++++ include/command.h | 2 ++4 files changed, 40 insertions(+)cmd/Kconfig +0
-0@@ -1450,6 +1450,13 @@ config CMD_POWEROFFhelp
Poweroff/Shutdown the systemcmd/Kconfig +7
-0+config CMD_TEST_ENTER_SUSPEND + bool "test enter suspend" + depends on ARM + select ARM_SMCCC + help + Command to test the suspend sequence (only for test) +config
CMD_READ
bool "read - Read binary data from a partition" helpcmd/boot.c +0
-0@@ -70,3 +70,11 @@ U_BOOT_CMD(""
);
#endifcmd/boot.c +8
-0+ +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +U_BOOT_CMD( + test_enter_suspend, 1, 0, do_test_enter_suspend, + "Test the enter SUSPEND sequence of the device", + "" +); +#endif drivers/firmware/psci.c +6
-0@@ -23,6 +23,9 @@ #include <linux/libfdt.h> #include <linux/printk.h> #include <linux/psci.h> +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +#include <cpu_func.h> +#endif #define DRIVER_NAME "psci"@@ -303,6 +306,26 @@ int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } #endif +#if IS_ENABLED (CONFIG_CMD_TEST_ENTER_SUSPEND ) +int do_test_enter_suspend (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{drivers/firmware/psci.c int do_poweroff(struct cmd_tbl *cmdtp, int flag, · line 323
Quoted 10 lines
drivers/firmware/psci.c +9
-0+ do_psci_probe(); + + puts("suspend ...\n"); + puts("disable dcache\n"); + + dcache_disable(); + + /* ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND */ + invoke_psci_fn(PSCI_0_2_FN64(14), (unsignedlong )do_test_enter_suspend,0 ,0 );Suspend exists on other architectures, too. E.g. OpenSBI provides an implementation for RISC-V. It would be preferable to add suspend as a value to enum enum
sysreset_t. Then that functionality can be implemented insysreset_psci.csysreset_sbi.c, and others.
Quoted 1 line
The command should simply be called 'suspend'.
This command is only for development/test purpose. As-is, the resume will not work.
We wrote this command to help during the development, and test our suspend sequence without booting a Linux.
We didn't plan to support suspend/resume from U-Boot. So I will remove this patch.
Best Regards,
Thomas
Quoted 5 lines
Best regards
Heinrich