usb: chipidea: add role switch class support
USB role is fully controlled by usb role switch consumer(e.g. typec), usb port can be at host mode(USB_ROLE_HOST), device mode connected to host(USB_ROLE_DEVICE), or not connecting any partner(USB_ROLE_NONE). Signed-off-by: Li Jun <jun.li@nxp.com> Signed-off-by: Peter Chen <peter.chen@nxp.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <linux/usb/gadget.h>
|
||||
#include <linux/usb/otg-fsm.h>
|
||||
#include <linux/usb/otg.h>
|
||||
#include <linux/usb/role.h>
|
||||
#include <linux/ulpi/interface.h>
|
||||
|
||||
/******************************************************************************
|
||||
@@ -217,6 +218,7 @@ struct ci_hdrc {
|
||||
ktime_t hr_timeouts[NUM_OTG_FSM_TIMERS];
|
||||
unsigned enabled_otg_timer_bits;
|
||||
enum otg_fsm_timer next_otg_timer;
|
||||
struct usb_role_switch *role_switch;
|
||||
struct work_struct work;
|
||||
struct workqueue_struct *wq;
|
||||
|
||||
@@ -290,6 +292,16 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
|
||||
ci->roles[role]->stop(ci);
|
||||
}
|
||||
|
||||
static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)
|
||||
{
|
||||
if (ci->role == CI_ROLE_HOST)
|
||||
return USB_ROLE_HOST;
|
||||
else if (ci->role == CI_ROLE_GADGET && ci->vbus_active)
|
||||
return USB_ROLE_DEVICE;
|
||||
else
|
||||
return USB_ROLE_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* hw_read_id_reg: reads from a identification register
|
||||
* @ci: the controller
|
||||
|
Reference in New Issue
Block a user