diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-24 17:57:49 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-24 17:57:49 -0400 |
commit | 1c41a9570a02cec80be5fb4f7f9cf206220d84a5 (patch) | |
tree | 21eeee43b0cb88415ea809bfab3f2b432fd5ac45 /drivers/usb/musb | |
parent | cd0e075784f4bce97b4ed47d4b354f045e895546 (diff) | |
parent | 3e457371f436e89ce9239674828f9729a36b2595 (diff) |
Merge tag 'usb-for-v4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next
Felipe writes:
usb: patches for v4.1 merge window
As usual, a big pile of commits. This time a total
of 111 non-merge commits.
Other than the usual set of cleanups and non-critical
fixes, we have some interesting work for AM335x's MUSB
babble recovery. Now that takes a lot less time and we
don't have to Reset MUSB all the time.
The printer gadget has been converted to configfs interface
and the atmel udc has learned suspend/resume with wakeup.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r-- | drivers/usb/musb/musb_core.c | 214 | ||||
-rw-r--r-- | drivers/usb/musb/musb_core.h | 14 | ||||
-rw-r--r-- | drivers/usb/musb/musb_cppi41.c | 84 | ||||
-rw-r--r-- | drivers/usb/musb/musb_dsps.c | 105 | ||||
-rw-r--r-- | drivers/usb/musb/musb_gadget.c | 40 |
5 files changed, 201 insertions, 256 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 067920f2d570..a48b5a9c6c47 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -507,7 +507,8 @@ void musb_hnp_stop(struct musb *musb) | |||
507 | musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16); | 507 | musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16); |
508 | } | 508 | } |
509 | 509 | ||
510 | static void musb_generic_disable(struct musb *musb); | 510 | static void musb_recover_from_babble(struct musb *musb); |
511 | |||
511 | /* | 512 | /* |
512 | * Interrupt Service Routine to record USB "global" interrupts. | 513 | * Interrupt Service Routine to record USB "global" interrupts. |
513 | * Since these do not happen often and signify things of | 514 | * Since these do not happen often and signify things of |
@@ -534,30 +535,16 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
534 | */ | 535 | */ |
535 | if (int_usb & MUSB_INTR_RESUME) { | 536 | if (int_usb & MUSB_INTR_RESUME) { |
536 | handled = IRQ_HANDLED; | 537 | handled = IRQ_HANDLED; |
537 | dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state)); | 538 | dev_dbg(musb->controller, "RESUME (%s)\n", |
539 | usb_otg_state_string(musb->xceiv->otg->state)); | ||
538 | 540 | ||
539 | if (devctl & MUSB_DEVCTL_HM) { | 541 | if (devctl & MUSB_DEVCTL_HM) { |
540 | void __iomem *mbase = musb->mregs; | ||
541 | u8 power; | ||
542 | |||
543 | switch (musb->xceiv->otg->state) { | 542 | switch (musb->xceiv->otg->state) { |
544 | case OTG_STATE_A_SUSPEND: | 543 | case OTG_STATE_A_SUSPEND: |
545 | /* remote wakeup? later, GetPortStatus | 544 | /* remote wakeup? later, GetPortStatus |
546 | * will stop RESUME signaling | 545 | * will stop RESUME signaling |
547 | */ | 546 | */ |
548 | 547 | ||
549 | power = musb_readb(musb->mregs, MUSB_POWER); | ||
550 | if (power & MUSB_POWER_SUSPENDM) { | ||
551 | /* spurious */ | ||
552 | musb->int_usb &= ~MUSB_INTR_SUSPEND; | ||
553 | dev_dbg(musb->controller, "Spurious SUSPENDM\n"); | ||
554 | break; | ||
555 | } | ||
556 | |||
557 | power &= ~MUSB_POWER_SUSPENDM; | ||
558 | musb_writeb(mbase, MUSB_POWER, | ||
559 | power | MUSB_POWER_RESUME); | ||
560 | |||
561 | musb->port1_status |= | 548 | musb->port1_status |= |
562 | (USB_PORT_STAT_C_SUSPEND << 16) | 549 | (USB_PORT_STAT_C_SUSPEND << 16) |
563 | | MUSB_PORT_STAT_RESUME; | 550 | | MUSB_PORT_STAT_RESUME; |
@@ -775,10 +762,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
775 | 762 | ||
776 | musb->ep0_stage = MUSB_EP0_START; | 763 | musb->ep0_stage = MUSB_EP0_START; |
777 | 764 | ||
778 | /* flush endpoints when transitioning from Device Mode */ | ||
779 | if (is_peripheral_active(musb)) { | ||
780 | /* REVISIT HNP; just force disconnect */ | ||
781 | } | ||
782 | musb->intrtxe = musb->epmask; | 765 | musb->intrtxe = musb->epmask; |
783 | musb_writew(musb->mregs, MUSB_INTRTXE, musb->intrtxe); | 766 | musb_writew(musb->mregs, MUSB_INTRTXE, musb->intrtxe); |
784 | musb->intrrxe = musb->epmask & 0xfffe; | 767 | musb->intrrxe = musb->epmask & 0xfffe; |
@@ -879,20 +862,19 @@ b_host: | |||
879 | */ | 862 | */ |
880 | if (int_usb & MUSB_INTR_RESET) { | 863 | if (int_usb & MUSB_INTR_RESET) { |
881 | handled = IRQ_HANDLED; | 864 | handled = IRQ_HANDLED; |
882 | if ((devctl & MUSB_DEVCTL_HM) != 0) { | 865 | if (devctl & MUSB_DEVCTL_HM) { |
883 | /* | 866 | /* |
884 | * Looks like non-HS BABBLE can be ignored, but | 867 | * When BABBLE happens what we can depends on which |
885 | * HS BABBLE is an error condition. For HS the solution | 868 | * platform MUSB is running, because some platforms |
886 | * is to avoid babble in the first place and fix what | 869 | * implemented proprietary means for 'recovering' from |
887 | * caused BABBLE. When HS BABBLE happens we can only | 870 | * Babble conditions. One such platform is AM335x. In |
888 | * stop the session. | 871 | * most cases, however, the only thing we can do is |
872 | * drop the session. | ||
889 | */ | 873 | */ |
890 | if (devctl & (MUSB_DEVCTL_FSDEV | MUSB_DEVCTL_LSDEV)) | 874 | dev_err(musb->controller, "Babble\n"); |
891 | dev_dbg(musb->controller, "BABBLE devctl: %02x\n", devctl); | 875 | |
892 | else { | 876 | if (is_host_active(musb)) |
893 | ERR("Stopping host session -- babble\n"); | 877 | musb_recover_from_babble(musb); |
894 | musb_writeb(musb->mregs, MUSB_DEVCTL, 0); | ||
895 | } | ||
896 | } else { | 878 | } else { |
897 | dev_dbg(musb->controller, "BUS RESET as %s\n", | 879 | dev_dbg(musb->controller, "BUS RESET as %s\n", |
898 | usb_otg_state_string(musb->xceiv->otg->state)); | 880 | usb_otg_state_string(musb->xceiv->otg->state)); |
@@ -931,13 +913,6 @@ b_host: | |||
931 | } | 913 | } |
932 | } | 914 | } |
933 | 915 | ||
934 | /* handle babble condition */ | ||
935 | if (int_usb & MUSB_INTR_BABBLE && is_host_active(musb)) { | ||
936 | musb_generic_disable(musb); | ||
937 | schedule_delayed_work(&musb->recover_work, | ||
938 | msecs_to_jiffies(100)); | ||
939 | } | ||
940 | |||
941 | #if 0 | 916 | #if 0 |
942 | /* REVISIT ... this would be for multiplexing periodic endpoints, or | 917 | /* REVISIT ... this would be for multiplexing periodic endpoints, or |
943 | * supporting transfer phasing to prevent exceeding ISO bandwidth | 918 | * supporting transfer phasing to prevent exceeding ISO bandwidth |
@@ -990,7 +965,7 @@ b_host: | |||
990 | 965 | ||
991 | /*-------------------------------------------------------------------------*/ | 966 | /*-------------------------------------------------------------------------*/ |
992 | 967 | ||
993 | static void musb_generic_disable(struct musb *musb) | 968 | static void musb_disable_interrupts(struct musb *musb) |
994 | { | 969 | { |
995 | void __iomem *mbase = musb->mregs; | 970 | void __iomem *mbase = musb->mregs; |
996 | u16 temp; | 971 | u16 temp; |
@@ -1002,14 +977,33 @@ static void musb_generic_disable(struct musb *musb) | |||
1002 | musb->intrrxe = 0; | 977 | musb->intrrxe = 0; |
1003 | musb_writew(mbase, MUSB_INTRRXE, 0); | 978 | musb_writew(mbase, MUSB_INTRRXE, 0); |
1004 | 979 | ||
1005 | /* off */ | ||
1006 | musb_writeb(mbase, MUSB_DEVCTL, 0); | ||
1007 | |||
1008 | /* flush pending interrupts */ | 980 | /* flush pending interrupts */ |
1009 | temp = musb_readb(mbase, MUSB_INTRUSB); | 981 | temp = musb_readb(mbase, MUSB_INTRUSB); |
1010 | temp = musb_readw(mbase, MUSB_INTRTX); | 982 | temp = musb_readw(mbase, MUSB_INTRTX); |
1011 | temp = musb_readw(mbase, MUSB_INTRRX); | 983 | temp = musb_readw(mbase, MUSB_INTRRX); |
984 | } | ||
985 | |||
986 | static void musb_enable_interrupts(struct musb *musb) | ||
987 | { | ||
988 | void __iomem *regs = musb->mregs; | ||
989 | |||
990 | /* Set INT enable registers, enable interrupts */ | ||
991 | musb->intrtxe = musb->epmask; | ||
992 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); | ||
993 | musb->intrrxe = musb->epmask & 0xfffe; | ||
994 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
995 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | ||
996 | |||
997 | } | ||
998 | |||
999 | static void musb_generic_disable(struct musb *musb) | ||
1000 | { | ||
1001 | void __iomem *mbase = musb->mregs; | ||
1012 | 1002 | ||
1003 | musb_disable_interrupts(musb); | ||
1004 | |||
1005 | /* off */ | ||
1006 | musb_writeb(mbase, MUSB_DEVCTL, 0); | ||
1013 | } | 1007 | } |
1014 | 1008 | ||
1015 | /* | 1009 | /* |
@@ -1022,13 +1016,7 @@ void musb_start(struct musb *musb) | |||
1022 | 1016 | ||
1023 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); | 1017 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); |
1024 | 1018 | ||
1025 | /* Set INT enable registers, enable interrupts */ | 1019 | musb_enable_interrupts(musb); |
1026 | musb->intrtxe = musb->epmask; | ||
1027 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); | ||
1028 | musb->intrrxe = musb->epmask & 0xfffe; | ||
1029 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
1030 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | ||
1031 | |||
1032 | musb_writeb(regs, MUSB_TESTMODE, 0); | 1020 | musb_writeb(regs, MUSB_TESTMODE, 0); |
1033 | 1021 | ||
1034 | /* put into basic highspeed mode and start session */ | 1022 | /* put into basic highspeed mode and start session */ |
@@ -1587,9 +1575,12 @@ static int musb_core_init(u16 musb_type, struct musb *musb) | |||
1587 | irqreturn_t musb_interrupt(struct musb *musb) | 1575 | irqreturn_t musb_interrupt(struct musb *musb) |
1588 | { | 1576 | { |
1589 | irqreturn_t retval = IRQ_NONE; | 1577 | irqreturn_t retval = IRQ_NONE; |
1578 | unsigned long status; | ||
1579 | unsigned long epnum; | ||
1590 | u8 devctl; | 1580 | u8 devctl; |
1591 | int ep_num; | 1581 | |
1592 | u32 reg; | 1582 | if (!musb->int_usb && !musb->int_tx && !musb->int_rx) |
1583 | return IRQ_NONE; | ||
1593 | 1584 | ||
1594 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 1585 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
1595 | 1586 | ||
@@ -1597,56 +1588,57 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
1597 | is_host_active(musb) ? "host" : "peripheral", | 1588 | is_host_active(musb) ? "host" : "peripheral", |
1598 | musb->int_usb, musb->int_tx, musb->int_rx); | 1589 | musb->int_usb, musb->int_tx, musb->int_rx); |
1599 | 1590 | ||
1600 | /* the core can interrupt us for multiple reasons; docs have | 1591 | /** |
1601 | * a generic interrupt flowchart to follow | 1592 | * According to Mentor Graphics' documentation, flowchart on page 98, |
1593 | * IRQ should be handled as follows: | ||
1594 | * | ||
1595 | * . Resume IRQ | ||
1596 | * . Session Request IRQ | ||
1597 | * . VBUS Error IRQ | ||
1598 | * . Suspend IRQ | ||
1599 | * . Connect IRQ | ||
1600 | * . Disconnect IRQ | ||
1601 | * . Reset/Babble IRQ | ||
1602 | * . SOF IRQ (we're not using this one) | ||
1603 | * . Endpoint 0 IRQ | ||
1604 | * . TX Endpoints | ||
1605 | * . RX Endpoints | ||
1606 | * | ||
1607 | * We will be following that flowchart in order to avoid any problems | ||
1608 | * that might arise with internal Finite State Machine. | ||
1602 | */ | 1609 | */ |
1603 | if (musb->int_usb) | ||
1604 | retval |= musb_stage0_irq(musb, musb->int_usb, | ||
1605 | devctl); | ||
1606 | 1610 | ||
1607 | /* "stage 1" is handling endpoint irqs */ | 1611 | if (musb->int_usb) |
1612 | retval |= musb_stage0_irq(musb, musb->int_usb, devctl); | ||
1608 | 1613 | ||
1609 | /* handle endpoint 0 first */ | ||
1610 | if (musb->int_tx & 1) { | 1614 | if (musb->int_tx & 1) { |
1611 | if (is_host_active(musb)) | 1615 | if (is_host_active(musb)) |
1612 | retval |= musb_h_ep0_irq(musb); | 1616 | retval |= musb_h_ep0_irq(musb); |
1613 | else | 1617 | else |
1614 | retval |= musb_g_ep0_irq(musb); | 1618 | retval |= musb_g_ep0_irq(musb); |
1619 | |||
1620 | /* we have just handled endpoint 0 IRQ, clear it */ | ||
1621 | musb->int_tx &= ~BIT(0); | ||
1615 | } | 1622 | } |
1616 | 1623 | ||
1617 | /* RX on endpoints 1-15 */ | 1624 | status = musb->int_tx; |
1618 | reg = musb->int_rx >> 1; | ||
1619 | ep_num = 1; | ||
1620 | while (reg) { | ||
1621 | if (reg & 1) { | ||
1622 | /* musb_ep_select(musb->mregs, ep_num); */ | ||
1623 | /* REVISIT just retval = ep->rx_irq(...) */ | ||
1624 | retval = IRQ_HANDLED; | ||
1625 | if (is_host_active(musb)) | ||
1626 | musb_host_rx(musb, ep_num); | ||
1627 | else | ||
1628 | musb_g_rx(musb, ep_num); | ||
1629 | } | ||
1630 | 1625 | ||
1631 | reg >>= 1; | 1626 | for_each_set_bit(epnum, &status, 16) { |
1632 | ep_num++; | 1627 | retval = IRQ_HANDLED; |
1628 | if (is_host_active(musb)) | ||
1629 | musb_host_tx(musb, epnum); | ||
1630 | else | ||
1631 | musb_g_tx(musb, epnum); | ||
1633 | } | 1632 | } |
1634 | 1633 | ||
1635 | /* TX on endpoints 1-15 */ | 1634 | status = musb->int_rx; |
1636 | reg = musb->int_tx >> 1; | 1635 | |
1637 | ep_num = 1; | 1636 | for_each_set_bit(epnum, &status, 16) { |
1638 | while (reg) { | 1637 | retval = IRQ_HANDLED; |
1639 | if (reg & 1) { | 1638 | if (is_host_active(musb)) |
1640 | /* musb_ep_select(musb->mregs, ep_num); */ | 1639 | musb_host_rx(musb, epnum); |
1641 | /* REVISIT just retval |= ep->tx_irq(...) */ | 1640 | else |
1642 | retval = IRQ_HANDLED; | 1641 | musb_g_rx(musb, epnum); |
1643 | if (is_host_active(musb)) | ||
1644 | musb_host_tx(musb, ep_num); | ||
1645 | else | ||
1646 | musb_g_tx(musb, ep_num); | ||
1647 | } | ||
1648 | reg >>= 1; | ||
1649 | ep_num++; | ||
1650 | } | 1642 | } |
1651 | 1643 | ||
1652 | return retval; | 1644 | return retval; |
@@ -1825,33 +1817,44 @@ static void musb_irq_work(struct work_struct *data) | |||
1825 | } | 1817 | } |
1826 | } | 1818 | } |
1827 | 1819 | ||
1828 | /* Recover from babble interrupt conditions */ | 1820 | static void musb_recover_from_babble(struct musb *musb) |
1829 | static void musb_recover_work(struct work_struct *data) | ||
1830 | { | 1821 | { |
1831 | struct musb *musb = container_of(data, struct musb, recover_work.work); | 1822 | int ret; |
1832 | int status, ret; | 1823 | u8 devctl; |
1833 | 1824 | ||
1834 | ret = musb_platform_reset(musb); | 1825 | musb_disable_interrupts(musb); |
1835 | if (ret) | 1826 | |
1827 | /* | ||
1828 | * wait at least 320 cycles of 60MHz clock. That's 5.3us, we will give | ||
1829 | * it some slack and wait for 10us. | ||
1830 | */ | ||
1831 | udelay(10); | ||
1832 | |||
1833 | ret = musb_platform_recover(musb); | ||
1834 | if (ret) { | ||
1835 | musb_enable_interrupts(musb); | ||
1836 | return; | 1836 | return; |
1837 | } | ||
1837 | 1838 | ||
1838 | usb_phy_vbus_off(musb->xceiv); | 1839 | /* drop session bit */ |
1839 | usleep_range(100, 200); | 1840 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
1841 | devctl &= ~MUSB_DEVCTL_SESSION; | ||
1842 | musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); | ||
1840 | 1843 | ||
1841 | usb_phy_vbus_on(musb->xceiv); | 1844 | /* tell usbcore about it */ |
1842 | usleep_range(100, 200); | 1845 | musb_root_disconnect(musb); |
1843 | 1846 | ||
1844 | /* | 1847 | /* |
1845 | * When a babble condition occurs, the musb controller | 1848 | * When a babble condition occurs, the musb controller |
1846 | * removes the session bit and the endpoint config is lost. | 1849 | * removes the session bit and the endpoint config is lost. |
1847 | */ | 1850 | */ |
1848 | if (musb->dyn_fifo) | 1851 | if (musb->dyn_fifo) |
1849 | status = ep_config_from_table(musb); | 1852 | ret = ep_config_from_table(musb); |
1850 | else | 1853 | else |
1851 | status = ep_config_from_hw(musb); | 1854 | ret = ep_config_from_hw(musb); |
1852 | 1855 | ||
1853 | /* start the session again */ | 1856 | /* restart session */ |
1854 | if (status == 0) | 1857 | if (ret == 0) |
1855 | musb_start(musb); | 1858 | musb_start(musb); |
1856 | } | 1859 | } |
1857 | 1860 | ||
@@ -2087,7 +2090,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
2087 | 2090 | ||
2088 | /* Init IRQ workqueue before request_irq */ | 2091 | /* Init IRQ workqueue before request_irq */ |
2089 | INIT_WORK(&musb->irq_work, musb_irq_work); | 2092 | INIT_WORK(&musb->irq_work, musb_irq_work); |
2090 | INIT_DELAYED_WORK(&musb->recover_work, musb_recover_work); | ||
2091 | INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset); | 2093 | INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset); |
2092 | INIT_DELAYED_WORK(&musb->finish_resume_work, musb_host_finish_resume); | 2094 | INIT_DELAYED_WORK(&musb->finish_resume_work, musb_host_finish_resume); |
2093 | 2095 | ||
@@ -2183,7 +2185,6 @@ fail4: | |||
2183 | 2185 | ||
2184 | fail3: | 2186 | fail3: |
2185 | cancel_work_sync(&musb->irq_work); | 2187 | cancel_work_sync(&musb->irq_work); |
2186 | cancel_delayed_work_sync(&musb->recover_work); | ||
2187 | cancel_delayed_work_sync(&musb->finish_resume_work); | 2188 | cancel_delayed_work_sync(&musb->finish_resume_work); |
2188 | cancel_delayed_work_sync(&musb->deassert_reset_work); | 2189 | cancel_delayed_work_sync(&musb->deassert_reset_work); |
2189 | if (musb->dma_controller) | 2190 | if (musb->dma_controller) |
@@ -2249,7 +2250,6 @@ static int musb_remove(struct platform_device *pdev) | |||
2249 | dma_controller_destroy(musb->dma_controller); | 2250 | dma_controller_destroy(musb->dma_controller); |
2250 | 2251 | ||
2251 | cancel_work_sync(&musb->irq_work); | 2252 | cancel_work_sync(&musb->irq_work); |
2252 | cancel_delayed_work_sync(&musb->recover_work); | ||
2253 | cancel_delayed_work_sync(&musb->finish_resume_work); | 2253 | cancel_delayed_work_sync(&musb->finish_resume_work); |
2254 | cancel_delayed_work_sync(&musb->deassert_reset_work); | 2254 | cancel_delayed_work_sync(&musb->deassert_reset_work); |
2255 | musb_free(musb); | 2255 | musb_free(musb); |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 5e65958f7915..3877249a8b2d 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -160,7 +160,8 @@ struct musb_io; | |||
160 | * @init: turns on clocks, sets up platform-specific registers, etc | 160 | * @init: turns on clocks, sets up platform-specific registers, etc |
161 | * @exit: undoes @init | 161 | * @exit: undoes @init |
162 | * @set_mode: forcefully changes operating mode | 162 | * @set_mode: forcefully changes operating mode |
163 | * @try_ilde: tries to idle the IP | 163 | * @try_idle: tries to idle the IP |
164 | * @recover: platform-specific babble recovery | ||
164 | * @vbus_status: returns vbus status if possible | 165 | * @vbus_status: returns vbus status if possible |
165 | * @set_vbus: forces vbus status | 166 | * @set_vbus: forces vbus status |
166 | * @adjust_channel_params: pre check for standard dma channel_program func | 167 | * @adjust_channel_params: pre check for standard dma channel_program func |
@@ -196,7 +197,7 @@ struct musb_platform_ops { | |||
196 | void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf); | 197 | void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf); |
197 | int (*set_mode)(struct musb *musb, u8 mode); | 198 | int (*set_mode)(struct musb *musb, u8 mode); |
198 | void (*try_idle)(struct musb *musb, unsigned long timeout); | 199 | void (*try_idle)(struct musb *musb, unsigned long timeout); |
199 | int (*reset)(struct musb *musb); | 200 | int (*recover)(struct musb *musb); |
200 | 201 | ||
201 | int (*vbus_status)(struct musb *musb); | 202 | int (*vbus_status)(struct musb *musb); |
202 | void (*set_vbus)(struct musb *musb, int on); | 203 | void (*set_vbus)(struct musb *musb, int on); |
@@ -300,7 +301,6 @@ struct musb { | |||
300 | 301 | ||
301 | irqreturn_t (*isr)(int, void *); | 302 | irqreturn_t (*isr)(int, void *); |
302 | struct work_struct irq_work; | 303 | struct work_struct irq_work; |
303 | struct delayed_work recover_work; | ||
304 | struct delayed_work deassert_reset_work; | 304 | struct delayed_work deassert_reset_work; |
305 | struct delayed_work finish_resume_work; | 305 | struct delayed_work finish_resume_work; |
306 | u16 hwvers; | 306 | u16 hwvers; |
@@ -558,12 +558,12 @@ static inline void musb_platform_try_idle(struct musb *musb, | |||
558 | musb->ops->try_idle(musb, timeout); | 558 | musb->ops->try_idle(musb, timeout); |
559 | } | 559 | } |
560 | 560 | ||
561 | static inline int musb_platform_reset(struct musb *musb) | 561 | static inline int musb_platform_recover(struct musb *musb) |
562 | { | 562 | { |
563 | if (!musb->ops->reset) | 563 | if (!musb->ops->recover) |
564 | return -EINVAL; | 564 | return 0; |
565 | 565 | ||
566 | return musb->ops->reset(musb); | 566 | return musb->ops->recover(musb); |
567 | } | 567 | } |
568 | 568 | ||
569 | static inline int musb_platform_get_vbus_status(struct musb *musb) | 569 | static inline int musb_platform_get_vbus_status(struct musb *musb) |
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index be84562d021b..8bd8c5e26921 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c | |||
@@ -225,10 +225,12 @@ static void cppi41_dma_callback(void *private_data) | |||
225 | struct dma_channel *channel = private_data; | 225 | struct dma_channel *channel = private_data; |
226 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; | 226 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; |
227 | struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep; | 227 | struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep; |
228 | struct cppi41_dma_controller *controller; | ||
228 | struct musb *musb = hw_ep->musb; | 229 | struct musb *musb = hw_ep->musb; |
229 | unsigned long flags; | 230 | unsigned long flags; |
230 | struct dma_tx_state txstate; | 231 | struct dma_tx_state txstate; |
231 | u32 transferred; | 232 | u32 transferred; |
233 | int is_hs = 0; | ||
232 | bool empty; | 234 | bool empty; |
233 | 235 | ||
234 | spin_lock_irqsave(&musb->lock, flags); | 236 | spin_lock_irqsave(&musb->lock, flags); |
@@ -248,61 +250,59 @@ static void cppi41_dma_callback(void *private_data) | |||
248 | transferred < cppi41_channel->packet_sz) | 250 | transferred < cppi41_channel->packet_sz) |
249 | cppi41_channel->prog_len = 0; | 251 | cppi41_channel->prog_len = 0; |
250 | 252 | ||
251 | empty = musb_is_tx_fifo_empty(hw_ep); | 253 | if (cppi41_channel->is_tx) |
252 | if (empty) { | 254 | empty = musb_is_tx_fifo_empty(hw_ep); |
255 | |||
256 | if (!cppi41_channel->is_tx || empty) { | ||
253 | cppi41_trans_done(cppi41_channel); | 257 | cppi41_trans_done(cppi41_channel); |
254 | } else { | 258 | goto out; |
255 | struct cppi41_dma_controller *controller; | 259 | } |
256 | int is_hs = 0; | ||
257 | /* | ||
258 | * On AM335x it has been observed that the TX interrupt fires | ||
259 | * too early that means the TXFIFO is not yet empty but the DMA | ||
260 | * engine says that it is done with the transfer. We don't | ||
261 | * receive a FIFO empty interrupt so the only thing we can do is | ||
262 | * to poll for the bit. On HS it usually takes 2us, on FS around | ||
263 | * 110us - 150us depending on the transfer size. | ||
264 | * We spin on HS (no longer than than 25us and setup a timer on | ||
265 | * FS to check for the bit and complete the transfer. | ||
266 | */ | ||
267 | controller = cppi41_channel->controller; | ||
268 | 260 | ||
269 | if (is_host_active(musb)) { | 261 | /* |
270 | if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED) | 262 | * On AM335x it has been observed that the TX interrupt fires |
271 | is_hs = 1; | 263 | * too early that means the TXFIFO is not yet empty but the DMA |
272 | } else { | 264 | * engine says that it is done with the transfer. We don't |
273 | if (musb->g.speed == USB_SPEED_HIGH) | 265 | * receive a FIFO empty interrupt so the only thing we can do is |
274 | is_hs = 1; | 266 | * to poll for the bit. On HS it usually takes 2us, on FS around |
275 | } | 267 | * 110us - 150us depending on the transfer size. |
276 | if (is_hs) { | 268 | * We spin on HS (no longer than than 25us and setup a timer on |
277 | unsigned wait = 25; | 269 | * FS to check for the bit and complete the transfer. |
278 | 270 | */ | |
279 | do { | 271 | controller = cppi41_channel->controller; |
280 | empty = musb_is_tx_fifo_empty(hw_ep); | 272 | |
281 | if (empty) | 273 | if (is_host_active(musb)) { |
282 | break; | 274 | if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED) |
283 | wait--; | 275 | is_hs = 1; |
284 | if (!wait) | 276 | } else { |
285 | break; | 277 | if (musb->g.speed == USB_SPEED_HIGH) |
286 | udelay(1); | 278 | is_hs = 1; |
287 | } while (1); | 279 | } |
280 | if (is_hs) { | ||
281 | unsigned wait = 25; | ||
288 | 282 | ||
283 | do { | ||
289 | empty = musb_is_tx_fifo_empty(hw_ep); | 284 | empty = musb_is_tx_fifo_empty(hw_ep); |
290 | if (empty) { | 285 | if (empty) { |
291 | cppi41_trans_done(cppi41_channel); | 286 | cppi41_trans_done(cppi41_channel); |
292 | goto out; | 287 | goto out; |
293 | } | 288 | } |
294 | } | 289 | wait--; |
295 | list_add_tail(&cppi41_channel->tx_check, | 290 | if (!wait) |
296 | &controller->early_tx_list); | 291 | break; |
297 | if (!hrtimer_is_queued(&controller->early_tx)) { | 292 | cpu_relax(); |
298 | unsigned long usecs = cppi41_channel->total_len / 10; | 293 | } while (1); |
294 | } | ||
295 | list_add_tail(&cppi41_channel->tx_check, | ||
296 | &controller->early_tx_list); | ||
297 | if (!hrtimer_is_queued(&controller->early_tx)) { | ||
298 | unsigned long usecs = cppi41_channel->total_len / 10; | ||
299 | 299 | ||
300 | hrtimer_start_range_ns(&controller->early_tx, | 300 | hrtimer_start_range_ns(&controller->early_tx, |
301 | ktime_set(0, usecs * NSEC_PER_USEC), | 301 | ktime_set(0, usecs * NSEC_PER_USEC), |
302 | 20 * NSEC_PER_USEC, | 302 | 20 * NSEC_PER_USEC, |
303 | HRTIMER_MODE_REL); | 303 | HRTIMER_MODE_REL); |
304 | } | ||
305 | } | 304 | } |
305 | |||
306 | out: | 306 | out: |
307 | spin_unlock_irqrestore(&musb->lock, flags); | 307 | spin_unlock_irqrestore(&musb->lock, flags); |
308 | } | 308 | } |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index a900c9877195..b23ad150a165 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -119,7 +119,7 @@ struct dsps_musb_wrapper { | |||
119 | unsigned iddig:5; | 119 | unsigned iddig:5; |
120 | unsigned iddig_mux:5; | 120 | unsigned iddig_mux:5; |
121 | /* miscellaneous stuff */ | 121 | /* miscellaneous stuff */ |
122 | u8 poll_seconds; | 122 | unsigned poll_timeout; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | /* | 125 | /* |
@@ -225,9 +225,8 @@ static void dsps_musb_enable(struct musb *musb) | |||
225 | 225 | ||
226 | dsps_writel(reg_base, wrp->epintr_set, epmask); | 226 | dsps_writel(reg_base, wrp->epintr_set, epmask); |
227 | dsps_writel(reg_base, wrp->coreintr_set, coremask); | 227 | dsps_writel(reg_base, wrp->coreintr_set, coremask); |
228 | /* Force the DRVVBUS IRQ so we can start polling for ID change. */ | 228 | /* start polling for ID change. */ |
229 | dsps_writel(reg_base, wrp->coreintr_set, | 229 | mod_timer(&glue->timer, jiffies + msecs_to_jiffies(wrp->poll_timeout)); |
230 | (1 << wrp->drvvbus) << wrp->usb_shift); | ||
231 | dsps_musb_try_idle(musb, 0); | 230 | dsps_musb_try_idle(musb, 0); |
232 | } | 231 | } |
233 | 232 | ||
@@ -285,7 +284,8 @@ static void otg_timer(unsigned long _musb) | |||
285 | } | 284 | } |
286 | if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) | 285 | if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) |
287 | dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION); | 286 | dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION); |
288 | mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); | 287 | mod_timer(&glue->timer, jiffies + |
288 | msecs_to_jiffies(wrp->poll_timeout)); | ||
289 | break; | 289 | break; |
290 | case OTG_STATE_A_WAIT_VFALL: | 290 | case OTG_STATE_A_WAIT_VFALL: |
291 | musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; | 291 | musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; |
@@ -330,28 +330,6 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
330 | 330 | ||
331 | dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n", | 331 | dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n", |
332 | usbintr, epintr); | 332 | usbintr, epintr); |
333 | /* | ||
334 | * DRVVBUS IRQs are the only proxy we have (a very poor one!) for | ||
335 | * DSPS IP's missing ID change IRQ. We need an ID change IRQ to | ||
336 | * switch appropriately between halves of the OTG state machine. | ||
337 | * Managing DEVCTL.SESSION per Mentor docs requires that we know its | ||
338 | * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set. | ||
339 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... | ||
340 | */ | ||
341 | if (is_host_active(musb) && usbintr & MUSB_INTR_BABBLE) { | ||
342 | pr_info("CAUTION: musb: Babble Interrupt Occurred\n"); | ||
343 | |||
344 | /* | ||
345 | * When a babble condition occurs, the musb controller removes | ||
346 | * the session and is no longer in host mode. Hence, all | ||
347 | * devices connected to its root hub get disconnected. | ||
348 | * | ||
349 | * Hand this error down to the musb core isr, so it can | ||
350 | * recover. | ||
351 | */ | ||
352 | musb->int_usb = MUSB_INTR_BABBLE | MUSB_INTR_DISCONNECT; | ||
353 | musb->int_tx = musb->int_rx = 0; | ||
354 | } | ||
355 | 333 | ||
356 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { | 334 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { |
357 | int drvvbus = dsps_readl(reg_base, wrp->status); | 335 | int drvvbus = dsps_readl(reg_base, wrp->status); |
@@ -374,8 +352,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
374 | */ | 352 | */ |
375 | musb->int_usb &= ~MUSB_INTR_VBUSERROR; | 353 | musb->int_usb &= ~MUSB_INTR_VBUSERROR; |
376 | musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; | 354 | musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; |
377 | mod_timer(&glue->timer, | 355 | mod_timer(&glue->timer, jiffies + |
378 | jiffies + wrp->poll_seconds * HZ); | 356 | msecs_to_jiffies(wrp->poll_timeout)); |
379 | WARNING("VBUS error workaround (delay coming)\n"); | 357 | WARNING("VBUS error workaround (delay coming)\n"); |
380 | } else if (drvvbus) { | 358 | } else if (drvvbus) { |
381 | MUSB_HST_MODE(musb); | 359 | MUSB_HST_MODE(musb); |
@@ -404,7 +382,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
404 | /* Poll for ID change in OTG port mode */ | 382 | /* Poll for ID change in OTG port mode */ |
405 | if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && | 383 | if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && |
406 | musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) | 384 | musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) |
407 | mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); | 385 | mod_timer(&glue->timer, jiffies + |
386 | msecs_to_jiffies(wrp->poll_timeout)); | ||
408 | out: | 387 | out: |
409 | spin_unlock_irqrestore(&musb->lock, flags); | 388 | spin_unlock_irqrestore(&musb->lock, flags); |
410 | 389 | ||
@@ -453,7 +432,7 @@ static int dsps_musb_init(struct musb *musb) | |||
453 | musb->ctrl_base = reg_base; | 432 | musb->ctrl_base = reg_base; |
454 | 433 | ||
455 | /* NOP driver needs change if supporting dual instance */ | 434 | /* NOP driver needs change if supporting dual instance */ |
456 | musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0); | 435 | musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent, "phys", 0); |
457 | if (IS_ERR(musb->xceiv)) | 436 | if (IS_ERR(musb->xceiv)) |
458 | return PTR_ERR(musb->xceiv); | 437 | return PTR_ERR(musb->xceiv); |
459 | 438 | ||
@@ -497,7 +476,7 @@ static int dsps_musb_init(struct musb *musb) | |||
497 | * logic enabled. | 476 | * logic enabled. |
498 | */ | 477 | */ |
499 | val = dsps_readb(musb->mregs, MUSB_BABBLE_CTL); | 478 | val = dsps_readb(musb->mregs, MUSB_BABBLE_CTL); |
500 | if (val == MUSB_BABBLE_RCV_DISABLE) { | 479 | if (val & MUSB_BABBLE_RCV_DISABLE) { |
501 | glue->sw_babble_enabled = true; | 480 | glue->sw_babble_enabled = true; |
502 | val |= MUSB_BABBLE_SW_SESSION_CTRL; | 481 | val |= MUSB_BABBLE_SW_SESSION_CTRL; |
503 | dsps_writeb(musb->mregs, MUSB_BABBLE_CTL, val); | 482 | dsps_writeb(musb->mregs, MUSB_BABBLE_CTL, val); |
@@ -571,7 +550,7 @@ static int dsps_musb_set_mode(struct musb *musb, u8 mode) | |||
571 | return 0; | 550 | return 0; |
572 | } | 551 | } |
573 | 552 | ||
574 | static bool sw_babble_control(struct musb *musb) | 553 | static bool dsps_sw_babble_control(struct musb *musb) |
575 | { | 554 | { |
576 | u8 babble_ctl; | 555 | u8 babble_ctl; |
577 | bool session_restart = false; | 556 | bool session_restart = false; |
@@ -622,37 +601,36 @@ static bool sw_babble_control(struct musb *musb) | |||
622 | return session_restart; | 601 | return session_restart; |
623 | } | 602 | } |
624 | 603 | ||
625 | static int dsps_musb_reset(struct musb *musb) | 604 | static int dsps_musb_recover(struct musb *musb) |
626 | { | 605 | { |
627 | struct device *dev = musb->controller; | 606 | struct device *dev = musb->controller; |
628 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 607 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
629 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 608 | int session_restart = 0; |
630 | int session_restart = 0, error; | ||
631 | 609 | ||
632 | if (glue->sw_babble_enabled) | 610 | if (glue->sw_babble_enabled) |
633 | session_restart = sw_babble_control(musb); | 611 | session_restart = dsps_sw_babble_control(musb); |
634 | /* | 612 | else |
635 | * In case of new silicon version babble condition can be recovered | ||
636 | * without resetting the MUSB. But for older silicon versions, MUSB | ||
637 | * reset is needed | ||
638 | */ | ||
639 | if (session_restart || !glue->sw_babble_enabled) { | ||
640 | dev_info(musb->controller, "Restarting MUSB to recover from Babble\n"); | ||
641 | dsps_writel(musb->ctrl_base, wrp->control, (1 << wrp->reset)); | ||
642 | usleep_range(100, 200); | ||
643 | usb_phy_shutdown(musb->xceiv); | ||
644 | error = phy_power_off(musb->phy); | ||
645 | if (error) | ||
646 | dev_err(dev, "phy shutdown failed: %i\n", error); | ||
647 | usleep_range(100, 200); | ||
648 | usb_phy_init(musb->xceiv); | ||
649 | error = phy_power_on(musb->phy); | ||
650 | if (error) | ||
651 | dev_err(dev, "phy powerup failed: %i\n", error); | ||
652 | session_restart = 1; | 613 | session_restart = 1; |
614 | |||
615 | return session_restart ? 0 : -EPIPE; | ||
616 | } | ||
617 | |||
618 | /* Similar to am35x, dm81xx support only 32-bit read operation */ | ||
619 | static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | ||
620 | { | ||
621 | void __iomem *fifo = hw_ep->fifo; | ||
622 | |||
623 | if (len >= 4) { | ||
624 | readsl(fifo, dst, len >> 2); | ||
625 | dst += len & ~0x03; | ||
626 | len &= 0x03; | ||
653 | } | 627 | } |
654 | 628 | ||
655 | return !session_restart; | 629 | /* Read any remaining 1 to 3 bytes */ |
630 | if (len > 0) { | ||
631 | u32 val = musb_readl(fifo, 0); | ||
632 | memcpy(dst, &val, len); | ||
633 | } | ||
656 | } | 634 | } |
657 | 635 | ||
658 | static struct musb_platform_ops dsps_ops = { | 636 | static struct musb_platform_ops dsps_ops = { |
@@ -665,7 +643,7 @@ static struct musb_platform_ops dsps_ops = { | |||
665 | 643 | ||
666 | .try_idle = dsps_musb_try_idle, | 644 | .try_idle = dsps_musb_try_idle, |
667 | .set_mode = dsps_musb_set_mode, | 645 | .set_mode = dsps_musb_set_mode, |
668 | .reset = dsps_musb_reset, | 646 | .recover = dsps_musb_recover, |
669 | }; | 647 | }; |
670 | 648 | ||
671 | static u64 musb_dmamask = DMA_BIT_MASK(32); | 649 | static u64 musb_dmamask = DMA_BIT_MASK(32); |
@@ -737,7 +715,6 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, | |||
737 | musb->dev.parent = dev; | 715 | musb->dev.parent = dev; |
738 | musb->dev.dma_mask = &musb_dmamask; | 716 | musb->dev.dma_mask = &musb_dmamask; |
739 | musb->dev.coherent_dma_mask = musb_dmamask; | 717 | musb->dev.coherent_dma_mask = musb_dmamask; |
740 | musb->dev.of_node = of_node_get(dn); | ||
741 | 718 | ||
742 | glue->musb = musb; | 719 | glue->musb = musb; |
743 | 720 | ||
@@ -802,6 +779,9 @@ static int dsps_probe(struct platform_device *pdev) | |||
802 | } | 779 | } |
803 | wrp = match->data; | 780 | wrp = match->data; |
804 | 781 | ||
782 | if (of_device_is_compatible(pdev->dev.of_node, "ti,musb-dm816")) | ||
783 | dsps_ops.read_fifo = dsps_read_fifo32; | ||
784 | |||
805 | /* allocate glue */ | 785 | /* allocate glue */ |
806 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); | 786 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); |
807 | if (!glue) | 787 | if (!glue) |
@@ -873,12 +853,14 @@ static const struct dsps_musb_wrapper am33xx_driver_data = { | |||
873 | .rxep_shift = 16, | 853 | .rxep_shift = 16, |
874 | .rxep_mask = 0xfffe, | 854 | .rxep_mask = 0xfffe, |
875 | .rxep_bitmap = (0xfffe << 16), | 855 | .rxep_bitmap = (0xfffe << 16), |
876 | .poll_seconds = 2, | 856 | .poll_timeout = 2000, /* ms */ |
877 | }; | 857 | }; |
878 | 858 | ||
879 | static const struct of_device_id musb_dsps_of_match[] = { | 859 | static const struct of_device_id musb_dsps_of_match[] = { |
880 | { .compatible = "ti,musb-am33xx", | 860 | { .compatible = "ti,musb-am33xx", |
881 | .data = (void *) &am33xx_driver_data, }, | 861 | .data = &am33xx_driver_data, }, |
862 | { .compatible = "ti,musb-dm816", | ||
863 | .data = &am33xx_driver_data, }, | ||
882 | { }, | 864 | { }, |
883 | }; | 865 | }; |
884 | MODULE_DEVICE_TABLE(of, musb_dsps_of_match); | 866 | MODULE_DEVICE_TABLE(of, musb_dsps_of_match); |
@@ -929,7 +911,8 @@ static int dsps_resume(struct device *dev) | |||
929 | dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode); | 911 | dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode); |
930 | if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && | 912 | if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && |
931 | musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) | 913 | musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) |
932 | mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); | 914 | mod_timer(&glue->timer, jiffies + |
915 | msecs_to_jiffies(wrp->poll_timeout)); | ||
933 | 916 | ||
934 | return 0; | 917 | return 0; |
935 | } | 918 | } |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b2d9040c7685..4c481cd66c77 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -1876,44 +1876,6 @@ err: | |||
1876 | return retval; | 1876 | return retval; |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver) | ||
1880 | { | ||
1881 | int i; | ||
1882 | struct musb_hw_ep *hw_ep; | ||
1883 | |||
1884 | /* don't disconnect if it's not connected */ | ||
1885 | if (musb->g.speed == USB_SPEED_UNKNOWN) | ||
1886 | driver = NULL; | ||
1887 | else | ||
1888 | musb->g.speed = USB_SPEED_UNKNOWN; | ||
1889 | |||
1890 | /* deactivate the hardware */ | ||
1891 | if (musb->softconnect) { | ||
1892 | musb->softconnect = 0; | ||
1893 | musb_pullup(musb, 0); | ||
1894 | } | ||
1895 | musb_stop(musb); | ||
1896 | |||
1897 | /* killing any outstanding requests will quiesce the driver; | ||
1898 | * then report disconnect | ||
1899 | */ | ||
1900 | if (driver) { | ||
1901 | for (i = 0, hw_ep = musb->endpoints; | ||
1902 | i < musb->nr_endpoints; | ||
1903 | i++, hw_ep++) { | ||
1904 | musb_ep_select(musb->mregs, i); | ||
1905 | if (hw_ep->is_shared_fifo /* || !epnum */) { | ||
1906 | nuke(&hw_ep->ep_in, -ESHUTDOWN); | ||
1907 | } else { | ||
1908 | if (hw_ep->max_packet_sz_tx) | ||
1909 | nuke(&hw_ep->ep_in, -ESHUTDOWN); | ||
1910 | if (hw_ep->max_packet_sz_rx) | ||
1911 | nuke(&hw_ep->ep_out, -ESHUTDOWN); | ||
1912 | } | ||
1913 | } | ||
1914 | } | ||
1915 | } | ||
1916 | |||
1917 | /* | 1879 | /* |
1918 | * Unregister the gadget driver. Used by gadget drivers when | 1880 | * Unregister the gadget driver. Used by gadget drivers when |
1919 | * unregistering themselves from the controller. | 1881 | * unregistering themselves from the controller. |
@@ -1940,7 +1902,7 @@ static int musb_gadget_stop(struct usb_gadget *g) | |||
1940 | (void) musb_gadget_vbus_draw(&musb->g, 0); | 1902 | (void) musb_gadget_vbus_draw(&musb->g, 0); |
1941 | 1903 | ||
1942 | musb->xceiv->otg->state = OTG_STATE_UNDEFINED; | 1904 | musb->xceiv->otg->state = OTG_STATE_UNDEFINED; |
1943 | stop_activity(musb, NULL); | 1905 | musb_stop(musb); |
1944 | otg_set_peripheral(musb->xceiv->otg, NULL); | 1906 | otg_set_peripheral(musb->xceiv->otg, NULL); |
1945 | 1907 | ||
1946 | musb->is_active = 0; | 1908 | musb->is_active = 0; |