Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309055
b: refs/heads/master
c: 5b5b544
h: refs/heads/master
i:
  309053: f14fe10
  309051: ac4080f
  309047: 4f00e2b
  309039: 73820ba
  309023: 9d58db2
  308991: 0cc79fc
v: v3
  • Loading branch information
Gabor Juhos authored and Ralf Baechle committed May 15, 2012
1 parent 2ff31e4 commit c92930b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 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: 8889612b3e2054617219581ae10dbe33cf3bddfe
refs/heads/master: 5b5b544ed32a1b6ad4d7706fcee530eb67670e71
47 changes: 46 additions & 1 deletion trunk/arch/mips/ath79/gpio.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/*
* Atheros AR71XX/AR724X/AR913X GPIO API support
*
* Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
* Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
*
* Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
Expand Down Expand Up @@ -89,6 +92,42 @@ static int ath79_gpio_direction_output(struct gpio_chip *chip,
return 0;
}

static int ar934x_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
{
void __iomem *base = ath79_gpio_base;
unsigned long flags;

spin_lock_irqsave(&ath79_gpio_lock, flags);

__raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) | (1 << offset),
base + AR71XX_GPIO_REG_OE);

spin_unlock_irqrestore(&ath79_gpio_lock, flags);

return 0;
}

static int ar934x_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
int value)
{
void __iomem *base = ath79_gpio_base;
unsigned long flags;

spin_lock_irqsave(&ath79_gpio_lock, flags);

if (value)
__raw_writel(1 << offset, base + AR71XX_GPIO_REG_SET);
else
__raw_writel(1 << offset, base + AR71XX_GPIO_REG_CLEAR);

__raw_writel(__raw_readl(base + AR71XX_GPIO_REG_OE) & ~(1 << offset),
base + AR71XX_GPIO_REG_OE);

spin_unlock_irqrestore(&ath79_gpio_lock, flags);

return 0;
}

static struct gpio_chip ath79_gpio_chip = {
.label = "ath79",
.get = ath79_gpio_get_value,
Expand Down Expand Up @@ -155,11 +194,17 @@ void __init ath79_gpio_init(void)
ath79_gpio_count = AR913X_GPIO_COUNT;
else if (soc_is_ar933x())
ath79_gpio_count = AR933X_GPIO_COUNT;
else if (soc_is_ar934x())
ath79_gpio_count = AR934X_GPIO_COUNT;
else
BUG();

ath79_gpio_base = ioremap_nocache(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
ath79_gpio_chip.ngpio = ath79_gpio_count;
if (soc_is_ar934x()) {
ath79_gpio_chip.direction_input = ar934x_gpio_direction_input;
ath79_gpio_chip.direction_output = ar934x_gpio_direction_output;
}

err = gpiochip_add(&ath79_gpio_chip);
if (err)
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,5 +367,6 @@
#define AR724X_GPIO_COUNT 18
#define AR913X_GPIO_COUNT 22
#define AR933X_GPIO_COUNT 30
#define AR934X_GPIO_COUNT 23

#endif /* __ASM_MACH_AR71XX_REGS_H */

0 comments on commit c92930b

Please sign in to comment.