Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Steven J. Hill | b72d9a4 | 2013-06-13 19:55:06 +0000 | [diff] [blame] | 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Carsten Langgaard, carstenl@mips.com |
| 7 | * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
Steven J. Hill | b72d9a4 | 2013-06-13 19:55:06 +0000 | [diff] [blame] | 9 | #include <linux/io.h> |
Ralf Baechle | fcdb27a | 2006-01-18 17:37:07 +0000 | [diff] [blame] | 10 | #include <linux/pm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/reboot.h> |
Paul Burton | dadaa1c | 2014-05-07 12:22:12 +0100 | [diff] [blame] | 13 | #include <asm/mach-malta/malta-pm.h> |
Steven J. Hill | 36a29af | 2013-06-13 19:55:05 +0000 | [diff] [blame] | 14 | |
| 15 | #define SOFTRES_REG 0x1f000500 |
| 16 | #define GORESET 0x42 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | static void mips_machine_restart(char *command) |
| 19 | { |
Dmitri Vorobiev | 84c21e2 | 2008-01-08 06:44:00 +0300 | [diff] [blame] | 20 | unsigned int __iomem *softres_reg = |
| 21 | ioremap(SOFTRES_REG, sizeof(unsigned int)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Dmitri Vorobiev | 84c21e2 | 2008-01-08 06:44:00 +0300 | [diff] [blame] | 23 | __raw_writel(GORESET, softres_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | static void mips_machine_halt(void) |
| 27 | { |
Paul Burton | 37e5c83 | 2014-05-07 12:20:59 +0100 | [diff] [blame] | 28 | while (true); |
| 29 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Paul Burton | 37e5c83 | 2014-05-07 12:20:59 +0100 | [diff] [blame] | 31 | static void mips_machine_power_off(void) |
| 32 | { |
Paul Burton | dadaa1c | 2014-05-07 12:22:12 +0100 | [diff] [blame] | 33 | mips_pm_suspend(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF); |
| 34 | |
| 35 | pr_info("Failed to power down, resetting\n"); |
Paul Burton | 37e5c83 | 2014-05-07 12:20:59 +0100 | [diff] [blame] | 36 | mips_machine_restart(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Ralf Baechle | 1f320d0 | 2009-09-15 14:50:39 +0200 | [diff] [blame] | 39 | static int __init mips_reboot_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | { |
| 41 | _machine_restart = mips_machine_restart; |
| 42 | _machine_halt = mips_machine_halt; |
Paul Burton | 37e5c83 | 2014-05-07 12:20:59 +0100 | [diff] [blame] | 43 | pm_power_off = mips_machine_power_off; |
Ralf Baechle | 1f320d0 | 2009-09-15 14:50:39 +0200 | [diff] [blame] | 44 | |
| 45 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |
Ralf Baechle | 1f320d0 | 2009-09-15 14:50:39 +0200 | [diff] [blame] | 47 | arch_initcall(mips_reboot_setup); |