Lines Matching refs:mtk

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