* [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi
@ 2015-12-20 15:41 Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command Hans de Goede
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Hans de Goede @ 2015-12-20 15:41 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command
2015-12-20 15:41 [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Hans de Goede
@ 2015-12-20 15:41 ` Hans de Goede
2015-12-20 15:58 ` Tom Rini
2015-12-20 15:41 ` [U-Boot] [PATCH 2/4] sunxi: Implement poweroff support for axp152 pmic Hans de Goede
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2015-12-20 15:41 UTC (permalink / raw)
To: u-boot
From: Michael van Slingerland <michael@deviousops.nl>
Add a 'poweroff' command to boot commands, this only gets enabled if the
board Kconfig does a "select CMD_POWEROFF".
Signed-off-by: Michael van Slingerland <michael@deviousops.nl>
[hdegoede at redhat.com: Make the cmd conditional on a CMD_POWEROFF Kconfig]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
common/Kconfig | 3 +++
common/cmd_boot.c | 8 ++++++++
include/command.h | 3 +++
3 files changed, 14 insertions(+)
diff --git a/common/Kconfig b/common/Kconfig
index ccf5475..9d446bf 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -184,6 +184,9 @@ config CMD_XIMG
help
Extract a part of a multi-image.
+config CMD_POWEROFF
+ bool
+
endmenu
menu "Environment commands"
diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index 8f2e070..5a8f912 100644
--- a/common/cmd_boot.c
+++ b/common/cmd_boot.c
@@ -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
diff --git a/include/command.h b/include/command.h
index 2ae9b6c..30bc327 100644
--- a/include/command.h
+++ b/include/command.h
@@ -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
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/4] sunxi: Implement poweroff support for axp152 pmic
2015-12-20 15:41 [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command Hans de Goede
@ 2015-12-20 15:41 ` Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 3/4] sunxi: Implement poweroff support for axp209 pmic Hans de Goede
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2015-12-20 15:41 UTC (permalink / raw)
To: u-boot
Adds poweroff support for axp152 pmic.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/power/Kconfig | 1 +
drivers/power/axp152.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index e86dd72..de32828 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -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.
diff --git a/drivers/power/axp152.c b/drivers/power/axp152.c
index 2972586..cd07275 100644
--- a/drivers/power/axp152.c
+++ b/drivers/power/axp152.c
@@ -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;
+}
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 3/4] sunxi: Implement poweroff support for axp209 pmic
2015-12-20 15:41 [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 2/4] sunxi: Implement poweroff support for axp152 pmic Hans de Goede
@ 2015-12-20 15:41 ` Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 4/4] sunxi: Implement poweroff support for axp221 pmic Hans de Goede
2015-12-20 20:14 ` [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Ian Campbell
4 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2015-12-20 15:41 UTC (permalink / raw)
To: u-boot
From: Michael van Slingerland <michael@deviousops.nl>
Adds poweroff support for axp209 pmic.
Signed-off-by: Michael van Slingerland <michael@deviousops.nl>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/power/Kconfig | 1 +
drivers/power/axp209.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index de32828..52c9e61 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -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.
diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
index 71aa000..fc162a1 100644
--- a/drivers/power/axp209.c
+++ b/drivers/power/axp209.c
@@ -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;
+}
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 4/4] sunxi: Implement poweroff support for axp221 pmic
2015-12-20 15:41 [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Hans de Goede
` (2 preceding siblings ...)
2015-12-20 15:41 ` [U-Boot] [PATCH 3/4] sunxi: Implement poweroff support for axp209 pmic Hans de Goede
@ 2015-12-20 15:41 ` Hans de Goede
2015-12-20 20:14 ` [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Ian Campbell
4 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2015-12-20 15:41 UTC (permalink / raw)
To: u-boot
Adds poweroff support for axp221 pmic.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/power/Kconfig | 1 +
drivers/power/axp221.c | 12 ++++++++++++
include/axp221.h | 2 ++
3 files changed, 15 insertions(+)
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 52c9e61..dfd60aa 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -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.
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
index 65802e4..8acadf0 100644
--- a/drivers/power/axp221.c
+++ b/drivers/power/axp221.c
@@ -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;
+}
diff --git a/include/axp221.h b/include/axp221.h
index 0ee21b6..04cd8c2 100644
--- a/include/axp221.h
+++ b/include/axp221.h
@@ -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
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command
2015-12-20 15:41 ` [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command Hans de Goede
@ 2015-12-20 15:58 ` Tom Rini
0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2015-12-20 15:58 UTC (permalink / raw)
To: u-boot
On Sun, Dec 20, 2015 at 04:41:32PM +0100, Hans de Goede wrote:
> From: Michael van Slingerland <michael@deviousops.nl>
>
> Add a 'poweroff' command to boot commands, this only gets enabled if the
> board Kconfig does a "select CMD_POWEROFF".
>
> Signed-off-by: Michael van Slingerland <michael@deviousops.nl>
> [hdegoede at redhat.com: Make the cmd conditional on a CMD_POWEROFF Kconfig]
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> common/Kconfig | 3 +++
> common/cmd_boot.c | 8 ++++++++
> include/command.h | 3 +++
> 3 files changed, 14 insertions(+)
>
> diff --git a/common/Kconfig b/common/Kconfig
> index ccf5475..9d446bf 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -184,6 +184,9 @@ config CMD_XIMG
> help
> Extract a part of a multi-image.
>
> +config CMD_POWEROFF
> + bool
> +
> endmenu
>
> menu "Environment commands"
> diff --git a/common/cmd_boot.c b/common/cmd_boot.c
> index 8f2e070..5a8f912 100644
> --- a/common/cmd_boot.c
> +++ b/common/cmd_boot.c
> @@ -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"
> + ""
> +);
> +#endif
> diff --git a/include/command.h b/include/command.h
> index 2ae9b6c..30bc327 100644
> --- a/include/command.h
> +++ b/include/command.h
> @@ -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!
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi
2015-12-20 15:41 [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Hans de Goede
` (3 preceding siblings ...)
2015-12-20 15:41 ` [U-Boot] [PATCH 4/4] sunxi: Implement poweroff support for axp221 pmic Hans de Goede
@ 2015-12-20 20:14 ` Ian Campbell
4 siblings, 0 replies; 7+ messages in thread
From: Ian Campbell @ 2015-12-20 20:14 UTC (permalink / raw)
To: u-boot
On Sun, 2015-12-20 at 16:41 +0100, Hans de Goede wrote:
> 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 <ijc@hellion.org.uk>
#1 looks fine to me too, modulo Tom's comments.
Ian.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-12-20 20:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-20 15:41 [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 1/4] cmd_boot: Add a poweroff command Hans de Goede
2015-12-20 15:58 ` Tom Rini
2015-12-20 15:41 ` [U-Boot] [PATCH 2/4] sunxi: Implement poweroff support for axp152 pmic Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 3/4] sunxi: Implement poweroff support for axp209 pmic Hans de Goede
2015-12-20 15:41 ` [U-Boot] [PATCH 4/4] sunxi: Implement poweroff support for axp221 pmic Hans de Goede
2015-12-20 20:14 ` [U-Boot] [PATCH 0/4] Add a new poweroff command and implement it for sunxi Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox