diff options
author | Joachim Eastwood <joachim.eastwood@jotron.com> | 2010-02-10 06:31:41 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2010-03-09 00:30:52 -0500 |
commit | 7f4f69f991146fa976cbc914a50285b2afc0ad93 (patch) | |
tree | 3cbcc6cdf3e433e2be68278b51a22aa7be9f9773 /arch | |
parent | f8e6dbffa7a6cb3da3bcaf1fde3039896e1ac764 (diff) |
Blackfin: GPIO: implement to_irq handler
This makes it possible to support IRQs coming from off-chip GPIO
controllers.
Signed-off-by: Joachim Eastwood <joachim.eastwood@jotron.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/blackfin/include/asm/gpio.h | 17 | ||||
-rw-r--r-- | arch/blackfin/kernel/bfin_gpio.c | 6 |
2 files changed, 19 insertions, 4 deletions
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index 539468a05057..91bd2d7b9d55 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h | |||
@@ -70,6 +70,8 @@ | |||
70 | 70 | ||
71 | #ifndef __ASSEMBLY__ | 71 | #ifndef __ASSEMBLY__ |
72 | 72 | ||
73 | #include <linux/compiler.h> | ||
74 | |||
73 | /*********************************************************** | 75 | /*********************************************************** |
74 | * | 76 | * |
75 | * FUNCTIONS: Blackfin General Purpose Ports Access Functions | 77 | * FUNCTIONS: Blackfin General Purpose Ports Access Functions |
@@ -223,6 +225,9 @@ int bfin_gpio_direction_output(unsigned gpio, int value); | |||
223 | int bfin_gpio_get_value(unsigned gpio); | 225 | int bfin_gpio_get_value(unsigned gpio); |
224 | void bfin_gpio_set_value(unsigned gpio, int value); | 226 | void bfin_gpio_set_value(unsigned gpio, int value); |
225 | 227 | ||
228 | #include <asm/irq.h> | ||
229 | #include <asm/errno.h> | ||
230 | |||
226 | #ifdef CONFIG_GPIOLIB | 231 | #ifdef CONFIG_GPIOLIB |
227 | #include <asm-generic/gpio.h> /* cansleep wrappers */ | 232 | #include <asm-generic/gpio.h> /* cansleep wrappers */ |
228 | 233 | ||
@@ -247,6 +252,11 @@ static inline int gpio_cansleep(unsigned int gpio) | |||
247 | return __gpio_cansleep(gpio); | 252 | return __gpio_cansleep(gpio); |
248 | } | 253 | } |
249 | 254 | ||
255 | static inline int gpio_to_irq(unsigned gpio) | ||
256 | { | ||
257 | return __gpio_to_irq(gpio); | ||
258 | } | ||
259 | |||
250 | #else /* !CONFIG_GPIOLIB */ | 260 | #else /* !CONFIG_GPIOLIB */ |
251 | 261 | ||
252 | static inline int gpio_request(unsigned gpio, const char *label) | 262 | static inline int gpio_request(unsigned gpio, const char *label) |
@@ -279,10 +289,6 @@ static inline void gpio_set_value(unsigned gpio, int value) | |||
279 | return bfin_gpio_set_value(gpio, value); | 289 | return bfin_gpio_set_value(gpio, value); |
280 | } | 290 | } |
281 | 291 | ||
282 | #include <asm-generic/gpio.h> /* cansleep wrappers */ | ||
283 | #endif /* !CONFIG_GPIOLIB */ | ||
284 | #include <asm/irq.h> | ||
285 | |||
286 | static inline int gpio_to_irq(unsigned gpio) | 292 | static inline int gpio_to_irq(unsigned gpio) |
287 | { | 293 | { |
288 | if (likely(gpio < MAX_BLACKFIN_GPIOS)) | 294 | if (likely(gpio < MAX_BLACKFIN_GPIOS)) |
@@ -291,6 +297,9 @@ static inline int gpio_to_irq(unsigned gpio) | |||
291 | return -EINVAL; | 297 | return -EINVAL; |
292 | } | 298 | } |
293 | 299 | ||
300 | #include <asm-generic/gpio.h> /* cansleep wrappers */ | ||
301 | #endif /* !CONFIG_GPIOLIB */ | ||
302 | |||
294 | static inline int irq_to_gpio(unsigned irq) | 303 | static inline int irq_to_gpio(unsigned irq) |
295 | { | 304 | { |
296 | return (irq - GPIO_IRQ_BASE); | 305 | return (irq - GPIO_IRQ_BASE); |
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index 0dd9cf913503..6dcb344001f0 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c | |||
@@ -1319,6 +1319,11 @@ void bfin_gpiolib_gpio_free(struct gpio_chip *chip, unsigned gpio) | |||
1319 | return bfin_gpio_free(gpio); | 1319 | return bfin_gpio_free(gpio); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | int bfin_gpiolib_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) | ||
1323 | { | ||
1324 | return gpio + GPIO_IRQ_BASE; | ||
1325 | } | ||
1326 | |||
1322 | static struct gpio_chip bfin_chip = { | 1327 | static struct gpio_chip bfin_chip = { |
1323 | .label = "BFIN-GPIO", | 1328 | .label = "BFIN-GPIO", |
1324 | .direction_input = bfin_gpiolib_direction_input, | 1329 | .direction_input = bfin_gpiolib_direction_input, |
@@ -1327,6 +1332,7 @@ static struct gpio_chip bfin_chip = { | |||
1327 | .set = bfin_gpiolib_set_value, | 1332 | .set = bfin_gpiolib_set_value, |
1328 | .request = bfin_gpiolib_gpio_request, | 1333 | .request = bfin_gpiolib_gpio_request, |
1329 | .free = bfin_gpiolib_gpio_free, | 1334 | .free = bfin_gpiolib_gpio_free, |
1335 | .to_irq = bfin_gpiolib_gpio_to_irq, | ||
1330 | .base = 0, | 1336 | .base = 0, |
1331 | .ngpio = MAX_BLACKFIN_GPIOS, | 1337 | .ngpio = MAX_BLACKFIN_GPIOS, |
1332 | }; | 1338 | }; |