3 * BRIEF MODULE DESCRIPTION
4 * IT8172/QED5231 board setup.
6 * Copyright 2000 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * ppopov@mvista.com or source@mvista.com
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <linux/config.h>
31 #include <linux/init.h>
32 #include <linux/sched.h>
33 #include <linux/ioport.h>
34 #include <linux/console.h>
35 #include <linux/mc146818rtc.h>
36 #include <linux/serial_reg.h>
37 #include <linux/root_dev.h>
40 #include <asm/bootinfo.h>
42 #include <asm/mipsregs.h>
43 #include <asm/reboot.h>
44 #include <asm/it8172/it8172.h>
45 #include <asm/it8712.h>
47 #include <asm/keyboard.h>
50 #if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE)
51 extern void console_setup(char *, int *);
52 char serial_console[20];
55 extern struct rtc_ops it8172_rtc_ops;
56 extern struct resource ioport_resource;
57 extern unsigned long mips_io_port_base;
58 #ifdef CONFIG_BLK_DEV_IDE
59 extern struct ide_ops std_ide_ops;
60 extern struct ide_ops *ide_ops;
63 extern struct kbd_ops std_kbd_ops;
64 int init_8712_keyboard(void);
67 extern int SearchIT8712(void);
68 extern void InitLPCInterface(void);
69 extern char * __init prom_getcmdline(void);
70 extern void it8172_restart(char *command);
71 extern void it8172_halt(void);
72 extern void it8172_power_off(void);
74 #ifdef CONFIG_IT8172_REVC
77 struct resource pci_mem;
78 struct resource pci_io;
79 struct resource flash;
81 } it8172_resources = {
82 { "RAM", 0, 0, IORESOURCE_MEM }, /* to be initted */
83 { "PCI Mem", 0x10000000, 0x13FFFFFF, IORESOURCE_MEM },
84 { "PCI I/O", 0x14000000, 0x17FFFFFF },
85 { "Flash", 0x08000000, 0x0CFFFFFF },
86 { "Boot ROM", 0x1FC00000, 0x1FFFFFFF }
91 struct resource pci_mem0;
92 struct resource pci_mem1;
93 struct resource pci_io;
94 struct resource pci_mem2;
95 struct resource pci_mem3;
96 struct resource flash;
98 } it8172_resources = {
99 { "RAM", 0, 0, IORESOURCE_MEM }, /* to be initted */
100 { "PCI Mem0", 0x0C000000, 0x0FFFFFFF, IORESOURCE_MEM },
101 { "PCI Mem1", 0x10000000, 0x13FFFFFF, IORESOURCE_MEM },
102 { "PCI I/O", 0x14000000, 0x17FFFFFF },
103 { "PCI Mem2", 0x1A000000, 0x1BFFFFFF, IORESOURCE_MEM },
104 { "PCI Mem3", 0x1C000000, 0x1FBFFFFF, IORESOURCE_MEM },
105 { "Flash", 0x08000000, 0x0CFFFFFF },
106 { "Boot ROM", 0x1FC00000, 0x1FFFFFFF }
111 void __init it8172_init_ram_resource(unsigned long memsize)
113 it8172_resources.ram.end = memsize;
116 void __init it8172_setup(void)
121 argptr = prom_getcmdline();
122 #ifdef CONFIG_SERIAL_CONSOLE
123 if ((argptr = strstr(argptr, "console=")) == NULL) {
124 argptr = prom_getcmdline();
125 strcat(argptr, " console=ttyS0,115200");
129 clear_cp0_status(ST0_FR);
130 rtc_ops = &it8172_rtc_ops;
132 _machine_restart = it8172_restart;
133 _machine_halt = it8172_halt;
134 _machine_power_off = it8172_power_off;
141 mips_io_port_base = KSEG1;
142 ioport_resource.start = it8172_resources.pci_io.start;
143 ioport_resource.end = it8172_resources.pci_io.end;
144 #ifdef CONFIG_IT8172_REVC
145 iomem_resource.start = it8172_resources.pci_mem.start;
146 iomem_resource.end = it8172_resources.pci_mem.end;
148 iomem_resource.start = it8172_resources.pci_mem0.start;
149 iomem_resource.end = it8172_resources.pci_mem3.end;
152 #ifdef CONFIG_BLK_DEV_INITRD
153 ROOT_DEV = Root_RAM0;
157 * Pull enabled devices out of standby
159 IT_IO_READ16(IT_PM_DSR, dsr);
160 #ifdef CONFIG_SOUND_IT8172
161 dsr &= ~IT_PM_DSR_ACSB;
163 dsr |= IT_PM_DSR_ACSB;
165 #ifdef CONFIG_BLK_DEV_IT8172
166 dsr &= ~IT_PM_DSR_IDESB;
167 ide_ops = &std_ide_ops;
169 dsr |= IT_PM_DSR_IDESB;
171 IT_IO_WRITE16(IT_PM_DSR, dsr);
174 conswitchp = &dummy_con;
179 #ifdef CONFIG_MIPS_ITE8172
180 if (SearchIT8712()) {
181 printk("Found IT8712 Super IO\n");
182 // enable IT8712 serial port
183 LPCSetConfig(LDN_SERIAL1, 0x30, 0x01); /* enable */
184 LPCSetConfig(LDN_SERIAL1, 0x23, 0x01); /* clock selection */
185 #ifdef CONFIG_PC_KEYB
186 if (init_8712_keyboard()) {
187 printk("Unable to initialize keyboard\n");
188 LPCSetConfig(LDN_KEYBOARD, 0x30, 0x0); /* disable keyboard */
191 LPCSetConfig(LDN_KEYBOARD, 0x30, 0x1); /* enable keyboard */
192 LPCSetConfig(LDN_KEYBOARD, 0xf0, 0x2);
193 LPCSetConfig(LDN_KEYBOARD, 0x71, 0x3);
195 LPCSetConfig(LDN_MOUSE, 0x30, 0x1); /* enable mouse */
197 LPCSetConfig(0x4, 0x30, 0x1);
198 LPCSetConfig(0x4, 0xf4, LPCGetConfig(0x4, 0xf4) | 0x80);
200 if ((LPCGetConfig(LDN_KEYBOARD, 0x30) == 0) ||
201 (LPCGetConfig(LDN_MOUSE, 0x30) == 0))
202 printk("Error: keyboard or mouse not enabled\n");
204 kbd_ops = &std_kbd_ops;
209 printk("IT8712 Super IO not found\n");
213 #ifdef CONFIG_IT8172_CIR
216 //printk("Enabling CIR0\n");
217 IT_IO_READ16(IT_PM_DSR, data);
218 data &= ~IT_PM_DSR_CIR0SB;
219 IT_IO_WRITE16(IT_PM_DSR, data);
220 //printk("DSR register: %x\n", (unsigned)IT_IO_READ16(IT_PM_DSR, data));
223 #ifdef CONFIG_IT8172_SCR0
226 /* Enable Smart Card Reader 0 */
227 /* First power it up */
228 IT_IO_READ16(IT_PM_DSR, i);
229 i &= ~IT_PM_DSR_SCR0SB;
230 IT_IO_WRITE16(IT_PM_DSR, i);
231 /* Then initialize its registers */
232 outb(( IT_SCR_SFR_GATE_UART_OFF << IT_SCR_SFR_GATE_UART_BIT
233 |IT_SCR_SFR_FET_CHARGE_213_US << IT_SCR_SFR_FET_CHARGE_BIT
234 |IT_SCR_SFR_CARD_FREQ_3_5_MHZ << IT_SCR_SFR_CARD_FREQ_BIT
235 |IT_SCR_SFR_FET_ACTIVE_INVERT << IT_SCR_SFR_FET_ACTIVE_BIT
236 |IT_SCR_SFR_ENABLE_ON << IT_SCR_SFR_ENABLE_BIT),
237 IT8172_PCI_IO_BASE + IT_SCR0_BASE + IT_SCR_SFR);
238 outb(IT_SCR_SCDR_RESET_MODE_ASYNC << IT_SCR_SCDR_RESET_MODE_BIT,
239 IT8172_PCI_IO_BASE + IT_SCR0_BASE + IT_SCR_SCDR);
241 #endif /* CONFIG_IT8172_SCR0 */
242 #ifdef CONFIG_IT8172_SCR1
245 /* Enable Smart Card Reader 1 */
246 /* First power it up */
247 IT_IO_READ16(IT_PM_DSR, i);
248 i &= ~IT_PM_DSR_SCR1SB;
249 IT_IO_WRITE16(IT_PM_DSR, i);
250 /* Then initialize its registers */
251 outb(( IT_SCR_SFR_GATE_UART_OFF << IT_SCR_SFR_GATE_UART_BIT
252 |IT_SCR_SFR_FET_CHARGE_213_US << IT_SCR_SFR_FET_CHARGE_BIT
253 |IT_SCR_SFR_CARD_FREQ_3_5_MHZ << IT_SCR_SFR_CARD_FREQ_BIT
254 |IT_SCR_SFR_FET_ACTIVE_INVERT << IT_SCR_SFR_FET_ACTIVE_BIT
255 |IT_SCR_SFR_ENABLE_ON << IT_SCR_SFR_ENABLE_BIT),
256 IT8172_PCI_IO_BASE + IT_SCR1_BASE + IT_SCR_SFR);
257 outb(IT_SCR_SCDR_RESET_MODE_ASYNC << IT_SCR_SCDR_RESET_MODE_BIT,
258 IT8172_PCI_IO_BASE + IT_SCR1_BASE + IT_SCR_SCDR);
260 #endif /* CONFIG_IT8172_SCR1 */
264 #ifdef CONFIG_PC_KEYB
266 * According to the ITE Special BIOS Note for waking up the
267 * keyboard controller...
269 int init_8712_keyboard()
271 unsigned int cmd_port = 0x14000064;
272 unsigned int data_port = 0x14000060;
276 outb(0xaa, cmd_port); /* send self-test cmd */
278 while (!(inb(cmd_port) & 0x1)) { /* wait output buffer full */
284 data = inb(data_port);
285 outb(0xcb, cmd_port); /* set ps2 mode */
286 while (inb(cmd_port) & 0x2) { /* wait while input buffer full */
291 outb(0x01, data_port);
292 while (inb(cmd_port) & 0x2) { /* wait while input buffer full */
298 outb(0x60, cmd_port); /* write 8042 command byte */
299 while (inb(cmd_port) & 0x2) { /* wait while input buffer full */
304 outb(0x45, data_port); /* at interface, keyboard enabled, system flag */
305 while (inb(cmd_port) & 0x2) { /* wait while input buffer full */
311 outb(0xae, cmd_port); /* enable interface */