]> Pileus Git - ~andy/linux/commitdiff
usb: phy: introduce ->set_vbus() method
authorFelipe Balbi <balbi@ti.com>
Fri, 8 Mar 2013 11:22:58 +0000 (13:22 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 18 Mar 2013 09:18:09 +0000 (11:18 +0200)
this method will be used to enable or disable
the charge pump.

Whenever we have DRD devices, we need to be
able to turn VBUS on or off whenever we want.

Note that in the ideal case, this would be
controlled by the ID-pin Interrupt, but not
all devices have ID-pin properly routed since
manufacturers can choose to save that trace
if they're building a host-only product out
of a DRD IP.

This is also useful during debugging where
we might not have the proper cable hanging
around.

Signed-off-by: Felipe Balbi <balbi@ti.com>
include/linux/usb/phy.h

index b001dc3d635403b83077d315755710ad93d07688..b7c2217c585fef708dfc39bc36fa3fd92a80bfc7 100644 (file)
@@ -91,6 +91,9 @@ struct usb_phy {
        int     (*init)(struct usb_phy *x);
        void    (*shutdown)(struct usb_phy *x);
 
+       /* enable/disable VBUS */
+       int     (*set_vbus)(struct usb_phy *x, int on);
+
        /* effective for B devices, ignored for A-peripheral */
        int     (*set_power)(struct usb_phy *x,
                                unsigned mA);
@@ -160,6 +163,24 @@ usb_phy_shutdown(struct usb_phy *x)
                x->shutdown(x);
 }
 
+static inline int
+usb_phy_vbus_on(struct usb_phy *x)
+{
+       if (!x->set_vbus)
+               return 0;
+
+       return x->set_vbus(x, true);
+}
+
+static inline int
+usb_phy_vbus_off(struct usb_phy *x)
+{
+       if (!x->set_vbus)
+               return 0;
+
+       return x->set_vbus(x, false);
+}
+
 /* for usb host and peripheral controller drivers */
 #if IS_ENABLED(CONFIG_USB_PHY)
 extern struct usb_phy *usb_get_phy(enum usb_phy_type type);