blob: 406893e4422b823add65445967dfceb661ea7b8f [file] [log] [blame]
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +09001/*
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>
19#include "./common.h"
20#include "./pipe.h"
21
Kuninori Morimotod3af90a2011-06-06 14:18:44 +090022#define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo))
Kuninori Morimotoe73a9892011-06-06 14:19:03 +090023#define usbhsf_get_d0fifo(p) (&((p)->fifo_info.d0fifo))
24#define usbhsf_get_d1fifo(p) (&((p)->fifo_info.d1fifo))
Kuninori Morimotod3af90a2011-06-06 14:18:44 +090025
Kuninori Morimotod77e3f42011-06-06 14:18:50 +090026#define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */
27
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090028/*
Kuninori Morimoto233f5192011-07-07 00:23:24 -070029 * packet initialize
30 */
31void usbhs_pkt_init(struct usbhs_pkt *pkt)
32{
33 pkt->dma = DMA_ADDR_INVALID;
34 INIT_LIST_HEAD(&pkt->node);
35}
36
37/*
38 * packet control function
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090039 */
Kuninori Morimoto97664a22011-06-06 14:18:38 +090040static int usbhsf_null_handle(struct usbhs_pkt *pkt, int *is_done)
Kuninori Morimotodad67392011-06-06 14:18:28 +090041{
42 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe);
43 struct device *dev = usbhs_priv_to_dev(priv);
44
45 dev_err(dev, "null handler\n");
46
47 return -EINVAL;
48}
49
50static struct usbhs_pkt_handle usbhsf_null_handler = {
51 .prepare = usbhsf_null_handle,
52 .try_run = usbhsf_null_handle,
53};
54
Kuninori Morimoto659d4952011-06-06 14:18:23 +090055void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
Kuninori Morimotodad67392011-06-06 14:18:28 +090056 struct usbhs_pkt_handle *handler,
Kuninori Morimoto659d4952011-06-06 14:18:23 +090057 void *buf, int len, int zero)
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090058{
Kuninori Morimotodad67392011-06-06 14:18:28 +090059 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
60 struct device *dev = usbhs_priv_to_dev(priv);
Kuninori Morimoto97664a22011-06-06 14:18:38 +090061 unsigned long flags;
62
63 /******************** spin lock ********************/
64 usbhs_lock(priv, flags);
Kuninori Morimotodad67392011-06-06 14:18:28 +090065
66 if (!handler) {
67 dev_err(dev, "no handler function\n");
68 handler = &usbhsf_null_handler;
69 }
70
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090071 list_del_init(&pkt->node);
72 list_add_tail(&pkt->node, &pipe->list);
73
Kuninori Morimoto659d4952011-06-06 14:18:23 +090074 pkt->pipe = pipe;
75 pkt->buf = buf;
Kuninori Morimotodad67392011-06-06 14:18:28 +090076 pkt->handler = handler;
Kuninori Morimoto659d4952011-06-06 14:18:23 +090077 pkt->length = len;
78 pkt->zero = zero;
79 pkt->actual = 0;
Kuninori Morimoto97664a22011-06-06 14:18:38 +090080
81 usbhs_unlock(priv, flags);
82 /******************** spin unlock ******************/
Kuninori Morimoto0432eed2011-06-06 14:18:54 +090083
84 usbhs_pkt_start(pipe);
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090085}
86
Kuninori Morimoto97664a22011-06-06 14:18:38 +090087static void __usbhsf_pkt_del(struct usbhs_pkt *pkt)
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090088{
89 list_del_init(&pkt->node);
90}
91
Kuninori Morimoto97664a22011-06-06 14:18:38 +090092static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090093{
94 if (list_empty(&pipe->list))
95 return NULL;
96
97 return list_entry(pipe->list.next, struct usbhs_pkt, node);
98}
99
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900100struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt)
101{
102 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
103 unsigned long flags;
104
105 /******************** spin lock ********************/
106 usbhs_lock(priv, flags);
107
108 if (!pkt)
109 pkt = __usbhsf_pkt_get(pipe);
110
111 if (pkt)
112 __usbhsf_pkt_del(pkt);
113
114 usbhs_unlock(priv, flags);
115 /******************** spin unlock ******************/
116
117 return pkt;
118}
119
120int __usbhs_pkt_handler(struct usbhs_pipe *pipe, int type)
121{
122 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
123 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
124 struct usbhs_pkt *pkt;
125 struct device *dev = usbhs_priv_to_dev(priv);
126 int (*func)(struct usbhs_pkt *pkt, int *is_done);
127 unsigned long flags;
128 int ret = 0;
129 int is_done = 0;
130
131 /******************** spin lock ********************/
132 usbhs_lock(priv, flags);
133
134 pkt = __usbhsf_pkt_get(pipe);
135 if (!pkt)
136 goto __usbhs_pkt_handler_end;
137
138 switch (type) {
139 case USBHSF_PKT_PREPARE:
140 func = pkt->handler->prepare;
141 break;
142 case USBHSF_PKT_TRY_RUN:
143 func = pkt->handler->try_run;
144 break;
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900145 case USBHSF_PKT_DMA_DONE:
146 func = pkt->handler->dma_done;
147 break;
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900148 default:
149 dev_err(dev, "unknown pkt hander\n");
150 goto __usbhs_pkt_handler_end;
151 }
152
153 ret = func(pkt, &is_done);
154
155 if (is_done)
156 __usbhsf_pkt_del(pkt);
157
158__usbhs_pkt_handler_end:
159 usbhs_unlock(priv, flags);
160 /******************** spin unlock ******************/
161
Kuninori Morimoto0432eed2011-06-06 14:18:54 +0900162 if (is_done) {
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900163 info->done(pkt);
Kuninori Morimoto0432eed2011-06-06 14:18:54 +0900164 usbhs_pkt_start(pipe);
165 }
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900166
167 return ret;
168}
169
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900170/*
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900171 * irq enable/disable function
172 */
173#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, bempsts, e)
174#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, brdysts, e)
175#define usbhsf_irq_callback_ctrl(pipe, status, enable) \
176 ({ \
177 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \
178 struct usbhs_mod *mod = usbhs_mod_get_current(priv); \
179 u16 status = (1 << usbhs_pipe_number(pipe)); \
180 if (!mod) \
181 return; \
182 if (enable) \
183 mod->irq_##status |= status; \
184 else \
185 mod->irq_##status &= ~status; \
186 usbhs_irq_callback_update(priv, mod); \
187 })
188
189static void usbhsf_tx_irq_ctrl(struct usbhs_pipe *pipe, int enable)
190{
191 /*
192 * And DCP pipe can NOT use "ready interrupt" for "send"
193 * it should use "empty" interrupt.
194 * see
195 * "Operation" - "Interrupt Function" - "BRDY Interrupt"
196 *
197 * on the other hand, normal pipe can use "ready interrupt" for "send"
198 * even though it is single/double buffer
199 */
200 if (usbhs_pipe_is_dcp(pipe))
201 usbhsf_irq_empty_ctrl(pipe, enable);
202 else
203 usbhsf_irq_ready_ctrl(pipe, enable);
204}
205
206static void usbhsf_rx_irq_ctrl(struct usbhs_pipe *pipe, int enable)
207{
208 usbhsf_irq_ready_ctrl(pipe, enable);
209}
210
211/*
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900212 * FIFO ctrl
213 */
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900214static void usbhsf_send_terminator(struct usbhs_pipe *pipe,
215 struct usbhs_fifo *fifo)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900216{
217 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
218
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900219 usbhs_bset(priv, fifo->ctr, BVAL, BVAL);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900220}
221
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900222static int usbhsf_fifo_barrier(struct usbhs_priv *priv,
223 struct usbhs_fifo *fifo)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900224{
225 int timeout = 1024;
226
227 do {
228 /* The FIFO port is accessible */
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900229 if (usbhs_read(priv, fifo->ctr) & FRDY)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900230 return 0;
231
232 udelay(10);
233 } while (timeout--);
234
235 return -EBUSY;
236}
237
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900238static void usbhsf_fifo_clear(struct usbhs_pipe *pipe,
239 struct usbhs_fifo *fifo)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900240{
241 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
242
243 if (!usbhs_pipe_is_dcp(pipe))
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900244 usbhsf_fifo_barrier(priv, fifo);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900245
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900246 usbhs_write(priv, fifo->ctr, BCLR);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900247}
248
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900249static int usbhsf_fifo_rcv_len(struct usbhs_priv *priv,
250 struct usbhs_fifo *fifo)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900251{
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900252 return usbhs_read(priv, fifo->ctr) & DTLN_MASK;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900253}
254
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900255static void usbhsf_fifo_unselect(struct usbhs_pipe *pipe,
256 struct usbhs_fifo *fifo)
257{
258 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
259
260 usbhs_pipe_select_fifo(pipe, NULL);
261 usbhs_write(priv, fifo->sel, 0);
262}
263
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900264static int usbhsf_fifo_select(struct usbhs_pipe *pipe,
265 struct usbhs_fifo *fifo,
266 int write)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900267{
268 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
269 struct device *dev = usbhs_priv_to_dev(priv);
270 int timeout = 1024;
271 u16 mask = ((1 << 5) | 0xF); /* mask of ISEL | CURPIPE */
272 u16 base = usbhs_pipe_number(pipe); /* CURPIPE */
273
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900274 if (usbhs_pipe_is_busy(pipe) ||
275 usbhsf_fifo_is_busy(fifo))
276 return -EBUSY;
277
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900278 if (usbhs_pipe_is_dcp(pipe))
279 base |= (1 == write) << 5; /* ISEL */
280
281 /* "base" will be used below */
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900282 usbhs_write(priv, fifo->sel, base | MBW_32);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900283
284 /* check ISEL and CURPIPE value */
285 while (timeout--) {
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900286 if (base == (mask & usbhs_read(priv, fifo->sel))) {
287 usbhs_pipe_select_fifo(pipe, fifo);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900288 return 0;
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900289 }
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900290 udelay(10);
291 }
292
293 dev_err(dev, "fifo select error\n");
294
295 return -EIO;
296}
297
298/*
Kuninori Morimoto233f5192011-07-07 00:23:24 -0700299 * PIO push handler
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900300 */
Kuninori Morimoto0cb7e612011-06-06 14:18:58 +0900301static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900302{
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900303 struct usbhs_pipe *pipe = pkt->pipe;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900304 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900305 struct device *dev = usbhs_priv_to_dev(priv);
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900306 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
307 void __iomem *addr = priv->base + fifo->port;
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900308 u8 *buf;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900309 int maxp = usbhs_pipe_get_maxpacket(pipe);
310 int total_len;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900311 int i, ret, len;
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900312 int is_short;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900313
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900314 ret = usbhsf_fifo_select(pipe, fifo, 1);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900315 if (ret < 0)
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900316 return 0;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900317
Kuninori Morimotodad67392011-06-06 14:18:28 +0900318 ret = usbhs_pipe_is_accessible(pipe);
Kuninori Morimoto4ef85e02011-07-03 17:42:47 -0700319 if (ret < 0) {
320 /* inaccessible pipe is not an error */
321 ret = 0;
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900322 goto usbhs_fifo_write_busy;
Kuninori Morimoto4ef85e02011-07-03 17:42:47 -0700323 }
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900324
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900325 ret = usbhsf_fifo_barrier(priv, fifo);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900326 if (ret < 0)
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900327 goto usbhs_fifo_write_busy;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900328
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900329 buf = pkt->buf + pkt->actual;
330 len = pkt->length - pkt->actual;
331 len = min(len, maxp);
332 total_len = len;
333 is_short = total_len < maxp;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900334
335 /*
336 * FIXME
337 *
338 * 32-bit access only
339 */
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900340 if (len >= 4 && !((unsigned long)buf & 0x03)) {
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900341 iowrite32_rep(addr, buf, len / 4);
342 len %= 4;
343 buf += total_len - len;
344 }
345
346 /* the rest operation */
347 for (i = 0; i < len; i++)
348 iowrite8(buf[i], addr + (0x03 - (i & 0x03)));
349
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900350 /*
351 * variable update
352 */
353 pkt->actual += total_len;
354
355 if (pkt->actual < pkt->length)
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900356 *is_done = 0; /* there are remainder data */
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900357 else if (is_short)
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900358 *is_done = 1; /* short packet */
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900359 else
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900360 *is_done = !pkt->zero; /* send zero packet ? */
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900361
362 /*
363 * pipe/irq handling
364 */
365 if (is_short)
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900366 usbhsf_send_terminator(pipe, fifo);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900367
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900368 usbhsf_tx_irq_ctrl(pipe, !*is_done);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900369 usbhs_pipe_enable(pipe);
370
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900371 dev_dbg(dev, " send %d (%d/ %d/ %d/ %d)\n",
372 usbhs_pipe_number(pipe),
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900373 pkt->length, pkt->actual, *is_done, pkt->zero);
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900374
375 /*
376 * Transmission end
377 */
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900378 if (*is_done) {
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900379 if (usbhs_pipe_is_dcp(pipe))
380 usbhs_dcp_control_transfer_done(pipe);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900381 }
382
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900383 usbhsf_fifo_unselect(pipe, fifo);
384
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900385 return 0;
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900386
387usbhs_fifo_write_busy:
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900388 usbhsf_fifo_unselect(pipe, fifo);
389
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900390 /*
391 * pipe is busy.
392 * retry in interrupt
393 */
394 usbhsf_tx_irq_ctrl(pipe, 1);
395
396 return ret;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900397}
398
Kuninori Morimoto0cb7e612011-06-06 14:18:58 +0900399struct usbhs_pkt_handle usbhs_fifo_pio_push_handler = {
400 .prepare = usbhsf_pio_try_push,
401 .try_run = usbhsf_pio_try_push,
Kuninori Morimotodad67392011-06-06 14:18:28 +0900402};
403
Kuninori Morimoto233f5192011-07-07 00:23:24 -0700404/*
405 * PIO pop handler
406 */
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900407static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900408{
Kuninori Morimotodad67392011-06-06 14:18:28 +0900409 struct usbhs_pipe *pipe = pkt->pipe;
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900410
411 if (usbhs_pipe_is_busy(pipe))
412 return 0;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900413
414 /*
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900415 * pipe enable to prepare packet receive
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900416 */
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900417
418 usbhs_pipe_enable(pipe);
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900419 usbhsf_rx_irq_ctrl(pipe, 1);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900420
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900421 return 0;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900422}
423
Kuninori Morimoto0cb7e612011-06-06 14:18:58 +0900424static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done)
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900425{
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900426 struct usbhs_pipe *pipe = pkt->pipe;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900427 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900428 struct device *dev = usbhs_priv_to_dev(priv);
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900429 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
430 void __iomem *addr = priv->base + fifo->port;
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900431 u8 *buf;
432 u32 data = 0;
433 int maxp = usbhs_pipe_get_maxpacket(pipe);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900434 int rcv_len, len;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900435 int i, ret;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900436 int total_len = 0;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900437
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900438 ret = usbhsf_fifo_select(pipe, fifo, 0);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900439 if (ret < 0)
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900440 return 0;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900441
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900442 ret = usbhsf_fifo_barrier(priv, fifo);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900443 if (ret < 0)
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900444 goto usbhs_fifo_read_busy;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900445
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900446 rcv_len = usbhsf_fifo_rcv_len(priv, fifo);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900447
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900448 buf = pkt->buf + pkt->actual;
449 len = pkt->length - pkt->actual;
450 len = min(len, rcv_len);
451 total_len = len;
452
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900453 /*
454 * Buffer clear if Zero-Length packet
455 *
456 * see
457 * "Operation" - "FIFO Buffer Memory" - "FIFO Port Function"
458 */
459 if (0 == rcv_len) {
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900460 usbhsf_fifo_clear(pipe, fifo);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900461 goto usbhs_fifo_read_end;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900462 }
463
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900464 /*
465 * FIXME
466 *
467 * 32-bit access only
468 */
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900469 if (len >= 4 && !((unsigned long)buf & 0x03)) {
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900470 ioread32_rep(addr, buf, len / 4);
471 len %= 4;
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900472 buf += total_len - len;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900473 }
474
475 /* the rest operation */
476 for (i = 0; i < len; i++) {
477 if (!(i & 0x03))
478 data = ioread32(addr);
479
480 buf[i] = (data >> ((i & 0x03) * 8)) & 0xff;
481 }
482
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900483 pkt->actual += total_len;
484
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900485usbhs_fifo_read_end:
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900486 if ((pkt->actual == pkt->length) || /* receive all data */
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900487 (total_len < maxp)) { /* short packet */
488 *is_done = 1;
489 usbhsf_rx_irq_ctrl(pipe, 0);
490 usbhs_pipe_disable(pipe);
491 }
Kuninori Morimoto659d4952011-06-06 14:18:23 +0900492
493 dev_dbg(dev, " recv %d (%d/ %d/ %d/ %d)\n",
494 usbhs_pipe_number(pipe),
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900495 pkt->length, pkt->actual, *is_done, pkt->zero);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +0900496
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900497usbhs_fifo_read_busy:
498 usbhsf_fifo_unselect(pipe, fifo);
499
500 return ret;
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +0900501}
Kuninori Morimotodad67392011-06-06 14:18:28 +0900502
Kuninori Morimoto0cb7e612011-06-06 14:18:58 +0900503struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler = {
Kuninori Morimotodad67392011-06-06 14:18:28 +0900504 .prepare = usbhsf_prepare_pop,
Kuninori Morimoto0cb7e612011-06-06 14:18:58 +0900505 .try_run = usbhsf_pio_try_pop,
Kuninori Morimotodad67392011-06-06 14:18:28 +0900506};
507
508/*
Kuninori Morimoto233f5192011-07-07 00:23:24 -0700509 * DCP ctrol statge handler
Kuninori Morimotodad67392011-06-06 14:18:28 +0900510 */
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900511static int usbhsf_ctrl_stage_end(struct usbhs_pkt *pkt, int *is_done)
Kuninori Morimotodad67392011-06-06 14:18:28 +0900512{
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900513 usbhs_dcp_control_transfer_done(pkt->pipe);
Kuninori Morimotodad67392011-06-06 14:18:28 +0900514
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900515 *is_done = 1;
Kuninori Morimotodad67392011-06-06 14:18:28 +0900516
517 return 0;
518}
519
520struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler = {
521 .prepare = usbhsf_ctrl_stage_end,
522 .try_run = usbhsf_ctrl_stage_end,
523};
524
525/*
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900526 * DMA fifo functions
527 */
528static struct dma_chan *usbhsf_dma_chan_get(struct usbhs_fifo *fifo,
529 struct usbhs_pkt *pkt)
530{
531 if (&usbhs_fifo_dma_push_handler == pkt->handler)
532 return fifo->tx_chan;
533
534 if (&usbhs_fifo_dma_pop_handler == pkt->handler)
535 return fifo->rx_chan;
536
537 return NULL;
538}
539
540static struct usbhs_fifo *usbhsf_get_dma_fifo(struct usbhs_priv *priv,
541 struct usbhs_pkt *pkt)
542{
543 struct usbhs_fifo *fifo;
544
545 /* DMA :: D0FIFO */
546 fifo = usbhsf_get_d0fifo(priv);
547 if (usbhsf_dma_chan_get(fifo, pkt) &&
548 !usbhsf_fifo_is_busy(fifo))
549 return fifo;
550
551 /* DMA :: D1FIFO */
552 fifo = usbhsf_get_d1fifo(priv);
553 if (usbhsf_dma_chan_get(fifo, pkt) &&
554 !usbhsf_fifo_is_busy(fifo))
555 return fifo;
556
557 return NULL;
558}
559
560#define usbhsf_dma_start(p, f) __usbhsf_dma_ctrl(p, f, DREQE)
561#define usbhsf_dma_stop(p, f) __usbhsf_dma_ctrl(p, f, 0)
562static void __usbhsf_dma_ctrl(struct usbhs_pipe *pipe,
563 struct usbhs_fifo *fifo,
564 u16 dreqe)
565{
566 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
567
568 usbhs_bset(priv, fifo->sel, DREQE, dreqe);
569}
570
571#define usbhsf_dma_map(p) __usbhsf_dma_map_ctrl(p, 1)
572#define usbhsf_dma_unmap(p) __usbhsf_dma_map_ctrl(p, 0)
573static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
574{
575 struct usbhs_pipe *pipe = pkt->pipe;
576 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
577 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
578
579 return info->dma_map_ctrl(pkt, map);
580}
581
582static void usbhsf_dma_complete(void *arg);
583static void usbhsf_dma_prepare_tasklet(unsigned long data)
584{
585 struct usbhs_pkt *pkt = (struct usbhs_pkt *)data;
586 struct usbhs_pipe *pipe = pkt->pipe;
587 struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe);
588 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
589 struct scatterlist sg;
590 struct dma_async_tx_descriptor *desc;
591 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt);
592 struct device *dev = usbhs_priv_to_dev(priv);
593 enum dma_data_direction dir;
594 dma_cookie_t cookie;
595
596 dir = usbhs_pipe_is_dir_in(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
597
598 sg_init_table(&sg, 1);
599 sg_set_page(&sg, virt_to_page(pkt->dma),
600 pkt->length, offset_in_page(pkt->dma));
601 sg_dma_address(&sg) = pkt->dma + pkt->actual;
602 sg_dma_len(&sg) = pkt->trans;
603
604 desc = chan->device->device_prep_slave_sg(chan, &sg, 1, dir,
605 DMA_PREP_INTERRUPT |
606 DMA_CTRL_ACK);
607 if (!desc)
608 return;
609
610 desc->callback = usbhsf_dma_complete;
611 desc->callback_param = pipe;
612
613 cookie = desc->tx_submit(desc);
614 if (cookie < 0) {
615 dev_err(dev, "Failed to submit dma descriptor\n");
616 return;
617 }
618
619 dev_dbg(dev, " %s %d (%d/ %d)\n",
620 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero);
621
622 usbhsf_dma_start(pipe, fifo);
623 dma_async_issue_pending(chan);
624}
625
Kuninori Morimoto233f5192011-07-07 00:23:24 -0700626/*
627 * DMA push handler
628 */
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900629static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
630{
631 struct usbhs_pipe *pipe = pkt->pipe;
632 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
633 struct usbhs_fifo *fifo;
634 int len = pkt->length - pkt->actual;
635 int ret;
636
637 if (usbhs_pipe_is_busy(pipe))
638 return 0;
639
640 /* use PIO if packet is less than pio_dma_border or pipe is DCP */
641 if ((len < usbhs_get_dparam(priv, pio_dma_border)) ||
642 usbhs_pipe_is_dcp(pipe))
643 goto usbhsf_pio_prepare_push;
644
645 if (len % 4) /* 32bit alignment */
646 goto usbhsf_pio_prepare_push;
647
Kuninori Morimoto9a12d092011-07-03 17:42:19 -0700648 if (((u32)pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
649 goto usbhsf_pio_prepare_push;
650
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900651 /* get enable DMA fifo */
652 fifo = usbhsf_get_dma_fifo(priv, pkt);
653 if (!fifo)
654 goto usbhsf_pio_prepare_push;
655
656 if (usbhsf_dma_map(pkt) < 0)
657 goto usbhsf_pio_prepare_push;
658
659 ret = usbhsf_fifo_select(pipe, fifo, 0);
660 if (ret < 0)
661 goto usbhsf_pio_prepare_push_unmap;
662
663 pkt->trans = len;
664
665 tasklet_init(&fifo->tasklet,
666 usbhsf_dma_prepare_tasklet,
667 (unsigned long)pkt);
668
669 tasklet_schedule(&fifo->tasklet);
670
671 return 0;
672
673usbhsf_pio_prepare_push_unmap:
674 usbhsf_dma_unmap(pkt);
675usbhsf_pio_prepare_push:
676 /*
677 * change handler to PIO
678 */
679 pkt->handler = &usbhs_fifo_pio_push_handler;
680
681 return pkt->handler->prepare(pkt, is_done);
682}
683
684static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done)
685{
686 struct usbhs_pipe *pipe = pkt->pipe;
687
688 pkt->actual = pkt->trans;
689
690 *is_done = !pkt->zero; /* send zero packet ? */
691
692 usbhsf_dma_stop(pipe, pipe->fifo);
693 usbhsf_dma_unmap(pkt);
694 usbhsf_fifo_unselect(pipe, pipe->fifo);
695
696 return 0;
697}
698
699struct usbhs_pkt_handle usbhs_fifo_dma_push_handler = {
700 .prepare = usbhsf_dma_prepare_push,
701 .dma_done = usbhsf_dma_push_done,
702};
703
Kuninori Morimoto233f5192011-07-07 00:23:24 -0700704/*
705 * DMA pop handler
706 */
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900707static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done)
708{
709 struct usbhs_pipe *pipe = pkt->pipe;
710 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
711 struct usbhs_fifo *fifo;
712 int len, ret;
713
714 if (usbhs_pipe_is_busy(pipe))
715 return 0;
716
717 if (usbhs_pipe_is_dcp(pipe))
718 goto usbhsf_pio_prepare_pop;
719
720 /* get enable DMA fifo */
721 fifo = usbhsf_get_dma_fifo(priv, pkt);
722 if (!fifo)
723 goto usbhsf_pio_prepare_pop;
724
Kuninori Morimoto9a12d092011-07-03 17:42:19 -0700725 if (((u32)pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
726 goto usbhsf_pio_prepare_pop;
727
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900728 ret = usbhsf_fifo_select(pipe, fifo, 0);
729 if (ret < 0)
730 goto usbhsf_pio_prepare_pop;
731
732 /* use PIO if packet is less than pio_dma_border */
733 len = usbhsf_fifo_rcv_len(priv, fifo);
734 len = min(pkt->length - pkt->actual, len);
735 if (len % 4) /* 32bit alignment */
736 goto usbhsf_pio_prepare_pop_unselect;
737
738 if (len < usbhs_get_dparam(priv, pio_dma_border))
739 goto usbhsf_pio_prepare_pop_unselect;
740
741 ret = usbhsf_fifo_barrier(priv, fifo);
742 if (ret < 0)
743 goto usbhsf_pio_prepare_pop_unselect;
744
745 if (usbhsf_dma_map(pkt) < 0)
746 goto usbhsf_pio_prepare_pop_unselect;
747
748 /* DMA */
749
750 /*
751 * usbhs_fifo_dma_pop_handler :: prepare
752 * enabled irq to come here.
753 * but it is no longer needed for DMA. disable it.
754 */
755 usbhsf_rx_irq_ctrl(pipe, 0);
756
757 pkt->trans = len;
758
759 tasklet_init(&fifo->tasklet,
760 usbhsf_dma_prepare_tasklet,
761 (unsigned long)pkt);
762
763 tasklet_schedule(&fifo->tasklet);
764
765 return 0;
766
767usbhsf_pio_prepare_pop_unselect:
768 usbhsf_fifo_unselect(pipe, fifo);
769usbhsf_pio_prepare_pop:
770
771 /*
772 * change handler to PIO
773 */
774 pkt->handler = &usbhs_fifo_pio_pop_handler;
775
776 return pkt->handler->try_run(pkt, is_done);
777}
778
779static int usbhsf_dma_pop_done(struct usbhs_pkt *pkt, int *is_done)
780{
781 struct usbhs_pipe *pipe = pkt->pipe;
782 int maxp = usbhs_pipe_get_maxpacket(pipe);
783
784 usbhsf_dma_stop(pipe, pipe->fifo);
785 usbhsf_dma_unmap(pkt);
786 usbhsf_fifo_unselect(pipe, pipe->fifo);
787
788 pkt->actual += pkt->trans;
789
790 if ((pkt->actual == pkt->length) || /* receive all data */
791 (pkt->trans < maxp)) { /* short packet */
792 *is_done = 1;
793 } else {
794 /* re-enable */
795 usbhsf_prepare_pop(pkt, is_done);
796 }
797
798 return 0;
799}
800
801struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler = {
802 .prepare = usbhsf_prepare_pop,
803 .try_run = usbhsf_dma_try_pop,
804 .dma_done = usbhsf_dma_pop_done
805};
806
807/*
808 * DMA setting
809 */
810static bool usbhsf_dma_filter(struct dma_chan *chan, void *param)
811{
812 struct sh_dmae_slave *slave = param;
813
814 /*
815 * FIXME
816 *
817 * usbhs doesn't recognize id = 0 as valid DMA
818 */
819 if (0 == slave->slave_id)
820 return false;
821
822 chan->private = slave;
823
824 return true;
825}
826
827static void usbhsf_dma_quit(struct usbhs_priv *priv, struct usbhs_fifo *fifo)
828{
829 if (fifo->tx_chan)
830 dma_release_channel(fifo->tx_chan);
831 if (fifo->rx_chan)
832 dma_release_channel(fifo->rx_chan);
833
834 fifo->tx_chan = NULL;
835 fifo->rx_chan = NULL;
836}
837
838static void usbhsf_dma_init(struct usbhs_priv *priv,
839 struct usbhs_fifo *fifo)
840{
841 struct device *dev = usbhs_priv_to_dev(priv);
842 dma_cap_mask_t mask;
843
844 dma_cap_zero(mask);
845 dma_cap_set(DMA_SLAVE, mask);
846 fifo->tx_chan = dma_request_channel(mask, usbhsf_dma_filter,
847 &fifo->tx_slave);
848
849 dma_cap_zero(mask);
850 dma_cap_set(DMA_SLAVE, mask);
851 fifo->rx_chan = dma_request_channel(mask, usbhsf_dma_filter,
852 &fifo->rx_slave);
853
854 if (fifo->tx_chan || fifo->rx_chan)
Kuninori Morimoto4ce68802011-06-21 09:33:43 +0900855 dev_dbg(dev, "enable DMAEngine (%s%s%s)\n",
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900856 fifo->name,
857 fifo->tx_chan ? "[TX]" : " ",
858 fifo->rx_chan ? "[RX]" : " ");
859}
860
861/*
Kuninori Morimotodad67392011-06-06 14:18:28 +0900862 * irq functions
863 */
864static int usbhsf_irq_empty(struct usbhs_priv *priv,
865 struct usbhs_irq_state *irq_state)
866{
867 struct usbhs_pipe *pipe;
Kuninori Morimotodad67392011-06-06 14:18:28 +0900868 struct device *dev = usbhs_priv_to_dev(priv);
869 int i, ret;
870
871 if (!irq_state->bempsts) {
872 dev_err(dev, "debug %s !!\n", __func__);
873 return -EIO;
874 }
875
876 dev_dbg(dev, "irq empty [0x%04x]\n", irq_state->bempsts);
877
878 /*
879 * search interrupted "pipe"
880 * not "uep".
881 */
882 usbhs_for_each_pipe_with_dcp(pipe, priv, i) {
883 if (!(irq_state->bempsts & (1 << i)))
884 continue;
885
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900886 ret = usbhs_pkt_run(pipe);
Kuninori Morimotodad67392011-06-06 14:18:28 +0900887 if (ret < 0)
888 dev_err(dev, "irq_empty run_error %d : %d\n", i, ret);
889 }
890
891 return 0;
892}
893
894static int usbhsf_irq_ready(struct usbhs_priv *priv,
895 struct usbhs_irq_state *irq_state)
896{
897 struct usbhs_pipe *pipe;
Kuninori Morimotodad67392011-06-06 14:18:28 +0900898 struct device *dev = usbhs_priv_to_dev(priv);
899 int i, ret;
900
901 if (!irq_state->brdysts) {
902 dev_err(dev, "debug %s !!\n", __func__);
903 return -EIO;
904 }
905
906 dev_dbg(dev, "irq ready [0x%04x]\n", irq_state->brdysts);
907
908 /*
909 * search interrupted "pipe"
910 * not "uep".
911 */
912 usbhs_for_each_pipe_with_dcp(pipe, priv, i) {
913 if (!(irq_state->brdysts & (1 << i)))
914 continue;
915
Kuninori Morimoto97664a22011-06-06 14:18:38 +0900916 ret = usbhs_pkt_run(pipe);
Kuninori Morimotodad67392011-06-06 14:18:28 +0900917 if (ret < 0)
918 dev_err(dev, "irq_ready run_error %d : %d\n", i, ret);
919 }
920
921 return 0;
922}
923
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900924static void usbhsf_dma_complete(void *arg)
925{
926 struct usbhs_pipe *pipe = arg;
927 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
928 struct device *dev = usbhs_priv_to_dev(priv);
929 int ret;
930
931 ret = usbhs_pkt_dmadone(pipe);
932 if (ret < 0)
933 dev_err(dev, "dma_complete run_error %d : %d\n",
934 usbhs_pipe_number(pipe), ret);
935}
936
Kuninori Morimotodad67392011-06-06 14:18:28 +0900937/*
938 * fifo init
939 */
940void usbhs_fifo_init(struct usbhs_priv *priv)
941{
942 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900943 struct usbhs_fifo *cfifo = usbhsf_get_cfifo(priv);
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900944 struct usbhs_fifo *d0fifo = usbhsf_get_d0fifo(priv);
945 struct usbhs_fifo *d1fifo = usbhsf_get_d1fifo(priv);
Kuninori Morimotodad67392011-06-06 14:18:28 +0900946
947 mod->irq_empty = usbhsf_irq_empty;
948 mod->irq_ready = usbhsf_irq_ready;
949 mod->irq_bempsts = 0;
950 mod->irq_brdysts = 0;
Kuninori Morimotod77e3f42011-06-06 14:18:50 +0900951
952 cfifo->pipe = NULL;
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900953 cfifo->tx_chan = NULL;
954 cfifo->rx_chan = NULL;
955
956 d0fifo->pipe = NULL;
957 d0fifo->tx_chan = NULL;
958 d0fifo->rx_chan = NULL;
959
960 d1fifo->pipe = NULL;
961 d1fifo->tx_chan = NULL;
962 d1fifo->rx_chan = NULL;
963
964 usbhsf_dma_init(priv, usbhsf_get_d0fifo(priv));
965 usbhsf_dma_init(priv, usbhsf_get_d1fifo(priv));
Kuninori Morimotodad67392011-06-06 14:18:28 +0900966}
967
968void usbhs_fifo_quit(struct usbhs_priv *priv)
969{
970 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
971
972 mod->irq_empty = NULL;
973 mod->irq_ready = NULL;
974 mod->irq_bempsts = 0;
975 mod->irq_brdysts = 0;
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900976
977 usbhsf_dma_quit(priv, usbhsf_get_d0fifo(priv));
978 usbhsf_dma_quit(priv, usbhsf_get_d1fifo(priv));
Kuninori Morimotodad67392011-06-06 14:18:28 +0900979}
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900980
981int usbhs_fifo_probe(struct usbhs_priv *priv)
982{
983 struct usbhs_fifo *fifo;
984
985 /* CFIFO */
986 fifo = usbhsf_get_cfifo(priv);
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900987 fifo->name = "CFIFO";
Kuninori Morimotod3af90a2011-06-06 14:18:44 +0900988 fifo->port = CFIFO;
989 fifo->sel = CFIFOSEL;
990 fifo->ctr = CFIFOCTR;
991
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900992 /* D0FIFO */
993 fifo = usbhsf_get_d0fifo(priv);
994 fifo->name = "D0FIFO";
995 fifo->port = D0FIFO;
996 fifo->sel = D0FIFOSEL;
997 fifo->ctr = D0FIFOCTR;
998 fifo->tx_slave.slave_id = usbhs_get_dparam(priv, d0_tx_id);
999 fifo->rx_slave.slave_id = usbhs_get_dparam(priv, d0_rx_id);
1000
1001 /* D1FIFO */
1002 fifo = usbhsf_get_d1fifo(priv);
1003 fifo->name = "D1FIFO";
1004 fifo->port = D1FIFO;
1005 fifo->sel = D1FIFOSEL;
1006 fifo->ctr = D1FIFOCTR;
1007 fifo->tx_slave.slave_id = usbhs_get_dparam(priv, d1_tx_id);
1008 fifo->rx_slave.slave_id = usbhs_get_dparam(priv, d1_rx_id);
1009
Kuninori Morimotod3af90a2011-06-06 14:18:44 +09001010 return 0;
1011}
1012
1013void usbhs_fifo_remove(struct usbhs_priv *priv)
1014{
1015}