Lines Matching refs:mtk

76 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)  in xhci_mtk_host_enable()  argument
78 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_enable()
84 if (!mtk->has_ippc) in xhci_mtk_host_enable()
93 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_enable()
94 if ((0x1 << i) & mtk->u3p_dis_msk) { in xhci_mtk_host_enable()
106 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_enable()
120 if (mtk->num_u3_ports > u3_ports_disabed) in xhci_mtk_host_enable()
126 dev_err(mtk->dev, "clocks are not stable (0x%x)\n", value); in xhci_mtk_host_enable()
133 static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_host_disable() argument
135 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_host_disable()
140 if (!mtk->has_ippc) in xhci_mtk_host_disable()
144 for (i = 0; i < mtk->num_u3_ports; i++) { in xhci_mtk_host_disable()
145 if ((0x1 << i) & mtk->u3p_dis_msk) in xhci_mtk_host_disable()
154 for (i = 0; i < mtk->num_u2_ports; i++) { in xhci_mtk_host_disable()
169 dev_err(mtk->dev, "ip sleep failed!!!\n"); in xhci_mtk_host_disable()
175 static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) in xhci_mtk_ssusb_config() argument
177 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; in xhci_mtk_ssusb_config()
180 if (!mtk->has_ippc) in xhci_mtk_ssusb_config()
201 mtk->num_u3_ports = CAP_U3_PORT_NUM(value); in xhci_mtk_ssusb_config()
202 mtk->num_u2_ports = CAP_U2_PORT_NUM(value); in xhci_mtk_ssusb_config()
203 dev_dbg(mtk->dev, "%s u2p:%d, u3p:%d\n", __func__, in xhci_mtk_ssusb_config()
204 mtk->num_u2_ports, mtk->num_u3_ports); in xhci_mtk_ssusb_config()
206 return xhci_mtk_host_enable(mtk); in xhci_mtk_ssusb_config()
222 static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) in xhci_mtk_clks_get() argument
224 struct device *dev = mtk->dev; in xhci_mtk_clks_get()
226 mtk->sys_clk = devm_clk_get(dev, "sys_ck"); in xhci_mtk_clks_get()
227 if (IS_ERR(mtk->sys_clk)) { in xhci_mtk_clks_get()
229 return PTR_ERR(mtk->sys_clk); in xhci_mtk_clks_get()
232 mtk->ref_clk = optional_clk_get(dev, "ref_ck"); in xhci_mtk_clks_get()
233 if (IS_ERR(mtk->ref_clk)) in xhci_mtk_clks_get()
234 return PTR_ERR(mtk->ref_clk); in xhci_mtk_clks_get()
236 mtk->mcu_clk = optional_clk_get(dev, "mcu_ck"); in xhci_mtk_clks_get()
237 if (IS_ERR(mtk->mcu_clk)) in xhci_mtk_clks_get()
238 return PTR_ERR(mtk->mcu_clk); in xhci_mtk_clks_get()
240 mtk->dma_clk = optional_clk_get(dev, "dma_ck"); in xhci_mtk_clks_get()
241 return PTR_ERR_OR_ZERO(mtk->dma_clk); in xhci_mtk_clks_get()
244 static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) in xhci_mtk_clks_enable() argument
248 ret = clk_prepare_enable(mtk->ref_clk); in xhci_mtk_clks_enable()
250 dev_err(mtk->dev, "failed to enable ref_clk\n"); in xhci_mtk_clks_enable()
254 ret = clk_prepare_enable(mtk->sys_clk); in xhci_mtk_clks_enable()
256 dev_err(mtk->dev, "failed to enable sys_clk\n"); in xhci_mtk_clks_enable()
260 ret = clk_prepare_enable(mtk->mcu_clk); in xhci_mtk_clks_enable()
262 dev_err(mtk->dev, "failed to enable mcu_clk\n"); in xhci_mtk_clks_enable()
266 ret = clk_prepare_enable(mtk->dma_clk); in xhci_mtk_clks_enable()
268 dev_err(mtk->dev, "failed to enable dma_clk\n"); in xhci_mtk_clks_enable()
275 clk_disable_unprepare(mtk->mcu_clk); in xhci_mtk_clks_enable()
277 clk_disable_unprepare(mtk->sys_clk); in xhci_mtk_clks_enable()
279 clk_disable_unprepare(mtk->ref_clk); in xhci_mtk_clks_enable()
284 static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_clks_disable() argument
286 clk_disable_unprepare(mtk->dma_clk); in xhci_mtk_clks_disable()
287 clk_disable_unprepare(mtk->mcu_clk); in xhci_mtk_clks_disable()
288 clk_disable_unprepare(mtk->sys_clk); in xhci_mtk_clks_disable()
289 clk_disable_unprepare(mtk->ref_clk); in xhci_mtk_clks_disable()
293 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_ip_sleep_set() argument
297 switch (mtk->uwk_vers) { in usb_wakeup_ip_sleep_set()
299 reg = mtk->uwk_reg_base + PERI_WK_CTRL1; in usb_wakeup_ip_sleep_set()
304 reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL; in usb_wakeup_ip_sleep_set()
311 regmap_update_bits(mtk->uwk, reg, msk, val); in usb_wakeup_ip_sleep_set()
314 static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, in usb_wakeup_of_property_parse() argument
321 mtk->uwk_en = of_property_read_bool(dn, "wakeup-source"); in usb_wakeup_of_property_parse()
322 if (!mtk->uwk_en) in usb_wakeup_of_property_parse()
330 mtk->uwk_reg_base = args.args[0]; in usb_wakeup_of_property_parse()
331 mtk->uwk_vers = args.args[1]; in usb_wakeup_of_property_parse()
332 mtk->uwk = syscon_node_to_regmap(args.np); in usb_wakeup_of_property_parse()
334 dev_info(mtk->dev, "uwk - reg:0x%x, version:%d\n", in usb_wakeup_of_property_parse()
335 mtk->uwk_reg_base, mtk->uwk_vers); in usb_wakeup_of_property_parse()
337 return PTR_ERR_OR_ZERO(mtk->uwk); in usb_wakeup_of_property_parse()
341 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable) in usb_wakeup_set() argument
343 if (mtk->uwk_en) in usb_wakeup_set()
344 usb_wakeup_ip_sleep_set(mtk, enable); in usb_wakeup_set()
354 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk) in xhci_mtk_ldos_enable() argument
358 ret = regulator_enable(mtk->vbus); in xhci_mtk_ldos_enable()
360 dev_err(mtk->dev, "failed to enable vbus\n"); in xhci_mtk_ldos_enable()
364 ret = regulator_enable(mtk->vusb33); in xhci_mtk_ldos_enable()
366 dev_err(mtk->dev, "failed to enable vusb33\n"); in xhci_mtk_ldos_enable()
367 regulator_disable(mtk->vbus); in xhci_mtk_ldos_enable()
373 static void xhci_mtk_ldos_disable(struct xhci_hcd_mtk *mtk) in xhci_mtk_ldos_disable() argument
375 regulator_disable(mtk->vbus); in xhci_mtk_ldos_disable()
376 regulator_disable(mtk->vusb33); in xhci_mtk_ldos_disable()
382 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_quirks() local
396 if (mtk->lpm_support) in xhci_mtk_quirks()
403 struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); in xhci_mtk_setup() local
407 ret = xhci_mtk_ssusb_config(mtk); in xhci_mtk_setup()
417 ret = xhci_mtk_sch_init(mtk); in xhci_mtk_setup()
429 struct xhci_hcd_mtk *mtk; in xhci_mtk_probe() local
441 mtk = devm_kzalloc(dev, sizeof(*mtk), GFP_KERNEL); in xhci_mtk_probe()
442 if (!mtk) in xhci_mtk_probe()
445 mtk->dev = dev; in xhci_mtk_probe()
446 mtk->vbus = devm_regulator_get(dev, "vbus"); in xhci_mtk_probe()
447 if (IS_ERR(mtk->vbus)) { in xhci_mtk_probe()
449 return PTR_ERR(mtk->vbus); in xhci_mtk_probe()
452 mtk->vusb33 = devm_regulator_get(dev, "vusb33"); in xhci_mtk_probe()
453 if (IS_ERR(mtk->vusb33)) { in xhci_mtk_probe()
455 return PTR_ERR(mtk->vusb33); in xhci_mtk_probe()
458 ret = xhci_mtk_clks_get(mtk); in xhci_mtk_probe()
462 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); in xhci_mtk_probe()
465 &mtk->u3p_dis_msk); in xhci_mtk_probe()
467 ret = usb_wakeup_of_property_parse(mtk, node); in xhci_mtk_probe()
477 ret = xhci_mtk_ldos_enable(mtk); in xhci_mtk_probe()
481 ret = xhci_mtk_clks_enable(mtk); in xhci_mtk_probe()
506 mtk->hcd = platform_get_drvdata(pdev); in xhci_mtk_probe()
507 platform_set_drvdata(pdev, mtk); in xhci_mtk_probe()
520 mtk->ippc_regs = devm_ioremap_resource(dev, res); in xhci_mtk_probe()
521 if (IS_ERR(mtk->ippc_regs)) { in xhci_mtk_probe()
522 ret = PTR_ERR(mtk->ippc_regs); in xhci_mtk_probe()
525 mtk->has_ippc = true; in xhci_mtk_probe()
527 mtk->has_ippc = false; in xhci_mtk_probe()
567 xhci_mtk_sch_exit(mtk); in xhci_mtk_probe()
577 xhci_mtk_clks_disable(mtk); in xhci_mtk_probe()
580 xhci_mtk_ldos_disable(mtk); in xhci_mtk_probe()
590 struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev); in xhci_mtk_remove() local
591 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_remove()
600 xhci_mtk_sch_exit(mtk); in xhci_mtk_remove()
601 xhci_mtk_clks_disable(mtk); in xhci_mtk_remove()
602 xhci_mtk_ldos_disable(mtk); in xhci_mtk_remove()
618 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_suspend() local
619 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_suspend()
628 xhci_mtk_host_disable(mtk); in xhci_mtk_suspend()
629 xhci_mtk_clks_disable(mtk); in xhci_mtk_suspend()
630 usb_wakeup_set(mtk, true); in xhci_mtk_suspend()
636 struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); in xhci_mtk_resume() local
637 struct usb_hcd *hcd = mtk->hcd; in xhci_mtk_resume()
640 usb_wakeup_set(mtk, false); in xhci_mtk_resume()
641 xhci_mtk_clks_enable(mtk); in xhci_mtk_resume()
642 xhci_mtk_host_enable(mtk); in xhci_mtk_resume()