Lines Matching refs:nop
10 * This provides a "nop" transceiver for PHYs which are
48 struct usb_phy_generic *nop = dev_get_drvdata(x->dev);
50 if (!IS_ERR(nop->clk)) {
52 clk_disable_unprepare(nop->clk);
54 clk_prepare_enable(nop->clk);
60 static void nop_reset(struct usb_phy_generic *nop)
62 if (!nop->gpiod_reset)
65 gpiod_set_value_cansleep(nop->gpiod_reset, 1);
67 gpiod_set_value_cansleep(nop->gpiod_reset, 0);
71 static void nop_set_vbus_draw(struct usb_phy_generic *nop, unsigned mA)
73 struct regulator *vbus_draw = nop->vbus_draw;
80 enabled = nop->vbus_draw_enabled;
87 nop->vbus_draw_enabled = 1;
94 nop->vbus_draw_enabled = 0;
97 nop->mA = mA;
103 struct usb_phy_generic *nop = data;
104 struct usb_otg *otg = nop->phy.otg;
107 vbus = gpiod_get_value(nop->gpiod_vbus);
108 if ((vbus ^ nop->vbus) == 0)
110 nop->vbus = vbus;
115 nop->phy.last_event = status;
118 nop_set_vbus_draw(nop, 100);
120 atomic_notifier_call_chain(&nop->phy.notifier, status,
123 nop_set_vbus_draw(nop, 0);
127 nop->phy.last_event = status;
129 atomic_notifier_call_chain(&nop->phy.notifier, status,
137 struct usb_phy_generic *nop = dev_get_drvdata(phy->dev);
140 if (!IS_ERR(nop->vcc)) {
141 if (regulator_enable(nop->vcc))
145 if (!IS_ERR(nop->clk)) {
146 ret = clk_prepare_enable(nop->clk);
151 nop_reset(nop);
159 struct usb_phy_generic *nop = dev_get_drvdata(phy->dev);
161 gpiod_set_value_cansleep(nop->gpiod_reset, 1);
163 if (!IS_ERR(nop->clk))
164 clk_disable_unprepare(nop->clk);
166 if (!IS_ERR(nop->vcc)) {
167 if (regulator_disable(nop->vcc))
206 int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
223 nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
225 err = PTR_ERR_OR_ZERO(nop->gpiod_reset);
227 nop->gpiod_vbus = devm_gpiod_get_optional(dev,
230 err = PTR_ERR_OR_ZERO(nop->gpiod_vbus);
239 if (nop->gpiod_reset)
240 gpiod_direction_output(nop->gpiod_reset, 1);
242 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg),
244 if (!nop->phy.otg)
247 nop->clk = devm_clk_get(dev, "main_clk");
248 if (IS_ERR(nop->clk)) {
250 PTR_ERR(nop->clk));
252 return PTR_ERR(nop->clk);
255 if (!IS_ERR(nop->clk) && clk_rate) {
256 err = clk_set_rate(nop->clk, clk_rate);
263 nop->vcc = devm_regulator_get(dev, "vcc");
264 if (IS_ERR(nop->vcc)) {
266 PTR_ERR(nop->vcc));
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),
278 nop->dev = dev;
279 nop->phy.dev = nop->dev;
280 nop->phy.label = "nop-xceiv";
281 nop->phy.set_suspend = nop_set_suspend;
282 nop->phy.type = type;
284 nop->phy.otg->state = OTG_STATE_UNDEFINED;
285 nop->phy.otg->usb_phy = &nop->phy;
286 nop->phy.otg->set_host = nop_set_host;
287 nop->phy.otg->set_peripheral = nop_set_peripheral;
296 struct usb_phy_generic *nop;
299 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL);
300 if (!nop)
303 err = usb_phy_gen_create_phy(dev, nop);
306 if (nop->gpiod_vbus) {
308 gpiod_to_irq(nop->gpiod_vbus),
311 nop);
314 gpiod_to_irq(nop->gpiod_vbus), err);
317 nop->phy.otg->state = gpiod_get_value(nop->gpiod_vbus) ?
321 nop->phy.init = usb_gen_phy_init;
322 nop->phy.shutdown = usb_gen_phy_shutdown;
324 err = usb_add_phy_dev(&nop->phy);
331 platform_set_drvdata(pdev, nop);
338 struct usb_phy_generic *nop = platform_get_drvdata(pdev);
340 usb_remove_phy(&nop->phy);
346 { .compatible = "usb-nop-xceiv" },