![]() |
coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
|
#include <assert.h>
#include <console/console.h>
#include <device/mmio.h>
#include <delay.h>
#include <soc/cpu.h>
#include <soc/gpio.h>
Go to the source code of this file.
Data Structures | |
struct | gpio_info |
Macros | |
#define | CON_MASK(x) (0xf << ((x) << 2)) |
#define | CON_SFR(x, v) ((v) << ((x) << 2)) |
#define | DAT_MASK(x) (0x1 << (x)) |
#define | DAT_SET(x) (0x1 << (x)) |
#define | PULL_MASK(x) (0x3 << ((x) << 1)) |
#define | PULL_MODE(x, v) ((v) << ((x) << 1)) |
#define | DRV_MASK(x) (0x3 << ((x) << 1)) |
#define | DRV_SET(x, m) ((m) << ((x) << 1)) |
#define | RATE_MASK(x) (0x1 << (x + 16)) |
#define | RATE_SET(x) (0x1 << (x + 16)) |
#define | GPIO_BIT(x) ((x) & 0x7) |
#define | GPIO_DELAY_US 15 |
Functions | |
static struct gpio_bank * | gpio_get_bank (unsigned int gpio) |
void | gpio_cfg_pin (int gpio, int cfg) |
Set GPIO pin configuration. More... | |
static int | gpio_get_cfg (int gpio) |
void | gpio_set_pull (int gpio, int mode) |
Set GPIO pull mode. More... | |
void | gpio_set_drv (int gpio, int mode) |
Set GPIO drive strength level. More... | |
void | gpio_set_rate (int gpio, int mode) |
Set GPIO drive rate. More... | |
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... | |
int | gpio_read_mvl3 (unsigned int gpio) |
void | gpio_info (void) |
Variables | |
static const struct gpio_info | gpio_data [EXYNOS_GPIO_NUM_PARTS] |
void gpio_cfg_pin | ( | int | gpio, |
int | cfg | ||
) |
Set GPIO pin configuration.
gpio | GPIO pin |
cfg | Either GPIO_INPUT, GPIO_OUTPUT, or GPIO_IRQ |
Definition at line 63 of file gpio.c.
References gpio_bank::con, CON_MASK, CON_SFR, GPIO_BIT, gpio_get_bank(), read32(), value, and write32().
int gpio_direction_input | ( | unsigned int | gpio | ) |
Make a GPIO an input.
gpio | GPIO number |
Definition at line 144 of file gpio.c.
References gpio_cfg_pin(), and GPIO_INPUT.
int gpio_direction_output | ( | unsigned int | gpio, |
int | value | ||
) |
Make a GPIO an output, and set its value.
gpio | GPIO number |
value | GPIO value (0 for low or 1 for high) |
Definition at line 151 of file gpio.c.
References gpio_bank::dat, DAT_MASK, DAT_SET, GPIO_BIT, gpio_cfg_pin(), gpio_get_bank(), GPIO_OUTPUT, read32(), val, value, and write32().
Definition at line 41 of file gpio.c.
References ASSERT, EXYNOS_GPIO_NUM_PARTS, gpio_data, GPIO_MAX_PORT, GPIO_PER_BANK, gpio_info::max_gpio, NULL, and gpio_info::reg_addr.
Referenced by gpio_cfg_pin(), gpio_direction_output(), gpio_get_cfg(), gpio_get_value(), gpio_set_drv(), gpio_set_pull(), gpio_set_rate(), and gpio_set_value().
|
static |
Definition at line 74 of file gpio.c.
References gpio_bank::con, CON_MASK, GPIO_BIT, gpio_get_bank(), and read32().
Referenced by gpio_info().
int gpio_get_value | ( | unsigned int | gpio | ) |
Get a GPIO's value.
This will work whether the GPIO is an input or an output.
gpio | GPIO number |
Definition at line 167 of file gpio.c.
References gpio_bank::dat, DAT_MASK, GPIO_BIT, gpio_get_bank(), read32(), and value.
Definition at line 236 of file gpio.c.
References BIOS_INFO, gpio_get_cfg(), gpio_get_value(), GPIO_INPUT, GPIO_MAX_PORT, GPIO_OUTPUT, and printk.
int gpio_read_mvl3 | ( | unsigned int | gpio | ) |
Definition at line 197 of file gpio.c.
References GPIO_DELAY_US, gpio_direction_input(), gpio_get_value(), GPIO_MAX_PORT, GPIO_PULL_DOWN, GPIO_PULL_UP, gpio_set_pull(), LOGIC_0, LOGIC_1, LOGIC_Z, udelay(), and value.
void gpio_set_drv | ( | int | gpio, |
int | mode | ||
) |
Set GPIO drive strength level.
gpio | GPIO pin |
mode | Either GPIO_DRV_1X, GPIO_DRV_2X, GPIO_DRV_3X, or GPIO_DRV_4X |
Definition at line 102 of file gpio.c.
References gpio_bank::drv, DRV_MASK, DRV_SET, GPIO_BIT, GPIO_DRV_1X, GPIO_DRV_2X, GPIO_DRV_3X, GPIO_DRV_4X, gpio_get_bank(), read32(), value, and write32().
void gpio_set_pull | ( | int | gpio, |
int | mode | ||
) |
Set GPIO pull mode.
gpio | GPIO pin |
mode | Either GPIO_PULL_DOWN or GPIO_PULL_UP |
Definition at line 82 of file gpio.c.
References GPIO_BIT, gpio_get_bank(), GPIO_PULL_DOWN, GPIO_PULL_UP, gpio_bank::pull, PULL_MASK, PULL_MODE, read32(), value, and write32().
void gpio_set_rate | ( | int | gpio, |
int | mode | ||
) |
Set GPIO drive rate.
gpio | GPIO pin |
mode | Either GPIO_DRV_FAST or GPIO_DRV_SLOW |
Definition at line 124 of file gpio.c.
References gpio_bank::drv, GPIO_BIT, GPIO_DRV_FAST, GPIO_DRV_SLOW, gpio_get_bank(), RATE_MASK, RATE_SET, read32(), value, and write32().
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.
gpio | GPIO number |
value | GPIO value (0 for low or 1 for high) |
Definition at line 176 of file gpio.c.
References gpio_bank::dat, DAT_MASK, DAT_SET, GPIO_BIT, gpio_get_bank(), read32(), val, value, and write32().
|
static |