Lines Matching refs:mtk
115 static void xhci_mtk_set_frame_interval(struct xhci_hcd_mtk *mtk) in xhci_mtk_set_frame_interval() argument
117 struct device *dev = mtk->dev; in xhci_mtk_set_frame_interval()
118 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_set_frame_interval()
150 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_enable() argument
152 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_enable()
158 if (!mtk->has_ippc) in xhci_mtk_host_enable()
167 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_enable()
168 if ((0x1 << i) & mtk->u3p_dis_msk) { in xhci_mtk_host_enable()
180 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_enable()
181 if (BIT(i) & mtk->u2p_dis_msk) in xhci_mtk_host_enable()
197 if (mtk->num_u3_ports > u3_ports_disabled) in xhci_mtk_host_enable()
203 dev_err(mtk->dev, "clocks are not stable (0x%x)\n", value); in xhci_mtk_host_enable()
210 static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_disable() argument
212 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_disable()
217 if (!mtk->has_ippc) in xhci_mtk_host_disable()
221 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_disable()
222 if ((0x1 << i) & mtk->u3p_dis_msk) in xhci_mtk_host_disable()
231 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_disable()
232 if (BIT(i) & mtk->u2p_dis_msk) in xhci_mtk_host_disable()
249 dev_err(mtk->dev, "ip sleep failed!!!\n"); in xhci_mtk_host_disable()
255 static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) in xhci_mtk_ssusb_config() argument
257 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_ssusb_config()
260 if (!mtk->has_ippc) in xhci_mtk_ssusb_config()
281 mtk->num_u3_ports = CAP_U3_PORT_NUM(value); in xhci_mtk_ssusb_config()
282 mtk->num_u2_ports = CAP_U2_PORT_NUM(value); in xhci_mtk_ssusb_config()
283 dev_dbg(mtk->dev, "%s u2p:%d, u3p:%d\n", __func__, in xhci_mtk_ssusb_config()
284 mtk->num_u2_ports, mtk->num_u3_ports); in xhci_mtk_ssusb_config()
286 return xhci_mtk_host_enable(mtk); in xhci_mtk_ssusb_config()
290 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_ip_sleep_set() argument
294 switch (mtk->uwk_vers) { in usb_wakeup_ip_sleep_set()
296 reg = mtk->uwk_reg_base + PERI_WK_CTRL1; in usb_wakeup_ip_sleep_set()
301 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; in usb_wakeup_ip_sleep_set()
306 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; in usb_wakeup_ip_sleep_set()
311 reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL; in usb_wakeup_ip_sleep_set()
318 regmap_update_bits(mtk->uwk, reg, msk, val); in usb_wakeup_ip_sleep_set()
321 static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, in usb_wakeup_of_property_parse() argument
328 mtk->uwk_en = of_property_read_bool(dn, "wakeup-source"); in usb_wakeup_of_property_parse()
329 if (!mtk->uwk_en) in usb_wakeup_of_property_parse()
337 mtk->uwk_reg_base = args.args[0]; in usb_wakeup_of_property_parse()
338 mtk->uwk_vers = args.args[1]; in usb_wakeup_of_property_parse()
339 mtk->uwk = syscon_node_to_regmap(args.np); in usb_wakeup_of_property_parse()
341 dev_info(mtk->dev, "uwk - reg:0x%x, version:%d\n", in usb_wakeup_of_property_parse()
342 mtk->uwk_reg_base, mtk->uwk_vers); in usb_wakeup_of_property_parse()
344 return PTR_ERR_OR_ZERO(mtk->uwk); in usb_wakeup_of_property_parse()
347 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_set() argument
349 if (mtk->uwk_en) in usb_wakeup_set()
350 usb_wakeup_ip_sleep_set(mtk, enable); in usb_wakeup_set()
353 static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) in xhci_mtk_clks_get() argument
355 struct clk_bulk_data *clks = mtk->clks; in xhci_mtk_clks_get()
363 return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks); in xhci_mtk_clks_get()
366 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk) in xhci_mtk_ldos_enable() argument
370 ret = regulator_enable(mtk->vbus); in xhci_mtk_ldos_enable()
372 dev_err(mtk->dev, "failed to enable vbus\n"); in xhci_mtk_ldos_enable()
376 ret = regulator_enable(mtk->vusb33); in xhci_mtk_ldos_enable()
378 dev_err(mtk->dev, "failed to enable vusb33\n"); in xhci_mtk_ldos_enable()
379 regulator_disable(mtk->vbus); in xhci_mtk_ldos_enable()
385 static void xhci_mtk_ldos_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_ldos_disable() argument
387 regulator_disable(mtk->vbus); in xhci_mtk_ldos_disable()
388 regulator_disable(mtk->vusb33); in xhci_mtk_ldos_disable()
394 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_quirks() local
408 if (mtk->lpm_support) in xhci_mtk_quirks()
410 if (mtk->u2_lpm_disable) in xhci_mtk_quirks()
424 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_setup() local
428 ret = xhci_mtk_ssusb_config(mtk); in xhci_mtk_setup()
433 xhci_mtk_set_frame_interval(mtk); in xhci_mtk_setup()
441 ret = xhci_mtk_sch_init(mtk); in xhci_mtk_setup()
463 struct xhci_hcd_mtk *mtk; in xhci_mtk_probe() local
476 mtk = devm_kzalloc(dev, sizeof(*mtk), GFP_KERNEL); in xhci_mtk_probe()
477 if (!mtk) in xhci_mtk_probe()
480 mtk->dev = dev; in xhci_mtk_probe()
481 mtk->vbus = devm_regulator_get(dev, "vbus"); in xhci_mtk_probe()
482 if (IS_ERR(mtk->vbus)) { in xhci_mtk_probe()
484 return PTR_ERR(mtk->vbus); in xhci_mtk_probe()
487 mtk->vusb33 = devm_regulator_get(dev, "vusb33"); in xhci_mtk_probe()
488 if (IS_ERR(mtk->vusb33)) { in xhci_mtk_probe()
490 return PTR_ERR(mtk->vusb33); in xhci_mtk_probe()
493 ret = xhci_mtk_clks_get(mtk); in xhci_mtk_probe()
512 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); in xhci_mtk_probe()
513 mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable"); in xhci_mtk_probe()
516 &mtk->u3p_dis_msk); in xhci_mtk_probe()
518 &mtk->u2p_dis_msk); in xhci_mtk_probe()
520 ret = usb_wakeup_of_property_parse(mtk, node); in xhci_mtk_probe()
532 ret = xhci_mtk_ldos_enable(mtk); in xhci_mtk_probe()
536 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
550 mtk->hcd = platform_get_drvdata(pdev); in xhci_mtk_probe()
551 platform_set_drvdata(pdev, mtk); in xhci_mtk_probe()
564 mtk->ippc_regs = devm_ioremap_resource(dev, res); in xhci_mtk_probe()
565 if (IS_ERR(mtk->ippc_regs)) { in xhci_mtk_probe()
566 ret = PTR_ERR(mtk->ippc_regs); in xhci_mtk_probe()
569 mtk->has_ippc = true; in xhci_mtk_probe()
628 xhci_mtk_sch_exit(mtk); in xhci_mtk_probe()
638 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
641 xhci_mtk_ldos_disable(mtk); in xhci_mtk_probe()
651 struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev); in xhci_mtk_remove() local
652 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_remove()
667 xhci_mtk_sch_exit(mtk); in xhci_mtk_remove()
668 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_remove()
669 xhci_mtk_ldos_disable(mtk); in xhci_mtk_remove()
680 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_suspend() local
681 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_suspend()
691 ret = xhci_mtk_host_disable(mtk); in xhci_mtk_suspend()
695 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_suspend()
696 usb_wakeup_set(mtk, true); in xhci_mtk_suspend()
710 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_resume() local
711 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_resume()
715 usb_wakeup_set(mtk, false); in xhci_mtk_resume()
716 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
720 ret = xhci_mtk_host_enable(mtk); in xhci_mtk_resume()
732 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
734 usb_wakeup_set(mtk, true); in xhci_mtk_resume()
740 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_suspend() local
741 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_suspend()
756 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_resume() local
757 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_resume()