diff options
author | Jarkko Nikula <jarkko.nikula@nokia.com> | 2008-12-10 20:35:27 -0500 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2008-12-10 20:35:27 -0500 |
commit | 3ff164e15574191c69e8406794b0578c8d2a4e23 (patch) | |
tree | 66c338c6f8dc7893f7a0e44246191766499e83bf /arch/arm/plat-omap | |
parent | 15f74b0335962e8554c91e52d588dc9f8ee7098d (diff) |
ARM: OMAP: make legacy gpio request/free calls superfluous
Clean up OMAP GPIO request/free functions
- Rename and declare static OMAP specific GPIO request/free functions
- Register them into gpiolib as chip-specific hooks
- Add omap_request_gpio/omap_free_gpio wrappers for existing code not
converted yet to use gpiolib
Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
[ dbrownell@users.sourceforge.net: remove needless check_gpio() calls ]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r-- | arch/arm/plat-omap/gpio.c | 43 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/mach/gpio.h | 12 |
2 files changed, 21 insertions, 34 deletions
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index a6dbef476035..e8aae2ac2a00 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c | |||
@@ -886,26 +886,17 @@ static int gpio_wake_enable(unsigned int irq, unsigned int enable) | |||
886 | return retval; | 886 | return retval; |
887 | } | 887 | } |
888 | 888 | ||
889 | int omap_request_gpio(int gpio) | 889 | static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) |
890 | { | 890 | { |
891 | struct gpio_bank *bank; | 891 | struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip); |
892 | unsigned long flags; | 892 | unsigned long flags; |
893 | int status; | ||
894 | |||
895 | if (check_gpio(gpio) < 0) | ||
896 | return -EINVAL; | ||
897 | |||
898 | status = gpio_request(gpio, NULL); | ||
899 | if (status < 0) | ||
900 | return status; | ||
901 | 893 | ||
902 | bank = get_gpio_bank(gpio); | ||
903 | spin_lock_irqsave(&bank->lock, flags); | 894 | spin_lock_irqsave(&bank->lock, flags); |
904 | 895 | ||
905 | /* Set trigger to none. You need to enable the desired trigger with | 896 | /* Set trigger to none. You need to enable the desired trigger with |
906 | * request_irq() or set_irq_type(). | 897 | * request_irq() or set_irq_type(). |
907 | */ | 898 | */ |
908 | _set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE); | 899 | _set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); |
909 | 900 | ||
910 | #ifdef CONFIG_ARCH_OMAP15XX | 901 | #ifdef CONFIG_ARCH_OMAP15XX |
911 | if (bank->method == METHOD_GPIO_1510) { | 902 | if (bank->method == METHOD_GPIO_1510) { |
@@ -913,7 +904,7 @@ int omap_request_gpio(int gpio) | |||
913 | 904 | ||
914 | /* Claim the pin for MPU */ | 905 | /* Claim the pin for MPU */ |
915 | reg = bank->base + OMAP1510_GPIO_PIN_CONTROL; | 906 | reg = bank->base + OMAP1510_GPIO_PIN_CONTROL; |
916 | __raw_writel(__raw_readl(reg) | (1 << get_gpio_index(gpio)), reg); | 907 | __raw_writel(__raw_readl(reg) | (1 << offset), reg); |
917 | } | 908 | } |
918 | #endif | 909 | #endif |
919 | spin_unlock_irqrestore(&bank->lock, flags); | 910 | spin_unlock_irqrestore(&bank->lock, flags); |
@@ -921,39 +912,28 @@ int omap_request_gpio(int gpio) | |||
921 | return 0; | 912 | return 0; |
922 | } | 913 | } |
923 | 914 | ||
924 | void omap_free_gpio(int gpio) | 915 | static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) |
925 | { | 916 | { |
926 | struct gpio_bank *bank; | 917 | struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip); |
927 | unsigned long flags; | 918 | unsigned long flags; |
928 | 919 | ||
929 | if (check_gpio(gpio) < 0) | ||
930 | return; | ||
931 | bank = get_gpio_bank(gpio); | ||
932 | spin_lock_irqsave(&bank->lock, flags); | 920 | spin_lock_irqsave(&bank->lock, flags); |
933 | if (unlikely(!gpiochip_is_requested(&bank->chip, | ||
934 | get_gpio_index(gpio)))) { | ||
935 | spin_unlock_irqrestore(&bank->lock, flags); | ||
936 | printk(KERN_ERR "omap-gpio: GPIO %d wasn't reserved!\n", gpio); | ||
937 | dump_stack(); | ||
938 | return; | ||
939 | } | ||
940 | #ifdef CONFIG_ARCH_OMAP16XX | 921 | #ifdef CONFIG_ARCH_OMAP16XX |
941 | if (bank->method == METHOD_GPIO_1610) { | 922 | if (bank->method == METHOD_GPIO_1610) { |
942 | /* Disable wake-up during idle for dynamic tick */ | 923 | /* Disable wake-up during idle for dynamic tick */ |
943 | void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA; | 924 | void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA; |
944 | __raw_writel(1 << get_gpio_index(gpio), reg); | 925 | __raw_writel(1 << offset, reg); |
945 | } | 926 | } |
946 | #endif | 927 | #endif |
947 | #if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) | 928 | #if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) |
948 | if (bank->method == METHOD_GPIO_24XX) { | 929 | if (bank->method == METHOD_GPIO_24XX) { |
949 | /* Disable wake-up during idle for dynamic tick */ | 930 | /* Disable wake-up during idle for dynamic tick */ |
950 | void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA; | 931 | void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA; |
951 | __raw_writel(1 << get_gpio_index(gpio), reg); | 932 | __raw_writel(1 << offset, reg); |
952 | } | 933 | } |
953 | #endif | 934 | #endif |
954 | _reset_gpio(bank, gpio); | 935 | _reset_gpio(bank, bank->chip.base + offset); |
955 | spin_unlock_irqrestore(&bank->lock, flags); | 936 | spin_unlock_irqrestore(&bank->lock, flags); |
956 | gpio_free(gpio); | ||
957 | } | 937 | } |
958 | 938 | ||
959 | /* | 939 | /* |
@@ -1458,6 +1438,8 @@ static int __init _omap_gpio_init(void) | |||
1458 | /* REVISIT eventually switch from OMAP-specific gpio structs | 1438 | /* REVISIT eventually switch from OMAP-specific gpio structs |
1459 | * over to the generic ones | 1439 | * over to the generic ones |
1460 | */ | 1440 | */ |
1441 | bank->chip.request = omap_gpio_request; | ||
1442 | bank->chip.free = omap_gpio_free; | ||
1461 | bank->chip.direction_input = gpio_input; | 1443 | bank->chip.direction_input = gpio_input; |
1462 | bank->chip.get = gpio_get; | 1444 | bank->chip.get = gpio_get; |
1463 | bank->chip.direction_output = gpio_output; | 1445 | bank->chip.direction_output = gpio_output; |
@@ -1726,9 +1708,6 @@ static int __init omap_gpio_sysinit(void) | |||
1726 | return ret; | 1708 | return ret; |
1727 | } | 1709 | } |
1728 | 1710 | ||
1729 | EXPORT_SYMBOL(omap_request_gpio); | ||
1730 | EXPORT_SYMBOL(omap_free_gpio); | ||
1731 | |||
1732 | arch_initcall(omap_gpio_sysinit); | 1711 | arch_initcall(omap_gpio_sysinit); |
1733 | 1712 | ||
1734 | 1713 | ||
diff --git a/arch/arm/plat-omap/include/mach/gpio.h b/arch/arm/plat-omap/include/mach/gpio.h index 552ad0c0ac4f..04e68e88f134 100644 --- a/arch/arm/plat-omap/include/mach/gpio.h +++ b/arch/arm/plat-omap/include/mach/gpio.h | |||
@@ -71,8 +71,6 @@ | |||
71 | IH_GPIO_BASE + (nr)) | 71 | IH_GPIO_BASE + (nr)) |
72 | 72 | ||
73 | extern int omap_gpio_init(void); /* Call from board init only */ | 73 | extern int omap_gpio_init(void); /* Call from board init only */ |
74 | extern int omap_request_gpio(int gpio); | ||
75 | extern void omap_free_gpio(int gpio); | ||
76 | extern void omap2_gpio_prepare_for_retention(void); | 74 | extern void omap2_gpio_prepare_for_retention(void); |
77 | extern void omap2_gpio_resume_after_retention(void); | 75 | extern void omap2_gpio_resume_after_retention(void); |
78 | extern void omap_set_gpio_debounce(int gpio, int enable); | 76 | extern void omap_set_gpio_debounce(int gpio, int enable); |
@@ -89,6 +87,16 @@ extern void omap_set_gpio_debounce_time(int gpio, int enable); | |||
89 | #include <linux/errno.h> | 87 | #include <linux/errno.h> |
90 | #include <asm-generic/gpio.h> | 88 | #include <asm-generic/gpio.h> |
91 | 89 | ||
90 | static inline int omap_request_gpio(int gpio) | ||
91 | { | ||
92 | return gpio_request(gpio, "FIXME"); | ||
93 | } | ||
94 | |||
95 | static inline void omap_free_gpio(int gpio) | ||
96 | { | ||
97 | gpio_free(gpio); | ||
98 | } | ||
99 | |||
92 | static inline int gpio_get_value(unsigned gpio) | 100 | static inline int gpio_get_value(unsigned gpio) |
93 | { | 101 | { |
94 | return __gpio_get_value(gpio); | 102 | return __gpio_get_value(gpio); |