diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-21 11:50:59 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-21 12:08:19 +0100 |
commit | fd716ce4e8c909545eac5dd254b82a8081b02c28 (patch) | |
tree | 4f54a28de7136b73303c1f8f7238c6069b6f53e3 | |
parent | a2a05df5c5c45dce786b23d22700befddd0439ea (diff) | |
download | barebox-fd716ce4e8c909545eac5dd254b82a8081b02c28.tar.gz barebox-fd716ce4e8c909545eac5dd254b82a8081b02c28.tar.xz |
usb: dwc3: register otg device
When the role in the device tree is specified as "otg" then register
a otg device in barebox so that the user can configure the desired mode.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/usb/dwc3/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.c | 14 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.h | 1 |
3 files changed, 12 insertions, 4 deletions
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 09da121374..2eb8e9c85a 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -2,6 +2,7 @@ config USB_DWC3 tristate "DesignWare USB3 DRD Core Support" depends on USB && HAS_DMA select USB_XHCI + select USB_OTGDEV help Say Y or M here if your system has a Dual Role SuperSpeed USB controller based on the DesignWare USB3 IP Core. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index ad84708da2..04b700d12d 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -936,12 +936,13 @@ static int dwc3_core_get_phy(struct dwc3 *dwc) return 0; } -static int dwc3_core_init_mode(struct dwc3 *dwc) +static int dwc3_set_mode(void *ctx, enum usb_dr_mode mode) { + struct dwc3 *dwc = ctx; struct device_d *dev = dwc->dev; int ret; - switch (dwc->dr_mode) { + switch (mode) { case USB_DR_MODE_PERIPHERAL: dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); @@ -963,13 +964,20 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) } break; default: - dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); return -EINVAL; } return 0; } +static int dwc3_core_init_mode(struct dwc3 *dwc) +{ + if (dwc->dr_mode == USB_DR_MODE_OTG) + return usb_register_otg_device(dwc->dev, dwc3_set_mode, dwc); + else + return dwc3_set_mode(dwc, dwc->dr_mode); +} + static void dwc3_get_properties(struct dwc3 *dwc) { struct device_d *dev = dwc->dev; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index df0a188a63..f2f7a311d1 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1336,7 +1336,6 @@ struct dwc3_gadget_ep_cmd_params { /* prototypes */ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc); void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode); -void dwc3_set_mode(struct dwc3 *dwc, u32 mode); /* check whether we are on the DWC_usb3 core */ static inline bool dwc3_is_usb3(struct dwc3 *dwc) |