summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorejka <ejka@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-09-21 12:37:50 +0000
committerejka <ejka@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-09-21 12:37:50 +0000
commit35a0fb9185194743f1d43c07dea98347e052a96a (patch)
treef6c8e7ecf7b2d3f53aa96fd8062af9d2774dce18 /target
parent9fb66acf6351fde2162c690b2e238f4c438febb0 (diff)
make gpio conformant to generic gpio spec.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8911 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r--target/linux/ar7/files/arch/mips/ar7/gpio.c4
-rw-r--r--target/linux/ar7/files/arch/mips/ar7/platform.c3
-rw-r--r--target/linux/ar7/files/drivers/char/ar7_gpio.c2
-rw-r--r--target/linux/ar7/files/drivers/leds/leds-ar7.c2
-rw-r--r--target/linux/ar7/files/include/asm-mips/ar7/gpio.h53
5 files changed, 32 insertions, 32 deletions
diff --git a/target/linux/ar7/files/arch/mips/ar7/gpio.c b/target/linux/ar7/files/arch/mips/ar7/gpio.c
index e18dfe873..11f300fea 100644
--- a/target/linux/ar7/files/arch/mips/ar7/gpio.c
+++ b/target/linux/ar7/files/arch/mips/ar7/gpio.c
@@ -20,9 +20,9 @@
#include <asm/ar7/gpio.h>
-static char *ar7_gpio_list[AR7_GPIO_MAX] = { 0, };
+static const char *ar7_gpio_list[AR7_GPIO_MAX] = { 0, };
-int gpio_request(unsigned gpio, char *label)
+int gpio_request(unsigned gpio, const char *label)
{
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
diff --git a/target/linux/ar7/files/arch/mips/ar7/platform.c b/target/linux/ar7/files/arch/mips/ar7/platform.c
index 1af1a87b2..980739f90 100644
--- a/target/linux/ar7/files/arch/mips/ar7/platform.c
+++ b/target/linux/ar7/files/arch/mips/ar7/platform.c
@@ -58,10 +58,9 @@ static int vlynq_on(struct vlynq_device *dev)
if ((result = ar7_gpio_enable(pdata->gpio_bit)))
goto out_enabled;
- if ((result = gpio_direction_output(pdata->gpio_bit)))
+ if ((result = gpio_direction_output(pdata->gpio_bit, 0)))
goto out_gpio_enabled;
- gpio_set_value(pdata->gpio_bit, 0);
mdelay(50);
gpio_set_value(pdata->gpio_bit, 1);
diff --git a/target/linux/ar7/files/drivers/char/ar7_gpio.c b/target/linux/ar7/files/drivers/char/ar7_gpio.c
index d3cd7d96c..aa68a5b87 100644
--- a/target/linux/ar7/files/drivers/char/ar7_gpio.c
+++ b/target/linux/ar7/files/drivers/char/ar7_gpio.c
@@ -73,7 +73,7 @@ static ssize_t ar7_gpio_write(struct file *file, const char __user *buf,
case 'o':
case 'O':
case '>':
- gpio_direction_output(pin);
+ gpio_direction_output(pin, 0);
break;
default:
return -EINVAL;
diff --git a/target/linux/ar7/files/drivers/leds/leds-ar7.c b/target/linux/ar7/files/drivers/leds/leds-ar7.c
index fb137c922..53ab53f20 100644
--- a/target/linux/ar7/files/drivers/leds/leds-ar7.c
+++ b/target/linux/ar7/files/drivers/leds/leds-ar7.c
@@ -73,7 +73,7 @@ static int ar7_leds_probe(struct platform_device *pdev)
goto out;
ar7_gpio_enable(AR7_GPIO_BIT_STATUS_LED);
- gpio_direction_output(AR7_GPIO_BIT_STATUS_LED);
+ gpio_direction_output(AR7_GPIO_BIT_STATUS_LED, 0);
out:
return rc;
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 c82ba78cf..a7ae1eeae 100644
--- a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
+++ b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h
@@ -22,24 +22,37 @@
#define AR7_GPIO_MAX 32
-extern int gpio_request(unsigned gpio, char *label);
+extern int gpio_request(unsigned gpio, const char *label);
extern void gpio_free(unsigned gpio);
/* Common GPIO layer */
-static inline int gpio_direction_input(unsigned gpio)
+static inline int gpio_get_value(unsigned gpio)
{
- void __iomem *gpio_dir =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
+ void __iomem *gpio_in =
+ (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
- writel(readl(gpio_dir) | (1 << gpio), gpio_dir);
+ return ((readl(gpio_in) & (1 << gpio)) != 0);
+}
- return 0;
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+ void __iomem *gpio_out =
+ (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
+ volatile unsigned tmp;
+
+ if (gpio >= AR7_GPIO_MAX)
+ return;
+
+ tmp = readl(gpio_out) & ~(1 << gpio);
+ if (value)
+ tmp |= 1 << gpio;
+ writel(tmp, gpio_out);
}
-static inline int gpio_direction_output(unsigned gpio)
+static inline int gpio_direction_input(unsigned gpio)
{
void __iomem *gpio_dir =
(void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
@@ -47,35 +60,23 @@ static inline int gpio_direction_output(unsigned gpio)
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
- writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir);
+ writel(readl(gpio_dir) | (1 << gpio), gpio_dir);
return 0;
}
-static inline int gpio_get_value(unsigned gpio)
+static inline int gpio_direction_output(unsigned gpio, int value)
{
- void __iomem *gpio_in =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
+ void __iomem *gpio_dir =
+ (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
if (gpio >= AR7_GPIO_MAX)
return -EINVAL;
- return ((readl(gpio_in) & (1 << gpio)) != 0);
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- void __iomem *gpio_out =
- (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
- volatile unsigned tmp;
-
- if (gpio >= AR7_GPIO_MAX)
- return;
+ gpio_set_value(gpio, value);
+ writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir);
- tmp = readl(gpio_out) & ~(1 << gpio);
- if (value)
- tmp |= 1 << gpio;
- writel(tmp, gpio_out);
+ return 0;
}
static inline int gpio_to_irq(unsigned gpio)