aboutsummaryrefslogtreecommitdiff
path: root/src/soc/nvidia/tegra
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/nvidia/tegra')
-rw-r--r--src/soc/nvidia/tegra/gpio.c68
-rw-r--r--src/soc/nvidia/tegra/gpio.h23
2 files changed, 17 insertions, 74 deletions
diff --git a/src/soc/nvidia/tegra/gpio.c b/src/soc/nvidia/tegra/gpio.c
index b10cded12d..17b90aa1d9 100644
--- a/src/soc/nvidia/tegra/gpio.c
+++ b/src/soc/nvidia/tegra/gpio.c
@@ -23,6 +23,7 @@
#include <stddef.h>
#include <stdint.h>
#include <delay.h>
+#include <gpiolib.h>
#include "gpio.h"
#include "pinmux.h"
@@ -175,58 +176,6 @@ int gpio_get_in_value(gpio_t gpio)
return (port & (1 << bit)) != 0;
}
-int gpio_get_in_tristate_values(gpio_t gpio[], int num_gpio, int value[])
-{
- /*
- * GPIOs which are tied to stronger external pull up or pull down
- * will stay there regardless of the internal pull up or pull
- * down setting.
- *
- * GPIOs which are floating will go to whatever level they're
- * internally pulled to.
- */
-
- int temp;
- int index;
-
- /* Enable internal pull up */
- for (index = 0; index < num_gpio; ++index)
- gpio_input_pullup(gpio[index]);
-
- /* Wait until signals become stable */
- udelay(10);
-
- /* Get gpio values at internal pull up */
- for (index = 0; index < num_gpio; ++index)
- value[index] = gpio_get_in_value(gpio[index]);
-
- /* Enable internal pull down */
- for (index = 0; index < num_gpio; ++index)
- gpio_input_pulldown(gpio[index]);
-
- /* Wait until signals become stable */
- udelay(10);
-
- /*
- * Get gpio values at internal pull down.
- * Compare with gpio pull up value and then
- * determine a gpio final value/state:
- * 0: pull down
- * 1: pull up
- * 2: floating
- */
- for (index = 0; index < num_gpio; ++index) {
- temp = gpio_get_in_value(gpio[index]);
- value[index] = ((value[index] ^ temp) << 1) | temp;
- }
-
- /* Disable pull up / pull down to conserve power */
- for (index = 0; index < num_gpio; ++index)
- gpio_input(gpio[index]);
-
- return 0;
-}
-
int gpio_get_int_status(gpio_t gpio)
{
int bit = gpio % GPIO_GPIOS_PER_PORT;
@@ -279,3 +228,18 @@ void gpio_set_int_clear(gpio_t gpio)
offsetof(struct gpio_bank, int_clear),
1 << bit, 1 << bit);
}
+
+void gpio_input_pulldown(gpio_t gpio)
+{
+ __gpio_input(gpio, PINMUX_PULL_DOWN);
+}
+
+void gpio_input_pullup(gpio_t gpio)
+{
+ __gpio_input(gpio, PINMUX_PULL_UP);
+}
+
+void gpio_input(gpio_t gpio)
+{
+ __gpio_input(gpio, PINMUX_PULL_NONE);
+}
diff --git a/src/soc/nvidia/tegra/gpio.h b/src/soc/nvidia/tegra/gpio.h
index 5f6833af79..43f898958e 100644
--- a/src/soc/nvidia/tegra/gpio.h
+++ b/src/soc/nvidia/tegra/gpio.h
@@ -21,12 +21,10 @@
#define __SOC_NVIDIA_TEGRA_GPIO_H__
#include <stdint.h>
+#include <gpiolib.h>
#include "pinmux.h"
-/* Wrapper type for GPIOs. Always use GPIO() macro to generate. */
-typedef u32 gpio_t;
-
#define GPIO_PINMUX_SHIFT 16
#define GPIO(name) ((gpio_t)(GPIO_##name##_INDEX | \
(PINMUX_GPIO_##name << GPIO_PINMUX_SHIFT)))
@@ -46,21 +44,6 @@ static inline void gpio_output_open_drain(gpio_t gpio, int value)
__gpio_output(gpio, value, PINMUX_OPEN_DRAIN);
}
-static inline void gpio_input(gpio_t gpio)
-{
- __gpio_input(gpio, PINMUX_PULL_NONE);
-}
-
-static inline void gpio_input_pulldown(gpio_t gpio)
-{
- __gpio_input(gpio, PINMUX_PULL_DOWN);
-}
-
-static inline void gpio_input_pullup(gpio_t gpio)
-{
- __gpio_input(gpio, PINMUX_PULL_UP);
-}
-
/* Functions to modify specific GPIO control values. */
enum gpio_mode {
@@ -77,12 +60,8 @@ 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_out_value(gpio_t gpio, int value);
int gpio_get_out_value(gpio_t gpio);
-int gpio_get_in_value(gpio_t gpio);
-int gpio_get_in_tristate_values(gpio_t gpio[], int num_gpio, int value[]);
-
int gpio_get_int_status(gpio_t gpio);
void gpio_set_int_enable(gpio_t gpio, int enable);