kernel: update 4.4 kernel to 4.4.42
[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 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
29 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
30 @@ -14,7 +14,6 @@ Optional properties:
31 the second element is expected to be a handle to the USB3/SS PHY
32 - phys: from the *Generic PHY* bindings
33 - phy-names: from the *Generic PHY* bindings
34 - - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
35 - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable
36 - snps,disable_scramble_quirk: true when SW should disable data scrambling.
37 Only really useful for FPGA builds.
38 @@ -47,6 +46,8 @@ Optional properties:
39 register for post-silicon frame length adjustment when the
40 fladj_30mhz_sdbnd signal is invalid or incorrect.
41
42 + - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
43 +
44 This is usually a subnode to DWC3 glue to which it is connected.
45
46 dwc3@4a030000 {
47 @@ -54,5 +55,4 @@ dwc3@4a030000 {
48 reg = <0x4a030000 0xcfff>;
49 interrupts = <0 92 4>
50 usb-phy = <&usb2_phy>, <&usb3,phy>;
51 - tx-fifo-resize;
52 };
53 --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
54 +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
55 @@ -59,7 +59,6 @@ Example device nodes:
56 interrupts = <0 205 0x4>;
57 phys = <&hs_phy>, <&ss_phy>;
58 phy-names = "usb2-phy", "usb3-phy";
59 - tx-fifo-resize;
60 dr_mode = "host";
61 };
62 };
63 --- a/drivers/usb/dwc3/core.c
64 +++ b/drivers/usb/dwc3/core.c
65 @@ -882,9 +882,6 @@ static int dwc3_probe(struct platform_de
66 dwc->usb3_lpm_capable = device_property_read_bool(dev,
67 "snps,usb3_lpm_capable");
68
69 - dwc->needs_fifo_resize = device_property_read_bool(dev,
70 - "tx-fifo-resize");
71 -
72 dwc->disable_scramble_quirk = device_property_read_bool(dev,
73 "snps,disable_scramble_quirk");
74 dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
75 @@ -926,7 +923,6 @@ static int dwc3_probe(struct platform_de
76 if (pdata->hird_threshold)
77 hird_threshold = pdata->hird_threshold;
78
79 - dwc->needs_fifo_resize = pdata->tx_fifo_resize;
80 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
81 dwc->dr_mode = pdata->dr_mode;
82
83 --- a/drivers/usb/dwc3/core.h
84 +++ b/drivers/usb/dwc3/core.h
85 @@ -705,9 +705,7 @@ struct dwc3_scratchpad_array {
86 * 0 - utmi_sleep_n
87 * 1 - utmi_l1_suspend_n
88 * @is_fpga: true when we are using the FPGA board
89 - * @needs_fifo_resize: not all users might want fifo resizing, flag it
90 * @pullups_connected: true when Run/Stop bit is set
91 - * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes.
92 * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround
93 * @start_config_issued: true when StartConfig command has been issued
94 * @three_stage_setup: set if we perform a three phase setup
95 @@ -850,9 +848,7 @@ struct dwc3 {
96 unsigned has_lpm_erratum:1;
97 unsigned is_utmi_l1_suspend:1;
98 unsigned is_fpga:1;
99 - unsigned needs_fifo_resize:1;
100 unsigned pullups_connected:1;
101 - unsigned resize_fifos:1;
102 unsigned setup_packet_pending:1;
103 unsigned three_stage_setup:1;
104 unsigned usb3_lpm_capable:1;
105 @@ -1020,7 +1016,6 @@ struct dwc3_gadget_ep_cmd_params {
106
107 /* prototypes */
108 void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
109 -int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
110
111 /* check whether we are on the DWC_usb31 core */
112 static inline bool dwc3_is_usb31(struct dwc3 *dwc)
113 --- a/drivers/usb/dwc3/ep0.c
114 +++ b/drivers/usb/dwc3/ep0.c
115 @@ -587,9 +587,6 @@ static int dwc3_ep0_set_config(struct dw
116 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
117 reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA);
118 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
119 -
120 - dwc->resize_fifos = true;
121 - dwc3_trace(trace_dwc3_ep0, "resize FIFOs flag SET");
122 }
123 break;
124
125 @@ -1028,12 +1025,6 @@ static int dwc3_ep0_start_control_status
126
127 static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
128 {
129 - if (dwc->resize_fifos) {
130 - dwc3_trace(trace_dwc3_ep0, "Resizing FIFOs");
131 - dwc3_gadget_resize_tx_fifos(dwc);
132 - dwc->resize_fifos = 0;
133 - }
134 -
135 WARN_ON(dwc3_ep0_start_control_status(dep));
136 }
137
138 --- a/drivers/usb/dwc3/gadget.c
139 +++ b/drivers/usb/dwc3/gadget.c
140 @@ -145,92 +145,6 @@ int dwc3_gadget_set_link_state(struct dw
141 return -ETIMEDOUT;
142 }
143
144 -/**
145 - * dwc3_gadget_resize_tx_fifos - reallocate fifo spaces for current use-case
146 - * @dwc: pointer to our context structure
147 - *
148 - * This function will a best effort FIFO allocation in order
149 - * to improve FIFO usage and throughput, while still allowing
150 - * us to enable as many endpoints as possible.
151 - *
152 - * Keep in mind that this operation will be highly dependent
153 - * on the configured size for RAM1 - which contains TxFifo -,
154 - * the amount of endpoints enabled on coreConsultant tool, and
155 - * the width of the Master Bus.
156 - *
157 - * In the ideal world, we would always be able to satisfy the
158 - * following equation:
159 - *
160 - * ((512 + 2 * MDWIDTH-Bytes) + (Number of IN Endpoints - 1) * \
161 - * (3 * (1024 + MDWIDTH-Bytes) + MDWIDTH-Bytes)) / MDWIDTH-Bytes
162 - *
163 - * Unfortunately, due to many variables that's not always the case.
164 - */
165 -int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
166 -{
167 - int last_fifo_depth = 0;
168 - int ram1_depth;
169 - int fifo_size;
170 - int mdwidth;
171 - int num;
172 -
173 - if (!dwc->needs_fifo_resize)
174 - return 0;
175 -
176 - ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7);
177 - mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
178 -
179 - /* MDWIDTH is represented in bits, we need it in bytes */
180 - mdwidth >>= 3;
181 -
182 - /*
183 - * FIXME For now we will only allocate 1 wMaxPacketSize space
184 - * for each enabled endpoint, later patches will come to
185 - * improve this algorithm so that we better use the internal
186 - * FIFO space
187 - */
188 - for (num = 0; num < dwc->num_in_eps; num++) {
189 - /* bit0 indicates direction; 1 means IN ep */
190 - struct dwc3_ep *dep = dwc->eps[(num << 1) | 1];
191 - int mult = 1;
192 - int tmp;
193 -
194 - if (!(dep->flags & DWC3_EP_ENABLED))
195 - continue;
196 -
197 - if (usb_endpoint_xfer_bulk(dep->endpoint.desc)
198 - || usb_endpoint_xfer_isoc(dep->endpoint.desc))
199 - mult = 3;
200 -
201 - /*
202 - * REVISIT: the following assumes we will always have enough
203 - * space available on the FIFO RAM for all possible use cases.
204 - * Make sure that's true somehow and change FIFO allocation
205 - * accordingly.
206 - *
207 - * If we have Bulk or Isochronous endpoints, we want
208 - * them to be able to be very, very fast. So we're giving
209 - * those endpoints a fifo_size which is enough for 3 full
210 - * packets
211 - */
212 - tmp = mult * (dep->endpoint.maxpacket + mdwidth);
213 - tmp += mdwidth;
214 -
215 - fifo_size = DIV_ROUND_UP(tmp, mdwidth);
216 -
217 - fifo_size |= (last_fifo_depth << 16);
218 -
219 - dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d",
220 - dep->name, last_fifo_depth, fifo_size & 0xffff);
221 -
222 - dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size);
223 -
224 - last_fifo_depth += (fifo_size & 0xffff);
225 - }
226 -
227 - return 0;
228 -}
229 -
230 void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
231 int status)
232 {
233 --- a/drivers/usb/dwc3/platform_data.h
234 +++ b/drivers/usb/dwc3/platform_data.h
235 @@ -23,7 +23,6 @@
236 struct dwc3_platform_data {
237 enum usb_device_speed maximum_speed;
238 enum usb_dr_mode dr_mode;
239 - bool tx_fifo_resize;
240 bool usb3_lpm_capable;
241
242 unsigned is_utmi_l1_suspend:1;