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, wuzj@lemote.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>
24 static void reset_cpu(void)
27 * reset cpu to full speed, this is needed when enabling cpu frequency
30 LOONGSON_CHIPCFG0 |= 0x7;
33 /* reset support for fuloong2f */
35 static void fl2f_reboot(void)
39 /* send a reset signal to south bridge.
41 * NOTE: if enable "Power Management" in kernel, rtl8169 will not reset
42 * normally with this reset operation and it will not work in PMON, but
43 * you can type halt command and then reboot, seems the hardware reset
44 * logic not work normally.
48 _rdmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), &hi, &lo);
50 _wrmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), hi, lo);
54 static void fl2f_shutdown(void)
60 _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO), &hi, &lo);
61 gpio_base = lo & 0xff00;
63 /* make cs5536 gpio13 output enable */
64 val = inl(gpio_base + GPIOL_OUT_EN);
65 val &= ~(1 << (16 + 13));
67 outl(val, gpio_base + GPIOL_OUT_EN);
69 /* make cs5536 gpio13 output low level voltage. */
70 val = inl(gpio_base + GPIOL_OUT_VAL) & ~(1 << (13));
71 val |= (1 << (16 + 13));
72 outl(val, gpio_base + GPIOL_OUT_VAL);
76 /* reset support for yeeloong2f and mengloong2f notebook */
79 * The following registers are determined by the EC index configuration.
80 * 1. fill the PORT_HIGH as EC register high part.
81 * 2. fill the PORT_LOW as EC register low part.
82 * 3. fill the PORT_DATA as EC register write data or get the data from it.
85 #define EC_IO_PORT_HIGH 0x0381
86 #define EC_IO_PORT_LOW 0x0382
87 #define EC_IO_PORT_DATA 0x0383
88 #define REG_RESET_HIGH 0xF4 /* reset the machine auto-clear : rd/wr */
89 #define REG_RESET_LOW 0xEC
90 #define BIT_RESET_ON (1 << 0)
92 void ml2f_reboot(void)
96 /* sending an reset signal to EC(embedded controller) */
97 outb(REG_RESET_HIGH, EC_IO_PORT_HIGH);
98 outb(REG_RESET_LOW, EC_IO_PORT_LOW);
100 outb(BIT_RESET_ON, EC_IO_PORT_DATA);
104 #define yl2f89_reboot ml2f_reboot
106 /* menglong(7inches) laptop has different shutdown logic from 8.9inches */
107 #define EC_SHUTDOWN_IO_PORT_HIGH 0xff2d
108 #define EC_SHUTDOWN_IO_PORT_LOW 0xff2e
109 #define EC_SHUTDOWN_IO_PORT_DATA 0xff2f
110 #define REG_SHUTDOWN_HIGH 0xFC
111 #define REG_SHUTDOWN_LOW 0x29
112 #define BIT_SHUTDOWN_ON (1 << 1)
114 static void ml2f_shutdown(void)
119 outb(REG_SHUTDOWN_HIGH, EC_SHUTDOWN_IO_PORT_HIGH);
120 outb(REG_SHUTDOWN_LOW, EC_SHUTDOWN_IO_PORT_LOW);
122 val = inb(EC_SHUTDOWN_IO_PORT_DATA);
123 outb(val & (~BIT_SHUTDOWN_ON), EC_SHUTDOWN_IO_PORT_DATA);
125 /* need enough wait here... how many microseconds needs? */
126 for (i = 0; i < 0x10000; i++)
128 outb(val | BIT_SHUTDOWN_ON, EC_SHUTDOWN_IO_PORT_DATA);
132 static void yl2f89_shutdown(void)
134 /* cpu-gpio0 output low */
135 LOONGSON_GPIODATA &= ~0x00000001;
136 /* cpu-gpio0 as output */
137 LOONGSON_GPIOIE &= ~0x00000001;
140 void mach_prepare_reboot(void)
142 switch (mips_machtype) {
143 case MACH_LEMOTE_FL2F:
146 case MACH_LEMOTE_ML2F7:
149 case MACH_LEMOTE_YL2F89:
157 void mach_prepare_shutdown(void)
159 switch (mips_machtype) {
160 case MACH_LEMOTE_FL2F:
163 case MACH_LEMOTE_ML2F7:
166 case MACH_LEMOTE_YL2F89: