Lines Matching full:role

29 static int cdns_role_start(struct cdns *cdns, enum usb_role role)  in cdns_role_start()  argument
33 if (WARN_ON(role > USB_ROLE_DEVICE)) in cdns_role_start()
37 cdns->role = role; in cdns_role_start()
40 if (!cdns->roles[role]) in cdns_role_start()
43 if (cdns->roles[role]->state == CDNS_ROLE_STATE_ACTIVE) in cdns_role_start()
47 ret = cdns->roles[role]->start(cdns); in cdns_role_start()
49 cdns->roles[role]->state = CDNS_ROLE_STATE_ACTIVE; in cdns_role_start()
57 enum usb_role role = cdns->role; in cdns_role_stop() local
59 if (WARN_ON(role > USB_ROLE_DEVICE)) in cdns_role_stop()
62 if (cdns->roles[role]->state == CDNS_ROLE_STATE_INACTIVE) in cdns_role_stop()
66 cdns->roles[role]->stop(cdns); in cdns_role_stop()
67 cdns->roles[role]->state = CDNS_ROLE_STATE_INACTIVE; in cdns_role_stop()
78 * cdns_core_init_role - initialize role of operation
91 cdns->role = USB_ROLE_NONE; in cdns_core_init_role()
174 /* Initialize idle role to start with */ in cdns_core_init_role()
207 * cdns_hw_role_state_machine - role switch state machine based on hw events.
210 * Returns next role to be entered based on hw events.
214 enum usb_role role = USB_ROLE_NONE; in cdns_hw_role_state_machine() local
219 role = USB_ROLE_HOST; in cdns_hw_role_state_machine()
221 role = USB_ROLE_DEVICE; in cdns_hw_role_state_machine()
223 return role; in cdns_hw_role_state_machine()
230 * Role change state machine in cdns_hw_role_state_machine()
232 * Previous state: cdns->role in cdns_hw_role_state_machine()
233 * Next state: role in cdns_hw_role_state_machine()
235 role = cdns->role; in cdns_hw_role_state_machine()
237 switch (role) { in cdns_hw_role_state_machine()
244 role = USB_ROLE_HOST; in cdns_hw_role_state_machine()
246 role = USB_ROLE_DEVICE; in cdns_hw_role_state_machine()
250 role = USB_ROLE_NONE; in cdns_hw_role_state_machine()
254 role = USB_ROLE_NONE; in cdns_hw_role_state_machine()
258 dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role); in cdns_hw_role_state_machine()
260 return role; in cdns_hw_role_state_machine()
303 /* Depends on role switch class */ in cdns_hw_role_switch()
309 current_role = cdns->role; in cdns_hw_role_switch()
318 dev_dbg(cdns->dev, "Switching role %d -> %d", current_role, real_role); in cdns_hw_role_switch()
322 /* Back to current role */ in cdns_hw_role_switch()
336 * cdns_role_get - get current role of controller.
338 * @sw: pointer to USB role switch structure
340 * Returns role
346 return cdns->role; in cdns_role_get()
350 * cdns_role_set - set current role of controller.
352 * @sw: pointer to USB role switch structure
353 * @role: the previous role
355 * - Role switch for dual-role devices
358 static int cdns_role_set(struct usb_role_switch *sw, enum usb_role role) in cdns_role_set() argument
365 if (cdns->role == role) in cdns_role_set()
369 switch (role) { in cdns_role_set()
379 switch (role) { in cdns_role_set()
389 ret = cdns_role_start(cdns, role); in cdns_role_set()
391 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()
533 cdns->role = cdns_role_get(cdns->role_sw); in cdns_resume()
536 if (real_role != cdns->role) { in cdns_resume()
545 if (cdns->role == USB_ROLE_HOST) in cdns_resume()
547 else if (cdns->role == USB_ROLE_DEVICE) in cdns_resume()
555 if (cdns->roles[cdns->role]->resume) in cdns_resume()
556 cdns->roles[cdns->role]->resume(cdns, cdns_power_is_lost(cdns)); in cdns_resume()