| 1 |
|
| 2 |
|
| 3 |
#include <device/mmio.h> |
| 4 |
#include <device/pci_ops.h> |
| 5 |
#include <cf9_reset.h> |
| 6 |
#include <device/pci_def.h> |
| 7 |
#include <device/smbus_host.h> |
| 8 |
#include <southbridge/intel/common/gpio.h> |
| 9 |
#include <southbridge/intel/common/pmbase.h> |
| 10 |
#include <southbridge/intel/common/rcba.h> |
| 11 |
|
| 12 |
|
| 13 |
#include <northbridge/intel/sandybridge/sandybridge.h> |
| 14 |
|
| 15 |
#include "pch.h" |
| 16 |
#include "chip.h" |
| 17 |
|
| 18 |
#define SOUTHBRIDGE PCI_DEV(0, 0x1f, 0) |
| 19 |
#define PCI_DEVICE_ID_INTEL_UM77 0x1e58 |
| 20 |
|
| 21 |
static void wait_iobp(void) |
| 22 |
{ |
| 23 |
while (RCBA8(IOBPS) & 1) |
| 24 |
; |
| 25 |
} |
| 26 |
|
| 27 |
static u32 read_iobp(u32 address) |
| 28 |
{ |
| 29 |
u32 ret; |
| 30 |
|
| 31 |
RCBA32(IOBPIRI) = address; |
| 32 |
RCBA16(IOBPS) = (RCBA16(IOBPS) & 0x1ff) | 0x600; |
| 33 |
wait_iobp(); |
| 34 |
ret = RCBA32(IOBPD); |
| 35 |
wait_iobp(); |
| 36 |
RCBA8(IOBPS); |
| 37 |
return ret; |
| 38 |
} |
| 39 |
|
| 40 |
static void write_iobp(u32 address, u32 val) |
| 41 |
{ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
read_iobp(address); |
| 46 |
RCBA16(IOBPS) = (RCBA16(IOBPS) & 0x1ff) | 0x600; |
| 47 |
wait_iobp(); |
| 48 |
|
| 49 |
RCBA32(IOBPD) = val; |
| 50 |
wait_iobp(); |
| 51 |
RCBA16(IOBPS) = (RCBA16(IOBPS) & 0x1ff) | 0x600; |
| 52 |
|
| 53 |
RCBA8(IOBPS); |
| 54 |
} |
| 55 |
|
| 56 |
void early_pch_init_native_dmi_pre(void) |
| 57 |
{ |
| 58 |
|
| 59 |
RCBA32(LCAP) = (RCBA32(LCAP) & ~0x3fc00) | |
| 60 |
(3 << 10) | |
| 61 |
(2 << 12) | |
| 62 |
(2 << 15); |
| 63 |
|
| 64 |
RCBA32(0x2340) = (RCBA32(0x2340) & ~0xff0000) | (0x3a << 16); |
| 65 |
RCBA8(DLCTL2) = (RCBA8(DLCTL2) & ~0xf) | 2; |
| 66 |
} |
| 67 |
|
| 68 |
void early_pch_init_native_dmi_post(void) |
| 69 |
{ |
| 70 |
u32 reg32; |
| 71 |
|
| 72 |
reg32 = RCBA32(CIR0); |
| 73 |
reg32 &= ~(0xff << 16 | 0xfff); |
| 74 |
reg32 |= 0x654; |
| 75 |
reg32 |= 0x20 << 16; |
| 76 |
reg32 |= 0x0a << 16; |
| 77 |
RCBA32(CIR0) = reg32; |
| 78 |
RCBA32(CIR0); |
| 79 |
|
| 80 |
RCBA8(UPDCR) = RCBA8(UPDCR) | 1 << 2 | 1 << 0; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
RCBA32(V0CTL) = (1 << 31) | (0 << 24) | (0x0c << 1) | 1; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
RCBA32(V1CTL) = (1 << 31) | (1 << 24) | (0x11 << 1); |
| 105 |
|
| 106 |
RCBA32(V1CTL); |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
RCBA32(CIR31) = (1 << 31) | (2 << 24) | (0x22 << 1); |
| 114 |
|
| 115 |
RCBA32(CIR31); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
RCBA32(CIR32) = (1 << 31) | (7 << 24) | (0x40 << 1); |
| 123 |
|
| 124 |
|
| 125 |
RCBA32(CIR0) |= TCLOCKDN; |
| 126 |
|
| 127 |
RCBA32(CIR0); |
| 128 |
|
| 129 |
|
| 130 |
while (RCBA16(V0STS) & VCNEGPND) |
| 131 |
; |
| 132 |
while (RCBA16(V1STS) & VCNEGPND) |
| 133 |
; |
| 134 |
while (RCBA16(0x2036) & VCNEGPND) |
| 135 |
; |
| 136 |
while (RCBA16(0x2046) & VCNEGPND) |
| 137 |
; |
| 138 |
} |
| 139 |
|
| 140 |
void early_pch_init_native(void) |
| 141 |
{ |
| 142 |
const u16 dev_id = pci_read_config16(PCH_LPC_DEV, PCI_DEVICE_ID); |
| 143 |
u8 pcie_ports = (dev_id == PCI_DEVICE_ID_INTEL_UM77) ? 4 : 8; |
| 144 |
|
| 145 |
|
| 146 |
for (uint8_t i = 0; i < pcie_ports; i++) |
| 147 |
pci_update_config32(PCH_PCIE_DEV(i), 0x338, ~(1 << 26), 0); |
| 148 |
|
| 149 |
|
| 150 |
pci_or_config8(PCH_LPC_DEV, GEN_PMCON_LOCK, 1 << 1); |
| 151 |
|
| 152 |
RCBA32(CIR1) = 0x00109000; |
| 153 |
RCBA32_OR(REC, 1 << 30); |
| 154 |
RCBA32(0x100c) = 0x01110000; |
| 155 |
RCBA8(0x2340) = 0x1b; |
| 156 |
RCBA32_OR(CIR6, 1 << 21); |
| 157 |
RCBA32_AND_OR(0x2310, ~(3 << 29), 1 << 29); |
| 158 |
RCBA32(DMC2) = 0x00854c74; |
| 159 |
|
| 160 |
|
| 161 |
RCBA32_AND_OR(0x2310, ~(3 << 22), 0); |
| 162 |
RCBA32_AND_OR(0x2310, ~(3 << 20), 0); |
| 163 |
|
| 164 |
write_iobp(0xea007f62, 0x00590133); |
| 165 |
write_iobp(0xec007f62, 0x00590133); |
| 166 |
write_iobp(0xec007f64, 0x59555588); |
| 167 |
write_iobp(0xea0040b9, 0x0001051c); |
| 168 |
write_iobp(0xeb0040a1, 0x800084ff); |
| 169 |
write_iobp(0xec0040a1, 0x800084ff); |
| 170 |
write_iobp(0xea004001, 0x00008400); |
| 171 |
write_iobp(0xeb004002, 0x40201758); |
| 172 |
write_iobp(0xec004002, 0x40201758); |
| 173 |
write_iobp(0xea004002, 0x00601758); |
| 174 |
write_iobp(0xea0040a1, 0x810084ff); |
| 175 |
write_iobp(0xeb0040b1, 0x0001c598); |
| 176 |
write_iobp(0xec0040b1, 0x0001c598); |
| 177 |
write_iobp(0xeb0040b6, 0x0001c598); |
| 178 |
write_iobp(0xea0000a9, 0x80ff969f); |
| 179 |
write_iobp(0xea0001a9, 0x80ff969f); |
| 180 |
write_iobp(0xeb0040b2, 0x0001c396); |
| 181 |
write_iobp(0xeb0040b3, 0x0001c396); |
| 182 |
write_iobp(0xec0040b2, 0x0001c396); |
| 183 |
write_iobp(0xea0001a9, 0x80ff94ff); |
| 184 |
write_iobp(SATA_IOBP_SP0G3IR, 0x0088037f); |
| 185 |
write_iobp(0xea0000a9, 0x80ff94ff); |
| 186 |
write_iobp(SATA_IOBP_SP1G3IR, 0x0088037f); |
| 187 |
|
| 188 |
write_iobp(0xea007f05, 0x00010642); |
| 189 |
write_iobp(0xea0040b7, 0x0001c91c); |
| 190 |
write_iobp(0xea0040b8, 0x0001c91c); |
| 191 |
write_iobp(0xeb0040a1, 0x820084ff); |
| 192 |
write_iobp(0xec0040a1, 0x820084ff); |
| 193 |
write_iobp(0xea007f0a, 0xc2480000); |
| 194 |
|
| 195 |
write_iobp(0xec00404d, 0x1ff177f); |
| 196 |
write_iobp(0xec000084, 0x5a600000); |
| 197 |
write_iobp(0xec000184, 0x5a600000); |
| 198 |
write_iobp(0xec000284, 0x5a600000); |
| 199 |
write_iobp(0xec000384, 0x5a600000); |
| 200 |
write_iobp(0xec000094, 0x000f0501); |
| 201 |
write_iobp(0xec000194, 0x000f0501); |
| 202 |
write_iobp(0xec000294, 0x000f0501); |
| 203 |
write_iobp(0xec000394, 0x000f0501); |
| 204 |
write_iobp(0xec000096, 0x00000001); |
| 205 |
write_iobp(0xec000196, 0x00000001); |
| 206 |
write_iobp(0xec000296, 0x00000001); |
| 207 |
write_iobp(0xec000396, 0x00000001); |
| 208 |
write_iobp(0xec000001, 0x00008c08); |
| 209 |
write_iobp(0xec000101, 0x00008c08); |
| 210 |
write_iobp(0xec000201, 0x00008c08); |
| 211 |
write_iobp(0xec000301, 0x00008c08); |
| 212 |
write_iobp(0xec0040b5, 0x0001c518); |
| 213 |
write_iobp(0xec000087, 0x06077597); |
| 214 |
write_iobp(0xec000187, 0x06077597); |
| 215 |
write_iobp(0xec000287, 0x06077597); |
| 216 |
write_iobp(0xec000387, 0x06077597); |
| 217 |
write_iobp(0xea000050, 0x00bb0157); |
| 218 |
write_iobp(0xea000150, 0x00bb0157); |
| 219 |
write_iobp(0xec007f60, 0x77777d77); |
| 220 |
write_iobp(0xea00008d, 0x01320000); |
| 221 |
write_iobp(0xea00018d, 0x01320000); |
| 222 |
write_iobp(0xec0007b2, 0x04514b5e); |
| 223 |
write_iobp(0xec00078c, 0x40000200); |
| 224 |
write_iobp(0xec000780, 0x02000020); |
| 225 |
} |
| 226 |
|
| 227 |
static void pch_enable_bars(void) |
| 228 |
{ |
| 229 |
pci_write_config32(PCH_LPC_DEV, RCBA, CONFIG_FIXED_RCBA_MMIO_BASE | 1); |
| 230 |
|
| 231 |
pci_write_config32(PCH_LPC_DEV, PMBASE, DEFAULT_PMBASE | 1); |
| 232 |
|
| 233 |
pci_write_config8(PCH_LPC_DEV, ACPI_CNTL, ACPI_EN); |
| 234 |
|
| 235 |
pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1); |
| 236 |
|
| 237 |
|
| 238 |
pci_write_config8(PCH_LPC_DEV, GPIO_CNTL, 0x10); |
| 239 |
} |
| 240 |
|
| 241 |
static void pch_generic_setup(void) |
| 242 |
{ |
| 243 |
RCBA32(GCS) = RCBA32(GCS) | (1 << 5); |
| 244 |
write_pmbase16(TCO1_CNT, 1 << 11); |
| 245 |
} |
| 246 |
|
| 247 |
static void pch_enable_gbe(void) |
| 248 |
{ |
| 249 |
uint8_t wanted_buc; |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
if (ENV_BOOTBLOCK) |
| 254 |
return; |
| 255 |
|
| 256 |
const struct device *const gbe = pcidev_on_root(0x19, 0); |
| 257 |
if (gbe && gbe->enabled) |
| 258 |
wanted_buc = RCBA8(BUC) & ~PCH_DISABLE_GBE; |
| 259 |
else |
| 260 |
wanted_buc = RCBA8(BUC) | PCH_DISABLE_GBE; |
| 261 |
|
| 262 |
if (RCBA8(BUC) != wanted_buc) { |
| 263 |
RCBA8(BUC) = wanted_buc; |
| 264 |
|
| 265 |
if (RCBA8(BUC) != wanted_buc) |
| 266 |
return; |
| 267 |
full_reset(); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
static void pch_enable_lpc_decode(void) |
| 272 |
{ |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); |
| 283 |
pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN |
| 284 |
| KBC_LPC_EN | FDD_LPC_EN | LPT_LPC_EN | COMB_LPC_EN | COMA_LPC_EN); |
| 285 |
|
| 286 |
const struct device *dev = pcidev_on_root(0x1f, 0); |
| 287 |
const struct southbridge_intel_bd82x6x_config *config = NULL; |
| 288 |
|
| 289 |
|
| 290 |
if (!dev) |
| 291 |
return; |
| 292 |
if (dev->chip_info) |
| 293 |
config = dev->chip_info; |
| 294 |
if (!config) |
| 295 |
return; |
| 296 |
|
| 297 |
pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec); |
| 298 |
pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec); |
| 299 |
pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec); |
| 300 |
pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec); |
| 301 |
} |
| 302 |
|
| 303 |
__weak void mainboard_pch_lpc_setup(void) |
| 304 |
{ |
| 305 |
} |
| 306 |
|
| 307 |
void early_pch_init(void) |
| 308 |
{ |
| 309 |
pch_enable_lpc_decode(); |
| 310 |
|
| 311 |
mainboard_pch_lpc_setup(); |
| 312 |
|
| 313 |
pch_enable_bars(); |
| 314 |
|
| 315 |
pch_generic_setup(); |
| 316 |
|
| 317 |
pch_enable_gbe(); |
| 318 |
|
| 319 |
setup_pch_gpios(&mainboard_gpio_map); |
| 320 |
|
| 321 |
if (ENV_RAMINIT || (CONFIG(CONSOLE_I2C_SMBUS) && ENV_INITIAL_STAGE)) |
| 322 |
enable_smbus(); |
| 323 |
} |