Lines Matching full:glue

3  * Allwinner sun4i MUSB Glue Layer
99 struct sunxi_glue *glue = container_of(work, struct sunxi_glue, work); in sunxi_musb_work() local
102 if (!test_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags)) in sunxi_musb_work()
105 if (test_and_clear_bit(SUNXI_MUSB_FL_HOSTMODE_PEND, &glue->flags)) { in sunxi_musb_work()
106 struct musb *musb = glue->musb; in sunxi_musb_work()
113 if (test_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags)) { in sunxi_musb_work()
114 set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); in sunxi_musb_work()
119 clear_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); in sunxi_musb_work()
129 vbus_on = test_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); in sunxi_musb_work()
130 phy_on = test_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); in sunxi_musb_work()
134 phy_power_on(glue->phy); in sunxi_musb_work()
135 set_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); in sunxi_musb_work()
137 phy_power_off(glue->phy); in sunxi_musb_work()
138 clear_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); in sunxi_musb_work()
142 if (test_and_clear_bit(SUNXI_MUSB_FL_PHY_MODE_PEND, &glue->flags)) in sunxi_musb_work()
143 phy_set_mode(glue->phy, glue->phy_mode); in sunxi_musb_work()
148 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_set_vbus() local
151 set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); in sunxi_musb_set_vbus()
154 clear_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); in sunxi_musb_set_vbus()
157 schedule_work(&glue->work); in sunxi_musb_set_vbus()
162 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_pre_root_reset_end() local
164 sun4i_usb_phy_set_squelch_detect(glue->phy, false); in sunxi_musb_pre_root_reset_end()
169 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_post_root_reset_end() local
171 sun4i_usb_phy_set_squelch_detect(glue->phy, true); in sunxi_musb_post_root_reset_end()
209 struct sunxi_glue *glue = container_of(nb, struct sunxi_glue, host_nb); in sunxi_musb_host_notifier() local
212 set_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags); in sunxi_musb_host_notifier()
214 clear_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags); in sunxi_musb_host_notifier()
216 set_bit(SUNXI_MUSB_FL_HOSTMODE_PEND, &glue->flags); in sunxi_musb_host_notifier()
217 schedule_work(&glue->work); in sunxi_musb_host_notifier()
224 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_init() local
228 musb->phy = glue->phy; in sunxi_musb_init()
229 musb->xceiv = glue->xceiv; in sunxi_musb_init()
231 if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) { in sunxi_musb_init()
237 ret = clk_prepare_enable(glue->clk); in sunxi_musb_init()
241 if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) { in sunxi_musb_init()
242 ret = reset_control_deassert(glue->rst); in sunxi_musb_init()
250 ret = devm_extcon_register_notifier(glue->dev, glue->extcon, in sunxi_musb_init()
251 EXTCON_USB_HOST, &glue->host_nb); in sunxi_musb_init()
255 ret = phy_init(glue->phy); in sunxi_musb_init()
267 if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) in sunxi_musb_init()
268 reset_control_assert(glue->rst); in sunxi_musb_init()
270 clk_disable_unprepare(glue->clk); in sunxi_musb_init()
272 if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) in sunxi_musb_init()
279 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_exit() local
283 cancel_work_sync(&glue->work); in sunxi_musb_exit()
284 if (test_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags)) in sunxi_musb_exit()
285 phy_power_off(glue->phy); in sunxi_musb_exit()
287 phy_exit(glue->phy); in sunxi_musb_exit()
289 if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) in sunxi_musb_exit()
290 reset_control_assert(glue->rst); in sunxi_musb_exit()
292 clk_disable_unprepare(glue->clk); in sunxi_musb_exit()
293 if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) in sunxi_musb_exit()
301 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_enable() local
303 glue->musb = musb; in sunxi_musb_enable()
306 if (test_and_set_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags)) in sunxi_musb_enable()
309 schedule_work(&glue->work); in sunxi_musb_enable()
314 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_disable() local
316 clear_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags); in sunxi_musb_disable()
331 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_set_mode() local
350 if (glue->phy_mode == new_mode) in sunxi_musb_set_mode()
366 glue->phy_mode = new_mode; in sunxi_musb_set_mode()
367 set_bit(SUNXI_MUSB_FL_PHY_MODE_PEND, &glue->flags); in sunxi_musb_set_mode()
368 schedule_work(&glue->work); in sunxi_musb_set_mode()
375 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); in sunxi_musb_recover() local
378 * Schedule a phy_set_mode with the current glue->phy_mode value, in sunxi_musb_recover()
381 set_bit(SUNXI_MUSB_FL_PHY_MODE_PEND, &glue->flags); in sunxi_musb_recover()
382 schedule_work(&glue->work); in sunxi_musb_recover()
417 struct sunxi_glue *glue; in sunxi_musb_readb() local
441 glue = dev_get_drvdata(sunxi_musb->controller->parent); in sunxi_musb_readb()
444 &glue->flags)) in sunxi_musb_readb()
681 struct sunxi_glue *glue; in sunxi_musb_probe() local
691 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); in sunxi_musb_probe()
692 if (!glue) in sunxi_musb_probe()
700 glue->phy_mode = PHY_MODE_USB_HOST; in sunxi_musb_probe()
706 glue->phy_mode = PHY_MODE_USB_DEVICE; in sunxi_musb_probe()
712 glue->phy_mode = PHY_MODE_USB_OTG; in sunxi_musb_probe()
727 glue->dev = &pdev->dev; in sunxi_musb_probe()
728 INIT_WORK(&glue->work, sunxi_musb_work); in sunxi_musb_probe()
729 glue->host_nb.notifier_call = sunxi_musb_host_notifier; in sunxi_musb_probe()
732 set_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags); in sunxi_musb_probe()
735 set_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags); in sunxi_musb_probe()
738 set_bit(SUNXI_MUSB_FL_NO_CONFIGDATA, &glue->flags); in sunxi_musb_probe()
740 glue->clk = devm_clk_get(&pdev->dev, NULL); in sunxi_musb_probe()
741 if (IS_ERR(glue->clk)) { in sunxi_musb_probe()
743 PTR_ERR(glue->clk)); in sunxi_musb_probe()
744 return PTR_ERR(glue->clk); in sunxi_musb_probe()
747 if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) { in sunxi_musb_probe()
748 glue->rst = devm_reset_control_get(&pdev->dev, NULL); in sunxi_musb_probe()
749 if (IS_ERR(glue->rst)) in sunxi_musb_probe()
750 return dev_err_probe(&pdev->dev, PTR_ERR(glue->rst), in sunxi_musb_probe()
754 glue->extcon = extcon_get_edev_by_phandle(&pdev->dev, 0); in sunxi_musb_probe()
755 if (IS_ERR(glue->extcon)) in sunxi_musb_probe()
756 return dev_err_probe(&pdev->dev, PTR_ERR(glue->extcon), in sunxi_musb_probe()
759 glue->phy = devm_phy_get(&pdev->dev, "usb"); in sunxi_musb_probe()
760 if (IS_ERR(glue->phy)) in sunxi_musb_probe()
761 return dev_err_probe(&pdev->dev, PTR_ERR(glue->phy), in sunxi_musb_probe()
764 glue->usb_phy = usb_phy_generic_register(); in sunxi_musb_probe()
765 if (IS_ERR(glue->usb_phy)) { in sunxi_musb_probe()
767 PTR_ERR(glue->usb_phy)); in sunxi_musb_probe()
768 return PTR_ERR(glue->usb_phy); in sunxi_musb_probe()
771 glue->xceiv = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); in sunxi_musb_probe()
772 if (IS_ERR(glue->xceiv)) { in sunxi_musb_probe()
773 ret = PTR_ERR(glue->xceiv); in sunxi_musb_probe()
778 platform_set_drvdata(pdev, glue); in sunxi_musb_probe()
791 glue->musb_pdev = platform_device_register_full(&pinfo); in sunxi_musb_probe()
792 if (IS_ERR(glue->musb_pdev)) { in sunxi_musb_probe()
793 ret = PTR_ERR(glue->musb_pdev); in sunxi_musb_probe()
801 usb_phy_generic_unregister(glue->usb_phy); in sunxi_musb_probe()
807 struct sunxi_glue *glue = platform_get_drvdata(pdev); in sunxi_musb_remove() local
808 struct platform_device *usb_phy = glue->usb_phy; in sunxi_musb_remove()
810 platform_device_unregister(glue->musb_pdev); in sunxi_musb_remove()
868 MODULE_DESCRIPTION("Allwinner sunxi MUSB Glue Layer");