Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] OMAP GPIO wrappers

This teaches OMAP how to implement the cross-platform GPIO interfaces.

[akpm@osdl.org: cleanups]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Brownell and committed by
Linus Torvalds
3c729f1e 4c20386c

+66
+66
include/asm-arm/arch-omap/gpio.h
··· 76 76 extern void omap_set_gpio_dataout(int gpio, int enable); 77 77 extern int omap_get_gpio_datain(int gpio); 78 78 79 + /*-------------------------------------------------------------------------*/ 80 + 81 + /* wrappers for "new style" GPIO calls. the old OMAP-specfic ones should 82 + * eventually be removed (along with this errno.h inclusion), and maybe 83 + * gpios should put MPUIOs last too. 84 + */ 85 + 86 + #include <asm/errno.h> 87 + 88 + static inline int gpio_request(unsigned gpio, const char *label) 89 + { 90 + return omap_request_gpio(gpio); 91 + } 92 + 93 + static inline void gpio_free(unsigned gpio) 94 + { 95 + omap_free_gpio(gpio); 96 + } 97 + 98 + static inline int __gpio_set_direction(unsigned gpio, int is_input) 99 + { 100 + if (cpu_class_is_omap2()) { 101 + if (gpio > OMAP_MAX_GPIO_LINES) 102 + return -EINVAL; 103 + } else { 104 + if (gpio > (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)) 105 + return -EINVAL; 106 + } 107 + omap_set_gpio_direction(gpio, is_input); 108 + return 0; 109 + } 110 + 111 + static inline int gpio_direction_input(unsigned gpio) 112 + { 113 + return __gpio_set_direction(gpio, 1); 114 + } 115 + 116 + static inline int gpio_direction_output(unsigned gpio) 117 + { 118 + return __gpio_set_direction(gpio, 0); 119 + } 120 + 121 + static inline int gpio_get_value(unsigned gpio) 122 + { 123 + return omap_get_gpio_datain(gpio); 124 + } 125 + 126 + static inline void gpio_set_value(unsigned gpio, int value) 127 + { 128 + omap_set_gpio_dataout(gpio, value); 129 + } 130 + 131 + #include <asm-generic/gpio.h> /* cansleep wrappers */ 132 + 133 + static inline int gpio_to_irq(unsigned gpio) 134 + { 135 + return OMAP_GPIO_IRQ(gpio); 136 + } 137 + 138 + static inline int irq_to_gpio(unsigned irq) 139 + { 140 + if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16))) 141 + return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES; 142 + return irq - IH_GPIO_BASE; 143 + } 144 + 79 145 #endif