1
0
Fork 0

MLK-18922-2 usb: dwc3: add OTG capabilities handling

During the USB certification CV9 test, if we report OTG descriptor
to test suite, it will require doing OTG test, but in fact, it does
not support OTG-compliance in dwc3 driver.

For one Image configuration, it may choose CONFIG_USB_OTG, in order to
skip OTG descriptor, we need to set gadget->is_otg as false for
non OTG-compliance hardware. Due to dwc3 IP supports OTG-compliance,
the user can add "hnp-disable", "srp-disable" and "adp-disable"
at firmware to disable OTG features (skip OTG descriptor). This
patch does NOT affect current configuration descriptors.

Acked-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
pull/10/head
Peter Chen 2018-07-16 17:12:58 +08:00 committed by Jason Liu
parent c18f3affe7
commit 0fc059ab3d
3 changed files with 20 additions and 1 deletions

View File

@ -1256,6 +1256,19 @@ static int dwc3_probe(struct platform_device *pdev)
dwc3_get_properties(dwc);
if (dwc->dr_mode == USB_DR_MODE_OTG) {
dwc->otg_caps.otg_rev = 0x0300;
dwc->otg_caps.hnp_support = true;
dwc->otg_caps.srp_support = true;
dwc->otg_caps.adp_support = true;
/* Update otg capabilities by DT properties */
ret = of_usb_update_otg_caps(dev->of_node,
&dwc->otg_caps);
if (ret)
goto err0;
}
platform_set_drvdata(pdev, dwc);
dwc3_cache_hwparams(dwc);

View File

@ -872,6 +872,7 @@ struct dwc3_scratchpad_array {
* 3 - Reserved
* @imod_interval: set the interrupt moderation interval in 250ns
* increments or 0 to disable.
* @otg_caps: the OTG capabilities from hardware point
*/
struct dwc3 {
struct work_struct drd_work;
@ -1027,6 +1028,8 @@ struct dwc3 {
unsigned tx_de_emphasis:2;
u16 imod_interval;
struct usb_otg_caps otg_caps;
};
#define work_to_dwc(w) (container_of((w), struct dwc3, drd_work))

View File

@ -3251,7 +3251,10 @@ int dwc3_gadget_init(struct dwc3 *dwc)
dwc->gadget.speed = USB_SPEED_UNKNOWN;
dwc->gadget.sg_supported = true;
dwc->gadget.name = "dwc3-gadget";
dwc->gadget.is_otg = dwc->dr_mode == USB_DR_MODE_OTG;
dwc->gadget.is_otg = (dwc->dr_mode == USB_DR_MODE_OTG) &&
(dwc->otg_caps.hnp_support ||
dwc->otg_caps.srp_support ||
dwc->otg_caps.adp_support);
/*
* FIXME We might be setting max_speed to <SUPER, however versions