TWL4030: Force power down before powering up the PHY

To address issues with USB not enumerating properly when the cable
is connected on a warm reboot, make sure the PHY is powered down
before powering it up.  This results in proper enumeration on a
warm reboot.

Change-Id: If52df6386ec7c8bd3c6715b96644e1dad752b9a7
diff --git a/drivers/usb/phy/twl4030.c b/drivers/usb/phy/twl4030.c
index 54d2e61..6dcf6c9 100644
--- a/drivers/usb/phy/twl4030.c
+++ b/drivers/usb/phy/twl4030.c
@@ -118,10 +118,22 @@
 {
 	u8 pwr, clk;
 
-	/* Power the PHY */
+	/* First make sure PHY is powered down to
+	 * clear any state from a previous reboot and
+	 * force unenumeration.  Otherwise, sometimes
+	 * the device doesn't enumerate properly on
+	 * a warm reboot.
+	 */
+
+	/* Power down the PHY */
 	pwr = twl4030_usb_read(TWL4030_USB_PHY_PWR_CTRL);
+	pwr |= PHYPWD;
+	twl4030_usb_write(TWL4030_USB_PHY_PWR_CTRL, pwr);
+
+	/* Power the PHY */
 	pwr &= ~PHYPWD;
 	twl4030_usb_write(TWL4030_USB_PHY_PWR_CTRL, pwr);
+
 	/* Enable clocks */
 	clk = twl4030_usb_read(TWL4030_USB_PHY_CLK_CTRL);
 	clk |= CLOCKGATING_EN | CLK32K_EN;
@@ -139,6 +151,8 @@
 	long timeout = 1000 * 1000; /* 1 sec */;
 	u8 clk, sts, pwr;
 
+	i2c_set_bus_num(0);
+
 	/* twl4030 ldo init */
 	twl4030_usb_ldo_init();