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