1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-24 02:48:26 +02:00

[AR7] cache GPIO addresses to be more efficent

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@10179 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
matteo 2008-01-12 16:41:28 +00:00
parent b45c92bdd0
commit b9a0122f2f

View File

@ -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)
{
void __iomem *gpio_out =
(void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
static unsigned addr;
unsigned tmp;
tmp = readl(gpio_out) & ~(1 << gpio);
void __iomem *gpio_out =
(void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
if (!addr)
addr = readl(gpio_out);
tmp = addr & ~(1 << gpio);
if (value)
tmp |= 1 << gpio;
writel(tmp, gpio_out);