usb: phy: Handle per-PHY event for connnect and disconnect events
authorKiran Raparthy <kiran.kumar@linaro.org>
Mon, 24 Nov 2014 17:24:59 +0000 (22:54 +0530)
committerFelipe Balbi <balbi@ti.com>
Tue, 25 Nov 2014 14:47:05 +0000 (08:47 -0600)
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>
drivers/usb/phy/phy-ab8500-usb.c
drivers/usb/phy/phy-gpio-vbus-usb.c
drivers/usb/phy/phy-mv-usb.c
drivers/usb/phy/phy-tahvo.c

index 30c96f08308b99faa614cc90370782fa42cd22f1..8cd7d193c2ca5bae33273dea8280c02dfe242bbf 100644 (file)
@@ -445,6 +445,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.otg->state = OTG_STATE_B_IDLE;
+               usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
                break;
 
        case USB_LINK_ACA_RID_C_NM_9540:
@@ -459,12 +460,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;
@@ -500,6 +503,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:
@@ -524,6 +528,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;
@@ -583,6 +588,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
                 * is connected
                 */
                ab->phy.otg->state = OTG_STATE_B_IDLE;
+               usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
                break;
 
        case USB_LINK_ACA_RID_C_NM_8540:
@@ -596,6 +602,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;
@@ -624,6 +631,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:
@@ -646,6 +654,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;
 
@@ -692,6 +701,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
                 * is connected
                 */
                ab->phy.otg->state = OTG_STATE_B_IDLE;
+               usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
                break;
 
        case USB_LINK_ACA_RID_C_NM_8505:
@@ -705,6 +715,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;
@@ -732,6 +743,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:
@@ -775,6 +787,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.otg->state = OTG_STATE_B_IDLE;
+               usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
                break;
 
        case USB_LINK_ACA_RID_C_NM_8500:
@@ -792,6 +805,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;
@@ -818,6 +832,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:
index 9fcf19ba141686f2296a8d38d76cde4a8e274f15..54511725caaf7606a85f47d19b4c69c17cfc91d7 100644 (file)
@@ -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);
        }
 }
 
index 81d934fdd0c3e46dc3f5e1d0218bfabb011ac592..b234d46cd58b4aa5e1d3e50a5aa2c0ae4a972064 100644 (file)
@@ -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;
index 9cabc1a20d1c18b78f531df2b9271db3e00b1106..d391c79a542a831bd2ef2a76d63541a0ed8e85d4 100644 (file)
@@ -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.otg->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.otg->state = OTG_STATE_B_IDLE;
+                       usb_phy_set_event(&tu->phy, USB_EVENT_NONE);
                        break;
                case OTG_STATE_A_HOST:
                        tu->phy.otg->state = OTG_STATE_A_IDLE;