smol-gilbraltar/power.c

22 lines
405 B
C
Raw Normal View History

2024-12-23 00:46:17 +00:00
#include <bcm.h>
#include <mem.h>
#define PM_RSTC_WRCFG_FULL_RESET 0x20
void reboot(void) {
write32(ARM_PM_WDOG, ARM_PM_PASSWD | 1);
write32(ARM_PM_RSTC, ARM_PM_PASSWD | PM_RSTC_WRCFG_FULL_RESET);
for (;;)
; // wait for reset
}
void poweroff(void) {
__asm__ __volatile("mov x0, %0\n"
"smc #0\n" ::"r"(0x84000008UL) // function code SYSTEM_OFF
);
for (;;)
;
}