[U-Boot] [PATCH v2 2/3] 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 --- v2: Fixup STPMIC1 config selection of CONFIG_SYSRESET_CMD_POWEROFF --- arch/Kconfig | 1 + arch/arm/mach-stm32mp/Makefile | 3 --- arch/arm/mach-stm32mp/cmd_poweroff.c | 24 drivers/power/pmic/Kconfig | 1 + drivers/sysreset/Kconfig | 10 ++ drivers/sysreset/sysreset-uclass.c | 18 ++ 6 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 arch/arm/mach-stm32mp/cmd_poweroff.c diff --git a/arch/Kconfig b/arch/Kconfig index 239289b885..83ff21dfd7 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -91,6 +91,7 @@ config SANDBOX select LZO select SPI select SUPPORT_OF_CONTROL + select SYSRESET_CMD_POWEROFF if CMD_POWEROFF imply BITREVERSE select BLOBLIST imply CMD_DM diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile index 1493914a11..f59ced5ee1 100644 --- a/arch/arm/mach-stm32mp/Makefile +++ b/arch/arm/mach-stm32mp/Makefile @@ -11,9 +11,6 @@ ifdef CONFIG_SPL_BUILD obj-y += spl.o else obj-y += bsec.o -ifndef CONFIG_STM32MP1_TRUSTED -obj-$(CONFIG_SYSRESET) += cmd_poweroff.o -endif endif obj-$(CONFIG_ARMV7_PSCI) += psci.o obj-$(CONFIG_$(SPL_)DM_REGULATOR) += pwr_regulator.o diff --git a/arch/arm/mach-stm32mp/cmd_poweroff.c b/arch/arm/mach-stm32mp/cmd_poweroff.c deleted file mode 100644 index 62347425a0..00 --- a/arch/arm/mach-stm32mp/cmd_poweroff.c +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -/* - * Copyright (C) 2019, STMicroelectronics - All Rights Reserved - */ - -#include -#include -#include - -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; -} diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index b0cd260354..52edb29b48 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -234,6 +234,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 30aed2c4c1..4c883923bf 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) -- 2.21.0 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 2/3] sysreset: move stm32mp sysreset poweroff implementation to sysreset uclass
Hi Urja, > > 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: Patrick Delaunay Tested on stm32mp1-ev1 with 2 other corrections: [U-Boot] pmic: stpmic1: add support for SYSRESET_POWER_OFF http://patchwork.ozlabs.org/patch/1101856/ [U-Boot] sysreset: syscon: add support for power off http://patchwork.ozlabs.org/patch/1101905/ Tested-by: Patrick Delaunay > --- > v2: Fixup STPMIC1 config selection of CONFIG_SYSRESET_CMD_POWEROFF > --- > arch/Kconfig | 1 + > arch/arm/mach-stm32mp/Makefile | 3 --- > arch/arm/mach-stm32mp/cmd_poweroff.c | 24 > drivers/power/pmic/Kconfig | 1 + > drivers/sysreset/Kconfig | 10 ++ > drivers/sysreset/sysreset-uclass.c | 18 ++ > 6 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 > arch/arm/mach-stm32mp/cmd_poweroff.c > > diff --git a/arch/Kconfig b/arch/Kconfig index 239289b885..83ff21dfd7 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -91,6 +91,7 @@ config SANDBOX > select LZO > select SPI > select SUPPORT_OF_CONTROL > + select SYSRESET_CMD_POWEROFF if CMD_POWEROFF > imply BITREVERSE > select BLOBLIST > imply CMD_DM > diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile > index 1493914a11..f59ced5ee1 100644 > --- a/arch/arm/mach-stm32mp/Makefile > +++ b/arch/arm/mach-stm32mp/Makefile > @@ -11,9 +11,6 @@ ifdef CONFIG_SPL_BUILD obj-y += spl.o else obj-y += > bsec.o -ifndef CONFIG_STM32MP1_TRUSTED > -obj-$(CONFIG_SYSRESET) += cmd_poweroff.o -endif endif > obj-$(CONFIG_ARMV7_PSCI) += psci.o > obj-$(CONFIG_$(SPL_)DM_REGULATOR) += pwr_regulator.o diff --git > a/arch/arm/mach-stm32mp/cmd_poweroff.c b/arch/arm/mach- > stm32mp/cmd_poweroff.c > deleted file mode 100644 > index 62347425a0..00 > --- a/arch/arm/mach-stm32mp/cmd_poweroff.c > +++ /dev/null > @@ -1,24 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause > -/* > - * Copyright (C) 2019, STMicroelectronics - All Rights Reserved > - */ > - > -#include > -#include > -#include > - > -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; > -} > diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index > b0cd260354..52edb29b48 100644 > --- a/drivers/power/pmic/Kconfig > +++ b/drivers/power/pmic/Kconfig > @@ -234,6 +234,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 > 30aed2c4c1..4c883923bf 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) > -- > 2.21.0 Regards Patrick Delaunay ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de
Re: [U-Boot] [PATCH v2 2/3] sysreset: move stm32mp sysreset poweroff implementation to sysreset uclass
Hi Urja On 5/16/19 11:48 PM, Urja Rannikko wrote: > 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 > --- > v2: Fixup STPMIC1 config selection of CONFIG_SYSRESET_CMD_POWEROFF > --- > arch/Kconfig | 1 + > arch/arm/mach-stm32mp/Makefile | 3 --- > arch/arm/mach-stm32mp/cmd_poweroff.c | 24 > drivers/power/pmic/Kconfig | 1 + > drivers/sysreset/Kconfig | 10 ++ > drivers/sysreset/sysreset-uclass.c | 18 ++ > 6 files changed, 30 insertions(+), 27 deletions(-) > delete mode 100644 arch/arm/mach-stm32mp/cmd_poweroff.c > > diff --git a/arch/Kconfig b/arch/Kconfig > index 239289b885..83ff21dfd7 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -91,6 +91,7 @@ config SANDBOX > select LZO > select SPI > select SUPPORT_OF_CONTROL > + select SYSRESET_CMD_POWEROFF if CMD_POWEROFF > imply BITREVERSE > select BLOBLIST > imply CMD_DM > diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile > index 1493914a11..f59ced5ee1 100644 > --- a/arch/arm/mach-stm32mp/Makefile > +++ b/arch/arm/mach-stm32mp/Makefile > @@ -11,9 +11,6 @@ ifdef CONFIG_SPL_BUILD > obj-y += spl.o > else > obj-y += bsec.o > -ifndef CONFIG_STM32MP1_TRUSTED > -obj-$(CONFIG_SYSRESET) += cmd_poweroff.o > -endif > endif > obj-$(CONFIG_ARMV7_PSCI) += psci.o > obj-$(CONFIG_$(SPL_)DM_REGULATOR) += pwr_regulator.o > diff --git a/arch/arm/mach-stm32mp/cmd_poweroff.c > b/arch/arm/mach-stm32mp/cmd_poweroff.c > deleted file mode 100644 > index 62347425a0..00 > --- a/arch/arm/mach-stm32mp/cmd_poweroff.c > +++ /dev/null > @@ -1,24 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause > -/* > - * Copyright (C) 2019, STMicroelectronics - All Rights Reserved > - */ > - > -#include > -#include > -#include > - > -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; > -} > diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig > index b0cd260354..52edb29b48 100644 > --- a/drivers/power/pmic/Kconfig > +++ b/drivers/power/pmic/Kconfig > @@ -234,6 +234,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 30aed2c4c1..4c883923bf 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) > Reviewed-by: Patrice Chotard Thanks ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot