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 dev_err_probe(dev, PTR_ERR(qcom->edev), in dwc3_qcom_register_extcon()
173 qcom->vbus_nb.notifier_call = dwc3_qcom_vbus_notifier; in dwc3_qcom_register_extcon()
175 qcom->host_edev = extcon_get_edev_by_phandle(dev, 1); in dwc3_qcom_register_extcon()
176 if (IS_ERR(qcom->host_edev)) in dwc3_qcom_register_extcon()
177 qcom->host_edev = NULL; in dwc3_qcom_register_extcon()
179 ret = devm_extcon_register_notifier(dev, qcom->edev, EXTCON_USB, in dwc3_qcom_register_extcon()
180 &qcom->vbus_nb); in dwc3_qcom_register_extcon()
186 if (qcom->host_edev) in dwc3_qcom_register_extcon()
187 host_edev = qcom->host_edev; in dwc3_qcom_register_extcon()
189 host_edev = qcom->edev; in dwc3_qcom_register_extcon()
191 qcom->host_nb.notifier_call = dwc3_qcom_host_notifier; in dwc3_qcom_register_extcon()
193 &qcom->host_nb); in dwc3_qcom_register_extcon()
200 if (extcon_get_state(qcom->edev, EXTCON_USB) || in dwc3_qcom_register_extcon()
202 dwc3_qcom_vbus_notifier(&qcom->vbus_nb, true, qcom->edev); in dwc3_qcom_register_extcon()
204 dwc3_qcom_vbus_notifier(&qcom->vbus_nb, false, qcom->edev); in dwc3_qcom_register_extcon()
209 static int dwc3_qcom_interconnect_enable(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_enable() argument
213 ret = icc_enable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_enable()
217 ret = icc_enable(qcom->icc_path_apps); in dwc3_qcom_interconnect_enable()
219 icc_disable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_enable()
224 static int dwc3_qcom_interconnect_disable(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_disable() argument
228 ret = icc_disable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_disable()
232 ret = icc_disable(qcom->icc_path_apps); in dwc3_qcom_interconnect_disable()
234 icc_enable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_disable()
242 * @qcom: Pointer to the concerned usb core.
245 static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_init() argument
248 struct device *dev = qcom->dev; in dwc3_qcom_interconnect_init()
254 qcom->icc_path_ddr = of_icc_get(dev, "usb-ddr"); in dwc3_qcom_interconnect_init()
255 if (IS_ERR(qcom->icc_path_ddr)) { in dwc3_qcom_interconnect_init()
256 return dev_err_probe(dev, 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()
262 ret = dev_err_probe(dev, 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()
289 icc_put(qcom->icc_path_apps); in dwc3_qcom_interconnect_init()
291 icc_put(qcom->icc_path_ddr); in dwc3_qcom_interconnect_init()
297 * @qcom: Pointer to the concerned usb core.
301 static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_exit() argument
303 icc_put(qcom->icc_path_ddr); in dwc3_qcom_interconnect_exit()
304 icc_put(qcom->icc_path_apps); in dwc3_qcom_interconnect_exit()
308 static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom) in dwc3_qcom_is_host() argument
315 dwc = platform_get_drvdata(qcom->dwc3); in dwc3_qcom_is_host()
324 static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom) in dwc3_qcom_read_usb2_speed() argument
326 struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); in dwc3_qcom_read_usb2_speed()
373 static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) in dwc3_qcom_disable_interrupts() argument
375 dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq); in dwc3_qcom_disable_interrupts()
377 if (qcom->usb2_speed == USB_SPEED_LOW) { in dwc3_qcom_disable_interrupts()
378 dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); in dwc3_qcom_disable_interrupts()
379 } else if ((qcom->usb2_speed == USB_SPEED_HIGH) || in dwc3_qcom_disable_interrupts()
380 (qcom->usb2_speed == USB_SPEED_FULL)) { in dwc3_qcom_disable_interrupts()
381 dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); in dwc3_qcom_disable_interrupts()
383 dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); in dwc3_qcom_disable_interrupts()
384 dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); in dwc3_qcom_disable_interrupts()
387 dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq); in dwc3_qcom_disable_interrupts()
390 static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) in dwc3_qcom_enable_interrupts() argument
392 dwc3_qcom_enable_wakeup_irq(qcom->hs_phy_irq, 0); in dwc3_qcom_enable_interrupts()
403 if (qcom->usb2_speed == USB_SPEED_LOW) { in dwc3_qcom_enable_interrupts()
404 dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq, in dwc3_qcom_enable_interrupts()
406 } else if ((qcom->usb2_speed == USB_SPEED_HIGH) || in dwc3_qcom_enable_interrupts()
407 (qcom->usb2_speed == USB_SPEED_FULL)) { in dwc3_qcom_enable_interrupts()
408 dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq, in dwc3_qcom_enable_interrupts()
411 dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq, in dwc3_qcom_enable_interrupts()
413 dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq, in dwc3_qcom_enable_interrupts()
417 dwc3_qcom_enable_wakeup_irq(qcom->ss_phy_irq, 0); in dwc3_qcom_enable_interrupts()
420 static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) in dwc3_qcom_suspend() argument
425 if (qcom->is_suspended) in dwc3_qcom_suspend()
428 val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); in dwc3_qcom_suspend()
430 dev_err(qcom->dev, "HS-PHY not in L2\n"); in dwc3_qcom_suspend()
432 for (i = qcom->num_clocks - 1; i >= 0; i--) in dwc3_qcom_suspend()
433 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_suspend()
435 ret = dwc3_qcom_interconnect_disable(qcom); in dwc3_qcom_suspend()
437 dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret); in dwc3_qcom_suspend()
443 if (dwc3_qcom_is_host(qcom) && wakeup) { in dwc3_qcom_suspend()
444 qcom->usb2_speed = dwc3_qcom_read_usb2_speed(qcom); in dwc3_qcom_suspend()
445 dwc3_qcom_enable_interrupts(qcom); in dwc3_qcom_suspend()
448 qcom->is_suspended = true; in dwc3_qcom_suspend()
453 static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) in dwc3_qcom_resume() argument
458 if (!qcom->is_suspended) in dwc3_qcom_resume()
461 if (dwc3_qcom_is_host(qcom) && wakeup) in dwc3_qcom_resume()
462 dwc3_qcom_disable_interrupts(qcom); in dwc3_qcom_resume()
464 for (i = 0; i < qcom->num_clocks; i++) { in dwc3_qcom_resume()
465 ret = clk_prepare_enable(qcom->clks[i]); in dwc3_qcom_resume()
468 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_resume()
473 ret = dwc3_qcom_interconnect_enable(qcom); in dwc3_qcom_resume()
475 dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret); in dwc3_qcom_resume()
478 dwc3_qcom_setbits(qcom->qscratch_base, PWR_EVNT_IRQ_STAT_REG, in dwc3_qcom_resume()
481 qcom->is_suspended = false; in dwc3_qcom_resume()
488 struct dwc3_qcom *qcom = data; in qcom_dwc3_resume_irq() local
489 struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); in qcom_dwc3_resume_irq()
492 if (qcom->pm_suspended) in qcom_dwc3_resume_irq()
499 if (dwc3_qcom_is_host(qcom)) in qcom_dwc3_resume_irq()
505 static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom) in dwc3_qcom_select_utmi_clk() argument
508 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
513 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
518 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
525 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_get_irq() local
526 struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : pdev; in dwc3_qcom_get_irq()
540 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_setup_irq() local
541 const struct dwc3_acpi_pdata *pdata = qcom->acpi_pdata; in dwc3_qcom_setup_irq()
550 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
553 "qcom_dwc3 HS", qcom); in dwc3_qcom_setup_irq()
555 dev_err(qcom->dev, "hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
558 qcom->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 DP_HS", qcom); in dwc3_qcom_setup_irq()
570 dev_err(qcom->dev, "dp_hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
573 qcom->dp_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 DM_HS", qcom); in dwc3_qcom_setup_irq()
585 dev_err(qcom->dev, "dm_hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
588 qcom->dm_hs_phy_irq = irq; in dwc3_qcom_setup_irq()
595 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
598 "qcom_dwc3 SS", qcom); in dwc3_qcom_setup_irq()
600 dev_err(qcom->dev, "ss_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
603 qcom->ss_phy_irq = irq; in dwc3_qcom_setup_irq()
609 static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) in dwc3_qcom_clk_init() argument
611 struct device *dev = qcom->dev; in dwc3_qcom_clk_init()
621 qcom->num_clocks = count; in dwc3_qcom_clk_init()
623 qcom->clks = devm_kcalloc(dev, qcom->num_clocks, in dwc3_qcom_clk_init()
625 if (!qcom->clks) in dwc3_qcom_clk_init()
628 for (i = 0; i < qcom->num_clocks; i++) { in dwc3_qcom_clk_init()
635 clk_put(qcom->clks[i]); in dwc3_qcom_clk_init()
642 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_clk_init()
643 clk_put(qcom->clks[i]); in dwc3_qcom_clk_init()
650 qcom->clks[i] = clk; in dwc3_qcom_clk_init()
667 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_acpi_register_core() local
670 struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : in dwc3_qcom_acpi_register_core()
675 qcom->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); in dwc3_qcom_acpi_register_core()
676 if (!qcom->dwc3) in dwc3_qcom_acpi_register_core()
679 qcom->dwc3->dev.parent = dev; in dwc3_qcom_acpi_register_core()
680 qcom->dwc3->dev.type = dev->type; in dwc3_qcom_acpi_register_core()
681 qcom->dwc3->dev.dma_mask = dev->dma_mask; in dwc3_qcom_acpi_register_core()
682 qcom->dwc3->dev.dma_parms = dev->dma_parms; in dwc3_qcom_acpi_register_core()
683 qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask; in dwc3_qcom_acpi_register_core()
687 platform_device_put(qcom->dwc3); in dwc3_qcom_acpi_register_core()
701 qcom->acpi_pdata->dwc3_core_base_size; in dwc3_qcom_acpi_register_core()
711 ret = platform_device_add_resources(qcom->dwc3, child_res, 2); in dwc3_qcom_acpi_register_core()
717 ret = device_add_software_node(&qcom->dwc3->dev, &dwc3_qcom_swnode); in dwc3_qcom_acpi_register_core()
723 ret = platform_device_add(qcom->dwc3); in dwc3_qcom_acpi_register_core()
726 device_remove_software_node(&qcom->dwc3->dev); in dwc3_qcom_acpi_register_core()
733 platform_device_put(qcom->dwc3); in dwc3_qcom_acpi_register_core()
740 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_of_register_core() local
757 qcom->dwc3 = of_find_device_by_node(dwc3_np); in dwc3_qcom_of_register_core()
758 if (!qcom->dwc3) { in dwc3_qcom_of_register_core()
818 struct dwc3_qcom *qcom; in dwc3_qcom_probe() local
825 qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL); in dwc3_qcom_probe()
826 if (!qcom) in dwc3_qcom_probe()
829 platform_set_drvdata(pdev, qcom); in dwc3_qcom_probe()
830 qcom->dev = &pdev->dev; in dwc3_qcom_probe()
833 qcom->acpi_pdata = acpi_device_get_match_data(dev); in dwc3_qcom_probe()
834 if (!qcom->acpi_pdata) { in dwc3_qcom_probe()
840 qcom->resets = devm_reset_control_array_get_optional_exclusive(dev); in dwc3_qcom_probe()
841 if (IS_ERR(qcom->resets)) { in dwc3_qcom_probe()
842 return dev_err_probe(&pdev->dev, PTR_ERR(qcom->resets), in dwc3_qcom_probe()
846 ret = reset_control_assert(qcom->resets); in dwc3_qcom_probe()
854 ret = reset_control_deassert(qcom->resets); in dwc3_qcom_probe()
860 ret = dwc3_qcom_clk_init(qcom, of_clk_get_parent_count(np)); in dwc3_qcom_probe()
875 qcom->acpi_pdata->qscratch_base_offset; in dwc3_qcom_probe()
877 qcom->acpi_pdata->qscratch_base_size; in dwc3_qcom_probe()
879 if (qcom->acpi_pdata->is_urs) { in dwc3_qcom_probe()
880 qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev); in dwc3_qcom_probe()
881 if (IS_ERR_OR_NULL(qcom->urs_usb)) { in dwc3_qcom_probe()
883 if (!qcom->urs_usb) in dwc3_qcom_probe()
886 ret = PTR_ERR(qcom->urs_usb); in dwc3_qcom_probe()
892 qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); in dwc3_qcom_probe()
893 if (IS_ERR(qcom->qscratch_base)) { in dwc3_qcom_probe()
894 ret = PTR_ERR(qcom->qscratch_base); in dwc3_qcom_probe()
909 "qcom,select-utmi-as-pipe-clk"); in dwc3_qcom_probe()
911 dwc3_qcom_select_utmi_clk(qcom); in dwc3_qcom_probe()
923 ret = dwc3_qcom_interconnect_init(qcom); in dwc3_qcom_probe()
927 qcom->mode = usb_get_dr_mode(&qcom->dwc3->dev); in dwc3_qcom_probe()
930 if (qcom->mode != USB_DR_MODE_HOST) in dwc3_qcom_probe()
931 dwc3_qcom_vbus_override_enable(qcom, true); in dwc3_qcom_probe()
934 ret = dwc3_qcom_register_extcon(qcom); in dwc3_qcom_probe()
940 device_init_wakeup(&qcom->dwc3->dev, wakeup_source); in dwc3_qcom_probe()
942 qcom->is_suspended = false; in dwc3_qcom_probe()
950 dwc3_qcom_interconnect_exit(qcom); in dwc3_qcom_probe()
955 device_remove_software_node(&qcom->dwc3->dev); in dwc3_qcom_probe()
956 platform_device_del(qcom->dwc3); in dwc3_qcom_probe()
958 platform_device_put(qcom->dwc3); in dwc3_qcom_probe()
960 if (qcom->urs_usb) in dwc3_qcom_probe()
961 dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb); in dwc3_qcom_probe()
963 for (i = qcom->num_clocks - 1; i >= 0; i--) { in dwc3_qcom_probe()
964 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_probe()
965 clk_put(qcom->clks[i]); in dwc3_qcom_probe()
968 reset_control_assert(qcom->resets); in dwc3_qcom_probe()
975 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_remove() local
983 device_remove_software_node(&qcom->dwc3->dev); in dwc3_qcom_remove()
984 platform_device_del(qcom->dwc3); in dwc3_qcom_remove()
986 platform_device_put(qcom->dwc3); in dwc3_qcom_remove()
988 if (qcom->urs_usb) in dwc3_qcom_remove()
989 dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb); in dwc3_qcom_remove()
991 for (i = qcom->num_clocks - 1; i >= 0; i--) { in dwc3_qcom_remove()
992 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_remove()
993 clk_put(qcom->clks[i]); in dwc3_qcom_remove()
995 qcom->num_clocks = 0; in dwc3_qcom_remove()
997 dwc3_qcom_interconnect_exit(qcom); in dwc3_qcom_remove()
998 reset_control_assert(qcom->resets); in dwc3_qcom_remove()
1006 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_pm_suspend() local
1010 ret = dwc3_qcom_suspend(qcom, wakeup); in dwc3_qcom_pm_suspend()
1014 qcom->pm_suspended = true; in dwc3_qcom_pm_suspend()
1021 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_pm_resume() local
1025 ret = dwc3_qcom_resume(qcom, wakeup); in dwc3_qcom_pm_resume()
1029 qcom->pm_suspended = false; in dwc3_qcom_pm_resume()
1036 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_runtime_suspend() local
1038 return dwc3_qcom_suspend(qcom, true); in dwc3_qcom_runtime_suspend()
1043 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_runtime_resume() local
1045 return dwc3_qcom_resume(qcom, true); in dwc3_qcom_runtime_resume()
1055 { .compatible = "qcom,dwc3" },
1096 .name = "dwc3-qcom",
1106 MODULE_DESCRIPTION("DesignWare DWC3 QCOM Glue Driver");