aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-11-12 10:54:09 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-11-12 10:54:09 +0000
commit856b67cb13e5bdadc8d64a086c4a6274da72dae0 (patch)
tree42288ba833de50eb7de9aa9298aae2083ea9e4df /target/linux
parent4bafa258d8963feb1032915d28c4c582aab286c9 (diff)
downloadupstream-856b67cb13e5bdadc8d64a086c4a6274da72dae0.tar.gz
upstream-856b67cb13e5bdadc8d64a086c4a6274da72dae0.tar.bz2
upstream-856b67cb13e5bdadc8d64a086c4a6274da72dae0.zip
ar71xx: fix GPIO direction setup for AR934x
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@28974 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c b/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c
index 10d80817f5..137a018156 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/gpio.c
@@ -90,6 +90,43 @@ static int ar71xx_gpio_direction_output(struct gpio_chip *chip,
return 0;
}
+static int ar934x_gpio_direction_input(struct gpio_chip *chip,
+ unsigned offset)
+{
+ void __iomem *base = ar71xx_gpio_base;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ar71xx_gpio_lock, flags);
+
+ __raw_writel(__raw_readl(base + GPIO_REG_OE) | (1 << offset),
+ base + GPIO_REG_OE);
+
+ spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
+
+ return 0;
+}
+
+static int ar934x_gpio_direction_output(struct gpio_chip *chip,
+ unsigned offset, int value)
+{
+ void __iomem *base = ar71xx_gpio_base;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ar71xx_gpio_lock, flags);
+
+ if (value)
+ __raw_writel(1 << offset, base + GPIO_REG_SET);
+ else
+ __raw_writel(1 << offset, base + GPIO_REG_CLEAR);
+
+ __raw_writel(__raw_readl(base + GPIO_REG_OE) & ~(1 << offset),
+ base + GPIO_REG_OE);
+
+ spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
+
+ return 0;
+}
+
static struct gpio_chip ar71xx_gpio_chip = {
.label = "ar71xx",
.get = ar71xx_gpio_get_value,
@@ -181,6 +218,8 @@ void __init ar71xx_gpio_init(void)
case AR71XX_SOC_AR9342:
case AR71XX_SOC_AR9344:
ar71xx_gpio_chip.ngpio = AR934X_GPIO_COUNT;
+ ar71xx_gpio_chip.direction_input = ar934x_gpio_direction_input;
+ ar71xx_gpio_chip.direction_output = ar934x_gpio_direction_output;
break;
default: