Debian Codegraph @

src/mainboard/google/guybrush/bootblock.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <amdblocks/espi.h>
4 #include <bootblock_common.h>
5 #include <baseboard/variants.h>
6 #include <console/console.h>
7 #include <delay.h>
8 #include <soc/espi.h>
9 #include <soc/southbridge.h>
10 #include <timer.h>
11
12 #define FC350_PCIE_INIT_DELAY_US (20 * USECS_PER_MSEC)
13 struct stopwatch pcie_init_timeout_sw;
14
15 void mb_set_up_early_espi(void)
16 {
17 /*
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.
21 *
22 * This will not be present in the normal boot flow.
23 */
24 bootblock_mainboard_early_init();
25 }
26
27 void bootblock_mainboard_early_init(void)
28 {
29 size_t num_gpios, override_num_gpios;
30 const struct soc_amd_gpio *gpios, *override_gpios;
31
32 espi_disable_lpc_ldrq();
33
34 /*
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.
38 */
39
40 if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK))
41 return;
42
43 gpios = variant_espi_gpio_table(&num_gpios);
44 gpio_configure_pads(gpios, num_gpios);
45
46 gpios = variant_tpm_gpio_table(&num_gpios);
47 gpio_configure_pads(gpios, num_gpios);
48
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);
52
53 /* Set a timer to make sure there's enough delay for
54 * the Fibocom 350 PCIe init
55 */
56 stopwatch_init_usecs_expire(&pcie_init_timeout_sw, FC350_PCIE_INIT_DELAY_US);
57
58 /* Early eSPI interface configuration */
59
60 espi_switch_to_spi2_pads();
61 }
62
63 void bootblock_mainboard_init(void)
64 {
65 size_t base_num_gpios, override_num_gpios;
66 const struct soc_amd_gpio *base_gpios, *override_gpios;
67 int i = 0;
68
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.
73 */
74 if (!CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) && variant_has_pcie_wwan()) {
75 while (!stopwatch_expired(&pcie_init_timeout_sw)) {
76 mdelay(1);
77 i++;
78 };
79 if (i)
80 printk(BIOS_DEBUG, "Delayed %d ms for PCIe\n", i);
81 }
82
83 base_gpios = variant_bootblock_gpio_table(&base_num_gpios);
84 override_gpios = variant_bootblock_override_gpio_table(&override_num_gpios);
85
86 gpio_configure_pads_with_override(base_gpios, base_num_gpios, override_gpios,
87 override_num_gpios);
88 }