usb: phy: handle per-PHY connect and disconnect events
RFC v6 2/3 usb: phy: handle per-PHY connect and disconnect events
From: Todd Poynor <[email protected]>
usb: phy: handle per-PHY connect 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.
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Android Kernel Team <[email protected]>
Cc John Stultz <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Arve Hj�nnev�g <[email protected]>
Cc Benoit Goby <[email protected]>
Signed-off-by Todd Poynor <[email protected]>
[kiran: Added context to commit message, squished build fixes from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage to wakeupsource, merged Todd's refactoring logic and simplified the structures and code and addressed community feedback]
Signed-off-by Kiran Raparthy <[email protected]>
--- drivers/usb/phy/phy-ab8500-usb.c | 15 +++++++++++++++ drivers/usb/phy/phy-gpio-vbus-usb.c | 2 ++ drivers/usb/phy/phy-mv-usb.c | 2 ++ drivers/usb/phy/phy-tahvo.c | 2 ++ 4 files changed, 21 insertions(+)
drivers/usb/phy/phy-ab8500-usb.c +15 -0
@@ -447,6 +447,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, event =UX500_MUSB_NONE ;/* Fallback to default B_IDLE as nothing is connected. */ ab->phy.state =OTG_STATE_B_IDLE ; +usb_phy_set_event (&ab->phy,USB_EVENT_NONE );break ;case USB_LINK_ACA_RID_C_NM_9540 :
@@ -461,12 +462,14 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,ab8500_usb_peri_phy_en (ab);atomic_notifier_call_chain (&ab->phy.notifier,UX500_MUSB_PREPARE , &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_ENUMERATED ); }if (ab->mode ==USB_IDLE ) { ab->mode =USB_PERIPHERAL ;ab8500_usb_peri_phy_en (ab);atomic_notifier_call_chain (&ab->phy.notifier,UX500_MUSB_PREPARE , &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_ENUMERATED ); }if (event !=UX500_MUSB_RIDC ) event =UX500_MUSB_VBUS ;
@@ -502,6 +505,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, event =UX500_MUSB_CHARGER ;atomic_notifier_call_chain (&ab->phy.notifier, event, &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_CHARGER );break ;case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540 :
@@ -526,6 +530,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, ab->mode =USB_IDLE ; ab->phy.otg->default_a = false; ab->vbus_draw =0 ; +usb_phy_set_event (&ab->phy,USB_EVENT_NONE ); } }break ;
@@ -585,6 +590,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,* is connected */ ab->phy.state =OTG_STATE_B_IDLE ; +usb_phy_set_event (&ab->phy,USB_EVENT_NONE );break ;case USB_LINK_ACA_RID_C_NM_8540 :
@@ -598,6 +604,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,ab8500_usb_peri_phy_en (ab);atomic_notifier_call_chain (&ab->phy.notifier,UX500_MUSB_PREPARE , &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_ENUMERATED ); }if (event !=UX500_MUSB_RIDC ) event =UX500_MUSB_VBUS ;
@@ -626,6 +633,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, event =UX500_MUSB_CHARGER ;atomic_notifier_call_chain (&ab->phy.notifier, event, &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_CHARGER );break ;case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540 :
@@ -648,6 +656,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, ab->mode =USB_IDLE ; ab->phy.otg->default_a = false; ab->vbus_draw =0 ; +usb_phy_set_event (&ab->phy,USB_EVENT_NONE ); }break ;
@@ -694,6 +703,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,* is connected */ ab->phy.state =OTG_STATE_B_IDLE ; +usb_phy_set_event (&ab->phy,USB_EVENT_NONE );break ;case USB_LINK_ACA_RID_C_NM_8505 :
@@ -707,6 +717,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,ab8500_usb_peri_phy_en (ab);atomic_notifier_call_chain (&ab->phy.notifier,UX500_MUSB_PREPARE , &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_ENUMERATED ); }if (event !=UX500_MUSB_RIDC ) event =UX500_MUSB_VBUS ;
@@ -734,6 +745,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, event =UX500_MUSB_CHARGER ;atomic_notifier_call_chain (&ab->phy.notifier, event, &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_CHARGER );break ;default :
@@ -777,6 +789,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, event =UX500_MUSB_NONE ;/* Fallback to default B_IDLE as nothing is connected */ ab->phy.state =OTG_STATE_B_IDLE ; +usb_phy_set_event (&ab->phy,USB_EVENT_NONE );break ;case USB_LINK_ACA_RID_C_NM_8500 :
@@ -794,6 +807,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,ab8500_usb_peri_phy_en (ab);atomic_notifier_call_chain (&ab->phy.notifier,UX500_MUSB_PREPARE , &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_ENUMERATED ); }if (event !=UX500_MUSB_RIDC ) event =UX500_MUSB_VBUS ;
@@ -820,6 +834,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, event =UX500_MUSB_CHARGER ;atomic_notifier_call_chain (&ab->phy.notifier, event, &ab->vbus_draw); +usb_phy_set_event (&ab->phy,USB_EVENT_CHARGER );break ;case USB_LINK_RESERVED_8500 :
drivers/usb/phy/phy-gpio-vbus-usb.c +2 -0
@@ -134,6 +134,7 @@ static void gpio_vbus_work(struct work_struct *work)atomic_notifier_call_chain (&gpio_vbus->phy.notifier, status, gpio_vbus->phy.otg->gadget); +usb_phy_set_event (&gpio_vbus->phy,USB_EVENT_ENUMERATED ); }else {/* optionally disable D+ pullup */ if (gpio_is_valid (gpio))
@@ -148,6 +149,7 @@ static void gpio_vbus_work(struct work_struct *work)atomic_notifier_call_chain (&gpio_vbus->phy.notifier, status, gpio_vbus->phy.otg->gadget); +usb_phy_set_event (&gpio_vbus->phy,USB_EVENT_NONE ); } }
drivers/usb/phy/phy-mv-usb.c +2 -0
@@ -441,10 +441,12 @@ run:mv_otg_start_periphrals (mvotg,0 );mv_otg_reset (mvotg);mv_otg_disable (mvotg); +usb_phy_set_event (&mvotg->phy,USB_EVENT_NONE );break ;case OTG_STATE_B_PERIPHERAL :mv_otg_enable (mvotg);mv_otg_start_periphrals (mvotg,1 ); +usb_phy_set_event (&mvotg->phy,USB_EVENT_ENUMERATED );break ;case OTG_STATE_A_IDLE : otg->default_a =1 ;
drivers/usb/phy/phy-tahvo.c +2 -0
@@ -87,6 +87,7 @@ static void check_vbus_state(struct tahvo_usb *tu)if (tu->phy.otg->gadget)usb_gadget_vbus_connect (tu->phy.otg->gadget); tu->phy.state =OTG_STATE_B_PERIPHERAL ; +usb_phy_set_event (&tu->phy,USB_EVENT_ENUMERATED );break ;case OTG_STATE_A_IDLE :/*
@@ -105,6 +106,7 @@ static void check_vbus_state(struct tahvo_usb *tu)if (tu->phy.otg->gadget)usb_gadget_vbus_disconnect (tu->phy.otg->gadget); tu->phy.state =OTG_STATE_B_IDLE ; +usb_phy_set_event (&tu->phy,USB_EVENT_NONE );break ;case OTG_STATE_A_HOST : tu->phy.state =OTG_STATE_A_IDLE ;
Signature · 1 line
1.8.2.1