Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2010 coresystems GmbH |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 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; version 2 of the License. |
| 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 | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 16 | #include <stdlib.h> |
Elyes HAOUAS | 5db9871 | 2019-04-21 18:50:34 +0200 | [diff] [blame] | 17 | #include <cf9_reset.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <arch/io.h> |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 20 | #include <delay.h> |
| 21 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 22 | #include <device/pci_ops.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 23 | #include <device/pci_def.h> |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 24 | #include <cbmem.h> |
Kyösti Mälkki | 8183025 | 2016-06-25 11:40:00 +0300 | [diff] [blame] | 25 | #include <romstage_handoff.h> |
Arthur Heymans | 874a8f9 | 2016-05-19 16:06:09 +0200 | [diff] [blame] | 26 | #include <pc80/mc146818rtc.h> |
Arthur Heymans | 62902ca | 2016-11-29 14:13:43 +0100 | [diff] [blame] | 27 | #include <southbridge/intel/common/gpio.h> |
Elyes HAOUAS | 51401c3 | 2019-05-15 21:09:30 +0200 | [diff] [blame] | 28 | #include <types.h> |
| 29 | |
| 30 | #include "i945.h" |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 31 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 32 | int i945_silicon_revision(void) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 33 | { |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 34 | return pci_read_config8(PCI_DEV(0, 0x00, 0), PCI_CLASS_REVISION); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 37 | static void i945m_detect_chipset(void) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 38 | { |
| 39 | u8 reg8; |
| 40 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 41 | printk(BIOS_INFO, "\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 42 | reg8 = (pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe7) & 0x70) >> 4; |
| 43 | switch (reg8) { |
| 44 | case 1: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 45 | printk(BIOS_INFO, "Mobile Intel(R) 82945GM/GME Express"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 46 | break; |
| 47 | case 2: |
Stefan Reinauer | 7981b94 | 2011-04-01 22:33:25 +0200 | [diff] [blame] | 48 | printk(BIOS_INFO, "Mobile Intel(R) 82945GMS/GU/GSE Express"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 49 | break; |
| 50 | case 3: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 51 | printk(BIOS_INFO, "Mobile Intel(R) 82945PM Express"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 52 | break; |
| 53 | case 5: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 54 | printk(BIOS_INFO, "Intel(R) 82945GT Express"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 55 | break; |
| 56 | case 6: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 57 | printk(BIOS_INFO, "Mobile Intel(R) 82943/82940GML Express"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 58 | break; |
| 59 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 60 | printk(BIOS_INFO, "Unknown (%02x)", reg8); /* Others reserved. */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 61 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 62 | printk(BIOS_INFO, " Chipset\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 63 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 64 | printk(BIOS_DEBUG, "(G)MCH capable of up to FSB "); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 65 | reg8 = (pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe3) & 0xe0) >> 5; |
| 66 | switch (reg8) { |
| 67 | case 2: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 68 | printk(BIOS_DEBUG, "800 MHz"); /* According to 965 spec */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 69 | break; |
| 70 | case 3: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 71 | printk(BIOS_DEBUG, "667 MHz"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 72 | break; |
| 73 | case 4: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 74 | printk(BIOS_DEBUG, "533 MHz"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 75 | break; |
| 76 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 77 | printk(BIOS_DEBUG, "N/A MHz (%02x)", reg8); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 78 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 79 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 80 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 81 | printk(BIOS_DEBUG, "(G)MCH capable of "); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 82 | reg8 = (pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe4) & 0x07); |
| 83 | switch (reg8) { |
| 84 | case 2: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 85 | printk(BIOS_DEBUG, "up to DDR2-667"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 86 | break; |
| 87 | case 3: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 88 | printk(BIOS_DEBUG, "up to DDR2-533"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 89 | break; |
| 90 | case 4: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 91 | printk(BIOS_DEBUG, "DDR2-400"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 92 | break; |
| 93 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 94 | printk(BIOS_INFO, "unknown max. RAM clock (%02x).", reg8); /* Others reserved. */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 95 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 96 | printk(BIOS_DEBUG, "\n"); |
Elyes HAOUAS | 6372a0e | 2016-10-30 18:39:53 +0100 | [diff] [blame] | 97 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 98 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) |
Elyes HAOUAS | 6372a0e | 2016-10-30 18:39:53 +0100 | [diff] [blame] | 99 | printk(BIOS_ERR, "coreboot is compiled for the wrong chipset.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 102 | static void i945_detect_chipset(void) |
| 103 | { |
| 104 | u8 reg8; |
| 105 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 106 | printk(BIOS_INFO, "\nIntel(R) "); |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 107 | |
| 108 | reg8 = ((pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe7) >> 5) & 4) | ((pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe4) >> 4) & 3); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 109 | switch (reg8) { |
| 110 | case 0: |
| 111 | case 1: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 112 | printk(BIOS_INFO, "82945G"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 113 | break; |
| 114 | case 2: |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 115 | case 3: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 116 | printk(BIOS_INFO, "82945P"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 117 | break; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 118 | case 4: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 119 | printk(BIOS_INFO, "82945GC"); |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 120 | break; |
| 121 | case 5: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 122 | printk(BIOS_INFO, "82945GZ"); |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 123 | break; |
| 124 | case 6: |
| 125 | case 7: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 126 | printk(BIOS_INFO, "82945PL"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 127 | break; |
| 128 | default: |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 129 | break; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 130 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 131 | printk(BIOS_INFO, " Chipset\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 132 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 133 | printk(BIOS_DEBUG, "(G)MCH capable of "); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 134 | reg8 = (pci_read_config8(PCI_DEV(0, 0x00, 0), 0xe4) & 0x07); |
| 135 | switch (reg8) { |
| 136 | case 0: |
Elyes HAOUAS | 5db9450 | 2016-10-30 18:30:21 +0100 | [diff] [blame] | 137 | case 2: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 138 | printk(BIOS_DEBUG, "up to DDR2-667"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 139 | break; |
| 140 | case 3: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 141 | printk(BIOS_DEBUG, "up to DDR2-533"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 142 | break; |
| 143 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 144 | printk(BIOS_INFO, "unknown max. RAM clock (%02x).", reg8); /* Others reserved. */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 145 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 146 | printk(BIOS_DEBUG, "\n"); |
Elyes HAOUAS | 6372a0e | 2016-10-30 18:39:53 +0100 | [diff] [blame] | 147 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 148 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) |
Elyes HAOUAS | 6372a0e | 2016-10-30 18:39:53 +0100 | [diff] [blame] | 149 | printk(BIOS_ERR, "coreboot is compiled for the wrong chipset.\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 152 | static void i945_setup_bars(void) |
| 153 | { |
Arthur Heymans | 874a8f9 | 2016-05-19 16:06:09 +0200 | [diff] [blame] | 154 | u8 reg8, gfxsize; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 155 | |
| 156 | /* As of now, we don't have all the A0 workarounds implemented */ |
| 157 | if (i945_silicon_revision() == 0) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 158 | printk(BIOS_INFO, "Warning: i945 silicon revision A0 might not work correctly.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 159 | |
| 160 | /* Setting up Southbridge. In the northbridge code. */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 161 | printk(BIOS_DEBUG, "Setting up static southbridge registers..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 162 | |
| 163 | pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, DEFAULT_PMBASE | 1); |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 164 | pci_write_config8(PCI_DEV(0, 0x1f, 0), ACPI_CNTL, ACPI_EN); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 165 | |
| 166 | pci_write_config32(PCI_DEV(0, 0x1f, 0), GPIOBASE, DEFAULT_GPIOBASE | 1); |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 167 | pci_write_config8(PCI_DEV(0, 0x1f, 0), GPIO_CNTL, GPIO_EN); |
Arthur Heymans | 62902ca | 2016-11-29 14:13:43 +0100 | [diff] [blame] | 168 | setup_pch_gpios(&mainboard_gpio_map); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 169 | printk(BIOS_DEBUG, " done.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 170 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 171 | printk(BIOS_DEBUG, "Disabling Watchdog reboot..."); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 172 | RCBA32(GCS) = RCBA32(GCS) | (1 << 5); /* No reset */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 173 | outw((1 << 11), DEFAULT_PMBASE | 0x60 | 0x08); /* halt timer */ |
Nico Huber | 0b80bd1 | 2017-09-09 19:46:44 +0200 | [diff] [blame] | 174 | outw((1 << 3), DEFAULT_PMBASE | 0x60 | 0x04); /* clear timeout */ |
| 175 | outw((1 << 1), DEFAULT_PMBASE | 0x60 | 0x06); /* clear 2nd timeout */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 176 | printk(BIOS_DEBUG, " done.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 177 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 178 | printk(BIOS_DEBUG, "Setting up static northbridge registers..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 179 | /* Set up all hardcoded northbridge BARs */ |
| 180 | pci_write_config32(PCI_DEV(0, 0x00, 0), EPBAR, DEFAULT_EPBAR | 1); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 181 | pci_write_config32(PCI_DEV(0, 0x00, 0), MCHBAR, (uintptr_t)DEFAULT_MCHBAR | 1); |
| 182 | pci_write_config32(PCI_DEV(0, 0x00, 0), DMIBAR, (uintptr_t)DEFAULT_DMIBAR | 1); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 183 | pci_write_config32(PCI_DEV(0, 0x00, 0), X60BAR, DEFAULT_X60BAR | 1); |
| 184 | |
Arthur Heymans | 874a8f9 | 2016-05-19 16:06:09 +0200 | [diff] [blame] | 185 | /* vram size from cmos option */ |
| 186 | if (get_option(&gfxsize, "gfx_uma_size") != CB_SUCCESS) |
| 187 | gfxsize = 2; /* 2 for 8MB */ |
| 188 | /* make sure no invalid setting is used */ |
| 189 | if (gfxsize > 6) |
| 190 | gfxsize = 2; |
| 191 | pci_write_config16(PCI_DEV(0, 0x00, 0), GGC, ((gfxsize + 1) << 4)); |
Arthur Heymans | d522db0 | 2018-08-06 15:50:54 +0200 | [diff] [blame] | 192 | /* TSEG 2M, This amount can easily be covered by SMRR MTRR's, |
| 193 | which requires to have TSEG_BASE aligned to TSEG_SIZE. */ |
Arthur Heymans | e07df9d | 2018-04-09 22:03:21 +0200 | [diff] [blame] | 194 | reg8 = pci_read_config8(PCI_DEV(0, 0, 0), ESMRAMC); |
| 195 | reg8 &= ~0x7; |
Arthur Heymans | d522db0 | 2018-08-06 15:50:54 +0200 | [diff] [blame] | 196 | reg8 |= (1 << 1) | (1 << 0); /* 2M and TSEG_Enable */ |
Arthur Heymans | e07df9d | 2018-04-09 22:03:21 +0200 | [diff] [blame] | 197 | pci_write_config8(PCI_DEV(0, 0, 0), ESMRAMC, reg8); |
| 198 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 199 | /* Set C0000-FFFFF to access RAM on both reads and writes */ |
| 200 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM0, 0x30); |
| 201 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM1, 0x33); |
| 202 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM2, 0x33); |
| 203 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM3, 0x33); |
| 204 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM4, 0x33); |
| 205 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM5, 0x33); |
| 206 | pci_write_config8(PCI_DEV(0, 0x00, 0), PAM6, 0x33); |
| 207 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 208 | printk(BIOS_DEBUG, " done.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 209 | |
| 210 | /* Wait for MCH BAR to come up */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 211 | printk(BIOS_DEBUG, "Waiting for MCHBAR to come up..."); |
Elyes HAOUAS | a3ea1e4 | 2014-11-27 13:23:32 +0100 | [diff] [blame] | 212 | if ((pci_read_config32(PCI_DEV(0, 0x00, 0), 0xe4) & 0x20000) == 0x00) { /* Bit 49 of CAPID0 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 213 | do { |
| 214 | reg8 = *(volatile u8 *)0xfed40000; |
| 215 | } while (!(reg8 & 0x80)); |
| 216 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 217 | printk(BIOS_DEBUG, "ok\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | static void i945_setup_egress_port(void) |
| 221 | { |
| 222 | u32 reg32; |
| 223 | u32 timeout; |
| 224 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 225 | printk(BIOS_DEBUG, "Setting up Egress Port RCRB\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 226 | |
| 227 | /* Egress Port Virtual Channel 0 Configuration */ |
| 228 | |
| 229 | /* map only TC0 to VC0 */ |
| 230 | reg32 = EPBAR32(EPVC0RCTL); |
| 231 | reg32 &= 0xffffff01; |
| 232 | EPBAR32(EPVC0RCTL) = reg32; |
| 233 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 234 | reg32 = EPBAR32(EPPVCCAP1); |
| 235 | reg32 &= ~(7 << 0); |
| 236 | reg32 |= 1; |
| 237 | EPBAR32(EPPVCCAP1) = reg32; |
| 238 | |
| 239 | /* Egress Port Virtual Channel 1 Configuration */ |
| 240 | reg32 = EPBAR32(0x2c); |
| 241 | reg32 &= 0xffffff00; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 242 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Elyes HAOUAS | f7acdf8 | 2016-10-31 18:55:04 +0100 | [diff] [blame] | 243 | if ((MCHBAR32(CLKCFG) & 7) == 0) |
| 244 | reg32 |= 0x1a; /* 1067MHz */ |
| 245 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 246 | if ((MCHBAR32(CLKCFG) & 7) == 1) |
| 247 | reg32 |= 0x0d; /* 533MHz */ |
Elyes HAOUAS | f7acdf8 | 2016-10-31 18:55:04 +0100 | [diff] [blame] | 248 | if ((MCHBAR32(CLKCFG) & 7) == 2) |
| 249 | reg32 |= 0x14; /* 800MHz */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 250 | if ((MCHBAR32(CLKCFG) & 7) == 3) |
| 251 | reg32 |= 0x10; /* 667MHz */ |
| 252 | EPBAR32(0x2c) = reg32; |
| 253 | |
| 254 | EPBAR32(EPVC1MTS) = 0x0a0a0a0a; |
| 255 | |
| 256 | reg32 = EPBAR32(EPVC1RCAP); |
| 257 | reg32 &= ~(0x7f << 16); |
| 258 | reg32 |= (0x0a << 16); |
| 259 | EPBAR32(EPVC1RCAP) = reg32; |
| 260 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 261 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 262 | if ((MCHBAR32(CLKCFG) & 7) == 0) { /* 1067MHz */ |
Elyes HAOUAS | f7acdf8 | 2016-10-31 18:55:04 +0100 | [diff] [blame] | 263 | EPBAR32(EPVC1IST + 0) = 0x01380138; |
| 264 | EPBAR32(EPVC1IST + 4) = 0x01380138; |
| 265 | } |
| 266 | } |
| 267 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 268 | if ((MCHBAR32(CLKCFG) & 7) == 1) { /* 533MHz */ |
| 269 | EPBAR32(EPVC1IST + 0) = 0x009c009c; |
| 270 | EPBAR32(EPVC1IST + 4) = 0x009c009c; |
| 271 | } |
| 272 | |
Elyes HAOUAS | f7acdf8 | 2016-10-31 18:55:04 +0100 | [diff] [blame] | 273 | if ((MCHBAR32(CLKCFG) & 7) == 2) { /* 800MHz */ |
| 274 | EPBAR32(EPVC1IST + 0) = 0x00f000f0; |
| 275 | EPBAR32(EPVC1IST + 4) = 0x00f000f0; |
| 276 | } |
| 277 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 278 | if ((MCHBAR32(CLKCFG) & 7) == 3) { /* 667MHz */ |
| 279 | EPBAR32(EPVC1IST + 0) = 0x00c000c0; |
| 280 | EPBAR32(EPVC1IST + 4) = 0x00c000c0; |
| 281 | } |
| 282 | |
| 283 | /* Is internal graphics enabled? */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 284 | if (pci_read_config8(PCI_DEV(0, 0x0, 0), DEVEN) & (DEVEN_D2F0 | DEVEN_D2F1)) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 285 | MCHBAR32(MMARB1) |= (1 << 17); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 286 | |
| 287 | /* Assign Virtual Channel ID 1 to VC1 */ |
| 288 | reg32 = EPBAR32(EPVC1RCTL); |
| 289 | reg32 &= ~(7 << 24); |
| 290 | reg32 |= (1 << 24); |
| 291 | EPBAR32(EPVC1RCTL) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 292 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 293 | reg32 = EPBAR32(EPVC1RCTL); |
| 294 | reg32 &= 0xffffff01; |
| 295 | reg32 |= (1 << 7); |
| 296 | EPBAR32(EPVC1RCTL) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 297 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 298 | EPBAR32(PORTARB + 0x00) = 0x01000001; |
| 299 | EPBAR32(PORTARB + 0x04) = 0x00040000; |
| 300 | EPBAR32(PORTARB + 0x08) = 0x00001000; |
| 301 | EPBAR32(PORTARB + 0x0c) = 0x00000040; |
| 302 | EPBAR32(PORTARB + 0x10) = 0x01000001; |
| 303 | EPBAR32(PORTARB + 0x14) = 0x00040000; |
| 304 | EPBAR32(PORTARB + 0x18) = 0x00001000; |
| 305 | EPBAR32(PORTARB + 0x1c) = 0x00000040; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 306 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 307 | EPBAR32(EPVC1RCTL) |= (1 << 16); |
| 308 | EPBAR32(EPVC1RCTL) |= (1 << 16); |
| 309 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 310 | printk(BIOS_DEBUG, "Loading port arbitration table ..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 311 | /* Loop until bit 0 becomes 0 */ |
| 312 | timeout = 0x7fffff; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 313 | while ((EPBAR16(EPVC1RSTS) & 1) && --timeout) |
| 314 | ; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 315 | if (!timeout) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 316 | printk(BIOS_DEBUG, "timeout!\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 317 | else |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 318 | printk(BIOS_DEBUG, "ok\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 319 | |
| 320 | /* Now enable VC1 */ |
| 321 | EPBAR32(EPVC1RCTL) |= (1 << 31); |
| 322 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 323 | printk(BIOS_DEBUG, "Wait for VC1 negotiation ..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 324 | /* Wait for VC1 negotiation pending */ |
| 325 | timeout = 0x7fff; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 326 | while ((EPBAR16(EPVC1RSTS) & (1 << 1)) && --timeout) |
| 327 | ; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 328 | if (!timeout) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 329 | printk(BIOS_DEBUG, "timeout!\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 330 | else |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 331 | printk(BIOS_DEBUG, "ok\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 332 | |
| 333 | } |
| 334 | |
| 335 | static void ich7_setup_dmi_rcrb(void) |
| 336 | { |
| 337 | u16 reg16; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 338 | u32 reg32; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 339 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 340 | reg16 = RCBA16(LCTL); |
| 341 | reg16 &= ~(3 << 0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 342 | reg16 |= 3; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 343 | RCBA16(LCTL) = reg16; |
| 344 | |
| 345 | RCBA32(V0CTL) = 0x80000001; |
| 346 | RCBA32(V1CAP) = 0x03128010; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 347 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 348 | pci_write_config16(PCI_DEV(0, 0x1c, 0), 0x42, 0x0141); |
| 349 | pci_write_config16(PCI_DEV(0, 0x1c, 4), 0x42, 0x0141); |
| 350 | pci_write_config16(PCI_DEV(0, 0x1c, 5), 0x42, 0x0141); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 351 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 352 | pci_write_config32(PCI_DEV(0, 0x1c, 4), 0x54, 0x00480ce0); |
| 353 | pci_write_config32(PCI_DEV(0, 0x1c, 5), 0x54, 0x00500ce0); |
| 354 | |
| 355 | reg32 = RCBA32(V1CTL); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 356 | reg32 &= ~((0x7f << 1) | (7 << 17) | (7 << 24)); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 357 | reg32 |= (0x40 << 1) | (4 << 17) | (1 << 24) | (1 << 31); |
| 358 | RCBA32(V1CTL) = reg32; |
| 359 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 360 | RCBA32(LCAP) |= (3 << 10); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static void i945_setup_dmi_rcrb(void) |
| 364 | { |
| 365 | u32 reg32; |
| 366 | u32 timeout; |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 367 | int activate_aspm = 1; /* hardcode ASPM for now */ |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 368 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 369 | printk(BIOS_DEBUG, "Setting up DMI RCRB\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 370 | |
| 371 | /* Virtual Channel 0 Configuration */ |
| 372 | reg32 = DMIBAR32(DMIVC0RCTL0); |
| 373 | reg32 &= 0xffffff01; |
| 374 | DMIBAR32(DMIVC0RCTL0) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 375 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 376 | reg32 = DMIBAR32(DMIPVCCAP1); |
| 377 | reg32 &= ~(7 << 0); |
| 378 | reg32 |= 1; |
| 379 | DMIBAR32(DMIPVCCAP1) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 380 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 381 | reg32 = DMIBAR32(DMIVC1RCTL); |
| 382 | reg32 &= ~(7 << 24); |
| 383 | reg32 |= (1 << 24); /* NOTE: This ID must match ICH7 side */ |
| 384 | DMIBAR32(DMIVC1RCTL) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 385 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 386 | reg32 = DMIBAR32(DMIVC1RCTL); |
| 387 | reg32 &= 0xffffff01; |
| 388 | reg32 |= (1 << 7); |
| 389 | DMIBAR32(DMIVC1RCTL) = reg32; |
| 390 | |
| 391 | /* Now enable VC1 */ |
| 392 | DMIBAR32(DMIVC1RCTL) |= (1 << 31); |
| 393 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 394 | printk(BIOS_DEBUG, "Wait for VC1 negotiation ..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 395 | /* Wait for VC1 negotiation pending */ |
| 396 | timeout = 0x7ffff; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 397 | while ((DMIBAR16(DMIVC1RSTS) & (1 << 1)) && --timeout) |
| 398 | ; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 399 | if (!timeout) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 400 | printk(BIOS_DEBUG, "timeout!\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 401 | else |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 402 | printk(BIOS_DEBUG, "done..\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 403 | #if 1 |
| 404 | /* Enable Active State Power Management (ASPM) L0 state */ |
| 405 | |
| 406 | reg32 = DMIBAR32(DMILCAP); |
| 407 | reg32 &= ~(7 << 12); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 408 | reg32 |= (2 << 12); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 409 | |
| 410 | reg32 &= ~(7 << 15); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 411 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 412 | reg32 |= (2 << 15); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 413 | DMIBAR32(DMILCAP) = reg32; |
| 414 | |
| 415 | reg32 = DMIBAR32(DMICC); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 416 | reg32 &= 0x00ffffff; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 417 | reg32 &= ~(3 << 0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 418 | reg32 |= (1 << 0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 419 | reg32 &= ~(3 << 20); |
| 420 | reg32 |= (1 << 20); |
| 421 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 422 | DMIBAR32(DMICC) = reg32; |
| 423 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 424 | if (activate_aspm) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 425 | DMIBAR32(DMILCTL) |= (3 << 0); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 426 | #endif |
| 427 | |
| 428 | /* Last but not least, some additional steps */ |
| 429 | reg32 = MCHBAR32(FSBSNPCTL); |
| 430 | reg32 &= ~(0xff << 2); |
| 431 | reg32 |= (0xaa << 2); |
| 432 | MCHBAR32(FSBSNPCTL) = reg32; |
| 433 | |
| 434 | DMIBAR32(0x2c) = 0x86000040; |
| 435 | |
| 436 | reg32 = DMIBAR32(0x204); |
| 437 | reg32 &= ~0x3ff; |
| 438 | #if 1 |
| 439 | reg32 |= 0x13f; /* for x4 DMI only */ |
| 440 | #else |
| 441 | reg32 |= 0x1e4; /* for x2 DMI only */ |
| 442 | #endif |
| 443 | DMIBAR32(0x204) = reg32; |
| 444 | |
Kyösti Mälkki | 3c3e34d | 2014-05-31 11:32:54 +0300 | [diff] [blame] | 445 | if (pci_read_config8(PCI_DEV(0, 0x0, 0), DEVEN) & (DEVEN_D2F0 | DEVEN_D2F1)) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 446 | printk(BIOS_DEBUG, "Internal graphics: enabled\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 447 | DMIBAR32(0x200) |= (1 << 21); |
| 448 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 449 | printk(BIOS_DEBUG, "Internal graphics: disabled\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 450 | DMIBAR32(0x200) &= ~(1 << 21); |
| 451 | } |
| 452 | |
| 453 | reg32 = DMIBAR32(0x204); |
| 454 | reg32 &= ~((1 << 11) | (1 << 10)); |
| 455 | DMIBAR32(0x204) = reg32; |
| 456 | |
| 457 | reg32 = DMIBAR32(0x204); |
| 458 | reg32 &= ~(0xff << 12); |
| 459 | reg32 |= (0x0d << 12); |
| 460 | DMIBAR32(0x204) = reg32; |
| 461 | |
| 462 | DMIBAR32(DMICTL1) |= (3 << 24); |
| 463 | |
| 464 | reg32 = DMIBAR32(0x200); |
| 465 | reg32 &= ~(0x3 << 26); |
| 466 | reg32 |= (0x02 << 26); |
| 467 | DMIBAR32(0x200) = reg32; |
| 468 | |
| 469 | DMIBAR32(DMIDRCCFG) &= ~(1 << 31); |
| 470 | DMIBAR32(DMICTL2) |= (1 << 31); |
| 471 | |
| 472 | if (i945_silicon_revision() >= 3) { |
| 473 | reg32 = DMIBAR32(0xec0); |
| 474 | reg32 &= 0x0fffffff; |
| 475 | reg32 |= (2 << 28); |
| 476 | DMIBAR32(0xec0) = reg32; |
| 477 | |
| 478 | reg32 = DMIBAR32(0xed4); |
| 479 | reg32 &= 0x0fffffff; |
| 480 | reg32 |= (2 << 28); |
| 481 | DMIBAR32(0xed4) = reg32; |
| 482 | |
| 483 | reg32 = DMIBAR32(0xee8); |
| 484 | reg32 &= 0x0fffffff; |
| 485 | reg32 |= (2 << 28); |
| 486 | DMIBAR32(0xee8) = reg32; |
| 487 | |
| 488 | reg32 = DMIBAR32(0xefc); |
| 489 | reg32 &= 0x0fffffff; |
| 490 | reg32 |= (2 << 28); |
| 491 | DMIBAR32(0xefc) = reg32; |
| 492 | } |
| 493 | |
| 494 | /* wait for bit toggle to 0 */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 495 | printk(BIOS_DEBUG, "Waiting for DMI hardware..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 496 | timeout = 0x7fffff; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 497 | while ((DMIBAR8(0x32) & (1 << 1)) && --timeout) |
| 498 | ; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 499 | if (!timeout) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 500 | printk(BIOS_DEBUG, "timeout!\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 501 | else |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 502 | printk(BIOS_DEBUG, "ok\n"); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 503 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 504 | /* Clear Error Status Bits! */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 505 | DMIBAR32(0x1c4) = 0xffffffff; |
| 506 | DMIBAR32(0x1d0) = 0xffffffff; |
| 507 | DMIBAR32(0x228) = 0xffffffff; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 508 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 509 | /* Program Read-Only Write-Once Registers */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 510 | DMIBAR32(0x308) = DMIBAR32(0x308); |
| 511 | DMIBAR32(0x314) = DMIBAR32(0x314); |
| 512 | DMIBAR32(0x324) = DMIBAR32(0x324); |
| 513 | DMIBAR32(0x328) = DMIBAR32(0x328); |
Elyes HAOUAS | d3fa7fa5 | 2019-01-24 11:47:27 +0100 | [diff] [blame] | 514 | DMIBAR32(0x334) = DMIBAR32(0x334); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 515 | DMIBAR32(0x338) = DMIBAR32(0x338); |
| 516 | |
Patrick Georgi | a341a77 | 2014-09-29 19:51:21 +0200 | [diff] [blame] | 517 | if (i945_silicon_revision() == 1 && (MCHBAR8(DFT_STRAP1) & (1 << 5))) { |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 518 | if ((MCHBAR32(0x214) & 0xf) != 0x3) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 519 | printk(BIOS_INFO, "DMI link requires A1 stepping workaround. Rebooting.\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 520 | reg32 = DMIBAR32(0x224); |
| 521 | reg32 &= ~(7 << 0); |
| 522 | reg32 |= (3 << 0); |
| 523 | DMIBAR32(0x224) = reg32; |
Elyes HAOUAS | 5db9871 | 2019-04-21 18:50:34 +0200 | [diff] [blame] | 524 | system_reset(); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | static void i945_setup_pci_express_x16(void) |
| 530 | { |
| 531 | u32 timeout; |
| 532 | u32 reg32; |
| 533 | u16 reg16; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 534 | pci_devfn_t p2peg = PCI_DEV(0, 0x01, 0); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 535 | |
Kyösti Mälkki | 2647b6f | 2019-09-29 07:03:55 +0300 | [diff] [blame] | 536 | u8 tmp_secondary = 0x0a; |
| 537 | pci_devfn_t peg_plugin = PCI_DEV(tmp_secondary, 0, 0); |
| 538 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 539 | printk(BIOS_DEBUG, "Enabling PCI Express x16 Link\n"); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 540 | |
| 541 | reg16 = pci_read_config16(PCI_DEV(0, 0x00, 0), DEVEN); |
| 542 | reg16 |= DEVEN_D1F0; |
| 543 | pci_write_config16(PCI_DEV(0, 0x00, 0), DEVEN, reg16); |
| 544 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 545 | reg32 = pci_read_config32(p2peg, PEGCC); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 546 | reg32 &= ~(1 << 8); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 547 | pci_write_config32(p2peg, PEGCC, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 548 | |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 549 | /* We have no success with querying the usual PCIe registers |
| 550 | * for link setup success on the i945. Hence we assign a temporary |
| 551 | * PCI bus 0x0a and check whether we find a device on 0:a.0 |
| 552 | */ |
| 553 | |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 554 | /* Force PCIRST# */ |
| 555 | pci_s_assert_secondary_reset(p2peg); |
| 556 | pci_s_deassert_secondary_reset(p2peg); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 557 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 558 | reg16 = pci_read_config16(p2peg, SLOTSTS); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 559 | printk(BIOS_DEBUG, "SLOTSTS: %04x\n", reg16); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 560 | if (!(reg16 & 0x48)) |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 561 | goto disable_pciexpress_x16_link; |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 562 | reg16 |= (1 << 4) | (1 << 0); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 563 | pci_write_config16(p2peg, SLOTSTS, reg16); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 564 | |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 565 | pci_s_bridge_set_secondary(p2peg, tmp_secondary); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 566 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 567 | reg32 = pci_read_config32(p2peg, 0x224); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 568 | reg32 &= ~(1 << 8); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 569 | pci_write_config32(p2peg, 0x224, reg32); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 570 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 571 | MCHBAR16(UPMC1) &= ~((1 << 5) | (1 << 0)); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 572 | |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 573 | /* Initialize PEG_CAP */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 574 | reg16 = pci_read_config16(p2peg, PEG_CAP); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 575 | reg16 |= (1 << 8); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 576 | pci_write_config16(p2peg, PEG_CAP, reg16); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 577 | |
| 578 | /* Setup SLOTCAP */ |
| 579 | /* TODO: These values are mainboard dependent and should |
Uwe Hermann | 607614d | 2010-11-18 20:12:13 +0000 | [diff] [blame] | 580 | * be set from devicetree.cb. |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 581 | */ |
| 582 | /* NOTE: SLOTCAP becomes RO after the first write! */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 583 | reg32 = pci_read_config32(p2peg, SLOTCAP); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 584 | reg32 &= 0x0007ffff; |
| 585 | |
| 586 | reg32 &= 0xfffe007f; |
| 587 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 588 | pci_write_config32(p2peg, SLOTCAP, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 589 | |
| 590 | /* Wait for training to succeed */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 591 | printk(BIOS_DEBUG, "PCIe link training ..."); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 592 | timeout = 0x7ffff; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 593 | while ((((pci_read_config32(p2peg, PEGSTS) >> 16) & 3) != 3) |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 594 | && --timeout) |
| 595 | ; |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 596 | |
Kyösti Mälkki | 2647b6f | 2019-09-29 07:03:55 +0300 | [diff] [blame] | 597 | reg32 = pci_read_config32(peg_plugin, PCI_VENDOR_ID); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 598 | if (reg32 != 0x00000000 && reg32 != 0xffffffff) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 599 | printk(BIOS_DEBUG, " Detected PCIe device %04x:%04x\n", |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 600 | reg32 & 0xffff, reg32 >> 16); |
| 601 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 602 | printk(BIOS_DEBUG, " timeout!\n"); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 603 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 604 | printk(BIOS_DEBUG, "Restrain PCIe port to x1\n"); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 605 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 606 | reg32 = pci_read_config32(p2peg, PEGSTS); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 607 | reg32 &= ~(0xf << 1); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 608 | reg32 |= 1; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 609 | pci_write_config32(p2peg, PEGSTS, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 610 | |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 611 | /* Force PCIRST# */ |
| 612 | pci_s_assert_secondary_reset(p2peg); |
| 613 | pci_s_deassert_secondary_reset(p2peg); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 614 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 615 | printk(BIOS_DEBUG, "PCIe link training ..."); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 616 | timeout = 0x7ffff; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 617 | while ((((pci_read_config32(p2peg, PEGSTS) >> 16) & 3) != 3) |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 618 | && --timeout) |
| 619 | ; |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 620 | |
Kyösti Mälkki | 2647b6f | 2019-09-29 07:03:55 +0300 | [diff] [blame] | 621 | reg32 = pci_read_config32(peg_plugin, PCI_VENDOR_ID); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 622 | if (reg32 != 0x00000000 && reg32 != 0xffffffff) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 623 | printk(BIOS_DEBUG, " Detected PCIe x1 device %04x:%04x\n", |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 624 | reg32 & 0xffff, reg32 >> 16); |
| 625 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 626 | printk(BIOS_DEBUG, " timeout!\n"); |
| 627 | printk(BIOS_DEBUG, "Disabling PCIe x16 port completely.\n"); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 628 | goto disable_pciexpress_x16_link; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 629 | } |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 630 | } |
| 631 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 632 | reg16 = pci_read_config16(p2peg, 0xb2); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 633 | reg16 >>= 4; |
| 634 | reg16 &= 0x3f; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 635 | /* reg16 == 1 -> x1; reg16 == 16 -> x16 */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 636 | printk(BIOS_DEBUG, "PCIe x%d link training succeeded.\n", reg16); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 637 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 638 | reg32 = pci_read_config32(p2peg, PEGTC); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 639 | reg32 &= 0xfffffc00; /* clear [9:0] */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 640 | if (reg16 == 1) |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 641 | reg32 |= 0x32b; |
| 642 | // TODO |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 643 | /* pci_write_config32(p2peg, PEGTC, reg32); */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 644 | else if (reg16 == 16) |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 645 | reg32 |= 0x0f4; |
| 646 | // TODO |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 647 | /* pci_write_config32(p2peg, PEGTC, reg32); */ |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 648 | |
Kyösti Mälkki | 2647b6f | 2019-09-29 07:03:55 +0300 | [diff] [blame] | 649 | reg32 = (pci_read_config32(peg_plugin, 0x8) >> 8); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 650 | printk(BIOS_DEBUG, "PCIe device class: %06x\n", reg32); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 651 | if (reg32 == 0x030000) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 652 | printk(BIOS_DEBUG, "PCIe device is VGA. Disabling IGD.\n"); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 653 | reg16 = (1 << 1); |
Elyes HAOUAS | ef20ecc | 2018-10-04 13:50:14 +0200 | [diff] [blame] | 654 | pci_write_config16(PCI_DEV(0, 0x0, 0), GGC, reg16); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 655 | |
Kyösti Mälkki | 3c3e34d | 2014-05-31 11:32:54 +0300 | [diff] [blame] | 656 | reg32 = pci_read_config32(PCI_DEV(0, 0x0, 0), DEVEN); |
| 657 | reg32 &= ~(DEVEN_D2F0 | DEVEN_D2F1); |
| 658 | pci_write_config32(PCI_DEV(0, 0x0, 0), DEVEN, reg32); |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 659 | } |
| 660 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 661 | /* Enable GPEs */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 662 | reg32 = pci_read_config32(p2peg, PEG_LC); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 663 | reg32 |= (1 << 2) | (1 << 1) | (1 << 0); /* PMEGPE, HPGPE, GENGPE */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 664 | pci_write_config32(p2peg, PEG_LC, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 665 | |
| 666 | /* Virtual Channel Configuration: Only VC0 on PCIe x16 */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 667 | reg32 = pci_read_config32(p2peg, VC0RCTL); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 668 | reg32 &= 0xffffff01; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 669 | pci_write_config32(p2peg, VC0RCTL, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 670 | |
| 671 | /* Extended VC count */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 672 | reg32 = pci_read_config32(p2peg, PVCCAP1); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 673 | reg32 &= ~(7 << 0); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 674 | pci_write_config32(p2peg, PVCCAP1, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 675 | |
| 676 | /* Active State Power Management ASPM */ |
| 677 | |
| 678 | /* TODO */ |
| 679 | |
| 680 | /* Clear error bits */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 681 | pci_write_config16(p2peg, PCISTS1, 0xffff); |
| 682 | pci_write_config16(p2peg, SSTS1, 0xffff); |
| 683 | pci_write_config16(p2peg, DSTS, 0xffff); |
| 684 | pci_write_config32(p2peg, UESTS, 0xffffffff); |
| 685 | pci_write_config32(p2peg, CESTS, 0xffffffff); |
| 686 | pci_write_config32(p2peg, 0x1f0, 0xffffffff); |
| 687 | pci_write_config32(p2peg, 0x228, 0xffffffff); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 688 | |
| 689 | /* Program R/WO registers */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 690 | reg32 = pci_read_config32(p2peg, 0x308); |
| 691 | pci_write_config32(p2peg, 0x308, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 692 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 693 | reg32 = pci_read_config32(p2peg, 0x314); |
| 694 | pci_write_config32(p2peg, 0x314, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 695 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 696 | reg32 = pci_read_config32(p2peg, 0x324); |
| 697 | pci_write_config32(p2peg, 0x324, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 698 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 699 | reg32 = pci_read_config32(p2peg, 0x328); |
| 700 | pci_write_config32(p2peg, 0x328, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 701 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 702 | /* Additional PCIe graphics setup */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 703 | reg32 = pci_read_config32(p2peg, 0xf0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 704 | reg32 |= (3 << 26); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 705 | pci_write_config32(p2peg, 0xf0, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 706 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 707 | reg32 = pci_read_config32(p2peg, 0xf0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 708 | reg32 |= (3 << 24); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 709 | pci_write_config32(p2peg, 0xf0, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 710 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 711 | reg32 = pci_read_config32(p2peg, 0xf0); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 712 | reg32 |= (1 << 5); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 713 | pci_write_config32(p2peg, 0xf0, reg32); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 714 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 715 | reg32 = pci_read_config32(p2peg, 0x200); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 716 | reg32 &= ~(3 << 26); |
| 717 | reg32 |= (2 << 26); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 718 | pci_write_config32(p2peg, 0x200, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 719 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 720 | reg32 = pci_read_config32(p2peg, 0xe80); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 721 | if (i945_silicon_revision() >= 2) |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 722 | reg32 |= (1 << 12); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 723 | else |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 724 | reg32 &= ~(1 << 12); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 725 | pci_write_config32(p2peg, 0xe80, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 726 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 727 | reg32 = pci_read_config32(p2peg, 0xeb4); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 728 | reg32 &= ~(1 << 31); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 729 | pci_write_config32(p2peg, 0xeb4, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 730 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 731 | reg32 = pci_read_config32(p2peg, 0xfc); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 732 | reg32 |= (1 << 31); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 733 | pci_write_config32(p2peg, 0xfc, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 734 | |
| 735 | if (i945_silicon_revision() >= 3) { |
| 736 | static const u32 reglist[] = { |
| 737 | 0xec0, 0xed4, 0xee8, 0xefc, 0xf10, 0xf24, |
| 738 | 0xf38, 0xf4c, 0xf60, 0xf74, 0xf88, 0xf9c, |
| 739 | 0xfb0, 0xfc4, 0xfd8, 0xfec |
| 740 | }; |
| 741 | |
| 742 | int i; |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 743 | for (i = 0; i < ARRAY_SIZE(reglist); i++) { |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 744 | reg32 = pci_read_config32(p2peg, reglist[i]); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 745 | reg32 &= 0x0fffffff; |
| 746 | reg32 |= (2 << 28); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 747 | pci_write_config32(p2peg, reglist[i], reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 748 | } |
| 749 | } |
| 750 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 751 | if (i945_silicon_revision() <= 2) { |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 752 | /* Set voltage specific parameters */ |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 753 | reg32 = pci_read_config32(p2peg, 0xe80); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 754 | reg32 &= (0xf << 4); /* Default case 1.05V */ |
Patrick Georgi | 3cb86de | 2014-09-29 20:42:33 +0200 | [diff] [blame] | 755 | if ((MCHBAR32(DFT_STRAP1) & (1 << 20)) == 0) { /* 1.50V */ |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 756 | reg32 |= (7 << 4); |
| 757 | } |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 758 | pci_write_config32(p2peg, 0xe80, reg32); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | return; |
| 762 | |
| 763 | disable_pciexpress_x16_link: |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 764 | /* For now we just disable the x16 link */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 765 | printk(BIOS_DEBUG, "Disabling PCI Express x16 Link\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 766 | |
| 767 | MCHBAR16(UPMC1) |= (1 << 5) | (1 << 0); |
| 768 | |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 769 | /* Toggle PCIRST# */ |
| 770 | pci_s_assert_secondary_reset(p2peg); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 771 | |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 772 | reg32 = pci_read_config32(p2peg, 0x224); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 773 | reg32 |= (1 << 8); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 774 | pci_write_config32(p2peg, 0x224, reg32); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 775 | |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 776 | pci_s_deassert_secondary_reset(p2peg); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 777 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 778 | printk(BIOS_DEBUG, "Wait for link to enter detect state... "); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 779 | timeout = 0x7fffff; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 780 | for (reg32 = pci_read_config32(p2peg, PEGSTS); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 781 | (reg32 & 0x000f0000) && --timeout;) |
| 782 | ; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 783 | if (!timeout) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 784 | printk(BIOS_DEBUG, "timeout!\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 785 | else |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 786 | printk(BIOS_DEBUG, "ok\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 787 | |
| 788 | /* Finally: Disable the PCI config header */ |
| 789 | reg16 = pci_read_config16(PCI_DEV(0, 0x00, 0), DEVEN); |
| 790 | reg16 &= ~DEVEN_D1F0; |
| 791 | pci_write_config16(PCI_DEV(0, 0x00, 0), DEVEN, reg16); |
| 792 | } |
| 793 | |
| 794 | static void i945_setup_root_complex_topology(void) |
| 795 | { |
| 796 | u32 reg32; |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 797 | pci_devfn_t p2peg = PCI_DEV(0, 0x01, 0); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 798 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 799 | printk(BIOS_DEBUG, "Setting up Root Complex Topology\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 800 | /* Egress Port Root Topology */ |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 801 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 802 | reg32 = EPBAR32(EPESD); |
| 803 | reg32 &= 0xff00ffff; |
| 804 | reg32 |= (1 << 16); |
| 805 | EPBAR32(EPESD) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 806 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 807 | EPBAR32(EPLE1D) |= (1 << 16) | (1 << 0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 808 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 809 | EPBAR32(EPLE1A) = (uintptr_t)DEFAULT_DMIBAR; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 810 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 811 | EPBAR32(EPLE2D) |= (1 << 16) | (1 << 0); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 812 | |
| 813 | /* DMI Port Root Topology */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 814 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 815 | reg32 = DMIBAR32(DMILE1D); |
| 816 | reg32 &= 0x00ffffff; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 817 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 818 | reg32 &= 0xff00ffff; |
| 819 | reg32 |= (2 << 16); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 820 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 821 | reg32 |= (1 << 0); |
| 822 | DMIBAR32(DMILE1D) = reg32; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 823 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 824 | DMIBAR32(DMILE1A) = (uintptr_t)DEFAULT_RCBA; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 825 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 826 | DMIBAR32(DMILE2D) |= (1 << 16) | (1 << 0); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 827 | |
| 828 | DMIBAR32(DMILE2A) = DEFAULT_EPBAR; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 829 | |
| 830 | /* PCI Express x16 Port Root Topology */ |
| 831 | if (pci_read_config8(PCI_DEV(0, 0x00, 0), DEVEN) & DEVEN_D1F0) { |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 832 | pci_write_config32(p2peg, LE1A, DEFAULT_EPBAR); |
| 833 | reg32 = pci_read_config32(p2peg, LE1D); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 834 | reg32 |= (1 << 0); |
Kyösti Mälkki | 444d2af | 2019-09-29 07:03:31 +0300 | [diff] [blame] | 835 | pci_write_config32(p2peg, LE1D, reg32); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 836 | } |
| 837 | } |
| 838 | |
| 839 | static void ich7_setup_root_complex_topology(void) |
| 840 | { |
Elyes HAOUAS | b217baa | 2019-01-18 15:32:39 +0100 | [diff] [blame] | 841 | /* Write the R/WO registers */ |
| 842 | |
| 843 | RCBA32(ESD) |= (2 << 16); |
| 844 | |
| 845 | RCBA32(ULD) |= (1 << 24) | (1 << 16); |
| 846 | |
| 847 | RCBA32(ULBA) = (uintptr_t)DEFAULT_DMIBAR; |
| 848 | /* Write ESD.CID to TCID */ |
| 849 | RCBA32(RP1D) |= (2 << 16); |
| 850 | RCBA32(RP2D) |= (2 << 16); |
| 851 | RCBA32(RP3D) |= (2 << 16); |
| 852 | RCBA32(RP4D) |= (2 << 16); |
| 853 | RCBA32(HDD) |= (2 << 16); |
| 854 | RCBA32(RP5D) |= (2 << 16); |
| 855 | RCBA32(RP6D) |= (2 << 16); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | static void ich7_setup_pci_express(void) |
| 859 | { |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 860 | RCBA32(CG) |= (1 << 0); |
| 861 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 862 | /* Initialize slot power limit for root ports */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 863 | pci_write_config32(PCI_DEV(0, 0x1c, 0), 0x54, 0x00000060); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 864 | #if 0 |
| 865 | pci_write_config32(PCI_DEV(0, 0x1c, 4), 0x54, 0x00480ce0); |
| 866 | pci_write_config32(PCI_DEV(0, 0x1c, 5), 0x54, 0x00500ce0); |
| 867 | #endif |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 868 | |
| 869 | pci_write_config32(PCI_DEV(0, 0x1c, 0), 0xd8, 0x00110000); |
| 870 | } |
| 871 | |
Kyösti Mälkki | ad787e1 | 2019-09-30 04:14:19 +0300 | [diff] [blame^] | 872 | void ich7_p2p_secondary_reset(void) |
| 873 | { |
| 874 | pci_devfn_t p2p_bridge = PCI_DEV(0, 0x1e, 0); |
| 875 | pci_s_assert_secondary_reset(p2p_bridge); |
| 876 | mdelay(200); |
| 877 | pci_s_deassert_secondary_reset(p2p_bridge); |
| 878 | } |
| 879 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 880 | void i945_early_initialization(void) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 881 | { |
| 882 | /* Print some chipset specific information */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 883 | switch (pci_read_config32(PCI_DEV(0, 0x00, 0), 0)) { |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 884 | case 0x27708086: /* 82945G/GZ/GC/P/PL */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 885 | i945_detect_chipset(); |
| 886 | break; |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 887 | case 0x27a08086: /* 945GME/GSE */ |
| 888 | case 0x27ac8086: /* 945GM/PM/GMS/GU/GT, 943/940GML */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 889 | i945m_detect_chipset(); |
| 890 | break; |
| 891 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 892 | |
| 893 | /* Setup all BARs required for early PCIe and raminit */ |
| 894 | i945_setup_bars(); |
| 895 | |
| 896 | /* Change port80 to LPC */ |
| 897 | RCBA32(GCS) &= (~0x04); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 898 | |
| 899 | /* Just do it that way */ |
| 900 | RCBA32(0x2010) |= (1 << 10); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 901 | } |
| 902 | |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 903 | static void i945_prepare_resume(int s3resume) |
| 904 | { |
| 905 | int cbmem_was_initted; |
| 906 | |
| 907 | cbmem_was_initted = !cbmem_recovery(s3resume); |
| 908 | |
Kyösti Mälkki | 8183025 | 2016-06-25 11:40:00 +0300 | [diff] [blame] | 909 | romstage_handoff_init(cbmem_was_initted && s3resume); |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | void i945_late_initialization(int s3resume) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 913 | { |
| 914 | i945_setup_egress_port(); |
| 915 | |
| 916 | ich7_setup_root_complex_topology(); |
| 917 | |
| 918 | ich7_setup_pci_express(); |
| 919 | |
| 920 | ich7_setup_dmi_rcrb(); |
| 921 | |
| 922 | i945_setup_dmi_rcrb(); |
| 923 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 924 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) |
Arthur Heymans | 2f6b52e | 2017-03-02 23:51:09 +0100 | [diff] [blame] | 925 | i945_setup_pci_express_x16(); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 926 | |
| 927 | i945_setup_root_complex_topology(); |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 928 | |
Kyösti Mälkki | 346d201 | 2019-03-23 10:07:16 +0200 | [diff] [blame] | 929 | if (CONFIG(DEBUG_RAM_SETUP)) |
| 930 | sdram_dump_mchbar_registers(); |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 931 | |
| 932 | MCHBAR16(SSKPD) = 0xCAFE; |
| 933 | |
| 934 | i945_prepare_resume(s3resume); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 935 | } |