coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootblock.c
Go to the documentation of this file.
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)
14 
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  */
25 }
26 
28 {
29  size_t num_gpios, override_num_gpios;
30  const struct soc_amd_gpio *gpios, *override_gpios;
31 
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  */
57 
58  /* Early eSPI interface configuration */
59 
61 }
62 
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()) {
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 }
void espi_switch_to_spi2_pads(void)
Definition: espi_util.c:22
void espi_disable_lpc_ldrq(void)
Definition: espi_util.c:12
#define printk(level,...)
Definition: stdlib.h:16
void mdelay(unsigned int msecs)
Definition: delay.c:2
@ CONFIG
Definition: dsi_common.h:201
bool __weak variant_has_pcie_wwan(void)
Definition: helpers.c:7
static int stopwatch_expired(struct stopwatch *sw)
Definition: timer.h:152
static void stopwatch_init_usecs_expire(struct stopwatch *sw, long us)
Definition: timer.h:127
__weak void bootblock_mainboard_init(void)
Definition: bootblock.c:19
__weak void bootblock_mainboard_early_init(void)
Definition: bootblock.c:16
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
const struct pad_config * variant_early_gpio_table(size_t *num)
Definition: gpio.c:204
void mb_set_up_early_espi(void)
Definition: bootblock.c:15
struct stopwatch pcie_init_timeout_sw
Definition: bootblock.c:13
#define FC350_PCIE_INIT_DELAY_US
Definition: bootblock.c:12
const __weak struct soc_amd_gpio * variant_espi_gpio_table(size_t *size)
Definition: gpio.c:348
const struct soc_amd_gpio *__weak variant_bootblock_override_gpio_table(size_t *size)
Definition: gpio.c:324
const struct soc_amd_gpio *__weak variant_early_override_gpio_table(size_t *size)
Definition: gpio.c:317
const __weak struct soc_amd_gpio * variant_tpm_gpio_table(size_t *size)
Definition: gpio.c:354
const struct soc_amd_gpio *__weak variant_bootblock_gpio_table(size_t *size)
Definition: gpio.c:300
void gpio_configure_pads(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
program a particular set of GPIO
Definition: gpio.c:307
void gpio_configure_pads_with_override(const struct soc_amd_gpio *base_cfg, size_t base_num_pads, const struct soc_amd_gpio *override_cfg, size_t override_num_pads)
Definition: gpio.c:262