Lines Matching refs:otg_sx

17 static inline struct ssusb_mtk *otg_sx_to_ssusb(struct otg_switch_mtk *otg_sx)  in otg_sx_to_ssusb()  argument
19 return container_of(otg_sx, struct ssusb_mtk, otg_switch); in otg_sx_to_ssusb()
104 int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on) in ssusb_set_vbus() argument
106 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_set_vbus()
107 struct regulator *vbus = otg_sx->vbus; in ssusb_set_vbus()
131 struct otg_switch_mtk *otg_sx = in ssusb_mode_sw_work() local
133 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_mode_sw_work()
135 enum usb_role desired_role = otg_sx->desired_role; in ssusb_mode_sw_work()
143 if (otg_sx->default_role == USB_ROLE_DEVICE) in ssusb_mode_sw_work()
159 ssusb_set_vbus(otg_sx, 1); in ssusb_mode_sw_work()
165 ssusb_set_vbus(otg_sx, 0); in ssusb_mode_sw_work()
176 static void ssusb_set_mode(struct otg_switch_mtk *otg_sx, enum usb_role role) in ssusb_set_mode() argument
178 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_set_mode()
183 otg_sx->desired_role = role; in ssusb_set_mode()
184 queue_work(system_freezable_wq, &otg_sx->dr_work); in ssusb_set_mode()
190 struct otg_switch_mtk *otg_sx = in ssusb_id_notifier() local
193 ssusb_set_mode(otg_sx, event ? USB_ROLE_HOST : USB_ROLE_DEVICE); in ssusb_id_notifier()
198 static int ssusb_extcon_register(struct otg_switch_mtk *otg_sx) in ssusb_extcon_register() argument
200 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_extcon_register()
201 struct extcon_dev *edev = otg_sx->edev; in ssusb_extcon_register()
208 otg_sx->id_nb.notifier_call = ssusb_id_notifier; in ssusb_extcon_register()
210 &otg_sx->id_nb); in ssusb_extcon_register()
221 ssusb_set_mode(otg_sx, USB_ROLE_DEVICE); in ssusb_extcon_register()
234 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_mode_switch() local
236 ssusb_set_mode(otg_sx, to_host ? USB_ROLE_HOST : USB_ROLE_DEVICE); in ssusb_mode_switch()
265 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_role_sw_set() local
267 ssusb_set_mode(otg_sx, role); in ssusb_role_sw_set()
279 static int ssusb_role_sw_register(struct otg_switch_mtk *otg_sx) in ssusb_role_sw_register() argument
282 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_role_sw_register()
286 if (!otg_sx->role_sw_used) in ssusb_role_sw_register()
291 otg_sx->default_role = USB_ROLE_DEVICE; in ssusb_role_sw_register()
293 otg_sx->default_role = USB_ROLE_HOST; in ssusb_role_sw_register()
299 otg_sx->role_sw = usb_role_switch_register(dev, &role_sx_desc); in ssusb_role_sw_register()
300 if (IS_ERR(otg_sx->role_sw)) in ssusb_role_sw_register()
301 return PTR_ERR(otg_sx->role_sw); in ssusb_role_sw_register()
303 ssusb_set_mode(otg_sx, otg_sx->default_role); in ssusb_role_sw_register()
310 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_otg_switch_init() local
313 INIT_WORK(&otg_sx->dr_work, ssusb_mode_sw_work); in ssusb_otg_switch_init()
315 if (otg_sx->manual_drd_enabled) in ssusb_otg_switch_init()
317 else if (otg_sx->role_sw_used) in ssusb_otg_switch_init()
318 ret = ssusb_role_sw_register(otg_sx); in ssusb_otg_switch_init()
320 ret = ssusb_extcon_register(otg_sx); in ssusb_otg_switch_init()
327 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_otg_switch_exit() local
329 cancel_work_sync(&otg_sx->dr_work); in ssusb_otg_switch_exit()
330 usb_role_switch_unregister(otg_sx->role_sw); in ssusb_otg_switch_exit()