coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gpio.h File Reference
#include <stdint.h>
#include "pinmux.h"
Include dependency graph for gpio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gpio_bank
 

Macros

#define GPIO_PINMUX_SHIFT   16
 
#define GPIO(name)
 

Typedefs

typedef u32 gpio_t
 

Enumerations

enum  gpio_mode { GPIO_MODE_SPIO = 0 , GPIO_MODE_GPIO = 1 }
 
enum  {
  GPIO_GPIOS_PER_PORT = 8 , GPIO_PORTS_PER_BANK = 4 , GPIO_BANKS = 8 , GPIO_GPIOS_PER_BANK = GPIO_GPIOS_PER_PORT * GPIO_PORTS_PER_BANK ,
  GPIO_GPIOS = GPIO_BANKS * GPIO_GPIOS_PER_BANK
}
 

Functions

void gpio_set_mode (gpio_t gpio, enum gpio_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)
 
int gpio_get_out_value (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_output_open_drain (gpio_t gpio, int value)
 
static int gpio_index_to_bank (int index)
 
static int gpio_index_to_port (int index)
 
static int gpio_to_bit (int index)
 

Macro Definition Documentation

◆ GPIO

#define GPIO (   name)
Value:
((gpio_t)(GPIO_##name##_INDEX | \
(PINMUX_GPIO_##name << GPIO_PINMUX_SHIFT)))
const char * name
Definition: mmu.c:92
uint32_t gpio_t
Definition: gpio.h:9
#define GPIO_PINMUX_SHIFT
Definition: gpio.h:12

Definition at line 13 of file gpio.h.

◆ GPIO_PINMUX_SHIFT

#define GPIO_PINMUX_SHIFT   16

Definition at line 12 of file gpio.h.

Typedef Documentation

◆ gpio_t

typedef u32 gpio_t

Definition at line 10 of file gpio.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GPIO_GPIOS_PER_PORT 
GPIO_PORTS_PER_BANK 
GPIO_BANKS 
GPIO_GPIOS_PER_BANK 
GPIO_GPIOS 

Definition at line 48 of file gpio.h.

◆ gpio_mode

enum gpio_mode
Enumerator
GPIO_MODE_SPIO 
GPIO_MODE_GPIO 

Definition at line 18 of file gpio.h.

Function Documentation

◆ 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_index_to_bank()

static int gpio_index_to_bank ( int  index)
inlinestatic

Definition at line 57 of file gpio.h.

References GPIO_GPIOS_PER_BANK.

Referenced by get_gpio_bank_regs().

Here is the caller graph for this function:

◆ gpio_index_to_port()

static int gpio_index_to_port ( int  index)
inlinestatic

Definition at line 62 of file gpio.h.

References GPIO_GPIOS_PER_BANK, and GPIO_GPIOS_PER_PORT.

Referenced by pad_set_gpio_out(), and pad_set_mode().

Here is the caller 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_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 
)

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_to_bit()

static int gpio_to_bit ( int  index)
inlinestatic

Definition at line 67 of file gpio.h.

References GPIO_GPIOS_PER_PORT.

Referenced by pad_set_gpio_out(), and pad_set_mode().

Here is the caller graph for this function: