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. |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 16 | /* __PRE_RAM__ means: use "unsigned" for device, not a struct. */ |
Stefan Reinauer | 5e32823 | 2010-03-29 19:19:16 +0000 | [diff] [blame] | 17 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 18 | #include <stdint.h> |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 19 | #include <halt.h> |
Paul Menzel | 6c20b65 | 2016-12-29 22:54:02 +0100 | [diff] [blame] | 20 | #include <timestamp.h> |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 21 | #include <console/console.h> |
| 22 | #include <cpu/intel/romstage.h> |
| 23 | #include <cpu/x86/bist.h> |
| 24 | #include <cpu/x86/lapic.h> |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 25 | #include <device/pci_def.h> |
| 26 | #include <device/pnp_def.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 27 | #include <pc80/mc146818rtc.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 28 | #include <northbridge/intel/i945/i945.h> |
| 29 | #include <northbridge/intel/i945/raminit.h> |
| 30 | #include <southbridge/intel/i82801gx/i82801gx.h> |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 31 | #include <superio/winbond/common/winbond.h> |
| 32 | #include <superio/winbond/w83627thg/w83627thg.h> |
| 33 | |
| 34 | #include "option_table.h" |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 35 | |
Uwe Hermann | 57b2ff8 | 2010-11-21 17:29:59 +0000 | [diff] [blame] | 36 | #define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1) |
| 37 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 38 | static void ich7_enable_lpc(void) |
| 39 | { |
Patrick Georgi | a470019 | 2011-01-27 07:39:38 +0000 | [diff] [blame] | 40 | int lpt_en = 0; |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 41 | if (read_option(lpt, 0) != 0) |
| 42 | lpt_en = LPT_LPC_EN; /* enable LPT */ |
| 43 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 44 | /* Enable Serial IRQ */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 45 | pci_write_config8(PCI_DEV(0, 0x1f, 0), SERIRQ_CNTL, 0xd0); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 46 | /* Set COM1/COM2 decode range */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 47 | pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_IO_DEC, 0x0010); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 48 | /* Enable COM1/COM2/KBD/SuperIO1+2 */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 49 | pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, CNF2_LPC_EN |
| 50 | | CNF1_LPC_EN | KBC_LPC_EN | FDD_LPC_EN | COMA_LPC_EN |
| 51 | | COMB_LPC_EN | lpt_en); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 52 | /* Enable HWM at 0xa00 */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 53 | pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN1_DEC, 0x00fc0a01); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 54 | /* COM3 decode */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 55 | pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN2_DEC, 0x000403e9); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 56 | /* COM4 decode */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 57 | pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN3_DEC, 0x000402e9); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 58 | /* io 0x300 decode */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 59 | pci_write_config32(PCI_DEV(0, 0x1f, 0), GEN4_DEC, 0x00000301); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 62 | /* This box has two superios, so enabling serial becomes slightly excessive. |
| 63 | * We disable a lot of stuff to make sure that there are no conflicts between |
| 64 | * the two. Also set up the GPIOs from the beginning. This is the "no schematic |
| 65 | * but safe anyways" method. |
| 66 | */ |
| 67 | static void early_superio_config_w83627thg(void) |
| 68 | { |
Antonello Dettori | 9ec1123 | 2016-11-08 18:44:46 +0100 | [diff] [blame] | 69 | pnp_devfn_t dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 70 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 71 | dev = PNP_DEV(0x2e, W83627THG_SP1); |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 72 | pnp_enter_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 73 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 74 | pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 75 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 76 | pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */ |
| 77 | pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 78 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 79 | dev = PNP_DEV(0x2e, W83627THG_SP1); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 80 | pnp_set_logical_device(dev); |
| 81 | pnp_set_enable(dev, 0); |
| 82 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8); |
| 83 | pnp_set_irq(dev, PNP_IDX_IRQ0, 4); |
| 84 | pnp_set_enable(dev, 1); |
| 85 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 86 | dev = PNP_DEV(0x2e, W83627THG_SP2); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 87 | pnp_set_logical_device(dev); |
| 88 | pnp_set_enable(dev, 0); |
| 89 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8); |
| 90 | pnp_set_irq(dev, PNP_IDX_IRQ0, 3); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 91 | pnp_set_enable(dev, 1); |
| 92 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 93 | dev = PNP_DEV(0x2e, W83627THG_KBC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 94 | pnp_set_logical_device(dev); |
| 95 | pnp_set_enable(dev, 0); |
| 96 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x60); |
| 97 | pnp_set_iobase(dev, PNP_IDX_IO1, 0x64); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 98 | pnp_set_enable(dev, 1); |
| 99 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 100 | dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 101 | pnp_set_logical_device(dev); |
| 102 | pnp_set_enable(dev, 0); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 103 | pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 104 | pnp_set_enable(dev, 1); |
| 105 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 106 | dev = PNP_DEV(0x2e, W83627THG_GPIO2); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 107 | pnp_set_logical_device(dev); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 108 | pnp_set_enable(dev, 1); /* Just enable it */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 109 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 110 | dev = PNP_DEV(0x2e, W83627THG_GPIO3); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 111 | pnp_set_logical_device(dev); |
| 112 | pnp_set_enable(dev, 0); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 113 | pnp_write_config(dev, 0xf0, 0xfb); /* GPIO bit 2 is output */ |
| 114 | pnp_write_config(dev, 0xf1, 0x00); /* GPIO bit 2 is 0 */ |
| 115 | pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO3+4. pnp_set_enable is not sufficient */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 116 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 117 | dev = PNP_DEV(0x2e, W83627THG_FDC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 118 | pnp_set_logical_device(dev); |
| 119 | pnp_set_enable(dev, 0); |
| 120 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 121 | dev = PNP_DEV(0x2e, W83627THG_PP); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 122 | pnp_set_logical_device(dev); |
| 123 | pnp_set_enable(dev, 0); |
| 124 | |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame] | 125 | /* Enable HWM */ |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 126 | dev = PNP_DEV(0x2e, W83627THG_HWM); |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame] | 127 | pnp_set_logical_device(dev); |
| 128 | pnp_set_enable(dev, 0); |
| 129 | pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00); |
| 130 | pnp_set_enable(dev, 1); |
| 131 | |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 132 | pnp_exit_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 133 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 134 | dev = PNP_DEV(0x4e, W83627THG_SP1); |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 135 | pnp_enter_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 136 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 137 | pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 138 | pnp_set_enable(dev, 0); |
| 139 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8); |
| 140 | pnp_set_irq(dev, PNP_IDX_IRQ0, 11); |
| 141 | pnp_set_enable(dev, 1); |
| 142 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 143 | dev = PNP_DEV(0x4e, W83627THG_SP2); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 144 | pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 145 | pnp_set_enable(dev, 0); |
| 146 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8); |
| 147 | pnp_set_irq(dev, PNP_IDX_IRQ0, 10); |
| 148 | pnp_set_enable(dev, 1); |
| 149 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 150 | dev = PNP_DEV(0x4e, W83627THG_FDC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 151 | pnp_set_logical_device(dev); |
| 152 | pnp_set_enable(dev, 0); |
| 153 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 154 | dev = PNP_DEV(0x4e, W83627THG_PP); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 155 | pnp_set_logical_device(dev); |
| 156 | pnp_set_enable(dev, 0); |
| 157 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 158 | dev = PNP_DEV(0x4e, W83627THG_KBC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 159 | pnp_set_logical_device(dev); |
| 160 | pnp_set_enable(dev, 0); |
| 161 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x00); |
| 162 | pnp_set_iobase(dev, PNP_IDX_IO1, 0x00); |
| 163 | |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame^] | 164 | pnp_exit_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | static void rcba_config(void) |
| 168 | { |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 169 | u32 reg32; |
| 170 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 171 | /* Set up virtual channel 0 */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 172 | |
| 173 | /* Device 1f interrupt pin register */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 174 | RCBA32(D31IP) = 0x00042210; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 175 | /* Device 1d interrupt pin register */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 176 | RCBA32(D28IP) = 0x00214321; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 177 | |
| 178 | /* dev irq route register */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 179 | RCBA16(D31IR) = 0x0132; |
| 180 | RCBA16(D30IR) = 0x3241; |
| 181 | RCBA16(D29IR) = 0x0237; |
| 182 | RCBA16(D28IR) = 0x3210; |
| 183 | RCBA16(D27IR) = 0x3210; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 184 | |
| 185 | /* Enable IOAPIC */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 186 | RCBA8(OIC) = 0x03; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 187 | |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 188 | /* Now, this is a bit ugly. As per PCI specification, function 0 of a |
| 189 | * device always has to be implemented. So disabling ethernet port 1 |
| 190 | * would essentially disable all three ethernet ports of the mainboard. |
| 191 | * It's possible to rename the ports to achieve compatibility to the |
| 192 | * PCI spec but this will confuse all (static!) tables containing |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 193 | * interrupt routing information. |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 194 | * To avoid this, we enable (unused) port 6 and swap it with port 1 |
| 195 | * in the case that ethernet port 1 is disabled. Since no devices |
| 196 | * are connected to that port, we don't have to worry about interrupt |
| 197 | * routing. |
| 198 | */ |
| 199 | int port_shuffle = 0; |
| 200 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 201 | /* Disable unused devices */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 202 | reg32 = FD_ACMOD|FD_ACAUD|FD_PATA; |
| 203 | reg32 |= FD_PCIE6|FD_PCIE5|FD_PCIE4; |
| 204 | |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 205 | if (read_option(ethernet1, 0) != 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 206 | printk(BIOS_DEBUG, "Disabling ethernet adapter 1.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 207 | reg32 |= FD_PCIE1; |
| 208 | } |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 209 | if (read_option(ethernet2, 0) != 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 210 | printk(BIOS_DEBUG, "Disabling ethernet adapter 2.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 211 | reg32 |= FD_PCIE2; |
| 212 | } else { |
| 213 | if (reg32 & FD_PCIE1) |
| 214 | port_shuffle = 1; |
| 215 | } |
Patrick Georgi | b251753 | 2011-05-10 21:53:13 +0000 | [diff] [blame] | 216 | if (read_option(ethernet3, 0) != 0) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 217 | printk(BIOS_DEBUG, "Disabling ethernet adapter 3.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 218 | reg32 |= FD_PCIE3; |
| 219 | } else { |
| 220 | if (reg32 & FD_PCIE1) |
| 221 | port_shuffle = 1; |
| 222 | } |
| 223 | |
| 224 | if (port_shuffle) { |
| 225 | /* Enable PCIE6 again */ |
| 226 | reg32 &= ~FD_PCIE6; |
| 227 | /* Swap PCIE6 and PCIE1 */ |
| 228 | RCBA32(RPFN) = 0x00043215; |
| 229 | } |
| 230 | |
| 231 | reg32 |= 1; |
| 232 | |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 233 | RCBA32(FD) = reg32; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 234 | |
| 235 | /* Enable PCIe Root Port Clock Gate */ |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 236 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | static void early_ich7_init(void) |
| 240 | { |
| 241 | uint8_t reg8; |
| 242 | uint32_t reg32; |
| 243 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 244 | /* program secondary mlt XXX byte? */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 245 | pci_write_config8(PCI_DEV(0, 0x1e, 0), 0x1b, 0x20); |
| 246 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 247 | /* reset rtc power status */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 248 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa4); |
| 249 | reg8 &= ~(1 << 2); |
| 250 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa4, reg8); |
| 251 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 252 | /* usb transient disconnect */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 253 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xad); |
| 254 | reg8 |= (3 << 0); |
| 255 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xad, reg8); |
| 256 | |
| 257 | reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xfc); |
| 258 | reg32 |= (1 << 29) | (1 << 17); |
| 259 | pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xfc, reg32); |
| 260 | |
| 261 | reg32 = pci_read_config32(PCI_DEV(0, 0x1d, 7), 0xdc); |
| 262 | reg32 |= (1 << 31) | (1 << 27); |
| 263 | pci_write_config32(PCI_DEV(0, 0x1d, 7), 0xdc, reg32); |
| 264 | |
| 265 | RCBA32(0x0088) = 0x0011d000; |
| 266 | RCBA16(0x01fc) = 0x060f; |
| 267 | RCBA32(0x01f4) = 0x86000040; |
| 268 | RCBA32(0x0214) = 0x10030549; |
| 269 | RCBA32(0x0218) = 0x00020504; |
| 270 | RCBA8(0x0220) = 0xc5; |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 271 | reg32 = RCBA32(GCS); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 272 | reg32 |= (1 << 6); |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 273 | RCBA32(GCS) = reg32; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 274 | reg32 = RCBA32(0x3430); |
| 275 | reg32 &= ~(3 << 0); |
| 276 | reg32 |= (1 << 0); |
| 277 | RCBA32(0x3430) = reg32; |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 278 | RCBA32(FD) |= (1 << 0); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 279 | RCBA16(0x0200) = 0x2008; |
| 280 | RCBA8(0x2027) = 0x0d; |
| 281 | RCBA16(0x3e08) |= (1 << 7); |
| 282 | RCBA16(0x3e48) |= (1 << 7); |
| 283 | RCBA32(0x3e0e) |= (1 << 7); |
| 284 | RCBA32(0x3e4e) |= (1 << 7); |
| 285 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 286 | /* next step only on ich7m b0 and later: */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 287 | reg32 = RCBA32(0x2034); |
| 288 | reg32 &= ~(0x0f << 16); |
| 289 | reg32 |= (5 << 16); |
| 290 | RCBA32(0x2034) = reg32; |
| 291 | } |
| 292 | |
Kyösti Mälkki | 15fa992 | 2016-06-17 10:00:28 +0300 | [diff] [blame] | 293 | void mainboard_romstage_entry(unsigned long bist) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 294 | { |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 295 | int s3resume = 0; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 296 | |
Paul Menzel | 6c20b65 | 2016-12-29 22:54:02 +0100 | [diff] [blame] | 297 | |
| 298 | timestamp_init(get_initial_timestamp()); |
| 299 | timestamp_add_now(TS_START_ROMSTAGE); |
| 300 | |
Uwe Hermann | 7b99705 | 2010-11-21 22:47:22 +0000 | [diff] [blame] | 301 | if (bist == 0) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 302 | enable_lapic(); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 303 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 304 | /* Force PCIRST# */ |
| 305 | pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, SBR); |
Stefan Reinauer | bc8613e | 2010-08-25 18:35:42 +0000 | [diff] [blame] | 306 | udelay(200 * 1000); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 307 | pci_write_config16(PCI_DEV(0, 0x1e, 0), BCTRL, 0); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 308 | |
Stefan Reinauer | bc8613e | 2010-08-25 18:35:42 +0000 | [diff] [blame] | 309 | ich7_enable_lpc(); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 310 | early_superio_config_w83627thg(); |
| 311 | |
| 312 | /* Set up the console */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 313 | console_init(); |
| 314 | |
| 315 | /* Halt if there was a built in self test failure */ |
| 316 | report_bist_failure(bist); |
| 317 | |
| 318 | if (MCHBAR16(SSKPD) == 0xCAFE) { |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 319 | printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n"); |
| 320 | outb(0x6, 0xcf9); |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 321 | halt(); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | /* Perform some early chipset initialization required |
| 325 | * before RAM initialization can work |
| 326 | */ |
| 327 | i945_early_initialization(); |
| 328 | |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 329 | s3resume = southbridge_detect_s3_resume(); |
Stefan Reinauer | a5fdadf | 2009-07-21 21:58:20 +0000 | [diff] [blame] | 330 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 331 | /* Enable SPD ROMs and DDR-II DRAM */ |
| 332 | enable_smbus(); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 333 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 334 | #if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 8 |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 335 | dump_spd_registers(); |
| 336 | #endif |
| 337 | |
Paul Menzel | 6c20b65 | 2016-12-29 22:54:02 +0100 | [diff] [blame] | 338 | timestamp_add_now(TS_BEFORE_INITRAM); |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 339 | sdram_initialize(s3resume ? 2 : 0, NULL); |
Paul Menzel | 6c20b65 | 2016-12-29 22:54:02 +0100 | [diff] [blame] | 340 | timestamp_add_now(TS_AFTER_INITRAM); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 341 | |
| 342 | /* Perform some initialization that must run before stage2 */ |
| 343 | early_ich7_init(); |
| 344 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 345 | /* This should probably go away. Until now it is required |
| 346 | * and mainboard specific |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 347 | */ |
| 348 | rcba_config(); |
| 349 | |
| 350 | /* Chipset Errata! */ |
| 351 | fixup_i945_errata(); |
| 352 | |
| 353 | /* Initialize the internal PCIe links before we go into stage2 */ |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 354 | i945_late_initialization(s3resume); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 355 | } |