From 041a03c5bdb4339f3ed2bc90268747de5b20c951 Mon Sep 17 00:00:00 2001 From: Eugene Konev Date: Fri, 21 Sep 2007 12:37:50 +0000 Subject: [PATCH] make gpio conformant to generic gpio spec. SVN-Revision: 8911 --- target/linux/ar7/files/arch/mips/ar7/gpio.c | 4 +- .../linux/ar7/files/arch/mips/ar7/platform.c | 3 +- .../linux/ar7/files/drivers/char/ar7_gpio.c | 2 +- .../linux/ar7/files/drivers/leds/leds-ar7.c | 2 +- .../ar7/files/include/asm-mips/ar7/gpio.h | 55 ++++++++++--------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/target/linux/ar7/files/arch/mips/ar7/gpio.c b/target/linux/ar7/files/arch/mips/ar7/gpio.c index e18dfe873a..11f300fead 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 -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 1af1a87b2a..980739f90a 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 d3cd7d96cc..aa68a5b87b 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 fb137c9221..53ab53f208 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 c82ba78cf9..a7ae1eeae1 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h @@ -22,36 +22,10 @@ #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) -{ - void __iomem *gpio_dir = - (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); - - if (gpio >= AR7_GPIO_MAX) - return -EINVAL; - - writel(readl(gpio_dir) | (1 << gpio), gpio_dir); - - return 0; -} - -static inline int gpio_direction_output(unsigned gpio) -{ - void __iomem *gpio_dir = - (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); - - if (gpio >= AR7_GPIO_MAX) - return -EINVAL; - - writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir); - - return 0; -} - static inline int gpio_get_value(unsigned gpio) { void __iomem *gpio_in = @@ -78,6 +52,33 @@ static inline void gpio_set_value(unsigned gpio, int value) writel(tmp, gpio_out); } +static inline int gpio_direction_input(unsigned gpio) +{ + void __iomem *gpio_dir = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); + + if (gpio >= AR7_GPIO_MAX) + return -EINVAL; + + writel(readl(gpio_dir) | (1 << gpio), gpio_dir); + + return 0; +} + +static inline int gpio_direction_output(unsigned gpio, int value) +{ + void __iomem *gpio_dir = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); + + if (gpio >= AR7_GPIO_MAX) + return -EINVAL; + + gpio_set_value(gpio, value); + writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir); + + return 0; +} + static inline int gpio_to_irq(unsigned gpio) { return -EINVAL;