Leave vbus on/off hanlded by OTG fsm if in OTG mode, init OTG port number.

Signed-off-by: Li Jun <b47...@freescale.com>
---
 drivers/usb/chipidea/host.c |   13 +++++++++----
 drivers/usb/chipidea/host.h |    9 +++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index a8ac6c1..5ec8ccd 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -67,7 +67,7 @@ static int host_start(struct ci_hdrc *ci)
        ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
        ehci->imx28_write_fix = ci->imx28_write_fix;
 
-       if (ci->platdata->reg_vbus) {
+       if (ci->platdata->reg_vbus && !ci_host_is_otg(ci)) {
                ret = regulator_enable(ci->platdata->reg_vbus);
                if (ret) {
                        dev_err(ci->dev,
@@ -80,8 +80,13 @@ static int host_start(struct ci_hdrc *ci)
        ret = usb_add_hcd(hcd, 0, 0);
        if (ret)
                goto disable_reg;
-       else
+       else {
                ci->hcd = hcd;
+               if (ci_host_is_otg(ci)) {
+                       ci->transceiver->otg->host = &hcd->self;
+                       ci->transceiver->otg->host->otg_port = 1;
+               }
+       }
 
        if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
                hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
@@ -89,7 +94,7 @@ static int host_start(struct ci_hdrc *ci)
        return ret;
 
 disable_reg:
-       if (ci->platdata->reg_vbus)
+       if (ci->platdata->reg_vbus && !ci_host_is_otg(ci))
                regulator_disable(ci->platdata->reg_vbus);
 
 put_hcd:
@@ -105,7 +110,7 @@ static void host_stop(struct ci_hdrc *ci)
        if (hcd) {
                usb_remove_hcd(hcd);
                usb_put_hcd(hcd);
-               if (ci->platdata->reg_vbus)
+               if (ci->platdata->reg_vbus && !ci_host_is_otg(ci))
                        regulator_disable(ci->platdata->reg_vbus);
        }
 }
diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h
index 5707bf3..f98d084 100644
--- a/drivers/usb/chipidea/host.h
+++ b/drivers/usb/chipidea/host.h
@@ -6,6 +6,15 @@
 int ci_hdrc_host_init(struct ci_hdrc *ci);
 void ci_hdrc_host_destroy(struct ci_hdrc *ci);
 
+static inline bool ci_host_is_otg(struct ci_hdrc *ci)
+{
+#ifdef CONFIG_USB_OTG_FSM
+       return (ci->is_otg) && (ci->platdata->dr_mode == USB_DR_MODE_OTG);
+#else
+       return false;
+#endif
+}
+
 #else
 
 static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
-- 
1.7.8


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to