/* * * Gary Jennejohn * Copyright (C) 2003 Gary Jennejohn * * ######################################################################## * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * * ######################################################################## * * Reset the VR9 reference board. * */ #include #include #include #include #include #include #include #include static void ifx_machine_restart(char *command) { local_irq_disable(); #if defined(CONFIG_AR9) *IFX_RCU_PPE_CONF &= ~(3 << 30); // workaround for AFE (enable_afe) abnormal behavior #endif *IFX_RCU_RST_REQ = IFX_RCU_RST_REQ_ALL; for (;;) { ; /* Do nothing */ } } static void ifx_machine_halt(void) { /* Disable interrupts and loop forever */ printk(KERN_NOTICE "System halted.\n"); local_irq_disable(); for (;;) { ; /* Do nothing */ } } /*--- #define POWER_OFF_GPIO ((16 * 2) + 4) ---*/ #define POWER_OFF_GPIO 45 /*--- ((16 * 2) + 13) ---*/ static void ifx_machine_power_off(void) { /* We can't power off without the user's assistance */ local_irq_disable(); printk(KERN_NOTICE "Power is turned off now.\n"); if(ifx_gpio_output_set(POWER_OFF_GPIO, IFX_GPIO_MODULE_SYSTEM) == IFX_ERROR) { printk(KERN_ERR "Power off failed.\n"); } else { printk(KERN_ERR "Power should be off ????\n"); } for (;;) { ; /* Do nothing */ } } void ifx_reboot_setup(void) { _machine_restart = ifx_machine_restart; _machine_halt = ifx_machine_halt; pm_power_off = ifx_machine_power_off; } int __init ifx_system_gpio_setup(void) { int ret; ret = ifx_gpio_register(IFX_GPIO_MODULE_SYSTEM); if(ret == IFX_ERROR) { printk(KERN_ERR "[%s] Error: Registering GPIO module ID %d failed!\n", __FUNCTION__, IFX_GPIO_MODULE_SYSTEM); panic("could not register power-ctrl-gpio\n"); } ifx_gpio_output_clear(POWER_OFF_GPIO, IFX_GPIO_MODULE_SYSTEM); return 0; } static void no_wait(void) { register volatile unsigned int a; register volatile unsigned int b; register volatile unsigned int c; do { c = a * b; b = a * c; a = b * c; } while( (*((volatile unsigned int *)(0xBF880200 + 0x00)) == 0) && (*((volatile unsigned int *)(0xBF880200 + 0x28)) == 0) && (*((volatile unsigned int *)(0xBF880200 + 0x50)) == 0) && (*((volatile unsigned int *)(0xBF880200 + 0x78)) == 0) && (*((volatile unsigned int *)(0xBF880200 + 0xA0)) == 0)); } extern void (*cpu_wait)(void); extern void r4k_wait(void); extern void r4k_wait_irqoff(void); static int __init wait_setup(char *p) { printk(KERN_ERR "[%s] param: '%s'\n", __FUNCTION__, p); if(!strcmp(p, "r4k_wait")) { printk(KERN_ERR "[%s] set kernel-idle-function to '%s'\n", __FUNCTION__, p); cpu_wait = r4k_wait; } if(!strcmp(p, "r4k_wait_irqoff")) { printk(KERN_ERR "[%s] set kernel-idle-function to '%s'\n", __FUNCTION__, p); cpu_wait = r4k_wait_irqoff; } if(!strcmp(p, "no_wait")) { printk(KERN_ERR "[%s] set kernel-idle-function to '%s'\n", __FUNCTION__, p); cpu_wait = no_wait; } return 0; } __setup("wait=", wait_setup); late_initcall(ifx_system_gpio_setup);