Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 3 | * |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2010 coresystems GmbH |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 5 | * |
Uwe Hermann | 2bb4acf | 2010-03-01 17:19:55 +0000 | [diff] [blame] | 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; version 2 of the License. |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Uwe Hermann | 2bb4acf | 2010-03-01 17:19:55 +0000 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Myles Watson | 1d6d45e | 2009-11-06 17:02:51 +0000 | [diff] [blame] | 20 | // __PRE_RAM__ means: use "unsigned" for device, not a struct. |
Stefan Reinauer | 5e32823 | 2010-03-29 19:19:16 +0000 | [diff] [blame] | 21 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 22 | #include <stdint.h> |
Patrick Georgi | 12aba82 | 2009-04-30 07:07:22 +0000 | [diff] [blame] | 23 | #include <string.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 24 | #include <lib.h> |
Kyösti Mälkki | 12d681b | 2014-06-14 18:51:34 +0300 | [diff] [blame] | 25 | #include <arch/acpi.h> |
Kyösti Mälkki | a7c9611 | 2013-10-13 20:41:57 +0300 | [diff] [blame] | 26 | #include <cbmem.h> |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 27 | #include <arch/io.h> |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 28 | #include <device/pci_def.h> |
| 29 | #include <device/pnp_def.h> |
| 30 | #include <cpu/x86/lapic.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 31 | #include <pc80/mc146818rtc.h> |
Stefan Reinauer | 10ec0fe | 2010-09-25 10:40:47 +0000 | [diff] [blame] | 32 | #include "option_table.h" |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 33 | #include <console/console.h> |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 34 | #include <cpu/x86/bist.h> |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 35 | #include <halt.h> |
Edward O'Callaghan | 4f5a525 | 2014-04-03 14:40:24 +1100 | [diff] [blame] | 36 | #include <superio/winbond/w83627thg/w83627thg.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame^] | 37 | #include <northbridge/intel/i945/i945.h> |
| 38 | #include <northbridge/intel/i945/raminit.h> |
| 39 | #include <southbridge/intel/i82801gx/i82801gx.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 40 | |
Uwe Hermann | 57b2ff8 | 2010-11-21 17:29:59 +0000 | [diff] [blame] | 41 | #define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1) |
| 42 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 43 | void setup_ich7_gpios(void) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 44 | { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 45 | printk(BIOS_DEBUG, " GPIOS..."); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 46 | /* General Registers */ |
| 47 | outl(0x1f1ff7c0, DEFAULT_GPIOBASE + 0x00); /* GPIO_USE_SEL */ |
| 48 | outl(0xe0e8efc3, DEFAULT_GPIOBASE + 0x04); /* GP_IO_SEL */ |
| 49 | outl(0xebffeeff, DEFAULT_GPIOBASE + 0x0c); /* GP_LVL */ |
| 50 | /* Output Control Registers */ |
| 51 | outl(0x00000000, DEFAULT_GPIOBASE + 0x18); /* GPO_BLINK */ |
| 52 | /* Input Control Registers */ |
| 53 | outl(0x00002180, DEFAULT_GPIOBASE + 0x2c); /* GPI_INV */ |
Stefan Reinauer | e1025d0 | 2009-03-11 15:20:36 +0000 | [diff] [blame] | 54 | outl(0x000100ff, DEFAULT_GPIOBASE + 0x30); /* GPIO_USE_SEL2 */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 55 | outl(0x00000030, DEFAULT_GPIOBASE + 0x34); /* GP_IO_SEL2 */ |
| 56 | outl(0x00010035, DEFAULT_GPIOBASE + 0x38); /* GP_LVL */ |
| 57 | } |
| 58 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 59 | static void ich7_enable_lpc(void) |
| 60 | { |
Patrick Georgi | a470019 | 2011-01-27 07:39:38 +0000 | [diff] [blame] | 61 | int lpt_en = 0; |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 62 | if (read_option(lpt, 0) != 0) { |
Patrick Georgi | a470019 | 2011-01-27 07:39:38 +0000 | [diff] [blame] | 63 | lpt_en = 1<<2; // enable LPT |
| 64 | } |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 65 | // Enable Serial IRQ |
| 66 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x64, 0xd0); |
| 67 | // Set COM1/COM2 decode range |
| 68 | pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0010); |
| 69 | // Enable COM1/COM2/KBD/SuperIO1+2 |
Patrick Georgi | a470019 | 2011-01-27 07:39:38 +0000 | [diff] [blame] | 70 | pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x340b | lpt_en); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 71 | // Enable HWM at 0xa00 |
Stefan Reinauer | e1025d0 | 2009-03-11 15:20:36 +0000 | [diff] [blame] | 72 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x00fc0a01); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 73 | // COM3 decode |
| 74 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000403e9); |
| 75 | // COM4 decode |
| 76 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x000402e9); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 77 | // io 0x300 decode |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 78 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x00000301); |
| 79 | } |
| 80 | |
Edward O'Callaghan | 2c55b70 | 2014-05-13 23:29:22 +1000 | [diff] [blame] | 81 | /* TODO: superio code should really not be in mainboard */ |
| 82 | static void pnp_enter_func_mode(device_t dev) |
| 83 | { |
| 84 | u16 port = dev >> 8; |
| 85 | outb(0x87, port); |
| 86 | outb(0x87, port); |
| 87 | } |
| 88 | |
| 89 | static void pnp_exit_func_mode(device_t dev) |
| 90 | { |
| 91 | u16 port = dev >> 8; |
| 92 | outb(0xaa, port); |
| 93 | } |
| 94 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 95 | /* This box has two superios, so enabling serial becomes slightly excessive. |
| 96 | * We disable a lot of stuff to make sure that there are no conflicts between |
| 97 | * the two. Also set up the GPIOs from the beginning. This is the "no schematic |
| 98 | * but safe anyways" method. |
| 99 | */ |
| 100 | static void early_superio_config_w83627thg(void) |
| 101 | { |
| 102 | device_t dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 103 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 104 | dev=PNP_DEV(0x2e, W83627THG_SP1); |
Edward O'Callaghan | 2c55b70 | 2014-05-13 23:29:22 +1000 | [diff] [blame] | 105 | pnp_enter_func_mode(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 106 | |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 107 | pnp_write_config(dev, 0x24, 0xc6); // PNPCSV |
| 108 | |
| 109 | pnp_write_config(dev, 0x29, 0x43); // GPIO settings |
| 110 | pnp_write_config(dev, 0x2a, 0x40); // GPIO settings |
| 111 | |
| 112 | dev=PNP_DEV(0x2e, W83627THG_SP1); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 113 | pnp_set_logical_device(dev); |
| 114 | pnp_set_enable(dev, 0); |
| 115 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8); |
| 116 | pnp_set_irq(dev, PNP_IDX_IRQ0, 4); |
| 117 | pnp_set_enable(dev, 1); |
| 118 | |
| 119 | dev=PNP_DEV(0x2e, W83627THG_SP2); |
| 120 | pnp_set_logical_device(dev); |
| 121 | pnp_set_enable(dev, 0); |
| 122 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8); |
| 123 | pnp_set_irq(dev, PNP_IDX_IRQ0, 3); |
| 124 | // pnp_write_config(dev, 0xf1, 4); // IRMODE0 |
| 125 | pnp_set_enable(dev, 1); |
| 126 | |
| 127 | dev=PNP_DEV(0x2e, W83627THG_KBC); |
| 128 | pnp_set_logical_device(dev); |
| 129 | pnp_set_enable(dev, 0); |
| 130 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x60); |
| 131 | pnp_set_iobase(dev, PNP_IDX_IO1, 0x64); |
| 132 | // pnp_write_config(dev, 0xf0, 0x82); |
| 133 | pnp_set_enable(dev, 1); |
| 134 | |
| 135 | dev=PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1); |
| 136 | pnp_set_logical_device(dev); |
| 137 | pnp_set_enable(dev, 0); |
| 138 | pnp_write_config(dev, 0xf5, 0xff); // invert all GPIOs |
| 139 | pnp_set_enable(dev, 1); |
| 140 | |
| 141 | dev=PNP_DEV(0x2e, W83627THG_GPIO2); |
| 142 | pnp_set_logical_device(dev); |
| 143 | pnp_set_enable(dev, 1); // Just enable it |
| 144 | |
| 145 | dev=PNP_DEV(0x2e, W83627THG_GPIO3); |
| 146 | pnp_set_logical_device(dev); |
| 147 | pnp_set_enable(dev, 0); |
| 148 | pnp_write_config(dev, 0xf0, 0xfb); // GPIO bit 2 is output |
| 149 | pnp_write_config(dev, 0xf1, 0x00); // GPIO bit 2 is 0 |
| 150 | pnp_write_config(dev, 0x30, 0x03); // Enable GPIO3+4. pnp_set_enable is not sufficient |
| 151 | |
| 152 | dev=PNP_DEV(0x2e, W83627THG_FDC); |
| 153 | pnp_set_logical_device(dev); |
| 154 | pnp_set_enable(dev, 0); |
| 155 | |
| 156 | dev=PNP_DEV(0x2e, W83627THG_PP); |
| 157 | pnp_set_logical_device(dev); |
| 158 | pnp_set_enable(dev, 0); |
| 159 | |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame] | 160 | /* Enable HWM */ |
| 161 | dev=PNP_DEV(0x2e, W83627THG_HWM); |
| 162 | pnp_set_logical_device(dev); |
| 163 | pnp_set_enable(dev, 0); |
| 164 | pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00); |
| 165 | pnp_set_enable(dev, 1); |
| 166 | |
Edward O'Callaghan | 2c55b70 | 2014-05-13 23:29:22 +1000 | [diff] [blame] | 167 | pnp_exit_func_mode(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 168 | |
| 169 | dev=PNP_DEV(0x4e, W83627THG_SP1); |
Edward O'Callaghan | 2c55b70 | 2014-05-13 23:29:22 +1000 | [diff] [blame] | 170 | pnp_enter_func_mode(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 171 | |
| 172 | pnp_set_logical_device(dev); // Set COM3 to sane non-conflicting values |
| 173 | pnp_set_enable(dev, 0); |
| 174 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8); |
| 175 | pnp_set_irq(dev, PNP_IDX_IRQ0, 11); |
| 176 | pnp_set_enable(dev, 1); |
| 177 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 178 | dev=PNP_DEV(0x4e, W83627THG_SP2); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 179 | pnp_set_logical_device(dev); // Set COM4 to sane non-conflicting values |
| 180 | pnp_set_enable(dev, 0); |
| 181 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8); |
| 182 | pnp_set_irq(dev, PNP_IDX_IRQ0, 10); |
| 183 | pnp_set_enable(dev, 1); |
| 184 | |
| 185 | dev=PNP_DEV(0x4e, W83627THG_FDC); |
| 186 | pnp_set_logical_device(dev); |
| 187 | pnp_set_enable(dev, 0); |
| 188 | |
| 189 | dev=PNP_DEV(0x4e, W83627THG_PP); |
| 190 | pnp_set_logical_device(dev); |
| 191 | pnp_set_enable(dev, 0); |
| 192 | |
| 193 | dev=PNP_DEV(0x4e, W83627THG_KBC); |
| 194 | pnp_set_logical_device(dev); |
| 195 | pnp_set_enable(dev, 0); |
| 196 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x00); |
| 197 | pnp_set_iobase(dev, PNP_IDX_IO1, 0x00); |
| 198 | |
Edward O'Callaghan | 2c55b70 | 2014-05-13 23:29:22 +1000 | [diff] [blame] | 199 | pnp_exit_func_mode(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | static void rcba_config(void) |
| 203 | { |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 204 | u32 reg32; |
| 205 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 206 | /* Set up virtual channel 0 */ |
| 207 | //RCBA32(0x0014) = 0x80000001; |
| 208 | //RCBA32(0x001c) = 0x03128010; |
| 209 | |
| 210 | /* Device 1f interrupt pin register */ |
| 211 | RCBA32(0x3100) = 0x00042210; |
| 212 | /* Device 1d interrupt pin register */ |
| 213 | RCBA32(0x310c) = 0x00214321; |
| 214 | |
| 215 | /* dev irq route register */ |
| 216 | RCBA16(0x3140) = 0x0132; |
| 217 | RCBA16(0x3142) = 0x3241; |
| 218 | RCBA16(0x3144) = 0x0237; |
| 219 | RCBA16(0x3146) = 0x3210; |
| 220 | RCBA16(0x3148) = 0x3210; |
| 221 | |
| 222 | /* Enable IOAPIC */ |
| 223 | RCBA8(0x31ff) = 0x03; |
| 224 | |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 225 | /* Now, this is a bit ugly. As per PCI specification, function 0 of a |
| 226 | * device always has to be implemented. So disabling ethernet port 1 |
| 227 | * would essentially disable all three ethernet ports of the mainboard. |
| 228 | * It's possible to rename the ports to achieve compatibility to the |
| 229 | * PCI spec but this will confuse all (static!) tables containing |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 230 | * interrupt routing information. |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 231 | * To avoid this, we enable (unused) port 6 and swap it with port 1 |
| 232 | * in the case that ethernet port 1 is disabled. Since no devices |
| 233 | * are connected to that port, we don't have to worry about interrupt |
| 234 | * routing. |
| 235 | */ |
| 236 | int port_shuffle = 0; |
| 237 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 238 | /* Disable unused devices */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 239 | reg32 = FD_ACMOD|FD_ACAUD|FD_PATA; |
| 240 | reg32 |= FD_PCIE6|FD_PCIE5|FD_PCIE4; |
| 241 | |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 242 | if (read_option(ethernet1, 0) != 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 243 | printk(BIOS_DEBUG, "Disabling ethernet adapter 1.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 244 | reg32 |= FD_PCIE1; |
| 245 | } |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 246 | if (read_option(ethernet2, 0) != 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 247 | printk(BIOS_DEBUG, "Disabling ethernet adapter 2.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 248 | reg32 |= FD_PCIE2; |
| 249 | } else { |
| 250 | if (reg32 & FD_PCIE1) |
| 251 | port_shuffle = 1; |
| 252 | } |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 253 | if (read_option(ethernet3, 0) != 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 254 | printk(BIOS_DEBUG, "Disabling ethernet adapter 3.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 255 | reg32 |= FD_PCIE3; |
| 256 | } else { |
| 257 | if (reg32 & FD_PCIE1) |
| 258 | port_shuffle = 1; |
| 259 | } |
| 260 | |
| 261 | if (port_shuffle) { |
| 262 | /* Enable PCIE6 again */ |
| 263 | reg32 &= ~FD_PCIE6; |
| 264 | /* Swap PCIE6 and PCIE1 */ |
| 265 | RCBA32(RPFN) = 0x00043215; |
| 266 | } |
| 267 | |
| 268 | reg32 |= 1; |
| 269 | |
| 270 | RCBA32(0x3418) = reg32; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 271 | |
| 272 | /* Enable PCIe Root Port Clock Gate */ |
| 273 | // RCBA32(0x341c) = 0x00000001; |
| 274 | } |
| 275 | |
| 276 | static void early_ich7_init(void) |
| 277 | { |
| 278 | uint8_t reg8; |
| 279 | uint32_t reg32; |
| 280 | |
| 281 | // program secondary mlt XXX byte? |
| 282 | pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20); |
| 283 | |
| 284 | // reset rtc power status |
| 285 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa4); |
| 286 | reg8 &= ~(1 << 2); |
| 287 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa4, reg8); |
| 288 | |
| 289 | // usb transient disconnect |
| 290 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xad); |
| 291 | reg8 |= (3 << 0); |
| 292 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xad, reg8); |
| 293 | |
| 294 | reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xfc); |
| 295 | reg32 |= (1 << 29) | (1 << 17); |
| 296 | pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xfc, reg32); |
| 297 | |
| 298 | reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xdc); |
| 299 | reg32 |= (1 << 31) | (1 << 27); |
| 300 | pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xdc, reg32); |
| 301 | |
| 302 | RCBA32(0x0088) = 0x0011d000; |
| 303 | RCBA16(0x01fc) = 0x060f; |
| 304 | RCBA32(0x01f4) = 0x86000040; |
| 305 | RCBA32(0x0214) = 0x10030549; |
| 306 | RCBA32(0x0218) = 0x00020504; |
| 307 | RCBA8(0x0220) = 0xc5; |
| 308 | reg32 = RCBA32(0x3410); |
| 309 | reg32 |= (1 << 6); |
| 310 | RCBA32(0x3410) = reg32; |
| 311 | reg32 = RCBA32(0x3430); |
| 312 | reg32 &= ~(3 << 0); |
| 313 | reg32 |= (1 << 0); |
| 314 | RCBA32(0x3430) = reg32; |
| 315 | RCBA32(0x3418) |= (1 << 0); |
| 316 | RCBA16(0x0200) = 0x2008; |
| 317 | RCBA8(0x2027) = 0x0d; |
| 318 | RCBA16(0x3e08) |= (1 << 7); |
| 319 | RCBA16(0x3e48) |= (1 << 7); |
| 320 | RCBA32(0x3e0e) |= (1 << 7); |
| 321 | RCBA32(0x3e4e) |= (1 << 7); |
| 322 | |
| 323 | // next step only on ich7m b0 and later: |
| 324 | reg32 = RCBA32(0x2034); |
| 325 | reg32 &= ~(0x0f << 16); |
| 326 | reg32 |= (5 << 16); |
| 327 | RCBA32(0x2034) = reg32; |
| 328 | } |
| 329 | |
Aaron Durbin | a0a3727 | 2014-08-14 08:35:11 -0500 | [diff] [blame] | 330 | #include <cpu/intel/romstage.h> |
Stefan Reinauer | 3e1f524 | 2010-04-12 23:04:29 +0000 | [diff] [blame] | 331 | void main(unsigned long bist) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 332 | { |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 333 | int s3resume = 0; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 334 | |
Uwe Hermann | 7b99705 | 2010-11-21 22:47:22 +0000 | [diff] [blame] | 335 | if (bist == 0) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 336 | enable_lapic(); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 337 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 338 | /* Force PCIRST# */ |
| 339 | pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, SBR); |
Stefan Reinauer | bc8613e | 2010-08-25 18:35:42 +0000 | [diff] [blame] | 340 | udelay(200 * 1000); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 341 | pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, 0); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 342 | |
Stefan Reinauer | bc8613e | 2010-08-25 18:35:42 +0000 | [diff] [blame] | 343 | ich7_enable_lpc(); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 344 | early_superio_config_w83627thg(); |
| 345 | |
| 346 | /* Set up the console */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 347 | console_init(); |
| 348 | |
| 349 | /* Halt if there was a built in self test failure */ |
| 350 | report_bist_failure(bist); |
| 351 | |
| 352 | if (MCHBAR16(SSKPD) == 0xCAFE) { |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 353 | printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n"); |
| 354 | outb(0x6, 0xcf9); |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 355 | halt(); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | /* Perform some early chipset initialization required |
| 359 | * before RAM initialization can work |
| 360 | */ |
| 361 | i945_early_initialization(); |
| 362 | |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 363 | s3resume = southbridge_detect_s3_resume(); |
Stefan Reinauer | a5fdadf | 2009-07-21 21:58:20 +0000 | [diff] [blame] | 364 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 365 | /* Enable SPD ROMs and DDR-II DRAM */ |
| 366 | enable_smbus(); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 367 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 368 | #if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 8 |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 369 | dump_spd_registers(); |
| 370 | #endif |
| 371 | |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 372 | sdram_initialize(s3resume ? 2 : 0, NULL); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 373 | |
| 374 | /* Perform some initialization that must run before stage2 */ |
| 375 | early_ich7_init(); |
| 376 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 377 | /* This should probably go away. Until now it is required |
| 378 | * and mainboard specific |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 379 | */ |
| 380 | rcba_config(); |
| 381 | |
| 382 | /* Chipset Errata! */ |
| 383 | fixup_i945_errata(); |
| 384 | |
| 385 | /* Initialize the internal PCIe links before we go into stage2 */ |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 386 | i945_late_initialization(s3resume); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 387 | } |