diff options
Diffstat (limited to 'arch/arm/mach-tegra/include/mach/gpio.h')
| -rw-r--r-- | arch/arm/mach-tegra/include/mach/gpio.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/include/mach/gpio.h b/arch/arm/mach-tegra/include/mach/gpio.h new file mode 100644 index 00000000000..b7357ab0c4d --- /dev/null +++ b/arch/arm/mach-tegra/include/mach/gpio.h | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | /* | ||
| 2 | * arch/arm/mach-tegra/include/mach/gpio.h | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Google, Inc. | ||
| 5 | * | ||
| 6 | * Author: | ||
| 7 | * Erik Gilling <konkers@google.com> | ||
| 8 | * | ||
| 9 | * This software is licensed under the terms of the GNU General Public | ||
| 10 | * License version 2, as published by the Free Software Foundation, and | ||
| 11 | * may be copied, distributed, and modified under those terms. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __MACH_TEGRA_GPIO_H | ||
| 21 | #define __MACH_TEGRA_GPIO_H | ||
| 22 | |||
| 23 | #include <linux/init.h> | ||
| 24 | #include <mach/irqs.h> | ||
| 25 | |||
| 26 | #define TEGRA_NR_GPIOS INT_GPIO_NR | ||
| 27 | #define ARCH_NR_GPIOS (TEGRA_NR_GPIOS + 128) | ||
| 28 | |||
| 29 | #include <asm-generic/gpio.h> | ||
| 30 | #include "pinmux.h" | ||
| 31 | |||
| 32 | struct gpio_init_pin_info { | ||
| 33 | char name[16]; | ||
| 34 | int gpio_nr; | ||
| 35 | bool is_gpio; | ||
| 36 | bool is_input; | ||
| 37 | int value; /* Value if it is output*/ | ||
| 38 | }; | ||
| 39 | |||
| 40 | #define gpio_get_value __gpio_get_value | ||
| 41 | #define gpio_set_value __gpio_set_value | ||
| 42 | #define gpio_cansleep __gpio_cansleep | ||
| 43 | |||
| 44 | #define TEGRA_GPIO_TO_IRQ(gpio) (INT_GPIO_BASE + (gpio)) | ||
| 45 | #define TEGRA_IRQ_TO_GPIO(irq) ((irq) - INT_GPIO_BASE) | ||
| 46 | |||
| 47 | static inline int gpio_to_irq(unsigned int gpio) | ||
| 48 | { | ||
| 49 | /* SOC gpio */ | ||
| 50 | if (gpio < TEGRA_NR_GPIOS) | ||
| 51 | return INT_GPIO_BASE + gpio; | ||
| 52 | |||
| 53 | /* For non soc gpio, the external peripheral driver need to | ||
| 54 | * provide the implementation */ | ||
| 55 | return __gpio_to_irq(gpio); | ||
| 56 | } | ||
| 57 | |||
| 58 | static inline int irq_to_gpio(unsigned int irq) | ||
| 59 | { | ||
| 60 | /* SOC gpio */ | ||
| 61 | if ((irq >= INT_GPIO_BASE) && (irq < INT_GPIO_BASE + INT_GPIO_NR)) | ||
| 62 | return irq - INT_GPIO_BASE; | ||
| 63 | |||
| 64 | /* we don't supply reverse mappings for non-SOC gpios */ | ||
| 65 | return -EIO; | ||
| 66 | } | ||
| 67 | |||
| 68 | struct tegra_gpio_table { | ||
| 69 | int gpio; /* GPIO number */ | ||
| 70 | bool enable; /* Enable for GPIO at init? */ | ||
| 71 | }; | ||
| 72 | |||
| 73 | void tegra_gpio_config(struct tegra_gpio_table *table, int num); | ||
| 74 | void tegra_gpio_enable(int gpio); | ||
| 75 | void tegra_gpio_disable(int gpio); | ||
| 76 | int tegra_gpio_resume_init(void); | ||
| 77 | void tegra_gpio_init_configure(unsigned gpio, bool is_input, int value); | ||
| 78 | void tegra_gpio_set_tristate(int gpio, enum tegra_tristate ts); | ||
| 79 | int tegra_gpio_get_bank_int_nr(int gpio); | ||
| 80 | #endif | ||
