aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy/omap-usb2.c
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2013-01-25 05:24:00 -0500
committerFelipe Balbi <balbi@ti.com>2013-01-25 05:27:24 -0500
commitca784be36cc725bca9b526eba342de7550329731 (patch)
tree23f0da8e88f81d73587e06a6d295260d50494eb7 /drivers/usb/phy/omap-usb2.c
parent01658f0f8d1322dbf94f289aa610731d539bf888 (diff)
usb: start using the control module driver
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy/omap-usb2.c')
-rw-r--r--drivers/usb/phy/omap-usb2.c41
1 files changed, 8 insertions, 33 deletions
diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c
index 26ae8f49225c..c2b4c8e6f3c6 100644
--- a/drivers/usb/phy/omap-usb2.c
+++ b/drivers/usb/phy/omap-usb2.c
@@ -27,6 +27,7 @@
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/usb/omap_control_usb.h>
30 31
31/** 32/**
32 * omap_usb2_set_comparator - links the comparator present in the sytem with 33 * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -52,29 +53,6 @@ int omap_usb2_set_comparator(struct phy_companion *comparator)
52} 53}
53EXPORT_SYMBOL_GPL(omap_usb2_set_comparator); 54EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);
54 55
55/**
56 * omap_usb_phy_power - power on/off the phy using control module reg
57 * @phy: struct omap_usb *
58 * @on: 0 or 1, based on powering on or off the PHY
59 *
60 * XXX: Remove this function once control module driver gets merged
61 */
62static void omap_usb_phy_power(struct omap_usb *phy, int on)
63{
64 u32 val;
65
66 if (on) {
67 val = readl(phy->control_dev);
68 if (val & PHY_PD) {
69 writel(~PHY_PD, phy->control_dev);
70 /* XXX: add proper documentation for this delay */
71 mdelay(200);
72 }
73 } else {
74 writel(PHY_PD, phy->control_dev);
75 }
76}
77
78static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled) 56static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
79{ 57{
80 struct omap_usb *phy = phy_to_omapusb(otg->phy); 58 struct omap_usb *phy = phy_to_omapusb(otg->phy);
@@ -124,7 +102,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
124 struct omap_usb *phy = phy_to_omapusb(x); 102 struct omap_usb *phy = phy_to_omapusb(x);
125 103
126 if (suspend && !phy->is_suspended) { 104 if (suspend && !phy->is_suspended) {
127 omap_usb_phy_power(phy, 0); 105 omap_control_usb_phy_power(phy->control_dev, 0);
128 pm_runtime_put_sync(phy->dev); 106 pm_runtime_put_sync(phy->dev);
129 phy->is_suspended = 1; 107 phy->is_suspended = 1;
130 } else if (!suspend && phy->is_suspended) { 108 } else if (!suspend && phy->is_suspended) {
@@ -134,7 +112,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
134 ret); 112 ret);
135 return ret; 113 return ret;
136 } 114 }
137 omap_usb_phy_power(phy, 1); 115 omap_control_usb_phy_power(phy->control_dev, 1);
138 phy->is_suspended = 0; 116 phy->is_suspended = 0;
139 } 117 }
140 118
@@ -145,7 +123,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
145{ 123{
146 struct omap_usb *phy; 124 struct omap_usb *phy;
147 struct usb_otg *otg; 125 struct usb_otg *otg;
148 struct resource *res;
149 126
150 phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); 127 phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
151 if (!phy) { 128 if (!phy) {
@@ -166,16 +143,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
166 phy->phy.set_suspend = omap_usb2_suspend; 143 phy->phy.set_suspend = omap_usb2_suspend;
167 phy->phy.otg = otg; 144 phy->phy.otg = otg;
168 145
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 146 phy->control_dev = omap_get_control_dev();
170 147 if (IS_ERR(phy->control_dev)) {
171 phy->control_dev = devm_request_and_ioremap(&pdev->dev, res); 148 dev_dbg(&pdev->dev, "Failed to get control device\n");
172 if (phy->control_dev == NULL) { 149 return -ENODEV;
173 dev_err(&pdev->dev, "Failed to obtain io memory\n");
174 return -ENXIO;
175 } 150 }
176 151
177 phy->is_suspended = 1; 152 phy->is_suspended = 1;
178 omap_usb_phy_power(phy, 0); 153 omap_control_usb_phy_power(phy->control_dev, 0);
179 154
180 otg->set_host = omap_usb_set_host; 155 otg->set_host = omap_usb_set_host;
181 otg->set_peripheral = omap_usb_set_peripheral; 156 otg->set_peripheral = omap_usb_set_peripheral;