| 1 |
|
| 2 |
|
| 3 |
#include <bootblock_common.h> |
| 4 |
#include <device/pnp_ops.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <northbridge/intel/x4x/x4x.h> |
| 7 |
#include <cpu/x86/msr.h> |
| 8 |
#include <cpu/intel/speedstep.h> |
| 9 |
#include <cf9_reset.h> |
| 10 |
#include <superio/winbond/w83627dhg/w83627dhg.h> |
| 11 |
#include <superio/winbond/common/winbond.h> |
| 12 |
|
| 13 |
#define SERIAL_DEV PNP_DEV(0x2e, W83627DHG_SP1) |
| 14 |
#define GPIO_DEV PNP_DEV(0x2e, W83627DHG_GPIO2345_V) |
| 15 |
|
| 16 |
void bootblock_mainboard_early_init(void) |
| 17 |
{ |
| 18 |
winbond_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 19 |
} |
| 20 |
|
| 21 |
static u8 msr_get_fsb(void) |
| 22 |
{ |
| 23 |
u8 fsbcfg; |
| 24 |
msr_t msr; |
| 25 |
const u32 eax = cpuid_eax(1); |
| 26 |
|
| 27 |
|
| 28 |
if (((eax >> 8) & 0xf) == 0xf) { |
| 29 |
msr = rdmsr(MSR_EBC_FREQUENCY_ID); |
| 30 |
fsbcfg = (msr.lo >> 16) & 0x7; |
| 31 |
} else { |
| 32 |
msr = rdmsr(MSR_FSB_FREQ); |
| 33 |
fsbcfg = msr.lo & 0x7; |
| 34 |
} |
| 35 |
|
| 36 |
return fsbcfg; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
static int setup_sio_gpio(void) |
| 41 |
{ |
| 42 |
int need_reset = 0; |
| 43 |
u8 reg, old_reg; |
| 44 |
|
| 45 |
u8 bsel = msr_get_fsb(); |
| 46 |
switch (bsel) { |
| 47 |
case 0: |
| 48 |
case 2: |
| 49 |
case 4: |
| 50 |
break; |
| 51 |
default: |
| 52 |
printk(BIOS_WARNING, |
| 53 |
"BSEL: Unsupported FSB frequency, using 800MHz\n"); |
| 54 |
bsel = 2; |
| 55 |
break; |
| 56 |
} |
| 57 |
|
| 58 |
pnp_enter_ext_func_mode(GPIO_DEV); |
| 59 |
pnp_set_logical_device(GPIO_DEV); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
reg = 0x92; |
| 68 |
|
| 69 |
old_reg = pnp_read_config(GPIO_DEV, 0x2c); |
| 70 |
pnp_write_config(GPIO_DEV, 0x2c, reg); |
| 71 |
need_reset = (reg != old_reg); |
| 72 |
|
| 73 |
pnp_write_config(GPIO_DEV, 0x30, 0x0e); |
| 74 |
pnp_write_config(GPIO_DEV, 0xf0, 0xf3); |
| 75 |
pnp_write_config(GPIO_DEV, 0xf2, 0x08); |
| 76 |
pnp_write_config(GPIO_DEV, 0xf4, 0x06); |
| 77 |
|
| 78 |
const int gpio33 = (bsel & 2) >> 1; |
| 79 |
const int gpio40 = (bsel & 4) >> 2; |
| 80 |
reg = (gpio33 << 3); |
| 81 |
old_reg = pnp_read_config(GPIO_DEV, 0xf1); |
| 82 |
|
| 83 |
pnp_write_config(GPIO_DEV, 0xf1, old_reg | reg | 4); |
| 84 |
need_reset += ((reg & 0x8) != (old_reg & 0x8)); |
| 85 |
|
| 86 |
reg = gpio40; |
| 87 |
old_reg = pnp_read_config(GPIO_DEV, 0xf5); |
| 88 |
pnp_write_config(GPIO_DEV, 0xf5, old_reg | reg); |
| 89 |
need_reset += ((reg & 0x1) != (old_reg & 0x1)); |
| 90 |
pnp_exit_ext_func_mode(GPIO_DEV); |
| 91 |
|
| 92 |
return need_reset; |
| 93 |
} |
| 94 |
|
| 95 |
void mb_pre_raminit_setup(int s3_resume) |
| 96 |
{ |
| 97 |
if (!s3_resume && setup_sio_gpio()) { |
| 98 |
printk(BIOS_DEBUG, "Needs reset to configure CPU BSEL straps\n"); |
| 99 |
full_reset(); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
void mb_get_spd_map(u8 spd_map[4]) |
| 104 |
{ |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
spd_map[0] = 0x50; |
| 110 |
spd_map[2] = 0x52; |
| 111 |
} |