coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gpio.c File Reference
#include <device/mmio.h>
#include <gpio.h>
#include <soc/addressmap.h>
#include <stddef.h>
#include <stdint.h>
#include "pinmux.h"
Include dependency graph for gpio.c:

Go to the source code of this file.

Functions

static void __gpio_input (gpio_t gpio, u32 pull)
 
static void __gpio_output (gpio_t gpio, int value, u32 od)
 
static u32 gpio_read_port (int index, size_t offset)
 
static void gpio_write_port (int index, size_t offset, u32 mask, u32 value)
 
void gpio_set_mode (gpio_t gpio, enum gpio_mode mode)
 
int gpio_get_mode (gpio_t gpio)
 
void gpio_set_lock (gpio_t gpio)
 
int gpio_get_lock (gpio_t gpio)
 
void gpio_set_out_enable (gpio_t gpio, int enable)
 
int gpio_get_out_enable (gpio_t gpio)
 
void gpio_set (gpio_t gpio, int value)
 
int gpio_get_out_value (gpio_t gpio)
 
int gpio_get (gpio_t gpio)
 
int gpio_get_int_status (gpio_t gpio)
 
void gpio_set_int_enable (gpio_t gpio, int enable)
 
int gpio_get_int_enable (gpio_t gpio)
 
void gpio_set_int_level (gpio_t gpio, int high_rise, int edge, int delta)
 
void gpio_get_int_level (gpio_t gpio, int *high_rise, int *edge, int *delta)
 
void gpio_set_int_clear (gpio_t gpio)
 
void gpio_input_pulldown (gpio_t gpio)
 
void gpio_input_pullup (gpio_t gpio)
 
void gpio_input (gpio_t gpio)
 
void gpio_output (gpio_t gpio, int value)
 
void gpio_output_open_drain (gpio_t gpio, int value)
 

Variables

static const struct gpio_bankgpio_banks = (void *)TEGRA_GPIO_BASE
 

Function Documentation

◆ __gpio_input()

static void __gpio_input ( gpio_t  gpio,
u32  pull 
)
static

Definition at line 11 of file gpio.c.

References GPIO_MODE_GPIO, GPIO_PINMUX_SHIFT, gpio_set_int_enable(), gpio_set_mode(), gpio_set_out_enable(), PINMUX_INPUT_ENABLE, pinmux_set_config(), and pull.

Referenced by gpio_input(), gpio_input_pulldown(), and gpio_input_pullup().

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

◆ __gpio_output()

static void __gpio_output ( gpio_t  gpio,
int  value,
u32  od 
)
static

Definition at line 21 of file gpio.c.

References GPIO_MODE_GPIO, GPIO_PINMUX_SHIFT, gpio_set(), gpio_set_int_enable(), gpio_set_mode(), gpio_set_out_enable(), PINMUX_PULL_NONE, pinmux_set_config(), and value.

Referenced by gpio_output(), and gpio_output_open_drain().

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

◆ gpio_get()

int gpio_get ( gpio_t  gpio)

Definition at line 120 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), gpio_bank::in_value, and offsetof.

Here is the call graph for this function:

◆ gpio_get_int_enable()

int gpio_get_int_enable ( gpio_t  gpio)

Definition at line 144 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), gpio_bank::int_enable, and offsetof.

Here is the call graph for this function:

◆ gpio_get_int_level()

void gpio_get_int_level ( gpio_t  gpio,
int *  high_rise,
int *  edge,
int *  delta 
)

Definition at line 163 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), gpio_bank::int_level, and offsetof.

Here is the call graph for this function:

◆ gpio_get_int_status()

int gpio_get_int_status ( gpio_t  gpio)

Definition at line 128 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), gpio_bank::int_status, and offsetof.

Here is the call graph for this function:

◆ gpio_get_lock()

int gpio_get_lock ( gpio_t  gpio)

Definition at line 80 of file gpio.c.

References config, GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), and offsetof.

Here is the call graph for this function:

◆ gpio_get_mode()

int gpio_get_mode ( gpio_t  gpio)

Definition at line 64 of file gpio.c.

References config, GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), and offsetof.

Here is the call graph for this function:

◆ gpio_get_out_enable()

int gpio_get_out_enable ( gpio_t  gpio)

Definition at line 96 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), offsetof, and gpio_bank::out_enable.

Here is the call graph for this function:

◆ gpio_get_out_value()

int gpio_get_out_value ( gpio_t  gpio)

Definition at line 112 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_read_port(), offsetof, and gpio_bank::out_value.

Here is the call graph for this function:

◆ gpio_input()

void gpio_input ( gpio_t  gpio)

Definition at line 191 of file gpio.c.

References __gpio_input(), and PINMUX_PULL_NONE.

Here is the call graph for this function:

◆ gpio_input_pulldown()

void gpio_input_pulldown ( gpio_t  gpio)

Definition at line 181 of file gpio.c.

References __gpio_input(), and PINMUX_PULL_DOWN.

Here is the call graph for this function:

◆ gpio_input_pullup()

void gpio_input_pullup ( gpio_t  gpio)

Definition at line 186 of file gpio.c.

References __gpio_input(), and PINMUX_PULL_UP.

Here is the call graph for this function:

◆ gpio_output()

void gpio_output ( gpio_t  gpio,
int  value 
)

Definition at line 196 of file gpio.c.

References __gpio_output(), and value.

Here is the call graph for this function:

◆ gpio_output_open_drain()

void gpio_output_open_drain ( gpio_t  gpio,
int  value 
)

Definition at line 201 of file gpio.c.

References __gpio_output(), PINMUX_OPEN_DRAIN, and value.

Here is the call graph for this function:

◆ gpio_read_port()

static u32 gpio_read_port ( int  index,
size_t  offset 
)
static

Definition at line 32 of file gpio.c.

References gpio_banks, GPIO_GPIOS_PER_BANK, GPIO_GPIOS_PER_PORT, offset, and read32().

Referenced by gpio_get(), gpio_get_int_enable(), gpio_get_int_level(), gpio_get_int_status(), gpio_get_lock(), gpio_get_mode(), gpio_get_out_enable(), and gpio_get_out_value().

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

◆ gpio_set()

void gpio_set ( gpio_t  gpio,
int  value 
)

Definition at line 104 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), offsetof, gpio_bank::out_value, and value.

Here is the call graph for this function:

◆ gpio_set_int_clear()

void gpio_set_int_clear ( gpio_t  gpio)

Definition at line 173 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), gpio_bank::int_clear, and offsetof.

Here is the call graph for this function:

◆ gpio_set_int_enable()

void gpio_set_int_enable ( gpio_t  gpio,
int  enable 
)

Definition at line 136 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), gpio_bank::int_enable, and offsetof.

Referenced by __gpio_input(), and __gpio_output().

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

◆ gpio_set_int_level()

void gpio_set_int_level ( gpio_t  gpio,
int  high_rise,
int  edge,
int  delta 
)

Definition at line 152 of file gpio.c.

References config, GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), offsetof, and value.

Here is the call graph for this function:

◆ gpio_set_lock()

void gpio_set_lock ( gpio_t  gpio)

Definition at line 72 of file gpio.c.

References config, GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), and offsetof.

Here is the call graph for this function:

◆ gpio_set_mode()

void gpio_set_mode ( gpio_t  gpio,
enum gpio_mode  mode 
)

Definition at line 56 of file gpio.c.

References config, GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), and offsetof.

Here is the call graph for this function:

◆ gpio_set_out_enable()

void gpio_set_out_enable ( gpio_t  gpio,
int  enable 
)

Definition at line 88 of file gpio.c.

References GPIO_GPIOS_PER_PORT, GPIO_PINMUX_SHIFT, gpio_write_port(), offsetof, and gpio_bank::out_enable.

Referenced by __gpio_input(), and __gpio_output().

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

◆ gpio_write_port()

static void gpio_write_port ( int  index,
size_t  offset,
u32  mask,
u32  value 
)
static

Definition at line 41 of file gpio.c.

References gpio_banks, GPIO_GPIOS_PER_BANK, GPIO_GPIOS_PER_PORT, mask, offset, read32(), value, and write32().

Referenced by gpio_set(), gpio_set_int_clear(), gpio_set_int_enable(), gpio_set_int_level(), gpio_set_lock(), gpio_set_mode(), and gpio_set_out_enable().

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

Variable Documentation

◆ gpio_banks

const struct gpio_bank* gpio_banks = (void *)TEGRA_GPIO_BASE
static

Definition at line 30 of file gpio.c.

Referenced by gpio_read_port(), and gpio_write_port().