Lines Matching full:role
28 static int cdns_role_start(struct cdns *cdns, enum usb_role role) in cdns_role_start() argument
32 if (WARN_ON(role > USB_ROLE_DEVICE)) in cdns_role_start()
36 cdns->role = role; in cdns_role_start()
39 if (!cdns->roles[role]) in cdns_role_start()
42 if (cdns->roles[role]->state == CDNS_ROLE_STATE_ACTIVE) in cdns_role_start()
46 ret = cdns->roles[role]->start(cdns); in cdns_role_start()
48 cdns->roles[role]->state = CDNS_ROLE_STATE_ACTIVE; in cdns_role_start()
56 enum usb_role role = cdns->role; in cdns_role_stop() local
58 if (WARN_ON(role > USB_ROLE_DEVICE)) in cdns_role_stop()
61 if (cdns->roles[role]->state == CDNS_ROLE_STATE_INACTIVE) in cdns_role_stop()
65 cdns->roles[role]->stop(cdns); in cdns_role_stop()
66 cdns->roles[role]->state = CDNS_ROLE_STATE_INACTIVE; in cdns_role_stop()
77 * cdns_core_init_role - initialize role of operation
90 cdns->role = USB_ROLE_NONE; in cdns_core_init_role()
173 /* Initialize idle role to start with */ in cdns_core_init_role()
206 * cdns_hw_role_state_machine - role switch state machine based on hw events.
209 * Returns next role to be entered based on hw events.
213 enum usb_role role = USB_ROLE_NONE; in cdns_hw_role_state_machine() local
218 role = USB_ROLE_HOST; in cdns_hw_role_state_machine()
220 role = USB_ROLE_DEVICE; in cdns_hw_role_state_machine()
222 return role; in cdns_hw_role_state_machine()
229 * Role change state machine in cdns_hw_role_state_machine()
231 * Previous state: cdns->role in cdns_hw_role_state_machine()
232 * Next state: role in cdns_hw_role_state_machine()
234 role = cdns->role; in cdns_hw_role_state_machine()
236 switch (role) { in cdns_hw_role_state_machine()
243 role = USB_ROLE_HOST; in cdns_hw_role_state_machine()
245 role = USB_ROLE_DEVICE; in cdns_hw_role_state_machine()
249 role = USB_ROLE_NONE; in cdns_hw_role_state_machine()
253 role = USB_ROLE_NONE; in cdns_hw_role_state_machine()
257 dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role); in cdns_hw_role_state_machine()
259 return role; in cdns_hw_role_state_machine()
302 /* Depends on role switch class */ in cdns_hw_role_switch()
308 current_role = cdns->role; in cdns_hw_role_switch()
317 dev_dbg(cdns->dev, "Switching role %d -> %d", current_role, real_role); in cdns_hw_role_switch()
321 /* Back to current role */ in cdns_hw_role_switch()
335 * cdns_role_get - get current role of controller.
337 * @sw: pointer to USB role switch structure
339 * Returns role
345 return cdns->role; in cdns_role_get()
349 * cdns_role_set - set current role of controller.
351 * @sw: pointer to USB role switch structure
352 * @role: the previous role
354 * - Role switch for dual-role devices
357 static int cdns_role_set(struct usb_role_switch *sw, enum usb_role role) in cdns_role_set() argument
364 if (cdns->role == role) in cdns_role_set()
368 switch (role) { in cdns_role_set()
378 switch (role) { in cdns_role_set()
388 ret = cdns_role_start(cdns, role); in cdns_role_set()
390 dev_err(cdns->dev, "set role %d has failed\n", role); in cdns_role_set()
412 if ((cdns->role == USB_ROLE_HOST) && cdns->host_dev) in cdns_wakeup_irq()
440 if (device_property_read_bool(dev, "usb-role-switch")) { in cdns_init()
451 dev_warn(dev, "Unable to register Role Switch\n"); in cdns_init()
515 if (cdns->roles[cdns->role]->suspend) { in cdns_suspend()
517 cdns->roles[cdns->role]->suspend(cdns, false); in cdns_suspend()
534 cdns->role = cdns_role_get(cdns->role_sw); in cdns_resume()
537 if (real_role != cdns->role) { in cdns_resume()
546 if (cdns->role == USB_ROLE_HOST) in cdns_resume()
548 else if (cdns->role == USB_ROLE_DEVICE) in cdns_resume()
556 if (cdns->roles[cdns->role]->resume) in cdns_resume()
557 cdns->roles[cdns->role]->resume(cdns, cdns_power_is_lost(cdns)); in cdns_resume()