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 <bootblock_common.h>
4 #include <device/mmio.h>
5 #include <gpio.h>
6 #include <soc/gpio.h>
7 #include <soc/i2c.h>
8 #include <soc/pcie.h>
9 #include <soc/spi.h>
10 
11 #include "gpio.h"
12 
13 struct pad_func {
16 };
17 
18 #define PAD_FUNC(name, func) {PAD_##name##_ID, PAD_##name##_FUNC_##func}
19 
20 static void nor_set_gpio_pinmux(void)
21 {
22  const struct pad_func *ptr = NULL;
23 
24  /* GPIO 140 ~ 143 */
25  struct pad_func nor_pinmux[] = {
26  PAD_FUNC(SPIM2_CSB, SPINOR_CS),
27  PAD_FUNC(SPIM2_CLK, SPINOR_CK),
28  PAD_FUNC(SPIM2_MO, SPINOR_IO0),
29  PAD_FUNC(SPIM2_MI, SPINOR_IO1),
30  };
31 
32  ptr = nor_pinmux;
33  for (size_t i = 0; i < ARRAY_SIZE(nor_pinmux); i++) {
34  gpio_set_pull((gpio_t){.id = ptr[i].pin_id},
36  gpio_set_mode((gpio_t){.id = ptr[i].pin_id}, ptr[i].func);
37  }
38 }
39 
40 static void usb3_hub_reset(void)
41 {
42  gpio_output(GPIO(DGI_D7), 1);
43 }
44 
46 {
47  /*
48  * Initialize PCIe pinmux and assert PERST# early to reduce
49  * the impact of 100ms delay.
50  */
51  if (CONFIG(PCI))
53 
54  mtk_i2c_bus_init(CONFIG_DRIVER_TPM_I2C_BUS, I2C_SPEED_FAST);
55  mtk_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, SPI_PAD0_MASK, 3 * MHz, 0);
60 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define MHz
Definition: helpers.h:80
@ GPIO
Definition: chip.h:84
@ CONFIG
Definition: dsi_common.h:201
void setup_chromeos_gpios(void)
Definition: chromeos.c:10
@ I2C_SPEED_FAST
Definition: i2c.h:45
void gpio_output(gpio_t gpio, int value)
Definition: gpio.c:194
__weak void bootblock_mainboard_init(void)
Definition: bootblock.c:19
static void nor_set_gpio_pinmux(void)
Definition: bootblock.c:20
static void usb3_hub_reset(void)
Definition: bootblock.c:40
#define PAD_FUNC(name, func)
Definition: bootblock.c:18
#define GPIO_GSC_AP_INT
Definition: gpio.h:14
@ IRQ_TYPE_EDGE_RISING
Definition: gpio_common.h:55
@ GPIO_PULL_ENABLE
Definition: gpio_common.h:13
void gpio_set_pull(gpio_t gpio, enum pull_enable enable, enum pull_select select)
Definition: gpio.c:17
void mtk_pcie_pre_init(void)
Definition: pcie.c:70
void gpio_set_mode(gpio_t gpio, int mode)
Definition: gpio.c:45
void gpio_eint_configure(gpio_t gpio, enum gpio_irq_type type)
Definition: gpio.c:142
void mtk_i2c_bus_init(uint8_t bus)
Definition: i2c.c:65
static const struct pad_func nor_pinmux[SPI_NOR_GPIO_SET_NUM][4]
Definition: spi.c:124
#define GPIO_PULL_UP
Definition: gpio.h:24
@ SPI_PAD0_MASK
Definition: spi_common.h:46
void mtk_spi_init(unsigned int bus, enum spi_pad_mask pad_select, unsigned int speed_hz, unsigned int tick_dly)
Definition: spi.c:56
#define NULL
Definition: stddef.h:19
uint8_t u8
Definition: stdint.h:45
u8 func
Definition: bootblock.c:15
u8 pin_id
Definition: bootblock.c:14