aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_gadget.c
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-03-31 15:30:04 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-16 00:44:40 -0400
commit84e250ffa76dddc1bad84e04248a27f442c25986 (patch)
treeb253b1e2b030b160d2c458aece9c8122446e433f /drivers/usb/musb/musb_gadget.c
parentcc835e321a9f3fa5e083436872e198095f4805b9 (diff)
musb: proper hookup to transceiver drivers
Let the otg_transceiver in MUSB be managed by an external driver; don't assume it's integrated. OMAP3 chips need it to be external, and there may be ways to interact with the transceiver which add functionality to the system. Platform init code is responsible for setting up the transeciver, probably using the NOP transceiver for integrated transceivers. External ones will use whatever the board init code provided, such as twl4030 or something more hands-off. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/musb/musb_gadget.c')
-rw-r--r--drivers/usb/musb/musb_gadget.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index bc197b28ac40..8dfad1189da2 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1406,7 +1406,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
1406 1406
1407 spin_lock_irqsave(&musb->lock, flags); 1407 spin_lock_irqsave(&musb->lock, flags);
1408 1408
1409 switch (musb->xceiv.state) { 1409 switch (musb->xceiv->state) {
1410 case OTG_STATE_B_PERIPHERAL: 1410 case OTG_STATE_B_PERIPHERAL:
1411 /* NOTE: OTG state machine doesn't include B_SUSPENDED; 1411 /* NOTE: OTG state machine doesn't include B_SUSPENDED;
1412 * that's part of the standard usb 1.1 state machine, and 1412 * that's part of the standard usb 1.1 state machine, and
@@ -1508,9 +1508,9 @@ static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
1508{ 1508{
1509 struct musb *musb = gadget_to_musb(gadget); 1509 struct musb *musb = gadget_to_musb(gadget);
1510 1510
1511 if (!musb->xceiv.set_power) 1511 if (!musb->xceiv->set_power)
1512 return -EOPNOTSUPP; 1512 return -EOPNOTSUPP;
1513 return otg_set_power(&musb->xceiv, mA); 1513 return otg_set_power(musb->xceiv, mA);
1514} 1514}
1515 1515
1516static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) 1516static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on)
@@ -1733,11 +1733,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1733 1733
1734 spin_lock_irqsave(&musb->lock, flags); 1734 spin_lock_irqsave(&musb->lock, flags);
1735 1735
1736 /* REVISIT always use otg_set_peripheral(), handling 1736 otg_set_peripheral(musb->xceiv, &musb->g);
1737 * issues including the root hub one below ...
1738 */
1739 musb->xceiv.gadget = &musb->g;
1740 musb->xceiv.state = OTG_STATE_B_IDLE;
1741 musb->is_active = 1; 1737 musb->is_active = 1;
1742 1738
1743 /* FIXME this ignores the softconnect flag. Drivers are 1739 /* FIXME this ignores the softconnect flag. Drivers are
@@ -1749,6 +1745,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1749 if (!is_otg_enabled(musb)) 1745 if (!is_otg_enabled(musb))
1750 musb_start(musb); 1746 musb_start(musb);
1751 1747
1748 otg_set_peripheral(musb->xceiv, &musb->g);
1749
1752 spin_unlock_irqrestore(&musb->lock, flags); 1750 spin_unlock_irqrestore(&musb->lock, flags);
1753 1751
1754 if (is_otg_enabled(musb)) { 1752 if (is_otg_enabled(musb)) {
@@ -1762,8 +1760,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1762 if (retval < 0) { 1760 if (retval < 0) {
1763 DBG(1, "add_hcd failed, %d\n", retval); 1761 DBG(1, "add_hcd failed, %d\n", retval);
1764 spin_lock_irqsave(&musb->lock, flags); 1762 spin_lock_irqsave(&musb->lock, flags);
1765 musb->xceiv.gadget = NULL; 1763 otg_set_peripheral(musb->xceiv, NULL);
1766 musb->xceiv.state = OTG_STATE_UNDEFINED;
1767 musb->gadget_driver = NULL; 1764 musb->gadget_driver = NULL;
1768 musb->g.dev.driver = NULL; 1765 musb->g.dev.driver = NULL;
1769 spin_unlock_irqrestore(&musb->lock, flags); 1766 spin_unlock_irqrestore(&musb->lock, flags);
@@ -1846,8 +1843,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1846 1843
1847 (void) musb_gadget_vbus_draw(&musb->g, 0); 1844 (void) musb_gadget_vbus_draw(&musb->g, 0);
1848 1845
1849 musb->xceiv.state = OTG_STATE_UNDEFINED; 1846 musb->xceiv->state = OTG_STATE_UNDEFINED;
1850 stop_activity(musb, driver); 1847 stop_activity(musb, driver);
1848 otg_set_peripheral(musb->xceiv, NULL);
1851 1849
1852 DBG(3, "unregistering driver %s\n", driver->function); 1850 DBG(3, "unregistering driver %s\n", driver->function);
1853 spin_unlock_irqrestore(&musb->lock, flags); 1851 spin_unlock_irqrestore(&musb->lock, flags);
@@ -1883,7 +1881,7 @@ EXPORT_SYMBOL(usb_gadget_unregister_driver);
1883void musb_g_resume(struct musb *musb) 1881void musb_g_resume(struct musb *musb)
1884{ 1882{
1885 musb->is_suspended = 0; 1883 musb->is_suspended = 0;
1886 switch (musb->xceiv.state) { 1884 switch (musb->xceiv->state) {
1887 case OTG_STATE_B_IDLE: 1885 case OTG_STATE_B_IDLE:
1888 break; 1886 break;
1889 case OTG_STATE_B_WAIT_ACON: 1887 case OTG_STATE_B_WAIT_ACON:
@@ -1909,10 +1907,10 @@ void musb_g_suspend(struct musb *musb)
1909 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 1907 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
1910 DBG(3, "devctl %02x\n", devctl); 1908 DBG(3, "devctl %02x\n", devctl);
1911 1909
1912 switch (musb->xceiv.state) { 1910 switch (musb->xceiv->state) {
1913 case OTG_STATE_B_IDLE: 1911 case OTG_STATE_B_IDLE:
1914 if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) 1912 if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
1915 musb->xceiv.state = OTG_STATE_B_PERIPHERAL; 1913 musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
1916 break; 1914 break;
1917 case OTG_STATE_B_PERIPHERAL: 1915 case OTG_STATE_B_PERIPHERAL:
1918 musb->is_suspended = 1; 1916 musb->is_suspended = 1;
@@ -1958,22 +1956,22 @@ void musb_g_disconnect(struct musb *musb)
1958 spin_lock(&musb->lock); 1956 spin_lock(&musb->lock);
1959 } 1957 }
1960 1958
1961 switch (musb->xceiv.state) { 1959 switch (musb->xceiv->state) {
1962 default: 1960 default:
1963#ifdef CONFIG_USB_MUSB_OTG 1961#ifdef CONFIG_USB_MUSB_OTG
1964 DBG(2, "Unhandled disconnect %s, setting a_idle\n", 1962 DBG(2, "Unhandled disconnect %s, setting a_idle\n",
1965 otg_state_string(musb)); 1963 otg_state_string(musb));
1966 musb->xceiv.state = OTG_STATE_A_IDLE; 1964 musb->xceiv->state = OTG_STATE_A_IDLE;
1967 break; 1965 break;
1968 case OTG_STATE_A_PERIPHERAL: 1966 case OTG_STATE_A_PERIPHERAL:
1969 musb->xceiv.state = OTG_STATE_A_WAIT_VFALL; 1967 musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
1970 break; 1968 break;
1971 case OTG_STATE_B_WAIT_ACON: 1969 case OTG_STATE_B_WAIT_ACON:
1972 case OTG_STATE_B_HOST: 1970 case OTG_STATE_B_HOST:
1973#endif 1971#endif
1974 case OTG_STATE_B_PERIPHERAL: 1972 case OTG_STATE_B_PERIPHERAL:
1975 case OTG_STATE_B_IDLE: 1973 case OTG_STATE_B_IDLE:
1976 musb->xceiv.state = OTG_STATE_B_IDLE; 1974 musb->xceiv->state = OTG_STATE_B_IDLE;
1977 break; 1975 break;
1978 case OTG_STATE_B_SRP_INIT: 1976 case OTG_STATE_B_SRP_INIT:
1979 break; 1977 break;
@@ -2029,10 +2027,10 @@ __acquires(musb->lock)
2029 * or else after HNP, as A-Device 2027 * or else after HNP, as A-Device
2030 */ 2028 */
2031 if (devctl & MUSB_DEVCTL_BDEVICE) { 2029 if (devctl & MUSB_DEVCTL_BDEVICE) {
2032 musb->xceiv.state = OTG_STATE_B_PERIPHERAL; 2030 musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
2033 musb->g.is_a_peripheral = 0; 2031 musb->g.is_a_peripheral = 0;
2034 } else if (is_otg_enabled(musb)) { 2032 } else if (is_otg_enabled(musb)) {
2035 musb->xceiv.state = OTG_STATE_A_PERIPHERAL; 2033 musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
2036 musb->g.is_a_peripheral = 1; 2034 musb->g.is_a_peripheral = 1;
2037 } else 2035 } else
2038 WARN_ON(1); 2036 WARN_ON(1);