usb: otg: tegra: Notify USB events to otg core
[linux-2.6.git] / drivers / usb / otg / tegra-otg.c
index 9d614cb..22e303e 100644 (file)
@@ -182,6 +182,12 @@ static void tegra_stop_host(struct tegra_otg_data *tegra)
        DBG("%s(%d) End\n", __func__, __LINE__);
 }
 
+static void tegra_otg_notify_event(struct otg_transceiver *otg,
+                                       enum usb_xceiv_events event)
+{
+       otg->last_event = event;
+       atomic_notifier_call_chain(&otg->notifier, event, NULL);
+}
 
 static void tegra_change_otg_state(struct tegra_otg_data *tegra,
                                enum usb_otg_state to)
@@ -203,16 +209,24 @@ static void tegra_change_otg_state(struct tegra_otg_data *tegra,
                                              tegra_state_name(to));
 
                if (from == OTG_STATE_A_SUSPEND) {
-                       if (to == OTG_STATE_B_PERIPHERAL && otg->gadget)
+                       if (to == OTG_STATE_B_PERIPHERAL && otg->gadget) {
                                usb_gadget_vbus_connect(otg->gadget);
-                       else if (to == OTG_STATE_A_HOST)
+                               tegra_otg_notify_event(otg, USB_EVENT_VBUS);
+                       }
+                       else if (to == OTG_STATE_A_HOST) {
                                tegra_start_host(tegra);
+                               tegra_otg_notify_event(otg, USB_EVENT_ID);
+                       }
                } else if (from == OTG_STATE_A_HOST) {
-                       if (to == OTG_STATE_A_SUSPEND)
+                       if (to == OTG_STATE_A_SUSPEND) {
                                tegra_stop_host(tegra);
+                               tegra_otg_notify_event(otg, USB_EVENT_NONE);
+                       }
                } else if (from == OTG_STATE_B_PERIPHERAL && otg->gadget) {
-                       if (to == OTG_STATE_A_SUSPEND)
+                       if (to == OTG_STATE_A_SUSPEND) {
                                usb_gadget_vbus_disconnect(otg->gadget);
+                               tegra_otg_notify_event(otg, USB_EVENT_NONE);
+                       }
                }
        }
 }