| 1 |
|
| 2 |
|
| 3 |
#include <stdint.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <arch/io.h> |
| 6 |
#include <device/pci_ops.h> |
| 7 |
#include <device/pci_def.h> |
| 8 |
#include <elog.h> |
| 9 |
#include <cpu/x86/msr.h> |
| 10 |
#include <cpu/intel/speedstep.h> |
| 11 |
#include <cpu/intel/turbo.h> |
| 12 |
#include <arch/cpu.h> |
| 13 |
|
| 14 |
#include "ironlake.h" |
| 15 |
|
| 16 |
static void ironlake_setup_bars(void) |
| 17 |
{ |
| 18 |
printk(BIOS_DEBUG, "Setting up static northbridge registers..."); |
| 19 |
|
| 20 |
pci_write_config32(PCI_DEV(0, 0, 0), EPBAR, CONFIG_FIXED_EPBAR_MMIO_BASE | 1); |
| 21 |
pci_write_config32(PCI_DEV(0, 0, 0), EPBAR + 4, 0); |
| 22 |
pci_write_config32(PCI_DEV(0, 0, 0), MCHBAR, CONFIG_FIXED_MCHBAR_MMIO_BASE | 1); |
| 23 |
pci_write_config32(PCI_DEV(0, 0, 0), MCHBAR + 4, 0); |
| 24 |
pci_write_config32(PCI_DEV(0, 0, 0), DMIBAR, CONFIG_FIXED_DMIBAR_MMIO_BASE | 1); |
| 25 |
pci_write_config32(PCI_DEV(0, 0, 0), DMIBAR + 4, 0); |
| 26 |
|
| 27 |
|
| 28 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(0), 0x30); |
| 29 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(1), 0x33); |
| 30 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(2), 0x33); |
| 31 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(3), 0x33); |
| 32 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(4), 0x33); |
| 33 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(5), 0x33); |
| 34 |
pci_write_config8(QPI_SAD, QPD0F1_PAM(6), 0x33); |
| 35 |
|
| 36 |
printk(BIOS_DEBUG, " done.\n"); |
| 37 |
} |
| 38 |
|
| 39 |
static void early_cpu_init(void) |
| 40 |
{ |
| 41 |
msr_t m; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
pci_update_config32(QPI_NON_CORE, DESIRED_CORES, 0xfffffefc, 0x10000); |
| 47 |
|
| 48 |
u8 reg8; |
| 49 |
struct cpuid_result result; |
| 50 |
result = cpuid_ext(0x6, 0x8b); |
| 51 |
if (!(result.eax & 0x2)) { |
| 52 |
m = rdmsr(MSR_FSB_CLOCK_VCC); |
| 53 |
reg8 = ((m.lo & 0xff00) >> 8) + 1; |
| 54 |
m = rdmsr(IA32_PERF_CTL); |
| 55 |
m.lo = (m.lo & ~0xff) | reg8; |
| 56 |
wrmsr(IA32_PERF_CTL, m); |
| 57 |
|
| 58 |
m = rdmsr(IA32_MISC_ENABLE); |
| 59 |
m.hi &= ~0x00000040; |
| 60 |
m.lo |= 0x10000; |
| 61 |
|
| 62 |
wrmsr(IA32_MISC_ENABLE, m); |
| 63 |
} |
| 64 |
|
| 65 |
m = rdmsr(MSR_FSB_CLOCK_VCC); |
| 66 |
reg8 = ((m.lo & 0xff00) >> 8) + 1; |
| 67 |
|
| 68 |
m = rdmsr(IA32_PERF_CTL); |
| 69 |
m.lo = (m.lo & ~0xff) | reg8; |
| 70 |
wrmsr(IA32_PERF_CTL, m); |
| 71 |
|
| 72 |
m = rdmsr(IA32_MISC_ENABLE); |
| 73 |
m.lo |= 0x10000; |
| 74 |
wrmsr(IA32_MISC_ENABLE, m); |
| 75 |
} |
| 76 |
|
| 77 |
void ironlake_early_initialization(int chipset_type) |
| 78 |
{ |
| 79 |
u32 capid0_a; |
| 80 |
u8 reg8; |
| 81 |
int s3_resume; |
| 82 |
|
| 83 |
|
| 84 |
capid0_a = pci_read_config32(PCI_DEV(0, 0, 0), 0xe4); |
| 85 |
if (capid0_a & (1 << 10)) { |
| 86 |
reg8 = pci_read_config8(PCI_DEV(0, 0, 0), 0xf3); |
| 87 |
reg8 &= ~7; |
| 88 |
|
| 89 |
if (chipset_type == IRONLAKE_MOBILE) |
| 90 |
reg8 |= 1; |
| 91 |
|
| 92 |
pci_write_config8(PCI_DEV(0, 0, 0), 0xf3, reg8); |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
ibexpeak_setup_bars(); |
| 97 |
ironlake_setup_bars(); |
| 98 |
|
| 99 |
s3_resume = (inw(DEFAULT_PMBASE + PM1_STS) & WAK_STS) && |
| 100 |
(((inl(DEFAULT_PMBASE + PM1_CNT) >> 10) & 7) == SLP_TYP_S3); |
| 101 |
|
| 102 |
elog_boot_notify(s3_resume); |
| 103 |
|
| 104 |
|
| 105 |
pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, DEVEN_IGD | DEVEN_PEG10 | DEVEN_HOST); |
| 106 |
|
| 107 |
early_cpu_init(); |
| 108 |
|
| 109 |
|
| 110 |
if (s3_resume) { |
| 111 |
mchbar_clrsetbits32(0x1e8, 1, 6); |
| 112 |
mchbar_clrsetbits32(0x1e8, 3, 4); |
| 113 |
} |
| 114 |
} |