diff options
author | Kiran Raparthy <kiran.kumar@linaro.org> | 2014-11-24 12:24:59 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-11-25 09:47:05 -0500 |
commit | b20f3f9e8e537ee25bfb86940903cba4b5abbde6 (patch) | |
tree | e5ff093ca23c06881f6d469e9e0a76fd78c1bd96 /drivers/usb/phy/phy-ab8500-usb.c | |
parent | f415fbd17f0438913339fd043779f306ee3587b0 (diff) |
usb: phy: Handle per-PHY event for connnect and disconnect events
When usb is connected and enumerated in device mode or when
usb is disconnected, call usb_phy_set_event() from phy drivers
to handle per-PHY event.
[ toddpoynor@google.com : Original patch in Android ]
Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team <kernel-team@android.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Benoit Goby <benoit@android.com>
Cc: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Kiran Raparthy <kiran.kumar@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy/phy-ab8500-usb.c')
-rw-r--r-- | drivers/usb/phy/phy-ab8500-usb.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index 30c96f08308b..8cd7d193c2ca 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c | |||
@@ -445,6 +445,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
445 | event = UX500_MUSB_NONE; | 445 | event = UX500_MUSB_NONE; |
446 | /* Fallback to default B_IDLE as nothing is connected. */ | 446 | /* Fallback to default B_IDLE as nothing is connected. */ |
447 | ab->phy.otg->state = OTG_STATE_B_IDLE; | 447 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
448 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
448 | break; | 449 | break; |
449 | 450 | ||
450 | case USB_LINK_ACA_RID_C_NM_9540: | 451 | case USB_LINK_ACA_RID_C_NM_9540: |
@@ -459,12 +460,14 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
459 | ab8500_usb_peri_phy_en(ab); | 460 | ab8500_usb_peri_phy_en(ab); |
460 | atomic_notifier_call_chain(&ab->phy.notifier, | 461 | atomic_notifier_call_chain(&ab->phy.notifier, |
461 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 462 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
463 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
462 | } | 464 | } |
463 | if (ab->mode == USB_IDLE) { | 465 | if (ab->mode == USB_IDLE) { |
464 | ab->mode = USB_PERIPHERAL; | 466 | ab->mode = USB_PERIPHERAL; |
465 | ab8500_usb_peri_phy_en(ab); | 467 | ab8500_usb_peri_phy_en(ab); |
466 | atomic_notifier_call_chain(&ab->phy.notifier, | 468 | atomic_notifier_call_chain(&ab->phy.notifier, |
467 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 469 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
470 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
468 | } | 471 | } |
469 | if (event != UX500_MUSB_RIDC) | 472 | if (event != UX500_MUSB_RIDC) |
470 | event = UX500_MUSB_VBUS; | 473 | event = UX500_MUSB_VBUS; |
@@ -500,6 +503,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
500 | event = UX500_MUSB_CHARGER; | 503 | event = UX500_MUSB_CHARGER; |
501 | atomic_notifier_call_chain(&ab->phy.notifier, | 504 | atomic_notifier_call_chain(&ab->phy.notifier, |
502 | event, &ab->vbus_draw); | 505 | event, &ab->vbus_draw); |
506 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
503 | break; | 507 | break; |
504 | 508 | ||
505 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540: | 509 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540: |
@@ -524,6 +528,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, | |||
524 | ab->mode = USB_IDLE; | 528 | ab->mode = USB_IDLE; |
525 | ab->phy.otg->default_a = false; | 529 | ab->phy.otg->default_a = false; |
526 | ab->vbus_draw = 0; | 530 | ab->vbus_draw = 0; |
531 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
527 | } | 532 | } |
528 | } | 533 | } |
529 | break; | 534 | break; |
@@ -583,6 +588,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
583 | * is connected | 588 | * is connected |
584 | */ | 589 | */ |
585 | ab->phy.otg->state = OTG_STATE_B_IDLE; | 590 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
591 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
586 | break; | 592 | break; |
587 | 593 | ||
588 | case USB_LINK_ACA_RID_C_NM_8540: | 594 | case USB_LINK_ACA_RID_C_NM_8540: |
@@ -596,6 +602,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
596 | ab8500_usb_peri_phy_en(ab); | 602 | ab8500_usb_peri_phy_en(ab); |
597 | atomic_notifier_call_chain(&ab->phy.notifier, | 603 | atomic_notifier_call_chain(&ab->phy.notifier, |
598 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 604 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
605 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
599 | } | 606 | } |
600 | if (event != UX500_MUSB_RIDC) | 607 | if (event != UX500_MUSB_RIDC) |
601 | event = UX500_MUSB_VBUS; | 608 | event = UX500_MUSB_VBUS; |
@@ -624,6 +631,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
624 | event = UX500_MUSB_CHARGER; | 631 | event = UX500_MUSB_CHARGER; |
625 | atomic_notifier_call_chain(&ab->phy.notifier, | 632 | atomic_notifier_call_chain(&ab->phy.notifier, |
626 | event, &ab->vbus_draw); | 633 | event, &ab->vbus_draw); |
634 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
627 | break; | 635 | break; |
628 | 636 | ||
629 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540: | 637 | case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540: |
@@ -646,6 +654,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, | |||
646 | ab->mode = USB_IDLE; | 654 | ab->mode = USB_IDLE; |
647 | ab->phy.otg->default_a = false; | 655 | ab->phy.otg->default_a = false; |
648 | ab->vbus_draw = 0; | 656 | ab->vbus_draw = 0; |
657 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
649 | } | 658 | } |
650 | break; | 659 | break; |
651 | 660 | ||
@@ -692,6 +701,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, | |||
692 | * is connected | 701 | * is connected |
693 | */ | 702 | */ |
694 | ab->phy.otg->state = OTG_STATE_B_IDLE; | 703 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
704 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
695 | break; | 705 | break; |
696 | 706 | ||
697 | case USB_LINK_ACA_RID_C_NM_8505: | 707 | case USB_LINK_ACA_RID_C_NM_8505: |
@@ -705,6 +715,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, | |||
705 | ab8500_usb_peri_phy_en(ab); | 715 | ab8500_usb_peri_phy_en(ab); |
706 | atomic_notifier_call_chain(&ab->phy.notifier, | 716 | atomic_notifier_call_chain(&ab->phy.notifier, |
707 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 717 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
718 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
708 | } | 719 | } |
709 | if (event != UX500_MUSB_RIDC) | 720 | if (event != UX500_MUSB_RIDC) |
710 | event = UX500_MUSB_VBUS; | 721 | event = UX500_MUSB_VBUS; |
@@ -732,6 +743,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, | |||
732 | event = UX500_MUSB_CHARGER; | 743 | event = UX500_MUSB_CHARGER; |
733 | atomic_notifier_call_chain(&ab->phy.notifier, | 744 | atomic_notifier_call_chain(&ab->phy.notifier, |
734 | event, &ab->vbus_draw); | 745 | event, &ab->vbus_draw); |
746 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
735 | break; | 747 | break; |
736 | 748 | ||
737 | default: | 749 | default: |
@@ -775,6 +787,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, | |||
775 | event = UX500_MUSB_NONE; | 787 | event = UX500_MUSB_NONE; |
776 | /* Fallback to default B_IDLE as nothing is connected */ | 788 | /* Fallback to default B_IDLE as nothing is connected */ |
777 | ab->phy.otg->state = OTG_STATE_B_IDLE; | 789 | ab->phy.otg->state = OTG_STATE_B_IDLE; |
790 | usb_phy_set_event(&ab->phy, USB_EVENT_NONE); | ||
778 | break; | 791 | break; |
779 | 792 | ||
780 | case USB_LINK_ACA_RID_C_NM_8500: | 793 | case USB_LINK_ACA_RID_C_NM_8500: |
@@ -792,6 +805,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, | |||
792 | ab8500_usb_peri_phy_en(ab); | 805 | ab8500_usb_peri_phy_en(ab); |
793 | atomic_notifier_call_chain(&ab->phy.notifier, | 806 | atomic_notifier_call_chain(&ab->phy.notifier, |
794 | UX500_MUSB_PREPARE, &ab->vbus_draw); | 807 | UX500_MUSB_PREPARE, &ab->vbus_draw); |
808 | usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); | ||
795 | } | 809 | } |
796 | if (event != UX500_MUSB_RIDC) | 810 | if (event != UX500_MUSB_RIDC) |
797 | event = UX500_MUSB_VBUS; | 811 | event = UX500_MUSB_VBUS; |
@@ -818,6 +832,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, | |||
818 | event = UX500_MUSB_CHARGER; | 832 | event = UX500_MUSB_CHARGER; |
819 | atomic_notifier_call_chain(&ab->phy.notifier, | 833 | atomic_notifier_call_chain(&ab->phy.notifier, |
820 | event, &ab->vbus_draw); | 834 | event, &ab->vbus_draw); |
835 | usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); | ||
821 | break; | 836 | break; |
822 | 837 | ||
823 | case USB_LINK_RESERVED_8500: | 838 | case USB_LINK_RESERVED_8500: |