Commit b27b6d03 authored by Cyril Chemparathy's avatar Cyril Chemparathy Committed by Kevin Hilman

Davinci: gpio - fine grained locking

This patch eliminates the global gpio_lock, and implements a per-controller
lock instead.  This also switches to irqsave/irqrestore locks in case gpios
are manipulated in isr.
Signed-off-by: default avatarCyril Chemparathy <cyril@ti.com>
Tested-by: default avatarSandeep Paulraj <s-paulraj@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 686b634a
...@@ -33,8 +33,6 @@ struct davinci_gpio_regs { ...@@ -33,8 +33,6 @@ struct davinci_gpio_regs {
u32 intstat; u32 intstat;
}; };
static DEFINE_SPINLOCK(gpio_lock);
#define chip2controller(chip) \ #define chip2controller(chip) \
container_of(chip, struct davinci_gpio_controller, chip) container_of(chip, struct davinci_gpio_controller, chip)
...@@ -83,10 +81,11 @@ static inline int __davinci_direction(struct gpio_chip *chip, ...@@ -83,10 +81,11 @@ static inline int __davinci_direction(struct gpio_chip *chip,
{ {
struct davinci_gpio_controller *d = chip2controller(chip); struct davinci_gpio_controller *d = chip2controller(chip);
struct davinci_gpio_regs __iomem *g = d->regs; struct davinci_gpio_regs __iomem *g = d->regs;
unsigned long flags;
u32 temp; u32 temp;
u32 mask = 1 << offset; u32 mask = 1 << offset;
spin_lock(&gpio_lock); spin_lock_irqsave(&d->lock, flags);
temp = __raw_readl(&g->dir); temp = __raw_readl(&g->dir);
if (out) { if (out) {
temp &= ~mask; temp &= ~mask;
...@@ -95,7 +94,7 @@ static inline int __davinci_direction(struct gpio_chip *chip, ...@@ -95,7 +94,7 @@ static inline int __davinci_direction(struct gpio_chip *chip,
temp |= mask; temp |= mask;
} }
__raw_writel(temp, &g->dir); __raw_writel(temp, &g->dir);
spin_unlock(&gpio_lock); spin_unlock_irqrestore(&d->lock, flags);
return 0; return 0;
} }
...@@ -175,6 +174,8 @@ static int __init davinci_gpio_setup(void) ...@@ -175,6 +174,8 @@ static int __init davinci_gpio_setup(void)
if (chips[i].chip.ngpio > 32) if (chips[i].chip.ngpio > 32)
chips[i].chip.ngpio = 32; chips[i].chip.ngpio = 32;
spin_lock_init(&chips[i].lock);
regs = gpio2regs(base); regs = gpio2regs(base);
chips[i].regs = regs; chips[i].regs = regs;
chips[i].set_data = &regs->set_data; chips[i].set_data = &regs->set_data;
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#define __DAVINCI_GPIO_H #define __DAVINCI_GPIO_H
#include <linux/io.h> #include <linux/io.h>
#include <linux/spinlock.h>
#include <asm-generic/gpio.h> #include <asm-generic/gpio.h>
#include <mach/irqs.h> #include <mach/irqs.h>
...@@ -52,6 +54,7 @@ enum davinci_gpio_type { ...@@ -52,6 +54,7 @@ enum davinci_gpio_type {
struct davinci_gpio_controller { struct davinci_gpio_controller {
struct gpio_chip chip; struct gpio_chip chip;
int irq_base; int irq_base;
spinlock_t lock;
void __iomem *regs; void __iomem *regs;
void __iomem *set_data; void __iomem *set_data;
void __iomem *clr_data; void __iomem *clr_data;
......
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