aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/host.c
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2013-08-14 05:44:04 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-14 15:34:17 -0400
commit40ed51a4b8588055ccd8e5420c76290659c4c974 (patch)
tree318195abfcad3595731be8bf3469611a1457959f /drivers/usb/chipidea/host.c
parent1542d9c35d8166c54e0616574954a0f48449f331 (diff)
usb: chipidea: host: add vbus regulator control
For boards which have board level vbus control (eg, through gpio), we need to vbus operation according to below rules: - For host, we need open vbus before start hcd, and close it after remove hcd. - For otg, the vbus needs to be on/off when usb role switches. When the host roles begins, it opens vbus; when the host role finishes, it closes vbus. We put vbus operation to host as host is the only vbus user, When we are at host mode, the vbus is on, when we are not at host mode, vbus should be off. Tested-by: Marek Vasut <marex@denx.de> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea/host.c')
-rw-r--r--drivers/usb/chipidea/host.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 9b3aaf132bc3..8cf8d28c88d6 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -24,6 +24,7 @@
24#include <linux/usb.h> 24#include <linux/usb.h>
25#include <linux/usb/hcd.h> 25#include <linux/usb/hcd.h>
26#include <linux/usb/chipidea.h> 26#include <linux/usb/chipidea.h>
27#include <linux/regulator/consumer.h>
27 28
28#include "../host/ehci.h" 29#include "../host/ehci.h"
29 30
@@ -65,9 +66,19 @@ static int host_start(struct ci_hdrc *ci)
65 ehci->has_hostpc = ci->hw_bank.lpm; 66 ehci->has_hostpc = ci->hw_bank.lpm;
66 ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; 67 ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
67 68
69 if (ci->platdata->reg_vbus) {
70 ret = regulator_enable(ci->platdata->reg_vbus);
71 if (ret) {
72 dev_err(ci->dev,
73 "Failed to enable vbus regulator, ret=%d\n",
74 ret);
75 goto put_hcd;
76 }
77 }
78
68 ret = usb_add_hcd(hcd, 0, 0); 79 ret = usb_add_hcd(hcd, 0, 0);
69 if (ret) 80 if (ret)
70 usb_put_hcd(hcd); 81 goto disable_reg;
71 else 82 else
72 ci->hcd = hcd; 83 ci->hcd = hcd;
73 84
@@ -75,6 +86,14 @@ static int host_start(struct ci_hdrc *ci)
75 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); 86 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
76 87
77 return ret; 88 return ret;
89
90disable_reg:
91 regulator_disable(ci->platdata->reg_vbus);
92
93put_hcd:
94 usb_put_hcd(hcd);
95
96 return ret;
78} 97}
79 98
80static void host_stop(struct ci_hdrc *ci) 99static void host_stop(struct ci_hdrc *ci)
@@ -83,6 +102,8 @@ static void host_stop(struct ci_hdrc *ci)
83 102
84 usb_remove_hcd(hcd); 103 usb_remove_hcd(hcd);
85 usb_put_hcd(hcd); 104 usb_put_hcd(hcd);
105 if (ci->platdata->reg_vbus)
106 regulator_disable(ci->platdata->reg_vbus);
86} 107}
87 108
88int ci_hdrc_host_init(struct ci_hdrc *ci) 109int ci_hdrc_host_init(struct ci_hdrc *ci)