usb: gadget: udc: pch_udc: Fix a plethora of function documentation related issues
[linux/fpc-iii.git] / arch / mips / loongson2ef / lemote-2f / reset.c
blob197dae4ffd23e0025933b96d48b573da78907bc9
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
8 */
10 #include <linux/io.h>
11 #include <linux/delay.h>
12 #include <linux/types.h>
14 #include <asm/bootinfo.h>
16 #include <loongson.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
25 * scalling
27 writel(readl(LOONGSON_CHIPCFG) | 0x7, LOONGSON_CHIPCFG);
30 /* reset support for fuloong2f */
32 static void fl2f_reboot(void)
34 reset_cpu();
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.
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);
51 static void fl2f_shutdown(void)
53 u32 hi, lo, val;
54 int gpio_base;
56 /* get gpio base */
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));
63 val |= (1 << 13);
64 outl(val, gpio_base + GPIOL_OUT_EN);
65 mmiowb();
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);
70 mmiowb();
73 /* reset support for yeeloong2f and mengloong2f notebook */
75 static void ml2f_reboot(void)
77 reset_cpu();
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)
95 u8 val;
96 u64 i;
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 /* need enough wait here... how many microseconds needs? */
105 for (i = 0; i < 0x10000; i++)
106 delay();
107 outb(val | BIT_SHUTDOWN_ON, EC_SHUTDOWN_IO_PORT_DATA);
108 mmiowb();
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:
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;
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:
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;