coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gpio.c File Reference
#include <acpi/acpi_pm.h>
#include <device/mmio.h>
#include <device/device.h>
#include <console/console.h>
#include <elog.h>
#include <gpio.h>
#include <amdblocks/acpi.h>
#include <amdblocks/acpimmio.h>
#include <amdblocks/gpio.h>
#include <amdblocks/smi.h>
#include <soc/gpio.h>
#include <soc/smi.h>
#include <assert.h>
#include <string.h>
#include <types.h>
Include dependency graph for gpio.c:

Go to the source code of this file.

Functions

static voidgpio_ctrl_ptr (gpio_t gpio_num)
 
static uint32_t gpio_read32 (gpio_t gpio_num)
 
static void gpio_write32 (gpio_t gpio_num, uint32_t value)
 
static voidgpio_mux_ptr (gpio_t gpio_num)
 
static uint8_t get_gpio_mux (gpio_t gpio_num)
 
static void set_gpio_mux (gpio_t gpio_num, uint8_t function)
 
static int get_gpio_gevent (gpio_t gpio, const struct soc_amd_event *table, size_t items)
 
static void program_smi (uint32_t flags, unsigned int gevent_num)
 
static void program_sci (uint32_t flags, unsigned int gevent_num)
 
static void gpio_update32 (gpio_t gpio_num, uint32_t mask, uint32_t or)
 
static void gpio_setbits32 (gpio_t gpio_num, uint32_t mask, uint32_t ctrl)
 
static void gpio_and32 (gpio_t gpio_num, uint32_t mask)
 
static void gpio_or32 (gpio_t gpio_num, uint32_t or)
 
static void master_switch_clr (uint32_t mask)
 
static void master_switch_set (uint32_t or)
 
int gpio_get (gpio_t gpio_num)
 
void gpio_set (gpio_t gpio_num, int value)
 
void gpio_input_pulldown (gpio_t gpio_num)
 
void gpio_input_pullup (gpio_t gpio_num)
 
void gpio_input (gpio_t gpio_num)
 
void gpio_output (gpio_t gpio_num, int value)
 
const char * gpio_acpi_path (gpio_t gpio)
 
uint16_t gpio_acpi_pin (gpio_t gpio)
 
void gpio_save_pin_registers (gpio_t gpio, struct soc_amd_gpio_register_save *save)
 
void gpio_restore_pin_registers (gpio_t gpio, struct soc_amd_gpio_register_save *save)
 
static void set_single_gpio (const struct soc_amd_gpio *g)
 
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)
 
void gpio_configure_pads (const struct soc_amd_gpio *gpio_list_ptr, size_t size)
 program a particular set of GPIO More...
 
int gpio_interrupt_status (gpio_t gpio)
 
static void check_and_add_wake_gpio (gpio_t begin, gpio_t end, struct gpio_wake_state *state)
 
static void check_gpios (uint32_t wake_stat, unsigned int bit_limit, gpio_t gpio_base, struct gpio_wake_state *state)
 
void gpio_fill_wake_state (struct gpio_wake_state *state)
 
void gpio_add_events (void)
 

Function Documentation

◆ check_and_add_wake_gpio()

static void check_and_add_wake_gpio ( gpio_t  begin,
gpio_t  end,
struct gpio_wake_state state 
)
static

Definition at line 326 of file gpio.c.

References ARRAY_SIZE, BIOS_INFO, gpio_read32(), GPIO_WAKE_STATUS, and printk.

Referenced by check_gpios().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_gpios()

static void check_gpios ( uint32_t  wake_stat,
unsigned int  bit_limit,
gpio_t  gpio_base,
struct gpio_wake_state state 
)
static

Definition at line 342 of file gpio.c.

References BIT, and check_and_add_wake_gpio().

Referenced by gpio_fill_wake_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_gpio_gevent()

static int get_gpio_gevent ( gpio_t  gpio,
const struct soc_amd_event table,
size_t  items 
)
static

Definition at line 71 of file gpio.c.

Referenced by set_single_gpio().

Here is the caller graph for this function:

◆ get_gpio_mux()

static uint8_t get_gpio_mux ( gpio_t  gpio_num)
static

Definition at line 60 of file gpio.c.

References gpio_mux_ptr(), and read8().

Referenced by gpio_save_pin_registers(), and set_gpio_mux().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_acpi_path()

const char* gpio_acpi_path ( gpio_t  gpio)

Definition at line 201 of file gpio.c.

◆ gpio_acpi_pin()

uint16_t gpio_acpi_pin ( gpio_t  gpio)

Definition at line 206 of file gpio.c.

◆ gpio_add_events()

void gpio_add_events ( void  )

Definition at line 382 of file gpio.c.

References acpi_pm_state_for_elog(), ARRAY_SIZE, elog_add_event_wake(), ELOG_WAKE_SOURCE_GPIO, chipset_power_state::gpio_state, and MIN.

Referenced by fch_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_and32()

static void gpio_and32 ( gpio_t  gpio_num,
uint32_t  mask 
)
static

Definition at line 144 of file gpio.c.

References gpio_update32(), and mask.

Referenced by gpio_input(), and master_switch_clr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_configure_pads()

void gpio_configure_pads ( const struct soc_amd_gpio gpio_list_ptr,
size_t  size 
)

program a particular set of GPIO

Parameters
gpio_list_ptr= pointer to array of gpio configurations
size= number of entries in array
Returns
none

Definition at line 307 of file gpio.c.

References gpio_configure_pads_with_override(), and NULL.

Referenced by bootblock_mainboard_early_init(), bootblock_mainboard_init(), carrier_gpio_configure(), configure_early_gpio_pads(), configure_gpio_pads(), disable_unused_gpios(), disable_wifi_wake(), early_config_gpio(), early_lpc_init(), enable_i2s(), fw_config_handle(), init_mainboard(), mainboard_chip_init(), mainboard_config_gpios(), mainboard_config_stage_gpios(), mainboard_configure_early_gpios(), mainboard_configure_gpios(), mainboard_init(), mainboard_memory_init_params(), mainboard_program_early_gpios(), mainboard_program_emmc_gpios(), mainboard_program_gpios(), mainboard_romstage_entry(), mainboard_silicon_init_params(), mainboard_smi_sleep(), mb_pre_fspm(), mb_set_up_early_espi(), program_early_gpio_pads(), program_gpio_pads(), sb_reset_i2c_peripherals(), set_uart_config(), setup_gpio(), tpm_enable(), variant_configure_early_gpio_pads(), variant_configure_early_gpios(), variant_configure_gpios(), variant_early_gpio_configure(), variant_pcie_gpio_configure(), verstage_mainboard_espi_init(), verstage_mainboard_tpm_init(), wifi_power_reset_configure_active_high_power(), wifi_power_reset_configure_active_low_power(), and wifi_power_reset_configure_pre_v3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_configure_pads_with_override()

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 
)

◆ gpio_ctrl_ptr()

static void* gpio_ctrl_ptr ( gpio_t  gpio_num)
inlinestatic

Definition at line 26 of file gpio.c.

References acpimmio_gpio0, acpimmio_remote_gpio, AMD_GPIO_FIRST_REMOTE_GPIO_NUMBER, CONFIG, ENV_SEPARATE_VERSTAGE, and SOC_GPIO_TOTAL_PINS.

Referenced by gpio_read32(), and gpio_write32().

Here is the caller graph for this function:

◆ gpio_fill_wake_state()

void gpio_fill_wake_state ( struct gpio_wake_state state)

Definition at line 362 of file gpio.c.

References BIOS_INFO, check_gpios(), GPIO_MASTER_SWITCH, gpio_read32(), GPIO_WAKE_STAT_0, GPIO_WAKE_STAT_1, memset(), and printk.

Referenced by fill_chipset_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_get()

int gpio_get ( gpio_t  gpio_num)

Definition at line 166 of file gpio.c.

Referenced by _gpio_base2_value(), _gpio_base3_value(), has_360_sensor_board(), and variant_mainboard_post_init_params().

Here is the caller graph for this function:

◆ gpio_input()

void gpio_input ( gpio_t  gpio_num)

Definition at line 189 of file gpio.c.

Referenced by _gpio_base3_value(), and gpio_base2_value().

Here is the caller graph for this function:

◆ gpio_input_pulldown()

void gpio_input_pulldown ( gpio_t  gpio_num)

Definition at line 179 of file gpio.c.

Referenced by _gpio_base3_value(), and gpio_pulldown_base2_value().

Here is the caller graph for this function:

◆ gpio_input_pullup()

void gpio_input_pullup ( gpio_t  gpio_num)

Definition at line 184 of file gpio.c.

Referenced by _gpio_base3_value(), gpio_eint_configure(), and gpio_pullup_base2_value().

Here is the caller graph for this function:

◆ gpio_interrupt_status()

int gpio_interrupt_status ( gpio_t  gpio)

Definition at line 312 of file gpio.c.

References GPIO_INT_STATUS, gpio_read32(), GPIO_WAKE_STATUS, and gpio_write32().

Referenced by tis_plat_irq_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_mux_ptr()

static void* gpio_mux_ptr ( gpio_t  gpio_num)
inlinestatic

Definition at line 48 of file gpio.c.

References acpimmio_iomux, acpimmio_remote_gpio, AMD_GPIO_FIRST_REMOTE_GPIO_NUMBER, AMD_GPIO_REMOTE_GPIO_MUX_OFFSET, CONFIG, ENV_SEPARATE_VERSTAGE, and SOC_GPIO_TOTAL_PINS.

Referenced by get_gpio_mux(), and set_gpio_mux().

Here is the caller graph for this function:

◆ gpio_or32()

static void gpio_or32 ( gpio_t  gpio_num,
uint32_t  or 
)
static

Definition at line 149 of file gpio.c.

References gpio_update32().

Referenced by gpio_output(), master_switch_set(), and set_single_gpio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_output()

void gpio_output ( gpio_t  gpio_num,
int  value 
)

Definition at line 194 of file gpio.c.

◆ gpio_read32()

static uint32_t gpio_read32 ( gpio_t  gpio_num)
inlinestatic

Definition at line 38 of file gpio.c.

References gpio_ctrl_ptr(), and read32().

Referenced by check_and_add_wake_gpio(), gpio_fill_wake_state(), gpio_get(), gpio_interrupt_status(), gpio_restore_pin_registers(), gpio_save_pin_registers(), and gpio_update32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_restore_pin_registers()

void gpio_restore_pin_registers ( gpio_t  gpio,
struct soc_amd_gpio_register_save save 
)

Definition at line 217 of file gpio.c.

References soc_amd_gpio_register_save::control_value, gpio_read32(), gpio_write32(), soc_amd_gpio_register_save::mux_value, and set_gpio_mux().

Referenced by sb_reset_i2c_peripherals().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_save_pin_registers()

void gpio_save_pin_registers ( gpio_t  gpio,
struct soc_amd_gpio_register_save save 
)

Definition at line 211 of file gpio.c.

References soc_amd_gpio_register_save::control_value, get_gpio_mux(), gpio_read32(), and soc_amd_gpio_register_save::mux_value.

Referenced by sb_reset_i2c_peripherals().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_set()

void gpio_set ( gpio_t  gpio_num,
int  value 
)

Definition at line 174 of file gpio.c.

Referenced by __gpio_output(), and gpio_output().

Here is the caller graph for this function:

◆ gpio_setbits32()

static void gpio_setbits32 ( gpio_t  gpio_num,
uint32_t  mask,
uint32_t  ctrl 
)
static

Definition at line 139 of file gpio.c.

References gpio_update32(), and mask.

Referenced by gpio_input_pulldown(), gpio_input_pullup(), gpio_set(), and set_single_gpio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_update32()

static void gpio_update32 ( gpio_t  gpio_num,
uint32_t  mask,
uint32_t  or 
)
static

Definition at line 128 of file gpio.c.

References gpio_read32(), gpio_write32(), and mask.

Referenced by gpio_and32(), gpio_or32(), and gpio_setbits32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_write32()

static void gpio_write32 ( gpio_t  gpio_num,
uint32_t  value 
)
inlinestatic

Definition at line 43 of file gpio.c.

References gpio_ctrl_ptr(), value, and write32().

Referenced by gpio_interrupt_status(), gpio_restore_pin_registers(), and gpio_update32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ master_switch_clr()

static void master_switch_clr ( uint32_t  mask)
static

Definition at line 154 of file gpio.c.

References gpio_and32(), GPIO_MASTER_SWITCH, and mask.

Referenced by gpio_configure_pads_with_override().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ master_switch_set()

static void master_switch_set ( uint32_t  or)
static

Definition at line 160 of file gpio.c.

References GPIO_MASTER_SWITCH, and gpio_or32().

Referenced by gpio_configure_pads_with_override().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ program_sci()

static void program_sci ( uint32_t  flags,
unsigned int  gevent_num 
)
static

Definition at line 108 of file gpio.c.

References configure_scimap(), sci_source::direction, sci_source::gpe, is_gpio_event_active_high(), is_gpio_event_level_triggered(), sci_source::level, sci_source::scimap, SMI_SCI_EDG, SMI_SCI_LVL, SMI_SCI_LVL_HIGH, and SMI_SCI_LVL_LOW.

Referenced by set_single_gpio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ program_smi()

static void program_smi ( uint32_t  flags,
unsigned int  gevent_num 
)
static

Definition at line 83 of file gpio.c.

References BIOS_ERR, BUG, configure_gevent_smi(), is_gpio_event_active_high(), is_gpio_event_level_triggered(), printk, SMI_MODE_SMI, SMI_SCI_LVL_HIGH, and SMI_SCI_LVL_LOW.

Referenced by set_single_gpio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_gpio_mux()

static void set_gpio_mux ( gpio_t  gpio_num,
uint8_t  function 
)
static

Definition at line 65 of file gpio.c.

References AMD_GPIO_MUX_MASK, get_gpio_mux(), gpio_mux_ptr(), and write8().

Referenced by gpio_restore_pin_registers(), and set_single_gpio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_single_gpio()