usb: musb: trivial cleanup
[linux-2.6-block.git] / drivers / usb / musb / omap2430.c
index ba85f273e4874f3db7e69d390a590b833c894a31..34c169896836b686d7f956fd41c829149971c0a8 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/list.h>
-#include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
@@ -228,21 +227,25 @@ static int musb_otg_notifications(struct notifier_block *nb,
                unsigned long event, void *unused)
 {
        struct musb     *musb = container_of(nb, struct musb, nb);
+
+       musb->xceiv_event = event;
+       schedule_work(&musb->otg_notifier_work);
+
+       return 0;
+}
+
+static void musb_otg_notifier_work(struct work_struct *data_notifier_work)
+{
+       struct musb *musb = container_of(data_notifier_work, struct musb, otg_notifier_work);
        struct device *dev = musb->controller;
        struct musb_hdrc_platform_data *pdata = dev->platform_data;
        struct omap_musb_board_data *data = pdata->board_data;
 
-       switch (event) {
+       switch (musb->xceiv_event) {
        case USB_EVENT_ID:
                dev_dbg(musb->controller, "ID GND\n");
 
-               if (is_otg_enabled(musb)) {
-                       if (musb->gadget_driver) {
-                               pm_runtime_get_sync(musb->controller);
-                               otg_init(musb->xceiv);
-                               omap2430_musb_set_vbus(musb, 1);
-                       }
-               } else {
+               if (!is_otg_enabled(musb) || musb->gadget_driver) {
                        pm_runtime_get_sync(musb->controller);
                        otg_init(musb->xceiv);
                        omap2430_musb_set_vbus(musb, 1);
@@ -274,10 +277,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
                break;
        default:
                dev_dbg(musb->controller, "ID float\n");
-               return NOTIFY_DONE;
        }
-
-       return NOTIFY_OK;
 }
 
 static int omap2430_musb_init(struct musb *musb)
@@ -297,6 +297,8 @@ static int omap2430_musb_init(struct musb *musb)
                return -ENODEV;
        }
 
+       INIT_WORK(&musb->otg_notifier_work, musb_otg_notifier_work);
+
        status = pm_runtime_get_sync(dev);
        if (status < 0) {
                dev_err(dev, "pm_runtime_get_sync FAILED");
@@ -491,6 +493,9 @@ static int omap2430_runtime_suspend(struct device *dev)
        struct omap2430_glue            *glue = dev_get_drvdata(dev);
        struct musb                     *musb = glue_to_musb(glue);
 
+       musb->context.otg_interfsel = musb_readl(musb->mregs,
+                                               OTG_INTERFSEL);
+
        omap2430_low_level_exit(musb);
        otg_set_suspend(musb->xceiv, 1);
 
@@ -503,6 +508,9 @@ static int omap2430_runtime_resume(struct device *dev)
        struct musb                     *musb = glue_to_musb(glue);
 
        omap2430_low_level_init(musb);
+       musb_writel(musb->mregs, OTG_INTERFSEL,
+                                       musb->context.otg_interfsel);
+
        otg_set_suspend(musb->xceiv, 0);
 
        return 0;