Lines Matching refs:glue

54 static int mtk_musb_clks_get(struct mtk_glue *glue)  in mtk_musb_clks_get()  argument
56 struct device *dev = glue->dev; in mtk_musb_clks_get()
58 glue->clks[0].id = "main"; in mtk_musb_clks_get()
59 glue->clks[1].id = "mcu"; in mtk_musb_clks_get()
60 glue->clks[2].id = "univpll"; in mtk_musb_clks_get()
62 return devm_clk_bulk_get(dev, MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_clks_get()
65 static int mtk_otg_switch_set(struct mtk_glue *glue, enum usb_role role) in mtk_otg_switch_set() argument
67 struct musb *musb = glue->musb; in mtk_otg_switch_set()
71 if (role == glue->role) in mtk_otg_switch_set()
77 glue->phy_mode = PHY_MODE_USB_HOST; in mtk_otg_switch_set()
79 if (glue->role == USB_ROLE_NONE) in mtk_otg_switch_set()
80 phy_power_on(glue->phy); in mtk_otg_switch_set()
88 glue->phy_mode = PHY_MODE_USB_DEVICE; in mtk_otg_switch_set()
92 if (glue->role == USB_ROLE_NONE) in mtk_otg_switch_set()
93 phy_power_on(glue->phy); in mtk_otg_switch_set()
98 glue->phy_mode = PHY_MODE_USB_OTG; in mtk_otg_switch_set()
102 if (glue->role != USB_ROLE_NONE) in mtk_otg_switch_set()
103 phy_power_off(glue->phy); in mtk_otg_switch_set()
107 dev_err(glue->dev, "Invalid State\n"); in mtk_otg_switch_set()
111 glue->role = new_role; in mtk_otg_switch_set()
112 phy_set_mode(glue->phy, glue->phy_mode); in mtk_otg_switch_set()
124 struct mtk_glue *glue = usb_role_switch_get_drvdata(sw); in musb_usb_role_sx_get() local
126 return glue->role; in musb_usb_role_sx_get()
129 static int mtk_otg_switch_init(struct mtk_glue *glue) in mtk_otg_switch_init() argument
136 role_sx_desc.fwnode = dev_fwnode(glue->dev); in mtk_otg_switch_init()
137 role_sx_desc.driver_data = glue; in mtk_otg_switch_init()
138 glue->role_sw = usb_role_switch_register(glue->dev, &role_sx_desc); in mtk_otg_switch_init()
140 return PTR_ERR_OR_ZERO(glue->role_sw); in mtk_otg_switch_init()
143 static void mtk_otg_switch_exit(struct mtk_glue *glue) in mtk_otg_switch_exit() argument
145 return usb_role_switch_unregister(glue->role_sw); in mtk_otg_switch_exit()
220 struct mtk_glue *glue = dev_get_drvdata(dev->parent); in mtk_musb_set_mode() local
238 dev_err(glue->dev, "Invalid mode request\n"); in mtk_musb_set_mode()
242 if (glue->phy_mode == new_mode) in mtk_musb_set_mode()
246 dev_err(glue->dev, "Does not support changing modes\n"); in mtk_musb_set_mode()
250 mtk_otg_switch_set(glue, new_role); in mtk_musb_set_mode()
257 struct mtk_glue *glue = dev_get_drvdata(dev->parent); in mtk_musb_init() local
260 glue->musb = musb; in mtk_musb_init()
261 musb->phy = glue->phy; in mtk_musb_init()
262 musb->xceiv = glue->xceiv; in mtk_musb_init()
271 ret = mtk_otg_switch_init(glue); in mtk_musb_init()
276 ret = phy_init(glue->phy); in mtk_musb_init()
280 ret = phy_power_on(glue->phy); in mtk_musb_init()
284 phy_set_mode(glue->phy, glue->phy_mode); in mtk_musb_init()
295 phy_exit(glue->phy); in mtk_musb_init()
297 mtk_otg_switch_exit(glue); in mtk_musb_init()
335 struct mtk_glue *glue = dev_get_drvdata(dev->parent); in mtk_musb_exit() local
337 mtk_otg_switch_exit(glue); in mtk_musb_exit()
338 phy_power_off(glue->phy); in mtk_musb_exit()
339 phy_exit(glue->phy); in mtk_musb_exit()
340 clk_bulk_disable_unprepare(MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_exit()
401 struct mtk_glue *glue; in mtk_musb_probe() local
407 glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); in mtk_musb_probe()
408 if (!glue) in mtk_musb_probe()
411 glue->dev = dev; in mtk_musb_probe()
422 ret = mtk_musb_clks_get(glue); in mtk_musb_probe()
437 glue->phy_mode = PHY_MODE_USB_HOST; in mtk_musb_probe()
438 glue->role = USB_ROLE_HOST; in mtk_musb_probe()
441 glue->phy_mode = PHY_MODE_USB_DEVICE; in mtk_musb_probe()
442 glue->role = USB_ROLE_DEVICE; in mtk_musb_probe()
445 glue->phy_mode = PHY_MODE_USB_OTG; in mtk_musb_probe()
446 glue->role = USB_ROLE_NONE; in mtk_musb_probe()
453 glue->phy = devm_of_phy_get_by_index(dev, np, 0); in mtk_musb_probe()
454 if (IS_ERR(glue->phy)) { in mtk_musb_probe()
456 PTR_ERR(glue->phy)); in mtk_musb_probe()
457 return PTR_ERR(glue->phy); in mtk_musb_probe()
460 glue->usb_phy = usb_phy_generic_register(); in mtk_musb_probe()
461 if (IS_ERR(glue->usb_phy)) { in mtk_musb_probe()
463 PTR_ERR(glue->usb_phy)); in mtk_musb_probe()
464 return PTR_ERR(glue->usb_phy); in mtk_musb_probe()
467 glue->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in mtk_musb_probe()
468 if (IS_ERR(glue->xceiv)) { in mtk_musb_probe()
469 ret = PTR_ERR(glue->xceiv); in mtk_musb_probe()
474 platform_set_drvdata(pdev, glue); in mtk_musb_probe()
478 ret = clk_bulk_prepare_enable(MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_probe()
491 glue->musb_pdev = platform_device_register_full(&pinfo); in mtk_musb_probe()
492 if (IS_ERR(glue->musb_pdev)) { in mtk_musb_probe()
493 ret = PTR_ERR(glue->musb_pdev); in mtk_musb_probe()
501 clk_bulk_disable_unprepare(MTK_MUSB_CLKS_NUM, glue->clks); in mtk_musb_probe()
506 usb_phy_generic_unregister(glue->usb_phy); in mtk_musb_probe()
512 struct mtk_glue *glue = platform_get_drvdata(pdev); in mtk_musb_remove() local
513 struct platform_device *usb_phy = glue->usb_phy; in mtk_musb_remove()
515 platform_device_unregister(glue->musb_pdev); in mtk_musb_remove()