Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2009-2010 iWave Systems |
| 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. |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include "sch.h" |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 17 | #include <southbridge/intel/sch/sch.h> |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 18 | |
| 19 | #if 0 |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 20 | static void sch_set_mtrr(void) |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 21 | { |
| 22 | msr_t msr; |
| 23 | printk(BIOS_DEBUG, "1"); |
| 24 | msr.hi = 0x06060606; |
| 25 | msr.lo = 0x06060606; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 26 | wrmsr(0x250, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 27 | printk(BIOS_DEBUG, "2"); |
| 28 | msr.hi = 0x06060606; |
| 29 | msr.lo = 0x06060606; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 30 | wrmsr(0x258, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 31 | printk(BIOS_DEBUG, "3"); |
| 32 | msr.hi = 0x0; |
| 33 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 34 | wrmsr(0x259, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 35 | printk(BIOS_DEBUG, "4"); |
| 36 | msr.hi = 0x04040404; |
| 37 | msr.lo = 0x04040404; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 38 | wrmsr(0x268, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 39 | printk(BIOS_DEBUG, "5"); |
| 40 | msr.hi = 0x04040404; |
| 41 | msr.lo = 0x04040404; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 42 | wrmsr(0x269, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 43 | printk(BIOS_DEBUG, "6"); |
| 44 | msr.hi = 0x04040404; |
| 45 | msr.lo = 0x04040404; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 46 | wrmsr(0x26A, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 47 | printk(BIOS_DEBUG, "7"); |
| 48 | msr.hi = 0x04040404; |
| 49 | msr.lo = 0x04040404; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 50 | wrmsr(0x26B, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 51 | printk(BIOS_DEBUG, "8"); |
| 52 | msr.hi = 0x04040404; |
| 53 | msr.lo = 0x04040404; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 54 | wrmsr(0x26C, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 55 | printk(BIOS_DEBUG, "9"); |
| 56 | msr.hi = 0x05050505; |
| 57 | msr.lo = 0x05050505; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 58 | wrmsr(0x26D, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 59 | printk(BIOS_DEBUG, "10"); |
| 60 | msr.hi = 0x05050505; |
| 61 | msr.lo = 0x05050505; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 62 | wrmsr(0x26E, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 63 | printk(BIOS_DEBUG, "11"); |
| 64 | msr.hi = 0x05050505; |
| 65 | msr.lo = 0x05050505; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 66 | wrmsr(0x26f, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 67 | printk(BIOS_DEBUG, "12"); |
| 68 | msr.hi = 0x0; |
| 69 | msr.lo = 0x6; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 70 | wrmsr(0x202, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 71 | printk(BIOS_DEBUG, "13"); |
| 72 | msr.hi = 0x0; |
| 73 | msr.lo = 0xC0000800; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 74 | wrmsr(0x203, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 75 | printk(BIOS_DEBUG, "14"); |
| 76 | msr.hi = 0x0; |
| 77 | msr.lo = 0x3FAF0000; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 78 | wrmsr(0x204, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 79 | printk(BIOS_DEBUG, "15"); |
| 80 | msr.hi = 0x0; |
| 81 | msr.lo = 0xFFFF0800; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 82 | wrmsr(0x205, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 83 | printk(BIOS_DEBUG, "16"); |
| 84 | msr.hi = 0x0; |
| 85 | msr.lo = 0x3FB00000; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 86 | wrmsr(0x206, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 87 | printk(BIOS_DEBUG, "16"); |
| 88 | msr.hi = 0x0; |
| 89 | msr.lo = 0xFFF00800; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 90 | wrmsr(0x207, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 91 | printk(BIOS_DEBUG, "17"); |
| 92 | msr.hi = 0x0; |
| 93 | msr.lo = 0x3FC00000; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 94 | wrmsr(0x208, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 95 | printk(BIOS_DEBUG, "18"); |
| 96 | msr.hi = 0x0; |
| 97 | msr.lo = 0xFFC00800; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 98 | wrmsr(0x209, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 99 | printk(BIOS_DEBUG, "19"); |
| 100 | msr.hi = 0x0; |
| 101 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 102 | wrmsr(0x20A, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 103 | printk(BIOS_DEBUG, "20"); |
| 104 | msr.hi = 0x0; |
| 105 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 106 | wrmsr(0x20B, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 107 | printk(BIOS_DEBUG, "21"); |
| 108 | msr.hi = 0x0; |
| 109 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 110 | wrmsr(0x20a, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 111 | printk(BIOS_DEBUG, "22"); |
| 112 | msr.hi = 0x0; |
| 113 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 114 | wrmsr(0x20B, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 115 | printk(BIOS_DEBUG, "23"); |
| 116 | msr.hi = 0x0; |
| 117 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 118 | wrmsr(0x20c, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 119 | msr.hi = 0x0; |
| 120 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 121 | wrmsr(0x20d, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 122 | msr.hi = 0x0; |
| 123 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 124 | wrmsr(0x20E, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 125 | msr.hi = 0x0; |
| 126 | msr.lo = 0x0; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 127 | wrmsr(0x20F, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 128 | msr.hi = 0x0; |
| 129 | msr.lo = 0XC00; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 130 | wrmsr(0x2FF, msr); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 131 | printk(BIOS_DEBUG, "end"); |
| 132 | } |
| 133 | #endif |
| 134 | |
| 135 | static void sch_detect_chipset(void) |
| 136 | { |
| 137 | u16 reg16; |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 138 | u8 reg8; |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 139 | printk(BIOS_INFO, "\n"); |
| 140 | reg16 = pci_read_config16(PCI_DEV(0, 0x00, 0), 0x2); |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 141 | switch (reg16) { |
| 142 | case 0x8101: |
| 143 | printk(BIOS_INFO, "UL11L/US15L"); |
| 144 | break; |
| 145 | case 0x8100: |
| 146 | printk(BIOS_INFO, "US15W"); |
| 147 | break; |
| 148 | default: |
| 149 | /* Others reserved. */ |
| 150 | printk(BIOS_INFO, "Unknown (%02x)", reg16); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 151 | } |
Sebastian Andrzej Siewior | 3e9155d | 2012-10-26 19:03:14 +0200 | [diff] [blame] | 152 | printk(BIOS_INFO, " Chipset "); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 153 | |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 154 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0x8); |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 155 | switch (reg8) { |
| 156 | case 3: |
| 157 | printk(BIOS_INFO, "Qual. Sample ES1, Stepping B1"); |
| 158 | break; |
| 159 | case 4: |
| 160 | printk(BIOS_INFO, "Qual. Sample ES2, Stepping C0"); |
| 161 | break; |
| 162 | case 5: |
| 163 | printk(BIOS_INFO, "Qual. Sample ES2-Prime, Stepping D0"); |
| 164 | break; |
| 165 | case 6: |
| 166 | printk(BIOS_INFO, "Qual. Sample QS, Stepping D1"); |
| 167 | break; |
| 168 | default: |
| 169 | /* Others reserved. */ |
| 170 | printk(BIOS_INFO, "Unknown (%02x)", reg8); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 171 | } |
Sebastian Andrzej Siewior | 3e9155d | 2012-10-26 19:03:14 +0200 | [diff] [blame] | 172 | printk(BIOS_INFO, "\n"); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | static void sch_setup_non_standard_bars(void) |
| 176 | { |
| 177 | printk(BIOS_DEBUG, "Setting up ACPI PM1 block "); |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 178 | /* Address 0x1000 size 16B */ |
| 179 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x48, |
| 180 | (0x80000000 | DEFAULT_PMBASE)); |
| 181 | |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 182 | printk(BIOS_DEBUG, "Setting up ACPI P block "); |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 183 | /* Address 0x1010 size 16B */ |
| 184 | sch_port_access_write(4, 0x70, 4, 0x80001010); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 185 | |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 186 | /* SMBus address 0x1040 size 64B */ |
| 187 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x40, 0x80001040); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 188 | |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 189 | /* GPIO address 0x1080 size 64B */ |
| 190 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x44, 0x80001080); |
| 191 | |
| 192 | /* GPE0 address 0x10C0 size 64B */ |
| 193 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x4C, 0x800010C0); |
| 194 | |
| 195 | sch_port_access_write(2, 4, 4, 0x3F703F76); /* FIXME: SMM Control */ |
| 196 | |
| 197 | /* Base of Stolen Memory Address 0x1080 size 64B */ |
| 198 | pci_write_config32(PCI_DEV(0, 0x02, 0), 0x5C, 0x3F800000); |
| 199 | |
| 200 | sch_port_access_write(0, 0, 4, DEFAULT_PCIEXBAR | 1); /* pre-b1 */ |
| 201 | sch_port_access_write(2, 9, 4, DEFAULT_PCIEXBAR | 1); /* b1+ */ |
| 202 | |
| 203 | /* RCBA */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 204 | pci_write_config32(PCI_DEV(0, 0x1f, 0), 0xF0, |
| 205 | ((uintptr_t)DEFAULT_RCBABASE | 1)); |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 206 | |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 207 | printk(BIOS_DEBUG, " done.\n"); |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | static void sch_early_initialization(void) |
| 211 | { |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 212 | /* Print some chipset specific information. */ |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 213 | sch_detect_chipset(); |
| 214 | |
Uwe Hermann | 405721d | 2010-12-18 13:22:37 +0000 | [diff] [blame] | 215 | /* Setup all non standard BARs. */ |
Patrick Georgi | be61a17 | 2010-12-18 07:48:43 +0000 | [diff] [blame] | 216 | sch_setup_non_standard_bars(); |
| 217 | } |