aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/gpio.h
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2008-11-18 04:48:22 -0500
committerBryan Wu <cooloney@kernel.org>2008-11-18 04:48:22 -0500
commita4f0b32c331a3da1dd1336f1691504268c63fc14 (patch)
treefe511ea71747c4a27cad8e56990681e67345f926 /arch/blackfin/include/asm/gpio.h
parent8d0223744f531168d4ae87f33354d12a50402779 (diff)
Blackfin arch: Convert Blackfin GPIO driver to use common gpiolib/gpiochip infrastructure
- This patch adds support for ARCH_WANT_OPTIONAL_GPIOLIB. - It may be changed in future to ARCH_REQUIRE_GPIOLIB. - Change GPIO_BANK_NUM use DIV_ROUND_UP( , ) macro Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/include/asm/gpio.h')
-rw-r--r--arch/blackfin/include/asm/gpio.h79
1 files changed, 67 insertions, 12 deletions
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h
index 2a5e846a5382..f8fe33b8bca6 100644
--- a/arch/blackfin/include/asm/gpio.h
+++ b/arch/blackfin/include/asm/gpio.h
@@ -84,13 +84,12 @@
84#ifndef __ARCH_BLACKFIN_GPIO_H__ 84#ifndef __ARCH_BLACKFIN_GPIO_H__
85#define __ARCH_BLACKFIN_GPIO_H__ 85#define __ARCH_BLACKFIN_GPIO_H__
86 86
87#define gpio_bank(x) ((x) >> 4) 87#define gpio_bank(x) ((x) >> 4)
88#define gpio_bank_n(x) ((x) & 0xF ? ((x) >> 4) + 1 : (x) >> 4) 88#define gpio_bit(x) (1<<((x) & 0xF))
89#define gpio_bit(x) (1<<((x) & 0xF)) 89#define gpio_sub_n(x) ((x) & 0xF)
90#define gpio_sub_n(x) ((x) & 0xF) 90#define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, 16)
91 91
92#define GPIO_BANKSIZE 16 92#define GPIO_BANKSIZE 16
93#define GPIO_BANK_NUM gpio_bank_n(MAX_BLACKFIN_GPIOS)
94 93
95#define GPIO_0 0 94#define GPIO_0 0
96#define GPIO_1 1 95#define GPIO_1 1
@@ -546,20 +545,76 @@ struct gpio_port_s {
546* MODIFICATION HISTORY : 545* MODIFICATION HISTORY :
547**************************************************************/ 546**************************************************************/
548 547
549int gpio_request(unsigned, const char *);
550void gpio_free(unsigned);
551 548
552void gpio_set_value(unsigned gpio, int arg); 549int bfin_gpio_request(unsigned gpio, const char *label);
553int gpio_get_value(unsigned gpio); 550void bfin_gpio_free(unsigned gpio);
551int bfin_gpio_direction_input(unsigned gpio);
552int bfin_gpio_direction_output(unsigned gpio, int value);
553int bfin_gpio_get_value(unsigned gpio);
554void bfin_gpio_set_value(unsigned gpio, int value);
554 555
555#ifndef BF548_FAMILY 556#ifndef BF548_FAMILY
556#define gpio_set_value(gpio, value) set_gpio_data(gpio, value) 557#define bfin_gpio_set_value(gpio, value) set_gpio_data(gpio, value)
557#endif 558#endif
558 559
559int gpio_direction_input(unsigned gpio); 560#ifdef CONFIG_GPIOLIB
560int gpio_direction_output(unsigned gpio, int value); 561#include <asm-generic/gpio.h> /* cansleep wrappers */
562
563static inline int gpio_get_value(unsigned int gpio)
564{
565 if (gpio < MAX_BLACKFIN_GPIOS)
566 return bfin_gpio_get_value(gpio);
567 else
568 return __gpio_get_value(gpio);
569}
570
571static inline void gpio_set_value(unsigned int gpio, int value)
572{
573 if (gpio < MAX_BLACKFIN_GPIOS)
574 bfin_gpio_set_value(gpio, value);
575 else
576 __gpio_set_value(gpio, value);
577}
578
579static inline int gpio_cansleep(unsigned int gpio)
580{
581 return __gpio_cansleep(gpio);
582}
583
584#else /* !CONFIG_GPIOLIB */
585
586static inline int gpio_request(unsigned gpio, const char *label)
587{
588 return bfin_gpio_request(gpio, label);
589}
590
591static inline void gpio_free(unsigned gpio)
592{
593 return bfin_gpio_free(gpio);
594}
595
596static inline int gpio_direction_input(unsigned gpio)
597{
598 return bfin_gpio_direction_input(gpio);
599}
600
601static inline int gpio_direction_output(unsigned gpio, int value)
602{
603 return bfin_gpio_direction_output(gpio, value);
604}
605
606static inline int gpio_get_value(unsigned gpio)
607{
608 return bfin_gpio_get_value(gpio);
609}
610
611static inline void gpio_set_value(unsigned gpio, int value)
612{
613 return bfin_gpio_set_value(gpio, value);
614}
561 615
562#include <asm-generic/gpio.h> /* cansleep wrappers */ 616#include <asm-generic/gpio.h> /* cansleep wrappers */
617#endif /* !CONFIG_GPIOLIB */
563#include <asm/irq.h> 618#include <asm/irq.h>
564 619
565static inline int gpio_to_irq(unsigned gpio) 620static inline int gpio_to_irq(unsigned gpio)