blob: f1843fd53a50658ebda807634e727ad86ad1cc93 [file] [log] [blame]
Joseph Smithb94a79f2010-06-21 23:25:06 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Joseph Smith <joe@settoplinux.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#define PME_DEV PNP_DEV(0x4e, 0x0a)
22#define PME_IO_BASE_ADDR 0x800 /* Runtime register base address */
23
24/* Early mainboard specific GPIO setup. */
25static void mb_gpio_init(void)
26{
27 device_t dev;
28 uint16_t port;
29
30 /* Southbridge GPIOs. */
31 /* Set the LPC device statically. */
32 dev = PCI_DEV(0x0, 0x1f, 0x0);
33
34 /* Set the value for GPIO base address register and enable GPIO. */
35 pci_write_config32(dev, GPIO_BASE, (GPIO_BASE_ADDR | 1));
36 pci_write_config8(dev, GPIO_CNTL, 0x10);
37
38 udelay(10);
39 outl(0x1a203180, GPIO_BASE_ADDR + 0x00); /* GPIO_USE_SEL */
40 outl(0x0000ffff, GPIO_BASE_ADDR + 0x04); /* GP_IO_SEL */
41 outl(0x13bf0000, GPIO_BASE_ADDR + 0x0c); /* GP_LVL */
42 outl(0x00040000, GPIO_BASE_ADDR + 0x18); /* GPO_BLINK */
43 outl(0x000039ff, GPIO_BASE_ADDR + 0x2c); /* GPI_INV */
44
45 /* Super I/O GPIOs. */
46 dev = PME_DEV;
47 port = dev >> 8;
48
49 /* Enter the configuration state. */
50 outb(0x55, port);
51 pnp_set_logical_device(dev);
52 pnp_set_enable(dev, 0);
53 pnp_set_iobase(dev, PNP_IDX_IO0, PME_IO_BASE_ADDR);
54 pnp_set_enable(dev, 1);
55
56 /* GP10 - J1B1 */
57 outl(0x01, PME_IO_BASE_ADDR + 0x23);
58
59 /* GP11 - J1B2 */
60 outl(0x01, PME_IO_BASE_ADDR + 0x24);
61
62 /* GP12 - J2B1 */
63 outl(0x01, PME_IO_BASE_ADDR + 0x25);
64
65 /* GP13 - J2B2 */
66 outl(0x01, PME_IO_BASE_ADDR + 0x26);
67
68 /* GP14 - J1X */
69 outl(0x01, PME_IO_BASE_ADDR + 0x27);
70
71 /* GP15 - J1Y */
72 outl(0x01, PME_IO_BASE_ADDR + 0x28);
73
74 /* GP16 - J2X */
75 outl(0x01, PME_IO_BASE_ADDR + 0x29);
76
77 /* GP17 - J2Y */
78 outl(0x01, PME_IO_BASE_ADDR + 0x2a);
79
80 /* GP20 - 8042 P17 */
81 outl(0x01, PME_IO_BASE_ADDR + 0x2b);
82
83 /* GP21 - 8042 P16 */
84 outl(0x00, PME_IO_BASE_ADDR + 0x2c);
85
86 /* GP22 - 8042 P12 */
87 outl(0x00, PME_IO_BASE_ADDR + 0x2d);
88
89 /* GP24 */
90 outl(0x00, PME_IO_BASE_ADDR + 0x2f);
91
92 /* GP25 - MIDI_IN */
93 outl(0x01, PME_IO_BASE_ADDR + 0x30);
94
95 /* GP26 - MIDI_OUT */
96 outl(0x01, PME_IO_BASE_ADDR + 0x31);
97
98 /* GP27 - nIO_SMI */
99 outl(0x04, PME_IO_BASE_ADDR + 0x32);
100
101 /* GP30 - FAN_TACH2 */
102 outl(0x05, PME_IO_BASE_ADDR + 0x33);
103
104 /* GP31 - FAN_TACH1 */
105 outl(0x05, PME_IO_BASE_ADDR + 0x34);
106
107 /* GP32 - FAN2 */
108 outl(0x04, PME_IO_BASE_ADDR + 0x35);
109
110 /* GP33 - FAN1 */
111 outl(0x04, PME_IO_BASE_ADDR + 0x36);
112
113 /* GP34 - IRRX2 */
114 outl(0x05, PME_IO_BASE_ADDR + 0x37);
115
116 /* GP35 - IRTX2 */
117 outl(0x04, PME_IO_BASE_ADDR + 0x38);
118
119 /* GP36 - nKBDRST */
120 outl(0x84, PME_IO_BASE_ADDR + 0x39);
121
122 /* GP37 - A20M */
123 outl(0x84, PME_IO_BASE_ADDR + 0x3a);
124
125 /* GP40 - DRVDEN0 */
126 outl(0x04, PME_IO_BASE_ADDR + 0x3b);
127
128 /* GP41 - DRVDEN1 */
129 outl(0x04, PME_IO_BASE_ADDR + 0x3c);
130
131 /* GP42 - nIO_PME */
132 outl(0x84, PME_IO_BASE_ADDR + 0x3d);
133
134 /* GP43 */
135 outl(0x00, PME_IO_BASE_ADDR + 0x3e);
136
137 /* GP50 - nIR2 */
138 outl(0x05, PME_IO_BASE_ADDR + 0x3f);
139
140 /* GP51 - nDCD2 */
141 outl(0x05, PME_IO_BASE_ADDR + 0x40);
142
143 /* GP52 - RXD2 */
144 outl(0x05, PME_IO_BASE_ADDR + 0x41);
145
146 /* GP53 - TXD2 */
147 outl(0x04, PME_IO_BASE_ADDR + 0x42);
148
149 /* GP54 - nDSR2 */
150 outl(0x05, PME_IO_BASE_ADDR + 0x43);
151
152 /* GP55 - nRTS2 */
153 outl(0x04, PME_IO_BASE_ADDR + 0x44);
154
155 /* GP56 - nCTS2 */
156 outl(0x05, PME_IO_BASE_ADDR + 0x45);
157
158 /* GP57 - nDTR2 */
159 outl(0x04, PME_IO_BASE_ADDR + 0x46);
160
161 /* GP60 - LED1 */
162 outl(0x84, PME_IO_BASE_ADDR + 0x47);
163
164 /* GP61 - LED2 */
165 outl(0x84, PME_IO_BASE_ADDR + 0x48);
166
167 /* GP1 */
168 outl(0x00, PME_IO_BASE_ADDR + 0x4b);
169
170 /* GP2 */
171 outl(0x14, PME_IO_BASE_ADDR + 0x4c);
172
173 /* GP3 */
174 outl(0xda, PME_IO_BASE_ADDR + 0x4d);
175
176 /* GP4 */
177 outl(0x08, PME_IO_BASE_ADDR + 0x4e);
178
179 /* GP5 */
180 outl(0x00, PME_IO_BASE_ADDR + 0x4f);
181
182 /* GP6 */
183 outl(0x00, PME_IO_BASE_ADDR + 0x50);
184
185 /* FAN1 */
186 outl(0x01, PME_IO_BASE_ADDR + 0x56);
187
188 /* FAN2 */
189 outl(0x01, PME_IO_BASE_ADDR + 0x57);
190
191 /* Fan Control */
192 outl(0xf0, PME_IO_BASE_ADDR + 0x58);
193
194 /* Fan1 Preload */
195 outl(0x00, PME_IO_BASE_ADDR + 0x5b);
196
197 /* Fan2 Preload */
198 outl(0x00, PME_IO_BASE_ADDR + 0x5c);
199
200 /* LED1 */
201 outl(0x03, PME_IO_BASE_ADDR + 0x5d);
202
203 /* LED2 */
204 outl(0x03, PME_IO_BASE_ADDR + 0x5e);
205
206 /* Keyboard Scan Code */
207 outl(0x00, PME_IO_BASE_ADDR + 0x5f);
208
209 /* Exit the configuration state. */
210 outb(0xaa, port);
211}