820-usb-0005-usb-dwc3-add-otg-properties-update.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 504c440dd9c391ed97299a9d4b2e41b3ac3b6211 Mon Sep 17 00:00:00 2001
  2. From: Peter Chen <[email protected]>
  3. Date: Mon, 28 Jan 2019 15:15:11 +0800
  4. Subject: [PATCH] usb: dwc3: add otg properties update
  5. During the USB certification CV9 test, if we report OTG descriptor
  6. to test suite, it will require doing OTG test, but in fact, it does
  7. not support OTG-compliance in dwc3 driver.
  8. Signed-off-by: Peter Chen <[email protected]>
  9. ---
  10. drivers/usb/dwc3/core.c | 11 +++++++++++
  11. drivers/usb/dwc3/core.h | 2 ++
  12. drivers/usb/dwc3/gadget.c | 4 ++++
  13. 3 files changed, 17 insertions(+)
  14. --- a/drivers/usb/dwc3/core.c
  15. +++ b/drivers/usb/dwc3/core.c
  16. @@ -1269,6 +1269,17 @@ static void dwc3_get_properties(struct d
  17. dwc->maximum_speed = usb_get_maximum_speed(dev);
  18. dwc->dr_mode = usb_get_dr_mode(dev);
  19. + if (dwc->dr_mode == USB_DR_MODE_OTG) {
  20. + dwc->otg_caps.otg_rev = 0x0300;
  21. + dwc->otg_caps.hnp_support = true;
  22. + dwc->otg_caps.srp_support = true;
  23. + dwc->otg_caps.adp_support = true;
  24. +
  25. + /* Update otg capabilities by DT properties */
  26. + of_usb_update_otg_caps(dev->of_node,
  27. + &dwc->otg_caps);
  28. + }
  29. +
  30. dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node);
  31. dwc->sysdev_is_parent = device_property_read_bool(dev,
  32. --- a/drivers/usb/dwc3/core.h
  33. +++ b/drivers/usb/dwc3/core.h
  34. @@ -953,6 +953,7 @@ struct dwc3_scratchpad_array {
  35. * @nr_scratch: number of scratch buffers
  36. * @u1u2: only used on revisions <1.83a for workaround
  37. * @maximum_speed: maximum speed requested (mainly for testing purposes)
  38. + * @otg_caps: the OTG capabilities from hardware point
  39. * @revision: revision register contents
  40. * @version_type: VERSIONTYPE register contents, a sub release of a revision
  41. * @dr_mode: requested mode of operation
  42. @@ -1109,6 +1110,7 @@ struct dwc3 {
  43. u32 nr_scratch;
  44. u32 u1u2;
  45. u32 maximum_speed;
  46. + struct usb_otg_caps otg_caps;
  47. /*
  48. * All 3.1 IP version constants are greater than the 3.0 IP
  49. --- a/drivers/usb/dwc3/gadget.c
  50. +++ b/drivers/usb/dwc3/gadget.c
  51. @@ -3495,6 +3495,10 @@ int dwc3_gadget_init(struct dwc3 *dwc)
  52. dwc->gadget.sg_supported = true;
  53. dwc->gadget.name = "dwc3-gadget";
  54. dwc->gadget.lpm_capable = true;
  55. + dwc->gadget.is_otg = (dwc->dr_mode == USB_DR_MODE_OTG) &&
  56. + (dwc->otg_caps.hnp_support ||
  57. + dwc->otg_caps.srp_support ||
  58. + dwc->otg_caps.adp_support);
  59. /*
  60. * FIXME We might be setting max_speed to <SUPER, however versions