Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 87291
b: refs/heads/master
c: a647253
h: refs/heads/master
i:
  87289: 8b40b41
  87287: 8cb100a
v: v3
  • Loading branch information
David Brownell authored and Tony Lindgren committed Mar 5, 2008
1 parent 8fbd5cd commit 93d6167
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 02bad5f9bc9f1f42d4bb87bb8bf741d4cefe87d6
refs/heads/master: a6472533e4553985af775982744b0ba088b5ff8c
59 changes: 35 additions & 24 deletions trunk/arch/arm/plat-omap/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,14 @@ static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
void omap_set_gpio_direction(int gpio, int is_input)
{
struct gpio_bank *bank;
unsigned long flags;

if (check_gpio(gpio) < 0)
return;
bank = get_gpio_bank(gpio);
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
_set_gpio_direction(bank, get_gpio_index(gpio), is_input);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
}

static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
Expand Down Expand Up @@ -406,13 +407,14 @@ static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
void omap_set_gpio_dataout(int gpio, int enable)
{
struct gpio_bank *bank;
unsigned long flags;

if (check_gpio(gpio) < 0)
return;
bank = get_gpio_bank(gpio);
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
_set_gpio_dataout(bank, get_gpio_index(gpio), enable);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
}

int omap_get_gpio_datain(int gpio)
Expand Down Expand Up @@ -624,6 +626,7 @@ static int gpio_irq_type(unsigned irq, unsigned type)
struct gpio_bank *bank;
unsigned gpio;
int retval;
unsigned long flags;

if (!cpu_class_is_omap2() && irq > IH_MPUIO_BASE)
gpio = OMAP_MPUIO(irq - IH_MPUIO_BASE);
Expand All @@ -642,13 +645,13 @@ static int gpio_irq_type(unsigned irq, unsigned type)
return -EINVAL;

bank = get_irq_chip_data(irq);
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
retval = _set_gpio_triggering(bank, get_gpio_index(gpio), type);
if (retval == 0) {
irq_desc[irq].status &= ~IRQ_TYPE_SENSE_MASK;
irq_desc[irq].status |= type;
}
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
return retval;
}

Expand Down Expand Up @@ -830,19 +833,21 @@ static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int ena
*/
static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
{
unsigned long flags;

switch (bank->method) {
#ifdef CONFIG_ARCH_OMAP16XX
case METHOD_MPUIO:
case METHOD_GPIO_1610:
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
if (enable) {
bank->suspend_wakeup |= (1 << gpio);
enable_irq_wake(bank->irq);
} else {
disable_irq_wake(bank->irq);
bank->suspend_wakeup &= ~(1 << gpio);
}
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
#endif
#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
Expand All @@ -853,15 +858,15 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
(bank - gpio_bank) * 32 + gpio);
return -EINVAL;
}
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
if (enable) {
bank->suspend_wakeup |= (1 << gpio);
enable_irq_wake(bank->irq);
} else {
disable_irq_wake(bank->irq);
bank->suspend_wakeup &= ~(1 << gpio);
}
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
#endif
default:
Expand Down Expand Up @@ -897,16 +902,17 @@ static int gpio_wake_enable(unsigned int irq, unsigned int enable)
int omap_request_gpio(int gpio)
{
struct gpio_bank *bank;
unsigned long flags;

if (check_gpio(gpio) < 0)
return -EINVAL;

bank = get_gpio_bank(gpio);
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
if (unlikely(bank->reserved_map & (1 << get_gpio_index(gpio)))) {
printk(KERN_ERR "omap-gpio: GPIO %d is already reserved!\n", gpio);
dump_stack();
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
return -1;
}
bank->reserved_map |= (1 << get_gpio_index(gpio));
Expand All @@ -925,23 +931,24 @@ int omap_request_gpio(int gpio)
__raw_writel(__raw_readl(reg) | (1 << get_gpio_index(gpio)), reg);
}
#endif
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);

return 0;
}

void omap_free_gpio(int gpio)
{
struct gpio_bank *bank;
unsigned long flags;

if (check_gpio(gpio) < 0)
return;
bank = get_gpio_bank(gpio);
spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
if (unlikely(!(bank->reserved_map & (1 << get_gpio_index(gpio))))) {
printk(KERN_ERR "omap-gpio: GPIO %d wasn't reserved!\n", gpio);
dump_stack();
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
return;
}
#ifdef CONFIG_ARCH_OMAP16XX
Expand All @@ -960,7 +967,7 @@ void omap_free_gpio(int gpio)
#endif
bank->reserved_map &= ~(1 << get_gpio_index(gpio));
_reset_gpio(bank, gpio);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
}

/*
Expand Down Expand Up @@ -1194,11 +1201,12 @@ static int omap_mpuio_suspend_late(struct platform_device *pdev, pm_message_t me
{
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT;
unsigned long flags;

spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
bank->saved_wakeup = __raw_readl(mask_reg);
__raw_writel(0xffff & ~bank->suspend_wakeup, mask_reg);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);

return 0;
}
Expand All @@ -1207,10 +1215,11 @@ static int omap_mpuio_resume_early(struct platform_device *pdev)
{
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT;
unsigned long flags;

spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
__raw_writel(bank->saved_wakeup, mask_reg);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);

return 0;
}
Expand Down Expand Up @@ -1495,6 +1504,7 @@ static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
void __iomem *wake_status;
void __iomem *wake_clear;
void __iomem *wake_set;
unsigned long flags;

switch (bank->method) {
#ifdef CONFIG_ARCH_OMAP16XX
Expand All @@ -1515,11 +1525,11 @@ static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
continue;
}

spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
bank->saved_wakeup = __raw_readl(wake_status);
__raw_writel(0xffffffff, wake_clear);
__raw_writel(bank->suspend_wakeup, wake_set);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
}

return 0;
Expand All @@ -1536,6 +1546,7 @@ static int omap_gpio_resume(struct sys_device *dev)
struct gpio_bank *bank = &gpio_bank[i];
void __iomem *wake_clear;
void __iomem *wake_set;
unsigned long flags;

switch (bank->method) {
#ifdef CONFIG_ARCH_OMAP16XX
Expand All @@ -1554,10 +1565,10 @@ static int omap_gpio_resume(struct sys_device *dev)
continue;
}

spin_lock(&bank->lock);
spin_lock_irqsave(&bank->lock, flags);
__raw_writel(0xffffffff, wake_clear);
__raw_writel(bank->saved_wakeup, wake_set);
spin_unlock(&bank->lock);
spin_unlock_irqrestore(&bank->lock, flags);
}

return 0;
Expand Down

0 comments on commit 93d6167

Please sign in to comment.