diff options
Diffstat (limited to 'drivers/usb/phy')
-rw-r--r-- | drivers/usb/phy/phy-ab8500-usb.c | 33 | ||||
-rw-r--r-- | drivers/usb/phy/phy-am335x-control.c | 4 | ||||
-rw-r--r-- | drivers/usb/phy/phy-fsl-usb.c | 27 | ||||
-rw-r--r-- | drivers/usb/phy/phy-fsl-usb.h | 2 | ||||
-rw-r--r-- | drivers/usb/phy/phy-generic.c | 8 | ||||
-rw-r--r-- | drivers/usb/phy/phy-gpio-vbus-usb.c | 16 | ||||
-rw-r--r-- | drivers/usb/phy/phy-isp1301-omap.c | 104 | ||||
-rw-r--r-- | drivers/usb/phy/phy-msm-usb.c | 107 | ||||
-rw-r--r-- | drivers/usb/phy/phy-mv-usb.c | 56 | ||||
-rw-r--r-- | drivers/usb/phy/phy-mxs-usb.c | 4 | ||||
-rw-r--r-- | drivers/usb/phy/phy-rcar-gen2-usb.c | 4 | ||||
-rw-r--r-- | drivers/usb/phy/phy-rcar-usb.c | 4 | ||||
-rw-r--r-- | drivers/usb/phy/phy-tahvo.c | 34 | ||||
-rw-r--r-- | drivers/usb/phy/phy-tegra-usb.c | 9 | ||||
-rw-r--r-- | drivers/usb/phy/phy-ulpi.c | 6 | ||||
-rw-r--r-- | drivers/usb/phy/phy.c | 16 |
16 files changed, 225 insertions, 209 deletions
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index 11ab2c45e462..8cd7d193c2ca 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/usb/otg/ab8500_usb.c | ||
3 | * | ||
4 | * USB transceiver driver for AB8500 family chips | 2 | * USB transceiver driver for AB8500 family chips |
5 | * | 3 | * |
6 | * Copyright (C) 2010-2013 ST-Ericsson AB | 4 | * Copyright (C) 2010-2013 ST-Ericsson AB |
@@ -446,7 +444,8 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
446 | if (event != UX500_MUSB_RIDB) | 444 | if (event != UX500_MUSB_RIDB) |
447 | event = UX500_MUSB_NONE; | 445 | event = UX500_MUSB_NONE; |
448 | /* Fallback to default B_IDLE as nothing is connected. */ | 446 | /* Fallback to default B_IDLE as nothing is connected. */ |
449 | ab->phy.state = OTG_STATE_B_IDLE; | 447 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
448 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
450 | break; | 449 | break; |
451 | 450 | ||
452 | case USB_LINK_ACA_RID_C_NM_9540: | 451 | case USB_LINK_ACA_RID_C_NM_9540: |
@@ -461,12 +460,14 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
461 | ab8500_usb_peri_phy_en(ab); | 460 | ab8500_usb_peri_phy_en(ab); |
462 | atomic_notifier_call_chain(&ab->phy.notifier, | 461 | atomic_notifier_call_chain(&ab->phy.notifier, |
463 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 462 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
463 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
464 | } | 464 | } |
465 | if (ab->mode == USB_IDLE) { | 465 | if (ab->mode == USB_IDLE) { |
466 | ab->mode = USB_PERIPHERAL; | 466 | ab->mode = USB_PERIPHERAL; |
467 | ab8500_usb_peri_phy_en(ab); | 467 | ab8500_usb_peri_phy_en(ab); |
468 | atomic_notifier_call_chain(&ab->phy.notifier, | 468 | atomic_notifier_call_chain(&ab->phy.notifier, |
469 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 469 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
470 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
470 | } | 471 | } |
471 | if (event != UX500_MUSB_RIDC) | 472 | if (event != UX500_MUSB_RIDC) |
472 | event = UX500_MUSB_VBUS; | 473 | event = UX500_MUSB_VBUS; |
@@ -502,6 +503,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
502 | event = UX500_MUSB_CHARGER; | 503 | event = UX500_MUSB_CHARGER; |
503 | atomic_notifier_call_chain(&ab->phy.notifier, | 504 | atomic_notifier_call_chain(&ab->phy.notifier, |
504 | event, &ab->vbus_draw); | 505 | event, &ab->vbus_draw); |
506 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
505 | break; | 507 | break; |
506 | 508 | ||
507 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540: | 509 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540: |
@@ -526,6 +528,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
526 | ab->mode = USB_IDLE; | 528 | ab->mode = USB_IDLE; |
527 | ab->phy.otg->default_a = false; | 529 | ab->phy.otg->default_a = false; |
528 | ab->vbus_draw = 0; | 530 | ab->vbus_draw = 0; |
531 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
529 | } | 532 | } |
530 | } | 533 | } |
531 | break; | 534 | break; |
@@ -584,7 +587,8 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
584 | * Fallback to default B_IDLE as nothing | 587 | * Fallback to default B_IDLE as nothing |
585 | * is connected | 588 | * is connected |
586 | */ | 589 | */ |
587 | ab->phy.state = OTG_STATE_B_IDLE; | 590 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
591 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
588 | break; | 592 | break; |
589 | 593 | ||
590 | case USB_LINK_ACA_RID_C_NM_8540: | 594 | case USB_LINK_ACA_RID_C_NM_8540: |
@@ -598,6 +602,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
598 | ab8500_usb_peri_phy_en(ab); | 602 | ab8500_usb_peri_phy_en(ab); |
599 | atomic_notifier_call_chain(&ab->phy.notifier, | 603 | atomic_notifier_call_chain(&ab->phy.notifier, |
600 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 604 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
605 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
601 | } | 606 | } |
602 | if (event != UX500_MUSB_RIDC) | 607 | if (event != UX500_MUSB_RIDC) |
603 | event = UX500_MUSB_VBUS; | 608 | event = UX500_MUSB_VBUS; |
@@ -626,6 +631,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
626 | event = UX500_MUSB_CHARGER; | 631 | event = UX500_MUSB_CHARGER; |
627 | atomic_notifier_call_chain(&ab->phy.notifier, | 632 | atomic_notifier_call_chain(&ab->phy.notifier, |
628 | event, &ab->vbus_draw); | 633 | event, &ab->vbus_draw); |
634 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
629 | break; | 635 | break; |
630 | 636 | ||
631 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540: | 637 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540: |
@@ -648,6 +654,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
648 | ab->mode = USB_IDLE; | 654 | ab->mode = USB_IDLE; |
649 | ab->phy.otg->default_a = false; | 655 | ab->phy.otg->default_a = false; |
650 | ab->vbus_draw = 0; | 656 | ab->vbus_draw = 0; |
657 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
651 | } | 658 | } |
652 | break; | 659 | break; |
653 | 660 | ||
@@ -693,7 +700,8 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, | |||
693 | * Fallback to default B_IDLE as nothing | 700 | * Fallback to default B_IDLE as nothing |
694 | * is connected | 701 | * is connected |
695 | */ | 702 | */ |
696 | ab->phy.state = OTG_STATE_B_IDLE; | 703 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
704 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
697 | break; | 705 | break; |
698 | 706 | ||
699 | case USB_LINK_ACA_RID_C_NM_8505: | 707 | case USB_LINK_ACA_RID_C_NM_8505: |
@@ -707,6 +715,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, | |||
707 | ab8500_usb_peri_phy_en(ab); | 715 | ab8500_usb_peri_phy_en(ab); |
708 | atomic_notifier_call_chain(&ab->phy.notifier, | 716 | atomic_notifier_call_chain(&ab->phy.notifier, |
709 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 717 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
718 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
710 | } | 719 | } |
711 | if (event != UX500_MUSB_RIDC) | 720 | if (event != UX500_MUSB_RIDC) |
712 | event = UX500_MUSB_VBUS; | 721 | event = UX500_MUSB_VBUS; |
@@ -734,6 +743,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, | |||
734 | event = UX500_MUSB_CHARGER; | 743 | event = UX500_MUSB_CHARGER; |
735 | atomic_notifier_call_chain(&ab->phy.notifier, | 744 | atomic_notifier_call_chain(&ab->phy.notifier, |
736 | event, &ab->vbus_draw); | 745 | event, &ab->vbus_draw); |
746 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
737 | break; | 747 | break; |
738 | 748 | ||
739 | default: | 749 | default: |
@@ -776,7 +786,8 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, | |||
776 | if (event != UX500_MUSB_RIDB) | 786 | if (event != UX500_MUSB_RIDB) |
777 | event = UX500_MUSB_NONE; | 787 | event = UX500_MUSB_NONE; |
778 | /* Fallback to default B_IDLE as nothing is connected */ | 788 | /* Fallback to default B_IDLE as nothing is connected */ |
779 | ab->phy.state = OTG_STATE_B_IDLE; | 789 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
790 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
780 | break; | 791 | break; |
781 | 792 | ||
782 | case USB_LINK_ACA_RID_C_NM_8500: | 793 | case USB_LINK_ACA_RID_C_NM_8500: |
@@ -794,6 +805,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, | |||
794 | ab8500_usb_peri_phy_en(ab); | 805 | ab8500_usb_peri_phy_en(ab); |
795 | atomic_notifier_call_chain(&ab->phy.notifier, | 806 | atomic_notifier_call_chain(&ab->phy.notifier, |
796 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 807 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
808 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
797 | } | 809 | } |
798 | if (event != UX500_MUSB_RIDC) | 810 | if (event != UX500_MUSB_RIDC) |
799 | event = UX500_MUSB_VBUS; | 811 | event = UX500_MUSB_VBUS; |
@@ -820,6 +832,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, | |||
820 | event = UX500_MUSB_CHARGER; | 832 | event = UX500_MUSB_CHARGER; |
821 | atomic_notifier_call_chain(&ab->phy.notifier, | 833 | atomic_notifier_call_chain(&ab->phy.notifier, |
822 | event, &ab->vbus_draw); | 834 | event, &ab->vbus_draw); |
835 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
823 | break; | 836 | break; |
824 | 837 | ||
825 | case USB_LINK_RESERVED_8500: | 838 | case USB_LINK_RESERVED_8500: |
@@ -1056,7 +1069,7 @@ static int ab8500_usb_set_peripheral(struct usb_otg *otg, | |||
1056 | if (!otg) | 1069 | if (!otg) |
1057 | return -ENODEV; | 1070 | return -ENODEV; |
1058 | 1071 | ||
1059 | ab = phy_to_ab(otg->phy); | 1072 | ab = phy_to_ab(otg->usb_phy); |
1060 | 1073 | ||
1061 | ab->phy.otg->gadget = gadget; | 1074 | ab->phy.otg->gadget = gadget; |
1062 | 1075 | ||
@@ -1080,7 +1093,7 @@ static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
1080 | if (!otg) | 1093 | if (!otg) |
1081 | return -ENODEV; | 1094 | return -ENODEV; |
1082 | 1095 | ||
1083 | ab = phy_to_ab(otg->phy); | 1096 | ab = phy_to_ab(otg->usb_phy); |
1084 | 1097 | ||
1085 | ab->phy.otg->host = host; | 1098 | ab->phy.otg->host = host; |
1086 | 1099 | ||
@@ -1380,9 +1393,9 @@ static int ab8500_usb_probe(struct platform_device *pdev) | |||
1380 | ab->phy.label = "ab8500"; | 1393 | ab->phy.label = "ab8500"; |
1381 | ab->phy.set_suspend = ab8500_usb_set_suspend; | 1394 | ab->phy.set_suspend = ab8500_usb_set_suspend; |
1382 | ab->phy.set_power = ab8500_usb_set_power; | 1395 | ab->phy.set_power = ab8500_usb_set_power; |
1383 | ab->phy.state = OTG_STATE_UNDEFINED; | 1396 | ab->phy.otg->state = OTG_STATE_UNDEFINED; |
1384 | 1397 | ||
1385 | otg->phy = &ab->phy; | 1398 | otg->usb_phy = &ab->phy; |
1386 | otg->set_host = ab8500_usb_set_host; | 1399 | otg->set_host = ab8500_usb_set_host; |
1387 | otg->set_peripheral = ab8500_usb_set_peripheral; | 1400 | otg->set_peripheral = ab8500_usb_set_peripheral; |
1388 | 1401 | ||
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c index 35b6083b7999..2e923c581809 100644 --- a/drivers/usb/phy/phy-am335x-control.c +++ b/drivers/usb/phy/phy-am335x-control.c | |||
@@ -147,10 +147,8 @@ static int am335x_control_usb_probe(struct platform_device *pdev) | |||
147 | phy_ctrl = of_id->data; | 147 | phy_ctrl = of_id->data; |
148 | 148 | ||
149 | ctrl_usb = devm_kzalloc(&pdev->dev, sizeof(*ctrl_usb), GFP_KERNEL); | 149 | ctrl_usb = devm_kzalloc(&pdev->dev, sizeof(*ctrl_usb), GFP_KERNEL); |
150 | if (!ctrl_usb) { | 150 | if (!ctrl_usb) |
151 | dev_err(&pdev->dev, "unable to alloc memory for control usb\n"); | ||
152 | return -ENOMEM; | 151 | return -ENOMEM; |
153 | } | ||
154 | 152 | ||
155 | ctrl_usb->dev = &pdev->dev; | 153 | ctrl_usb->dev = &pdev->dev; |
156 | 154 | ||
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index f1ea5990a50a..ab38aa32a6c1 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c | |||
@@ -274,7 +274,7 @@ void b_srp_end(unsigned long foo) | |||
274 | fsl_otg_dischrg_vbus(0); | 274 | fsl_otg_dischrg_vbus(0); |
275 | srp_wait_done = 1; | 275 | srp_wait_done = 1; |
276 | 276 | ||
277 | if ((fsl_otg_dev->phy.state == OTG_STATE_B_SRP_INIT) && | 277 | if ((fsl_otg_dev->phy.otg->state == OTG_STATE_B_SRP_INIT) && |
278 | fsl_otg_dev->fsm.b_sess_vld) | 278 | fsl_otg_dev->fsm.b_sess_vld) |
279 | fsl_otg_dev->fsm.b_srp_done = 1; | 279 | fsl_otg_dev->fsm.b_srp_done = 1; |
280 | } | 280 | } |
@@ -499,7 +499,8 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on) | |||
499 | { | 499 | { |
500 | struct usb_otg *otg = fsm->otg; | 500 | struct usb_otg *otg = fsm->otg; |
501 | struct device *dev; | 501 | struct device *dev; |
502 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 502 | struct fsl_otg *otg_dev = |
503 | container_of(otg->usb_phy, struct fsl_otg, phy); | ||
503 | u32 retval = 0; | 504 | u32 retval = 0; |
504 | 505 | ||
505 | if (!otg->host) | 506 | if (!otg->host) |
@@ -594,7 +595,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
594 | if (!otg) | 595 | if (!otg) |
595 | return -ENODEV; | 596 | return -ENODEV; |
596 | 597 | ||
597 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 598 | otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy); |
598 | if (otg_dev != fsl_otg_dev) | 599 | if (otg_dev != fsl_otg_dev) |
599 | return -ENODEV; | 600 | return -ENODEV; |
600 | 601 | ||
@@ -623,7 +624,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
623 | /* Mini-A cable connected */ | 624 | /* Mini-A cable connected */ |
624 | struct otg_fsm *fsm = &otg_dev->fsm; | 625 | struct otg_fsm *fsm = &otg_dev->fsm; |
625 | 626 | ||
626 | otg->phy->state = OTG_STATE_UNDEFINED; | 627 | otg->state = OTG_STATE_UNDEFINED; |
627 | fsm->protocol = PROTO_UNDEF; | 628 | fsm->protocol = PROTO_UNDEF; |
628 | } | 629 | } |
629 | } | 630 | } |
@@ -644,7 +645,7 @@ static int fsl_otg_set_peripheral(struct usb_otg *otg, | |||
644 | if (!otg) | 645 | if (!otg) |
645 | return -ENODEV; | 646 | return -ENODEV; |
646 | 647 | ||
647 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 648 | otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy); |
648 | VDBG("otg_dev 0x%x\n", (int)otg_dev); | 649 | VDBG("otg_dev 0x%x\n", (int)otg_dev); |
649 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); | 650 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); |
650 | if (otg_dev != fsl_otg_dev) | 651 | if (otg_dev != fsl_otg_dev) |
@@ -681,7 +682,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA) | |||
681 | { | 682 | { |
682 | if (!fsl_otg_dev) | 683 | if (!fsl_otg_dev) |
683 | return -ENODEV; | 684 | return -ENODEV; |
684 | if (phy->state == OTG_STATE_B_PERIPHERAL) | 685 | if (phy->otg->state == OTG_STATE_B_PERIPHERAL) |
685 | pr_info("FSL OTG: Draw %d mA\n", mA); | 686 | pr_info("FSL OTG: Draw %d mA\n", mA); |
686 | 687 | ||
687 | return 0; | 688 | return 0; |
@@ -714,10 +715,10 @@ static int fsl_otg_start_srp(struct usb_otg *otg) | |||
714 | { | 715 | { |
715 | struct fsl_otg *otg_dev; | 716 | struct fsl_otg *otg_dev; |
716 | 717 | ||
717 | if (!otg || otg->phy->state != OTG_STATE_B_IDLE) | 718 | if (!otg || otg->state != OTG_STATE_B_IDLE) |
718 | return -ENODEV; | 719 | return -ENODEV; |
719 | 720 | ||
720 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 721 | otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy); |
721 | if (otg_dev != fsl_otg_dev) | 722 | if (otg_dev != fsl_otg_dev) |
722 | return -ENODEV; | 723 | return -ENODEV; |
723 | 724 | ||
@@ -735,7 +736,7 @@ static int fsl_otg_start_hnp(struct usb_otg *otg) | |||
735 | if (!otg) | 736 | if (!otg) |
736 | return -ENODEV; | 737 | return -ENODEV; |
737 | 738 | ||
738 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 739 | otg_dev = container_of(otg->usb_phy, struct fsl_otg, phy); |
739 | if (otg_dev != fsl_otg_dev) | 740 | if (otg_dev != fsl_otg_dev) |
740 | return -ENODEV; | 741 | return -ENODEV; |
741 | 742 | ||
@@ -857,7 +858,7 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
857 | fsl_otg_tc->phy.dev = &pdev->dev; | 858 | fsl_otg_tc->phy.dev = &pdev->dev; |
858 | fsl_otg_tc->phy.set_power = fsl_otg_set_power; | 859 | fsl_otg_tc->phy.set_power = fsl_otg_set_power; |
859 | 860 | ||
860 | fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy; | 861 | fsl_otg_tc->phy.otg->usb_phy = &fsl_otg_tc->phy; |
861 | fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host; | 862 | fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host; |
862 | fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral; | 863 | fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral; |
863 | fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp; | 864 | fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp; |
@@ -989,10 +990,10 @@ int usb_otg_start(struct platform_device *pdev) | |||
989 | * Also: record initial state of ID pin | 990 | * Also: record initial state of ID pin |
990 | */ | 991 | */ |
991 | if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { | 992 | if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { |
992 | p_otg->phy.state = OTG_STATE_UNDEFINED; | 993 | p_otg->phy.otg->state = OTG_STATE_UNDEFINED; |
993 | p_otg->fsm.id = 1; | 994 | p_otg->fsm.id = 1; |
994 | } else { | 995 | } else { |
995 | p_otg->phy.state = OTG_STATE_A_IDLE; | 996 | p_otg->phy.otg->state = OTG_STATE_A_IDLE; |
996 | p_otg->fsm.id = 0; | 997 | p_otg->fsm.id = 0; |
997 | } | 998 | } |
998 | 999 | ||
@@ -1047,7 +1048,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, | |||
1047 | /* State */ | 1048 | /* State */ |
1048 | t = scnprintf(next, size, | 1049 | t = scnprintf(next, size, |
1049 | "OTG state: %s\n\n", | 1050 | "OTG state: %s\n\n", |
1050 | usb_otg_state_string(fsl_otg_dev->phy.state)); | 1051 | usb_otg_state_string(fsl_otg_dev->phy.otg->state)); |
1051 | size -= t; | 1052 | size -= t; |
1052 | next += t; | 1053 | next += t; |
1053 | 1054 | ||
diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h index 5986c96354df..23149954a09c 100644 --- a/drivers/usb/phy/phy-fsl-usb.h +++ b/drivers/usb/phy/phy-fsl-usb.h | |||
@@ -298,7 +298,7 @@ | |||
298 | /* SE0 Time Before SRP */ | 298 | /* SE0 Time Before SRP */ |
299 | #define TB_SE0_SRP (2) /* b_idle,minimum 2 ms, section:5.3.2 */ | 299 | #define TB_SE0_SRP (2) /* b_idle,minimum 2 ms, section:5.3.2 */ |
300 | 300 | ||
301 | #define SET_OTG_STATE(otg_ptr, newstate) ((otg_ptr)->state = newstate) | 301 | #define SET_OTG_STATE(phy, newstate) ((phy)->otg->state = newstate) |
302 | 302 | ||
303 | struct usb_dr_mmap { | 303 | struct usb_dr_mmap { |
304 | /* Capability register */ | 304 | /* Capability register */ |
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 7594e5069ae5..4ba1f57220f6 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/usb/otg/nop-usb-xceiv.c | ||
3 | * | ||
4 | * NOP USB transceiver for all USB transceiver which are either built-in | 2 | * NOP USB transceiver for all USB transceiver which are either built-in |
5 | * into USB IP or which are mostly autonomous. | 3 | * into USB IP or which are mostly autonomous. |
6 | * | 4 | * |
@@ -123,7 +121,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) | |||
123 | } | 121 | } |
124 | 122 | ||
125 | otg->gadget = gadget; | 123 | otg->gadget = gadget; |
126 | otg->phy->state = OTG_STATE_B_IDLE; | 124 | otg->state = OTG_STATE_B_IDLE; |
127 | return 0; | 125 | return 0; |
128 | } | 126 | } |
129 | 127 | ||
@@ -225,10 +223,10 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop, | |||
225 | nop->phy.dev = nop->dev; | 223 | nop->phy.dev = nop->dev; |
226 | nop->phy.label = "nop-xceiv"; | 224 | nop->phy.label = "nop-xceiv"; |
227 | nop->phy.set_suspend = nop_set_suspend; | 225 | nop->phy.set_suspend = nop_set_suspend; |
228 | nop->phy.state = OTG_STATE_UNDEFINED; | ||
229 | nop->phy.type = type; | 226 | nop->phy.type = type; |
230 | 227 | ||
231 | nop->phy.otg->phy = &nop->phy; | 228 | nop->phy.otg->state = OTG_STATE_UNDEFINED; |
229 | nop->phy.otg->usb_phy = &nop->phy; | ||
232 | nop->phy.otg->set_host = nop_set_host; | 230 | nop->phy.otg->set_host = nop_set_host; |
233 | nop->phy.otg->set_peripheral = nop_set_peripheral; | 231 | nop->phy.otg->set_peripheral = nop_set_peripheral; |
234 | 232 | ||
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c index f4b14bd97e14..54511725caaf 100644 --- a/drivers/usb/phy/phy-gpio-vbus-usb.c +++ b/drivers/usb/phy/phy-gpio-vbus-usb.c | |||
@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work) | |||
121 | 121 | ||
122 | if (vbus) { | 122 | if (vbus) { |
123 | status = USB_EVENT_VBUS; | 123 | status = USB_EVENT_VBUS; |
124 | gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; | 124 | gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
125 | gpio_vbus->phy.last_event = status; | 125 | gpio_vbus->phy.last_event = status; |
126 | usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); | 126 | usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); |
127 | 127 | ||
@@ -134,6 +134,7 @@ static void gpio_vbus_work(struct work_struct *work) | |||
134 | 134 | ||
135 | atomic_notifier_call_chain(&gpio_vbus->phy.notifier, | 135 | atomic_notifier_call_chain(&gpio_vbus->phy.notifier, |
136 | status, gpio_vbus->phy.otg->gadget); | 136 | status, gpio_vbus->phy.otg->gadget); |
137 | usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_ENUMERATED); | ||
137 | } else { | 138 | } else { |
138 | /* optionally disable D+ pullup */ | 139 | /* optionally disable D+ pullup */ |
139 | if (gpio_is_valid(gpio)) | 140 | if (gpio_is_valid(gpio)) |
@@ -143,11 +144,12 @@ static void gpio_vbus_work(struct work_struct *work) | |||
143 | 144 | ||
144 | usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); | 145 | usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); |
145 | status = USB_EVENT_NONE; | 146 | status = USB_EVENT_NONE; |
146 | gpio_vbus->phy.state = OTG_STATE_B_IDLE; | 147 | gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE; |
147 | gpio_vbus->phy.last_event = status; | 148 | gpio_vbus->phy.last_event = status; |
148 | 149 | ||
149 | atomic_notifier_call_chain(&gpio_vbus->phy.notifier, | 150 | atomic_notifier_call_chain(&gpio_vbus->phy.notifier, |
150 | status, gpio_vbus->phy.otg->gadget); | 151 | status, gpio_vbus->phy.otg->gadget); |
152 | usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_NONE); | ||
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
@@ -180,7 +182,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg, | |||
180 | struct platform_device *pdev; | 182 | struct platform_device *pdev; |
181 | int gpio; | 183 | int gpio; |
182 | 184 | ||
183 | gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy); | 185 | gpio_vbus = container_of(otg->usb_phy, struct gpio_vbus_data, phy); |
184 | pdev = to_platform_device(gpio_vbus->dev); | 186 | pdev = to_platform_device(gpio_vbus->dev); |
185 | pdata = dev_get_platdata(gpio_vbus->dev); | 187 | pdata = dev_get_platdata(gpio_vbus->dev); |
186 | gpio = pdata->gpio_pullup; | 188 | gpio = pdata->gpio_pullup; |
@@ -196,7 +198,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg, | |||
196 | set_vbus_draw(gpio_vbus, 0); | 198 | set_vbus_draw(gpio_vbus, 0); |
197 | 199 | ||
198 | usb_gadget_vbus_disconnect(otg->gadget); | 200 | usb_gadget_vbus_disconnect(otg->gadget); |
199 | otg->phy->state = OTG_STATE_UNDEFINED; | 201 | otg->state = OTG_STATE_UNDEFINED; |
200 | 202 | ||
201 | otg->gadget = NULL; | 203 | otg->gadget = NULL; |
202 | return 0; | 204 | return 0; |
@@ -218,7 +220,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA) | |||
218 | 220 | ||
219 | gpio_vbus = container_of(phy, struct gpio_vbus_data, phy); | 221 | gpio_vbus = container_of(phy, struct gpio_vbus_data, phy); |
220 | 222 | ||
221 | if (phy->state == OTG_STATE_B_PERIPHERAL) | 223 | if (phy->otg->state == OTG_STATE_B_PERIPHERAL) |
222 | set_vbus_draw(gpio_vbus, mA); | 224 | set_vbus_draw(gpio_vbus, mA); |
223 | return 0; | 225 | return 0; |
224 | } | 226 | } |
@@ -269,9 +271,9 @@ static int gpio_vbus_probe(struct platform_device *pdev) | |||
269 | gpio_vbus->phy.dev = gpio_vbus->dev; | 271 | gpio_vbus->phy.dev = gpio_vbus->dev; |
270 | gpio_vbus->phy.set_power = gpio_vbus_set_power; | 272 | gpio_vbus->phy.set_power = gpio_vbus_set_power; |
271 | gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend; | 273 | gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend; |
272 | gpio_vbus->phy.state = OTG_STATE_UNDEFINED; | ||
273 | 274 | ||
274 | gpio_vbus->phy.otg->phy = &gpio_vbus->phy; | 275 | gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED; |
276 | gpio_vbus->phy.otg->usb_phy = &gpio_vbus->phy; | ||
275 | gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral; | 277 | gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral; |
276 | 278 | ||
277 | err = devm_gpio_request(&pdev->dev, gpio, "vbus_detect"); | 279 | err = devm_gpio_request(&pdev->dev, gpio, "vbus_detect"); |
diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c index 8eea56d3ded6..a2dfb2ae520e 100644 --- a/drivers/usb/phy/phy-isp1301-omap.c +++ b/drivers/usb/phy/phy-isp1301-omap.c | |||
@@ -234,7 +234,7 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits) | |||
234 | 234 | ||
235 | static inline const char *state_name(struct isp1301 *isp) | 235 | static inline const char *state_name(struct isp1301 *isp) |
236 | { | 236 | { |
237 | return usb_otg_state_string(isp->phy.state); | 237 | return usb_otg_state_string(isp->phy.otg->state); |
238 | } | 238 | } |
239 | 239 | ||
240 | /*-------------------------------------------------------------------------*/ | 240 | /*-------------------------------------------------------------------------*/ |
@@ -249,7 +249,7 @@ static inline const char *state_name(struct isp1301 *isp) | |||
249 | 249 | ||
250 | static void power_down(struct isp1301 *isp) | 250 | static void power_down(struct isp1301 *isp) |
251 | { | 251 | { |
252 | isp->phy.state = OTG_STATE_UNDEFINED; | 252 | isp->phy.otg->state = OTG_STATE_UNDEFINED; |
253 | 253 | ||
254 | // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); | 254 | // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); |
255 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); | 255 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); |
@@ -339,7 +339,7 @@ static void a_idle(struct isp1301 *isp, const char *tag) | |||
339 | { | 339 | { |
340 | u32 l; | 340 | u32 l; |
341 | 341 | ||
342 | if (isp->phy.state == OTG_STATE_A_IDLE) | 342 | if (isp->phy.otg->state == OTG_STATE_A_IDLE) |
343 | return; | 343 | return; |
344 | 344 | ||
345 | isp->phy.otg->default_a = 1; | 345 | isp->phy.otg->default_a = 1; |
@@ -351,7 +351,7 @@ static void a_idle(struct isp1301 *isp, const char *tag) | |||
351 | isp->phy.otg->gadget->is_a_peripheral = 1; | 351 | isp->phy.otg->gadget->is_a_peripheral = 1; |
352 | gadget_suspend(isp); | 352 | gadget_suspend(isp); |
353 | } | 353 | } |
354 | isp->phy.state = OTG_STATE_A_IDLE; | 354 | isp->phy.otg->state = OTG_STATE_A_IDLE; |
355 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 355 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
356 | omap_writel(l, OTG_CTRL); | 356 | omap_writel(l, OTG_CTRL); |
357 | isp->last_otg_ctrl = l; | 357 | isp->last_otg_ctrl = l; |
@@ -363,7 +363,7 @@ static void b_idle(struct isp1301 *isp, const char *tag) | |||
363 | { | 363 | { |
364 | u32 l; | 364 | u32 l; |
365 | 365 | ||
366 | if (isp->phy.state == OTG_STATE_B_IDLE) | 366 | if (isp->phy.otg->state == OTG_STATE_B_IDLE) |
367 | return; | 367 | return; |
368 | 368 | ||
369 | isp->phy.otg->default_a = 0; | 369 | isp->phy.otg->default_a = 0; |
@@ -375,7 +375,7 @@ static void b_idle(struct isp1301 *isp, const char *tag) | |||
375 | isp->phy.otg->gadget->is_a_peripheral = 0; | 375 | isp->phy.otg->gadget->is_a_peripheral = 0; |
376 | gadget_suspend(isp); | 376 | gadget_suspend(isp); |
377 | } | 377 | } |
378 | isp->phy.state = OTG_STATE_B_IDLE; | 378 | isp->phy.otg->state = OTG_STATE_B_IDLE; |
379 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 379 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
380 | omap_writel(l, OTG_CTRL); | 380 | omap_writel(l, OTG_CTRL); |
381 | isp->last_otg_ctrl = l; | 381 | isp->last_otg_ctrl = l; |
@@ -474,7 +474,7 @@ static void check_state(struct isp1301 *isp, const char *tag) | |||
474 | default: | 474 | default: |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | if (isp->phy.state == state && !extra) | 477 | if (isp->phy.otg->state == state && !extra) |
478 | return; | 478 | return; |
479 | pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, | 479 | pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, |
480 | usb_otg_state_string(state), fsm, state_name(isp), | 480 | usb_otg_state_string(state), fsm, state_name(isp), |
@@ -498,23 +498,23 @@ static void update_otg1(struct isp1301 *isp, u8 int_src) | |||
498 | 498 | ||
499 | if (int_src & INTR_SESS_VLD) | 499 | if (int_src & INTR_SESS_VLD) |
500 | otg_ctrl |= OTG_ASESSVLD; | 500 | otg_ctrl |= OTG_ASESSVLD; |
501 | else if (isp->phy.state == OTG_STATE_A_WAIT_VFALL) { | 501 | else if (isp->phy.otg->state == OTG_STATE_A_WAIT_VFALL) { |
502 | a_idle(isp, "vfall"); | 502 | a_idle(isp, "vfall"); |
503 | otg_ctrl &= ~OTG_CTRL_BITS; | 503 | otg_ctrl &= ~OTG_CTRL_BITS; |
504 | } | 504 | } |
505 | if (int_src & INTR_VBUS_VLD) | 505 | if (int_src & INTR_VBUS_VLD) |
506 | otg_ctrl |= OTG_VBUSVLD; | 506 | otg_ctrl |= OTG_VBUSVLD; |
507 | if (int_src & INTR_ID_GND) { /* default-A */ | 507 | if (int_src & INTR_ID_GND) { /* default-A */ |
508 | if (isp->phy.state == OTG_STATE_B_IDLE | 508 | if (isp->phy.otg->state == OTG_STATE_B_IDLE |
509 | || isp->phy.state | 509 | || isp->phy.otg->state |
510 | == OTG_STATE_UNDEFINED) { | 510 | == OTG_STATE_UNDEFINED) { |
511 | a_idle(isp, "init"); | 511 | a_idle(isp, "init"); |
512 | return; | 512 | return; |
513 | } | 513 | } |
514 | } else { /* default-B */ | 514 | } else { /* default-B */ |
515 | otg_ctrl |= OTG_ID; | 515 | otg_ctrl |= OTG_ID; |
516 | if (isp->phy.state == OTG_STATE_A_IDLE | 516 | if (isp->phy.otg->state == OTG_STATE_A_IDLE |
517 | || isp->phy.state == OTG_STATE_UNDEFINED) { | 517 | || isp->phy.otg->state == OTG_STATE_UNDEFINED) { |
518 | b_idle(isp, "init"); | 518 | b_idle(isp, "init"); |
519 | return; | 519 | return; |
520 | } | 520 | } |
@@ -548,14 +548,14 @@ static void otg_update_isp(struct isp1301 *isp) | |||
548 | isp->last_otg_ctrl = otg_ctrl; | 548 | isp->last_otg_ctrl = otg_ctrl; |
549 | otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; | 549 | otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; |
550 | 550 | ||
551 | switch (isp->phy.state) { | 551 | switch (isp->phy.otg->state) { |
552 | case OTG_STATE_B_IDLE: | 552 | case OTG_STATE_B_IDLE: |
553 | case OTG_STATE_B_PERIPHERAL: | 553 | case OTG_STATE_B_PERIPHERAL: |
554 | case OTG_STATE_B_SRP_INIT: | 554 | case OTG_STATE_B_SRP_INIT: |
555 | if (!(otg_ctrl & OTG_PULLUP)) { | 555 | if (!(otg_ctrl & OTG_PULLUP)) { |
556 | // if (otg_ctrl & OTG_B_HNPEN) { | 556 | // if (otg_ctrl & OTG_B_HNPEN) { |
557 | if (isp->phy.otg->gadget->b_hnp_enable) { | 557 | if (isp->phy.otg->gadget->b_hnp_enable) { |
558 | isp->phy.state = OTG_STATE_B_WAIT_ACON; | 558 | isp->phy.otg->state = OTG_STATE_B_WAIT_ACON; |
559 | pr_debug(" --> b_wait_acon\n"); | 559 | pr_debug(" --> b_wait_acon\n"); |
560 | } | 560 | } |
561 | goto pulldown; | 561 | goto pulldown; |
@@ -585,7 +585,7 @@ pulldown: | |||
585 | if (!(isp->phy.otg->host)) | 585 | if (!(isp->phy.otg->host)) |
586 | otg_ctrl &= ~OTG_DRV_VBUS; | 586 | otg_ctrl &= ~OTG_DRV_VBUS; |
587 | 587 | ||
588 | switch (isp->phy.state) { | 588 | switch (isp->phy.otg->state) { |
589 | case OTG_STATE_A_SUSPEND: | 589 | case OTG_STATE_A_SUSPEND: |
590 | if (otg_ctrl & OTG_DRV_VBUS) { | 590 | if (otg_ctrl & OTG_DRV_VBUS) { |
591 | set |= OTG1_VBUS_DRV; | 591 | set |= OTG1_VBUS_DRV; |
@@ -596,7 +596,7 @@ pulldown: | |||
596 | 596 | ||
597 | /* FALLTHROUGH */ | 597 | /* FALLTHROUGH */ |
598 | case OTG_STATE_A_VBUS_ERR: | 598 | case OTG_STATE_A_VBUS_ERR: |
599 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; | 599 | isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; |
600 | pr_debug(" --> a_wait_vfall\n"); | 600 | pr_debug(" --> a_wait_vfall\n"); |
601 | /* FALLTHROUGH */ | 601 | /* FALLTHROUGH */ |
602 | case OTG_STATE_A_WAIT_VFALL: | 602 | case OTG_STATE_A_WAIT_VFALL: |
@@ -605,7 +605,7 @@ pulldown: | |||
605 | break; | 605 | break; |
606 | case OTG_STATE_A_IDLE: | 606 | case OTG_STATE_A_IDLE: |
607 | if (otg_ctrl & OTG_DRV_VBUS) { | 607 | if (otg_ctrl & OTG_DRV_VBUS) { |
608 | isp->phy.state = OTG_STATE_A_WAIT_VRISE; | 608 | isp->phy.otg->state = OTG_STATE_A_WAIT_VRISE; |
609 | pr_debug(" --> a_wait_vrise\n"); | 609 | pr_debug(" --> a_wait_vrise\n"); |
610 | } | 610 | } |
611 | /* FALLTHROUGH */ | 611 | /* FALLTHROUGH */ |
@@ -625,17 +625,17 @@ pulldown: | |||
625 | if (otg_change & OTG_PULLUP) { | 625 | if (otg_change & OTG_PULLUP) { |
626 | u32 l; | 626 | u32 l; |
627 | 627 | ||
628 | switch (isp->phy.state) { | 628 | switch (isp->phy.otg->state) { |
629 | case OTG_STATE_B_IDLE: | 629 | case OTG_STATE_B_IDLE: |
630 | if (clr & OTG1_DP_PULLUP) | 630 | if (clr & OTG1_DP_PULLUP) |
631 | break; | 631 | break; |
632 | isp->phy.state = OTG_STATE_B_PERIPHERAL; | 632 | isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
633 | pr_debug(" --> b_peripheral\n"); | 633 | pr_debug(" --> b_peripheral\n"); |
634 | break; | 634 | break; |
635 | case OTG_STATE_A_SUSPEND: | 635 | case OTG_STATE_A_SUSPEND: |
636 | if (clr & OTG1_DP_PULLUP) | 636 | if (clr & OTG1_DP_PULLUP) |
637 | break; | 637 | break; |
638 | isp->phy.state = OTG_STATE_A_PERIPHERAL; | 638 | isp->phy.otg->state = OTG_STATE_A_PERIPHERAL; |
639 | pr_debug(" --> a_peripheral\n"); | 639 | pr_debug(" --> a_peripheral\n"); |
640 | break; | 640 | break; |
641 | default: | 641 | default: |
@@ -673,7 +673,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
673 | * remote wakeup (SRP, normal) using their own timer | 673 | * remote wakeup (SRP, normal) using their own timer |
674 | * to give "check cable and A-device" messages. | 674 | * to give "check cable and A-device" messages. |
675 | */ | 675 | */ |
676 | if (isp->phy.state == OTG_STATE_B_SRP_INIT) | 676 | if (isp->phy.otg->state == OTG_STATE_B_SRP_INIT) |
677 | b_idle(isp, "srp_timeout"); | 677 | b_idle(isp, "srp_timeout"); |
678 | 678 | ||
679 | omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); | 679 | omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); |
@@ -691,7 +691,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
691 | omap_writel(otg_ctrl, OTG_CTRL); | 691 | omap_writel(otg_ctrl, OTG_CTRL); |
692 | 692 | ||
693 | /* subset of b_peripheral()... */ | 693 | /* subset of b_peripheral()... */ |
694 | isp->phy.state = OTG_STATE_B_PERIPHERAL; | 694 | isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
695 | pr_debug(" --> b_peripheral\n"); | 695 | pr_debug(" --> b_peripheral\n"); |
696 | 696 | ||
697 | omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); | 697 | omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); |
@@ -703,7 +703,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
703 | state_name(isp), omap_readl(OTG_CTRL)); | 703 | state_name(isp), omap_readl(OTG_CTRL)); |
704 | 704 | ||
705 | isp1301_defer_work(isp, WORK_UPDATE_OTG); | 705 | isp1301_defer_work(isp, WORK_UPDATE_OTG); |
706 | switch (isp->phy.state) { | 706 | switch (isp->phy.otg->state) { |
707 | case OTG_STATE_A_IDLE: | 707 | case OTG_STATE_A_IDLE: |
708 | if (!otg->host) | 708 | if (!otg->host) |
709 | break; | 709 | break; |
@@ -734,7 +734,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
734 | otg_ctrl |= OTG_BUSDROP; | 734 | otg_ctrl |= OTG_BUSDROP; |
735 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; | 735 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; |
736 | omap_writel(otg_ctrl, OTG_CTRL); | 736 | omap_writel(otg_ctrl, OTG_CTRL); |
737 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; | 737 | isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; |
738 | 738 | ||
739 | omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); | 739 | omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); |
740 | ret = IRQ_HANDLED; | 740 | ret = IRQ_HANDLED; |
@@ -748,7 +748,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
748 | otg_ctrl |= OTG_BUSDROP; | 748 | otg_ctrl |= OTG_BUSDROP; |
749 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; | 749 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; |
750 | omap_writel(otg_ctrl, OTG_CTRL); | 750 | omap_writel(otg_ctrl, OTG_CTRL); |
751 | isp->phy.state = OTG_STATE_A_VBUS_ERR; | 751 | isp->phy.otg->state = OTG_STATE_A_VBUS_ERR; |
752 | 752 | ||
753 | omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); | 753 | omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); |
754 | ret = IRQ_HANDLED; | 754 | ret = IRQ_HANDLED; |
@@ -769,7 +769,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
769 | 769 | ||
770 | /* role is peripheral */ | 770 | /* role is peripheral */ |
771 | if (otg_ctrl & OTG_DRIVER_SEL) { | 771 | if (otg_ctrl & OTG_DRIVER_SEL) { |
772 | switch (isp->phy.state) { | 772 | switch (isp->phy.otg->state) { |
773 | case OTG_STATE_A_IDLE: | 773 | case OTG_STATE_A_IDLE: |
774 | b_idle(isp, __func__); | 774 | b_idle(isp, __func__); |
775 | break; | 775 | break; |
@@ -786,18 +786,18 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
786 | } | 786 | } |
787 | 787 | ||
788 | if (otg->host) { | 788 | if (otg->host) { |
789 | switch (isp->phy.state) { | 789 | switch (isp->phy.otg->state) { |
790 | case OTG_STATE_B_WAIT_ACON: | 790 | case OTG_STATE_B_WAIT_ACON: |
791 | isp->phy.state = OTG_STATE_B_HOST; | 791 | isp->phy.otg->state = OTG_STATE_B_HOST; |
792 | pr_debug(" --> b_host\n"); | 792 | pr_debug(" --> b_host\n"); |
793 | kick = 1; | 793 | kick = 1; |
794 | break; | 794 | break; |
795 | case OTG_STATE_A_WAIT_BCON: | 795 | case OTG_STATE_A_WAIT_BCON: |
796 | isp->phy.state = OTG_STATE_A_HOST; | 796 | isp->phy.otg->state = OTG_STATE_A_HOST; |
797 | pr_debug(" --> a_host\n"); | 797 | pr_debug(" --> a_host\n"); |
798 | break; | 798 | break; |
799 | case OTG_STATE_A_PERIPHERAL: | 799 | case OTG_STATE_A_PERIPHERAL: |
800 | isp->phy.state = OTG_STATE_A_WAIT_BCON; | 800 | isp->phy.otg->state = OTG_STATE_A_WAIT_BCON; |
801 | pr_debug(" --> a_wait_bcon\n"); | 801 | pr_debug(" --> a_wait_bcon\n"); |
802 | break; | 802 | break; |
803 | default: | 803 | default: |
@@ -937,7 +937,7 @@ static void b_peripheral(struct isp1301 *isp) | |||
937 | /* UDC driver just set OTG_BSESSVLD */ | 937 | /* UDC driver just set OTG_BSESSVLD */ |
938 | isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); | 938 | isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); |
939 | isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); | 939 | isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); |
940 | isp->phy.state = OTG_STATE_B_PERIPHERAL; | 940 | isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
941 | pr_debug(" --> b_peripheral\n"); | 941 | pr_debug(" --> b_peripheral\n"); |
942 | dump_regs(isp, "2periph"); | 942 | dump_regs(isp, "2periph"); |
943 | #endif | 943 | #endif |
@@ -947,7 +947,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
947 | { | 947 | { |
948 | struct usb_otg *otg = isp->phy.otg; | 948 | struct usb_otg *otg = isp->phy.otg; |
949 | u8 isp_stat, isp_bstat; | 949 | u8 isp_stat, isp_bstat; |
950 | enum usb_otg_state state = isp->phy.state; | 950 | enum usb_otg_state state = isp->phy.otg->state; |
951 | 951 | ||
952 | if (stat & INTR_BDIS_ACON) | 952 | if (stat & INTR_BDIS_ACON) |
953 | pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); | 953 | pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); |
@@ -970,7 +970,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
970 | * when HNP is used. | 970 | * when HNP is used. |
971 | */ | 971 | */ |
972 | if (isp_stat & INTR_VBUS_VLD) | 972 | if (isp_stat & INTR_VBUS_VLD) |
973 | isp->phy.state = OTG_STATE_A_HOST; | 973 | isp->phy.otg->state = OTG_STATE_A_HOST; |
974 | break; | 974 | break; |
975 | case OTG_STATE_A_WAIT_VFALL: | 975 | case OTG_STATE_A_WAIT_VFALL: |
976 | if (!(isp_stat & INTR_SESS_VLD)) | 976 | if (!(isp_stat & INTR_SESS_VLD)) |
@@ -978,7 +978,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
978 | break; | 978 | break; |
979 | default: | 979 | default: |
980 | if (!(isp_stat & INTR_VBUS_VLD)) | 980 | if (!(isp_stat & INTR_VBUS_VLD)) |
981 | isp->phy.state = OTG_STATE_A_VBUS_ERR; | 981 | isp->phy.otg->state = OTG_STATE_A_VBUS_ERR; |
982 | break; | 982 | break; |
983 | } | 983 | } |
984 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); | 984 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); |
@@ -1007,7 +1007,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1007 | if (otg->default_a) { | 1007 | if (otg->default_a) { |
1008 | switch (state) { | 1008 | switch (state) { |
1009 | default: | 1009 | default: |
1010 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; | 1010 | isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; |
1011 | break; | 1011 | break; |
1012 | case OTG_STATE_A_WAIT_VFALL: | 1012 | case OTG_STATE_A_WAIT_VFALL: |
1013 | state = OTG_STATE_A_IDLE; | 1013 | state = OTG_STATE_A_IDLE; |
@@ -1020,7 +1020,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1020 | host_suspend(isp); | 1020 | host_suspend(isp); |
1021 | isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, | 1021 | isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, |
1022 | MC1_BDIS_ACON_EN); | 1022 | MC1_BDIS_ACON_EN); |
1023 | isp->phy.state = OTG_STATE_B_IDLE; | 1023 | isp->phy.otg->state = OTG_STATE_B_IDLE; |
1024 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; | 1024 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; |
1025 | l &= ~OTG_CTRL_BITS; | 1025 | l &= ~OTG_CTRL_BITS; |
1026 | omap_writel(l, OTG_CTRL); | 1026 | omap_writel(l, OTG_CTRL); |
@@ -1031,7 +1031,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1031 | } | 1031 | } |
1032 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); | 1032 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); |
1033 | 1033 | ||
1034 | switch (isp->phy.state) { | 1034 | switch (isp->phy.otg->state) { |
1035 | case OTG_STATE_B_PERIPHERAL: | 1035 | case OTG_STATE_B_PERIPHERAL: |
1036 | case OTG_STATE_B_WAIT_ACON: | 1036 | case OTG_STATE_B_WAIT_ACON: |
1037 | case OTG_STATE_B_HOST: | 1037 | case OTG_STATE_B_HOST: |
@@ -1071,7 +1071,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1071 | } | 1071 | } |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | if (state != isp->phy.state) | 1074 | if (state != isp->phy.otg->state) |
1075 | pr_debug(" isp, %s -> %s\n", | 1075 | pr_debug(" isp, %s -> %s\n", |
1076 | usb_otg_state_string(state), state_name(isp)); | 1076 | usb_otg_state_string(state), state_name(isp)); |
1077 | 1077 | ||
@@ -1129,10 +1129,10 @@ isp1301_work(struct work_struct *work) | |||
1129 | * skip A_WAIT_VRISE; hc transitions invisibly | 1129 | * skip A_WAIT_VRISE; hc transitions invisibly |
1130 | * skip A_WAIT_BCON; same. | 1130 | * skip A_WAIT_BCON; same. |
1131 | */ | 1131 | */ |
1132 | switch (isp->phy.state) { | 1132 | switch (isp->phy.otg->state) { |
1133 | case OTG_STATE_A_WAIT_BCON: | 1133 | case OTG_STATE_A_WAIT_BCON: |
1134 | case OTG_STATE_A_WAIT_VRISE: | 1134 | case OTG_STATE_A_WAIT_VRISE: |
1135 | isp->phy.state = OTG_STATE_A_HOST; | 1135 | isp->phy.otg->state = OTG_STATE_A_HOST; |
1136 | pr_debug(" --> a_host\n"); | 1136 | pr_debug(" --> a_host\n"); |
1137 | otg_ctrl = omap_readl(OTG_CTRL); | 1137 | otg_ctrl = omap_readl(OTG_CTRL); |
1138 | otg_ctrl |= OTG_A_BUSREQ; | 1138 | otg_ctrl |= OTG_A_BUSREQ; |
@@ -1141,7 +1141,7 @@ isp1301_work(struct work_struct *work) | |||
1141 | omap_writel(otg_ctrl, OTG_CTRL); | 1141 | omap_writel(otg_ctrl, OTG_CTRL); |
1142 | break; | 1142 | break; |
1143 | case OTG_STATE_B_WAIT_ACON: | 1143 | case OTG_STATE_B_WAIT_ACON: |
1144 | isp->phy.state = OTG_STATE_B_HOST; | 1144 | isp->phy.otg->state = OTG_STATE_B_HOST; |
1145 | pr_debug(" --> b_host (acon)\n"); | 1145 | pr_debug(" --> b_host (acon)\n"); |
1146 | break; | 1146 | break; |
1147 | case OTG_STATE_B_HOST: | 1147 | case OTG_STATE_B_HOST: |
@@ -1275,7 +1275,7 @@ static int isp1301_otg_enable(struct isp1301 *isp) | |||
1275 | static int | 1275 | static int |
1276 | isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) | 1276 | isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) |
1277 | { | 1277 | { |
1278 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); | 1278 | struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); |
1279 | 1279 | ||
1280 | if (isp != the_transceiver) | 1280 | if (isp != the_transceiver) |
1281 | return -ENODEV; | 1281 | return -ENODEV; |
@@ -1331,7 +1331,7 @@ isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
1331 | static int | 1331 | static int |
1332 | isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) | 1332 | isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) |
1333 | { | 1333 | { |
1334 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); | 1334 | struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); |
1335 | 1335 | ||
1336 | if (isp != the_transceiver) | 1336 | if (isp != the_transceiver) |
1337 | return -ENODEV; | 1337 | return -ENODEV; |
@@ -1368,7 +1368,7 @@ isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) | |||
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | power_up(isp); | 1370 | power_up(isp); |
1371 | isp->phy.state = OTG_STATE_B_IDLE; | 1371 | isp->phy.otg->state = OTG_STATE_B_IDLE; |
1372 | 1372 | ||
1373 | if (machine_is_omap_h2() || machine_is_omap_h3()) | 1373 | if (machine_is_omap_h2() || machine_is_omap_h3()) |
1374 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); | 1374 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); |
@@ -1403,7 +1403,7 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA) | |||
1403 | { | 1403 | { |
1404 | if (!the_transceiver) | 1404 | if (!the_transceiver) |
1405 | return -ENODEV; | 1405 | return -ENODEV; |
1406 | if (dev->state == OTG_STATE_B_PERIPHERAL) | 1406 | if (dev->otg->state == OTG_STATE_B_PERIPHERAL) |
1407 | enable_vbus_draw(the_transceiver, mA); | 1407 | enable_vbus_draw(the_transceiver, mA); |
1408 | return 0; | 1408 | return 0; |
1409 | } | 1409 | } |
@@ -1411,10 +1411,10 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA) | |||
1411 | static int | 1411 | static int |
1412 | isp1301_start_srp(struct usb_otg *otg) | 1412 | isp1301_start_srp(struct usb_otg *otg) |
1413 | { | 1413 | { |
1414 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); | 1414 | struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); |
1415 | u32 otg_ctrl; | 1415 | u32 otg_ctrl; |
1416 | 1416 | ||
1417 | if (isp != the_transceiver || isp->phy.state != OTG_STATE_B_IDLE) | 1417 | if (isp != the_transceiver || isp->phy.otg->state != OTG_STATE_B_IDLE) |
1418 | return -ENODEV; | 1418 | return -ENODEV; |
1419 | 1419 | ||
1420 | otg_ctrl = omap_readl(OTG_CTRL); | 1420 | otg_ctrl = omap_readl(OTG_CTRL); |
@@ -1424,7 +1424,7 @@ isp1301_start_srp(struct usb_otg *otg) | |||
1424 | otg_ctrl |= OTG_B_BUSREQ; | 1424 | otg_ctrl |= OTG_B_BUSREQ; |
1425 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; | 1425 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; |
1426 | omap_writel(otg_ctrl, OTG_CTRL); | 1426 | omap_writel(otg_ctrl, OTG_CTRL); |
1427 | isp->phy.state = OTG_STATE_B_SRP_INIT; | 1427 | isp->phy.otg->state = OTG_STATE_B_SRP_INIT; |
1428 | 1428 | ||
1429 | pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), | 1429 | pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), |
1430 | omap_readl(OTG_CTRL)); | 1430 | omap_readl(OTG_CTRL)); |
@@ -1438,7 +1438,7 @@ static int | |||
1438 | isp1301_start_hnp(struct usb_otg *otg) | 1438 | isp1301_start_hnp(struct usb_otg *otg) |
1439 | { | 1439 | { |
1440 | #ifdef CONFIG_USB_OTG | 1440 | #ifdef CONFIG_USB_OTG |
1441 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); | 1441 | struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); |
1442 | u32 l; | 1442 | u32 l; |
1443 | 1443 | ||
1444 | if (isp != the_transceiver) | 1444 | if (isp != the_transceiver) |
@@ -1452,9 +1452,9 @@ isp1301_start_hnp(struct usb_otg *otg) | |||
1452 | /* We want hardware to manage most HNP protocol timings. | 1452 | /* We want hardware to manage most HNP protocol timings. |
1453 | * So do this part as early as possible... | 1453 | * So do this part as early as possible... |
1454 | */ | 1454 | */ |
1455 | switch (isp->phy.state) { | 1455 | switch (isp->phy.otg->state) { |
1456 | case OTG_STATE_B_HOST: | 1456 | case OTG_STATE_B_HOST: |
1457 | isp->phy.state = OTG_STATE_B_PERIPHERAL; | 1457 | isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
1458 | /* caller will suspend next */ | 1458 | /* caller will suspend next */ |
1459 | break; | 1459 | break; |
1460 | case OTG_STATE_A_HOST: | 1460 | case OTG_STATE_A_HOST: |
@@ -1583,7 +1583,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1583 | isp->phy.label = DRIVER_NAME; | 1583 | isp->phy.label = DRIVER_NAME; |
1584 | isp->phy.set_power = isp1301_set_power, | 1584 | isp->phy.set_power = isp1301_set_power, |
1585 | 1585 | ||
1586 | isp->phy.otg->phy = &isp->phy; | 1586 | isp->phy.otg->usb_phy = &isp->phy; |
1587 | isp->phy.otg->set_host = isp1301_set_host, | 1587 | isp->phy.otg->set_host = isp1301_set_host, |
1588 | isp->phy.otg->set_peripheral = isp1301_set_peripheral, | 1588 | isp->phy.otg->set_peripheral = isp1301_set_peripheral, |
1589 | isp->phy.otg->start_srp = isp1301_start_srp, | 1589 | isp->phy.otg->start_srp = isp1301_start_srp, |
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 7843ef7dd0ff..e120d87778b2 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c | |||
@@ -708,7 +708,7 @@ static void msm_otg_start_host(struct usb_phy *phy, int on) | |||
708 | 708 | ||
709 | static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | 709 | static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
710 | { | 710 | { |
711 | struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy); | 711 | struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy); |
712 | struct usb_hcd *hcd; | 712 | struct usb_hcd *hcd; |
713 | 713 | ||
714 | /* | 714 | /* |
@@ -716,16 +716,16 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
716 | * only peripheral configuration. | 716 | * only peripheral configuration. |
717 | */ | 717 | */ |
718 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) { | 718 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) { |
719 | dev_info(otg->phy->dev, "Host mode is not supported\n"); | 719 | dev_info(otg->usb_phy->dev, "Host mode is not supported\n"); |
720 | return -ENODEV; | 720 | return -ENODEV; |
721 | } | 721 | } |
722 | 722 | ||
723 | if (!host) { | 723 | if (!host) { |
724 | if (otg->phy->state == OTG_STATE_A_HOST) { | 724 | if (otg->state == OTG_STATE_A_HOST) { |
725 | pm_runtime_get_sync(otg->phy->dev); | 725 | pm_runtime_get_sync(otg->usb_phy->dev); |
726 | msm_otg_start_host(otg->phy, 0); | 726 | msm_otg_start_host(otg->usb_phy, 0); |
727 | otg->host = NULL; | 727 | otg->host = NULL; |
728 | otg->phy->state = OTG_STATE_UNDEFINED; | 728 | otg->state = OTG_STATE_UNDEFINED; |
729 | schedule_work(&motg->sm_work); | 729 | schedule_work(&motg->sm_work); |
730 | } else { | 730 | } else { |
731 | otg->host = NULL; | 731 | otg->host = NULL; |
@@ -738,14 +738,14 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
738 | hcd->power_budget = motg->pdata->power_budget; | 738 | hcd->power_budget = motg->pdata->power_budget; |
739 | 739 | ||
740 | otg->host = host; | 740 | otg->host = host; |
741 | dev_dbg(otg->phy->dev, "host driver registered w/ tranceiver\n"); | 741 | dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n"); |
742 | 742 | ||
743 | /* | 743 | /* |
744 | * Kick the state machine work, if peripheral is not supported | 744 | * Kick the state machine work, if peripheral is not supported |
745 | * or peripheral is already registered with us. | 745 | * or peripheral is already registered with us. |
746 | */ | 746 | */ |
747 | if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) { | 747 | if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) { |
748 | pm_runtime_get_sync(otg->phy->dev); | 748 | pm_runtime_get_sync(otg->usb_phy->dev); |
749 | schedule_work(&motg->sm_work); | 749 | schedule_work(&motg->sm_work); |
750 | } | 750 | } |
751 | 751 | ||
@@ -782,23 +782,23 @@ static void msm_otg_start_peripheral(struct usb_phy *phy, int on) | |||
782 | static int msm_otg_set_peripheral(struct usb_otg *otg, | 782 | static int msm_otg_set_peripheral(struct usb_otg *otg, |
783 | struct usb_gadget *gadget) | 783 | struct usb_gadget *gadget) |
784 | { | 784 | { |
785 | struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy); | 785 | struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy); |
786 | 786 | ||
787 | /* | 787 | /* |
788 | * Fail peripheral registration if this board can support | 788 | * Fail peripheral registration if this board can support |
789 | * only host configuration. | 789 | * only host configuration. |
790 | */ | 790 | */ |
791 | if (motg->pdata->mode == USB_DR_MODE_HOST) { | 791 | if (motg->pdata->mode == USB_DR_MODE_HOST) { |
792 | dev_info(otg->phy->dev, "Peripheral mode is not supported\n"); | 792 | dev_info(otg->usb_phy->dev, "Peripheral mode is not supported\n"); |
793 | return -ENODEV; | 793 | return -ENODEV; |
794 | } | 794 | } |
795 | 795 | ||
796 | if (!gadget) { | 796 | if (!gadget) { |
797 | if (otg->phy->state == OTG_STATE_B_PERIPHERAL) { | 797 | if (otg->state == OTG_STATE_B_PERIPHERAL) { |
798 | pm_runtime_get_sync(otg->phy->dev); | 798 | pm_runtime_get_sync(otg->usb_phy->dev); |
799 | msm_otg_start_peripheral(otg->phy, 0); | 799 | msm_otg_start_peripheral(otg->usb_phy, 0); |
800 | otg->gadget = NULL; | 800 | otg->gadget = NULL; |
801 | otg->phy->state = OTG_STATE_UNDEFINED; | 801 | otg->state = OTG_STATE_UNDEFINED; |
802 | schedule_work(&motg->sm_work); | 802 | schedule_work(&motg->sm_work); |
803 | } else { | 803 | } else { |
804 | otg->gadget = NULL; | 804 | otg->gadget = NULL; |
@@ -807,14 +807,15 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, | |||
807 | return 0; | 807 | return 0; |
808 | } | 808 | } |
809 | otg->gadget = gadget; | 809 | otg->gadget = gadget; |
810 | dev_dbg(otg->phy->dev, "peripheral driver registered w/ tranceiver\n"); | 810 | dev_dbg(otg->usb_phy->dev, |
811 | "peripheral driver registered w/ tranceiver\n"); | ||
811 | 812 | ||
812 | /* | 813 | /* |
813 | * Kick the state machine work, if host is not supported | 814 | * Kick the state machine work, if host is not supported |
814 | * or host is already registered with us. | 815 | * or host is already registered with us. |
815 | */ | 816 | */ |
816 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) { | 817 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) { |
817 | pm_runtime_get_sync(otg->phy->dev); | 818 | pm_runtime_get_sync(otg->usb_phy->dev); |
818 | schedule_work(&motg->sm_work); | 819 | schedule_work(&motg->sm_work); |
819 | } | 820 | } |
820 | 821 | ||
@@ -1170,20 +1171,20 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1170 | struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); | 1171 | struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); |
1171 | struct usb_otg *otg = motg->phy.otg; | 1172 | struct usb_otg *otg = motg->phy.otg; |
1172 | 1173 | ||
1173 | switch (otg->phy->state) { | 1174 | switch (otg->state) { |
1174 | case OTG_STATE_UNDEFINED: | 1175 | case OTG_STATE_UNDEFINED: |
1175 | dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n"); | 1176 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n"); |
1176 | msm_otg_reset(otg->phy); | 1177 | msm_otg_reset(otg->usb_phy); |
1177 | msm_otg_init_sm(motg); | 1178 | msm_otg_init_sm(motg); |
1178 | otg->phy->state = OTG_STATE_B_IDLE; | 1179 | otg->state = OTG_STATE_B_IDLE; |
1179 | /* FALL THROUGH */ | 1180 | /* FALL THROUGH */ |
1180 | case OTG_STATE_B_IDLE: | 1181 | case OTG_STATE_B_IDLE: |
1181 | dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n"); | 1182 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n"); |
1182 | if (!test_bit(ID, &motg->inputs) && otg->host) { | 1183 | if (!test_bit(ID, &motg->inputs) && otg->host) { |
1183 | /* disable BSV bit */ | 1184 | /* disable BSV bit */ |
1184 | writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); | 1185 | writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); |
1185 | msm_otg_start_host(otg->phy, 1); | 1186 | msm_otg_start_host(otg->usb_phy, 1); |
1186 | otg->phy->state = OTG_STATE_A_HOST; | 1187 | otg->state = OTG_STATE_A_HOST; |
1187 | } else if (test_bit(B_SESS_VLD, &motg->inputs)) { | 1188 | } else if (test_bit(B_SESS_VLD, &motg->inputs)) { |
1188 | switch (motg->chg_state) { | 1189 | switch (motg->chg_state) { |
1189 | case USB_CHG_STATE_UNDEFINED: | 1190 | case USB_CHG_STATE_UNDEFINED: |
@@ -1198,14 +1199,16 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1198 | case USB_CDP_CHARGER: | 1199 | case USB_CDP_CHARGER: |
1199 | msm_otg_notify_charger(motg, | 1200 | msm_otg_notify_charger(motg, |
1200 | IDEV_CHG_MAX); | 1201 | IDEV_CHG_MAX); |
1201 | msm_otg_start_peripheral(otg->phy, 1); | 1202 | msm_otg_start_peripheral(otg->usb_phy, |
1202 | otg->phy->state | 1203 | 1); |
1204 | otg->state | ||
1203 | = OTG_STATE_B_PERIPHERAL; | 1205 | = OTG_STATE_B_PERIPHERAL; |
1204 | break; | 1206 | break; |
1205 | case USB_SDP_CHARGER: | 1207 | case USB_SDP_CHARGER: |
1206 | msm_otg_notify_charger(motg, IUNIT); | 1208 | msm_otg_notify_charger(motg, IUNIT); |
1207 | msm_otg_start_peripheral(otg->phy, 1); | 1209 | msm_otg_start_peripheral(otg->usb_phy, |
1208 | otg->phy->state | 1210 | 1); |
1211 | otg->state | ||
1209 | = OTG_STATE_B_PERIPHERAL; | 1212 | = OTG_STATE_B_PERIPHERAL; |
1210 | break; | 1213 | break; |
1211 | default: | 1214 | default: |
@@ -1222,36 +1225,36 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1222 | * is incremented in charger detection work. | 1225 | * is incremented in charger detection work. |
1223 | */ | 1226 | */ |
1224 | if (cancel_delayed_work_sync(&motg->chg_work)) { | 1227 | if (cancel_delayed_work_sync(&motg->chg_work)) { |
1225 | pm_runtime_put_sync(otg->phy->dev); | 1228 | pm_runtime_put_sync(otg->usb_phy->dev); |
1226 | msm_otg_reset(otg->phy); | 1229 | msm_otg_reset(otg->usb_phy); |
1227 | } | 1230 | } |
1228 | msm_otg_notify_charger(motg, 0); | 1231 | msm_otg_notify_charger(motg, 0); |
1229 | motg->chg_state = USB_CHG_STATE_UNDEFINED; | 1232 | motg->chg_state = USB_CHG_STATE_UNDEFINED; |
1230 | motg->chg_type = USB_INVALID_CHARGER; | 1233 | motg->chg_type = USB_INVALID_CHARGER; |
1231 | } | 1234 | } |
1232 | 1235 | ||
1233 | if (otg->phy->state == OTG_STATE_B_IDLE) | 1236 | if (otg->state == OTG_STATE_B_IDLE) |
1234 | pm_runtime_put_sync(otg->phy->dev); | 1237 | pm_runtime_put_sync(otg->usb_phy->dev); |
1235 | break; | 1238 | break; |
1236 | case OTG_STATE_B_PERIPHERAL: | 1239 | case OTG_STATE_B_PERIPHERAL: |
1237 | dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n"); | 1240 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n"); |
1238 | if (!test_bit(B_SESS_VLD, &motg->inputs) || | 1241 | if (!test_bit(B_SESS_VLD, &motg->inputs) || |
1239 | !test_bit(ID, &motg->inputs)) { | 1242 | !test_bit(ID, &motg->inputs)) { |
1240 | msm_otg_notify_charger(motg, 0); | 1243 | msm_otg_notify_charger(motg, 0); |
1241 | msm_otg_start_peripheral(otg->phy, 0); | 1244 | msm_otg_start_peripheral(otg->usb_phy, 0); |
1242 | motg->chg_state = USB_CHG_STATE_UNDEFINED; | 1245 | motg->chg_state = USB_CHG_STATE_UNDEFINED; |
1243 | motg->chg_type = USB_INVALID_CHARGER; | 1246 | motg->chg_type = USB_INVALID_CHARGER; |
1244 | otg->phy->state = OTG_STATE_B_IDLE; | 1247 | otg->state = OTG_STATE_B_IDLE; |
1245 | msm_otg_reset(otg->phy); | 1248 | msm_otg_reset(otg->usb_phy); |
1246 | schedule_work(w); | 1249 | schedule_work(w); |
1247 | } | 1250 | } |
1248 | break; | 1251 | break; |
1249 | case OTG_STATE_A_HOST: | 1252 | case OTG_STATE_A_HOST: |
1250 | dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n"); | 1253 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n"); |
1251 | if (test_bit(ID, &motg->inputs)) { | 1254 | if (test_bit(ID, &motg->inputs)) { |
1252 | msm_otg_start_host(otg->phy, 0); | 1255 | msm_otg_start_host(otg->usb_phy, 0); |
1253 | otg->phy->state = OTG_STATE_B_IDLE; | 1256 | otg->state = OTG_STATE_B_IDLE; |
1254 | msm_otg_reset(otg->phy); | 1257 | msm_otg_reset(otg->usb_phy); |
1255 | schedule_work(w); | 1258 | schedule_work(w); |
1256 | } | 1259 | } |
1257 | break; | 1260 | break; |
@@ -1303,7 +1306,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused) | |||
1303 | struct msm_otg *motg = s->private; | 1306 | struct msm_otg *motg = s->private; |
1304 | struct usb_otg *otg = motg->phy.otg; | 1307 | struct usb_otg *otg = motg->phy.otg; |
1305 | 1308 | ||
1306 | switch (otg->phy->state) { | 1309 | switch (otg->state) { |
1307 | case OTG_STATE_A_HOST: | 1310 | case OTG_STATE_A_HOST: |
1308 | seq_puts(s, "host\n"); | 1311 | seq_puts(s, "host\n"); |
1309 | break; | 1312 | break; |
@@ -1353,7 +1356,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1353 | 1356 | ||
1354 | switch (req_mode) { | 1357 | switch (req_mode) { |
1355 | case USB_DR_MODE_UNKNOWN: | 1358 | case USB_DR_MODE_UNKNOWN: |
1356 | switch (otg->phy->state) { | 1359 | switch (otg->state) { |
1357 | case OTG_STATE_A_HOST: | 1360 | case OTG_STATE_A_HOST: |
1358 | case OTG_STATE_B_PERIPHERAL: | 1361 | case OTG_STATE_B_PERIPHERAL: |
1359 | set_bit(ID, &motg->inputs); | 1362 | set_bit(ID, &motg->inputs); |
@@ -1364,7 +1367,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1364 | } | 1367 | } |
1365 | break; | 1368 | break; |
1366 | case USB_DR_MODE_PERIPHERAL: | 1369 | case USB_DR_MODE_PERIPHERAL: |
1367 | switch (otg->phy->state) { | 1370 | switch (otg->state) { |
1368 | case OTG_STATE_B_IDLE: | 1371 | case OTG_STATE_B_IDLE: |
1369 | case OTG_STATE_A_HOST: | 1372 | case OTG_STATE_A_HOST: |
1370 | set_bit(ID, &motg->inputs); | 1373 | set_bit(ID, &motg->inputs); |
@@ -1375,7 +1378,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1375 | } | 1378 | } |
1376 | break; | 1379 | break; |
1377 | case USB_DR_MODE_HOST: | 1380 | case USB_DR_MODE_HOST: |
1378 | switch (otg->phy->state) { | 1381 | switch (otg->state) { |
1379 | case OTG_STATE_B_IDLE: | 1382 | case OTG_STATE_B_IDLE: |
1380 | case OTG_STATE_B_PERIPHERAL: | 1383 | case OTG_STATE_B_PERIPHERAL: |
1381 | clear_bit(ID, &motg->inputs); | 1384 | clear_bit(ID, &motg->inputs); |
@@ -1388,7 +1391,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1388 | goto out; | 1391 | goto out; |
1389 | } | 1392 | } |
1390 | 1393 | ||
1391 | pm_runtime_get_sync(otg->phy->dev); | 1394 | pm_runtime_get_sync(otg->usb_phy->dev); |
1392 | schedule_work(&motg->sm_work); | 1395 | schedule_work(&motg->sm_work); |
1393 | out: | 1396 | out: |
1394 | return status; | 1397 | return status; |
@@ -1505,10 +1508,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1505 | } | 1508 | } |
1506 | 1509 | ||
1507 | pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); | 1510 | pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); |
1508 | if (!pdata->phy_init_seq) { | 1511 | if (!pdata->phy_init_seq) |
1509 | dev_warn(&pdev->dev, "No space for PHY init sequence\n"); | ||
1510 | return 0; | 1512 | return 0; |
1511 | } | ||
1512 | 1513 | ||
1513 | ret = of_property_read_u32_array(node, "qcom,phy-init-sequence", | 1514 | ret = of_property_read_u32_array(node, "qcom,phy-init-sequence", |
1514 | pdata->phy_init_seq, words); | 1515 | pdata->phy_init_seq, words); |
@@ -1530,10 +1531,8 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1530 | void __iomem *phy_select; | 1531 | void __iomem *phy_select; |
1531 | 1532 | ||
1532 | motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL); | 1533 | motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL); |
1533 | if (!motg) { | 1534 | if (!motg) |
1534 | dev_err(&pdev->dev, "unable to allocate msm_otg\n"); | ||
1535 | return -ENOMEM; | 1535 | return -ENOMEM; |
1536 | } | ||
1537 | 1536 | ||
1538 | pdata = dev_get_platdata(&pdev->dev); | 1537 | pdata = dev_get_platdata(&pdev->dev); |
1539 | if (!pdata) { | 1538 | if (!pdata) { |
@@ -1546,10 +1545,8 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1546 | 1545 | ||
1547 | motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), | 1546 | motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), |
1548 | GFP_KERNEL); | 1547 | GFP_KERNEL); |
1549 | if (!motg->phy.otg) { | 1548 | if (!motg->phy.otg) |
1550 | dev_err(&pdev->dev, "unable to allocate msm_otg\n"); | ||
1551 | return -ENOMEM; | 1549 | return -ENOMEM; |
1552 | } | ||
1553 | 1550 | ||
1554 | phy = &motg->phy; | 1551 | phy = &motg->phy; |
1555 | phy->dev = &pdev->dev; | 1552 | phy->dev = &pdev->dev; |
@@ -1674,7 +1671,7 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1674 | 1671 | ||
1675 | phy->io_ops = &msm_otg_io_ops; | 1672 | phy->io_ops = &msm_otg_io_ops; |
1676 | 1673 | ||
1677 | phy->otg->phy = &motg->phy; | 1674 | phy->otg->usb_phy = &motg->phy; |
1678 | phy->otg->set_host = msm_otg_set_host; | 1675 | phy->otg->set_host = msm_otg_set_host; |
1679 | phy->otg->set_peripheral = msm_otg_set_peripheral; | 1676 | phy->otg->set_peripheral = msm_otg_set_peripheral; |
1680 | 1677 | ||
@@ -1775,7 +1772,7 @@ static int msm_otg_runtime_idle(struct device *dev) | |||
1775 | * This 1 sec delay also prevents entering into LPM immediately | 1772 | * This 1 sec delay also prevents entering into LPM immediately |
1776 | * after asynchronous interrupt. | 1773 | * after asynchronous interrupt. |
1777 | */ | 1774 | */ |
1778 | if (otg->phy->state != OTG_STATE_UNDEFINED) | 1775 | if (otg->state != OTG_STATE_UNDEFINED) |
1779 | pm_schedule_suspend(dev, 1000); | 1776 | pm_schedule_suspend(dev, 1000); |
1780 | 1777 | ||
1781 | return -EAGAIN; | 1778 | return -EAGAIN; |
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index 7d80c54f0ac6..b234d46cd58b 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c | |||
@@ -56,7 +56,7 @@ static char *state_string[] = { | |||
56 | 56 | ||
57 | static int mv_otg_set_vbus(struct usb_otg *otg, bool on) | 57 | static int mv_otg_set_vbus(struct usb_otg *otg, bool on) |
58 | { | 58 | { |
59 | struct mv_otg *mvotg = container_of(otg->phy, struct mv_otg, phy); | 59 | struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy); |
60 | if (mvotg->pdata->set_vbus == NULL) | 60 | if (mvotg->pdata->set_vbus == NULL) |
61 | return -ENODEV; | 61 | return -ENODEV; |
62 | 62 | ||
@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg) | |||
339 | { | 339 | { |
340 | struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; | 340 | struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; |
341 | struct usb_phy *phy = &mvotg->phy; | 341 | struct usb_phy *phy = &mvotg->phy; |
342 | int old_state = phy->state; | 342 | int old_state = mvotg->phy.otg->state; |
343 | 343 | ||
344 | switch (old_state) { | 344 | switch (old_state) { |
345 | case OTG_STATE_UNDEFINED: | 345 | case OTG_STATE_UNDEFINED: |
346 | phy->state = OTG_STATE_B_IDLE; | 346 | mvotg->phy.otg->state = OTG_STATE_B_IDLE; |
347 | /* FALL THROUGH */ | 347 | /* FALL THROUGH */ |
348 | case OTG_STATE_B_IDLE: | 348 | case OTG_STATE_B_IDLE: |
349 | if (otg_ctrl->id == 0) | 349 | if (otg_ctrl->id == 0) |
350 | phy->state = OTG_STATE_A_IDLE; | 350 | mvotg->phy.otg->state = OTG_STATE_A_IDLE; |
351 | else if (otg_ctrl->b_sess_vld) | 351 | else if (otg_ctrl->b_sess_vld) |
352 | phy->state = OTG_STATE_B_PERIPHERAL; | 352 | mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
353 | break; | 353 | break; |
354 | case OTG_STATE_B_PERIPHERAL: | 354 | case OTG_STATE_B_PERIPHERAL: |
355 | if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) | 355 | if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) |
356 | phy->state = OTG_STATE_B_IDLE; | 356 | mvotg->phy.otg->state = OTG_STATE_B_IDLE; |
357 | break; | 357 | break; |
358 | case OTG_STATE_A_IDLE: | 358 | case OTG_STATE_A_IDLE: |
359 | if (otg_ctrl->id) | 359 | if (otg_ctrl->id) |
360 | phy->state = OTG_STATE_B_IDLE; | 360 | mvotg->phy.otg->state = OTG_STATE_B_IDLE; |
361 | else if (!(otg_ctrl->a_bus_drop) && | 361 | else if (!(otg_ctrl->a_bus_drop) && |
362 | (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) | 362 | (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) |
363 | phy->state = OTG_STATE_A_WAIT_VRISE; | 363 | mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE; |
364 | break; | 364 | break; |
365 | case OTG_STATE_A_WAIT_VRISE: | 365 | case OTG_STATE_A_WAIT_VRISE: |
366 | if (otg_ctrl->a_vbus_vld) | 366 | if (otg_ctrl->a_vbus_vld) |
367 | phy->state = OTG_STATE_A_WAIT_BCON; | 367 | mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON; |
368 | break; | 368 | break; |
369 | case OTG_STATE_A_WAIT_BCON: | 369 | case OTG_STATE_A_WAIT_BCON: |
370 | if (otg_ctrl->id || otg_ctrl->a_bus_drop | 370 | if (otg_ctrl->id || otg_ctrl->a_bus_drop |
371 | || otg_ctrl->a_wait_bcon_timeout) { | 371 | || otg_ctrl->a_wait_bcon_timeout) { |
372 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | 372 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); |
373 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | 373 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; |
374 | phy->state = OTG_STATE_A_WAIT_VFALL; | 374 | mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL; |
375 | otg_ctrl->a_bus_req = 0; | 375 | otg_ctrl->a_bus_req = 0; |
376 | } else if (!otg_ctrl->a_vbus_vld) { | 376 | } else if (!otg_ctrl->a_vbus_vld) { |
377 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | 377 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); |
378 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | 378 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; |
379 | phy->state = OTG_STATE_A_VBUS_ERR; | 379 | mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR; |
380 | } else if (otg_ctrl->b_conn) { | 380 | } else if (otg_ctrl->b_conn) { |
381 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | 381 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); |
382 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | 382 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; |
383 | phy->state = OTG_STATE_A_HOST; | 383 | mvotg->phy.otg->state = OTG_STATE_A_HOST; |
384 | } | 384 | } |
385 | break; | 385 | break; |
386 | case OTG_STATE_A_HOST: | 386 | case OTG_STATE_A_HOST: |
387 | if (otg_ctrl->id || !otg_ctrl->b_conn | 387 | if (otg_ctrl->id || !otg_ctrl->b_conn |
388 | || otg_ctrl->a_bus_drop) | 388 | || otg_ctrl->a_bus_drop) |
389 | phy->state = OTG_STATE_A_WAIT_BCON; | 389 | mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON; |
390 | else if (!otg_ctrl->a_vbus_vld) | 390 | else if (!otg_ctrl->a_vbus_vld) |
391 | phy->state = OTG_STATE_A_VBUS_ERR; | 391 | mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR; |
392 | break; | 392 | break; |
393 | case OTG_STATE_A_WAIT_VFALL: | 393 | case OTG_STATE_A_WAIT_VFALL: |
394 | if (otg_ctrl->id | 394 | if (otg_ctrl->id |
395 | || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) | 395 | || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) |
396 | || otg_ctrl->a_bus_req) | 396 | || otg_ctrl->a_bus_req) |
397 | phy->state = OTG_STATE_A_IDLE; | 397 | mvotg->phy.otg->state = OTG_STATE_A_IDLE; |
398 | break; | 398 | break; |
399 | case OTG_STATE_A_VBUS_ERR: | 399 | case OTG_STATE_A_VBUS_ERR: |
400 | if (otg_ctrl->id || otg_ctrl->a_clr_err | 400 | if (otg_ctrl->id || otg_ctrl->a_clr_err |
401 | || otg_ctrl->a_bus_drop) { | 401 | || otg_ctrl->a_bus_drop) { |
402 | otg_ctrl->a_clr_err = 0; | 402 | otg_ctrl->a_clr_err = 0; |
403 | phy->state = OTG_STATE_A_WAIT_VFALL; | 403 | mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL; |
404 | } | 404 | } |
405 | break; | 405 | break; |
406 | default: | 406 | default: |
@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work) | |||
420 | run: | 420 | run: |
421 | /* work queue is single thread, or we need spin_lock to protect */ | 421 | /* work queue is single thread, or we need spin_lock to protect */ |
422 | phy = &mvotg->phy; | 422 | phy = &mvotg->phy; |
423 | otg = phy->otg; | 423 | otg = mvotg->phy.otg; |
424 | old_state = phy->state; | 424 | old_state = otg->state; |
425 | 425 | ||
426 | if (!mvotg->active) | 426 | if (!mvotg->active) |
427 | return; | 427 | return; |
@@ -429,22 +429,24 @@ run: | |||
429 | mv_otg_update_inputs(mvotg); | 429 | mv_otg_update_inputs(mvotg); |
430 | mv_otg_update_state(mvotg); | 430 | mv_otg_update_state(mvotg); |
431 | 431 | ||
432 | if (old_state != phy->state) { | 432 | if (old_state != mvotg->phy.otg->state) { |
433 | dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", | 433 | dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", |
434 | state_string[old_state], | 434 | state_string[old_state], |
435 | state_string[phy->state]); | 435 | state_string[mvotg->phy.otg->state]); |
436 | 436 | ||
437 | switch (phy->state) { | 437 | switch (mvotg->phy.otg->state) { |
438 | case OTG_STATE_B_IDLE: | 438 | case OTG_STATE_B_IDLE: |
439 | otg->default_a = 0; | 439 | otg->default_a = 0; |
440 | if (old_state == OTG_STATE_B_PERIPHERAL) | 440 | if (old_state == OTG_STATE_B_PERIPHERAL) |
441 | mv_otg_start_periphrals(mvotg, 0); | 441 | mv_otg_start_periphrals(mvotg, 0); |
442 | mv_otg_reset(mvotg); | 442 | mv_otg_reset(mvotg); |
443 | mv_otg_disable(mvotg); | 443 | mv_otg_disable(mvotg); |
444 | usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE); | ||
444 | break; | 445 | break; |
445 | case OTG_STATE_B_PERIPHERAL: | 446 | case OTG_STATE_B_PERIPHERAL: |
446 | mv_otg_enable(mvotg); | 447 | mv_otg_enable(mvotg); |
447 | mv_otg_start_periphrals(mvotg, 1); | 448 | mv_otg_start_periphrals(mvotg, 1); |
449 | usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED); | ||
448 | break; | 450 | break; |
449 | case OTG_STATE_A_IDLE: | 451 | case OTG_STATE_A_IDLE: |
450 | otg->default_a = 1; | 452 | otg->default_a = 1; |
@@ -545,8 +547,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr, | |||
545 | return -1; | 547 | return -1; |
546 | 548 | ||
547 | /* We will use this interface to change to A device */ | 549 | /* We will use this interface to change to A device */ |
548 | if (mvotg->phy.state != OTG_STATE_B_IDLE | 550 | if (mvotg->phy.otg->state != OTG_STATE_B_IDLE |
549 | && mvotg->phy.state != OTG_STATE_A_IDLE) | 551 | && mvotg->phy.otg->state != OTG_STATE_A_IDLE) |
550 | return -1; | 552 | return -1; |
551 | 553 | ||
552 | /* The clock may disabled and we need to set irq for ID detected */ | 554 | /* The clock may disabled and we need to set irq for ID detected */ |
@@ -686,10 +688,8 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
686 | } | 688 | } |
687 | 689 | ||
688 | mvotg = devm_kzalloc(&pdev->dev, sizeof(*mvotg), GFP_KERNEL); | 690 | mvotg = devm_kzalloc(&pdev->dev, sizeof(*mvotg), GFP_KERNEL); |
689 | if (!mvotg) { | 691 | if (!mvotg) |
690 | dev_err(&pdev->dev, "failed to allocate memory!\n"); | ||
691 | return -ENOMEM; | 692 | return -ENOMEM; |
692 | } | ||
693 | 693 | ||
694 | otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); | 694 | otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); |
695 | if (!otg) | 695 | if (!otg) |
@@ -717,9 +717,9 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
717 | mvotg->phy.dev = &pdev->dev; | 717 | mvotg->phy.dev = &pdev->dev; |
718 | mvotg->phy.otg = otg; | 718 | mvotg->phy.otg = otg; |
719 | mvotg->phy.label = driver_name; | 719 | mvotg->phy.label = driver_name; |
720 | mvotg->phy.state = OTG_STATE_UNDEFINED; | ||
721 | 720 | ||
722 | otg->phy = &mvotg->phy; | 721 | otg->state = OTG_STATE_UNDEFINED; |
722 | otg->usb_phy = &mvotg->phy; | ||
723 | otg->set_host = mv_otg_set_host; | 723 | otg->set_host = mv_otg_set_host; |
724 | otg->set_peripheral = mv_otg_set_peripheral; | 724 | otg->set_peripheral = mv_otg_set_peripheral; |
725 | otg->set_vbus = mv_otg_set_vbus; | 725 | otg->set_vbus = mv_otg_set_vbus; |
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 0e0c41587a08..a55dadcd47f3 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c | |||
@@ -390,10 +390,8 @@ static int mxs_phy_probe(struct platform_device *pdev) | |||
390 | } | 390 | } |
391 | 391 | ||
392 | mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); | 392 | mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); |
393 | if (!mxs_phy) { | 393 | if (!mxs_phy) |
394 | dev_err(&pdev->dev, "Failed to allocate USB PHY structure!\n"); | ||
395 | return -ENOMEM; | 394 | return -ENOMEM; |
396 | } | ||
397 | 395 | ||
398 | /* Some SoCs don't have anatop registers */ | 396 | /* Some SoCs don't have anatop registers */ |
399 | if (of_get_property(np, "fsl,anatop", NULL)) { | 397 | if (of_get_property(np, "fsl,anatop", NULL)) { |
diff --git a/drivers/usb/phy/phy-rcar-gen2-usb.c b/drivers/usb/phy/phy-rcar-gen2-usb.c index 388d89f6b141..f83808413ba2 100644 --- a/drivers/usb/phy/phy-rcar-gen2-usb.c +++ b/drivers/usb/phy/phy-rcar-gen2-usb.c | |||
@@ -195,10 +195,8 @@ static int rcar_gen2_usb_phy_probe(struct platform_device *pdev) | |||
195 | return PTR_ERR(base); | 195 | return PTR_ERR(base); |
196 | 196 | ||
197 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | 197 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
198 | if (!priv) { | 198 | if (!priv) |
199 | dev_err(dev, "Memory allocation failed\n"); | ||
200 | return -ENOMEM; | 199 | return -ENOMEM; |
201 | } | ||
202 | 200 | ||
203 | spin_lock_init(&priv->lock); | 201 | spin_lock_init(&priv->lock); |
204 | priv->clk = clk; | 202 | priv->clk = clk; |
diff --git a/drivers/usb/phy/phy-rcar-usb.c b/drivers/usb/phy/phy-rcar-usb.c index e9f3a93e42b7..1e09b8377885 100644 --- a/drivers/usb/phy/phy-rcar-usb.c +++ b/drivers/usb/phy/phy-rcar-usb.c | |||
@@ -200,10 +200,8 @@ static int rcar_usb_phy_probe(struct platform_device *pdev) | |||
200 | return PTR_ERR(reg1); | 200 | return PTR_ERR(reg1); |
201 | 201 | ||
202 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | 202 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
203 | if (!priv) { | 203 | if (!priv) |
204 | dev_err(dev, "priv data allocation error\n"); | ||
205 | return -ENOMEM; | 204 | return -ENOMEM; |
206 | } | ||
207 | 205 | ||
208 | priv->reg0 = reg0; | 206 | priv->reg0 = reg0; |
209 | priv->reg1 = reg1; | 207 | priv->reg1 = reg1; |
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c index cc61ee44b911..d391c79a542a 100644 --- a/drivers/usb/phy/phy-tahvo.c +++ b/drivers/usb/phy/phy-tahvo.c | |||
@@ -81,33 +81,35 @@ static void check_vbus_state(struct tahvo_usb *tu) | |||
81 | 81 | ||
82 | reg = retu_read(rdev, TAHVO_REG_IDSR); | 82 | reg = retu_read(rdev, TAHVO_REG_IDSR); |
83 | if (reg & TAHVO_STAT_VBUS) { | 83 | if (reg & TAHVO_STAT_VBUS) { |
84 | switch (tu->phy.state) { | 84 | switch (tu->phy.otg->state) { |
85 | case OTG_STATE_B_IDLE: | 85 | case OTG_STATE_B_IDLE: |
86 | /* Enable the gadget driver */ | 86 | /* Enable the gadget driver */ |
87 | if (tu->phy.otg->gadget) | 87 | if (tu->phy.otg->gadget) |
88 | usb_gadget_vbus_connect(tu->phy.otg->gadget); | 88 | usb_gadget_vbus_connect(tu->phy.otg->gadget); |
89 | tu->phy.state = OTG_STATE_B_PERIPHERAL; | 89 | tu->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
90 | usb_phy_set_event(&tu->phy, USB_EVENT_ENUMERATED); | ||
90 | break; | 91 | break; |
91 | case OTG_STATE_A_IDLE: | 92 | case OTG_STATE_A_IDLE: |
92 | /* | 93 | /* |
93 | * Session is now valid assuming the USB hub is driving | 94 | * Session is now valid assuming the USB hub is driving |
94 | * Vbus. | 95 | * Vbus. |
95 | */ | 96 | */ |
96 | tu->phy.state = OTG_STATE_A_HOST; | 97 | tu->phy.otg->state = OTG_STATE_A_HOST; |
97 | break; | 98 | break; |
98 | default: | 99 | default: |
99 | break; | 100 | break; |
100 | } | 101 | } |
101 | dev_info(&tu->pt_dev->dev, "USB cable connected\n"); | 102 | dev_info(&tu->pt_dev->dev, "USB cable connected\n"); |
102 | } else { | 103 | } else { |
103 | switch (tu->phy.state) { | 104 | switch (tu->phy.otg->state) { |
104 | case OTG_STATE_B_PERIPHERAL: | 105 | case OTG_STATE_B_PERIPHERAL: |
105 | if (tu->phy.otg->gadget) | 106 | if (tu->phy.otg->gadget) |
106 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); | 107 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); |
107 | tu->phy.state = OTG_STATE_B_IDLE; | 108 | tu->phy.otg->state = OTG_STATE_B_IDLE; |
109 | usb_phy_set_event(&tu->phy, USB_EVENT_NONE); | ||
108 | break; | 110 | break; |
109 | case OTG_STATE_A_HOST: | 111 | case OTG_STATE_A_HOST: |
110 | tu->phy.state = OTG_STATE_A_IDLE; | 112 | tu->phy.otg->state = OTG_STATE_A_IDLE; |
111 | break; | 113 | break; |
112 | default: | 114 | default: |
113 | break; | 115 | break; |
@@ -132,14 +134,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu) | |||
132 | /* Power up the transceiver in USB host mode */ | 134 | /* Power up the transceiver in USB host mode */ |
133 | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | | 135 | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | |
134 | USBR_MASTER_SW2 | USBR_MASTER_SW1); | 136 | USBR_MASTER_SW2 | USBR_MASTER_SW1); |
135 | tu->phy.state = OTG_STATE_A_IDLE; | 137 | tu->phy.otg->state = OTG_STATE_A_IDLE; |
136 | 138 | ||
137 | check_vbus_state(tu); | 139 | check_vbus_state(tu); |
138 | } | 140 | } |
139 | 141 | ||
140 | static void tahvo_usb_stop_host(struct tahvo_usb *tu) | 142 | static void tahvo_usb_stop_host(struct tahvo_usb *tu) |
141 | { | 143 | { |
142 | tu->phy.state = OTG_STATE_A_IDLE; | 144 | tu->phy.otg->state = OTG_STATE_A_IDLE; |
143 | } | 145 | } |
144 | 146 | ||
145 | static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) | 147 | static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) |
@@ -151,7 +153,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) | |||
151 | /* Power up transceiver and set it in USB peripheral mode */ | 153 | /* Power up transceiver and set it in USB peripheral mode */ |
152 | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | | 154 | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | |
153 | USBR_NSUSPEND | USBR_SLAVE_SW); | 155 | USBR_NSUSPEND | USBR_SLAVE_SW); |
154 | tu->phy.state = OTG_STATE_B_IDLE; | 156 | tu->phy.otg->state = OTG_STATE_B_IDLE; |
155 | 157 | ||
156 | check_vbus_state(tu); | 158 | check_vbus_state(tu); |
157 | } | 159 | } |
@@ -160,7 +162,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu) | |||
160 | { | 162 | { |
161 | if (tu->phy.otg->gadget) | 163 | if (tu->phy.otg->gadget) |
162 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); | 164 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); |
163 | tu->phy.state = OTG_STATE_B_IDLE; | 165 | tu->phy.otg->state = OTG_STATE_B_IDLE; |
164 | } | 166 | } |
165 | 167 | ||
166 | static void tahvo_usb_power_off(struct tahvo_usb *tu) | 168 | static void tahvo_usb_power_off(struct tahvo_usb *tu) |
@@ -173,7 +175,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu) | |||
173 | 175 | ||
174 | /* Power off transceiver */ | 176 | /* Power off transceiver */ |
175 | retu_write(rdev, TAHVO_REG_USBR, 0); | 177 | retu_write(rdev, TAHVO_REG_USBR, 0); |
176 | tu->phy.state = OTG_STATE_UNDEFINED; | 178 | tu->phy.otg->state = OTG_STATE_UNDEFINED; |
177 | } | 179 | } |
178 | 180 | ||
179 | static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) | 181 | static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) |
@@ -196,7 +198,8 @@ static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) | |||
196 | 198 | ||
197 | static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | 199 | static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host) |
198 | { | 200 | { |
199 | struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy); | 201 | struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb, |
202 | phy); | ||
200 | 203 | ||
201 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, host); | 204 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, host); |
202 | 205 | ||
@@ -225,7 +228,8 @@ static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
225 | static int tahvo_usb_set_peripheral(struct usb_otg *otg, | 228 | static int tahvo_usb_set_peripheral(struct usb_otg *otg, |
226 | struct usb_gadget *gadget) | 229 | struct usb_gadget *gadget) |
227 | { | 230 | { |
228 | struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy); | 231 | struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb, |
232 | phy); | ||
229 | 233 | ||
230 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, gadget); | 234 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, gadget); |
231 | 235 | ||
@@ -379,11 +383,11 @@ static int tahvo_usb_probe(struct platform_device *pdev) | |||
379 | /* Create OTG interface */ | 383 | /* Create OTG interface */ |
380 | tahvo_usb_power_off(tu); | 384 | tahvo_usb_power_off(tu); |
381 | tu->phy.dev = &pdev->dev; | 385 | tu->phy.dev = &pdev->dev; |
382 | tu->phy.state = OTG_STATE_UNDEFINED; | 386 | tu->phy.otg->state = OTG_STATE_UNDEFINED; |
383 | tu->phy.label = DRIVER_NAME; | 387 | tu->phy.label = DRIVER_NAME; |
384 | tu->phy.set_suspend = tahvo_usb_set_suspend; | 388 | tu->phy.set_suspend = tahvo_usb_set_suspend; |
385 | 389 | ||
386 | tu->phy.otg->phy = &tu->phy; | 390 | tu->phy.otg->usb_phy = &tu->phy; |
387 | tu->phy.otg->set_host = tahvo_usb_set_host; | 391 | tu->phy.otg->set_host = tahvo_usb_set_host; |
388 | tu->phy.otg->set_peripheral = tahvo_usb_set_peripheral; | 392 | tu->phy.otg->set_peripheral = tahvo_usb_set_peripheral; |
389 | 393 | ||
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 886f1807a67b..fa2bfa4ee34e 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c | |||
@@ -880,11 +880,8 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, | |||
880 | 880 | ||
881 | tegra_phy->config = devm_kzalloc(&pdev->dev, sizeof(*config), | 881 | tegra_phy->config = devm_kzalloc(&pdev->dev, sizeof(*config), |
882 | GFP_KERNEL); | 882 | GFP_KERNEL); |
883 | if (!tegra_phy->config) { | 883 | if (!tegra_phy->config) |
884 | dev_err(&pdev->dev, | ||
885 | "unable to allocate memory for USB UTMIP config\n"); | ||
886 | return -ENOMEM; | 884 | return -ENOMEM; |
887 | } | ||
888 | 885 | ||
889 | config = tegra_phy->config; | 886 | config = tegra_phy->config; |
890 | 887 | ||
@@ -979,10 +976,8 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) | |||
979 | int err; | 976 | int err; |
980 | 977 | ||
981 | tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); | 978 | tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); |
982 | if (!tegra_phy) { | 979 | if (!tegra_phy) |
983 | dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n"); | ||
984 | return -ENOMEM; | 980 | return -ENOMEM; |
985 | } | ||
986 | 981 | ||
987 | match = of_match_device(tegra_usb_phy_id_table, &pdev->dev); | 982 | match = of_match_device(tegra_usb_phy_id_table, &pdev->dev); |
988 | if (!match) { | 983 | if (!match) { |
diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c index 4e3877c329f2..f48a7a21e3c2 100644 --- a/drivers/usb/phy/phy-ulpi.c +++ b/drivers/usb/phy/phy-ulpi.c | |||
@@ -211,7 +211,7 @@ static int ulpi_init(struct usb_phy *phy) | |||
211 | 211 | ||
212 | static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host) | 212 | static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host) |
213 | { | 213 | { |
214 | struct usb_phy *phy = otg->phy; | 214 | struct usb_phy *phy = otg->usb_phy; |
215 | unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL); | 215 | unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL); |
216 | 216 | ||
217 | if (!host) { | 217 | if (!host) { |
@@ -237,7 +237,7 @@ static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
237 | 237 | ||
238 | static int ulpi_set_vbus(struct usb_otg *otg, bool on) | 238 | static int ulpi_set_vbus(struct usb_otg *otg, bool on) |
239 | { | 239 | { |
240 | struct usb_phy *phy = otg->phy; | 240 | struct usb_phy *phy = otg->usb_phy; |
241 | unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL); | 241 | unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL); |
242 | 242 | ||
243 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); | 243 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); |
@@ -276,7 +276,7 @@ otg_ulpi_create(struct usb_phy_io_ops *ops, | |||
276 | phy->otg = otg; | 276 | phy->otg = otg; |
277 | phy->init = ulpi_init; | 277 | phy->init = ulpi_init; |
278 | 278 | ||
279 | otg->phy = phy; | 279 | otg->usb_phy = phy; |
280 | otg->set_host = ulpi_set_host; | 280 | otg->set_host = ulpi_set_host; |
281 | otg->set_vbus = ulpi_set_vbus; | 281 | otg->set_vbus = ulpi_set_vbus; |
282 | 282 | ||
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index 045cd309367a..b4066a001ba0 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c | |||
@@ -191,7 +191,9 @@ struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, | |||
191 | 191 | ||
192 | phy = __of_usb_find_phy(node); | 192 | phy = __of_usb_find_phy(node); |
193 | if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { | 193 | if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { |
194 | phy = ERR_PTR(-EPROBE_DEFER); | 194 | if (!IS_ERR(phy)) |
195 | phy = ERR_PTR(-EPROBE_DEFER); | ||
196 | |||
195 | devres_free(ptr); | 197 | devres_free(ptr); |
196 | goto err1; | 198 | goto err1; |
197 | } | 199 | } |
@@ -444,3 +446,15 @@ int usb_bind_phy(const char *dev_name, u8 index, | |||
444 | return 0; | 446 | return 0; |
445 | } | 447 | } |
446 | EXPORT_SYMBOL_GPL(usb_bind_phy); | 448 | EXPORT_SYMBOL_GPL(usb_bind_phy); |
449 | |||
450 | /** | ||
451 | * usb_phy_set_event - set event to phy event | ||
452 | * @x: the phy returned by usb_get_phy(); | ||
453 | * | ||
454 | * This sets event to phy event | ||
455 | */ | ||
456 | void usb_phy_set_event(struct usb_phy *x, unsigned long event) | ||
457 | { | ||
458 | x->last_event = event; | ||
459 | } | ||
460 | EXPORT_SYMBOL_GPL(usb_phy_set_event); | ||