sysreset: move stm32mp sysreset poweroff implementation to sysreset uclass
authorUrja Rannikko <urjaman@gmail.com>
Thu, 16 May 2019 21:48:42 +0000 (21:48 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Mon, 19 Aug 2019 04:43:26 +0000 (12:43 +0800)
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 <urjaman@gmail.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
arch/Kconfig
arch/arm/mach-stm32mp/Makefile
arch/arm/mach-stm32mp/cmd_poweroff.c [deleted file]
drivers/power/pmic/Kconfig
drivers/sysreset/Kconfig
drivers/sysreset/sysreset-uclass.c

index 949eb28..e510e97 100644 (file)
@@ -93,6 +93,7 @@ config SANDBOX
        select PCI_ENDPOINT
        select SPI
        select SUPPORT_OF_CONTROL
+       select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
        imply BITREVERSE
        select BLOBLIST
        imply CMD_DM
index 7745060..ad5fd46 100644 (file)
@@ -12,9 +12,6 @@ obj-y += spl.o
 else
 obj-y += bsec.o
 obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.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 (file)
index 6234742..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
-/*
- * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
- */
-
-#include <common.h>
-#include <command.h>
-#include <sysreset.h>
-
-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;
-}
index cb1d10b..586772f 100644 (file)
@@ -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
index 90c41ab..f565ae0 100644 (file)
@@ -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
index ad831c7..3920258 100644 (file)
@@ -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)