blob: 547f34b69e4c06a471032ab588b8391e62f0cc39 [file] [log] [blame]
Kelvin Cheungca585cf2012-07-25 16:17:24 +02001/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
Ralf Baechle70342282013-01-22 12:59:30 +01004 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
Kelvin Cheungca585cf2012-07-25 16:17:24 +02006 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/io.h>
11#include <linux/pm.h>
Ralf Baechlebdc92d742013-05-21 16:59:19 +020012#include <asm/idle.h>
Kelvin Cheungca585cf2012-07-25 16:17:24 +020013#include <asm/reboot.h>
14
15#include <loongson1.h>
16
17static void ls1x_restart(char *command)
18{
19 __raw_writel(0x1, LS1X_WDT_EN);
20 __raw_writel(0x5000000, LS1X_WDT_TIMER);
21 __raw_writel(0x1, LS1X_WDT_SET);
22}
23
24static void ls1x_halt(void)
25{
26 while (1) {
27 if (cpu_wait)
28 cpu_wait();
29 }
30}
31
32static void ls1x_power_off(void)
33{
34 ls1x_halt();
35}
36
37static int __init ls1x_reboot_setup(void)
38{
39 _machine_restart = ls1x_restart;
40 _machine_halt = ls1x_halt;
41 pm_power_off = ls1x_power_off;
42
43 return 0;
44}
45
46arch_initcall(ls1x_reboot_setup);