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()
102 int ssusb_set_vbus(struct otg_switch_mtk *otg_sx, int is_on) in ssusb_set_vbus() argument
104 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_set_vbus()
105 struct regulator *vbus = otg_sx->vbus; in ssusb_set_vbus()
129 struct otg_switch_mtk *otg_sx = in ssusb_mode_sw_work() local
131 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_mode_sw_work()
133 enum usb_role desired_role = otg_sx->desired_role; in ssusb_mode_sw_work()
141 if (otg_sx->default_role == USB_ROLE_DEVICE) in ssusb_mode_sw_work()
157 ssusb_set_vbus(otg_sx, 1); in ssusb_mode_sw_work()
163 ssusb_set_vbus(otg_sx, 0); in ssusb_mode_sw_work()
174 static void ssusb_set_mode(struct otg_switch_mtk *otg_sx, enum usb_role role) in ssusb_set_mode() argument
176 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_set_mode()
181 otg_sx->desired_role = role; in ssusb_set_mode()
182 queue_work(system_freezable_wq, &otg_sx->dr_work); in ssusb_set_mode()
188 struct otg_switch_mtk *otg_sx = in ssusb_id_notifier() local
191 ssusb_set_mode(otg_sx, event ? USB_ROLE_HOST : USB_ROLE_DEVICE); in ssusb_id_notifier()
196 static int ssusb_extcon_register(struct otg_switch_mtk *otg_sx) in ssusb_extcon_register() argument
198 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_extcon_register()
199 struct extcon_dev *edev = otg_sx->edev; in ssusb_extcon_register()
206 otg_sx->id_nb.notifier_call = ssusb_id_notifier; in ssusb_extcon_register()
208 &otg_sx->id_nb); in ssusb_extcon_register()
219 ssusb_set_mode(otg_sx, USB_ROLE_DEVICE); in ssusb_extcon_register()
232 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_mode_switch() local
234 ssusb_set_mode(otg_sx, to_host ? USB_ROLE_HOST : USB_ROLE_DEVICE); in ssusb_mode_switch()
263 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_role_sw_set() local
265 ssusb_set_mode(otg_sx, role); in ssusb_role_sw_set()
277 static int ssusb_role_sw_register(struct otg_switch_mtk *otg_sx) in ssusb_role_sw_register() argument
280 struct ssusb_mtk *ssusb = otg_sx_to_ssusb(otg_sx); in ssusb_role_sw_register()
284 if (!otg_sx->role_sw_used) in ssusb_role_sw_register()
289 otg_sx->default_role = USB_ROLE_DEVICE; in ssusb_role_sw_register()
291 otg_sx->default_role = USB_ROLE_HOST; in ssusb_role_sw_register()
297 otg_sx->role_sw = usb_role_switch_register(dev, &role_sx_desc); in ssusb_role_sw_register()
298 if (IS_ERR(otg_sx->role_sw)) in ssusb_role_sw_register()
299 return PTR_ERR(otg_sx->role_sw); in ssusb_role_sw_register()
301 ssusb_set_mode(otg_sx, otg_sx->default_role); in ssusb_role_sw_register()
308 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_otg_switch_init() local
311 INIT_WORK(&otg_sx->dr_work, ssusb_mode_sw_work); in ssusb_otg_switch_init()
313 if (otg_sx->manual_drd_enabled) in ssusb_otg_switch_init()
315 else if (otg_sx->role_sw_used) in ssusb_otg_switch_init()
316 ret = ssusb_role_sw_register(otg_sx); in ssusb_otg_switch_init()
318 ret = ssusb_extcon_register(otg_sx); in ssusb_otg_switch_init()
325 struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; in ssusb_otg_switch_exit() local
327 cancel_work_sync(&otg_sx->dr_work); in ssusb_otg_switch_exit()
328 usb_role_switch_unregister(otg_sx->role_sw); in ssusb_otg_switch_exit()