[PATCH 03/10] usb: chipidea: host:vbus control change for OTG HNP.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Li Jun <b47624@xxxxxxxxxxxxx>
---
 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 526cd77..bba54c3 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -66,7 +66,7 @@ static int host_start(struct ci_hdrc *ci)
 	ehci->has_hostpc = ci->hw_bank.lpm;
 	ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
 
-	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,
@@ -79,8 +79,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);
@@ -88,7 +93,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:
@@ -104,7 +109,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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux