1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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>
10 #include <superio/winbond/w83627dhg/w83627dhg.h>
11 #include <superio/winbond/common/winbond.h>
13 #define SERIAL_DEV PNP_DEV(0x2e, W83627DHG_SP1)
14 #define GPIO_DEV PNP_DEV(0x2e, W83627DHG_GPIO2345_V)
16 void bootblock_mainboard_early_init(void)
18 winbond_enable_serial(SERIAL_DEV
, CONFIG_TTYS0_BASE
);
21 static u8
msr_get_fsb(void)
25 const u32 eax
= cpuid_eax(1);
28 if (((eax
>> 8) & 0xf) == 0xf) {
29 msr
= rdmsr(MSR_EBC_FREQUENCY_ID
);
30 fsbcfg
= (msr
.lo
>> 16) & 0x7;
31 } else { /* Intel Core 2 */
32 msr
= rdmsr(MSR_FSB_FREQ
);
33 fsbcfg
= msr
.lo
& 0x7;
39 /* BSEL MCH straps are not hooked up to the CPU as usual but to the SIO */
40 static int setup_sio_gpio(void)
45 u8 bsel
= msr_get_fsb();
53 "BSEL: Unsupported FSB frequency, using 800MHz\n");
54 bsel
= 2; /* 800MHz */
58 pnp_enter_ext_func_mode(GPIO_DEV
);
59 pnp_set_logical_device(GPIO_DEV
);
63 * BSEL0 -> not hooked up (not supported anyways)
64 * BSEL1 -> GPIO33 (inverted)
68 /* Multi-function Pin Selection */
69 old_reg
= pnp_read_config(GPIO_DEV
, 0x2c);
70 pnp_write_config(GPIO_DEV
, 0x2c, reg
);
71 need_reset
= (reg
!= old_reg
);
73 pnp_write_config(GPIO_DEV
, 0x30, 0x0e); /* Enable GPIO3x,4x,5x */
74 pnp_write_config(GPIO_DEV
, 0xf0, 0xf3); /* GPIO3x direction */
75 pnp_write_config(GPIO_DEV
, 0xf2, 0x08); /* GPIO3x inversion */
76 pnp_write_config(GPIO_DEV
, 0xf4, 0x06); /* GPIO4x direction */
78 const int gpio33
= (bsel
& 2) >> 1;
79 const int gpio40
= (bsel
& 4) >> 2;
81 old_reg
= pnp_read_config(GPIO_DEV
, 0xf1); /* GPIO3x data */
82 /* Set GPIO32 high like vendor firmware */
83 pnp_write_config(GPIO_DEV
, 0xf1, old_reg
| reg
| 4);
84 need_reset
+= ((reg
& 0x8) != (old_reg
& 0x8));
87 old_reg
= pnp_read_config(GPIO_DEV
, 0xf5); /* GPIO4x data */
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
);
95 void mb_pre_raminit_setup(int s3_resume
)
97 if (!s3_resume
&& setup_sio_gpio()) {
98 printk(BIOS_DEBUG
, "Needs reset to configure CPU BSEL straps\n");
103 void mb_get_spd_map(u8 spd_map
[4])
105 /* This board has first dimm slot of each channel hooked up to
106 rank0 and rank1, while the second dimm slot is only connected
107 to rank1. The raminit does not support such setups. So only the
108 first dimms of each channel are used. */