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