1 From 18c1a92a09faf75ebdac7ac471c741a6622cf3e2 Mon Sep 17 00:00:00 2001
2 From: Dmitry Baryshkov <dbaryshkov@gmail.com>
3 Date: Wed, 9 Jan 2008 01:27:49 +0300
4 Subject: [PATCH 13/64] USB: gadget: pxa2xx_udc supports inverted vbus
6 Some boards (like e.g. Tosa) invert the VBUS-detection signal:
7 it's low when a host is supplying VBUS, and high otherwise.
8 Allow specifying whether gpio_vbus value is inverted.
10 Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
11 Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
12 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14 drivers/usb/gadget/pxa2xx_udc.c | 9 +++++++--
15 include/asm-arm/mach/udc_pxa2xx.h | 2 ++
16 2 files changed, 9 insertions(+), 2 deletions(-)
18 diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
19 index 3173b39..4f7d4ef 100644
20 --- a/drivers/usb/gadget/pxa2xx_udc.c
21 +++ b/drivers/usb/gadget/pxa2xx_udc.c
22 @@ -127,8 +127,10 @@ static int is_vbus_present(void)
24 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
26 - if (mach->gpio_vbus)
27 - return gpio_get_value(mach->gpio_vbus);
28 + if (mach->gpio_vbus) {
29 + int value = gpio_get_value(mach->gpio_vbus);
30 + return mach->gpio_vbus_inverted ? !value : value;
32 if (mach->udc_is_connected)
33 return mach->udc_is_connected();
35 @@ -1397,6 +1399,9 @@ static irqreturn_t udc_vbus_irq(int irq, void *_dev)
36 struct pxa2xx_udc *dev = _dev;
37 int vbus = gpio_get_value(dev->mach->gpio_vbus);
39 + if (dev->mach->gpio_vbus_inverted)
42 pxa2xx_udc_vbus_session(&dev->gadget, vbus);
45 diff --git a/include/asm-arm/mach/udc_pxa2xx.h b/include/asm-arm/mach/udc_pxa2xx.h
46 index ff0a957..f191e14 100644
47 --- a/include/asm-arm/mach/udc_pxa2xx.h
48 +++ b/include/asm-arm/mach/udc_pxa2xx.h
49 @@ -19,7 +19,9 @@ struct pxa2xx_udc_mach_info {
50 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane
51 * VBUS IRQ and omit the methods above. Store the GPIO number
52 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits.
53 + * Note that sometimes the signals go through inverters...
55 + bool gpio_vbus_inverted;
56 u16 gpio_vbus; /* high == vbus present */
57 u16 gpio_pullup; /* high == pullup activated */