Commit 3ff164e1 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Tony Lindgren

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: default avatarJarkko Nikula <jarkko.nikula@nokia.com>
[ dbrownell@users.sourceforge.net: remove needless check_gpio() calls ]
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 15f74b03
...@@ -886,26 +886,17 @@ static int gpio_wake_enable(unsigned int irq, unsigned int enable) ...@@ -886,26 +886,17 @@ static int gpio_wake_enable(unsigned int irq, unsigned int enable)
return retval; return retval;
} }
int omap_request_gpio(int gpio) static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
{ {
struct gpio_bank *bank; struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
unsigned long flags; unsigned long flags;
int status;
if (check_gpio(gpio) < 0)
return -EINVAL;
status = gpio_request(gpio, NULL);
if (status < 0)
return status;
bank = get_gpio_bank(gpio);
spin_lock_irqsave(&bank->lock, flags); spin_lock_irqsave(&bank->lock, flags);
/* Set trigger to none. You need to enable the desired trigger with /* Set trigger to none. You need to enable the desired trigger with
* request_irq() or set_irq_type(). * request_irq() or set_irq_type().
*/ */
_set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE); _set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
#ifdef CONFIG_ARCH_OMAP15XX #ifdef CONFIG_ARCH_OMAP15XX
if (bank->method == METHOD_GPIO_1510) { if (bank->method == METHOD_GPIO_1510) {
...@@ -913,7 +904,7 @@ int omap_request_gpio(int gpio) ...@@ -913,7 +904,7 @@ int omap_request_gpio(int gpio)
/* Claim the pin for MPU */ /* Claim the pin for MPU */
reg = bank->base + OMAP1510_GPIO_PIN_CONTROL; reg = bank->base + OMAP1510_GPIO_PIN_CONTROL;
__raw_writel(__raw_readl(reg) | (1 << get_gpio_index(gpio)), reg); __raw_writel(__raw_readl(reg) | (1 << offset), reg);
} }
#endif #endif
spin_unlock_irqrestore(&bank->lock, flags); spin_unlock_irqrestore(&bank->lock, flags);
...@@ -921,39 +912,28 @@ int omap_request_gpio(int gpio) ...@@ -921,39 +912,28 @@ int omap_request_gpio(int gpio)
return 0; return 0;
} }
void omap_free_gpio(int gpio) static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
{ {
struct gpio_bank *bank; struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
unsigned long flags; unsigned long flags;
if (check_gpio(gpio) < 0)
return;
bank = get_gpio_bank(gpio);
spin_lock_irqsave(&bank->lock, flags); spin_lock_irqsave(&bank->lock, flags);
if (unlikely(!gpiochip_is_requested(&bank->chip,
get_gpio_index(gpio)))) {
spin_unlock_irqrestore(&bank->lock, flags);
printk(KERN_ERR "omap-gpio: GPIO %d wasn't reserved!\n", gpio);
dump_stack();
return;
}
#ifdef CONFIG_ARCH_OMAP16XX #ifdef CONFIG_ARCH_OMAP16XX
if (bank->method == METHOD_GPIO_1610) { if (bank->method == METHOD_GPIO_1610) {
/* Disable wake-up during idle for dynamic tick */ /* Disable wake-up during idle for dynamic tick */
void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA; void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
__raw_writel(1 << get_gpio_index(gpio), reg); __raw_writel(1 << offset, reg);
} }
#endif #endif
#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) #if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
if (bank->method == METHOD_GPIO_24XX) { if (bank->method == METHOD_GPIO_24XX) {
/* Disable wake-up during idle for dynamic tick */ /* Disable wake-up during idle for dynamic tick */
void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA; void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
__raw_writel(1 << get_gpio_index(gpio), reg); __raw_writel(1 << offset, reg);
} }
#endif #endif
_reset_gpio(bank, gpio); _reset_gpio(bank, bank->chip.base + offset);
spin_unlock_irqrestore(&bank->lock, flags); spin_unlock_irqrestore(&bank->lock, flags);
gpio_free(gpio);
} }
/* /*
...@@ -1458,6 +1438,8 @@ static int __init _omap_gpio_init(void) ...@@ -1458,6 +1438,8 @@ static int __init _omap_gpio_init(void)
/* REVISIT eventually switch from OMAP-specific gpio structs /* REVISIT eventually switch from OMAP-specific gpio structs
* over to the generic ones * over to the generic ones
*/ */
bank->chip.request = omap_gpio_request;
bank->chip.free = omap_gpio_free;
bank->chip.direction_input = gpio_input; bank->chip.direction_input = gpio_input;
bank->chip.get = gpio_get; bank->chip.get = gpio_get;
bank->chip.direction_output = gpio_output; bank->chip.direction_output = gpio_output;
...@@ -1726,9 +1708,6 @@ static int __init omap_gpio_sysinit(void) ...@@ -1726,9 +1708,6 @@ static int __init omap_gpio_sysinit(void)
return ret; return ret;
} }
EXPORT_SYMBOL(omap_request_gpio);
EXPORT_SYMBOL(omap_free_gpio);
arch_initcall(omap_gpio_sysinit); arch_initcall(omap_gpio_sysinit);
......
...@@ -71,8 +71,6 @@ ...@@ -71,8 +71,6 @@
IH_GPIO_BASE + (nr)) IH_GPIO_BASE + (nr))
extern int omap_gpio_init(void); /* Call from board init only */ extern int omap_gpio_init(void); /* Call from board init only */
extern int omap_request_gpio(int gpio);
extern void omap_free_gpio(int gpio);
extern void omap2_gpio_prepare_for_retention(void); extern void omap2_gpio_prepare_for_retention(void);
extern void omap2_gpio_resume_after_retention(void); extern void omap2_gpio_resume_after_retention(void);
extern void omap_set_gpio_debounce(int gpio, int enable); 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,6 +87,16 @@ extern void omap_set_gpio_debounce_time(int gpio, int enable);
#include <linux/errno.h> #include <linux/errno.h>
#include <asm-generic/gpio.h> #include <asm-generic/gpio.h>
static inline int omap_request_gpio(int gpio)
{
return gpio_request(gpio, "FIXME");
}
static inline void omap_free_gpio(int gpio)
{
gpio_free(gpio);
}
static inline int gpio_get_value(unsigned gpio) static inline int gpio_get_value(unsigned gpio)
{ {
return __gpio_get_value(gpio); return __gpio_get_value(gpio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment