Merge tag 'v3.10.108' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / usb / renesas_usbhs / fifo.c
CommitLineData
e8d548d5
KM
1/*
2 * Renesas USB driver
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */
17#include <linux/delay.h>
18#include <linux/io.h>
9c646cfc 19#include <linux/scatterlist.h>
cc502bb7
PB
20#include "common.h"
21#include "pipe.h"
e8d548d5 22
d3af90a5 23#define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo))
e73a9891
KM
24#define usbhsf_get_d0fifo(p) (&((p)->fifo_info.d0fifo))
25#define usbhsf_get_d1fifo(p) (&((p)->fifo_info.d1fifo))
5ea43994 26#define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f)
d3af90a5 27
d77e3f4e
KM
28#define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */
29
4bd04811 30/*
233f519d
KM
31 * packet initialize
32 */
33void usbhs_pkt_init(struct usbhs_pkt *pkt)
34{
233f519d
KM
35 INIT_LIST_HEAD(&pkt->node);
36}
37
38/*
39 * packet control function
4bd04811 40 */
97664a20 41static int usbhsf_null_handle(struct usbhs_pkt *pkt, int *is_done)
dad67397
KM
42{
43 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe);
44 struct device *dev = usbhs_priv_to_dev(priv);
45
46 dev_err(dev, "null handler\n");
47
48 return -EINVAL;
49}
50
51static struct usbhs_pkt_handle usbhsf_null_handler = {
52 .prepare = usbhsf_null_handle,
53 .try_run = usbhsf_null_handle,
54};
55
659d4954 56void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
b331872b
KM
57 void (*done)(struct usbhs_priv *priv,
58 struct usbhs_pkt *pkt),
3edeee38 59 void *buf, int len, int zero, int sequence)
6acb95d4 60{
dad67397
KM
61 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
62 struct device *dev = usbhs_priv_to_dev(priv);
97664a20
KM
63 unsigned long flags;
64
b331872b
KM
65 if (!done) {
66 dev_err(dev, "no done function\n");
67 return;
68 }
69
a2c76b83
KM
70 /******************** spin lock ********************/
71 usbhs_lock(priv, flags);
72
0c6ef985 73 if (!pipe->handler) {
dad67397 74 dev_err(dev, "no handler function\n");
0c6ef985 75 pipe->handler = &usbhsf_null_handler;
dad67397
KM
76 }
77
d5261286 78 list_move_tail(&pkt->node, &pipe->list);
6acb95d4 79
0c6ef985
KM
80 /*
81 * each pkt must hold own handler.
82 * because handler might be changed by its situation.
83 * dma handler -> pio handler.
84 */
659d4954
KM
85 pkt->pipe = pipe;
86 pkt->buf = buf;
0c6ef985 87 pkt->handler = pipe->handler;
659d4954
KM
88 pkt->length = len;
89 pkt->zero = zero;
90 pkt->actual = 0;
b331872b 91 pkt->done = done;
3edeee38 92 pkt->sequence = sequence;
97664a20
KM
93
94 usbhs_unlock(priv, flags);
95 /******************** spin unlock ******************/
6acb95d4
KM
96}
97
97664a20 98static void __usbhsf_pkt_del(struct usbhs_pkt *pkt)
6acb95d4
KM
99{
100 list_del_init(&pkt->node);
101}
102
97664a20 103static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
6acb95d4
KM
104{
105 if (list_empty(&pipe->list))
106 return NULL;
107
d5261286 108 return list_first_entry(&pipe->list, struct usbhs_pkt, node);
6acb95d4
KM
109}
110
97664a20
KM
111struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt)
112{
113 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
114 unsigned long flags;
115
116 /******************** spin lock ********************/
117 usbhs_lock(priv, flags);
118
119 if (!pkt)
120 pkt = __usbhsf_pkt_get(pipe);
121
122 if (pkt)
123 __usbhsf_pkt_del(pkt);
124
125 usbhs_unlock(priv, flags);
126 /******************** spin unlock ******************/
127
128 return pkt;
129}
130
51b8a021
KM
131enum {
132 USBHSF_PKT_PREPARE,
133 USBHSF_PKT_TRY_RUN,
134 USBHSF_PKT_DMA_DONE,
135};
136
137static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type)
97664a20
KM
138{
139 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
97664a20
KM
140 struct usbhs_pkt *pkt;
141 struct device *dev = usbhs_priv_to_dev(priv);
142 int (*func)(struct usbhs_pkt *pkt, int *is_done);
143 unsigned long flags;
144 int ret = 0;
145 int is_done = 0;
146
147 /******************** spin lock ********************/
148 usbhs_lock(priv, flags);
149
150 pkt = __usbhsf_pkt_get(pipe);
151 if (!pkt)
152 goto __usbhs_pkt_handler_end;
153
154 switch (type) {
155 case USBHSF_PKT_PREPARE:
156 func = pkt->handler->prepare;
157 break;
158 case USBHSF_PKT_TRY_RUN:
159 func = pkt->handler->try_run;
160 break;
e73a9891
KM
161 case USBHSF_PKT_DMA_DONE:
162 func = pkt->handler->dma_done;
163 break;
97664a20 164 default:
984e833c 165 dev_err(dev, "unknown pkt handler\n");
97664a20
KM
166 goto __usbhs_pkt_handler_end;
167 }
168
5a6df60e
YS
169 if (likely(func))
170 ret = func(pkt, &is_done);
97664a20
KM
171
172 if (is_done)
173 __usbhsf_pkt_del(pkt);
174
175__usbhs_pkt_handler_end:
176 usbhs_unlock(priv, flags);
177 /******************** spin unlock ******************/
178
0432eed0 179 if (is_done) {
b331872b 180 pkt->done(priv, pkt);
0432eed0
KM
181 usbhs_pkt_start(pipe);
182 }
97664a20
KM
183
184 return ret;
185}
186
51b8a021
KM
187void usbhs_pkt_start(struct usbhs_pipe *pipe)
188{
189 usbhsf_pkt_handler(pipe, USBHSF_PKT_PREPARE);
190}
191
659d4954
KM
192/*
193 * irq enable/disable function
194 */
3192fcb2
KM
195#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_bempsts, e)
196#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_brdysts, e)
659d4954
KM
197#define usbhsf_irq_callback_ctrl(pipe, status, enable) \
198 ({ \
199 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \
200 struct usbhs_mod *mod = usbhs_mod_get_current(priv); \
201 u16 status = (1 << usbhs_pipe_number(pipe)); \
202 if (!mod) \
203 return; \
204 if (enable) \
3192fcb2 205 mod->status |= status; \
659d4954 206 else \
3192fcb2 207 mod->status &= ~status; \
659d4954
KM
208 usbhs_irq_callback_update(priv, mod); \
209 })
210
211static void usbhsf_tx_irq_ctrl(struct usbhs_pipe *pipe, int enable)
212{
213 /*
214 * And DCP pipe can NOT use "ready interrupt" for "send"
215 * it should use "empty" interrupt.
216 * see
217 * "Operation" - "Interrupt Function" - "BRDY Interrupt"
218 *
219 * on the other hand, normal pipe can use "ready interrupt" for "send"
220 * even though it is single/double buffer
221 */
222 if (usbhs_pipe_is_dcp(pipe))
223 usbhsf_irq_empty_ctrl(pipe, enable);
224 else
225 usbhsf_irq_ready_ctrl(pipe, enable);
226}
227
228static void usbhsf_rx_irq_ctrl(struct usbhs_pipe *pipe, int enable)
229{
230 usbhsf_irq_ready_ctrl(pipe, enable);
231}
232
e8d548d5
KM
233/*
234 * FIFO ctrl
235 */
d3af90a5
KM
236static void usbhsf_send_terminator(struct usbhs_pipe *pipe,
237 struct usbhs_fifo *fifo)
e8d548d5
KM
238{
239 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
240
d3af90a5 241 usbhs_bset(priv, fifo->ctr, BVAL, BVAL);
e8d548d5
KM
242}
243
d3af90a5
KM
244static int usbhsf_fifo_barrier(struct usbhs_priv *priv,
245 struct usbhs_fifo *fifo)
e8d548d5
KM
246{
247 int timeout = 1024;
248
249 do {
250 /* The FIFO port is accessible */
d3af90a5 251 if (usbhs_read(priv, fifo->ctr) & FRDY)
e8d548d5
KM
252 return 0;
253
254 udelay(10);
255 } while (timeout--);
256
257 return -EBUSY;
258}
259
d3af90a5
KM
260static void usbhsf_fifo_clear(struct usbhs_pipe *pipe,
261 struct usbhs_fifo *fifo)
e8d548d5
KM
262{
263 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
b974ab50 264 int ret = 0;
e8d548d5 265
5abdd6e8
YS
266 if (!usbhs_pipe_is_dcp(pipe)) {
267 /*
268 * This driver checks the pipe condition first to avoid -EBUSY
269 * from usbhsf_fifo_barrier() with about 10 msec delay in
270 * the interrupt handler if the pipe is RX direction and empty.
271 */
272 if (usbhs_pipe_is_dir_in(pipe))
273 ret = usbhs_pipe_is_accessible(pipe);
274 if (!ret)
275 ret = usbhsf_fifo_barrier(priv, fifo);
276 }
e8d548d5 277
b974ab50
YS
278 /*
279 * if non-DCP pipe, this driver should set BCLR when
280 * usbhsf_fifo_barrier() returns 0.
281 */
282 if (!ret)
283 usbhs_write(priv, fifo->ctr, BCLR);
e8d548d5
KM
284}
285
d3af90a5
KM
286static int usbhsf_fifo_rcv_len(struct usbhs_priv *priv,
287 struct usbhs_fifo *fifo)
e8d548d5 288{
d3af90a5 289 return usbhs_read(priv, fifo->ctr) & DTLN_MASK;
e8d548d5
KM
290}
291
d77e3f4e
KM
292static void usbhsf_fifo_unselect(struct usbhs_pipe *pipe,
293 struct usbhs_fifo *fifo)
294{
295 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
296
297 usbhs_pipe_select_fifo(pipe, NULL);
298 usbhs_write(priv, fifo->sel, 0);
299}
300
d3af90a5
KM
301static int usbhsf_fifo_select(struct usbhs_pipe *pipe,
302 struct usbhs_fifo *fifo,
303 int write)
e8d548d5
KM
304{
305 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
306 struct device *dev = usbhs_priv_to_dev(priv);
307 int timeout = 1024;
308 u16 mask = ((1 << 5) | 0xF); /* mask of ISEL | CURPIPE */
309 u16 base = usbhs_pipe_number(pipe); /* CURPIPE */
310
d77e3f4e
KM
311 if (usbhs_pipe_is_busy(pipe) ||
312 usbhsf_fifo_is_busy(fifo))
313 return -EBUSY;
314
92352071 315 if (usbhs_pipe_is_dcp(pipe)) {
e8d548d5
KM
316 base |= (1 == write) << 5; /* ISEL */
317
92352071
KM
318 if (usbhs_mod_is_host(priv))
319 usbhs_dcp_dir_for_host(pipe, write);
320 }
321
e8d548d5 322 /* "base" will be used below */
5ea43994
SY
323 if (usbhs_get_dparam(priv, has_sudmac) && !usbhsf_is_cfifo(priv, fifo))
324 usbhs_write(priv, fifo->sel, base);
325 else
326 usbhs_write(priv, fifo->sel, base | MBW_32);
e8d548d5
KM
327
328 /* check ISEL and CURPIPE value */
329 while (timeout--) {
d77e3f4e
KM
330 if (base == (mask & usbhs_read(priv, fifo->sel))) {
331 usbhs_pipe_select_fifo(pipe, fifo);
e8d548d5 332 return 0;
d77e3f4e 333 }
e8d548d5
KM
334 udelay(10);
335 }
336
337 dev_err(dev, "fifo select error\n");
338
339 return -EIO;
340}
341
9e74d601
KM
342/*
343 * DCP status stage
344 */
345static int usbhs_dcp_dir_switch_to_write(struct usbhs_pkt *pkt, int *is_done)
346{
347 struct usbhs_pipe *pipe = pkt->pipe;
348 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
349 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
350 struct device *dev = usbhs_priv_to_dev(priv);
351 int ret;
352
353 usbhs_pipe_disable(pipe);
354
355 ret = usbhsf_fifo_select(pipe, fifo, 1);
356 if (ret < 0) {
357 dev_err(dev, "%s() faile\n", __func__);
358 return ret;
359 }
360
361 usbhs_pipe_sequence_data1(pipe); /* DATA1 */
362
363 usbhsf_fifo_clear(pipe, fifo);
364 usbhsf_send_terminator(pipe, fifo);
365
366 usbhsf_fifo_unselect(pipe, fifo);
367
368 usbhsf_tx_irq_ctrl(pipe, 1);
369 usbhs_pipe_enable(pipe);
370
371 return ret;
372}
373
374static int usbhs_dcp_dir_switch_to_read(struct usbhs_pkt *pkt, int *is_done)
375{
376 struct usbhs_pipe *pipe = pkt->pipe;
377 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
378 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
379 struct device *dev = usbhs_priv_to_dev(priv);
380 int ret;
381
382 usbhs_pipe_disable(pipe);
383
384 ret = usbhsf_fifo_select(pipe, fifo, 0);
385 if (ret < 0) {
386 dev_err(dev, "%s() fail\n", __func__);
387 return ret;
388 }
389
390 usbhs_pipe_sequence_data1(pipe); /* DATA1 */
391 usbhsf_fifo_clear(pipe, fifo);
392
393 usbhsf_fifo_unselect(pipe, fifo);
394
395 usbhsf_rx_irq_ctrl(pipe, 1);
396 usbhs_pipe_enable(pipe);
397
398 return ret;
399
400}
401
402static int usbhs_dcp_dir_switch_done(struct usbhs_pkt *pkt, int *is_done)
403{
404 struct usbhs_pipe *pipe = pkt->pipe;
405
406 if (pkt->handler == &usbhs_dcp_status_stage_in_handler)
407 usbhsf_tx_irq_ctrl(pipe, 0);
408 else
409 usbhsf_rx_irq_ctrl(pipe, 0);
410
411 pkt->actual = pkt->length;
412 *is_done = 1;
413
414 return 0;
415}
416
417struct usbhs_pkt_handle usbhs_dcp_status_stage_in_handler = {
418 .prepare = usbhs_dcp_dir_switch_to_write,
419 .try_run = usbhs_dcp_dir_switch_done,
420};
421
422struct usbhs_pkt_handle usbhs_dcp_status_stage_out_handler = {
423 .prepare = usbhs_dcp_dir_switch_to_read,
424 .try_run = usbhs_dcp_dir_switch_done,
425};
426
427/*
428 * DCP data stage (push)
429 */
430static int usbhsf_dcp_data_stage_try_push(struct usbhs_pkt *pkt, int *is_done)
431{
432 struct usbhs_pipe *pipe = pkt->pipe;
433
434 usbhs_pipe_sequence_data1(pipe); /* DATA1 */
435
436 /*
437 * change handler to PIO push
438 */
439 pkt->handler = &usbhs_fifo_pio_push_handler;
440
441 return pkt->handler->prepare(pkt, is_done);
442}
443
444struct usbhs_pkt_handle usbhs_dcp_data_stage_out_handler = {
445 .prepare = usbhsf_dcp_data_stage_try_push,
446};
447
448/*
449 * DCP data stage (pop)
450 */
451static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
452 int *is_done)
453{
454 struct usbhs_pipe *pipe = pkt->pipe;
455 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
456 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv);
457
458 if (usbhs_pipe_is_busy(pipe))
459 return 0;
460
461 /*
462 * prepare pop for DCP should
463 * - change DCP direction,
464 * - clear fifo
465 * - DATA1
466 */
467 usbhs_pipe_disable(pipe);
468
469 usbhs_pipe_sequence_data1(pipe); /* DATA1 */
470
471 usbhsf_fifo_select(pipe, fifo, 0);
472 usbhsf_fifo_clear(pipe, fifo);
473 usbhsf_fifo_unselect(pipe, fifo);
474
475 /*
476 * change handler to PIO pop
477 */
478 pkt->handler = &usbhs_fifo_pio_pop_handler;
479
480 return pkt->handler->prepare(pkt, is_done);
481}
482
483struct usbhs_pkt_handle usbhs_dcp_data_stage_in_handler = {
484 .prepare = usbhsf_dcp_data_stage_prepare_pop,
485};
486
e8d548d5 487/*
233f519d 488 * PIO push handler
e8d548d5 489 */
0cb7e61d 490static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
e8d548d5 491{
4bd04811 492 struct usbhs_pipe *pipe = pkt->pipe;
e8d548d5 493 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
659d4954 494 struct device *dev = usbhs_priv_to_dev(priv);
d3af90a5
KM
495 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
496 void __iomem *addr = priv->base + fifo->port;
659d4954 497 u8 *buf;
e8d548d5
KM
498 int maxp = usbhs_pipe_get_maxpacket(pipe);
499 int total_len;
4bd04811 500 int i, ret, len;
97664a20 501 int is_short;
e8d548d5 502
3edeee38
KM
503 usbhs_pipe_data_sequence(pipe, pkt->sequence);
504 pkt->sequence = -1; /* -1 sequence will be ignored */
505
1c90ee0b
KM
506 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
507
d3af90a5 508 ret = usbhsf_fifo_select(pipe, fifo, 1);
e8d548d5 509 if (ret < 0)
d77e3f4e 510 return 0;
e8d548d5 511
dad67397 512 ret = usbhs_pipe_is_accessible(pipe);
4ef85e0f
KM
513 if (ret < 0) {
514 /* inaccessible pipe is not an error */
515 ret = 0;
659d4954 516 goto usbhs_fifo_write_busy;
4ef85e0f 517 }
e8d548d5 518
d3af90a5 519 ret = usbhsf_fifo_barrier(priv, fifo);
e8d548d5 520 if (ret < 0)
659d4954 521 goto usbhs_fifo_write_busy;
e8d548d5 522
659d4954
KM
523 buf = pkt->buf + pkt->actual;
524 len = pkt->length - pkt->actual;
525 len = min(len, maxp);
526 total_len = len;
527 is_short = total_len < maxp;
e8d548d5
KM
528
529 /*
530 * FIXME
531 *
532 * 32-bit access only
533 */
659d4954 534 if (len >= 4 && !((unsigned long)buf & 0x03)) {
e8d548d5
KM
535 iowrite32_rep(addr, buf, len / 4);
536 len %= 4;
537 buf += total_len - len;
538 }
539
540 /* the rest operation */
541 for (i = 0; i < len; i++)
542 iowrite8(buf[i], addr + (0x03 - (i & 0x03)));
543
659d4954
KM
544 /*
545 * variable update
546 */
547 pkt->actual += total_len;
548
549 if (pkt->actual < pkt->length)
97664a20 550 *is_done = 0; /* there are remainder data */
659d4954 551 else if (is_short)
97664a20 552 *is_done = 1; /* short packet */
659d4954 553 else
97664a20 554 *is_done = !pkt->zero; /* send zero packet ? */
659d4954
KM
555
556 /*
557 * pipe/irq handling
558 */
559 if (is_short)
d3af90a5 560 usbhsf_send_terminator(pipe, fifo);
e8d548d5 561
97664a20 562 usbhsf_tx_irq_ctrl(pipe, !*is_done);
58e47d43 563 usbhs_pipe_running(pipe, !*is_done);
4bd04811
KM
564 usbhs_pipe_enable(pipe);
565
659d4954
KM
566 dev_dbg(dev, " send %d (%d/ %d/ %d/ %d)\n",
567 usbhs_pipe_number(pipe),
97664a20 568 pkt->length, pkt->actual, *is_done, pkt->zero);
659d4954
KM
569
570 /*
571 * Transmission end
572 */
97664a20 573 if (*is_done) {
659d4954
KM
574 if (usbhs_pipe_is_dcp(pipe))
575 usbhs_dcp_control_transfer_done(pipe);
4bd04811
KM
576 }
577
d77e3f4e
KM
578 usbhsf_fifo_unselect(pipe, fifo);
579
4bd04811 580 return 0;
659d4954
KM
581
582usbhs_fifo_write_busy:
d77e3f4e
KM
583 usbhsf_fifo_unselect(pipe, fifo);
584
659d4954
KM
585 /*
586 * pipe is busy.
587 * retry in interrupt
588 */
589 usbhsf_tx_irq_ctrl(pipe, 1);
58e47d43 590 usbhs_pipe_running(pipe, 1);
659d4954
KM
591
592 return ret;
e8d548d5
KM
593}
594
58e47d43
YS
595static int usbhsf_pio_prepare_push(struct usbhs_pkt *pkt, int *is_done)
596{
597 if (usbhs_pipe_is_running(pkt->pipe))
598 return 0;
599
600 return usbhsf_pio_try_push(pkt, is_done);
601}
602
0cb7e61d 603struct usbhs_pkt_handle usbhs_fifo_pio_push_handler = {
58e47d43 604 .prepare = usbhsf_pio_prepare_push,
0cb7e61d 605 .try_run = usbhsf_pio_try_push,
dad67397
KM
606};
607
233f519d
KM
608/*
609 * PIO pop handler
610 */
97664a20 611static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
e8d548d5 612{
dad67397 613 struct usbhs_pipe *pipe = pkt->pipe;
d77e3f4e
KM
614
615 if (usbhs_pipe_is_busy(pipe))
616 return 0;
e8d548d5 617
58e47d43
YS
618 if (usbhs_pipe_is_running(pipe))
619 return 0;
620
e8d548d5 621 /*
d77e3f4e 622 * pipe enable to prepare packet receive
e8d548d5 623 */
3edeee38
KM
624 usbhs_pipe_data_sequence(pipe, pkt->sequence);
625 pkt->sequence = -1; /* -1 sequence will be ignored */
e8d548d5 626
1c90ee0b 627 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
e8d548d5 628 usbhs_pipe_enable(pipe);
58e47d43 629 usbhs_pipe_running(pipe, 1);
659d4954 630 usbhsf_rx_irq_ctrl(pipe, 1);
e8d548d5 631
d3af90a5 632 return 0;
e8d548d5
KM
633}
634
0cb7e61d 635static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done)
e8d548d5 636{
4bd04811 637 struct usbhs_pipe *pipe = pkt->pipe;
e8d548d5 638 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
659d4954 639 struct device *dev = usbhs_priv_to_dev(priv);
d3af90a5
KM
640 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
641 void __iomem *addr = priv->base + fifo->port;
659d4954
KM
642 u8 *buf;
643 u32 data = 0;
644 int maxp = usbhs_pipe_get_maxpacket(pipe);
4bd04811 645 int rcv_len, len;
e8d548d5 646 int i, ret;
4bd04811 647 int total_len = 0;
e8d548d5 648
d3af90a5 649 ret = usbhsf_fifo_select(pipe, fifo, 0);
e8d548d5 650 if (ret < 0)
d77e3f4e 651 return 0;
e8d548d5 652
d3af90a5 653 ret = usbhsf_fifo_barrier(priv, fifo);
e8d548d5 654 if (ret < 0)
d77e3f4e 655 goto usbhs_fifo_read_busy;
e8d548d5 656
d3af90a5 657 rcv_len = usbhsf_fifo_rcv_len(priv, fifo);
e8d548d5 658
659d4954
KM
659 buf = pkt->buf + pkt->actual;
660 len = pkt->length - pkt->actual;
661 len = min(len, rcv_len);
662 total_len = len;
663
6ff5d09b
KM
664 /*
665 * update actual length first here to decide disable pipe.
666 * if this pipe keeps BUF status and all data were popped,
667 * then, next interrupt/token will be issued again
668 */
669 pkt->actual += total_len;
670
671 if ((pkt->actual == pkt->length) || /* receive all data */
672 (total_len < maxp)) { /* short packet */
673 *is_done = 1;
674 usbhsf_rx_irq_ctrl(pipe, 0);
58e47d43 675 usbhs_pipe_running(pipe, 0);
6ff5d09b
KM
676 usbhs_pipe_disable(pipe); /* disable pipe first */
677 }
678
e8d548d5
KM
679 /*
680 * Buffer clear if Zero-Length packet
681 *
682 * see
683 * "Operation" - "FIFO Buffer Memory" - "FIFO Port Function"
684 */
685 if (0 == rcv_len) {
3edeee38 686 pkt->zero = 1;
d3af90a5 687 usbhsf_fifo_clear(pipe, fifo);
4bd04811 688 goto usbhs_fifo_read_end;
e8d548d5
KM
689 }
690
e8d548d5
KM
691 /*
692 * FIXME
693 *
694 * 32-bit access only
695 */
659d4954 696 if (len >= 4 && !((unsigned long)buf & 0x03)) {
e8d548d5
KM
697 ioread32_rep(addr, buf, len / 4);
698 len %= 4;
659d4954 699 buf += total_len - len;
e8d548d5
KM
700 }
701
702 /* the rest operation */
703 for (i = 0; i < len; i++) {
704 if (!(i & 0x03))
705 data = ioread32(addr);
706
707 buf[i] = (data >> ((i & 0x03) * 8)) & 0xff;
708 }
709
4bd04811 710usbhs_fifo_read_end:
97664a20
KM
711 dev_dbg(dev, " recv %d (%d/ %d/ %d/ %d)\n",
712 usbhs_pipe_number(pipe),
713 pkt->length, pkt->actual, *is_done, pkt->zero);
714
d77e3f4e
KM
715usbhs_fifo_read_busy:
716 usbhsf_fifo_unselect(pipe, fifo);
717
718 return ret;
e8d548d5 719}
dad67397 720
0cb7e61d 721struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler = {
dad67397 722 .prepare = usbhsf_prepare_pop,
0cb7e61d 723 .try_run = usbhsf_pio_try_pop,
dad67397
KM
724};
725
726/*
233f519d 727 * DCP ctrol statge handler
dad67397 728 */
97664a20 729static int usbhsf_ctrl_stage_end(struct usbhs_pkt *pkt, int *is_done)
dad67397 730{
97664a20 731 usbhs_dcp_control_transfer_done(pkt->pipe);
dad67397 732
97664a20 733 *is_done = 1;
dad67397
KM
734
735 return 0;
736}
737
738struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler = {
739 .prepare = usbhsf_ctrl_stage_end,
740 .try_run = usbhsf_ctrl_stage_end,
741};
742
e73a9891
KM
743/*
744 * DMA fifo functions
745 */
746static struct dma_chan *usbhsf_dma_chan_get(struct usbhs_fifo *fifo,
747 struct usbhs_pkt *pkt)
748{
749 if (&usbhs_fifo_dma_push_handler == pkt->handler)
750 return fifo->tx_chan;
751
752 if (&usbhs_fifo_dma_pop_handler == pkt->handler)
753 return fifo->rx_chan;
754
755 return NULL;
756}
757
758static struct usbhs_fifo *usbhsf_get_dma_fifo(struct usbhs_priv *priv,
759 struct usbhs_pkt *pkt)
760{
761 struct usbhs_fifo *fifo;
762
763 /* DMA :: D0FIFO */
764 fifo = usbhsf_get_d0fifo(priv);
765 if (usbhsf_dma_chan_get(fifo, pkt) &&
766 !usbhsf_fifo_is_busy(fifo))
767 return fifo;
768
769 /* DMA :: D1FIFO */
770 fifo = usbhsf_get_d1fifo(priv);
771 if (usbhsf_dma_chan_get(fifo, pkt) &&
772 !usbhsf_fifo_is_busy(fifo))
773 return fifo;
774
775 return NULL;
776}
777
778#define usbhsf_dma_start(p, f) __usbhsf_dma_ctrl(p, f, DREQE)
779#define usbhsf_dma_stop(p, f) __usbhsf_dma_ctrl(p, f, 0)
780static void __usbhsf_dma_ctrl(struct usbhs_pipe *pipe,
781 struct usbhs_fifo *fifo,
782 u16 dreqe)
783{
784 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
785
786 usbhs_bset(priv, fifo->sel, DREQE, dreqe);
787}
788
789#define usbhsf_dma_map(p) __usbhsf_dma_map_ctrl(p, 1)
790#define usbhsf_dma_unmap(p) __usbhsf_dma_map_ctrl(p, 0)
791static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
792{
793 struct usbhs_pipe *pipe = pkt->pipe;
794 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
795 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
796
797 return info->dma_map_ctrl(pkt, map);
798}
799
800static void usbhsf_dma_complete(void *arg);
6e4b74e4 801static void xfer_work(struct work_struct *work)
e73a9891 802{
6e4b74e4 803 struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work);
e73a9891
KM
804 struct usbhs_pipe *pipe = pkt->pipe;
805 struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe);
806 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
e73a9891
KM
807 struct dma_async_tx_descriptor *desc;
808 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt);
809 struct device *dev = usbhs_priv_to_dev(priv);
55ba4e5e 810 enum dma_transfer_direction dir;
e73a9891 811
55ba4e5e 812 dir = usbhs_pipe_is_dir_in(pipe) ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV;
e73a9891 813
2f0de9d8
KM
814 desc = dmaengine_prep_slave_single(chan, pkt->dma + pkt->actual,
815 pkt->trans, dir,
16052827 816 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
e73a9891
KM
817 if (!desc)
818 return;
819
820 desc->callback = usbhsf_dma_complete;
821 desc->callback_param = pipe;
822
2f0de9d8 823 if (dmaengine_submit(desc) < 0) {
e73a9891
KM
824 dev_err(dev, "Failed to submit dma descriptor\n");
825 return;
826 }
827
828 dev_dbg(dev, " %s %d (%d/ %d)\n",
829 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero);
830
58e47d43 831 usbhs_pipe_running(pipe, 1);
b2453bd4 832 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans);
e73a9891 833 dma_async_issue_pending(chan);
9a95fe3d 834 usbhsf_dma_start(pipe, fifo);
b2453bd4 835 usbhs_pipe_enable(pipe);
e73a9891
KM
836}
837
233f519d
KM
838/*
839 * DMA push handler
840 */
e73a9891
KM
841static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
842{
843 struct usbhs_pipe *pipe = pkt->pipe;
844 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
845 struct usbhs_fifo *fifo;
846 int len = pkt->length - pkt->actual;
847 int ret;
848
849 if (usbhs_pipe_is_busy(pipe))
850 return 0;
851
852 /* use PIO if packet is less than pio_dma_border or pipe is DCP */
853 if ((len < usbhs_get_dparam(priv, pio_dma_border)) ||
854 usbhs_pipe_is_dcp(pipe))
855 goto usbhsf_pio_prepare_push;
856
77975eec 857 if (len & 0x7) /* 8byte alignment */
e73a9891
KM
858 goto usbhsf_pio_prepare_push;
859
c9ae0c91 860 if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
9a12d097
KM
861 goto usbhsf_pio_prepare_push;
862
58e47d43
YS
863 /* return at this time if the pipe is running */
864 if (usbhs_pipe_is_running(pipe))
865 return 0;
866
e73a9891
KM
867 /* get enable DMA fifo */
868 fifo = usbhsf_get_dma_fifo(priv, pkt);
869 if (!fifo)
870 goto usbhsf_pio_prepare_push;
871
872 if (usbhsf_dma_map(pkt) < 0)
873 goto usbhsf_pio_prepare_push;
874
875 ret = usbhsf_fifo_select(pipe, fifo, 0);
876 if (ret < 0)
877 goto usbhsf_pio_prepare_push_unmap;
878
879 pkt->trans = len;
880
6e4b74e4
GL
881 INIT_WORK(&pkt->work, xfer_work);
882 schedule_work(&pkt->work);
e73a9891
KM
883
884 return 0;
885
886usbhsf_pio_prepare_push_unmap:
887 usbhsf_dma_unmap(pkt);
888usbhsf_pio_prepare_push:
889 /*
890 * change handler to PIO
891 */
892 pkt->handler = &usbhs_fifo_pio_push_handler;
893
894 return pkt->handler->prepare(pkt, is_done);
895}
896
897static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done)
898{
899 struct usbhs_pipe *pipe = pkt->pipe;
900
901 pkt->actual = pkt->trans;
902
903 *is_done = !pkt->zero; /* send zero packet ? */
58e47d43 904 usbhs_pipe_running(pipe, !*is_done);
e73a9891
KM
905
906 usbhsf_dma_stop(pipe, pipe->fifo);
907 usbhsf_dma_unmap(pkt);
908 usbhsf_fifo_unselect(pipe, pipe->fifo);
909
910 return 0;
911}
912
913struct usbhs_pkt_handle usbhs_fifo_dma_push_handler = {
914 .prepare = usbhsf_dma_prepare_push,
915 .dma_done = usbhsf_dma_push_done,
916};
917
233f519d
KM
918/*
919 * DMA pop handler
920 */
e73a9891
KM
921static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done)
922{
923 struct usbhs_pipe *pipe = pkt->pipe;
924 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
925 struct usbhs_fifo *fifo;
926 int len, ret;
927
928 if (usbhs_pipe_is_busy(pipe))
929 return 0;
930
931 if (usbhs_pipe_is_dcp(pipe))
932 goto usbhsf_pio_prepare_pop;
933
934 /* get enable DMA fifo */
935 fifo = usbhsf_get_dma_fifo(priv, pkt);
936 if (!fifo)
937 goto usbhsf_pio_prepare_pop;
938
c9ae0c91 939 if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
9a12d097
KM
940 goto usbhsf_pio_prepare_pop;
941
e73a9891
KM
942 ret = usbhsf_fifo_select(pipe, fifo, 0);
943 if (ret < 0)
944 goto usbhsf_pio_prepare_pop;
945
946 /* use PIO if packet is less than pio_dma_border */
947 len = usbhsf_fifo_rcv_len(priv, fifo);
948 len = min(pkt->length - pkt->actual, len);
77975eec 949 if (len & 0x7) /* 8byte alignment */
e73a9891
KM
950 goto usbhsf_pio_prepare_pop_unselect;
951
952 if (len < usbhs_get_dparam(priv, pio_dma_border))
953 goto usbhsf_pio_prepare_pop_unselect;
954
955 ret = usbhsf_fifo_barrier(priv, fifo);
956 if (ret < 0)
957 goto usbhsf_pio_prepare_pop_unselect;
958
959 if (usbhsf_dma_map(pkt) < 0)
960 goto usbhsf_pio_prepare_pop_unselect;
961
962 /* DMA */
963
964 /*
965 * usbhs_fifo_dma_pop_handler :: prepare
966 * enabled irq to come here.
967 * but it is no longer needed for DMA. disable it.
968 */
969 usbhsf_rx_irq_ctrl(pipe, 0);
970
971 pkt->trans = len;
972
4407936b 973 usbhsf_tx_irq_ctrl(pipe, 0);
6e4b74e4
GL
974 INIT_WORK(&pkt->work, xfer_work);
975 schedule_work(&pkt->work);
e73a9891
KM
976
977 return 0;
978
979usbhsf_pio_prepare_pop_unselect:
980 usbhsf_fifo_unselect(pipe, fifo);
981usbhsf_pio_prepare_pop:
982
983 /*
984 * change handler to PIO
985 */
986 pkt->handler = &usbhs_fifo_pio_pop_handler;
987
988 return pkt->handler->try_run(pkt, is_done);
989}
990
991static int usbhsf_dma_pop_done(struct usbhs_pkt *pkt, int *is_done)
992{
993 struct usbhs_pipe *pipe = pkt->pipe;
994 int maxp = usbhs_pipe_get_maxpacket(pipe);
995
996 usbhsf_dma_stop(pipe, pipe->fifo);
997 usbhsf_dma_unmap(pkt);
998 usbhsf_fifo_unselect(pipe, pipe->fifo);
999
1000 pkt->actual += pkt->trans;
1001
1002 if ((pkt->actual == pkt->length) || /* receive all data */
1003 (pkt->trans < maxp)) { /* short packet */
1004 *is_done = 1;
58e47d43 1005 usbhs_pipe_running(pipe, 0);
e73a9891
KM
1006 } else {
1007 /* re-enable */
58e47d43 1008 usbhs_pipe_running(pipe, 0);
e73a9891
KM
1009 usbhsf_prepare_pop(pkt, is_done);
1010 }
1011
1012 return 0;
1013}
1014
1015struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler = {
1016 .prepare = usbhsf_prepare_pop,
1017 .try_run = usbhsf_dma_try_pop,
1018 .dma_done = usbhsf_dma_pop_done
1019};
1020
1021/*
1022 * DMA setting
1023 */
1024static bool usbhsf_dma_filter(struct dma_chan *chan, void *param)
1025{
1026 struct sh_dmae_slave *slave = param;
1027
1028 /*
1029 * FIXME
1030 *
1031 * usbhs doesn't recognize id = 0 as valid DMA
1032 */
f19b7e0d 1033 if (0 == slave->shdma_slave.slave_id)
e73a9891
KM
1034 return false;
1035
1036 chan->private = slave;
1037
1038 return true;
1039}
1040
1041static void usbhsf_dma_quit(struct usbhs_priv *priv, struct usbhs_fifo *fifo)
1042{
1043 if (fifo->tx_chan)
1044 dma_release_channel(fifo->tx_chan);
1045 if (fifo->rx_chan)
1046 dma_release_channel(fifo->rx_chan);
1047
1048 fifo->tx_chan = NULL;
1049 fifo->rx_chan = NULL;
1050}
1051
1052static void usbhsf_dma_init(struct usbhs_priv *priv,
1053 struct usbhs_fifo *fifo)
1054{
1055 struct device *dev = usbhs_priv_to_dev(priv);
1056 dma_cap_mask_t mask;
1057
1058 dma_cap_zero(mask);
1059 dma_cap_set(DMA_SLAVE, mask);
1060 fifo->tx_chan = dma_request_channel(mask, usbhsf_dma_filter,
1061 &fifo->tx_slave);
1062
1063 dma_cap_zero(mask);
1064 dma_cap_set(DMA_SLAVE, mask);
1065 fifo->rx_chan = dma_request_channel(mask, usbhsf_dma_filter,
1066 &fifo->rx_slave);
1067
1068 if (fifo->tx_chan || fifo->rx_chan)
4ce68805 1069 dev_dbg(dev, "enable DMAEngine (%s%s%s)\n",
e73a9891
KM
1070 fifo->name,
1071 fifo->tx_chan ? "[TX]" : " ",
1072 fifo->rx_chan ? "[RX]" : " ");
1073}
1074
dad67397
KM
1075/*
1076 * irq functions
1077 */
1078static int usbhsf_irq_empty(struct usbhs_priv *priv,
1079 struct usbhs_irq_state *irq_state)
1080{
1081 struct usbhs_pipe *pipe;
dad67397
KM
1082 struct device *dev = usbhs_priv_to_dev(priv);
1083 int i, ret;
1084
1085 if (!irq_state->bempsts) {
1086 dev_err(dev, "debug %s !!\n", __func__);
1087 return -EIO;
1088 }
1089
1090 dev_dbg(dev, "irq empty [0x%04x]\n", irq_state->bempsts);
1091
1092 /*
1093 * search interrupted "pipe"
1094 * not "uep".
1095 */
1096 usbhs_for_each_pipe_with_dcp(pipe, priv, i) {
1097 if (!(irq_state->bempsts & (1 << i)))
1098 continue;
1099
51b8a021 1100 ret = usbhsf_pkt_handler(pipe, USBHSF_PKT_TRY_RUN);
dad67397
KM
1101 if (ret < 0)
1102 dev_err(dev, "irq_empty run_error %d : %d\n", i, ret);
1103 }
1104
1105 return 0;
1106}
1107
1108static int usbhsf_irq_ready(struct usbhs_priv *priv,
1109 struct usbhs_irq_state *irq_state)
1110{
1111 struct usbhs_pipe *pipe;
dad67397
KM
1112 struct device *dev = usbhs_priv_to_dev(priv);
1113 int i, ret;
1114
1115 if (!irq_state->brdysts) {
1116 dev_err(dev, "debug %s !!\n", __func__);
1117 return -EIO;
1118 }
1119
1120 dev_dbg(dev, "irq ready [0x%04x]\n", irq_state->brdysts);
1121
1122 /*
1123 * search interrupted "pipe"
1124 * not "uep".
1125 */
1126 usbhs_for_each_pipe_with_dcp(pipe, priv, i) {
1127 if (!(irq_state->brdysts & (1 << i)))
1128 continue;
1129
51b8a021 1130 ret = usbhsf_pkt_handler(pipe, USBHSF_PKT_TRY_RUN);
dad67397
KM
1131 if (ret < 0)
1132 dev_err(dev, "irq_ready run_error %d : %d\n", i, ret);
1133 }
1134
1135 return 0;
1136}
1137
e73a9891
KM
1138static void usbhsf_dma_complete(void *arg)
1139{
1140 struct usbhs_pipe *pipe = arg;
1141 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
1142 struct device *dev = usbhs_priv_to_dev(priv);
1143 int ret;
1144
51b8a021 1145 ret = usbhsf_pkt_handler(pipe, USBHSF_PKT_DMA_DONE);
e73a9891
KM
1146 if (ret < 0)
1147 dev_err(dev, "dma_complete run_error %d : %d\n",
1148 usbhs_pipe_number(pipe), ret);
1149}
1150
dad67397
KM
1151/*
1152 * fifo init
1153 */
1154void usbhs_fifo_init(struct usbhs_priv *priv)
1155{
1156 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
d77e3f4e 1157 struct usbhs_fifo *cfifo = usbhsf_get_cfifo(priv);
e73a9891
KM
1158 struct usbhs_fifo *d0fifo = usbhsf_get_d0fifo(priv);
1159 struct usbhs_fifo *d1fifo = usbhsf_get_d1fifo(priv);
dad67397
KM
1160
1161 mod->irq_empty = usbhsf_irq_empty;
1162 mod->irq_ready = usbhsf_irq_ready;
1163 mod->irq_bempsts = 0;
1164 mod->irq_brdysts = 0;
d77e3f4e
KM
1165
1166 cfifo->pipe = NULL;
e73a9891
KM
1167 cfifo->tx_chan = NULL;
1168 cfifo->rx_chan = NULL;
1169
1170 d0fifo->pipe = NULL;
1171 d0fifo->tx_chan = NULL;
1172 d0fifo->rx_chan = NULL;
1173
1174 d1fifo->pipe = NULL;
1175 d1fifo->tx_chan = NULL;
1176 d1fifo->rx_chan = NULL;
1177
1178 usbhsf_dma_init(priv, usbhsf_get_d0fifo(priv));
1179 usbhsf_dma_init(priv, usbhsf_get_d1fifo(priv));
dad67397
KM
1180}
1181
1182void usbhs_fifo_quit(struct usbhs_priv *priv)
1183{
1184 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
1185
1186 mod->irq_empty = NULL;
1187 mod->irq_ready = NULL;
1188 mod->irq_bempsts = 0;
1189 mod->irq_brdysts = 0;
e73a9891
KM
1190
1191 usbhsf_dma_quit(priv, usbhsf_get_d0fifo(priv));
1192 usbhsf_dma_quit(priv, usbhsf_get_d1fifo(priv));
dad67397 1193}
d3af90a5
KM
1194
1195int usbhs_fifo_probe(struct usbhs_priv *priv)
1196{
1197 struct usbhs_fifo *fifo;
1198
1199 /* CFIFO */
1200 fifo = usbhsf_get_cfifo(priv);
e73a9891 1201 fifo->name = "CFIFO";
d3af90a5
KM
1202 fifo->port = CFIFO;
1203 fifo->sel = CFIFOSEL;
1204 fifo->ctr = CFIFOCTR;
1205
e73a9891
KM
1206 /* D0FIFO */
1207 fifo = usbhsf_get_d0fifo(priv);
1208 fifo->name = "D0FIFO";
1209 fifo->port = D0FIFO;
1210 fifo->sel = D0FIFOSEL;
1211 fifo->ctr = D0FIFOCTR;
f19b7e0d
GL
1212 fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_tx_id);
1213 fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_rx_id);
e73a9891
KM
1214
1215 /* D1FIFO */
1216 fifo = usbhsf_get_d1fifo(priv);
1217 fifo->name = "D1FIFO";
1218 fifo->port = D1FIFO;
1219 fifo->sel = D1FIFOSEL;
1220 fifo->ctr = D1FIFOCTR;
f19b7e0d
GL
1221 fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_tx_id);
1222 fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_rx_id);
e73a9891 1223
d3af90a5
KM
1224 return 0;
1225}
1226
1227void usbhs_fifo_remove(struct usbhs_priv *priv)
1228{
1229}