arm: tegra: enterprise: Filling regulator supply info
[linux-2.6.git] / drivers / mfd / omap-usb-host.c
index cb01209..86e1458 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -25,7 +26,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
 #include <linux/gpio.h>
-#include <linux/regulator/consumer.h>
 #include <plat/usb.h>
 
 #define USBHS_DRIVER_NAME      "usbhs-omap"
@@ -282,6 +282,7 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
 
        if (!ehci) {
                dev_err(dev, "omap_usbhs_alloc_child failed\n");
+               ret = -ENOMEM;
                goto err_end;
        }
 
@@ -305,13 +306,14 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
                sizeof(*ohci_data), dev);
        if (!ohci) {
                dev_err(dev, "omap_usbhs_alloc_child failed\n");
+               ret = -ENOMEM;
                goto err_ehci;
        }
 
        return 0;
 
 err_ehci:
-       platform_device_put(ehci);
+       platform_device_unregister(ehci);
 
 err_end:
        return ret;
@@ -332,7 +334,7 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
        int                             i;
 
        if (!pdata) {
-               dev_err(dev, "Missing platfrom data\n");
+               dev_err(dev, "Missing platform data\n");
                ret = -ENOMEM;
                goto end_probe;
        }
@@ -675,7 +677,6 @@ static void usbhs_omap_tll_init(struct device *dev, u8 tll_channel_count)
                                | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
                                | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
 
-                       reg |= (1 << (i + 1));
                } else
                        continue;
 
@@ -700,8 +701,7 @@ static int usbhs_enable(struct device *dev)
        dev_dbg(dev, "starting TI HSUSB Controller\n");
        if (!pdata) {
                dev_dbg(dev, "missing platform_data\n");
-               ret =  -ENODEV;
-               goto end_enable;
+               return  -ENODEV;
        }
 
        spin_lock_irqsave(&omap->lock, flags);
@@ -719,14 +719,14 @@ static int usbhs_enable(struct device *dev)
                        gpio_request(pdata->ehci_data->reset_gpio_port[0],
                                                "USB1 PHY reset");
                        gpio_direction_output
-                               (pdata->ehci_data->reset_gpio_port[0], 1);
+                               (pdata->ehci_data->reset_gpio_port[0], 0);
                }
 
                if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) {
                        gpio_request(pdata->ehci_data->reset_gpio_port[1],
                                                "USB2 PHY reset");
                        gpio_direction_output
-                               (pdata->ehci_data->reset_gpio_port[1], 1);
+                               (pdata->ehci_data->reset_gpio_port[1], 0);
                }
 
                /* Hold the PHY in RESET for enough time till DIR is high */
@@ -906,16 +906,17 @@ static int usbhs_enable(struct device *dev)
 
                if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
                        gpio_set_value
-                               (pdata->ehci_data->reset_gpio_port[0], 0);
+                               (pdata->ehci_data->reset_gpio_port[0], 1);
 
                if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
                        gpio_set_value
-                               (pdata->ehci_data->reset_gpio_port[1], 0);
+                               (pdata->ehci_data->reset_gpio_port[1], 1);
        }
 
 end_count:
        omap->count++;
-       goto end_enable;
+       spin_unlock_irqrestore(&omap->lock, flags);
+       return 0;
 
 err_tll:
        if (pdata->ehci_data->phy_reset) {
@@ -931,8 +932,6 @@ err_tll:
        clk_disable(omap->usbhost_fs_fck);
        clk_disable(omap->usbhost_hs_fck);
        clk_disable(omap->usbhost_ick);
-
-end_enable:
        spin_unlock_irqrestore(&omap->lock, flags);
        return ret;
 }
@@ -997,22 +996,33 @@ static void usbhs_disable(struct device *dev)
                        dev_dbg(dev, "operation timed out\n");
        }
 
-       if (pdata->ehci_data->phy_reset) {
-               if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
-                       gpio_free(pdata->ehci_data->reset_gpio_port[0]);
-
-               if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
-                       gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+       if (is_omap_usbhs_rev2(omap)) {
+               if (is_ehci_tll_mode(pdata->port_mode[0]))
+                       clk_disable(omap->usbtll_p1_fck);
+               if (is_ehci_tll_mode(pdata->port_mode[1]))
+                       clk_disable(omap->usbtll_p2_fck);
+               clk_disable(omap->utmi_p2_fck);
+               clk_disable(omap->utmi_p1_fck);
        }
 
-       clk_disable(omap->utmi_p2_fck);
-       clk_disable(omap->utmi_p1_fck);
        clk_disable(omap->usbtll_ick);
        clk_disable(omap->usbtll_fck);
        clk_disable(omap->usbhost_fs_fck);
        clk_disable(omap->usbhost_hs_fck);
        clk_disable(omap->usbhost_ick);
 
+       /* The gpio_free migh sleep; so unlock the spinlock */
+       spin_unlock_irqrestore(&omap->lock, flags);
+
+       if (pdata->ehci_data->phy_reset) {
+               if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
+                       gpio_free(pdata->ehci_data->reset_gpio_port[0]);
+
+               if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+                       gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+       }
+       return;
+
 end_disble:
        spin_unlock_irqrestore(&omap->lock, flags);
 }