9b6026d9141ca77f9665b93fc3fcd32c547ef344
[openwrt/staging/yousong.git] / target / linux / ipq806x / patches-4.4 / 096-07-usb-dwc3-drop-FIFO-resizing-logic.patch
1 From bc5081617faeb3b2f0c126dc37264b87af7da47f Mon Sep 17 00:00:00 2001
2 From: Felipe Balbi <felipe.balbi@linux.intel.com>
3 Date: Thu, 4 Feb 2016 14:18:01 +0200
4 Subject: usb: dwc3: drop FIFO resizing logic
5
6 That FIFO resizing logic was added to support OMAP5
7 ES1.0 which had a bogus default FIFO size. I can't
8 remember the exact size of default FIFO, but it was
9 less than one bulk superspeed packet (<1024) which
10 would prevent USB3 from ever working on OMAP5 ES1.0.
11
12 However, OMAP5 ES1.0 support has been dropped by
13 commit aa2f4b16f830 ("ARM: OMAP5: id: Remove ES1.0
14 support") which renders FIFO resizing unnecessary.
15
16 Tested-by: Kishon Vijay Abraham I <kishon@ti.com>
17 Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
18 ---
19 Documentation/devicetree/bindings/usb/dwc3.txt | 4 +-
20 .../devicetree/bindings/usb/qcom,dwc3.txt | 1 -
21 drivers/usb/dwc3/core.c | 4 -
22 drivers/usb/dwc3/core.h | 5 --
23 drivers/usb/dwc3/ep0.c | 9 ---
24 drivers/usb/dwc3/gadget.c | 86 ----------------------
25 drivers/usb/dwc3/platform_data.h | 1 -
26 7 files changed, 2 insertions(+), 108 deletions(-)
27
28 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
29 index fb2ad0a..1569568 100644
30 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
31 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
32 @@ -14,7 +14,6 @@ Optional properties:
33 the second element is expected to be a handle to the USB3/SS PHY
34 - phys: from the *Generic PHY* bindings
35 - phy-names: from the *Generic PHY* bindings
36 - - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
37 - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable
38 - snps,disable_scramble_quirk: true when SW should disable data scrambling.
39 Only really useful for FPGA builds.
40 @@ -47,6 +46,8 @@ Optional properties:
41 register for post-silicon frame length adjustment when the
42 fladj_30mhz_sdbnd signal is invalid or incorrect.
43
44 + - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
45 +
46 This is usually a subnode to DWC3 glue to which it is connected.
47
48 dwc3@4a030000 {
49 @@ -54,5 +55,4 @@ dwc3@4a030000 {
50 reg = <0x4a030000 0xcfff>;
51 interrupts = <0 92 4>
52 usb-phy = <&usb2_phy>, <&usb3,phy>;
53 - tx-fifo-resize;
54 };
55 diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
56 index ca164e7..39acb08 100644
57 --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
58 +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
59 @@ -59,7 +59,6 @@ Example device nodes:
60 interrupts = <0 205 0x4>;
61 phys = <&hs_phy>, <&ss_phy>;
62 phy-names = "usb2-phy", "usb3-phy";
63 - tx-fifo-resize;
64 dr_mode = "host";
65 };
66 };
67 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
68 index fa20f5a9..67d183a 100644
69 --- a/drivers/usb/dwc3/core.c
70 +++ b/drivers/usb/dwc3/core.c
71 @@ -882,9 +882,6 @@ static int dwc3_probe(struct platform_device *pdev)
72 dwc->usb3_lpm_capable = device_property_read_bool(dev,
73 "snps,usb3_lpm_capable");
74
75 - dwc->needs_fifo_resize = device_property_read_bool(dev,
76 - "tx-fifo-resize");
77 -
78 dwc->disable_scramble_quirk = device_property_read_bool(dev,
79 "snps,disable_scramble_quirk");
80 dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
81 @@ -926,7 +923,6 @@ static int dwc3_probe(struct platform_device *pdev)
82 if (pdata->hird_threshold)
83 hird_threshold = pdata->hird_threshold;
84
85 - dwc->needs_fifo_resize = pdata->tx_fifo_resize;
86 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
87 dwc->dr_mode = pdata->dr_mode;
88
89 diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
90 index 6254b2f..7cbe9e9 100644
91 --- a/drivers/usb/dwc3/core.h
92 +++ b/drivers/usb/dwc3/core.h
93 @@ -709,9 +709,7 @@ struct dwc3_scratchpad_array {
94 * 0 - utmi_sleep_n
95 * 1 - utmi_l1_suspend_n
96 * @is_fpga: true when we are using the FPGA board
97 - * @needs_fifo_resize: not all users might want fifo resizing, flag it
98 * @pullups_connected: true when Run/Stop bit is set
99 - * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes.
100 * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround
101 * @start_config_issued: true when StartConfig command has been issued
102 * @three_stage_setup: set if we perform a three phase setup
103 @@ -855,9 +853,7 @@ struct dwc3 {
104 unsigned has_lpm_erratum:1;
105 unsigned is_utmi_l1_suspend:1;
106 unsigned is_fpga:1;
107 - unsigned needs_fifo_resize:1;
108 unsigned pullups_connected:1;
109 - unsigned resize_fifos:1;
110 unsigned setup_packet_pending:1;
111 unsigned three_stage_setup:1;
112 unsigned usb3_lpm_capable:1;
113 @@ -1025,7 +1021,6 @@ struct dwc3_gadget_ep_cmd_params {
114
115 /* prototypes */
116 void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
117 -int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
118
119 /* check whether we are on the DWC_usb31 core */
120 static inline bool dwc3_is_usb31(struct dwc3 *dwc)
121 diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
122 index eca2e6d..4454de0 100644
123 --- a/drivers/usb/dwc3/ep0.c
124 +++ b/drivers/usb/dwc3/ep0.c
125 @@ -586,9 +586,6 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
126 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
127 reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA);
128 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
129 -
130 - dwc->resize_fifos = true;
131 - dwc3_trace(trace_dwc3_ep0, "resize FIFOs flag SET");
132 }
133 break;
134
135 @@ -1027,12 +1024,6 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
136
137 static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
138 {
139 - if (dwc->resize_fifos) {
140 - dwc3_trace(trace_dwc3_ep0, "Resizing FIFOs");
141 - dwc3_gadget_resize_tx_fifos(dwc);
142 - dwc->resize_fifos = 0;
143 - }
144 -
145 WARN_ON(dwc3_ep0_start_control_status(dep));
146 }
147
148 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
149 index d54a028..3a5c271 100644
150 --- a/drivers/usb/dwc3/gadget.c
151 +++ b/drivers/usb/dwc3/gadget.c
152 @@ -145,92 +145,6 @@ int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state)
153 return -ETIMEDOUT;
154 }
155
156 -/**
157 - * dwc3_gadget_resize_tx_fifos - reallocate fifo spaces for current use-case
158 - * @dwc: pointer to our context structure
159 - *
160 - * This function will a best effort FIFO allocation in order
161 - * to improve FIFO usage and throughput, while still allowing
162 - * us to enable as many endpoints as possible.
163 - *
164 - * Keep in mind that this operation will be highly dependent
165 - * on the configured size for RAM1 - which contains TxFifo -,
166 - * the amount of endpoints enabled on coreConsultant tool, and
167 - * the width of the Master Bus.
168 - *
169 - * In the ideal world, we would always be able to satisfy the
170 - * following equation:
171 - *
172 - * ((512 + 2 * MDWIDTH-Bytes) + (Number of IN Endpoints - 1) * \
173 - * (3 * (1024 + MDWIDTH-Bytes) + MDWIDTH-Bytes)) / MDWIDTH-Bytes
174 - *
175 - * Unfortunately, due to many variables that's not always the case.
176 - */
177 -int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
178 -{
179 - int last_fifo_depth = 0;
180 - int ram1_depth;
181 - int fifo_size;
182 - int mdwidth;
183 - int num;
184 -
185 - if (!dwc->needs_fifo_resize)
186 - return 0;
187 -
188 - ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7);
189 - mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
190 -
191 - /* MDWIDTH is represented in bits, we need it in bytes */
192 - mdwidth >>= 3;
193 -
194 - /*
195 - * FIXME For now we will only allocate 1 wMaxPacketSize space
196 - * for each enabled endpoint, later patches will come to
197 - * improve this algorithm so that we better use the internal
198 - * FIFO space
199 - */
200 - for (num = 0; num < dwc->num_in_eps; num++) {
201 - /* bit0 indicates direction; 1 means IN ep */
202 - struct dwc3_ep *dep = dwc->eps[(num << 1) | 1];
203 - int mult = 1;
204 - int tmp;
205 -
206 - if (!(dep->flags & DWC3_EP_ENABLED))
207 - continue;
208 -
209 - if (usb_endpoint_xfer_bulk(dep->endpoint.desc)
210 - || usb_endpoint_xfer_isoc(dep->endpoint.desc))
211 - mult = 3;
212 -
213 - /*
214 - * REVISIT: the following assumes we will always have enough
215 - * space available on the FIFO RAM for all possible use cases.
216 - * Make sure that's true somehow and change FIFO allocation
217 - * accordingly.
218 - *
219 - * If we have Bulk or Isochronous endpoints, we want
220 - * them to be able to be very, very fast. So we're giving
221 - * those endpoints a fifo_size which is enough for 3 full
222 - * packets
223 - */
224 - tmp = mult * (dep->endpoint.maxpacket + mdwidth);
225 - tmp += mdwidth;
226 -
227 - fifo_size = DIV_ROUND_UP(tmp, mdwidth);
228 -
229 - fifo_size |= (last_fifo_depth << 16);
230 -
231 - dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d",
232 - dep->name, last_fifo_depth, fifo_size & 0xffff);
233 -
234 - dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size);
235 -
236 - last_fifo_depth += (fifo_size & 0xffff);
237 - }
238 -
239 - return 0;
240 -}
241 -
242 void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
243 int status)
244 {
245 diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
246 index 2bb4d3a..aaa6f00 100644
247 --- a/drivers/usb/dwc3/platform_data.h
248 +++ b/drivers/usb/dwc3/platform_data.h
249 @@ -23,7 +23,6 @@
250 struct dwc3_platform_data {
251 enum usb_device_speed maximum_speed;
252 enum usb_dr_mode dr_mode;
253 - bool tx_fifo_resize;
254 bool usb3_lpm_capable;
255
256 unsigned is_utmi_l1_suspend:1;
257 --
258 cgit v0.12