usb/penwell_otg: add related notification for vbus invalid case
authorWu, Hao <hao.wu@intel.com>
Mon, 4 Jun 2012 13:45:00 +0000 (21:45 +0800)
committerbuildbot <buildbot@intel.com>
Thu, 7 Jun 2012 04:19:41 +0000 (21:19 -0700)
BZ: 39874

Add vbus invalid notification from usb driver, for overcurrent
condition for USB host mode.

Change-Id: I413aa37bf87384b30a918d3facf9ae8b402acdff
Signed-off-by: Wu, Hao <hao.wu@intel.com>
Reviewed-on: http://android.intel.com:8080/51550
Reviewed-by: Tang, Richard <richard.tang@intel.com>
Reviewed-by: Tang, Jianqiang <jianqiang.tang@intel.com>
Reviewed-by: Meng, Zhe <zhe.meng@intel.com>
Tested-by: Meng, Zhe <zhe.meng@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/usb/otg/penwell_otg.c

index 8f70121..9ff5711 100644 (file)
@@ -1696,6 +1696,22 @@ void penwell_otg_phy_intr(bool on)
        penwell_otg_msic_spi_access(false);
 }
 
+static penwell_otg_notify_warning(int warning_code)
+{
+       struct penwell_otg      *pnw = the_transceiver;
+       struct usb_hcd          *hcd;
+       int                     err;
+
+       dev_dbg(pnw->dev, "%s ---> %d\n", __func__, warning_code);
+
+       if (pnw && pnw->iotg.otg.host && pnw->iotg.otg.host->root_hub)
+               usb_notify_warning(pnw->iotg.otg.host->root_hub, warning_code);
+       else
+               dev_dbg(pnw->dev, "no valid device for notification\n");
+
+       dev_dbg(pnw->dev, "%s <--- %d\n", __func__);
+}
+
 void penwell_otg_nsf_msg(unsigned long indicator)
 {
        switch (indicator) {
@@ -3174,6 +3190,9 @@ static void penwell_otg_work(struct work_struct *work)
                } else if (!hsm->a_vbus_vld) {
                        /* Move to A_VBUS_ERR state, over-current detected */
 
+                       /* Notify user space for vbus invalid event */
+                       penwell_otg_notify_warning(USB_WARNING_VBUS_INVALID);
+
                        /* Delete current timer and disable host function */
                        penwell_otg_del_timer(TA_WAIT_BCON_TMR);
 
@@ -3278,6 +3297,9 @@ static void penwell_otg_work(struct work_struct *work)
                } else if (!hsm->a_vbus_vld) {
                        /* Move to A_VBUS_ERR state */
 
+                       /* Notify user space for vbus invalid event */
+                       penwell_otg_notify_warning(USB_WARNING_VBUS_INVALID);
+
                        /* Delete current timer and clear flags */
                        if (hsm->test_device) {
                                hsm->test_device = 0;