Lines Matching full:qcom
120 static void dwc3_qcom_vbus_override_enable(struct dwc3_qcom *qcom, bool enable) in dwc3_qcom_vbus_override_enable() argument
123 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_SS_PHY_CTRL, in dwc3_qcom_vbus_override_enable()
125 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL, in dwc3_qcom_vbus_override_enable()
128 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_SS_PHY_CTRL, in dwc3_qcom_vbus_override_enable()
130 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL, in dwc3_qcom_vbus_override_enable()
138 struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, vbus_nb); in dwc3_qcom_vbus_notifier() local
141 dwc3_qcom_vbus_override_enable(qcom, event); in dwc3_qcom_vbus_notifier()
142 qcom->mode = event ? USB_DR_MODE_PERIPHERAL : USB_DR_MODE_HOST; in dwc3_qcom_vbus_notifier()
150 struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, host_nb); in dwc3_qcom_host_notifier() local
153 dwc3_qcom_vbus_override_enable(qcom, !event); in dwc3_qcom_host_notifier()
154 qcom->mode = event ? USB_DR_MODE_HOST : USB_DR_MODE_PERIPHERAL; in dwc3_qcom_host_notifier()
159 static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom) in dwc3_qcom_register_extcon() argument
161 struct device *dev = qcom->dev; in dwc3_qcom_register_extcon()
168 qcom->edev = extcon_get_edev_by_phandle(dev, 0); in dwc3_qcom_register_extcon()
169 if (IS_ERR(qcom->edev)) in dwc3_qcom_register_extcon()
170 return PTR_ERR(qcom->edev); in dwc3_qcom_register_extcon()
172 qcom->vbus_nb.notifier_call = dwc3_qcom_vbus_notifier; in dwc3_qcom_register_extcon()
174 qcom->host_edev = extcon_get_edev_by_phandle(dev, 1); in dwc3_qcom_register_extcon()
175 if (IS_ERR(qcom->host_edev)) in dwc3_qcom_register_extcon()
176 qcom->host_edev = NULL; in dwc3_qcom_register_extcon()
178 ret = devm_extcon_register_notifier(dev, qcom->edev, EXTCON_USB, in dwc3_qcom_register_extcon()
179 &qcom->vbus_nb); in dwc3_qcom_register_extcon()
185 if (qcom->host_edev) in dwc3_qcom_register_extcon()
186 host_edev = qcom->host_edev; in dwc3_qcom_register_extcon()
188 host_edev = qcom->edev; in dwc3_qcom_register_extcon()
190 qcom->host_nb.notifier_call = dwc3_qcom_host_notifier; in dwc3_qcom_register_extcon()
192 &qcom->host_nb); in dwc3_qcom_register_extcon()
199 if (extcon_get_state(qcom->edev, EXTCON_USB) || in dwc3_qcom_register_extcon()
201 dwc3_qcom_vbus_notifier(&qcom->vbus_nb, true, qcom->edev); in dwc3_qcom_register_extcon()
203 dwc3_qcom_vbus_notifier(&qcom->vbus_nb, false, qcom->edev); in dwc3_qcom_register_extcon()
208 static int dwc3_qcom_interconnect_enable(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_enable() argument
212 ret = icc_enable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_enable()
216 ret = icc_enable(qcom->icc_path_apps); in dwc3_qcom_interconnect_enable()
218 icc_disable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_enable()
223 static int dwc3_qcom_interconnect_disable(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_disable() argument
227 ret = icc_disable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_disable()
231 ret = icc_disable(qcom->icc_path_apps); in dwc3_qcom_interconnect_disable()
233 icc_enable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_disable()
241 * @qcom: Pointer to the concerned usb core.
244 static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_init() argument
247 struct device *dev = qcom->dev; in dwc3_qcom_interconnect_init()
253 qcom->icc_path_ddr = of_icc_get(dev, "usb-ddr"); in dwc3_qcom_interconnect_init()
254 if (IS_ERR(qcom->icc_path_ddr)) { in dwc3_qcom_interconnect_init()
256 PTR_ERR(qcom->icc_path_ddr)); in dwc3_qcom_interconnect_init()
257 return PTR_ERR(qcom->icc_path_ddr); in dwc3_qcom_interconnect_init()
260 qcom->icc_path_apps = of_icc_get(dev, "apps-usb"); in dwc3_qcom_interconnect_init()
261 if (IS_ERR(qcom->icc_path_apps)) { in dwc3_qcom_interconnect_init()
263 PTR_ERR(qcom->icc_path_apps)); in dwc3_qcom_interconnect_init()
264 return PTR_ERR(qcom->icc_path_apps); in dwc3_qcom_interconnect_init()
267 max_speed = usb_get_maximum_speed(&qcom->dwc3->dev); in dwc3_qcom_interconnect_init()
269 ret = icc_set_bw(qcom->icc_path_ddr, in dwc3_qcom_interconnect_init()
272 ret = icc_set_bw(qcom->icc_path_ddr, in dwc3_qcom_interconnect_init()
280 ret = icc_set_bw(qcom->icc_path_apps, APPS_USB_AVG_BW, APPS_USB_PEAK_BW); in dwc3_qcom_interconnect_init()
291 * @qcom: Pointer to the concerned usb core.
295 static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_exit() argument
297 icc_put(qcom->icc_path_ddr); in dwc3_qcom_interconnect_exit()
298 icc_put(qcom->icc_path_apps); in dwc3_qcom_interconnect_exit()
302 static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom) in dwc3_qcom_is_host() argument
304 struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); in dwc3_qcom_is_host()
309 static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom) in dwc3_qcom_read_usb2_speed() argument
311 struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); in dwc3_qcom_read_usb2_speed()
358 static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) in dwc3_qcom_disable_interrupts() argument
360 dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq); in dwc3_qcom_disable_interrupts()
362 if (qcom->usb2_speed == USB_SPEED_LOW) { in dwc3_qcom_disable_interrupts()
363 dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); in dwc3_qcom_disable_interrupts()
364 } else if ((qcom->usb2_speed == USB_SPEED_HIGH) || in dwc3_qcom_disable_interrupts()
365 (qcom->usb2_speed == USB_SPEED_FULL)) { in dwc3_qcom_disable_interrupts()
366 dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); in dwc3_qcom_disable_interrupts()
368 dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); in dwc3_qcom_disable_interrupts()
369 dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); in dwc3_qcom_disable_interrupts()
372 dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq); in dwc3_qcom_disable_interrupts()
375 static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) in dwc3_qcom_enable_interrupts() argument
377 dwc3_qcom_enable_wakeup_irq(qcom->hs_phy_irq, 0); in dwc3_qcom_enable_interrupts()
388 if (qcom->usb2_speed == USB_SPEED_LOW) { in dwc3_qcom_enable_interrupts()
389 dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq, in dwc3_qcom_enable_interrupts()
391 } else if ((qcom->usb2_speed == USB_SPEED_HIGH) || in dwc3_qcom_enable_interrupts()
392 (qcom->usb2_speed == USB_SPEED_FULL)) { in dwc3_qcom_enable_interrupts()
393 dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq, in dwc3_qcom_enable_interrupts()
396 dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq, in dwc3_qcom_enable_interrupts()
398 dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq, in dwc3_qcom_enable_interrupts()
402 dwc3_qcom_enable_wakeup_irq(qcom->ss_phy_irq, 0); in dwc3_qcom_enable_interrupts()
405 static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) in dwc3_qcom_suspend() argument
410 if (qcom->is_suspended) in dwc3_qcom_suspend()
413 val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); in dwc3_qcom_suspend()
415 dev_err(qcom->dev, "HS-PHY not in L2\n"); in dwc3_qcom_suspend()
417 for (i = qcom->num_clocks - 1; i >= 0; i--) in dwc3_qcom_suspend()
418 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_suspend()
420 ret = dwc3_qcom_interconnect_disable(qcom); in dwc3_qcom_suspend()
422 dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret); in dwc3_qcom_suspend()
428 if (dwc3_qcom_is_host(qcom) && wakeup) { in dwc3_qcom_suspend()
429 qcom->usb2_speed = dwc3_qcom_read_usb2_speed(qcom); in dwc3_qcom_suspend()
430 dwc3_qcom_enable_interrupts(qcom); in dwc3_qcom_suspend()
433 qcom->is_suspended = true; in dwc3_qcom_suspend()
438 static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) in dwc3_qcom_resume() argument
443 if (!qcom->is_suspended) in dwc3_qcom_resume()
446 if (dwc3_qcom_is_host(qcom) && wakeup) in dwc3_qcom_resume()
447 dwc3_qcom_disable_interrupts(qcom); in dwc3_qcom_resume()
449 for (i = 0; i < qcom->num_clocks; i++) { in dwc3_qcom_resume()
450 ret = clk_prepare_enable(qcom->clks[i]); in dwc3_qcom_resume()
453 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_resume()
458 ret = dwc3_qcom_interconnect_enable(qcom); in dwc3_qcom_resume()
460 dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret); in dwc3_qcom_resume()
463 dwc3_qcom_setbits(qcom->qscratch_base, PWR_EVNT_IRQ_STAT_REG, in dwc3_qcom_resume()
466 qcom->is_suspended = false; in dwc3_qcom_resume()
473 struct dwc3_qcom *qcom = data; in qcom_dwc3_resume_irq() local
474 struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); in qcom_dwc3_resume_irq()
477 if (qcom->pm_suspended) in qcom_dwc3_resume_irq()
484 if (dwc3_qcom_is_host(qcom)) in qcom_dwc3_resume_irq()
490 static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom) in dwc3_qcom_select_utmi_clk() argument
493 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
498 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
503 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
510 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_get_irq() local
511 struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : pdev; in dwc3_qcom_get_irq()
525 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_setup_irq() local
526 const struct dwc3_acpi_pdata *pdata = qcom->acpi_pdata; in dwc3_qcom_setup_irq()
535 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
538 "qcom_dwc3 HS", qcom); in dwc3_qcom_setup_irq()
540 dev_err(qcom->dev, "hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
543 qcom->hs_phy_irq = irq; in dwc3_qcom_setup_irq()
550 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
553 "qcom_dwc3 DP_HS", qcom); in dwc3_qcom_setup_irq()
555 dev_err(qcom->dev, "dp_hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
558 qcom->dp_hs_phy_irq = irq; in dwc3_qcom_setup_irq()
565 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
568 "qcom_dwc3 DM_HS", qcom); in dwc3_qcom_setup_irq()
570 dev_err(qcom->dev, "dm_hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
573 qcom->dm_hs_phy_irq = irq; in dwc3_qcom_setup_irq()
580 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
583 "qcom_dwc3 SS", qcom); in dwc3_qcom_setup_irq()
585 dev_err(qcom->dev, "ss_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
588 qcom->ss_phy_irq = irq; in dwc3_qcom_setup_irq()
594 static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) in dwc3_qcom_clk_init() argument
596 struct device *dev = qcom->dev; in dwc3_qcom_clk_init()
606 qcom->num_clocks = count; in dwc3_qcom_clk_init()
608 qcom->clks = devm_kcalloc(dev, qcom->num_clocks, in dwc3_qcom_clk_init()
610 if (!qcom->clks) in dwc3_qcom_clk_init()
613 for (i = 0; i < qcom->num_clocks; i++) { in dwc3_qcom_clk_init()
620 clk_put(qcom->clks[i]); in dwc3_qcom_clk_init()
627 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_clk_init()
628 clk_put(qcom->clks[i]); in dwc3_qcom_clk_init()
635 qcom->clks[i] = clk; in dwc3_qcom_clk_init()
652 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_acpi_register_core() local
655 struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : in dwc3_qcom_acpi_register_core()
660 qcom->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); in dwc3_qcom_acpi_register_core()
661 if (!qcom->dwc3) in dwc3_qcom_acpi_register_core()
664 qcom->dwc3->dev.parent = dev; in dwc3_qcom_acpi_register_core()
665 qcom->dwc3->dev.type = dev->type; in dwc3_qcom_acpi_register_core()
666 qcom->dwc3->dev.dma_mask = dev->dma_mask; in dwc3_qcom_acpi_register_core()
667 qcom->dwc3->dev.dma_parms = dev->dma_parms; in dwc3_qcom_acpi_register_core()
668 qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask; in dwc3_qcom_acpi_register_core()
672 platform_device_put(qcom->dwc3); in dwc3_qcom_acpi_register_core()
686 qcom->acpi_pdata->dwc3_core_base_size; in dwc3_qcom_acpi_register_core()
696 ret = platform_device_add_resources(qcom->dwc3, child_res, 2); in dwc3_qcom_acpi_register_core()
702 ret = device_add_software_node(&qcom->dwc3->dev, &dwc3_qcom_swnode); in dwc3_qcom_acpi_register_core()
708 ret = platform_device_add(qcom->dwc3); in dwc3_qcom_acpi_register_core()
711 device_remove_software_node(&qcom->dwc3->dev); in dwc3_qcom_acpi_register_core()
718 platform_device_put(qcom->dwc3); in dwc3_qcom_acpi_register_core()
725 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_of_register_core() local
742 qcom->dwc3 = of_find_device_by_node(dwc3_np); in dwc3_qcom_of_register_core()
743 if (!qcom->dwc3) { in dwc3_qcom_of_register_core()
785 struct dwc3_qcom *qcom; in dwc3_qcom_probe() local
791 qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL); in dwc3_qcom_probe()
792 if (!qcom) in dwc3_qcom_probe()
795 platform_set_drvdata(pdev, qcom); in dwc3_qcom_probe()
796 qcom->dev = &pdev->dev; in dwc3_qcom_probe()
799 qcom->acpi_pdata = acpi_device_get_match_data(dev); in dwc3_qcom_probe()
800 if (!qcom->acpi_pdata) { in dwc3_qcom_probe()
806 qcom->resets = devm_reset_control_array_get_optional_exclusive(dev); in dwc3_qcom_probe()
807 if (IS_ERR(qcom->resets)) { in dwc3_qcom_probe()
808 ret = PTR_ERR(qcom->resets); in dwc3_qcom_probe()
813 ret = reset_control_assert(qcom->resets); in dwc3_qcom_probe()
821 ret = reset_control_deassert(qcom->resets); in dwc3_qcom_probe()
827 ret = dwc3_qcom_clk_init(qcom, of_clk_get_parent_count(np)); in dwc3_qcom_probe()
843 qcom->acpi_pdata->qscratch_base_offset; in dwc3_qcom_probe()
845 qcom->acpi_pdata->qscratch_base_size; in dwc3_qcom_probe()
847 if (qcom->acpi_pdata->is_urs) { in dwc3_qcom_probe()
848 qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev); in dwc3_qcom_probe()
849 if (IS_ERR_OR_NULL(qcom->urs_usb)) { in dwc3_qcom_probe()
851 if (!qcom->urs_usb) in dwc3_qcom_probe()
854 return PTR_ERR(qcom->urs_usb); in dwc3_qcom_probe()
859 qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); in dwc3_qcom_probe()
860 if (IS_ERR(qcom->qscratch_base)) { in dwc3_qcom_probe()
861 ret = PTR_ERR(qcom->qscratch_base); in dwc3_qcom_probe()
876 "qcom,select-utmi-as-pipe-clk"); in dwc3_qcom_probe()
878 dwc3_qcom_select_utmi_clk(qcom); in dwc3_qcom_probe()
890 ret = dwc3_qcom_interconnect_init(qcom); in dwc3_qcom_probe()
894 qcom->mode = usb_get_dr_mode(&qcom->dwc3->dev); in dwc3_qcom_probe()
897 if (qcom->mode == USB_DR_MODE_PERIPHERAL) in dwc3_qcom_probe()
898 dwc3_qcom_vbus_override_enable(qcom, true); in dwc3_qcom_probe()
901 ret = dwc3_qcom_register_extcon(qcom); in dwc3_qcom_probe()
907 device_init_wakeup(&qcom->dwc3->dev, wakeup_source); in dwc3_qcom_probe()
909 qcom->is_suspended = false; in dwc3_qcom_probe()
917 dwc3_qcom_interconnect_exit(qcom); in dwc3_qcom_probe()
924 for (i = qcom->num_clocks - 1; i >= 0; i--) { in dwc3_qcom_probe()
925 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_probe()
926 clk_put(qcom->clks[i]); in dwc3_qcom_probe()
929 reset_control_assert(qcom->resets); in dwc3_qcom_probe()
936 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_remove() local
940 device_remove_software_node(&qcom->dwc3->dev); in dwc3_qcom_remove()
943 for (i = qcom->num_clocks - 1; i >= 0; i--) { in dwc3_qcom_remove()
944 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_remove()
945 clk_put(qcom->clks[i]); in dwc3_qcom_remove()
947 qcom->num_clocks = 0; in dwc3_qcom_remove()
949 dwc3_qcom_interconnect_exit(qcom); in dwc3_qcom_remove()
950 reset_control_assert(qcom->resets); in dwc3_qcom_remove()
960 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_pm_suspend() local
964 ret = dwc3_qcom_suspend(qcom, wakeup); in dwc3_qcom_pm_suspend()
968 qcom->pm_suspended = true; in dwc3_qcom_pm_suspend()
975 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_pm_resume() local
979 ret = dwc3_qcom_resume(qcom, wakeup); in dwc3_qcom_pm_resume()
983 qcom->pm_suspended = false; in dwc3_qcom_pm_resume()
990 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_runtime_suspend() local
992 return dwc3_qcom_suspend(qcom, true); in dwc3_qcom_runtime_suspend()
997 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_runtime_resume() local
999 return dwc3_qcom_resume(qcom, true); in dwc3_qcom_runtime_resume()
1009 { .compatible = "qcom,dwc3" },
1050 .name = "dwc3-qcom",
1060 MODULE_DESCRIPTION("DesignWare DWC3 QCOM Glue Driver");