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 <console/console.h>
#include <soc/ti/am335x/gpio.h>
#include <stdint.h>
Include dependency graph for gpio.c:

Go to the source code of this file.

Functions

static struct am335x_gpio_regsgpio_regs_and_bit (unsigned int gpio, uint32_t *bit)
 
void am335x_disable_gpio_irqs (void)
 
int gpio_direction_input (unsigned int gpio)
 Make a GPIO an input. More...
 
int gpio_direction_output (unsigned int gpio, int value)
 Make a GPIO an output, and set its value. More...
 
int gpio_get_value (unsigned int gpio)
 Get a GPIO's value. More...
 
int gpio_set_value (unsigned int gpio, int value)
 Set an output GPIO's value. More...
 

Function Documentation

◆ am335x_disable_gpio_irqs()

void am335x_disable_gpio_irqs ( void  )

Definition at line 21 of file gpio.c.

References am335x_gpio_banks, ARRAY_SIZE, am335x_gpio_regs::irqstatus_clr_0, and write32().

Referenced by bootblock_mainboard_early_init().

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

◆ gpio_direction_input()

int gpio_direction_input ( unsigned int  gpio)

Make a GPIO an input.

Parameters
gpioGPIO number
Returns
0 if ok, -1 on error

Definition at line 29 of file gpio.c.

References gpio_regs_and_bit(), and setbits32.

Here is the call graph for this function:

◆ gpio_direction_output()

int gpio_direction_output ( unsigned int  gpio,
int  value 
)

Make a GPIO an output, and set its value.

Parameters
gpioGPIO number
valueGPIO value (0 for low or 1 for high)
Returns
0 if ok, -1 on error

Definition at line 40 of file gpio.c.

References clrbits32, gpio_regs_and_bit(), value, and write32().

Here is the call graph for this function:

◆ gpio_get_value()

int gpio_get_value ( unsigned int  gpio)

Get a GPIO's value.

This will work whether the GPIO is an input or an output.

Parameters
gpioGPIO number
Returns
0 if low, 1 if high, -1 on error

Definition at line 55 of file gpio.c.

References gpio_regs_and_bit(), and read32().

Here is the call graph for this function:

◆ gpio_regs_and_bit()

static struct am335x_gpio_regs* gpio_regs_and_bit ( unsigned int  gpio,
uint32_t bit 
)
static

Definition at line 8 of file gpio.c.

References am335x_gpio_banks, AM335X_GPIO_BITS_PER_BANK, ARRAY_SIZE, BIOS_ERR, NULL, and printk.

Referenced by gpio_direction_input(), gpio_direction_output(), gpio_get_value(), and gpio_set_value().

Here is the caller graph for this function:

◆ gpio_set_value()

int gpio_set_value ( unsigned int  gpio,
int  value 
)

Set an output GPIO's value.

The GPIO must already be an output or this function may have no effect.

Parameters
gpioGPIO number
valueGPIO value (0 for low or 1 for high)
Returns
0 if ok, -1 on error

Definition at line 65 of file gpio.c.

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

Here is the call graph for this function: