aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 02:08:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 02:08:32 -0400
commitf549953c15deab4c54708b39af86d4edecc6cddc (patch)
treef0412f989b77cdceab34c18aa85a8a25d5942a1f /drivers/usb/musb/musb_core.c
parentf0deb97ab13ad1f89cd0993f7339655d59788405 (diff)
parente04f5f7e423018bcec84c11af2058cdce87816f3 (diff)
Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (115 commits) EHCI: fix direction handling for interrupt data toggles USB: serial: add IDs for WinChipHead USB->RS232 adapter USB: OHCI: fix another regression for NVIDIA controllers usb: gadget: m66592-udc: add pullup function usb: gadget: m66592-udc: add function for external controller usb: gadget: r8a66597-udc: add pullup function usb: renesas_usbhs: support multi driver usb: renesas_usbhs: inaccessible pipe is not an error usb: renesas_usbhs: care buff alignment when dma handler USB: PL2303: correctly handle baudrates above 115200 usb: r8a66597-hcd: fixup USB_PORT_STAT_C_SUSPEND shift usb: renesas_usbhs: compile/config are rescued usb: renesas_usbhs: fixup comment-out usb: update email address in ohci-sh and r8a66597-hcd usb: r8a66597-hcd: add function for external controller EHCI: only power off port if over-current is active USB: mon: Allow to use usbmon without debugfs USB: EHCI: go back to using the system clock for QH unlinks ehci: add pci quirk for Ordissimo and RM Slate 100 too ehci: refactor pci quirk to use standard dmi_check_system method ... Fix up trivial conflicts in Documentation/feature-removal-schedule.txt
Diffstat (limited to 'drivers/usb/musb/musb_core.c')
-rw-r--r--drivers/usb/musb/musb_core.c133
1 files changed, 32 insertions, 101 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index bcbd1aba961..20a28731c33 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -328,8 +328,6 @@ void musb_load_testpacket(struct musb *musb)
328 328
329/*-------------------------------------------------------------------------*/ 329/*-------------------------------------------------------------------------*/
330 330
331#ifdef CONFIG_USB_MUSB_OTG
332
333/* 331/*
334 * Handles OTG hnp timeouts, such as b_ase0_brst 332 * Handles OTG hnp timeouts, such as b_ase0_brst
335 */ 333 */
@@ -401,8 +399,6 @@ void musb_hnp_stop(struct musb *musb)
401 musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16); 399 musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16);
402} 400}
403 401
404#endif
405
406/* 402/*
407 * Interrupt Service Routine to record USB "global" interrupts. 403 * Interrupt Service Routine to record USB "global" interrupts.
408 * Since these do not happen often and signify things of 404 * Since these do not happen often and signify things of
@@ -432,7 +428,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
432 dev_dbg(musb->controller, "RESUME (%s)\n", otg_state_string(musb->xceiv->state)); 428 dev_dbg(musb->controller, "RESUME (%s)\n", otg_state_string(musb->xceiv->state));
433 429
434 if (devctl & MUSB_DEVCTL_HM) { 430 if (devctl & MUSB_DEVCTL_HM) {
435#ifdef CONFIG_USB_MUSB_HDRC_HCD
436 void __iomem *mbase = musb->mregs; 431 void __iomem *mbase = musb->mregs;
437 432
438 switch (musb->xceiv->state) { 433 switch (musb->xceiv->state) {
@@ -472,17 +467,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
472 "host", 467 "host",
473 otg_state_string(musb->xceiv->state)); 468 otg_state_string(musb->xceiv->state));
474 } 469 }
475#endif
476 } else { 470 } else {
477 switch (musb->xceiv->state) { 471 switch (musb->xceiv->state) {
478#ifdef CONFIG_USB_MUSB_HDRC_HCD
479 case OTG_STATE_A_SUSPEND: 472 case OTG_STATE_A_SUSPEND:
480 /* possibly DISCONNECT is upcoming */ 473 /* possibly DISCONNECT is upcoming */
481 musb->xceiv->state = OTG_STATE_A_HOST; 474 musb->xceiv->state = OTG_STATE_A_HOST;
482 usb_hcd_resume_root_hub(musb_to_hcd(musb)); 475 usb_hcd_resume_root_hub(musb_to_hcd(musb));
483 break; 476 break;
484#endif
485#ifdef CONFIG_USB_GADGET_MUSB_HDRC
486 case OTG_STATE_B_WAIT_ACON: 477 case OTG_STATE_B_WAIT_ACON:
487 case OTG_STATE_B_PERIPHERAL: 478 case OTG_STATE_B_PERIPHERAL:
488 /* disconnect while suspended? we may 479 /* disconnect while suspended? we may
@@ -500,7 +491,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
500 case OTG_STATE_B_IDLE: 491 case OTG_STATE_B_IDLE:
501 musb->int_usb &= ~MUSB_INTR_SUSPEND; 492 musb->int_usb &= ~MUSB_INTR_SUSPEND;
502 break; 493 break;
503#endif
504 default: 494 default:
505 WARNING("bogus %s RESUME (%s)\n", 495 WARNING("bogus %s RESUME (%s)\n",
506 "peripheral", 496 "peripheral",
@@ -509,7 +499,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
509 } 499 }
510 } 500 }
511 501
512#ifdef CONFIG_USB_MUSB_HDRC_HCD
513 /* see manual for the order of the tests */ 502 /* see manual for the order of the tests */
514 if (int_usb & MUSB_INTR_SESSREQ) { 503 if (int_usb & MUSB_INTR_SESSREQ) {
515 void __iomem *mbase = musb->mregs; 504 void __iomem *mbase = musb->mregs;
@@ -609,14 +598,12 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
609 handled = IRQ_HANDLED; 598 handled = IRQ_HANDLED;
610 } 599 }
611 600
612#endif
613 if (int_usb & MUSB_INTR_SUSPEND) { 601 if (int_usb & MUSB_INTR_SUSPEND) {
614 dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x power %02x\n", 602 dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x power %02x\n",
615 otg_state_string(musb->xceiv->state), devctl, power); 603 otg_state_string(musb->xceiv->state), devctl, power);
616 handled = IRQ_HANDLED; 604 handled = IRQ_HANDLED;
617 605
618 switch (musb->xceiv->state) { 606 switch (musb->xceiv->state) {
619#ifdef CONFIG_USB_MUSB_OTG
620 case OTG_STATE_A_PERIPHERAL: 607 case OTG_STATE_A_PERIPHERAL:
621 /* We also come here if the cable is removed, since 608 /* We also come here if the cable is removed, since
622 * this silicon doesn't report ID-no-longer-grounded. 609 * this silicon doesn't report ID-no-longer-grounded.
@@ -633,7 +620,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
633 ? : OTG_TIME_A_WAIT_BCON)); 620 ? : OTG_TIME_A_WAIT_BCON));
634 621
635 break; 622 break;
636#endif
637 case OTG_STATE_B_IDLE: 623 case OTG_STATE_B_IDLE:
638 if (!musb->is_active) 624 if (!musb->is_active)
639 break; 625 break;
@@ -642,13 +628,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
642 musb->is_active = is_otg_enabled(musb) 628 musb->is_active = is_otg_enabled(musb)
643 && musb->xceiv->gadget->b_hnp_enable; 629 && musb->xceiv->gadget->b_hnp_enable;
644 if (musb->is_active) { 630 if (musb->is_active) {
645#ifdef CONFIG_USB_MUSB_OTG
646 musb->xceiv->state = OTG_STATE_B_WAIT_ACON; 631 musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
647 dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); 632 dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
648 mod_timer(&musb->otg_timer, jiffies 633 mod_timer(&musb->otg_timer, jiffies
649 + msecs_to_jiffies( 634 + msecs_to_jiffies(
650 OTG_TIME_B_ASE0_BRST)); 635 OTG_TIME_B_ASE0_BRST));
651#endif
652 } 636 }
653 break; 637 break;
654 case OTG_STATE_A_WAIT_BCON: 638 case OTG_STATE_A_WAIT_BCON:
@@ -672,7 +656,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
672 } 656 }
673 } 657 }
674 658
675#ifdef CONFIG_USB_MUSB_HDRC_HCD
676 if (int_usb & MUSB_INTR_CONNECT) { 659 if (int_usb & MUSB_INTR_CONNECT) {
677 struct usb_hcd *hcd = musb_to_hcd(musb); 660 struct usb_hcd *hcd = musb_to_hcd(musb);
678 661
@@ -682,7 +665,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
682 665
683 musb->ep0_stage = MUSB_EP0_START; 666 musb->ep0_stage = MUSB_EP0_START;
684 667
685#ifdef CONFIG_USB_MUSB_OTG
686 /* flush endpoints when transitioning from Device Mode */ 668 /* flush endpoints when transitioning from Device Mode */
687 if (is_peripheral_active(musb)) { 669 if (is_peripheral_active(musb)) {
688 /* REVISIT HNP; just force disconnect */ 670 /* REVISIT HNP; just force disconnect */
@@ -690,7 +672,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
690 musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask); 672 musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask);
691 musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe); 673 musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe);
692 musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); 674 musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7);
693#endif
694 musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED 675 musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED
695 |USB_PORT_STAT_HIGH_SPEED 676 |USB_PORT_STAT_HIGH_SPEED
696 |USB_PORT_STAT_ENABLE 677 |USB_PORT_STAT_ENABLE
@@ -739,7 +720,6 @@ b_host:
739 dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n", 720 dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
740 otg_state_string(musb->xceiv->state), devctl); 721 otg_state_string(musb->xceiv->state), devctl);
741 } 722 }
742#endif /* CONFIG_USB_MUSB_HDRC_HCD */
743 723
744 if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) { 724 if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) {
745 dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n", 725 dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
@@ -748,7 +728,6 @@ b_host:
748 handled = IRQ_HANDLED; 728 handled = IRQ_HANDLED;
749 729
750 switch (musb->xceiv->state) { 730 switch (musb->xceiv->state) {
751#ifdef CONFIG_USB_MUSB_HDRC_HCD
752 case OTG_STATE_A_HOST: 731 case OTG_STATE_A_HOST:
753 case OTG_STATE_A_SUSPEND: 732 case OTG_STATE_A_SUSPEND:
754 usb_hcd_resume_root_hub(musb_to_hcd(musb)); 733 usb_hcd_resume_root_hub(musb_to_hcd(musb));
@@ -757,8 +736,6 @@ b_host:
757 musb_platform_try_idle(musb, jiffies 736 musb_platform_try_idle(musb, jiffies
758 + msecs_to_jiffies(musb->a_wait_bcon)); 737 + msecs_to_jiffies(musb->a_wait_bcon));
759 break; 738 break;
760#endif /* HOST */
761#ifdef CONFIG_USB_MUSB_OTG
762 case OTG_STATE_B_HOST: 739 case OTG_STATE_B_HOST:
763 /* REVISIT this behaves for "real disconnect" 740 /* REVISIT this behaves for "real disconnect"
764 * cases; make sure the other transitions from 741 * cases; make sure the other transitions from
@@ -777,13 +754,10 @@ b_host:
777 /* FALLTHROUGH */ 754 /* FALLTHROUGH */
778 case OTG_STATE_B_WAIT_ACON: 755 case OTG_STATE_B_WAIT_ACON:
779 /* FALLTHROUGH */ 756 /* FALLTHROUGH */
780#endif /* OTG */
781#ifdef CONFIG_USB_GADGET_MUSB_HDRC
782 case OTG_STATE_B_PERIPHERAL: 757 case OTG_STATE_B_PERIPHERAL:
783 case OTG_STATE_B_IDLE: 758 case OTG_STATE_B_IDLE:
784 musb_g_disconnect(musb); 759 musb_g_disconnect(musb);
785 break; 760 break;
786#endif /* GADGET */
787 default: 761 default:
788 WARNING("unhandled DISCONNECT transition (%s)\n", 762 WARNING("unhandled DISCONNECT transition (%s)\n",
789 otg_state_string(musb->xceiv->state)); 763 otg_state_string(musb->xceiv->state));
@@ -814,7 +788,6 @@ b_host:
814 dev_dbg(musb->controller, "BUS RESET as %s\n", 788 dev_dbg(musb->controller, "BUS RESET as %s\n",
815 otg_state_string(musb->xceiv->state)); 789 otg_state_string(musb->xceiv->state));
816 switch (musb->xceiv->state) { 790 switch (musb->xceiv->state) {
817#ifdef CONFIG_USB_OTG
818 case OTG_STATE_A_SUSPEND: 791 case OTG_STATE_A_SUSPEND:
819 /* We need to ignore disconnect on suspend 792 /* We need to ignore disconnect on suspend
820 * otherwise tusb 2.0 won't reconnect after a 793 * otherwise tusb 2.0 won't reconnect after a
@@ -842,7 +815,6 @@ b_host:
842 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 815 musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
843 musb_g_reset(musb); 816 musb_g_reset(musb);
844 break; 817 break;
845#endif
846 case OTG_STATE_B_IDLE: 818 case OTG_STATE_B_IDLE:
847 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; 819 musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
848 /* FALLTHROUGH */ 820 /* FALLTHROUGH */
@@ -927,7 +899,6 @@ void musb_start(struct musb *musb)
927 899
928 /* put into basic highspeed mode and start session */ 900 /* put into basic highspeed mode and start session */
929 musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE 901 musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
930 | MUSB_POWER_SOFTCONN
931 | MUSB_POWER_HSENAB 902 | MUSB_POWER_HSENAB
932 /* ENSUSPEND wedges tusb */ 903 /* ENSUSPEND wedges tusb */
933 /* | MUSB_POWER_ENSUSPEND */ 904 /* | MUSB_POWER_ENSUSPEND */
@@ -1038,10 +1009,15 @@ static void musb_shutdown(struct platform_device *pdev)
1038 * We don't currently use dynamic fifo setup capability to do anything 1009 * We don't currently use dynamic fifo setup capability to do anything
1039 * more than selecting one of a bunch of predefined configurations. 1010 * more than selecting one of a bunch of predefined configurations.
1040 */ 1011 */
1041#if defined(CONFIG_USB_MUSB_TUSB6010) || defined(CONFIG_USB_MUSB_OMAP2PLUS) \ 1012#if defined(CONFIG_USB_MUSB_TUSB6010) \
1042 || defined(CONFIG_USB_MUSB_AM35X) 1013 || defined(CONFIG_USB_MUSB_TUSB6010_MODULE) \
1014 || defined(CONFIG_USB_MUSB_OMAP2PLUS) \
1015 || defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE) \
1016 || defined(CONFIG_USB_MUSB_AM35X) \
1017 || defined(CONFIG_USB_MUSB_AM35X_MODULE)
1043static ushort __initdata fifo_mode = 4; 1018static ushort __initdata fifo_mode = 4;
1044#elif defined(CONFIG_USB_MUSB_UX500) 1019#elif defined(CONFIG_USB_MUSB_UX500) \
1020 || defined(CONFIG_USB_MUSB_UX500_MODULE)
1045static ushort __initdata fifo_mode = 5; 1021static ushort __initdata fifo_mode = 5;
1046#else 1022#else
1047static ushort __initdata fifo_mode = 2; 1023static ushort __initdata fifo_mode = 2;
@@ -1191,14 +1167,12 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1191 /* configure the FIFO */ 1167 /* configure the FIFO */
1192 musb_writeb(mbase, MUSB_INDEX, hw_ep->epnum); 1168 musb_writeb(mbase, MUSB_INDEX, hw_ep->epnum);
1193 1169
1194#ifdef CONFIG_USB_MUSB_HDRC_HCD
1195 /* EP0 reserved endpoint for control, bidirectional; 1170 /* EP0 reserved endpoint for control, bidirectional;
1196 * EP1 reserved for bulk, two unidirection halves. 1171 * EP1 reserved for bulk, two unidirection halves.
1197 */ 1172 */
1198 if (hw_ep->epnum == 1) 1173 if (hw_ep->epnum == 1)
1199 musb->bulk_ep = hw_ep; 1174 musb->bulk_ep = hw_ep;
1200 /* REVISIT error check: be sure ep0 can both rx and tx ... */ 1175 /* REVISIT error check: be sure ep0 can both rx and tx ... */
1201#endif
1202 switch (cfg->style) { 1176 switch (cfg->style) {
1203 case FIFO_TX: 1177 case FIFO_TX:
1204 musb_write_txfifosz(mbase, c_size); 1178 musb_write_txfifosz(mbase, c_size);
@@ -1317,12 +1291,10 @@ done:
1317 n + 1, musb->config->num_eps * 2 - 1, 1291 n + 1, musb->config->num_eps * 2 - 1,
1318 offset, (1 << (musb->config->ram_bits + 2))); 1292 offset, (1 << (musb->config->ram_bits + 2)));
1319 1293
1320#ifdef CONFIG_USB_MUSB_HDRC_HCD
1321 if (!musb->bulk_ep) { 1294 if (!musb->bulk_ep) {
1322 pr_debug("%s: missing bulk\n", musb_driver_name); 1295 pr_debug("%s: missing bulk\n", musb_driver_name);
1323 return -EINVAL; 1296 return -EINVAL;
1324 } 1297 }
1325#endif
1326 1298
1327 return 0; 1299 return 0;
1328} 1300}
@@ -1353,7 +1325,6 @@ static int __init ep_config_from_hw(struct musb *musb)
1353 1325
1354 /* FIXME set up hw_ep->{rx,tx}_double_buffered */ 1326 /* FIXME set up hw_ep->{rx,tx}_double_buffered */
1355 1327
1356#ifdef CONFIG_USB_MUSB_HDRC_HCD
1357 /* pick an RX/TX endpoint for bulk */ 1328 /* pick an RX/TX endpoint for bulk */
1358 if (hw_ep->max_packet_sz_tx < 512 1329 if (hw_ep->max_packet_sz_tx < 512
1359 || hw_ep->max_packet_sz_rx < 512) 1330 || hw_ep->max_packet_sz_rx < 512)
@@ -1365,15 +1336,12 @@ static int __init ep_config_from_hw(struct musb *musb)
1365 if (musb->bulk_ep) 1336 if (musb->bulk_ep)
1366 continue; 1337 continue;
1367 musb->bulk_ep = hw_ep; 1338 musb->bulk_ep = hw_ep;
1368#endif
1369 } 1339 }
1370 1340
1371#ifdef CONFIG_USB_MUSB_HDRC_HCD
1372 if (!musb->bulk_ep) { 1341 if (!musb->bulk_ep) {
1373 pr_debug("%s: missing bulk\n", musb_driver_name); 1342 pr_debug("%s: missing bulk\n", musb_driver_name);
1374 return -EINVAL; 1343 return -EINVAL;
1375 } 1344 }
1376#endif
1377 1345
1378 return 0; 1346 return 0;
1379} 1347}
@@ -1429,13 +1397,11 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1429 } else { 1397 } else {
1430 musb->is_multipoint = 0; 1398 musb->is_multipoint = 0;
1431 type = ""; 1399 type = "";
1432#ifdef CONFIG_USB_MUSB_HDRC_HCD
1433#ifndef CONFIG_USB_OTG_BLACKLIST_HUB 1400#ifndef CONFIG_USB_OTG_BLACKLIST_HUB
1434 printk(KERN_ERR 1401 printk(KERN_ERR
1435 "%s: kernel must blacklist external hubs\n", 1402 "%s: kernel must blacklist external hubs\n",
1436 musb_driver_name); 1403 musb_driver_name);
1437#endif 1404#endif
1438#endif
1439 } 1405 }
1440 1406
1441 /* log release info */ 1407 /* log release info */
@@ -1479,11 +1445,9 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1479#endif 1445#endif
1480 1446
1481 hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; 1447 hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase;
1482#ifdef CONFIG_USB_MUSB_HDRC_HCD
1483 hw_ep->target_regs = musb_read_target_reg_base(i, mbase); 1448 hw_ep->target_regs = musb_read_target_reg_base(i, mbase);
1484 hw_ep->rx_reinit = 1; 1449 hw_ep->rx_reinit = 1;
1485 hw_ep->tx_reinit = 1; 1450 hw_ep->tx_reinit = 1;
1486#endif
1487 1451
1488 if (hw_ep->max_packet_sz_tx) { 1452 if (hw_ep->max_packet_sz_tx) {
1489 dev_dbg(musb->controller, 1453 dev_dbg(musb->controller,
@@ -1561,14 +1525,6 @@ irqreturn_t musb_interrupt(struct musb *musb)
1561 (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", 1525 (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral",
1562 musb->int_usb, musb->int_tx, musb->int_rx); 1526 musb->int_usb, musb->int_tx, musb->int_rx);
1563 1527
1564#ifdef CONFIG_USB_GADGET_MUSB_HDRC
1565 if (is_otg_enabled(musb) || is_peripheral_enabled(musb))
1566 if (!musb->gadget_driver) {
1567 dev_dbg(musb->controller, "No gadget driver loaded\n");
1568 return IRQ_HANDLED;
1569 }
1570#endif
1571
1572 /* the core can interrupt us for multiple reasons; docs have 1528 /* the core can interrupt us for multiple reasons; docs have
1573 * a generic interrupt flowchart to follow 1529 * a generic interrupt flowchart to follow
1574 */ 1530 */
@@ -1767,8 +1723,6 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
1767} 1723}
1768static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store); 1724static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
1769 1725
1770#ifdef CONFIG_USB_GADGET_MUSB_HDRC
1771
1772/* Gadget drivers can't know that a host is connected so they might want 1726/* Gadget drivers can't know that a host is connected so they might want
1773 * to start SRP, but users can. This allows userspace to trigger SRP. 1727 * to start SRP, but users can. This allows userspace to trigger SRP.
1774 */ 1728 */
@@ -1792,14 +1746,10 @@ musb_srp_store(struct device *dev, struct device_attribute *attr,
1792} 1746}
1793static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store); 1747static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store);
1794 1748
1795#endif /* CONFIG_USB_GADGET_MUSB_HDRC */
1796
1797static struct attribute *musb_attributes[] = { 1749static struct attribute *musb_attributes[] = {
1798 &dev_attr_mode.attr, 1750 &dev_attr_mode.attr,
1799 &dev_attr_vbus.attr, 1751 &dev_attr_vbus.attr,
1800#ifdef CONFIG_USB_GADGET_MUSB_HDRC
1801 &dev_attr_srp.attr, 1752 &dev_attr_srp.attr,
1802#endif
1803 NULL 1753 NULL
1804}; 1754};
1805 1755
@@ -1832,7 +1782,6 @@ allocate_instance(struct device *dev,
1832 struct musb *musb; 1782 struct musb *musb;
1833 struct musb_hw_ep *ep; 1783 struct musb_hw_ep *ep;
1834 int epnum; 1784 int epnum;
1835#ifdef CONFIG_USB_MUSB_HDRC_HCD
1836 struct usb_hcd *hcd; 1785 struct usb_hcd *hcd;
1837 1786
1838 hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev)); 1787 hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
@@ -1850,12 +1799,6 @@ allocate_instance(struct device *dev,
1850 1799
1851 musb->vbuserr_retry = VBUSERR_RETRY_COUNT; 1800 musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
1852 musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON; 1801 musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON;
1853#else
1854 musb = kzalloc(sizeof *musb, GFP_KERNEL);
1855 if (!musb)
1856 return NULL;
1857
1858#endif
1859 dev_set_drvdata(dev, musb); 1802 dev_set_drvdata(dev, musb);
1860 musb->mregs = mbase; 1803 musb->mregs = mbase;
1861 musb->ctrl_base = mbase; 1804 musb->ctrl_base = mbase;
@@ -1885,9 +1828,7 @@ static void musb_free(struct musb *musb)
1885 sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); 1828 sysfs_remove_group(&musb->controller->kobj, &musb_attr_group);
1886#endif 1829#endif
1887 1830
1888#ifdef CONFIG_USB_GADGET_MUSB_HDRC
1889 musb_gadget_cleanup(musb); 1831 musb_gadget_cleanup(musb);
1890#endif
1891 1832
1892 if (musb->nIrq >= 0) { 1833 if (musb->nIrq >= 0) {
1893 if (musb->irq_wake) 1834 if (musb->irq_wake)
@@ -1901,11 +1842,7 @@ static void musb_free(struct musb *musb)
1901 dma_controller_destroy(c); 1842 dma_controller_destroy(c);
1902 } 1843 }
1903 1844
1904#ifdef CONFIG_USB_MUSB_HDRC_HCD
1905 usb_put_hcd(musb_to_hcd(musb));
1906#else
1907 kfree(musb); 1845 kfree(musb);
1908#endif
1909} 1846}
1910 1847
1911/* 1848/*
@@ -2000,9 +1937,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2000 if (status < 0) 1937 if (status < 0)
2001 goto fail3; 1938 goto fail3;
2002 1939
2003#ifdef CONFIG_USB_MUSB_OTG
2004 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); 1940 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
2005#endif
2006 1941
2007 /* Init IRQ workqueue before request_irq */ 1942 /* Init IRQ workqueue before request_irq */
2008 INIT_WORK(&musb->irq_work, musb_irq_work); 1943 INIT_WORK(&musb->irq_work, musb_irq_work);
@@ -2214,7 +2149,16 @@ static void musb_save_context(struct musb *musb)
2214 musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); 2149 musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
2215 2150
2216 for (i = 0; i < musb->config->num_eps; ++i) { 2151 for (i = 0; i < musb->config->num_eps; ++i) {
2217 epio = musb->endpoints[i].regs; 2152 struct musb_hw_ep *hw_ep;
2153
2154 hw_ep = &musb->endpoints[i];
2155 if (!hw_ep)
2156 continue;
2157
2158 epio = hw_ep->regs;
2159 if (!epio)
2160 continue;
2161
2218 musb->context.index_regs[i].txmaxp = 2162 musb->context.index_regs[i].txmaxp =
2219 musb_readw(epio, MUSB_TXMAXP); 2163 musb_readw(epio, MUSB_TXMAXP);
2220 musb->context.index_regs[i].txcsr = 2164 musb->context.index_regs[i].txcsr =
@@ -2280,7 +2224,16 @@ static void musb_restore_context(struct musb *musb)
2280 musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); 2224 musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl);
2281 2225
2282 for (i = 0; i < musb->config->num_eps; ++i) { 2226 for (i = 0; i < musb->config->num_eps; ++i) {
2283 epio = musb->endpoints[i].regs; 2227 struct musb_hw_ep *hw_ep;
2228
2229 hw_ep = &musb->endpoints[i];
2230 if (!hw_ep)
2231 continue;
2232
2233 epio = hw_ep->regs;
2234 if (!epio)
2235 continue;
2236
2284 musb_writew(epio, MUSB_TXMAXP, 2237 musb_writew(epio, MUSB_TXMAXP,
2285 musb->context.index_regs[i].txmaxp); 2238 musb->context.index_regs[i].txmaxp);
2286 musb_writew(epio, MUSB_TXCSR, 2239 musb_writew(epio, MUSB_TXCSR,
@@ -2329,13 +2282,13 @@ static void musb_restore_context(struct musb *musb)
2329 musb->context.index_regs[i].rxhubport); 2282 musb->context.index_regs[i].rxhubport);
2330 } 2283 }
2331 } 2284 }
2285 musb_writeb(musb_base, MUSB_INDEX, musb->context.index);
2332} 2286}
2333 2287
2334static int musb_suspend(struct device *dev) 2288static int musb_suspend(struct device *dev)
2335{ 2289{
2336 struct platform_device *pdev = to_platform_device(dev); 2290 struct musb *musb = dev_to_musb(dev);
2337 unsigned long flags; 2291 unsigned long flags;
2338 struct musb *musb = dev_to_musb(&pdev->dev);
2339 2292
2340 spin_lock_irqsave(&musb->lock, flags); 2293 spin_lock_irqsave(&musb->lock, flags);
2341 2294
@@ -2357,8 +2310,7 @@ static int musb_suspend(struct device *dev)
2357 2310
2358static int musb_resume_noirq(struct device *dev) 2311static int musb_resume_noirq(struct device *dev)
2359{ 2312{
2360 struct platform_device *pdev = to_platform_device(dev); 2313 struct musb *musb = dev_to_musb(dev);
2361 struct musb *musb = dev_to_musb(&pdev->dev);
2362 2314
2363 musb_restore_context(musb); 2315 musb_restore_context(musb);
2364 2316
@@ -2426,34 +2378,13 @@ static struct platform_driver musb_driver = {
2426 2378
2427static int __init musb_init(void) 2379static int __init musb_init(void)
2428{ 2380{
2429#ifdef CONFIG_USB_MUSB_HDRC_HCD
2430 if (usb_disabled()) 2381 if (usb_disabled())
2431 return 0; 2382 return 0;
2432#endif
2433 2383
2434 pr_info("%s: version " MUSB_VERSION ", " 2384 pr_info("%s: version " MUSB_VERSION ", "
2435#ifdef CONFIG_MUSB_PIO_ONLY
2436 "pio"
2437#elif defined(CONFIG_USB_TI_CPPI_DMA)
2438 "cppi-dma"
2439#elif defined(CONFIG_USB_INVENTRA_DMA)
2440 "musb-dma"
2441#elif defined(CONFIG_USB_TUSB_OMAP_DMA)
2442 "tusb-omap-dma"
2443#elif defined(CONFIG_USB_UX500_DMA)
2444 "ux500-dma"
2445#else
2446 "?dma?" 2385 "?dma?"
2447#endif
2448 ", " 2386 ", "
2449#ifdef CONFIG_USB_MUSB_OTG 2387 "otg (peripheral+host)",
2450 "otg (peripheral+host)"
2451#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
2452 "peripheral"
2453#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
2454 "host"
2455#endif
2456 ,
2457 musb_driver_name); 2388 musb_driver_name);
2458 return platform_driver_probe(&musb_driver, musb_probe); 2389 return platform_driver_probe(&musb_driver, musb_probe);
2459} 2390}