This source file includes following definitions.
- reset_cpu
- fl2f_reboot
- fl2f_shutdown
- ml2f_reboot
- ml2f_shutdown
- yl2f89_shutdown
- mach_prepare_reboot
- mach_prepare_shutdown
1
2
3
4
5
6
7
8
9
10 #include <linux/io.h>
11 #include <linux/delay.h>
12 #include <linux/types.h>
13
14 #include <asm/bootinfo.h>
15
16 #include <loongson.h>
17
18 #include <cs5536/cs5536.h>
19 #include "ec_kb3310b.h"
20
21 static void reset_cpu(void)
22 {
23
24
25
26
27 LOONGSON_CHIPCFG(0) |= 0x7;
28 }
29
30
31
32 static void fl2f_reboot(void)
33 {
34 reset_cpu();
35
36
37
38
39
40
41
42
43 {
44 u32 hi, lo;
45 _rdmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), &hi, &lo);
46 lo |= 0x00000001;
47 _wrmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), hi, lo);
48 }
49 }
50
51 static void fl2f_shutdown(void)
52 {
53 u32 hi, lo, val;
54 int gpio_base;
55
56
57 _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO), &hi, &lo);
58 gpio_base = lo & 0xff00;
59
60
61 val = inl(gpio_base + GPIOL_OUT_EN);
62 val &= ~(1 << (16 + 13));
63 val |= (1 << 13);
64 outl(val, gpio_base + GPIOL_OUT_EN);
65 mmiowb();
66
67 val = inl(gpio_base + GPIOL_OUT_VAL) & ~(1 << (13));
68 val |= (1 << (16 + 13));
69 outl(val, gpio_base + GPIOL_OUT_VAL);
70 mmiowb();
71 }
72
73
74
75 static void ml2f_reboot(void)
76 {
77 reset_cpu();
78
79
80 ec_write(REG_RESET, BIT_RESET_ON);
81 }
82
83 #define yl2f89_reboot ml2f_reboot
84
85
86 #define EC_SHUTDOWN_IO_PORT_HIGH 0xff2d
87 #define EC_SHUTDOWN_IO_PORT_LOW 0xff2e
88 #define EC_SHUTDOWN_IO_PORT_DATA 0xff2f
89 #define REG_SHUTDOWN_HIGH 0xFC
90 #define REG_SHUTDOWN_LOW 0x29
91 #define BIT_SHUTDOWN_ON (1 << 1)
92
93 static void ml2f_shutdown(void)
94 {
95 u8 val;
96 u64 i;
97
98 outb(REG_SHUTDOWN_HIGH, EC_SHUTDOWN_IO_PORT_HIGH);
99 outb(REG_SHUTDOWN_LOW, EC_SHUTDOWN_IO_PORT_LOW);
100 mmiowb();
101 val = inb(EC_SHUTDOWN_IO_PORT_DATA);
102 outb(val & (~BIT_SHUTDOWN_ON), EC_SHUTDOWN_IO_PORT_DATA);
103 mmiowb();
104
105 for (i = 0; i < 0x10000; i++)
106 delay();
107 outb(val | BIT_SHUTDOWN_ON, EC_SHUTDOWN_IO_PORT_DATA);
108 mmiowb();
109 }
110
111 static void yl2f89_shutdown(void)
112 {
113
114 LOONGSON_GPIODATA &= ~0x00000001;
115
116 LOONGSON_GPIOIE &= ~0x00000001;
117 }
118
119 void mach_prepare_reboot(void)
120 {
121 switch (mips_machtype) {
122 case MACH_LEMOTE_FL2F:
123 case MACH_LEMOTE_NAS:
124 case MACH_LEMOTE_LL2F:
125 fl2f_reboot();
126 break;
127 case MACH_LEMOTE_ML2F7:
128 ml2f_reboot();
129 break;
130 case MACH_LEMOTE_YL2F89:
131 yl2f89_reboot();
132 break;
133 default:
134 break;
135 }
136 }
137
138 void mach_prepare_shutdown(void)
139 {
140 switch (mips_machtype) {
141 case MACH_LEMOTE_FL2F:
142 case MACH_LEMOTE_NAS:
143 case MACH_LEMOTE_LL2F:
144 fl2f_shutdown();
145 break;
146 case MACH_LEMOTE_ML2F7:
147 ml2f_shutdown();
148 break;
149 case MACH_LEMOTE_YL2F89:
150 yl2f89_shutdown();
151 break;
152 default:
153 break;
154 }
155 }