blob: 7c746d3458e71a93594760866f3933e6351bcc5a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Ralf Baechlefcdb27a2006-01-18 17:37:07 +00006 * Copyright (C) 2001, 06 by Ralf Baechle (ralf@linux-mips.org)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * Copyright (C) 2001 MIPS Technologies, Inc.
8 */
9#include <linux/kernel.h>
Paul Gortmaker73bc2562011-07-23 16:30:40 -040010#include <linux/export.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000011#include <linux/pm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/types.h>
13#include <linux/reboot.h>
Andrew Brestickerf45e3882015-03-25 10:25:44 -070014#include <linux/delay.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000015
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/reboot.h>
17
18/*
19 * Urgs ... Too many MIPS machines to handle this in a generic way.
20 * So handle all using function pointers to machine specific
21 * functions.
22 */
23void (*_machine_restart)(char *command);
24void (*_machine_halt)(void);
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000025void (*pm_power_off)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Ralf Baechlef8bf35a2006-12-10 15:09:38 +000027EXPORT_SYMBOL(pm_power_off);
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029void machine_restart(char *command)
30{
Ralf Baechle9414d362006-01-17 21:14:01 +000031 if (_machine_restart)
32 _machine_restart(command);
Andrew Brestickerf45e3882015-03-25 10:25:44 -070033
34#ifdef CONFIG_SMP
35 preempt_disable();
36 smp_send_stop();
37#endif
38 do_kernel_restart(command);
39 mdelay(1000);
40 pr_emerg("Reboot failed -- System halted\n");
41 local_irq_disable();
42 while (1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043}
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045void machine_halt(void)
46{
Ralf Baechle9414d362006-01-17 21:14:01 +000047 if (_machine_halt)
48 _machine_halt();
Andrew Brestickerf45e3882015-03-25 10:25:44 -070049
50#ifdef CONFIG_SMP
51 preempt_disable();
52 smp_send_stop();
53#endif
54 local_irq_disable();
55 while (1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056}
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058void machine_power_off(void)
59{
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000060 if (pm_power_off)
61 pm_power_off();
Andrew Brestickerf45e3882015-03-25 10:25:44 -070062
63#ifdef CONFIG_SMP
64 preempt_disable();
65 smp_send_stop();
66#endif
67 local_irq_disable();
68 while (1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069}