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