aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorKiran Raparthy <kiran.kumar@linaro.org>2014-11-24 12:24:59 -0500
committerFelipe Balbi <balbi@ti.com>2014-11-25 09:47:05 -0500
commitb20f3f9e8e537ee25bfb86940903cba4b5abbde6 (patch)
treee5ff093ca23c06881f6d469e9e0a76fd78c1bd96 /drivers/usb/phy
parentf415fbd17f0438913339fd043779f306ee3587b0 (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')
-rw-r--r--drivers/usb/phy/phy-ab8500-usb.c15
-rw-r--r--drivers/usb/phy/phy-gpio-vbus-usb.c2
-rw-r--r--drivers/usb/phy/phy-mv-usb.c2
-rw-r--r--drivers/usb/phy/phy-tahvo.c2
4 files changed, 21 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:
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index 9fcf19ba1416..54511725caaf 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -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))
@@ -148,6 +149,7 @@ static void gpio_vbus_work(struct work_struct *work)
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
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 81d934fdd0c3..b234d46cd58b 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -441,10 +441,12 @@ run:
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;
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index 9cabc1a20d1c..d391c79a542a 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -87,6 +87,7 @@ static void check_vbus_state(struct tahvo_usb *tu)
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.otg->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 /*
@@ -105,6 +106,7 @@ static void check_vbus_state(struct tahvo_usb *tu)
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.otg->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.otg->state = OTG_STATE_A_IDLE; 112 tu->phy.otg->state = OTG_STATE_A_IDLE;