| 1 |
|
| 2 |
|
| 3 |
#include <bootblock_common.h> |
| 4 |
#include <superio/nuvoton/common/nuvoton.h> |
| 5 |
#include <superio/nuvoton/nct6791d/nct6791d.h> |
| 6 |
#include <superio/aspeed/common/aspeed.h> |
| 7 |
#include <superio/aspeed/ast2400/ast2400.h> |
| 8 |
#include <console/uart.h> |
| 9 |
#include <console/console.h> |
| 10 |
#include <device/pnp_ops.h> |
| 11 |
#include <delay.h> |
| 12 |
#include "gpio.h" |
| 13 |
#include <gpio.h> |
| 14 |
#include <timer.h> |
| 15 |
|
| 16 |
static int64_t bmc_ready_elapsed = 0; |
| 17 |
|
| 18 |
void bootblock_mainboard_early_init(void) |
| 19 |
{ |
| 20 |
gpio_configure_pads(early_gpio_table, ARRAY_SIZE(early_gpio_table)); |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
struct stopwatch sw; |
| 33 |
stopwatch_init_msecs_expire(&sw, 120 * 1000); |
| 34 |
while (!stopwatch_expired(&sw)) { |
| 35 |
|
| 36 |
if (!gpio_get(GPP_J2)) |
| 37 |
break; |
| 38 |
mdelay(1000); |
| 39 |
} |
| 40 |
|
| 41 |
if (stopwatch_expired(&sw)) |
| 42 |
bmc_ready_elapsed = -1; |
| 43 |
else |
| 44 |
bmc_ready_elapsed = stopwatch_duration_msecs(&sw); |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
const pnp_devfn_t nvt_serial_dev = PNP_DEV(0x2E, NCT6791D_SP1); |
| 51 |
nuvoton_pnp_enter_conf_state(nvt_serial_dev); |
| 52 |
pnp_set_logical_device(nvt_serial_dev); |
| 53 |
pnp_set_enable(nvt_serial_dev, 0); |
| 54 |
nuvoton_pnp_exit_conf_state(nvt_serial_dev); |
| 55 |
|
| 56 |
|
| 57 |
const pnp_devfn_t ast_serial_dev = PNP_DEV(0x4E, AST2400_SUART1); |
| 58 |
aspeed_enable_serial(ast_serial_dev, CONFIG_TTYS0_BASE); |
| 59 |
} |
| 60 |
|
| 61 |
void bootblock_mainboard_init(void) |
| 62 |
{ |
| 63 |
if (bmc_ready_elapsed >= 0) { |
| 64 |
printk(BIOS_INFO, "BMC became ready in early init after %lld ms\n", |
| 65 |
bmc_ready_elapsed); |
| 66 |
} else { |
| 67 |
|
| 68 |
|
| 69 |
printk(BIOS_ERR, "BMC was not ready within timeout, booting anyway\n"); |
| 70 |
} |
| 71 |
} |