Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
[pandora-kernel.git] / arch / arm / mach-omap2 / omap_phy_internal.c
index f172ec0..e2e605f 100644 (file)
@@ -44,6 +44,7 @@
 
 static struct clk *phyclk, *clk48m, *clk32k;
 static void __iomem *ctrl_base;
+static int usbotghs_control;
 
 int omap4430_phy_init(struct device *dev)
 {
@@ -104,13 +105,6 @@ int omap4430_phy_set_clk(struct device *dev, int on)
 int omap4430_phy_power(struct device *dev, int ID, int on)
 {
        if (on) {
-               /* enabled the clocks */
-               omap4430_phy_set_clk(dev, 1);
-               /* power on the phy */
-               if (__raw_readl(ctrl_base + CONTROL_DEV_CONF) & PHY_PD) {
-                       __raw_writel(~PHY_PD, ctrl_base + CONTROL_DEV_CONF);
-                       mdelay(200);
-               }
                if (ID)
                        /* enable VBUS valid, IDDIG groung */
                        __raw_writel(AVALID | VBUSVALID, ctrl_base +
@@ -126,10 +120,31 @@ int omap4430_phy_power(struct device *dev, int ID, int on)
                /* Enable session END and IDIG to high impedence. */
                __raw_writel(SESSEND | IDDIG, ctrl_base +
                                        USBOTGHS_CONTROL);
+       }
+       return 0;
+}
+
+int omap4430_phy_suspend(struct device *dev, int suspend)
+{
+       if (suspend) {
                /* Disable the clocks */
                omap4430_phy_set_clk(dev, 0);
                /* Power down the phy */
                __raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
+
+               /* save the context */
+               usbotghs_control = __raw_readl(ctrl_base + USBOTGHS_CONTROL);
+       } else {
+               /* Enable the internel phy clcoks */
+               omap4430_phy_set_clk(dev, 1);
+               /* power on the phy */
+               if (__raw_readl(ctrl_base + CONTROL_DEV_CONF) & PHY_PD) {
+                       __raw_writel(~PHY_PD, ctrl_base + CONTROL_DEV_CONF);
+                       mdelay(200);
+               }
+
+               /* restore the context */
+               __raw_writel(usbotghs_control, ctrl_base + USBOTGHS_CONTROL);
        }
 
        return 0;