Lines Matching refs:mtk

133 static void xhci_mtk_set_frame_interval(struct xhci_hcd_mtk *mtk)  in xhci_mtk_set_frame_interval()  argument
135 struct device *dev = mtk->dev; in xhci_mtk_set_frame_interval()
136 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_set_frame_interval()
168 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_enable() argument
170 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_enable()
176 if (!mtk->has_ippc) in xhci_mtk_host_enable()
185 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_enable()
186 if ((0x1 << i) & mtk->u3p_dis_msk) { in xhci_mtk_host_enable()
198 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_enable()
199 if (BIT(i) & mtk->u2p_dis_msk) in xhci_mtk_host_enable()
215 if (mtk->num_u3_ports > u3_ports_disabled) in xhci_mtk_host_enable()
221 dev_err(mtk->dev, "clocks are not stable (0x%x)\n", value); in xhci_mtk_host_enable()
228 static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_disable() argument
230 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_disable()
235 if (!mtk->has_ippc) in xhci_mtk_host_disable()
239 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_disable()
240 if ((0x1 << i) & mtk->u3p_dis_msk) in xhci_mtk_host_disable()
249 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_disable()
250 if (BIT(i) & mtk->u2p_dis_msk) in xhci_mtk_host_disable()
267 dev_err(mtk->dev, "ip sleep failed!!!\n"); in xhci_mtk_host_disable()
274 static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) in xhci_mtk_ssusb_config() argument
276 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_ssusb_config()
279 if (!mtk->has_ippc) in xhci_mtk_ssusb_config()
300 mtk->num_u3_ports = CAP_U3_PORT_NUM(value); in xhci_mtk_ssusb_config()
301 mtk->num_u2_ports = CAP_U2_PORT_NUM(value); in xhci_mtk_ssusb_config()
302 dev_dbg(mtk->dev, "%s u2p:%d, u3p:%d\n", __func__, in xhci_mtk_ssusb_config()
303 mtk->num_u2_ports, mtk->num_u3_ports); in xhci_mtk_ssusb_config()
305 return xhci_mtk_host_enable(mtk); in xhci_mtk_ssusb_config()
309 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_ip_sleep_set() argument
313 switch (mtk->uwk_vers) { in usb_wakeup_ip_sleep_set()
315 reg = mtk->uwk_reg_base + PERI_WK_CTRL1; in usb_wakeup_ip_sleep_set()
320 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; in usb_wakeup_ip_sleep_set()
325 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; in usb_wakeup_ip_sleep_set()
330 reg = mtk->uwk_reg_base + PERI_WK_CTRL1_8195; in usb_wakeup_ip_sleep_set()
335 reg = mtk->uwk_reg_base + PERI_WK_CTRL0_8195; in usb_wakeup_ip_sleep_set()
340 reg = mtk->uwk_reg_base + PERI_WK_CTRL0_8195; in usb_wakeup_ip_sleep_set()
345 reg = mtk->uwk_reg_base + PERI_WK_CTRL0_8195; in usb_wakeup_ip_sleep_set()
350 reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL; in usb_wakeup_ip_sleep_set()
357 regmap_update_bits(mtk->uwk, reg, msk, val); in usb_wakeup_ip_sleep_set()
360 static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, in usb_wakeup_of_property_parse() argument
367 mtk->uwk_en = of_property_read_bool(dn, "wakeup-source"); in usb_wakeup_of_property_parse()
368 if (!mtk->uwk_en) in usb_wakeup_of_property_parse()
376 mtk->uwk_reg_base = args.args[0]; in usb_wakeup_of_property_parse()
377 mtk->uwk_vers = args.args[1]; in usb_wakeup_of_property_parse()
378 mtk->uwk = syscon_node_to_regmap(args.np); in usb_wakeup_of_property_parse()
380 dev_info(mtk->dev, "uwk - reg:0x%x, version:%d\n", in usb_wakeup_of_property_parse()
381 mtk->uwk_reg_base, mtk->uwk_vers); in usb_wakeup_of_property_parse()
383 return PTR_ERR_OR_ZERO(mtk->uwk); in usb_wakeup_of_property_parse()
386 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_set() argument
388 if (mtk->uwk_en) in usb_wakeup_set()
389 usb_wakeup_ip_sleep_set(mtk, enable); in usb_wakeup_set()
392 static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) in xhci_mtk_clks_get() argument
394 struct clk_bulk_data *clks = mtk->clks; in xhci_mtk_clks_get()
402 return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks); in xhci_mtk_clks_get()
405 static int xhci_mtk_vregs_get(struct xhci_hcd_mtk *mtk) in xhci_mtk_vregs_get() argument
407 struct regulator_bulk_data *supplies = mtk->supplies; in xhci_mtk_vregs_get()
412 return devm_regulator_bulk_get(mtk->dev, BULK_VREGS_NUM, supplies); in xhci_mtk_vregs_get()
418 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_quirks() local
432 if (mtk->lpm_support) in xhci_mtk_quirks()
434 if (mtk->u2_lpm_disable) in xhci_mtk_quirks()
448 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_setup() local
452 ret = xhci_mtk_ssusb_config(mtk); in xhci_mtk_setup()
457 xhci_mtk_set_frame_interval(mtk); in xhci_mtk_setup()
465 ret = xhci_mtk_sch_init(mtk); in xhci_mtk_setup()
484 struct xhci_hcd_mtk *mtk; in xhci_mtk_probe() local
497 mtk = devm_kzalloc(dev, sizeof(*mtk), GFP_KERNEL); in xhci_mtk_probe()
498 if (!mtk) in xhci_mtk_probe()
501 mtk->dev = dev; in xhci_mtk_probe()
503 ret = xhci_mtk_vregs_get(mtk); in xhci_mtk_probe()
507 ret = xhci_mtk_clks_get(mtk); in xhci_mtk_probe()
526 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); in xhci_mtk_probe()
527 mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable"); in xhci_mtk_probe()
530 &mtk->u3p_dis_msk); in xhci_mtk_probe()
532 &mtk->u2p_dis_msk); in xhci_mtk_probe()
534 ret = usb_wakeup_of_property_parse(mtk, node); in xhci_mtk_probe()
546 ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_probe()
550 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
570 mtk->hcd = platform_get_drvdata(pdev); in xhci_mtk_probe()
571 platform_set_drvdata(pdev, mtk); in xhci_mtk_probe()
584 mtk->ippc_regs = devm_ioremap_resource(dev, res); in xhci_mtk_probe()
585 if (IS_ERR(mtk->ippc_regs)) { in xhci_mtk_probe()
586 ret = PTR_ERR(mtk->ippc_regs); in xhci_mtk_probe()
589 mtk->has_ippc = true; in xhci_mtk_probe()
648 xhci_mtk_sch_exit(mtk); in xhci_mtk_probe()
658 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
661 regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_probe()
671 struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev); in xhci_mtk_remove() local
672 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_remove()
687 xhci_mtk_sch_exit(mtk); in xhci_mtk_remove()
688 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_remove()
689 regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_remove()
700 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_suspend() local
701 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_suspend()
711 ret = xhci_mtk_host_disable(mtk); in xhci_mtk_suspend()
715 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_suspend()
716 usb_wakeup_set(mtk, true); in xhci_mtk_suspend()
730 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_resume() local
731 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_resume()
735 usb_wakeup_set(mtk, false); in xhci_mtk_resume()
736 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
740 ret = xhci_mtk_host_enable(mtk); in xhci_mtk_resume()
752 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
754 usb_wakeup_set(mtk, true); in xhci_mtk_resume()
760 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_suspend() local
761 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_suspend()
776 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_resume() local
777 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_resume()