1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/espi.h>
4 #include <bootblock_common.h>
5 #include <baseboard/variants.h>
6 #include <console/console.h>
9 #include <soc/southbridge.h>
12 #define FC350_PCIE_INIT_DELAY_US (20 * USECS_PER_MSEC)
13 struct stopwatch pcie_init_timeout_sw
;
15 void mb_set_up_early_espi(void)
18 * We don't need to initialize all of the GPIOs that are done
19 * in bootblock_mainboard_early_init(), but we need to release
20 * the EC eSPI reset and do the rest of the configuration.
22 * This will not be present in the normal boot flow.
24 bootblock_mainboard_early_init();
27 void bootblock_mainboard_early_init(void)
29 size_t num_gpios
, override_num_gpios
;
30 const struct soc_amd_gpio
*gpios
, *override_gpios
;
32 espi_disable_lpc_ldrq();
35 * All LPC decodes need to be cleared before we can configure the LPC pads as secondary
36 * eSPI interface that gets used for the EC communication. This is already done by
37 * lpc_disable_decodes that gets called before this function.
40 if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK
))
43 gpios
= variant_espi_gpio_table(&num_gpios
);
44 gpio_configure_pads(gpios
, num_gpios
);
46 gpios
= variant_tpm_gpio_table(&num_gpios
);
47 gpio_configure_pads(gpios
, num_gpios
);
49 gpios
= variant_early_gpio_table(&num_gpios
);
50 override_gpios
= variant_early_override_gpio_table(&override_num_gpios
);
51 gpio_configure_pads_with_override(gpios
, num_gpios
, override_gpios
, override_num_gpios
);
53 /* Set a timer to make sure there's enough delay for
54 * the Fibocom 350 PCIe init
56 stopwatch_init_usecs_expire(&pcie_init_timeout_sw
, FC350_PCIE_INIT_DELAY_US
);
58 /* Early eSPI interface configuration */
60 espi_switch_to_spi2_pads();
63 void bootblock_mainboard_init(void)
65 size_t base_num_gpios
, override_num_gpios
;
66 const struct soc_amd_gpio
*base_gpios
, *override_gpios
;
69 /* Make sure that at least 20ms has elapsed since enabling WWAN power
70 * in bootblock_mainboard_early_init.
71 * This is only applicable if verstage is not in the PSP and the board
72 * is using the fibocom 350 WLAN card, so this typically will not be hit.
74 if (!CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK
) && variant_has_pcie_wwan()) {
75 while (!stopwatch_expired(&pcie_init_timeout_sw
)) {
80 printk(BIOS_DEBUG
, "Delayed %d ms for PCIe\n", i
);
83 base_gpios
= variant_bootblock_gpio_table(&base_num_gpios
);
84 override_gpios
= variant_bootblock_override_gpio_table(&override_num_gpios
);
86 gpio_configure_pads_with_override(base_gpios
, base_num_gpios
, override_gpios
,