Lines Matching full:mtk
25 #include "xhci-mtk.h"
139 static void xhci_mtk_set_frame_interval(struct xhci_hcd_mtk *mtk) in xhci_mtk_set_frame_interval() argument
141 struct device *dev = mtk->dev; in xhci_mtk_set_frame_interval()
142 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_set_frame_interval()
179 static void xhci_mtk_rxfifo_depth_set(struct xhci_hcd_mtk *mtk) in xhci_mtk_rxfifo_depth_set() argument
181 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_rxfifo_depth_set()
184 if (!mtk->rxfifo_depth) in xhci_mtk_rxfifo_depth_set()
190 SCH_FIFO_TO_KB(mtk->rxfifo_depth) - 1); in xhci_mtk_rxfifo_depth_set()
194 static void xhci_mtk_init_quirk(struct xhci_hcd_mtk *mtk) in xhci_mtk_init_quirk() argument
197 xhci_mtk_set_frame_interval(mtk); in xhci_mtk_init_quirk()
200 xhci_mtk_rxfifo_depth_set(mtk); in xhci_mtk_init_quirk()
203 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_enable() argument
205 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_enable()
211 if (!mtk->has_ippc) in xhci_mtk_host_enable()
220 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_enable()
221 if ((0x1 << i) & mtk->u3p_dis_msk) { in xhci_mtk_host_enable()
233 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_enable()
234 if (BIT(i) & mtk->u2p_dis_msk) in xhci_mtk_host_enable()
250 if (mtk->num_u3_ports > u3_ports_disabled) in xhci_mtk_host_enable()
256 dev_err(mtk->dev, "clocks are not stable (0x%x)\n", value); in xhci_mtk_host_enable()
263 static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_disable() argument
265 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_disable()
270 if (!mtk->has_ippc) in xhci_mtk_host_disable()
274 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_disable()
275 if ((0x1 << i) & mtk->u3p_dis_msk) in xhci_mtk_host_disable()
284 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_disable()
285 if (BIT(i) & mtk->u2p_dis_msk) in xhci_mtk_host_disable()
302 dev_err(mtk->dev, "ip sleep failed!!!\n"); in xhci_mtk_host_disable()
309 static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) in xhci_mtk_ssusb_config() argument
311 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_ssusb_config()
314 if (!mtk->has_ippc) in xhci_mtk_ssusb_config()
335 mtk->num_u3_ports = CAP_U3_PORT_NUM(value); in xhci_mtk_ssusb_config()
336 mtk->num_u2_ports = CAP_U2_PORT_NUM(value); in xhci_mtk_ssusb_config()
337 dev_dbg(mtk->dev, "%s u2p:%d, u3p:%d\n", __func__, in xhci_mtk_ssusb_config()
338 mtk->num_u2_ports, mtk->num_u3_ports); in xhci_mtk_ssusb_config()
340 return xhci_mtk_host_enable(mtk); in xhci_mtk_ssusb_config()
344 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_ip_sleep_set() argument
348 switch (mtk->uwk_vers) { in usb_wakeup_ip_sleep_set()
350 reg = mtk->uwk_reg_base + PERI_WK_CTRL1; in usb_wakeup_ip_sleep_set()
355 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; in usb_wakeup_ip_sleep_set()
360 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; in usb_wakeup_ip_sleep_set()
365 reg = mtk->uwk_reg_base + PERI_WK_CTRL1_8195; in usb_wakeup_ip_sleep_set()
370 reg = mtk->uwk_reg_base + PERI_WK_CTRL0_8195; in usb_wakeup_ip_sleep_set()
375 reg = mtk->uwk_reg_base + PERI_WK_CTRL0_8195; in usb_wakeup_ip_sleep_set()
380 reg = mtk->uwk_reg_base + PERI_WK_CTRL0_8195; in usb_wakeup_ip_sleep_set()
385 reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL; in usb_wakeup_ip_sleep_set()
392 regmap_update_bits(mtk->uwk, reg, msk, val); in usb_wakeup_ip_sleep_set()
395 static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, in usb_wakeup_of_property_parse() argument
402 mtk->uwk_en = of_property_read_bool(dn, "wakeup-source"); in usb_wakeup_of_property_parse()
403 if (!mtk->uwk_en) in usb_wakeup_of_property_parse()
411 mtk->uwk_reg_base = args.args[0]; in usb_wakeup_of_property_parse()
412 mtk->uwk_vers = args.args[1]; in usb_wakeup_of_property_parse()
413 mtk->uwk = syscon_node_to_regmap(args.np); in usb_wakeup_of_property_parse()
415 dev_info(mtk->dev, "uwk - reg:0x%x, version:%d\n", in usb_wakeup_of_property_parse()
416 mtk->uwk_reg_base, mtk->uwk_vers); in usb_wakeup_of_property_parse()
418 return PTR_ERR_OR_ZERO(mtk->uwk); in usb_wakeup_of_property_parse()
421 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_set() argument
423 if (mtk->uwk_en) in usb_wakeup_set()
424 usb_wakeup_ip_sleep_set(mtk, enable); in usb_wakeup_set()
427 static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) in xhci_mtk_clks_get() argument
429 struct clk_bulk_data *clks = mtk->clks; in xhci_mtk_clks_get()
438 return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks); in xhci_mtk_clks_get()
441 static int xhci_mtk_vregs_get(struct xhci_hcd_mtk *mtk) in xhci_mtk_vregs_get() argument
443 struct regulator_bulk_data *supplies = mtk->supplies; in xhci_mtk_vregs_get()
448 return devm_regulator_bulk_get(mtk->dev, BULK_VREGS_NUM, supplies); in xhci_mtk_vregs_get()
454 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_quirks() local
458 * MTK host controller gives a spurious successful event after a in xhci_mtk_quirks()
462 if (mtk->lpm_support) in xhci_mtk_quirks()
464 if (mtk->u2_lpm_disable) in xhci_mtk_quirks()
468 * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream, in xhci_mtk_quirks()
478 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_setup() local
482 ret = xhci_mtk_ssusb_config(mtk); in xhci_mtk_setup()
486 xhci_mtk_init_quirk(mtk); in xhci_mtk_setup()
494 ret = xhci_mtk_sch_init(mtk); in xhci_mtk_setup()
513 struct xhci_hcd_mtk *mtk; in xhci_mtk_probe() local
527 mtk = devm_kzalloc(dev, sizeof(*mtk), GFP_KERNEL); in xhci_mtk_probe()
528 if (!mtk) in xhci_mtk_probe()
531 mtk->dev = dev; in xhci_mtk_probe()
533 ret = xhci_mtk_vregs_get(mtk); in xhci_mtk_probe()
537 ret = xhci_mtk_clks_get(mtk); in xhci_mtk_probe()
556 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); in xhci_mtk_probe()
557 mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable"); in xhci_mtk_probe()
560 &mtk->u3p_dis_msk); in xhci_mtk_probe()
562 &mtk->u2p_dis_msk); in xhci_mtk_probe()
564 of_property_read_u32(node, "rx-fifo-depth", &mtk->rxfifo_depth); in xhci_mtk_probe()
566 ret = usb_wakeup_of_property_parse(mtk, node); in xhci_mtk_probe()
578 ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_probe()
582 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
600 * Swap it with mtk HCD. in xhci_mtk_probe()
602 mtk->hcd = platform_get_drvdata(pdev); in xhci_mtk_probe()
603 platform_set_drvdata(pdev, mtk); in xhci_mtk_probe()
616 mtk->ippc_regs = devm_ioremap_resource(dev, res); in xhci_mtk_probe()
617 if (IS_ERR(mtk->ippc_regs)) { in xhci_mtk_probe()
618 ret = PTR_ERR(mtk->ippc_regs); in xhci_mtk_probe()
621 mtk->has_ippc = true; in xhci_mtk_probe()
634 * the xHCI spec on MTK's controller. in xhci_mtk_probe()
686 xhci_mtk_sch_exit(mtk); in xhci_mtk_probe()
696 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_probe()
699 regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_probe()
709 struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev); in xhci_mtk_remove() local
710 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_remove()
730 xhci_mtk_sch_exit(mtk); in xhci_mtk_remove()
731 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_remove()
732 regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); in xhci_mtk_remove()
741 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_suspend() local
742 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_suspend()
755 ret = xhci_mtk_host_disable(mtk); in xhci_mtk_suspend()
759 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_suspend()
760 usb_wakeup_set(mtk, true); in xhci_mtk_suspend()
776 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_resume() local
777 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_resume()
782 usb_wakeup_set(mtk, false); in xhci_mtk_resume()
783 ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
787 ret = xhci_mtk_host_enable(mtk); in xhci_mtk_resume()
801 clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); in xhci_mtk_resume()
803 usb_wakeup_set(mtk, true); in xhci_mtk_resume()
809 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_suspend() local
810 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_suspend()
825 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_runtime_resume() local
826 struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); in xhci_mtk_runtime_resume()
849 { .compatible = "mediatek,mtk-xhci"},
858 .name = "xhci-mtk",