Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * pmu.c, Power Management Unit routines for NEC VR4100 series. | |
3 | * | |
4 | * Copyright (C) 2003-2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | */ | |
20 | #include <linux/init.h> | |
21 | #include <linux/kernel.h> | |
22 | #include <linux/smp.h> | |
23 | #include <linux/types.h> | |
24 | ||
25 | #include <asm/cpu.h> | |
26 | #include <asm/io.h> | |
27 | #include <asm/reboot.h> | |
28 | #include <asm/system.h> | |
29 | ||
30 | #define PMUCNT2REG KSEG1ADDR(0x0f0000c6) | |
31 | #define SOFTRST 0x0010 | |
32 | ||
33 | static inline void software_reset(void) | |
34 | { | |
35 | uint16_t val; | |
36 | ||
37 | switch (current_cpu_data.cputype) { | |
38 | case CPU_VR4122: | |
39 | case CPU_VR4131: | |
40 | case CPU_VR4133: | |
41 | val = readw(PMUCNT2REG); | |
42 | val |= SOFTRST; | |
43 | writew(val, PMUCNT2REG); | |
44 | break; | |
45 | default: | |
46 | break; | |
47 | } | |
48 | } | |
49 | ||
50 | static void vr41xx_restart(char *command) | |
51 | { | |
52 | local_irq_disable(); | |
53 | software_reset(); | |
54 | printk(KERN_NOTICE "\nYou can reset your system\n"); | |
55 | while (1) ; | |
56 | } | |
57 | ||
58 | static void vr41xx_halt(void) | |
59 | { | |
60 | local_irq_disable(); | |
61 | printk(KERN_NOTICE "\nYou can turn off the power supply\n"); | |
62 | while (1) ; | |
63 | } | |
64 | ||
65 | static void vr41xx_power_off(void) | |
66 | { | |
67 | local_irq_disable(); | |
68 | printk(KERN_NOTICE "\nYou can turn off the power supply\n"); | |
69 | while (1) ; | |
70 | } | |
71 | ||
72 | static int __init vr41xx_pmu_init(void) | |
73 | { | |
74 | _machine_restart = vr41xx_restart; | |
75 | _machine_halt = vr41xx_halt; | |
76 | _machine_power_off = vr41xx_power_off; | |
77 | ||
78 | return 0; | |
79 | } | |
80 | ||
81 | early_initcall(vr41xx_pmu_init); |