1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Board-specific reboot/shutdown routines
4 * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
6 * Copyright (C) 2009 Lemote Inc.
7 * Author: Wu Zhangjin, wuzhangjin@gmail.com
11 #include <linux/delay.h>
12 #include <linux/types.h>
14 #include <asm/bootinfo.h>
18 #include <cs5536/cs5536.h>
19 #include "ec_kb3310b.h"
21 static void reset_cpu(void)
24 * reset cpu to full speed, this is needed when enabling cpu frequency
27 writel(readl(LOONGSON_CHIPCFG
) | 0x7, LOONGSON_CHIPCFG
);
30 /* reset support for fuloong2f */
32 static void fl2f_reboot(void)
36 /* send a reset signal to south bridge.
38 * NOTE: if enable "Power Management" in kernel, rtl8169 will not reset
39 * normally with this reset operation and it will not work in PMON, but
40 * you can type halt command and then reboot, seems the hardware reset
41 * logic not work normally.
45 _rdmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET
), &hi
, &lo
);
47 _wrmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET
), hi
, lo
);
51 static void fl2f_shutdown(void)
57 _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO
), &hi
, &lo
);
58 gpio_base
= lo
& 0xff00;
60 /* make cs5536 gpio13 output enable */
61 val
= inl(gpio_base
+ GPIOL_OUT_EN
);
62 val
&= ~(1 << (16 + 13));
64 outl(val
, gpio_base
+ GPIOL_OUT_EN
);
66 /* make cs5536 gpio13 output low level voltage. */
67 val
= inl(gpio_base
+ GPIOL_OUT_VAL
) & ~(1 << (13));
68 val
|= (1 << (16 + 13));
69 outl(val
, gpio_base
+ GPIOL_OUT_VAL
);
73 /* reset support for yeeloong2f and mengloong2f notebook */
75 static void ml2f_reboot(void)
79 /* sending an reset signal to EC(embedded controller) */
80 ec_write(REG_RESET
, BIT_RESET_ON
);
83 #define yl2f89_reboot ml2f_reboot
85 /* menglong(7inches) laptop has different shutdown logic from 8.9inches */
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)
93 static void ml2f_shutdown(void)
98 outb(REG_SHUTDOWN_HIGH
, EC_SHUTDOWN_IO_PORT_HIGH
);
99 outb(REG_SHUTDOWN_LOW
, EC_SHUTDOWN_IO_PORT_LOW
);
101 val
= inb(EC_SHUTDOWN_IO_PORT_DATA
);
102 outb(val
& (~BIT_SHUTDOWN_ON
), EC_SHUTDOWN_IO_PORT_DATA
);
104 /* need enough wait here... how many microseconds needs? */
105 for (i
= 0; i
< 0x10000; i
++)
107 outb(val
| BIT_SHUTDOWN_ON
, EC_SHUTDOWN_IO_PORT_DATA
);
111 static void yl2f89_shutdown(void)
113 /* cpu-gpio0 output low */
114 LOONGSON_GPIODATA
&= ~0x00000001;
115 /* cpu-gpio0 as output */
116 LOONGSON_GPIOIE
&= ~0x00000001;
119 void mach_prepare_reboot(void)
121 switch (mips_machtype
) {
122 case MACH_LEMOTE_FL2F
:
123 case MACH_LEMOTE_NAS
:
124 case MACH_LEMOTE_LL2F
:
127 case MACH_LEMOTE_ML2F7
:
130 case MACH_LEMOTE_YL2F89
:
138 void mach_prepare_shutdown(void)
140 switch (mips_machtype
) {
141 case MACH_LEMOTE_FL2F
:
142 case MACH_LEMOTE_NAS
:
143 case MACH_LEMOTE_LL2F
:
146 case MACH_LEMOTE_ML2F7
:
149 case MACH_LEMOTE_YL2F89
: