Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kiran Raparthy and committed by
Felipe Balbi
b20f3f9e f415fbd1

+21
+15
drivers/usb/phy/phy-ab8500-usb.c
··· 445 445 event = UX500_MUSB_NONE; 446 446 /* Fallback to default B_IDLE as nothing is connected. */ 447 447 ab->phy.otg->state = OTG_STATE_B_IDLE; 448 + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); 448 449 break; 449 450 450 451 case USB_LINK_ACA_RID_C_NM_9540: ··· 460 459 ab8500_usb_peri_phy_en(ab); 461 460 atomic_notifier_call_chain(&ab->phy.notifier, 462 461 UX500_MUSB_PREPARE, &ab->vbus_draw); 462 + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); 463 463 } 464 464 if (ab->mode == USB_IDLE) { 465 465 ab->mode = USB_PERIPHERAL; 466 466 ab8500_usb_peri_phy_en(ab); 467 467 atomic_notifier_call_chain(&ab->phy.notifier, 468 468 UX500_MUSB_PREPARE, &ab->vbus_draw); 469 + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); 469 470 } 470 471 if (event != UX500_MUSB_RIDC) 471 472 event = UX500_MUSB_VBUS; ··· 503 500 event = UX500_MUSB_CHARGER; 504 501 atomic_notifier_call_chain(&ab->phy.notifier, 505 502 event, &ab->vbus_draw); 503 + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); 506 504 break; 507 505 508 506 case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540: ··· 528 524 ab->mode = USB_IDLE; 529 525 ab->phy.otg->default_a = false; 530 526 ab->vbus_draw = 0; 527 + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); 531 528 } 532 529 } 533 530 break; ··· 588 583 * is connected 589 584 */ 590 585 ab->phy.otg->state = OTG_STATE_B_IDLE; 586 + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); 591 587 break; 592 588 593 589 case USB_LINK_ACA_RID_C_NM_8540: ··· 602 596 ab8500_usb_peri_phy_en(ab); 603 597 atomic_notifier_call_chain(&ab->phy.notifier, 604 598 UX500_MUSB_PREPARE, &ab->vbus_draw); 599 + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); 605 600 } 606 601 if (event != UX500_MUSB_RIDC) 607 602 event = UX500_MUSB_VBUS; ··· 631 624 event = UX500_MUSB_CHARGER; 632 625 atomic_notifier_call_chain(&ab->phy.notifier, 633 626 event, &ab->vbus_draw); 627 + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); 634 628 break; 635 629 636 630 case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540: ··· 654 646 ab->mode = USB_IDLE; 655 647 ab->phy.otg->default_a = false; 656 648 ab->vbus_draw = 0; 649 + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); 657 650 } 658 651 break; 659 652 ··· 701 692 * is connected 702 693 */ 703 694 ab->phy.otg->state = OTG_STATE_B_IDLE; 695 + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); 704 696 break; 705 697 706 698 case USB_LINK_ACA_RID_C_NM_8505: ··· 715 705 ab8500_usb_peri_phy_en(ab); 716 706 atomic_notifier_call_chain(&ab->phy.notifier, 717 707 UX500_MUSB_PREPARE, &ab->vbus_draw); 708 + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); 718 709 } 719 710 if (event != UX500_MUSB_RIDC) 720 711 event = UX500_MUSB_VBUS; ··· 743 732 event = UX500_MUSB_CHARGER; 744 733 atomic_notifier_call_chain(&ab->phy.notifier, 745 734 event, &ab->vbus_draw); 735 + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); 746 736 break; 747 737 748 738 default: ··· 787 775 event = UX500_MUSB_NONE; 788 776 /* Fallback to default B_IDLE as nothing is connected */ 789 777 ab->phy.otg->state = OTG_STATE_B_IDLE; 778 + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); 790 779 break; 791 780 792 781 case USB_LINK_ACA_RID_C_NM_8500: ··· 805 792 ab8500_usb_peri_phy_en(ab); 806 793 atomic_notifier_call_chain(&ab->phy.notifier, 807 794 UX500_MUSB_PREPARE, &ab->vbus_draw); 795 + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); 808 796 } 809 797 if (event != UX500_MUSB_RIDC) 810 798 event = UX500_MUSB_VBUS; ··· 832 818 event = UX500_MUSB_CHARGER; 833 819 atomic_notifier_call_chain(&ab->phy.notifier, 834 820 event, &ab->vbus_draw); 821 + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); 835 822 break; 836 823 837 824 case USB_LINK_RESERVED_8500:
+2
drivers/usb/phy/phy-gpio-vbus-usb.c
··· 134 134 135 135 atomic_notifier_call_chain(&gpio_vbus->phy.notifier, 136 136 status, gpio_vbus->phy.otg->gadget); 137 + usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_ENUMERATED); 137 138 } else { 138 139 /* optionally disable D+ pullup */ 139 140 if (gpio_is_valid(gpio)) ··· 149 148 150 149 atomic_notifier_call_chain(&gpio_vbus->phy.notifier, 151 150 status, gpio_vbus->phy.otg->gadget); 151 + usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_NONE); 152 152 } 153 153 } 154 154
+2
drivers/usb/phy/phy-mv-usb.c
··· 441 441 mv_otg_start_periphrals(mvotg, 0); 442 442 mv_otg_reset(mvotg); 443 443 mv_otg_disable(mvotg); 444 + usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE); 444 445 break; 445 446 case OTG_STATE_B_PERIPHERAL: 446 447 mv_otg_enable(mvotg); 447 448 mv_otg_start_periphrals(mvotg, 1); 449 + usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED); 448 450 break; 449 451 case OTG_STATE_A_IDLE: 450 452 otg->default_a = 1;
+2
drivers/usb/phy/phy-tahvo.c
··· 87 87 if (tu->phy.otg->gadget) 88 88 usb_gadget_vbus_connect(tu->phy.otg->gadget); 89 89 tu->phy.otg->state = OTG_STATE_B_PERIPHERAL; 90 + usb_phy_set_event(&tu->phy, USB_EVENT_ENUMERATED); 90 91 break; 91 92 case OTG_STATE_A_IDLE: 92 93 /* ··· 106 105 if (tu->phy.otg->gadget) 107 106 usb_gadget_vbus_disconnect(tu->phy.otg->gadget); 108 107 tu->phy.otg->state = OTG_STATE_B_IDLE; 108 + usb_phy_set_event(&tu->phy, USB_EVENT_NONE); 109 109 break; 110 110 case OTG_STATE_A_HOST: 111 111 tu->phy.otg->state = OTG_STATE_A_IDLE;