aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-10-24 10:45:29 -0400
committerFelipe Balbi <balbi@ti.com>2013-11-25 11:25:57 -0500
commitaf9f51c5512f9d55972603dd5dd90d0fa300b200 (patch)
tree599735437d547dfd14d23d67a4028c507e6a5762
parent39189c98d161c292e7f80fe50da00d33193362b9 (diff)
usb: phy: generic: fix how we find out about our resources
instead of having each user of generic phy find out about its own resources and pass it to the core layer, have th core layer itself figure that out. It's as simple as moving a piece of code around. This fixes a big regression caused during the merge window where am335x-based platforms wouldn't be able to probe their PHY driver. Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/phy/phy-am335x.c3
-rw-r--r--drivers/usb/phy/phy-generic.c61
-rw-r--r--drivers/usb/phy/phy-generic.h4
3 files changed, 34 insertions, 34 deletions
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index 48d41abd1b6b..0e3c60cb669a 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -52,8 +52,7 @@ static int am335x_phy_probe(struct platform_device *pdev)
52 return am_phy->id; 52 return am_phy->id;
53 } 53 }
54 54
55 ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, 55 ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, NULL);
56 USB_PHY_TYPE_USB2, 0, false);
57 if (ret) 56 if (ret)
58 return ret; 57 return ret;
59 58
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index db4fc22e4aa6..0c3b24124063 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -150,10 +150,38 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
150} 150}
151 151
152int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 152int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
153 enum usb_phy_type type, u32 clk_rate, bool needs_vcc) 153 struct usb_phy_gen_xceiv_platform_data *pdata)
154{ 154{
155 enum usb_phy_type type = USB_PHY_TYPE_USB2;
155 int err; 156 int err;
156 157
158 u32 clk_rate = 0;
159 bool needs_vcc = false;
160
161 nop->reset_active_low = true; /* default behaviour */
162
163 if (dev->of_node) {
164 struct device_node *node = dev->of_node;
165 enum of_gpio_flags flags;
166
167 if (of_property_read_u32(node, "clock-frequency", &clk_rate))
168 clk_rate = 0;
169
170 needs_vcc = of_property_read_bool(node, "vcc-supply");
171 nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
172 0, &flags);
173 if (nop->gpio_reset == -EPROBE_DEFER)
174 return -EPROBE_DEFER;
175
176 nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
177
178 } else if (pdata) {
179 type = pdata->type;
180 clk_rate = pdata->clk_rate;
181 needs_vcc = pdata->needs_vcc;
182 nop->gpio_reset = pdata->gpio_reset;
183 }
184
157 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), 185 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg),
158 GFP_KERNEL); 186 GFP_KERNEL);
159 if (!nop->phy.otg) 187 if (!nop->phy.otg)
@@ -218,43 +246,14 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy);
218static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) 246static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
219{ 247{
220 struct device *dev = &pdev->dev; 248 struct device *dev = &pdev->dev;
221 struct usb_phy_gen_xceiv_platform_data *pdata =
222 dev_get_platdata(&pdev->dev);
223 struct usb_phy_gen_xceiv *nop; 249 struct usb_phy_gen_xceiv *nop;
224 enum usb_phy_type type = USB_PHY_TYPE_USB2;
225 int err; 250 int err;
226 u32 clk_rate = 0;
227 bool needs_vcc = false;
228 251
229 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); 252 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL);
230 if (!nop) 253 if (!nop)
231 return -ENOMEM; 254 return -ENOMEM;
232 255
233 nop->reset_active_low = true; /* default behaviour */ 256 err = usb_phy_gen_create_phy(dev, nop, dev_get_platdata(&pdev->dev));
234
235 if (dev->of_node) {
236 struct device_node *node = dev->of_node;
237 enum of_gpio_flags flags;
238
239 if (of_property_read_u32(node, "clock-frequency", &clk_rate))
240 clk_rate = 0;
241
242 needs_vcc = of_property_read_bool(node, "vcc-supply");
243 nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
244 0, &flags);
245 if (nop->gpio_reset == -EPROBE_DEFER)
246 return -EPROBE_DEFER;
247
248 nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
249
250 } else if (pdata) {
251 type = pdata->type;
252 clk_rate = pdata->clk_rate;
253 needs_vcc = pdata->needs_vcc;
254 nop->gpio_reset = pdata->gpio_reset;
255 }
256
257 err = usb_phy_gen_create_phy(dev, nop, type, clk_rate, needs_vcc);
258 if (err) 257 if (err)
259 return err; 258 return err;
260 259
diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h
index d2a220d81734..38a81f307b82 100644
--- a/drivers/usb/phy/phy-generic.h
+++ b/drivers/usb/phy/phy-generic.h
@@ -1,6 +1,8 @@
1#ifndef _PHY_GENERIC_H_ 1#ifndef _PHY_GENERIC_H_
2#define _PHY_GENERIC_H_ 2#define _PHY_GENERIC_H_
3 3
4#include <linux/usb/usb_phy_gen_xceiv.h>
5
4struct usb_phy_gen_xceiv { 6struct usb_phy_gen_xceiv {
5 struct usb_phy phy; 7 struct usb_phy phy;
6 struct device *dev; 8 struct device *dev;
@@ -14,6 +16,6 @@ int usb_gen_phy_init(struct usb_phy *phy);
14void usb_gen_phy_shutdown(struct usb_phy *phy); 16void usb_gen_phy_shutdown(struct usb_phy *phy);
15 17
16int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 18int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
17 enum usb_phy_type type, u32 clk_rate, bool needs_vcc); 19 struct usb_phy_gen_xceiv_platform_data *pdata);
18 20
19#endif 21#endif