From 8f0a70e8162e350fa32122ff7bee78ce9178b0cf Mon Sep 17 00:00:00 2001 From: Kever Yang Date: Fri, 19 Jul 2019 11:23:47 +0800 Subject: core: ofnode: do not assert if node not valid in ofnode_get_name() In some case with LIVE DT, some node always not valid, or not have a valid name, eg. blk driver add by mmc. Return fail instead of Assert for this kind of ofnode, and this help with assert happen from time to time when of_live is enabled and DEBUG is enabled. Signed-off-by: Kever Yang Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 2ac73af934..e74a662d1d 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -212,7 +212,11 @@ ofnode ofnode_get_parent(ofnode node) const char *ofnode_get_name(ofnode node) { - assert(ofnode_valid(node)); + if (!ofnode_valid(node)) { + debug("%s node not valid\n", __func__); + return NULL; + } + if (ofnode_is_np(node)) return strrchr(node.np->full_name, '/') + 1; -- cgit From 857f39d7b09804566b23e0f20fcb04601f2ecb52 Mon Sep 17 00:00:00 2001 From: Urja Rannikko Date: Thu, 16 May 2019 21:48:41 +0000 Subject: sysreset: switch to using SYSRESET_POWER_OFF for poweroff It seems that SYSRESET_POWER_OFF was added recently, and all previous code used SYSRESET_POWER for poweroff. SYSRESET_POWER is supposed to be a PMIC-level power cycle, not a poweroff. (Comment by Simon Glass) SYSRESET_POWER means to do a power reset (removing and reinstating all power) SYSRESET_POWER_OFF means to turn the device off and leave it off Signed-off-by: Urja Rannikko Reviewed-by: Patrick Delaunay (Update comment to help understand the patch) Signed-off-by: Kever Yang --- drivers/sysreset/sysreset_psci.c | 2 +- drivers/sysreset/sysreset_sandbox.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/sysreset/sysreset_psci.c b/drivers/sysreset/sysreset_psci.c index de2ec8aeb1..c7907b3226 100644 --- a/drivers/sysreset/sysreset_psci.c +++ b/drivers/sysreset/sysreset_psci.c @@ -18,7 +18,7 @@ static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type) case SYSRESET_COLD: function_id = PSCI_0_2_FN_SYSTEM_RESET; break; - case SYSRESET_POWER: + case SYSRESET_POWER_OFF: function_id = PSCI_0_2_FN_SYSTEM_OFF; break; default: diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 7dfd89460f..69c22a7000 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -57,13 +57,13 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) case SYSRESET_COLD: state->last_sysreset = type; break; - case SYSRESET_POWER: + case SYSRESET_POWER_OFF: state->last_sysreset = type; if (!state->sysreset_allowed[type]) return -EACCES; sandbox_exit(); break; - case SYSRESET_POWER_OFF: + case SYSRESET_POWER: if (!state->sysreset_allowed[type]) return -EACCES; sandbox_exit(); -- cgit From b8050511c6ee4ab60ef4248dff42aff187696249 Mon Sep 17 00:00:00 2001 From: Urja Rannikko Date: Thu, 16 May 2019 21:48:42 +0000 Subject: sysreset: move stm32mp sysreset poweroff implementation to sysreset uclass This is a generic implementation. Add CONFIG_SYSRESET_CMD_POWEROFF to signal when we need it. Enable it from the STPMIC1 config and in sandbox. The config flag is transitionary, that is it can be removed after all poweroff implementations use sysreset, and just have CMD_POWEROFF depend on sysreset. Signed-off-by: Urja Rannikko Reviewed-by: Patrice Chotard Reviewed-by: Patrick Delaunay Tested-by: Patrick Delaunay --- drivers/power/pmic/Kconfig | 1 + drivers/sysreset/Kconfig | 10 ++++++++++ drivers/sysreset/sysreset-uclass.c | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) (limited to 'drivers') diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index cb1d10b2a9..586772fdec 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -241,6 +241,7 @@ config DM_PMIC_TPS65910 config PMIC_STPMIC1 bool "Enable support for STMicroelectronics STPMIC1 PMIC" depends on DM_PMIC && DM_I2C + select SYSRESET_CMD_POWEROFF if CMD_POWEROFF && !ARM_PSCI_FW ---help--- The STPMIC1 PMIC provides 4 BUCKs, 6 LDOs, 1 VREF and 2 power switches. It is accessed via an I2C interface. The device is used with STM32MP1 diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig index 90c41ab44d..f565ae0310 100644 --- a/drivers/sysreset/Kconfig +++ b/drivers/sysreset/Kconfig @@ -33,6 +33,16 @@ config TPL_SYSRESET if SYSRESET +if CMD_POWEROFF + +config SYSRESET_CMD_POWEROFF + bool "sysreset implementation of the poweroff command" + help + This should be selected by the appropriate PMIC driver if + the poweroff command is enabled. + +endif + config SYSRESET_GPIO bool "Enable support for GPIO reset driver" select DM_GPIO diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index ad831c703a..39202588ae 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -118,6 +118,24 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } +#if IS_ENABLED(CONFIG_SYSRESET_CMD_POWEROFF) +int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int ret; + + puts("poweroff ...\n"); + mdelay(100); + + ret = sysreset_walk(SYSRESET_POWER_OFF); + + if (ret == -EINPROGRESS) + mdelay(1000); + + /*NOTREACHED when power off*/ + return CMD_RET_FAILURE; +} +#endif + static int sysreset_post_bind(struct udevice *dev) { #if defined(CONFIG_NEEDS_MANUAL_RELOC) -- cgit