2 +++ b/arch/mips/ath79/gpio.c
5 + * Atheros AR71XX/AR724X/AR913X GPIO API support
7 + * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
8 + * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
9 + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
11 + * Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
13 + * This program is free software; you can redistribute it and/or modify it
14 + * under the terms of the GNU General Public License version 2 as published
15 + * by the Free Software Foundation.
17 +#include <linux/kernel.h>
18 +#include <linux/module.h>
19 +#include <linux/io.h>
20 +#include <linux/gpio.h>
21 +#include <asm/mach-ath79/ar71xx_regs.h>
22 +#include <asm/mach-ath79/ath79.h>
25 +void __iomem *ath79_gpio_base;
26 +EXPORT_SYMBOL_GPL(ath79_gpio_base);
28 +static void __iomem *ath79_gpio_get_function_reg(void)
32 + if (soc_is_ar71xx() ||
36 + reg = AR71XX_GPIO_REG_FUNC;
37 + else if (soc_is_ar934x())
38 + reg = AR934X_GPIO_REG_FUNC;
42 + return ath79_gpio_base + reg;
45 +void ath79_gpio_function_setup(u32 set, u32 clear)
47 + void __iomem *reg = ath79_gpio_get_function_reg();
49 + __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
54 +void ath79_gpio_function_enable(u32 mask)
56 + ath79_gpio_function_setup(mask, 0);
59 +void ath79_gpio_function_disable(u32 mask)
61 + ath79_gpio_function_setup(0, mask);
63 --- a/arch/mips/include/asm/mach-ath79/ath79.h
64 +++ b/arch/mips/include/asm/mach-ath79/ath79.h
65 @@ -118,6 +118,7 @@ static inline int soc_is_qca955x(void)
66 void ath79_ddr_wb_flush(unsigned int reg);
67 void ath79_ddr_set_pci_windows(void);
69 +extern void __iomem *ath79_gpio_base;
70 extern void __iomem *ath79_pll_base;
71 extern void __iomem *ath79_reset_base;
73 --- a/arch/mips/ath79/dev-common.c
74 +++ b/arch/mips/ath79/dev-common.c
75 @@ -156,4 +156,5 @@ void __init ath79_gpio_init(void)
78 platform_device_register(&ath79_gpio_device);
79 + ath79_gpio_base = ioremap(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
81 --- a/arch/mips/ath79/common.h
82 +++ b/arch/mips/ath79/common.h
83 @@ -24,6 +24,9 @@ unsigned long ath79_get_sys_clk_rate(con
85 void ath79_ddr_ctrl_init(void);
87 +void ath79_gpio_function_enable(u32 mask);
88 +void ath79_gpio_function_disable(u32 mask);
89 +void ath79_gpio_function_setup(u32 set, u32 clear);
90 void ath79_gpio_init(void);
92 #endif /* __ATH79_COMMON_H */