cache gpio values in gpio_set

SVN-Revision: 16330
master
Florian Fainelli 16 years ago
parent 1208ffaedb
commit 9013e936ed
  1. 13
      target/linux/brcm63xx/files/arch/mips/bcm63xx/gpio.c

@ -18,12 +18,14 @@
#include <bcm63xx_io.h> #include <bcm63xx_io.h>
#include <bcm63xx_regs.h> #include <bcm63xx_regs.h>
static u32 gpio_out_low, gpio_out_high;
static void bcm63xx_gpio_set(struct gpio_chip *chip, static void bcm63xx_gpio_set(struct gpio_chip *chip,
unsigned gpio, int val) unsigned gpio, int val)
{ {
u32 reg; u32 reg;
u32 mask; u32 mask;
u32 tmp; u32 *v;
unsigned long flags; unsigned long flags;
if (gpio >= chip->ngpio) if (gpio >= chip->ngpio)
@ -32,18 +34,19 @@ static void bcm63xx_gpio_set(struct gpio_chip *chip,
if (gpio < 32) { if (gpio < 32) {
reg = GPIO_DATA_LO_REG; reg = GPIO_DATA_LO_REG;
mask = 1 << gpio; mask = 1 << gpio;
v = &gpio_out_low;
} else { } else {
reg = GPIO_DATA_HI_REG; reg = GPIO_DATA_HI_REG;
mask = 1 << (gpio - 32); mask = 1 << (gpio - 32);
v = &gpio_out_high;
} }
local_irq_save(flags); local_irq_save(flags);
tmp = bcm_gpio_readl(reg);
if (val) if (val)
tmp |= mask; *v |= mask;
else else
tmp &= ~mask; *v &= ~mask;
bcm_gpio_writel(tmp, reg); bcm_gpio_writel(*v, reg);
local_irq_restore(flags); local_irq_restore(flags);
} }

Loading…
Cancel
Save