Module Name:    src
Committed By:   jmcneill
Date:           Sun Jan 21 01:41:54 UTC 2024

Modified Files:
        src/sys/arch/evbppc/include: wii.h
        src/sys/arch/evbppc/wii: machdep.c

Log Message:
wii: support RB_POWERDOWN


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/include/wii.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbppc/include/wii.h
diff -u src/sys/arch/evbppc/include/wii.h:1.1 src/sys/arch/evbppc/include/wii.h:1.2
--- src/sys/arch/evbppc/include/wii.h:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/include/wii.h	Sun Jan 21 01:41:54 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wii.h,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: wii.h,v 1.2 2024/01/21 01:41:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill <jmcne...@invisible.ca>
@@ -99,7 +99,7 @@
 #define HW_ARMIRQMASK			(HOLLYWOOD_PRIV_BASE + 0x03c)
 #define HW_AHBPROT			(HOLLYWOOD_PRIV_BASE + 0x064)
 #define HW_GPIOB_OUT			(HOLLYWOOD_BASE + 0x0c0)
-#define HW_GPIO_OUT			(HOLLYWOOD_PRIV_BASE + 0x0e0)
+#define HW_GPIO_OWNER			(HOLLYWOOD_PRIV_BASE + 0x0fc)
 #define HW_RESETS			(HOLLYWOOD_PRIV_BASE + 0x194)
 #define  RSTB_IOP			__BIT(23)
 #define  RSTBINB			__BIT(0)
@@ -108,6 +108,7 @@
 #define  HWREV_MASK			__BITS(3,0)
 
 /* GPIOs */
+#define GPIO_SHUTDOWN			1
 #define GPIO_SLOT_LED			5
 
 /* Blink the slot LED forever at the specified interval. */

Index: src/sys/arch/evbppc/wii/machdep.c
diff -u src/sys/arch/evbppc/wii/machdep.c:1.1 src/sys/arch/evbppc/wii/machdep.c:1.2
--- src/sys/arch/evbppc/wii/machdep.c:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/wii/machdep.c	Sun Jan 21 01:41:54 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.2 2024/01/21 01:41:54 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2002, 2024 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #define _POWERPC_BUS_DMA_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.2 2024/01/21 01:41:54 jmcneill Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -379,17 +379,25 @@ cpu_reboot(int howto, char *what)
 	}
 	pmf_system_shutdown(boothowto);
 	doshutdownhooks();
+
+	disable_intr();
+
 	/* Force halt on panic to capture the cause on screen. */
 	if (panicstr != NULL) {
 		howto |= RB_HALT;
 	}
+	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
+		printf("power off\n\n");
+		out32(HW_GPIOB_OUT, in32(HW_GPIOB_OUT) | __BIT(GPIO_SHUTDOWN));
+		delay(100000);
+		printf("power off failed!\n\n");
+	}
 	if (howto & RB_HALT) {
 		printf("halted\n\n");
 		while (1);
 	}
 
 	printf("rebooting\n\n");
-	disable_intr();
 	out32(HW_RESETS, in32(HW_RESETS) & ~RSTBINB);
 	while (1);
 }
@@ -399,6 +407,9 @@ wii_setup(void)
 {
 	/* Turn on the drive slot LED. */
 	out32(HW_GPIOB_OUT, in32(HW_GPIOB_OUT) | __BIT(GPIO_SLOT_LED));
+
+	/* Enable PPC access to SHUTDOWN GPIO. */
+	out32(HW_GPIO_OWNER, in32(HW_GPIO_OWNER) | __BIT(GPIO_SHUTDOWN));
 }
 
 static void

Reply via email to