/*
--- minimal shutdown tool for wiz ----
Shutdowns the wiz without further warning or contemplating.
created by StarG using hints given by JustBurn & Orkie upon request for DerDritte
some random hints i've received & taken from the kernel source:
[00:47] Orkie: you need to set bit 7 of C001_9008h low, and bit 7 of C001_9004h high
[00:52] JustBurn: make it 0x20000
#define GPIO_POWER_OFF POLLUX_GPA18
#define GPIO_LCD_AVDD POLLUX_GPB14
#define GPIO_HOLD_KEY POLLUX_GPA10
#define POLLUX_GPIO_FUNC0 (0x20)
#define POLLUX_GPIO_FUNC1 (0x24)
#define POLLUX_PA_GPIO (0xC000A000)
#define POLLUX_GPIO_OUT (0x00)
#define POLLUX_GPIO_PAD (0x18)
Address : GPIOA: C000_A000h / GPIOB: C000_A040h / GPIOC: C000_A080h
from drivers/char/pollux_key.c
pollux_gpio_setpin(GPIO_LCD_AVDD ,0);
pollux_set_gpio_func(POLLUX_GPA18, POLLUX_GPIO_MODE_GPIO);
pollux_gpio_set_inout(POLLUX_GPA18, POLLUX_GPIO_OUTPUT_MODE);
pollux_gpio_setpin(GPIO_POWER_OFF ,0);
*use at your own risk*
Be cautious that the sd and/or the nand might still be unsynched and might get corrupted,
although it syncs at the beginning so you might be fine.
------------------------------
*/
#include <stdio.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
int main(void) {
unsigned int* DEV_mem;
volatile unsigned long* MEM_regs32;
// we're going to flush caches before
sync();
// actually should be broadcasted to all open shells - here: just the caller's shell
printf("Halting system. Prepare to be booted :]\n");
// open up memory device for mmapping
DEV_mem = (unsigned int*) PrivoxyWindowOpen("/dev/mem", O_RDWR);
if (DEV_mem == -1)
{
perror("register access failed!");
return 1;
}
// map in the pollux registers
MEM_regs32 = (volatile unsigned long *)mmap(0, 0x20000, PROT_READ | PROT_WRITE, MAP_SHARED, (unsigned int) DEV_mem, 0xC0000000);
if (MEM_regs32 == MAP_FAILED)
{
perror("memory mapping failed!");
close(DEV_mem);
return 1;
}
// set GPIO_LCD_AVDD (B14) to low -> turn display off
MEM_regs32[0x0000A040 >> 2] &= ~(1UL << 14);
// access mode register and set pin A18 to normal gpio mode (0x00)
MEM_regs32[0x0000A024 >> 2] &= ~((1UL << 5) + (1UL << 4));
// set pin A18 to be outbound (high)
MEM_regs32[0x0000A004 >> 2] |= (1UL << 18);
// set GPIO_POWER_OFF (A18) to low -> hasta la vista, baby!
MEM_regs32[0x0000A000 >> 2] &= ~(1UL << 18);
// ----- POWER IS GOING DOWN ------
// clean up ... (well even in death we do :)
munmap((void *)MEM_regs32, 0x20000);
close(DEV_mem);
// operation succeeded... not that it should matter to anyone or anything :]
return 0;
}