diff --git a/arch/mips/goldfish/Makefile b/arch/mips/goldfish/Makefile index 98c6e1a36ee595190d8d0b509102ce24aa19df08..2d2a0d3e0d719e838ef4cad46aed5ecbd873b250 100644 --- a/arch/mips/goldfish/Makefile +++ b/arch/mips/goldfish/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_GOLDFISH) += goldfish-platform.o obj-$(CONFIG_GOLDFISH) += goldfish-interrupt.o obj-$(CONFIG_GOLDFISH) += goldfish-time.o obj-$(CONFIG_GOLDFISH) += pm.o +obj-$(CONFIG_GOLDFISH) += goldfish-reset.o obj-$(CONFIG_MIPS_GOLDFISH_SWITCH) += switch.o diff --git a/arch/mips/goldfish/goldfish-reset.c b/arch/mips/goldfish/goldfish-reset.c new file mode 100644 index 0000000000000000000000000000000000000000..1da473d9efbacfd1ee42a0838f7f437f390a6412 --- /dev/null +++ b/arch/mips/goldfish/goldfish-reset.c @@ -0,0 +1,67 @@ +/* arch/mips/goldfish/goldfish-reset.c + * + * Goldfish Machine Reset Routines + * + * Copyright (C) 2007 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that 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. + * + */ + +#include <linux/init.h> +#include <linux/pm.h> +#include <linux/io.h> +#include <linux/of.h> + +#include <asm/idle.h> +#include <asm/reboot.h> +#include <asm/mips-boards/generic.h> + +#define GORESET 0x42 +#define GOSHUTDOWN 0x43 + +static struct device_node *dn; +static uint32_t base; +static unsigned int __iomem *softres_reg; + +static void mips_machine_restart(char *command) +{ + writel(GORESET, softres_reg); +} + +static void mips_machine_halt(void) +{ + writel(GOSHUTDOWN, softres_reg); +} + +static int __init mips_reboot_setup(void) +{ + if ((dn = of_find_node_by_name(NULL, "goldfish_reset")) == NULL) { + printk(KERN_WARNING "mips_reboot_setup() failed to " + "fetch device node \'goldfish_reset\'!\n"); + return -1; + } + + if (of_property_read_u32(dn, "reg", &base) < 0) { + printk(KERN_WARNING "mips_reboot_setup() failed to " + "fetch device base address property \'reg\'! %x\n", base); + return -1; + } + + softres_reg = ioremap(base, sizeof(unsigned int)); + + _machine_restart = mips_machine_restart; + _machine_halt = mips_machine_halt; + pm_power_off = mips_machine_halt; + + return 0; +} + +arch_initcall(mips_reboot_setup);