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