aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar7/files
diff options
context:
space:
mode:
authorMatteo Croce <matteo@openwrt.org>2008-01-12 16:41:28 +0000
committerMatteo Croce <matteo@openwrt.org>2008-01-12 16:41:28 +0000
commitf1b788d21c97eaaf0220fead447049b5328d4d08 (patch)
tree41c6ab1a19eb6439a7ded7d87db1ccb24b4f2c60 /target/linux/ar7/files
parenta2f8bbfe100bf59e3ccc50a059003350329ba248 (diff)
downloadupstream-f1b788d21c97eaaf0220fead447049b5328d4d08.tar.gz
upstream-f1b788d21c97eaaf0220fead447049b5328d4d08.tar.bz2
upstream-f1b788d21c97eaaf0220fead447049b5328d4d08.zip
[AR7] cache GPIO addresses to be more efficent
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@10179 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar7/files')
-rw-r--r--target/linux/ar7/files/include/asm-mips/ar7/gpio.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
index 2e19fcae9d..7d665ff62d 100644
--- a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
+++ b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
@@ -28,19 +28,28 @@ extern void gpio_free(unsigned gpio);
/* Common GPIO layer */
static inline int gpio_get_value(unsigned gpio)
{
- void __iomem *gpio_in =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
+ static unsigned addr;
- return readl(gpio_in) & (1 << gpio);
+ if (!addr) {
+ void __iomem *gpio_in = (void __iomem *)
+ KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
+ addr = readl(gpio_in);
+ }
+
+ return addr & (1 << gpio);
}
static inline void gpio_set_value(unsigned gpio, int value)
{
+ static unsigned addr;
+ unsigned tmp;
+
void __iomem *gpio_out =
(void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
- unsigned tmp;
+ if (!addr)
+ addr = readl(gpio_out);
- tmp = readl(gpio_out) & ~(1 << gpio);
+ tmp = addr & ~(1 << gpio);
if (value)
tmp |= 1 << gpio;
writel(tmp, gpio_out);