Commit 632095ea authored by Olof Johansson's avatar Olof Johansson

ARM: tegra: add tegra_gpio_table and tegra_gpio_config

To give one place to setup the pins that are used as GPIOs instead
of as their pinmuxed functions. Specifying enabled as false explicitly
disables the gpio mode of that pin (if left on by firmware).

This should remove the need for calling these from specific drivers and
thus reduce tegra-specific code from them.
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
Acked-by: default avatarErik Gilling <konkers@android.com>
parent 38376866
...@@ -381,6 +381,20 @@ static int __init tegra_gpio_init(void) ...@@ -381,6 +381,20 @@ static int __init tegra_gpio_init(void)
postcore_initcall(tegra_gpio_init); postcore_initcall(tegra_gpio_init);
void __init tegra_gpio_config(struct tegra_gpio_table *table, int num)
{
int i;
for (i = 0; i < num; i++) {
int gpio = table[i].gpio;
if (table[i].enable)
tegra_gpio_enable(gpio);
else
tegra_gpio_disable(gpio);
}
}
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h> #include <linux/debugfs.h>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#ifndef __MACH_TEGRA_GPIO_H #ifndef __MACH_TEGRA_GPIO_H
#define __MACH_TEGRA_GPIO_H #define __MACH_TEGRA_GPIO_H
#include <linux/init.h>
#include <mach/irqs.h> #include <mach/irqs.h>
#define TEGRA_NR_GPIOS INT_GPIO_NR #define TEGRA_NR_GPIOS INT_GPIO_NR
...@@ -47,6 +48,12 @@ static inline int irq_to_gpio(unsigned int irq) ...@@ -47,6 +48,12 @@ static inline int irq_to_gpio(unsigned int irq)
return -EINVAL; return -EINVAL;
} }
struct tegra_gpio_table {
int gpio; /* GPIO number */
bool enable; /* Enable for GPIO at init? */
};
void tegra_gpio_config(struct tegra_gpio_table *table, int num);
void tegra_gpio_enable(int gpio); void tegra_gpio_enable(int gpio);
void tegra_gpio_disable(int gpio); void tegra_gpio_disable(int gpio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment