Lines Matching full:qcom

116 static void dwc3_qcom_vbus_overrride_enable(struct dwc3_qcom *qcom, bool enable)  in dwc3_qcom_vbus_overrride_enable()  argument
119 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_SS_PHY_CTRL, in dwc3_qcom_vbus_overrride_enable()
121 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL, in dwc3_qcom_vbus_overrride_enable()
124 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_SS_PHY_CTRL, in dwc3_qcom_vbus_overrride_enable()
126 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_HS_PHY_CTRL, in dwc3_qcom_vbus_overrride_enable()
134 struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, vbus_nb); in dwc3_qcom_vbus_notifier() local
137 dwc3_qcom_vbus_overrride_enable(qcom, event); in dwc3_qcom_vbus_notifier()
138 qcom->mode = event ? USB_DR_MODE_PERIPHERAL : USB_DR_MODE_HOST; in dwc3_qcom_vbus_notifier()
146 struct dwc3_qcom *qcom = container_of(nb, struct dwc3_qcom, host_nb); in dwc3_qcom_host_notifier() local
149 dwc3_qcom_vbus_overrride_enable(qcom, !event); in dwc3_qcom_host_notifier()
150 qcom->mode = event ? USB_DR_MODE_HOST : USB_DR_MODE_PERIPHERAL; in dwc3_qcom_host_notifier()
155 static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom) in dwc3_qcom_register_extcon() argument
157 struct device *dev = qcom->dev; in dwc3_qcom_register_extcon()
164 qcom->edev = extcon_get_edev_by_phandle(dev, 0); in dwc3_qcom_register_extcon()
165 if (IS_ERR(qcom->edev)) in dwc3_qcom_register_extcon()
166 return PTR_ERR(qcom->edev); in dwc3_qcom_register_extcon()
168 qcom->vbus_nb.notifier_call = dwc3_qcom_vbus_notifier; in dwc3_qcom_register_extcon()
170 qcom->host_edev = extcon_get_edev_by_phandle(dev, 1); in dwc3_qcom_register_extcon()
171 if (IS_ERR(qcom->host_edev)) in dwc3_qcom_register_extcon()
172 qcom->host_edev = NULL; in dwc3_qcom_register_extcon()
174 ret = devm_extcon_register_notifier(dev, qcom->edev, EXTCON_USB, in dwc3_qcom_register_extcon()
175 &qcom->vbus_nb); in dwc3_qcom_register_extcon()
181 if (qcom->host_edev) in dwc3_qcom_register_extcon()
182 host_edev = qcom->host_edev; in dwc3_qcom_register_extcon()
184 host_edev = qcom->edev; in dwc3_qcom_register_extcon()
186 qcom->host_nb.notifier_call = dwc3_qcom_host_notifier; in dwc3_qcom_register_extcon()
188 &qcom->host_nb); in dwc3_qcom_register_extcon()
195 if (extcon_get_state(qcom->edev, EXTCON_USB) || in dwc3_qcom_register_extcon()
197 dwc3_qcom_vbus_notifier(&qcom->vbus_nb, true, qcom->edev); in dwc3_qcom_register_extcon()
199 dwc3_qcom_vbus_notifier(&qcom->vbus_nb, false, qcom->edev); in dwc3_qcom_register_extcon()
204 static int dwc3_qcom_interconnect_enable(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_enable() argument
208 ret = icc_enable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_enable()
212 ret = icc_enable(qcom->icc_path_apps); in dwc3_qcom_interconnect_enable()
214 icc_disable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_enable()
219 static int dwc3_qcom_interconnect_disable(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_disable() argument
223 ret = icc_disable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_disable()
227 ret = icc_disable(qcom->icc_path_apps); in dwc3_qcom_interconnect_disable()
229 icc_enable(qcom->icc_path_ddr); in dwc3_qcom_interconnect_disable()
237 * @qcom: Pointer to the concerned usb core.
240 static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_init() argument
242 struct device *dev = qcom->dev; in dwc3_qcom_interconnect_init()
245 qcom->icc_path_ddr = of_icc_get(dev, "usb-ddr"); in dwc3_qcom_interconnect_init()
246 if (IS_ERR(qcom->icc_path_ddr)) { in dwc3_qcom_interconnect_init()
248 PTR_ERR(qcom->icc_path_ddr)); in dwc3_qcom_interconnect_init()
249 return PTR_ERR(qcom->icc_path_ddr); in dwc3_qcom_interconnect_init()
252 qcom->icc_path_apps = of_icc_get(dev, "apps-usb"); in dwc3_qcom_interconnect_init()
253 if (IS_ERR(qcom->icc_path_apps)) { in dwc3_qcom_interconnect_init()
255 PTR_ERR(qcom->icc_path_apps)); in dwc3_qcom_interconnect_init()
256 return PTR_ERR(qcom->icc_path_apps); in dwc3_qcom_interconnect_init()
259 if (usb_get_maximum_speed(&qcom->dwc3->dev) >= USB_SPEED_SUPER || in dwc3_qcom_interconnect_init()
260 usb_get_maximum_speed(&qcom->dwc3->dev) == USB_SPEED_UNKNOWN) in dwc3_qcom_interconnect_init()
261 ret = icc_set_bw(qcom->icc_path_ddr, in dwc3_qcom_interconnect_init()
264 ret = icc_set_bw(qcom->icc_path_ddr, in dwc3_qcom_interconnect_init()
272 ret = icc_set_bw(qcom->icc_path_apps, in dwc3_qcom_interconnect_init()
284 * @qcom: Pointer to the concerned usb core.
288 static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom) in dwc3_qcom_interconnect_exit() argument
290 icc_put(qcom->icc_path_ddr); in dwc3_qcom_interconnect_exit()
291 icc_put(qcom->icc_path_apps); in dwc3_qcom_interconnect_exit()
294 static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) in dwc3_qcom_disable_interrupts() argument
296 if (qcom->hs_phy_irq) { in dwc3_qcom_disable_interrupts()
297 disable_irq_wake(qcom->hs_phy_irq); in dwc3_qcom_disable_interrupts()
298 disable_irq_nosync(qcom->hs_phy_irq); in dwc3_qcom_disable_interrupts()
301 if (qcom->dp_hs_phy_irq) { in dwc3_qcom_disable_interrupts()
302 disable_irq_wake(qcom->dp_hs_phy_irq); in dwc3_qcom_disable_interrupts()
303 disable_irq_nosync(qcom->dp_hs_phy_irq); in dwc3_qcom_disable_interrupts()
306 if (qcom->dm_hs_phy_irq) { in dwc3_qcom_disable_interrupts()
307 disable_irq_wake(qcom->dm_hs_phy_irq); in dwc3_qcom_disable_interrupts()
308 disable_irq_nosync(qcom->dm_hs_phy_irq); in dwc3_qcom_disable_interrupts()
311 if (qcom->ss_phy_irq) { in dwc3_qcom_disable_interrupts()
312 disable_irq_wake(qcom->ss_phy_irq); in dwc3_qcom_disable_interrupts()
313 disable_irq_nosync(qcom->ss_phy_irq); in dwc3_qcom_disable_interrupts()
317 static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) in dwc3_qcom_enable_interrupts() argument
319 if (qcom->hs_phy_irq) { in dwc3_qcom_enable_interrupts()
320 enable_irq(qcom->hs_phy_irq); in dwc3_qcom_enable_interrupts()
321 enable_irq_wake(qcom->hs_phy_irq); in dwc3_qcom_enable_interrupts()
324 if (qcom->dp_hs_phy_irq) { in dwc3_qcom_enable_interrupts()
325 enable_irq(qcom->dp_hs_phy_irq); in dwc3_qcom_enable_interrupts()
326 enable_irq_wake(qcom->dp_hs_phy_irq); in dwc3_qcom_enable_interrupts()
329 if (qcom->dm_hs_phy_irq) { in dwc3_qcom_enable_interrupts()
330 enable_irq(qcom->dm_hs_phy_irq); in dwc3_qcom_enable_interrupts()
331 enable_irq_wake(qcom->dm_hs_phy_irq); in dwc3_qcom_enable_interrupts()
334 if (qcom->ss_phy_irq) { in dwc3_qcom_enable_interrupts()
335 enable_irq(qcom->ss_phy_irq); in dwc3_qcom_enable_interrupts()
336 enable_irq_wake(qcom->ss_phy_irq); in dwc3_qcom_enable_interrupts()
340 static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) in dwc3_qcom_suspend() argument
345 if (qcom->is_suspended) in dwc3_qcom_suspend()
348 val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); in dwc3_qcom_suspend()
350 dev_err(qcom->dev, "HS-PHY not in L2\n"); in dwc3_qcom_suspend()
352 for (i = qcom->num_clocks - 1; i >= 0; i--) in dwc3_qcom_suspend()
353 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_suspend()
355 ret = dwc3_qcom_interconnect_disable(qcom); in dwc3_qcom_suspend()
357 dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret); in dwc3_qcom_suspend()
359 qcom->is_suspended = true; in dwc3_qcom_suspend()
360 dwc3_qcom_enable_interrupts(qcom); in dwc3_qcom_suspend()
365 static int dwc3_qcom_resume(struct dwc3_qcom *qcom) in dwc3_qcom_resume() argument
370 if (!qcom->is_suspended) in dwc3_qcom_resume()
373 dwc3_qcom_disable_interrupts(qcom); in dwc3_qcom_resume()
375 for (i = 0; i < qcom->num_clocks; i++) { in dwc3_qcom_resume()
376 ret = clk_prepare_enable(qcom->clks[i]); in dwc3_qcom_resume()
379 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_resume()
384 ret = dwc3_qcom_interconnect_enable(qcom); in dwc3_qcom_resume()
386 dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret); in dwc3_qcom_resume()
389 dwc3_qcom_setbits(qcom->qscratch_base, PWR_EVNT_IRQ_STAT_REG, in dwc3_qcom_resume()
392 qcom->is_suspended = false; in dwc3_qcom_resume()
399 struct dwc3_qcom *qcom = data; in qcom_dwc3_resume_irq() local
400 struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); in qcom_dwc3_resume_irq()
403 if (qcom->pm_suspended) in qcom_dwc3_resume_irq()
412 static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom) in dwc3_qcom_select_utmi_clk() argument
415 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
420 dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
425 dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG, in dwc3_qcom_select_utmi_clk()
445 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_setup_irq() local
446 const struct dwc3_acpi_pdata *pdata = qcom->acpi_pdata; in dwc3_qcom_setup_irq()
455 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
458 "qcom_dwc3 HS", qcom); in dwc3_qcom_setup_irq()
460 dev_err(qcom->dev, "hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
463 qcom->hs_phy_irq = irq; in dwc3_qcom_setup_irq()
470 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
473 "qcom_dwc3 DP_HS", qcom); in dwc3_qcom_setup_irq()
475 dev_err(qcom->dev, "dp_hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
478 qcom->dp_hs_phy_irq = irq; in dwc3_qcom_setup_irq()
485 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
488 "qcom_dwc3 DM_HS", qcom); in dwc3_qcom_setup_irq()
490 dev_err(qcom->dev, "dm_hs_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
493 qcom->dm_hs_phy_irq = irq; in dwc3_qcom_setup_irq()
500 ret = devm_request_threaded_irq(qcom->dev, irq, NULL, in dwc3_qcom_setup_irq()
503 "qcom_dwc3 SS", qcom); in dwc3_qcom_setup_irq()
505 dev_err(qcom->dev, "ss_phy_irq failed: %d\n", ret); in dwc3_qcom_setup_irq()
508 qcom->ss_phy_irq = irq; in dwc3_qcom_setup_irq()
514 static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) in dwc3_qcom_clk_init() argument
516 struct device *dev = qcom->dev; in dwc3_qcom_clk_init()
526 qcom->num_clocks = count; in dwc3_qcom_clk_init()
528 qcom->clks = devm_kcalloc(dev, qcom->num_clocks, in dwc3_qcom_clk_init()
530 if (!qcom->clks) in dwc3_qcom_clk_init()
533 for (i = 0; i < qcom->num_clocks; i++) { in dwc3_qcom_clk_init()
540 clk_put(qcom->clks[i]); in dwc3_qcom_clk_init()
547 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_clk_init()
548 clk_put(qcom->clks[i]); in dwc3_qcom_clk_init()
555 qcom->clks[i] = clk; in dwc3_qcom_clk_init()
568 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_acpi_register_core() local
574 qcom->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); in dwc3_qcom_acpi_register_core()
575 if (!qcom->dwc3) in dwc3_qcom_acpi_register_core()
578 qcom->dwc3->dev.parent = dev; in dwc3_qcom_acpi_register_core()
579 qcom->dwc3->dev.type = dev->type; in dwc3_qcom_acpi_register_core()
580 qcom->dwc3->dev.dma_mask = dev->dma_mask; in dwc3_qcom_acpi_register_core()
581 qcom->dwc3->dev.dma_parms = dev->dma_parms; in dwc3_qcom_acpi_register_core()
582 qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask; in dwc3_qcom_acpi_register_core()
598 qcom->acpi_pdata->dwc3_core_base_size; in dwc3_qcom_acpi_register_core()
604 ret = platform_device_add_resources(qcom->dwc3, child_res, 2); in dwc3_qcom_acpi_register_core()
610 ret = platform_device_add_properties(qcom->dwc3, in dwc3_qcom_acpi_register_core()
617 ret = platform_device_add(qcom->dwc3); in dwc3_qcom_acpi_register_core()
628 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_of_register_core() local
645 qcom->dwc3 = of_find_device_by_node(dwc3_np); in dwc3_qcom_of_register_core()
646 if (!qcom->dwc3) { in dwc3_qcom_of_register_core()
658 struct dwc3_qcom *qcom; in dwc3_qcom_probe() local
663 qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL); in dwc3_qcom_probe()
664 if (!qcom) in dwc3_qcom_probe()
667 platform_set_drvdata(pdev, qcom); in dwc3_qcom_probe()
668 qcom->dev = &pdev->dev; in dwc3_qcom_probe()
671 qcom->acpi_pdata = acpi_device_get_match_data(dev); in dwc3_qcom_probe()
672 if (!qcom->acpi_pdata) { in dwc3_qcom_probe()
678 qcom->resets = devm_reset_control_array_get_optional_exclusive(dev); in dwc3_qcom_probe()
679 if (IS_ERR(qcom->resets)) { in dwc3_qcom_probe()
680 ret = PTR_ERR(qcom->resets); in dwc3_qcom_probe()
685 ret = reset_control_assert(qcom->resets); in dwc3_qcom_probe()
693 ret = reset_control_deassert(qcom->resets); in dwc3_qcom_probe()
699 ret = dwc3_qcom_clk_init(qcom, of_clk_get_parent_count(np)); in dwc3_qcom_probe()
715 qcom->acpi_pdata->qscratch_base_offset; in dwc3_qcom_probe()
717 qcom->acpi_pdata->qscratch_base_size; in dwc3_qcom_probe()
720 qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); in dwc3_qcom_probe()
721 if (IS_ERR(qcom->qscratch_base)) { in dwc3_qcom_probe()
723 ret = PTR_ERR(qcom->qscratch_base); in dwc3_qcom_probe()
738 "qcom,select-utmi-as-pipe-clk"); in dwc3_qcom_probe()
740 dwc3_qcom_select_utmi_clk(qcom); in dwc3_qcom_probe()
752 ret = dwc3_qcom_interconnect_init(qcom); in dwc3_qcom_probe()
756 qcom->mode = usb_get_dr_mode(&qcom->dwc3->dev); in dwc3_qcom_probe()
759 if (qcom->mode == USB_DR_MODE_PERIPHERAL) in dwc3_qcom_probe()
760 dwc3_qcom_vbus_overrride_enable(qcom, true); in dwc3_qcom_probe()
763 ret = dwc3_qcom_register_extcon(qcom); in dwc3_qcom_probe()
768 qcom->is_suspended = false; in dwc3_qcom_probe()
776 dwc3_qcom_interconnect_exit(qcom); in dwc3_qcom_probe()
783 for (i = qcom->num_clocks - 1; i >= 0; i--) { in dwc3_qcom_probe()
784 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_probe()
785 clk_put(qcom->clks[i]); in dwc3_qcom_probe()
788 reset_control_assert(qcom->resets); in dwc3_qcom_probe()
795 struct dwc3_qcom *qcom = platform_get_drvdata(pdev); in dwc3_qcom_remove() local
801 for (i = qcom->num_clocks - 1; i >= 0; i--) { in dwc3_qcom_remove()
802 clk_disable_unprepare(qcom->clks[i]); in dwc3_qcom_remove()
803 clk_put(qcom->clks[i]); in dwc3_qcom_remove()
805 qcom->num_clocks = 0; in dwc3_qcom_remove()
807 dwc3_qcom_interconnect_exit(qcom); in dwc3_qcom_remove()
808 reset_control_assert(qcom->resets); in dwc3_qcom_remove()
818 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_pm_suspend() local
821 ret = dwc3_qcom_suspend(qcom); in dwc3_qcom_pm_suspend()
823 qcom->pm_suspended = true; in dwc3_qcom_pm_suspend()
830 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_pm_resume() local
833 ret = dwc3_qcom_resume(qcom); in dwc3_qcom_pm_resume()
835 qcom->pm_suspended = false; in dwc3_qcom_pm_resume()
842 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_runtime_suspend() local
844 return dwc3_qcom_suspend(qcom); in dwc3_qcom_runtime_suspend()
849 struct dwc3_qcom *qcom = dev_get_drvdata(dev); in dwc3_qcom_runtime_resume() local
851 return dwc3_qcom_resume(qcom); in dwc3_qcom_runtime_resume()
861 { .compatible = "qcom,dwc3" },
862 { .compatible = "qcom,msm8996-dwc3" },
863 { .compatible = "qcom,msm8998-dwc3" },
864 { .compatible = "qcom,sdm845-dwc3" },
891 .name = "dwc3-qcom",
901 MODULE_DESCRIPTION("DesignWare DWC3 QCOM Glue Driver");