[PATCH] generic gpio: add default level to gpio_direction_output

Milan Svoboda <[email protected]>
Newsgroups gmane.linux.usb.devel,gmane.spam.detected
Message-ID <[email protected]>
This patch adds second parameter to gpio_direction_output function.
This allows users to specify default output level.

Patch covers pxa and ixp4xx plus driver for pxa2xx_udc.

Patch is agains 2.6.21-rc1

What do you think about this attempt?

Signed-off-by: Milan Svoboda <[email protected]>
---

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
generic-gpio-direction-out-add-level.patch (text/plain, 2.1 KB)
Index: linux-head/drivers/usb/gadget/pxa2xx_udc.c
===================================================================
--- linux-head.orig/drivers/usb/gadget/pxa2xx_udc.c
+++ linux-head/drivers/usb/gadget/pxa2xx_udc.c
@@ -2560,7 +2560,7 @@ static int __init pxa2xx_udc_probe(struc
 				gpio_free(dev->mach->gpio_vbus);
 			return -EBUSY;
 		}
-		gpio_direction_output(dev->mach->gpio_pullup);
+		gpio_direction_output(dev->mach->gpio_pullup, GPIO_DIRECTION_OUT_LOW);
 	}
 
 	init_timer(&dev->timer);
Index: linux-head/include/asm-arm/arch-ixp4xx/gpio.h
===================================================================
--- linux-head.orig/include/asm-arm/arch-ixp4xx/gpio.h
+++ linux-head/include/asm-arm/arch-ixp4xx/gpio.h
@@ -43,8 +43,12 @@ static inline int gpio_direction_input(u
 	return 0;
 }
 
-static inline int gpio_direction_output(unsigned gpio)
+static inline int gpio_direction_output(unsigned gpio, int level)
 {
+	level = (level == GPIO_DIRECTION_OUT_LOW) ?
+			IXP4XX_GPIO_LOW : IXP4XX_GPIO_HIGH;
+
+	gpio_line_set(gpio, level);
 	gpio_line_config(gpio, IXP4XX_GPIO_OUT);
 	return 0;
 }
Index: linux-head/include/asm-arm/arch-pxa/gpio.h
===================================================================
--- linux-head.orig/include/asm-arm/arch-pxa/gpio.h
+++ linux-head/include/asm-arm/arch-pxa/gpio.h
@@ -43,9 +43,11 @@ static inline int gpio_direction_input(u
 	return pxa_gpio_mode(gpio | GPIO_IN);
 }
 
-static inline int gpio_direction_output(unsigned gpio)
+static inline int gpio_direction_output(unsigned gpio, int level)
 {
-	return pxa_gpio_mode(gpio | GPIO_OUT);
+	return pxa_gpio_mode(gpio | GPIO_OUT |
+			((level == GPIO_DIRECTION_OUT_LOW) ?
+			 			GPIO_DFLT_LOW : 0));
 }
 
 static inline int __gpio_get_value(unsigned gpio)
Index: linux-head/include/asm-arm/gpio.h
===================================================================
--- linux-head.orig/include/asm-arm/gpio.h
+++ linux-head/include/asm-arm/gpio.h
@@ -1,6 +1,9 @@
 #ifndef _ARCH_ARM_GPIO_H
 #define _ARCH_ARM_GPIO_H
 
+#define GPIO_DIRECTION_OUT_LOW	0
+#define GPIO_DIRECTION_OUT_HIGH	1
+
 /* not all ARM platforms necessarily support this API ... */
 #include <asm/arch/gpio.h>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.