082a2c72b8d4f8860ffdfaf784fb020d6ee4325e
[openembedded.git] /
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
5
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.
9
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>
13 ---
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(-)
17
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)
23  {
24         struct pxa2xx_udc_mach_info             *mach = the_controller->mach;
25  
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;
31 +       }
32         if (mach->udc_is_connected)
33                 return mach->udc_is_connected();
34         return 1;
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);
38  
39 +       if (dev->mach->gpio_vbus_inverted)
40 +               vbus = !vbus;
41 +
42         pxa2xx_udc_vbus_session(&dev->gadget, vbus);
43         return IRQ_HANDLED;
44  }
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...
54          */
55 +       bool    gpio_vbus_inverted;
56         u16     gpio_vbus;                      /* high == vbus present */
57         u16     gpio_pullup;                    /* high == pullup activated */
58  };
59 -- 
60 1.5.3.8
61