usb: dwc3: omap: introduce enable/disable IRQ methods
authorFelipe Balbi <balbi@ti.com>
Mon, 11 Feb 2013 09:03:59 +0000 (11:03 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 18 Mar 2013 09:17:01 +0000 (11:17 +0200)
they will be re-used on suspend/resume implementation.

Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/dwc3-omap.c

index 3d343d92548aabc08ff632527896ad3ea2f34987..43d62053e158724caf86e25b6beffe134397c272 100644 (file)
@@ -250,6 +250,34 @@ static int dwc3_omap_remove_core(struct device *dev, void *c)
        return 0;
 }
 
+static void dwc3_omap_enable_irqs(struct dwc3_omap *omap)
+{
+       u32                     reg;
+
+       /* enable all IRQs */
+       reg = USBOTGSS_IRQO_COREIRQ_ST;
+       dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, reg);
+
+       reg = (USBOTGSS_IRQ1_OEVT |
+                       USBOTGSS_IRQ1_DRVVBUS_RISE |
+                       USBOTGSS_IRQ1_CHRGVBUS_RISE |
+                       USBOTGSS_IRQ1_DISCHRGVBUS_RISE |
+                       USBOTGSS_IRQ1_IDPULLUP_RISE |
+                       USBOTGSS_IRQ1_DRVVBUS_FALL |
+                       USBOTGSS_IRQ1_CHRGVBUS_FALL |
+                       USBOTGSS_IRQ1_DISCHRGVBUS_FALL |
+                       USBOTGSS_IRQ1_IDPULLUP_FALL);
+
+       dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, reg);
+}
+
+static void dwc3_omap_disable_irqs(struct dwc3_omap *omap)
+{
+       /* disable all IRQs */
+       dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, 0x00);
+       dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, 0x00);
+}
+
 static int dwc3_omap_probe(struct platform_device *pdev)
 {
        struct device_node      *node = pdev->dev.of_node;
@@ -355,21 +383,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
                return ret;
        }
 
-       /* enable all IRQs */
-       reg = USBOTGSS_IRQO_COREIRQ_ST;
-       dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, reg);
-
-       reg = (USBOTGSS_IRQ1_OEVT |
-                       USBOTGSS_IRQ1_DRVVBUS_RISE |
-                       USBOTGSS_IRQ1_CHRGVBUS_RISE |
-                       USBOTGSS_IRQ1_DISCHRGVBUS_RISE |
-                       USBOTGSS_IRQ1_IDPULLUP_RISE |
-                       USBOTGSS_IRQ1_DRVVBUS_FALL |
-                       USBOTGSS_IRQ1_CHRGVBUS_FALL |
-                       USBOTGSS_IRQ1_DISCHRGVBUS_FALL |
-                       USBOTGSS_IRQ1_IDPULLUP_FALL);
-
-       dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, reg);
+       dwc3_omap_enable_irqs(omap);
 
        ret = of_platform_populate(node, NULL, NULL, dev);
        if (ret) {
@@ -382,6 +396,9 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 
 static int dwc3_omap_remove(struct platform_device *pdev)
 {
+       struct dwc3_omap        *omap = platform_get_drvdata(pdev);
+
+       dwc3_omap_disable_irqs(omap);
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);