payloads/edk2: Disable the CPU Timer Lib unless supported
[coreboot.git] / src / mainboard / intel / galileo / gpio.c
blobb145d6a1f0bbc88cdacaabcb86a7391b7a45f714
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <soc/car.h>
5 #include <soc/ramstage.h>
6 #include "reg_access.h"
7 #include "gen1.h"
8 #include "gen2.h"
10 void car_mainboard_pre_console_init(void)
12 const struct reg_script *script;
14 /* Initialize the GPIO controllers */
15 if (CONFIG(GALILEO_GEN2))
16 script = gen2_gpio_init;
17 else
18 script = gen1_gpio_init;
19 reg_script_run(script);
21 /* Initialize the RXD and TXD paths for UART0 */
22 if (CONFIG(ENABLE_BUILTIN_HSUART0)) {
23 if (CONFIG(GALILEO_GEN2))
24 script = gen2_hsuart0;
25 else
26 script = (reg_legacy_gpio_read(
27 R_QNC_GPIO_RGLVL_RESUME_WELL)
28 & GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO)
29 ? gen1_hsuart0_0x20 : gen1_hsuart0_0x21;
30 reg_script_run(script);
34 void mainboard_gpio_i2c_init(struct device *dev)
36 const struct reg_script *script;
38 printk(BIOS_INFO, "Galileo I2C chip initialization\n");
40 /* Determine the correct script for the board */
41 if (CONFIG(GALILEO_GEN2))
42 script = gen2_i2c_init;
43 else
44 /* Determine which I2C address is in use */
45 script = (reg_legacy_gpio_read(R_QNC_GPIO_RGLVL_RESUME_WELL)
46 & GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO)
47 ? gen1_i2c_0x20_init : gen1_i2c_0x21_init;
49 /* Initialize the I2C chips */
50 reg_script_run(script);
53 void mainboard_gpio_pcie_reset(uint32_t pin_value)
55 uint32_t pin_number;
56 uint32_t value;
58 /* Determine the correct PCIe reset pin */
59 if (CONFIG(GALILEO_GEN2))
60 pin_number = GEN2_PCI_RESET_RESUMEWELL_GPIO;
61 else
62 pin_number = GEN1_PCI_RESET_RESUMEWELL_GPIO;
64 /* Update the PCIe reset value */
65 value = reg_legacy_gpio_read(R_QNC_GPIO_RGLVL_RESUME_WELL);
66 value = (value & ~(1 << pin_number)) | ((pin_value & 1) << pin_number);
67 reg_legacy_gpio_write(R_QNC_GPIO_RGLVL_RESUME_WELL, value);