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
498 mtk = devm_kzalloc(dev, sizeof(*mtk), GFP_KERNEL); in xhci_mtk_probe()
499 if (!mtk) in xhci_mtk_probe()
502 mtk->dev = dev; in xhci_mtk_probe()
504 ret = xhci_mtk_vregs_get(mtk); in xhci_mtk_probe()
508 ret = xhci_mtk_clks_get(mtk); in xhci_mtk_probe()
527 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); in xhci_mtk_probe()
528 mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable"); in xhci_mtk_probe()
531 &mtk->u3p_dis_msk); in xhci_mtk_probe()
533 &mtk->u2p_dis_msk); in xhci_mtk_probe()
535 ret = usb_wakeup_of_property_parse(mtk, node); in xhci_mtk_probe()
547 ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_probe()
551 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
571 mtk->hcd = platform_get_drvdata(pdev); in xhci_mtk_probe()
572 platform_set_drvdata(pdev, mtk); in xhci_mtk_probe()
585 mtk->ippc_regs = devm_ioremap_resource(dev, res); in xhci_mtk_probe()
586 if (IS_ERR(mtk->ippc_regs)) { in xhci_mtk_probe()
587 ret = PTR_ERR(mtk->ippc_regs); in xhci_mtk_probe()
590 mtk->has_ippc = true; in xhci_mtk_probe()
654 xhci_mtk_sch_exit(mtk); in xhci_mtk_probe()
664 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
667 regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_probe()
677 struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev); in xhci_mtk_remove() local
678 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_remove()
698 xhci_mtk_sch_exit(mtk); in xhci_mtk_remove()
699 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_remove()
700 regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_remove()
711 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_suspend() local
712 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_suspend()
725 ret = xhci_mtk_host_disable(mtk); in xhci_mtk_suspend()
729 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_suspend()
730 usb_wakeup_set(mtk, true); in xhci_mtk_suspend()
746 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_resume() local
747 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_resume()
752 usb_wakeup_set(mtk, false); in xhci_mtk_resume()
753 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
757 ret = xhci_mtk_host_enable(mtk); in xhci_mtk_resume()
771 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
773 usb_wakeup_set(mtk, true); in xhci_mtk_resume()
779 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_suspend() local
780 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_suspend()
795 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_resume() local
796 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_resume()