Add a new poweroff command and implement it for sunxi
cover Add a new poweroff command and implement it for sunxi
Hi All,
I've had this idea that it would be good to have a poweroff command in u-boot in my head for a while now. The reason being that during u-boot development one often stays in just u-boot (e.g. when testing usb kbd support), when I'm then done testing having a poweroff command would be useful, esp. on devices with builtin batteries like tablets where one cannot just pull the powerplug.
So when Michael (in the Cc, author of 2 of the patches) asked me if there was a simple u-boot task he could help with I suggested adding a poweroff command, the result of which is this patch-set.
Tom, can you review the non sunxi specific cmd_boot patch (patch 1/4) please ?
Regards,
Hans
PATCH 1/4 cmd_boot: Add a poweroff command
From: Michael van Slingerland <[email protected]>
Add a 'poweroff' command to boot commands, this only gets enabled if the board Kconfig does a "select CMD_POWEROFF".
--- common/Kconfig | 3 +++ common/cmd_boot.c | 8 ++++++++ include/command.h | 3 +++ 3 files changed, 14 insertions(+)
common/Kconfig +3 -0
@@ -184,6 +184,9 @@ config CMD_XIMG help Extract a part of a multi-image. +config CMD_POWEROFF + bool + endmenu menu "Environment commands"
common/cmd_boot.c +8 -0
@@ -61,3 +61,11 @@ U_BOOT_CMD("Perform RESET of the CPU" ,"" ); + +#ifdef CONFIG_CMD_POWEROFF +U_BOOT_CMD ( + poweroff,1 ,0 , do_poweroff, +"Perform POWEROFF" , +"" +); +#endif
include/command.h +3 -0
@@ -110,6 +110,9 @@ extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]);extern int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#ifdef CONFIG_CMD_POWEROFF +extern int do_poweroff (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif /* * Error codes that commands return to cmd_process(). We use the standard 0
Signature · 1 line
2.5.0
PATCH 1/4 cmd_boot: Add a poweroff command
Quoted 33 lines · Hans de Goede
From: Michael van Slingerland <[email protected]>
Add a 'poweroff' command to boot commands, this only gets enabled if the board
Kconfigdoes a "selectCMD_POWEROFF".Signed-off-by Michael van Slingerland <[email protected]>[hdegoede at redhat.com: Make the cmd conditional on a CMD_POWEROFF Kconfig]Signed-off-by Hans de Goede <[email protected]>--- common/Kconfig | 3 +++ common/cmd_boot.c | 8 ++++++++ include/command.h | 3 +++ 3 files changed, 14 insertions(+)common/Kconfig +3
-0@@ -184,6 +184,9 @@ config CMD_XIMG help Extract a part of a multi-image. +config CMD_POWEROFF + bool + endmenu menu "Environment commands"common/cmd_boot.c +0
-0
common/cmd_boot.c U_BOOT_CMD( · line 68
Quoted 8 lines
common/cmd_boot.c +5
-0@@ -61,3 +61,11 @@ U_BOOT_CMD("Perform RESET of the CPU" ,"" ); + +#ifdef CONFIG_CMD_POWEROFF +U_BOOT_CMD( + poweroff, 1, 0, do_poweroff, + "Perform POWEROFF",
" of the device"
Quoted 8 lines
common/cmd_boot.c +3
-0+"" +); +#endif include/command.h +0
-0
include/command.h extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, · line 115
Quoted 6 lines
include/command.h +3
-0@@ -110,6 +110,9 @@ extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]);extern int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#ifdef CONFIG_CMD_POWEROFF +extern int do_poweroff (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif
No need for ifdef/endif (yes, there's others in the file like that but that's something to fix sometime). Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151220/d735c0f1/attachment.sig>
PATCH 2/4 sunxi: Implement poweroff support for axp152 pmic
In reply to Hans de GoedeAdds poweroff support for axp152 pmic.
--- drivers/power/Kconfig | 1 + drivers/power/axp152.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
drivers/power/Kconfig +1 -0
@@ -20,6 +20,7 @@ config SUNXI_NO_PMIC config AXP152_POWER boolean "axp152 pmic support" depends on MACH_SUN5I + select CMD_POWEROFF ---help--- Select this to enable support for the axp152 pmic found on most A10s boards.
drivers/power/axp152.c +12 -0
@@ -5,6 +5,7 @@* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> +#include <command.h> #include <asm/arch/pmic_bus.h> #include <axp_pmic.h>
@@ -78,3 +79,14 @@ int axp_init(void)return 0 ; } + +int do_poweroff (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +pmic_bus_write (AXP152_SHUTDOWN ,AXP152_POWEROFF ); + +/* infinite loop during shutdown */ +while (1 ) {} + +/* not reached */ +return 0 ; +}
Signature · 1 line
2.5.0
PATCH 3/4 sunxi: Implement poweroff support for axp209 pmic
In reply to Hans de GoedeFrom: Michael van Slingerland <[email protected]>
Adds poweroff support for axp209 pmic.
--- drivers/power/Kconfig | 1 + drivers/power/axp209.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
drivers/power/Kconfig +1 -0
@@ -28,6 +28,7 @@ config AXP152_POWER config AXP209_POWER boolean "axp209 pmic support" depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I + select CMD_POWEROFF ---help--- Select this to enable support for the axp209 pmic found on most A10, A13 and A20 boards.
drivers/power/axp209.c +12 -0
@@ -6,6 +6,7 @@*/ #include <common.h> +#include <command.h> #include <asm/arch/pmic_bus.h> #include <axp_pmic.h>
@@ -168,3 +169,14 @@ int axp_init(void)return 0 ; } + +int do_poweroff (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +pmic_bus_write (AXP209_SHUTDOWN ,AXP209_POWEROFF ); + +/* infinite loop during shutdown */ +while (1 ) {} + +/* not reached */ +return 0 ; +}
Signature · 1 line
2.5.0
PATCH 4/4 sunxi: Implement poweroff support for axp221 pmic
In reply to Hans de GoedeAdds poweroff support for axp221 pmic.
--- drivers/power/Kconfig | 1 + drivers/power/axp221.c | 12 ++++++++++++ include/axp221.h | 2 ++ 3 files changed, 15 insertions(+)
drivers/power/Kconfig +1 -0
@@ -36,6 +36,7 @@ config AXP209_POWER config AXP221_POWER boolean "axp221 / axp223 pmic support" depends on MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33 + select CMD_POWEROFF ---help--- Select this to enable support for the axp221/axp223 pmic found on most A23 and A31 boards.
drivers/power/axp221.c +12 -0
@@ -11,6 +11,7 @@*/ #include <common.h> +#include <command.h> #include <errno.h> #include <asm/arch/pmic_bus.h> #include <axp_pmic.h>
@@ -312,3 +313,14 @@ int axp_get_sid(unsigned int *sid)return 0 ; } + +int do_poweroff (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +pmic_bus_write (AXP221_SHUTDOWN ,AXP221_SHUTDOWN_POWEROFF ); + +/* infinite loop during shutdown */ +while (1 ) {} + +/* not reached */ +return 0 ; +}
include/axp221.h +2 -0
@@ -45,6 +45,8 @@#define AXP221_ALDO3_CTRL 0x2a#define AXP221_VBUS_IPSOUT 0x30#define AXP221_VBUS_IPSOUT_DRIVEBUS (1 << 2) +#define AXP221_SHUTDOWN 0x32 +#define AXP221_SHUTDOWN_POWEROFF (1 << 7)#define AXP221_MISC_CTRL 0x8f#define AXP221_MISC_CTRL_N_VBUSEN_FUNC (1 << 4)#define AXP221_PAGE 0xff
Signature · 1 line
2.5.0
cover Add a new poweroff command and implement it for sunxi
In reply to Hans de GoedeQuoted 8 lines · Hans de Goede
Hi All,
I've had this idea that it would be good to have a poweroff command in u-boot in my head for a while now. The reason being that during u-boot development one often stays in just u-boot (e.g. when testing usb kbd support), when I'm then done testing having a poweroff command would be useful, esp. on devices with builtin batteries like tablets where one cannot just pull the powerplug.
Patches #2..#4: Acked-by: Ian Campbell <[email protected]>
#1 looks fine to me too, modulo Tom's comments.
Ian.