Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360058
b: refs/heads/master
c: 8838bec
h: refs/heads/master
v: v3
  • Loading branch information
Gabor Juhos authored and John Crispin committed Feb 17, 2013
1 parent 6794da2 commit 67e6187
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 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: 778eeb1b199b85bec79b49ac483b013e270636ea
refs/heads/master: 8838becdf5f7261d7f5dfbbe957fe9b9ed188aec
38 changes: 26 additions & 12 deletions trunk/arch/mips/ath79/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,47 +137,61 @@ static struct gpio_chip ath79_gpio_chip = {
.base = 0,
};

static void __iomem *ath79_gpio_get_function_reg(void)
{
u32 reg = 0;

if (soc_is_ar71xx() ||
soc_is_ar724x() ||
soc_is_ar913x() ||
soc_is_ar933x())
reg = AR71XX_GPIO_REG_FUNC;
else if (soc_is_ar934x())
reg = AR934X_GPIO_REG_FUNC;
else
BUG();

return ath79_gpio_base + reg;
}

void ath79_gpio_function_enable(u32 mask)
{
void __iomem *base = ath79_gpio_base;
void __iomem *reg = ath79_gpio_get_function_reg();
unsigned long flags;

spin_lock_irqsave(&ath79_gpio_lock, flags);

__raw_writel(__raw_readl(base + AR71XX_GPIO_REG_FUNC) | mask,
base + AR71XX_GPIO_REG_FUNC);
__raw_writel(__raw_readl(reg) | mask, reg);
/* flush write */
__raw_readl(base + AR71XX_GPIO_REG_FUNC);
__raw_readl(reg);

spin_unlock_irqrestore(&ath79_gpio_lock, flags);
}

void ath79_gpio_function_disable(u32 mask)
{
void __iomem *base = ath79_gpio_base;
void __iomem *reg = ath79_gpio_get_function_reg();
unsigned long flags;

spin_lock_irqsave(&ath79_gpio_lock, flags);

__raw_writel(__raw_readl(base + AR71XX_GPIO_REG_FUNC) & ~mask,
base + AR71XX_GPIO_REG_FUNC);
__raw_writel(__raw_readl(reg) & ~mask, reg);
/* flush write */
__raw_readl(base + AR71XX_GPIO_REG_FUNC);
__raw_readl(reg);

spin_unlock_irqrestore(&ath79_gpio_lock, flags);
}

void ath79_gpio_function_setup(u32 set, u32 clear)
{
void __iomem *base = ath79_gpio_base;
void __iomem *reg = ath79_gpio_get_function_reg();
unsigned long flags;

spin_lock_irqsave(&ath79_gpio_lock, flags);

__raw_writel((__raw_readl(base + AR71XX_GPIO_REG_FUNC) & ~clear) | set,
base + AR71XX_GPIO_REG_FUNC);
__raw_writel((__raw_readl(reg) & ~clear) | set, reg);
/* flush write */
__raw_readl(base + AR71XX_GPIO_REG_FUNC);
__raw_readl(reg);

spin_unlock_irqrestore(&ath79_gpio_lock, flags);
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@
#define AR71XX_GPIO_REG_INT_ENABLE 0x24
#define AR71XX_GPIO_REG_FUNC 0x28

#define AR934X_GPIO_REG_FUNC 0x6c

#define AR71XX_GPIO_COUNT 16
#define AR7240_GPIO_COUNT 18
#define AR7241_GPIO_COUNT 20
Expand Down

0 comments on commit 67e6187

Please sign in to comment.