1 /* Board-specific reboot/shutdown routines
3 * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
5 * Copyright (C) 2009 Lemote Inc.
6 * Author: Wu Zhangjin, wuzhangjin@gmail.com
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
15 #include <linux/delay.h>
16 #include <linux/types.h>
18 #include <asm/bootinfo.h>
22 #include <cs5536/cs5536.h>
23 #include "ec_kb3310b.h"
25 static void reset_cpu(void)
28 * reset cpu to full speed, this is needed when enabling cpu frequency
31 LOONGSON_CHIPCFG(0) |= 0x7;
34 /* reset support for fuloong2f */
36 static void fl2f_reboot(void)
40 /* send a reset signal to south bridge.
42 * NOTE: if enable "Power Management" in kernel, rtl8169 will not reset
43 * normally with this reset operation and it will not work in PMON, but
44 * you can type halt command and then reboot, seems the hardware reset
45 * logic not work normally.
49 _rdmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET
), &hi
, &lo
);
51 _wrmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET
), hi
, lo
);
55 static void fl2f_shutdown(void)
61 _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO
), &hi
, &lo
);
62 gpio_base
= lo
& 0xff00;
64 /* make cs5536 gpio13 output enable */
65 val
= inl(gpio_base
+ GPIOL_OUT_EN
);
66 val
&= ~(1 << (16 + 13));
68 outl(val
, gpio_base
+ GPIOL_OUT_EN
);
70 /* make cs5536 gpio13 output low level voltage. */
71 val
= inl(gpio_base
+ GPIOL_OUT_VAL
) & ~(1 << (13));
72 val
|= (1 << (16 + 13));
73 outl(val
, gpio_base
+ GPIOL_OUT_VAL
);
77 /* reset support for yeeloong2f and mengloong2f notebook */
79 static void ml2f_reboot(void)
83 /* sending an reset signal to EC(embedded controller) */
84 ec_write(REG_RESET
, BIT_RESET_ON
);
87 #define yl2f89_reboot ml2f_reboot
89 /* menglong(7inches) laptop has different shutdown logic from 8.9inches */
90 #define EC_SHUTDOWN_IO_PORT_HIGH 0xff2d
91 #define EC_SHUTDOWN_IO_PORT_LOW 0xff2e
92 #define EC_SHUTDOWN_IO_PORT_DATA 0xff2f
93 #define REG_SHUTDOWN_HIGH 0xFC
94 #define REG_SHUTDOWN_LOW 0x29
95 #define BIT_SHUTDOWN_ON (1 << 1)
97 static void ml2f_shutdown(void)
102 outb(REG_SHUTDOWN_HIGH
, EC_SHUTDOWN_IO_PORT_HIGH
);
103 outb(REG_SHUTDOWN_LOW
, EC_SHUTDOWN_IO_PORT_LOW
);
105 val
= inb(EC_SHUTDOWN_IO_PORT_DATA
);
106 outb(val
& (~BIT_SHUTDOWN_ON
), EC_SHUTDOWN_IO_PORT_DATA
);
108 /* need enough wait here... how many microseconds needs? */
109 for (i
= 0; i
< 0x10000; i
++)
111 outb(val
| BIT_SHUTDOWN_ON
, EC_SHUTDOWN_IO_PORT_DATA
);
115 static void yl2f89_shutdown(void)
117 /* cpu-gpio0 output low */
118 LOONGSON_GPIODATA
&= ~0x00000001;
119 /* cpu-gpio0 as output */
120 LOONGSON_GPIOIE
&= ~0x00000001;
123 void mach_prepare_reboot(void)
125 switch (mips_machtype
) {
126 case MACH_LEMOTE_FL2F
:
127 case MACH_LEMOTE_NAS
:
128 case MACH_LEMOTE_LL2F
:
131 case MACH_LEMOTE_ML2F7
:
134 case MACH_LEMOTE_YL2F89
:
142 void mach_prepare_shutdown(void)
144 switch (mips_machtype
) {
145 case MACH_LEMOTE_FL2F
:
146 case MACH_LEMOTE_NAS
:
147 case MACH_LEMOTE_LL2F
:
150 case MACH_LEMOTE_ML2F7
:
153 case MACH_LEMOTE_YL2F89
: