ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / vr41xx / common / pmu.c
1 /*
2  *  pmu.c, Power Management Unit routines for NEC VR4100 series.
3  *
4  *  Copyright (C) 2003  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/smp.h>
22 #include <linux/types.h>
23
24 #include <asm/cpu.h>
25 #include <asm/io.h>
26 #include <asm/reboot.h>
27 #include <asm/system.h>
28
29 #define PMUCNT2REG      KSEG1ADDR(0x0f0000c6)
30  #define SOFTRST        0x0010
31
32 static inline void software_reset(void)
33 {
34         uint16_t val;
35
36         switch (current_cpu_data.cputype) {
37         case CPU_VR4122:
38         case CPU_VR4131:
39         case CPU_VR4133:
40                 val = readw(PMUCNT2REG);
41                 val |= SOFTRST;
42                 writew(val, PMUCNT2REG);
43                 break;
44         default:
45                 break;
46         }
47 }
48
49 static void vr41xx_restart(char *command)
50 {
51         local_irq_disable();
52         software_reset();
53         printk(KERN_NOTICE "\nYou can reset your system\n");
54         while (1) ;
55 }
56
57 static void vr41xx_halt(void)
58 {
59         local_irq_disable();
60         printk(KERN_NOTICE "\nYou can turn off the power supply\n");
61         while (1) ;
62 }
63
64 static void vr41xx_power_off(void)
65 {
66         local_irq_disable();
67         printk(KERN_NOTICE "\nYou can turn off the power supply\n");
68         while (1) ;
69 }
70
71 void __init vr41xx_pmu_init(void)
72 {
73         _machine_restart = vr41xx_restart;
74         _machine_halt = vr41xx_halt;
75         _machine_power_off = vr41xx_power_off;
76 }