diff options
Diffstat (limited to 'src/soc/amd/stoneyridge/gpio.c')
-rw-r--r-- | src/soc/amd/stoneyridge/gpio.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/soc/amd/stoneyridge/gpio.c b/src/soc/amd/stoneyridge/gpio.c index d49637a09c..7e19d996ff 100644 --- a/src/soc/amd/stoneyridge/gpio.c +++ b/src/soc/amd/stoneyridge/gpio.c @@ -16,8 +16,11 @@ */ #include <arch/io.h> +#include <gpio.h> #include <soc/gpio.h> +/* The following functions must be implemented by SoC/board code. */ + int gpio_get(gpio_t gpio_num) { uint32_t reg; @@ -26,3 +29,52 @@ int gpio_get(gpio_t gpio_num) return !!(reg & GPIO_PIN_STS); } + + +void gpio_set(gpio_t gpio_num, int value) +{ + uint32_t reg; + + reg = read32((void *)(uintptr_t)gpio_num); + reg &= ~GPIO_OUTPUT_MASK; + reg |= !!value << GPIO_OUTPUT_SHIFT; + write32((void *)(uintptr_t)gpio_num, reg); +} + +void gpio_input_pulldown(gpio_t gpio_num) +{ + uint32_t reg; + + reg = read32((void *)(uintptr_t)gpio_num); + reg &= ~GPIO_PULLUP_ENABLE; + reg |= GPIO_PULLDOWN_ENABLE; + write32((void *)(uintptr_t)gpio_num, reg); +} + +void gpio_input_pullup(gpio_t gpio_num) +{ + uint32_t reg; + + reg = read32((void *)(uintptr_t)gpio_num); + reg &= ~GPIO_PULLDOWN_ENABLE; + reg |= GPIO_PULLUP_ENABLE; + write32((void *)(uintptr_t)gpio_num, reg); +} + +void gpio_input(gpio_t gpio_num) +{ + uint32_t reg; + + reg = read32((void *)(uintptr_t)gpio_num); + reg &= ~GPIO_OUTPUT_ENABLE; + write32((void *)(uintptr_t)gpio_num, reg); +} + +void gpio_output(gpio_t gpio_num, int value) +{ + uint32_t reg; + + reg = read32((void *)(uintptr_t)gpio_num); + reg |= GPIO_OUTPUT_ENABLE; + write32((void *)(uintptr_t)gpio_num, reg); +} |