diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2010-06-19 00:08:11 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-08-05 08:26:14 -0400 |
commit | c863a2368ced0e6df07121d13933ee0f5a5ee681 (patch) | |
tree | 1f246916a7f940aa1ac50b5a88a2729e81cdfc3a /arch/mips/jz4740/reset.c | |
parent | b200eff6d16cf53dfaf14eb6f1934890d2db2237 (diff) |
MIPS: JZ4740: Add power-management and system reset support
Add support for suspend/resume and poweroff/reboot on a JZ4740 SoC.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/1398/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/jz4740/reset.c')
-rw-r--r-- | arch/mips/jz4740/reset.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/arch/mips/jz4740/reset.c b/arch/mips/jz4740/reset.c new file mode 100644 index 000000000000..5f1fb95c0d0d --- /dev/null +++ b/arch/mips/jz4740/reset.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> | ||
3 | * | ||
4 | * 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 | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * You should have received a copy of the GNU General Public License along | ||
10 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
11 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/io.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/pm.h> | ||
18 | |||
19 | #include <asm/reboot.h> | ||
20 | |||
21 | #include <asm/mach-jz4740/base.h> | ||
22 | #include <asm/mach-jz4740/timer.h> | ||
23 | |||
24 | static void jz4740_halt(void) | ||
25 | { | ||
26 | while (1) { | ||
27 | __asm__(".set push;\n" | ||
28 | ".set mips3;\n" | ||
29 | "wait;\n" | ||
30 | ".set pop;\n" | ||
31 | ); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | #define JZ_REG_WDT_DATA 0x00 | ||
36 | #define JZ_REG_WDT_COUNTER_ENABLE 0x04 | ||
37 | #define JZ_REG_WDT_COUNTER 0x08 | ||
38 | #define JZ_REG_WDT_CTRL 0x0c | ||
39 | |||
40 | static void jz4740_restart(char *command) | ||
41 | { | ||
42 | void __iomem *wdt_base = ioremap(JZ4740_WDT_BASE_ADDR, 0x0f); | ||
43 | |||
44 | jz4740_timer_enable_watchdog(); | ||
45 | |||
46 | writeb(0, wdt_base + JZ_REG_WDT_COUNTER_ENABLE); | ||
47 | |||
48 | writew(0, wdt_base + JZ_REG_WDT_COUNTER); | ||
49 | writew(0, wdt_base + JZ_REG_WDT_DATA); | ||
50 | writew(BIT(2), wdt_base + JZ_REG_WDT_CTRL); | ||
51 | |||
52 | writeb(1, wdt_base + JZ_REG_WDT_COUNTER_ENABLE); | ||
53 | jz4740_halt(); | ||
54 | } | ||
55 | |||
56 | #define JZ_REG_RTC_CTRL 0x00 | ||
57 | #define JZ_REG_RTC_HIBERNATE 0x20 | ||
58 | |||
59 | #define JZ_RTC_CTRL_WRDY BIT(7) | ||
60 | |||
61 | static void jz4740_power_off(void) | ||
62 | { | ||
63 | void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x24); | ||
64 | uint32_t ctrl; | ||
65 | |||
66 | do { | ||
67 | ctrl = readl(rtc_base + JZ_REG_RTC_CTRL); | ||
68 | } while (!(ctrl & JZ_RTC_CTRL_WRDY)); | ||
69 | |||
70 | writel(1, rtc_base + JZ_REG_RTC_HIBERNATE); | ||
71 | jz4740_halt(); | ||
72 | } | ||
73 | |||
74 | void jz4740_reset_init(void) | ||
75 | { | ||
76 | _machine_restart = jz4740_restart; | ||
77 | _machine_halt = jz4740_halt; | ||
78 | pm_power_off = jz4740_power_off; | ||
79 | } | ||