Lines Matching full:glue

55 static int mtk_musb_clks_get(struct mtk_glue *glue)  in mtk_musb_clks_get()  argument
57 struct device *dev = glue->dev; in mtk_musb_clks_get()
59 glue->clks[0].id = "main"; in mtk_musb_clks_get()
60 glue->clks[1].id = "mcu"; in mtk_musb_clks_get()
61 glue->clks[2].id = "univpll"; in mtk_musb_clks_get()
63 return devm_clk_bulk_get(dev, MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_clks_get()
66 static int mtk_otg_switch_set(struct mtk_glue *glue, enum usb_role role) in mtk_otg_switch_set() argument
68 struct musb *musb = glue->musb; in mtk_otg_switch_set()
72 if (role == glue->role) in mtk_otg_switch_set()
78 glue->phy_mode = PHY_MODE_USB_HOST; in mtk_otg_switch_set()
80 if (glue->role == USB_ROLE_NONE) in mtk_otg_switch_set()
81 phy_power_on(glue->phy); in mtk_otg_switch_set()
89 glue->phy_mode = PHY_MODE_USB_DEVICE; in mtk_otg_switch_set()
93 if (glue->role == USB_ROLE_NONE) in mtk_otg_switch_set()
94 phy_power_on(glue->phy); in mtk_otg_switch_set()
99 glue->phy_mode = PHY_MODE_USB_OTG; in mtk_otg_switch_set()
103 if (glue->role != USB_ROLE_NONE) in mtk_otg_switch_set()
104 phy_power_off(glue->phy); in mtk_otg_switch_set()
108 dev_err(glue->dev, "Invalid State\n"); in mtk_otg_switch_set()
112 glue->role = new_role; in mtk_otg_switch_set()
113 phy_set_mode(glue->phy, glue->phy_mode); in mtk_otg_switch_set()
125 struct mtk_glue *glue = usb_role_switch_get_drvdata(sw); in musb_usb_role_sx_get() local
127 return glue->role; in musb_usb_role_sx_get()
130 static int mtk_otg_switch_init(struct mtk_glue *glue) in mtk_otg_switch_init() argument
137 role_sx_desc.fwnode = dev_fwnode(glue->dev); in mtk_otg_switch_init()
138 role_sx_desc.driver_data = glue; in mtk_otg_switch_init()
139 glue->role_sw = usb_role_switch_register(glue->dev, &role_sx_desc); in mtk_otg_switch_init()
141 return PTR_ERR_OR_ZERO(glue->role_sw); in mtk_otg_switch_init()
144 static void mtk_otg_switch_exit(struct mtk_glue *glue) in mtk_otg_switch_exit() argument
146 return usb_role_switch_unregister(glue->role_sw); in mtk_otg_switch_exit()
221 struct mtk_glue *glue = dev_get_drvdata(dev->parent); in mtk_musb_set_mode() local
239 dev_err(glue->dev, "Invalid mode request\n"); in mtk_musb_set_mode()
243 if (glue->phy_mode == new_mode) in mtk_musb_set_mode()
247 dev_err(glue->dev, "Does not support changing modes\n"); in mtk_musb_set_mode()
251 mtk_otg_switch_set(glue, new_role); in mtk_musb_set_mode()
258 struct mtk_glue *glue = dev_get_drvdata(dev->parent); in mtk_musb_init() local
261 glue->musb = musb; in mtk_musb_init()
262 musb->phy = glue->phy; in mtk_musb_init()
263 musb->xceiv = glue->xceiv; in mtk_musb_init()
272 ret = mtk_otg_switch_init(glue); in mtk_musb_init()
277 ret = phy_init(glue->phy); in mtk_musb_init()
281 ret = phy_power_on(glue->phy); in mtk_musb_init()
285 phy_set_mode(glue->phy, glue->phy_mode); in mtk_musb_init()
296 phy_exit(glue->phy); in mtk_musb_init()
299 mtk_otg_switch_exit(glue); in mtk_musb_init()
337 struct mtk_glue *glue = dev_get_drvdata(dev->parent); in mtk_musb_exit() local
339 mtk_otg_switch_exit(glue); in mtk_musb_exit()
340 phy_power_off(glue->phy); in mtk_musb_exit()
341 phy_exit(glue->phy); in mtk_musb_exit()
342 clk_bulk_disable_unprepare(MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_exit()
403 struct mtk_glue *glue; in mtk_musb_probe() local
409 glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); in mtk_musb_probe()
410 if (!glue) in mtk_musb_probe()
413 glue->dev = dev; in mtk_musb_probe()
423 ret = mtk_musb_clks_get(glue); in mtk_musb_probe()
438 glue->phy_mode = PHY_MODE_USB_HOST; in mtk_musb_probe()
439 glue->role = USB_ROLE_HOST; in mtk_musb_probe()
442 glue->phy_mode = PHY_MODE_USB_DEVICE; in mtk_musb_probe()
443 glue->role = USB_ROLE_DEVICE; in mtk_musb_probe()
446 glue->phy_mode = PHY_MODE_USB_OTG; in mtk_musb_probe()
447 glue->role = USB_ROLE_NONE; in mtk_musb_probe()
454 glue->phy = devm_of_phy_get_by_index(dev, np, 0); in mtk_musb_probe()
455 if (IS_ERR(glue->phy)) in mtk_musb_probe()
456 return dev_err_probe(dev, PTR_ERR(glue->phy), in mtk_musb_probe()
459 glue->usb_phy = usb_phy_generic_register(); in mtk_musb_probe()
460 if (IS_ERR(glue->usb_phy)) in mtk_musb_probe()
461 return dev_err_probe(dev, PTR_ERR(glue->usb_phy), in mtk_musb_probe()
464 glue->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in mtk_musb_probe()
465 if (IS_ERR(glue->xceiv)) { in mtk_musb_probe()
466 ret = PTR_ERR(glue->xceiv); in mtk_musb_probe()
471 platform_set_drvdata(pdev, glue); in mtk_musb_probe()
475 ret = clk_bulk_prepare_enable(MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_probe()
488 glue->musb_pdev = platform_device_register_full(&pinfo); in mtk_musb_probe()
489 if (IS_ERR(glue->musb_pdev)) { in mtk_musb_probe()
490 ret = PTR_ERR(glue->musb_pdev); in mtk_musb_probe()
498 clk_bulk_disable_unprepare(MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_probe()
503 usb_phy_generic_unregister(glue->usb_phy); in mtk_musb_probe()
509 struct mtk_glue *glue = platform_get_drvdata(pdev); in mtk_musb_remove() local
510 struct platform_device *usb_phy = glue->usb_phy; in mtk_musb_remove()
512 platform_device_unregister(glue->musb_pdev); in mtk_musb_remove()
535 MODULE_DESCRIPTION("MediaTek MUSB Glue Layer");