| 1 |
|
| 2 |
|
| 3 |
#include <stdint.h> |
| 4 |
#include <bootblock_common.h> |
| 5 |
#include <device/pci_ops.h> |
| 6 |
#include <device/pnp_ops.h> |
| 7 |
#include <option.h> |
| 8 |
#include <superio/nuvoton/common/nuvoton.h> |
| 9 |
#include <superio/nuvoton/nct6776/nct6776.h> |
| 10 |
|
| 11 |
#define GLOBAL_DEV PNP_DEV(0x2e, 0) |
| 12 |
#define SERIAL_DEV PNP_DEV(0x2e, NCT6776_SP1) |
| 13 |
#define GPIO6789_DEV PNP_DEV(0x2e, NCT6776_GPIO6789_V) |
| 14 |
|
| 15 |
|
| 16 |
enum cpu_fan_tach_src { |
| 17 |
CPU_FAN_HEADER_NONE, |
| 18 |
CPU_FAN_HEADER_1, |
| 19 |
CPU_FAN_HEADER_2, |
| 20 |
CPU_FAN_HEADER_BOTH |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
static u8 get_cpufanin_gpio_config(void) |
| 33 |
{ |
| 34 |
switch (get_uint_option("cpu_fan_tach_src", CPU_FAN_HEADER_1)) { |
| 35 |
case CPU_FAN_HEADER_NONE: |
| 36 |
return 0xff; |
| 37 |
case CPU_FAN_HEADER_1: |
| 38 |
default: |
| 39 |
return 0x7f; |
| 40 |
case CPU_FAN_HEADER_2: |
| 41 |
return 0xbf; |
| 42 |
case CPU_FAN_HEADER_BOTH: |
| 43 |
return 0x3f; |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
void bootblock_mainboard_early_init(void) |
| 48 |
{ |
| 49 |
nuvoton_pnp_enter_conf_state(GLOBAL_DEV); |
| 50 |
|
| 51 |
|
| 52 |
pnp_write_config(GLOBAL_DEV, 0x1b, 0x68); |
| 53 |
pnp_write_config(GLOBAL_DEV, 0x1c, 0x80); |
| 54 |
pnp_write_config(GLOBAL_DEV, 0x24, 0x5c); |
| 55 |
pnp_write_config(GLOBAL_DEV, 0x27, 0xc0); |
| 56 |
pnp_write_config(GLOBAL_DEV, 0x2a, 0x62); |
| 57 |
pnp_write_config(GLOBAL_DEV, 0x2b, 0x08); |
| 58 |
pnp_write_config(GLOBAL_DEV, 0x2c, 0x80); |
| 59 |
|
| 60 |
|
| 61 |
pnp_set_logical_device(GPIO6789_DEV); |
| 62 |
pnp_write_config(GPIO6789_DEV, 0xe0, 0x3f); |
| 63 |
pnp_write_config(GPIO6789_DEV, 0xe1, get_cpufanin_gpio_config()); |
| 64 |
|
| 65 |
nuvoton_pnp_exit_conf_state(GLOBAL_DEV); |
| 66 |
|
| 67 |
|
| 68 |
nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 69 |
} |