summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jun <b47624@freescale.com>2015-02-03 13:59:10 +0800
committerLi Jun <jun.li@freescale.com>2015-02-11 15:35:40 +0800
commit15290d39e1ba88d9c27c69f4691a14681a5cf42d (patch)
treec585d83a6ea080db4c8a0e405c03b19ad1a9a7b8
parent83f839d2e5d4783c51abce433f177c82b1a3ec9c (diff)
MLK-10179-2 usb: chipidea: host: turn on vbus before add hcd if early vbus on is required
If CI_HDRC_IMX_VBUS_EARLY_ON is set, turn on vbus before add hcd, and do not set reg_vbus of ehci_ci_priv, so vbus will not be handled by ehci core. Signed-off-by: Li Jun <jun.li@freescale.com> (cherry picked from commit a745133191bfe0c2ca408d9f8bcfc2a5204b0dbd)
-rw-r--r--drivers/usb/chipidea/host.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 4bfb1d43532b..5a8743877297 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -63,11 +63,10 @@ static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable)
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
struct ehci_ci_priv *priv = (struct ehci_ci_priv *)ehci->priv;
struct device *dev = hcd->self.controller;
- struct ci_hdrc *ci = dev_get_drvdata(dev);
int ret = 0;
int port = HCS_N_PORTS(ehci->hcs_params);
- if (priv->reg_vbus && !ci_otg_is_fsm_mode(ci)) {
+ if (priv->reg_vbus) {
if (port > 1) {
dev_warn(dev,
"Not support multi-port regulator control\n");
@@ -253,12 +252,23 @@ static int host_start(struct ci_hdrc *ci)
priv = (struct ehci_ci_priv *)ehci->priv;
priv->reg_vbus = NULL;
- if (ci->platdata->reg_vbus)
- priv->reg_vbus = ci->platdata->reg_vbus;
+ if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) {
+ if (ci->platdata->flags & CI_HDRC_IMX_VBUS_EARLY_ON) {
+ ret = regulator_enable(ci->platdata->reg_vbus);
+ if (ret) {
+ dev_err(ci->dev,
+ "Failed to enable vbus regulator, ret=%d\n",
+ ret);
+ goto put_hcd;
+ }
+ } else {
+ priv->reg_vbus = ci->platdata->reg_vbus;
+ }
+ }
ret = usb_add_hcd(hcd, 0, 0);
if (ret) {
- goto put_hcd;
+ goto disable_reg;
} else {
struct usb_otg *otg = &ci->otg;
@@ -286,6 +296,10 @@ static int host_start(struct ci_hdrc *ci)
return ret;
+disable_reg:
+ if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) &&
+ (ci->platdata->flags & CI_HDRC_IMX_VBUS_EARLY_ON))
+ regulator_disable(ci->platdata->reg_vbus);
put_hcd:
usb_put_hcd(hcd);
@@ -299,6 +313,9 @@ static void host_stop(struct ci_hdrc *ci)
if (hcd) {
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
+ if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) &&
+ (ci->platdata->flags & CI_HDRC_IMX_VBUS_EARLY_ON))
+ regulator_disable(ci->platdata->reg_vbus);
}
ci->hcd = NULL;
}