hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/usb/phy/phy-generic.c
....@@ -21,8 +21,7 @@
2121 #include <linux/clk.h>
2222 #include <linux/regulator/consumer.h>
2323 #include <linux/of.h>
24
-#include <linux/of_gpio.h>
25
-#include <linux/gpio.h>
24
+#include <linux/gpio/consumer.h>
2625 #include <linux/delay.h>
2726
2827 #include "phy-generic.h"
....@@ -204,8 +203,7 @@
204203 return 0;
205204 }
206205
207
-int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
208
- struct usb_phy_generic_platform_data *pdata)
206
+int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
209207 {
210208 enum usb_phy_type type = USB_PHY_TYPE_USB2;
211209 int err = 0;
....@@ -221,28 +219,15 @@
221219
222220 needs_vcc = of_property_read_bool(node, "vcc-supply");
223221 needs_clk = of_property_read_bool(node, "clocks");
224
- nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
225
- GPIOD_ASIS);
226
- err = PTR_ERR_OR_ZERO(nop->gpiod_reset);
227
- if (!err) {
228
- nop->gpiod_vbus = devm_gpiod_get_optional(dev,
229
- "vbus-detect",
230
- GPIOD_ASIS);
231
- err = PTR_ERR_OR_ZERO(nop->gpiod_vbus);
232
- }
233
- } else if (pdata) {
234
- type = pdata->type;
235
- clk_rate = pdata->clk_rate;
236
- needs_vcc = pdata->needs_vcc;
237
- if (gpio_is_valid(pdata->gpio_reset)) {
238
- err = devm_gpio_request_one(dev, pdata->gpio_reset,
239
- GPIOF_ACTIVE_LOW,
240
- dev_name(dev));
241
- if (!err)
242
- nop->gpiod_reset =
243
- gpio_to_desc(pdata->gpio_reset);
244
- }
245
- nop->gpiod_vbus = pdata->gpiod_vbus;
222
+ }
223
+ nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
224
+ GPIOD_ASIS);
225
+ err = PTR_ERR_OR_ZERO(nop->gpiod_reset);
226
+ if (!err) {
227
+ nop->gpiod_vbus = devm_gpiod_get_optional(dev,
228
+ "vbus-detect",
229
+ GPIOD_ASIS);
230
+ err = PTR_ERR_OR_ZERO(nop->gpiod_vbus);
246231 }
247232
248233 if (err == -EPROBE_DEFER)
....@@ -283,6 +268,13 @@
283268 return -EPROBE_DEFER;
284269 }
285270
271
+ nop->vbus_draw = devm_regulator_get_exclusive(dev, "vbus");
272
+ if (PTR_ERR(nop->vbus_draw) == -ENODEV)
273
+ nop->vbus_draw = NULL;
274
+ if (IS_ERR(nop->vbus_draw))
275
+ return dev_err_probe(dev, PTR_ERR(nop->vbus_draw),
276
+ "could not get vbus regulator\n");
277
+
286278 nop->dev = dev;
287279 nop->phy.dev = nop->dev;
288280 nop->phy.label = "nop-xceiv";
....@@ -308,7 +300,7 @@
308300 if (!nop)
309301 return -ENOMEM;
310302
311
- err = usb_phy_gen_create_phy(dev, nop, dev_get_platdata(&pdev->dev));
303
+ err = usb_phy_gen_create_phy(dev, nop);
312304 if (err)
313305 return err;
314306 if (nop->gpiod_vbus) {