diff options
author | Olof Johansson <olof@lixom.net> | 2013-12-26 13:31:33 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2013-12-26 13:31:33 -0500 |
commit | 509633c8366a0df239297c89689e87aaf6625781 (patch) | |
tree | 887622d77f0f2dc3886f52fdbe3f389df337dca1 /drivers/usb/phy/phy-generic.c | |
parent | bb748890d13232dba4a3975368bfeea6896368ae (diff) | |
parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) |
Merge tag 'v3.13-rc4' into next/cleanup
Linux 3.13-rc4
Diffstat (limited to 'drivers/usb/phy/phy-generic.c')
-rw-r--r-- | drivers/usb/phy/phy-generic.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index fce3a9e9bb5d..aa6d37b3378a 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c | |||
@@ -48,8 +48,9 @@ void usb_nop_xceiv_register(void) | |||
48 | if (pd) | 48 | if (pd) |
49 | return; | 49 | return; |
50 | pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0); | 50 | pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0); |
51 | if (!pd) { | 51 | if (IS_ERR(pd)) { |
52 | pr_err("Unable to register generic usb transceiver\n"); | 52 | pr_err("Unable to register generic usb transceiver\n"); |
53 | pd = NULL; | ||
53 | return; | 54 | return; |
54 | } | 55 | } |
55 | } | 56 | } |
@@ -150,10 +151,40 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
150 | } | 151 | } |
151 | 152 | ||
152 | int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, | 153 | int 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) | 154 | struct usb_phy_gen_xceiv_platform_data *pdata) |
154 | { | 155 | { |
156 | enum usb_phy_type type = USB_PHY_TYPE_USB2; | ||
155 | int err; | 157 | int err; |
156 | 158 | ||
159 | u32 clk_rate = 0; | ||
160 | bool needs_vcc = false; | ||
161 | |||
162 | nop->reset_active_low = true; /* default behaviour */ | ||
163 | |||
164 | if (dev->of_node) { | ||
165 | struct device_node *node = dev->of_node; | ||
166 | enum of_gpio_flags flags = 0; | ||
167 | |||
168 | if (of_property_read_u32(node, "clock-frequency", &clk_rate)) | ||
169 | clk_rate = 0; | ||
170 | |||
171 | needs_vcc = of_property_read_bool(node, "vcc-supply"); | ||
172 | nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios", | ||
173 | 0, &flags); | ||
174 | if (nop->gpio_reset == -EPROBE_DEFER) | ||
175 | return -EPROBE_DEFER; | ||
176 | |||
177 | nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
178 | |||
179 | } else if (pdata) { | ||
180 | type = pdata->type; | ||
181 | clk_rate = pdata->clk_rate; | ||
182 | needs_vcc = pdata->needs_vcc; | ||
183 | nop->gpio_reset = pdata->gpio_reset; | ||
184 | } else { | ||
185 | nop->gpio_reset = -1; | ||
186 | } | ||
187 | |||
157 | nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), | 188 | nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), |
158 | GFP_KERNEL); | 189 | GFP_KERNEL); |
159 | if (!nop->phy.otg) | 190 | if (!nop->phy.otg) |
@@ -218,43 +249,14 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); | |||
218 | static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) | 249 | static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) |
219 | { | 250 | { |
220 | struct device *dev = &pdev->dev; | 251 | 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; | 252 | struct usb_phy_gen_xceiv *nop; |
224 | enum usb_phy_type type = USB_PHY_TYPE_USB2; | ||
225 | int err; | 253 | int err; |
226 | u32 clk_rate = 0; | ||
227 | bool needs_vcc = false; | ||
228 | 254 | ||
229 | nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); | 255 | nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); |
230 | if (!nop) | 256 | if (!nop) |
231 | return -ENOMEM; | 257 | return -ENOMEM; |
232 | 258 | ||
233 | nop->reset_active_low = true; /* default behaviour */ | 259 | 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) | 260 | if (err) |
259 | return err; | 261 | return err; |
260 | 262 | ||
@@ -271,8 +273,6 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) | |||
271 | platform_set_drvdata(pdev, nop); | 273 | platform_set_drvdata(pdev, nop); |
272 | 274 | ||
273 | return 0; | 275 | return 0; |
274 | |||
275 | return err; | ||
276 | } | 276 | } |
277 | 277 | ||
278 | static int usb_phy_gen_xceiv_remove(struct platform_device *pdev) | 278 | static int usb_phy_gen_xceiv_remove(struct platform_device *pdev) |