Lines Matching +full:vbus +full:- +full:divider

1 // SPDX-License-Identifier: GPL-2.0+
73 { .compatible = "fsl,imx23-usb", .data = &imx23_usb_data},
74 { .compatible = "fsl,imx28-usb", .data = &imx28_usb_data},
75 { .compatible = "fsl,imx27-usb", .data = &imx27_usb_data},
76 { .compatible = "fsl,imx6q-usb", .data = &imx6q_usb_data},
77 { .compatible = "fsl,imx6sl-usb", .data = &imx6sl_usb_data},
78 { .compatible = "fsl,imx6sx-usb", .data = &imx6sx_usb_data},
79 { .compatible = "fsl,imx6ul-usb", .data = &imx6ul_usb_data},
80 { .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
81 { .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
102 /* --------------------------------- */
112 struct device_node *np = dev->of_node; in usbmisc_get_init_data()
126 return ERR_PTR(-ENOMEM); in usbmisc_get_init_data()
128 ret = of_parse_phandle_with_args(np, "fsl,usbmisc", "#index-cells", in usbmisc_get_init_data()
136 data->index = args.args[0]; in usbmisc_get_init_data()
142 return ERR_PTR(-EPROBE_DEFER); in usbmisc_get_init_data()
144 data->dev = &misc_pdev->dev; in usbmisc_get_init_data()
150 if (of_find_property(np, "disable-over-current", NULL)) { in usbmisc_get_init_data()
151 data->disable_oc = 1; in usbmisc_get_init_data()
152 } else if (of_find_property(np, "over-current-active-high", NULL)) { in usbmisc_get_init_data()
153 data->oc_pol_active_low = 0; in usbmisc_get_init_data()
154 data->oc_pol_configured = 1; in usbmisc_get_init_data()
155 } else if (of_find_property(np, "over-current-active-low", NULL)) { in usbmisc_get_init_data()
156 data->oc_pol_active_low = 1; in usbmisc_get_init_data()
157 data->oc_pol_configured = 1; in usbmisc_get_init_data()
162 data->pwr_pol = of_property_read_bool(np, "power-active-high"); in usbmisc_get_init_data()
163 data->evdo = of_property_read_bool(np, "external-vbus-divider"); in usbmisc_get_init_data()
166 data->ulpi = 1; in usbmisc_get_init_data()
168 of_property_read_u32(np, "samsung,picophy-pre-emp-curr-control", in usbmisc_get_init_data()
169 &data->emp_curr_control); in usbmisc_get_init_data()
170 of_property_read_u32(np, "samsung,picophy-dc-vol-level-adjust", in usbmisc_get_init_data()
171 &data->dc_vol_level_adjust); in usbmisc_get_init_data()
182 data->clk_ipg = devm_clk_get(dev, "ipg"); in imx_get_clks()
183 if (IS_ERR(data->clk_ipg)) { in imx_get_clks()
185 data->clk = devm_clk_get(dev, NULL); in imx_get_clks()
186 if (IS_ERR(data->clk)) { in imx_get_clks()
187 ret = PTR_ERR(data->clk); in imx_get_clks()
190 PTR_ERR(data->clk), PTR_ERR(data->clk_ipg)); in imx_get_clks()
196 data->clk_ahb = devm_clk_get(dev, "ahb"); in imx_get_clks()
197 if (IS_ERR(data->clk_ahb)) { in imx_get_clks()
198 ret = PTR_ERR(data->clk_ahb); in imx_get_clks()
204 data->clk_per = devm_clk_get(dev, "per"); in imx_get_clks()
205 if (IS_ERR(data->clk_per)) { in imx_get_clks()
206 ret = PTR_ERR(data->clk_per); in imx_get_clks()
212 data->need_three_clks = true; in imx_get_clks()
221 if (data->need_three_clks) { in imx_prepare_enable_clks()
222 ret = clk_prepare_enable(data->clk_ipg); in imx_prepare_enable_clks()
230 ret = clk_prepare_enable(data->clk_ahb); in imx_prepare_enable_clks()
235 clk_disable_unprepare(data->clk_ipg); in imx_prepare_enable_clks()
239 ret = clk_prepare_enable(data->clk_per); in imx_prepare_enable_clks()
244 clk_disable_unprepare(data->clk_ahb); in imx_prepare_enable_clks()
245 clk_disable_unprepare(data->clk_ipg); in imx_prepare_enable_clks()
249 ret = clk_prepare_enable(data->clk); in imx_prepare_enable_clks()
265 if (data->need_three_clks) { in imx_disable_unprepare_clks()
266 clk_disable_unprepare(data->clk_per); in imx_disable_unprepare_clks()
267 clk_disable_unprepare(data->clk_ahb); in imx_disable_unprepare_clks()
268 clk_disable_unprepare(data->clk_ipg); in imx_disable_unprepare_clks()
270 clk_disable_unprepare(data->clk); in imx_disable_unprepare_clks()
276 struct device *dev = ci->dev->parent; in ci_hdrc_imx_notify_event()
279 struct imx_usbmisc_data *mdata = data->usbmisc_data; in ci_hdrc_imx_notify_event()
283 if (data->pinctrl) { in ci_hdrc_imx_notify_event()
284 ret = pinctrl_select_state(data->pinctrl, in ci_hdrc_imx_notify_event()
285 data->pinctrl_hsic_active); in ci_hdrc_imx_notify_event()
299 if (ci->vbus_active) in ci_hdrc_imx_notify_event()
303 if (ci->usb_phy) in ci_hdrc_imx_notify_event()
304 schedule_work(&ci->usb_phy->chg_work); in ci_hdrc_imx_notify_event()
317 .name = dev_name(&pdev->dev), in ci_hdrc_imx_probe()
324 struct device_node *np = pdev->dev.of_node; in ci_hdrc_imx_probe()
325 struct device *dev = &pdev->dev; in ci_hdrc_imx_probe()
329 return -ENODEV; in ci_hdrc_imx_probe()
331 imx_platform_flag = of_id->data; in ci_hdrc_imx_probe()
333 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in ci_hdrc_imx_probe()
335 return -ENOMEM; in ci_hdrc_imx_probe()
337 data->plat_data = imx_platform_flag; in ci_hdrc_imx_probe()
338 pdata.flags |= imx_platform_flag->flags; in ci_hdrc_imx_probe()
340 data->usbmisc_data = usbmisc_get_init_data(dev); in ci_hdrc_imx_probe()
341 if (IS_ERR(data->usbmisc_data)) in ci_hdrc_imx_probe()
342 return PTR_ERR(data->usbmisc_data); in ci_hdrc_imx_probe()
344 if ((of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) in ci_hdrc_imx_probe()
345 && data->usbmisc_data) { in ci_hdrc_imx_probe()
347 data->usbmisc_data->hsic = 1; in ci_hdrc_imx_probe()
348 data->pinctrl = devm_pinctrl_get(dev); in ci_hdrc_imx_probe()
349 if (PTR_ERR(data->pinctrl) == -ENODEV) in ci_hdrc_imx_probe()
350 data->pinctrl = NULL; in ci_hdrc_imx_probe()
351 else if (IS_ERR(data->pinctrl)) { in ci_hdrc_imx_probe()
352 if (PTR_ERR(data->pinctrl) != -EPROBE_DEFER) in ci_hdrc_imx_probe()
354 PTR_ERR(data->pinctrl)); in ci_hdrc_imx_probe()
355 return PTR_ERR(data->pinctrl); in ci_hdrc_imx_probe()
358 data->hsic_pad_regulator = in ci_hdrc_imx_probe()
360 if (PTR_ERR(data->hsic_pad_regulator) == -ENODEV) { in ci_hdrc_imx_probe()
362 data->hsic_pad_regulator = NULL; in ci_hdrc_imx_probe()
363 } else if (IS_ERR(data->hsic_pad_regulator)) { in ci_hdrc_imx_probe()
364 if (PTR_ERR(data->hsic_pad_regulator) != -EPROBE_DEFER) in ci_hdrc_imx_probe()
367 PTR_ERR(data->hsic_pad_regulator)); in ci_hdrc_imx_probe()
368 return PTR_ERR(data->hsic_pad_regulator); in ci_hdrc_imx_probe()
371 if (data->hsic_pad_regulator) { in ci_hdrc_imx_probe()
372 ret = regulator_enable(data->hsic_pad_regulator); in ci_hdrc_imx_probe()
382 if (data->pinctrl) { in ci_hdrc_imx_probe()
385 pinctrl_hsic_idle = pinctrl_lookup_state(data->pinctrl, "idle"); in ci_hdrc_imx_probe()
393 ret = pinctrl_select_state(data->pinctrl, pinctrl_hsic_idle); in ci_hdrc_imx_probe()
399 data->pinctrl_hsic_active = pinctrl_lookup_state(data->pinctrl, in ci_hdrc_imx_probe()
401 if (IS_ERR(data->pinctrl_hsic_active)) { in ci_hdrc_imx_probe()
404 PTR_ERR(data->pinctrl_hsic_active)); in ci_hdrc_imx_probe()
405 return PTR_ERR(data->pinctrl_hsic_active); in ci_hdrc_imx_probe()
410 cpu_latency_qos_add_request(&data->pm_qos_req, 0); in ci_hdrc_imx_probe()
420 data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0); in ci_hdrc_imx_probe()
421 if (IS_ERR(data->phy)) { in ci_hdrc_imx_probe()
422 ret = PTR_ERR(data->phy); in ci_hdrc_imx_probe()
423 /* Return -EINVAL if no usbphy is available */ in ci_hdrc_imx_probe()
424 if (ret == -ENODEV) in ci_hdrc_imx_probe()
425 data->phy = NULL; in ci_hdrc_imx_probe()
430 pdata.usb_phy = data->phy; in ci_hdrc_imx_probe()
431 if (data->usbmisc_data) in ci_hdrc_imx_probe()
432 data->usbmisc_data->usb_phy = data->phy; in ci_hdrc_imx_probe()
434 if ((of_device_is_compatible(np, "fsl,imx53-usb") || in ci_hdrc_imx_probe()
435 of_device_is_compatible(np, "fsl,imx51-usb")) && pdata.usb_phy && in ci_hdrc_imx_probe()
438 data->override_phy_control = true; in ci_hdrc_imx_probe()
443 data->supports_runtime_pm = true; in ci_hdrc_imx_probe()
445 ret = imx_usbmisc_init(data->usbmisc_data); in ci_hdrc_imx_probe()
451 data->ci_pdev = ci_hdrc_add_device(dev, in ci_hdrc_imx_probe()
452 pdev->resource, pdev->num_resources, in ci_hdrc_imx_probe()
454 if (IS_ERR(data->ci_pdev)) { in ci_hdrc_imx_probe()
455 ret = PTR_ERR(data->ci_pdev); in ci_hdrc_imx_probe()
456 if (ret != -EPROBE_DEFER) in ci_hdrc_imx_probe()
462 if (data->usbmisc_data) { in ci_hdrc_imx_probe()
464 of_property_read_bool(np, "usb-role-switch")) in ci_hdrc_imx_probe()
465 data->usbmisc_data->ext_id = 1; in ci_hdrc_imx_probe()
468 of_property_read_bool(np, "usb-role-switch")) in ci_hdrc_imx_probe()
469 data->usbmisc_data->ext_vbus = 1; in ci_hdrc_imx_probe()
472 data->usbmisc_data->available_role = in ci_hdrc_imx_probe()
473 ci_hdrc_query_available_role(data->ci_pdev); in ci_hdrc_imx_probe()
476 ret = imx_usbmisc_init_post(data->usbmisc_data); in ci_hdrc_imx_probe()
482 if (data->supports_runtime_pm) { in ci_hdrc_imx_probe()
492 ci_hdrc_remove_device(data->ci_pdev); in ci_hdrc_imx_probe()
496 if (data->hsic_pad_regulator) in ci_hdrc_imx_probe()
498 regulator_disable(data->hsic_pad_regulator); in ci_hdrc_imx_probe()
500 cpu_latency_qos_remove_request(&data->pm_qos_req); in ci_hdrc_imx_probe()
501 data->ci_pdev = NULL; in ci_hdrc_imx_probe()
509 if (data->supports_runtime_pm) { in ci_hdrc_imx_remove()
510 pm_runtime_get_sync(&pdev->dev); in ci_hdrc_imx_remove()
511 pm_runtime_disable(&pdev->dev); in ci_hdrc_imx_remove()
512 pm_runtime_put_noidle(&pdev->dev); in ci_hdrc_imx_remove()
514 if (data->ci_pdev) in ci_hdrc_imx_remove()
515 ci_hdrc_remove_device(data->ci_pdev); in ci_hdrc_imx_remove()
516 if (data->override_phy_control) in ci_hdrc_imx_remove()
517 usb_phy_shutdown(data->phy); in ci_hdrc_imx_remove()
518 if (data->ci_pdev) { in ci_hdrc_imx_remove()
519 imx_disable_unprepare_clks(&pdev->dev); in ci_hdrc_imx_remove()
520 if (data->plat_data->flags & CI_HDRC_PMQOS) in ci_hdrc_imx_remove()
521 cpu_latency_qos_remove_request(&data->pm_qos_req); in ci_hdrc_imx_remove()
522 if (data->hsic_pad_regulator) in ci_hdrc_imx_remove()
523 regulator_disable(data->hsic_pad_regulator); in ci_hdrc_imx_remove()
541 ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, false); in imx_controller_suspend()
548 if (data->plat_data->flags & CI_HDRC_PMQOS) in imx_controller_suspend()
549 cpu_latency_qos_remove_request(&data->pm_qos_req); in imx_controller_suspend()
551 data->in_lpm = true; in imx_controller_suspend()
563 if (!data->in_lpm) { in imx_controller_resume()
568 if (data->plat_data->flags & CI_HDRC_PMQOS) in imx_controller_resume()
569 cpu_latency_qos_add_request(&data->pm_qos_req, 0); in imx_controller_resume()
575 data->in_lpm = false; in imx_controller_resume()
577 ret = imx_usbmisc_set_wakeup(data->usbmisc_data, false); in imx_controller_resume()
583 ret = imx_usbmisc_hsic_set_clk(data->usbmisc_data, true); in imx_controller_resume()
592 imx_usbmisc_set_wakeup(data->usbmisc_data, true); in imx_controller_resume()
604 if (data->in_lpm) in ci_hdrc_imx_suspend()
609 ret = imx_usbmisc_set_wakeup(data->usbmisc_data, true); in ci_hdrc_imx_suspend()
632 if (!ret && data->supports_runtime_pm) { in ci_hdrc_imx_resume()
646 if (data->in_lpm) { in ci_hdrc_imx_runtime_suspend()
651 ret = imx_usbmisc_set_wakeup(data->usbmisc_data, true); in ci_hdrc_imx_runtime_suspend()
683 MODULE_ALIAS("platform:imx-usb");