.. | .. |
---|
3 | 3 | * Renesas USB driver |
---|
4 | 4 | * |
---|
5 | 5 | * Copyright (C) 2011 Renesas Solutions Corp. |
---|
| 6 | + * Copyright (C) 2019 Renesas Electronics Corporation |
---|
6 | 7 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
---|
7 | 8 | */ |
---|
8 | 9 | #include <linux/delay.h> |
---|
.. | .. |
---|
12 | 13 | #include "pipe.h" |
---|
13 | 14 | |
---|
14 | 15 | #define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo)) |
---|
15 | | -#define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f) |
---|
16 | 16 | |
---|
17 | 17 | #define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */ |
---|
18 | 18 | |
---|
.. | .. |
---|
333 | 333 | } |
---|
334 | 334 | |
---|
335 | 335 | /* "base" will be used below */ |
---|
336 | | - if (usbhs_get_dparam(priv, has_sudmac) && !usbhsf_is_cfifo(priv, fifo)) |
---|
337 | | - usbhs_write(priv, fifo->sel, base); |
---|
338 | | - else |
---|
339 | | - usbhs_write(priv, fifo->sel, base | MBW_32); |
---|
| 336 | + usbhs_write(priv, fifo->sel, base | MBW_32); |
---|
340 | 337 | |
---|
341 | 338 | /* check ISEL and CURPIPE value */ |
---|
342 | 339 | while (timeout--) { |
---|
.. | .. |
---|
551 | 548 | } |
---|
552 | 549 | |
---|
553 | 550 | /* the rest operation */ |
---|
554 | | - for (i = 0; i < len; i++) |
---|
555 | | - iowrite8(buf[i], addr + (0x03 - (i & 0x03))); |
---|
| 551 | + if (usbhs_get_dparam(priv, cfifo_byte_addr)) { |
---|
| 552 | + for (i = 0; i < len; i++) |
---|
| 553 | + iowrite8(buf[i], addr + (i & 0x03)); |
---|
| 554 | + } else { |
---|
| 555 | + for (i = 0; i < len; i++) |
---|
| 556 | + iowrite8(buf[i], addr + (0x03 - (i & 0x03))); |
---|
| 557 | + } |
---|
556 | 558 | |
---|
557 | 559 | /* |
---|
558 | 560 | * variable update |
---|
.. | .. |
---|
809 | 811 | return info->dma_map_ctrl(chan->device->dev, pkt, map); |
---|
810 | 812 | } |
---|
811 | 813 | |
---|
812 | | -static void usbhsf_dma_complete(void *arg); |
---|
| 814 | +static void usbhsf_dma_complete(void *arg, |
---|
| 815 | + const struct dmaengine_result *result); |
---|
813 | 816 | static void usbhsf_dma_xfer_preparing(struct usbhs_pkt *pkt) |
---|
814 | 817 | { |
---|
815 | 818 | struct usbhs_pipe *pipe = pkt->pipe; |
---|
.. | .. |
---|
819 | 822 | struct dma_chan *chan; |
---|
820 | 823 | struct device *dev = usbhs_priv_to_dev(priv); |
---|
821 | 824 | enum dma_transfer_direction dir; |
---|
| 825 | + dma_cookie_t cookie; |
---|
822 | 826 | |
---|
823 | 827 | fifo = usbhs_pipe_to_fifo(pipe); |
---|
824 | 828 | if (!fifo) |
---|
.. | .. |
---|
833 | 837 | if (!desc) |
---|
834 | 838 | return; |
---|
835 | 839 | |
---|
836 | | - desc->callback = usbhsf_dma_complete; |
---|
837 | | - desc->callback_param = pipe; |
---|
| 840 | + desc->callback_result = usbhsf_dma_complete; |
---|
| 841 | + desc->callback_param = pkt; |
---|
838 | 842 | |
---|
839 | | - pkt->cookie = dmaengine_submit(desc); |
---|
840 | | - if (pkt->cookie < 0) { |
---|
| 843 | + cookie = dmaengine_submit(desc); |
---|
| 844 | + if (cookie < 0) { |
---|
841 | 845 | dev_err(dev, "Failed to submit dma descriptor\n"); |
---|
842 | 846 | return; |
---|
843 | 847 | } |
---|
.. | .. |
---|
1158 | 1162 | struct dma_chan *chan, int dtln) |
---|
1159 | 1163 | { |
---|
1160 | 1164 | struct usbhs_pipe *pipe = pkt->pipe; |
---|
1161 | | - struct dma_tx_state state; |
---|
1162 | 1165 | size_t received_size; |
---|
1163 | 1166 | int maxp = usbhs_pipe_get_maxpacket(pipe); |
---|
1164 | 1167 | |
---|
1165 | | - dmaengine_tx_status(chan, pkt->cookie, &state); |
---|
1166 | | - received_size = pkt->length - state.residue; |
---|
| 1168 | + received_size = pkt->length - pkt->dma_result->residue; |
---|
1167 | 1169 | |
---|
1168 | 1170 | if (dtln) { |
---|
1169 | 1171 | received_size -= USBHS_USB_DMAC_XFER_SIZE; |
---|
.. | .. |
---|
1279 | 1281 | */ |
---|
1280 | 1282 | snprintf(name, sizeof(name), "ch%d", channel); |
---|
1281 | 1283 | if (channel & 1) { |
---|
1282 | | - fifo->tx_chan = dma_request_slave_channel_reason(dev, name); |
---|
| 1284 | + fifo->tx_chan = dma_request_chan(dev, name); |
---|
1283 | 1285 | if (IS_ERR(fifo->tx_chan)) |
---|
1284 | 1286 | fifo->tx_chan = NULL; |
---|
1285 | 1287 | } else { |
---|
1286 | | - fifo->rx_chan = dma_request_slave_channel_reason(dev, name); |
---|
| 1288 | + fifo->rx_chan = dma_request_chan(dev, name); |
---|
1287 | 1289 | if (IS_ERR(fifo->rx_chan)) |
---|
1288 | 1290 | fifo->rx_chan = NULL; |
---|
1289 | 1291 | } |
---|
.. | .. |
---|
1294 | 1296 | { |
---|
1295 | 1297 | struct device *dev = usbhs_priv_to_dev(priv); |
---|
1296 | 1298 | |
---|
1297 | | - if (dev->of_node) |
---|
| 1299 | + if (dev_of_node(dev)) |
---|
1298 | 1300 | usbhsf_dma_init_dt(dev, fifo, channel); |
---|
1299 | 1301 | else |
---|
1300 | 1302 | usbhsf_dma_init_pdev(fifo); |
---|
.. | .. |
---|
1369 | 1371 | return 0; |
---|
1370 | 1372 | } |
---|
1371 | 1373 | |
---|
1372 | | -static void usbhsf_dma_complete(void *arg) |
---|
| 1374 | +static void usbhsf_dma_complete(void *arg, |
---|
| 1375 | + const struct dmaengine_result *result) |
---|
1373 | 1376 | { |
---|
1374 | | - struct usbhs_pipe *pipe = arg; |
---|
| 1377 | + struct usbhs_pkt *pkt = arg; |
---|
| 1378 | + struct usbhs_pipe *pipe = pkt->pipe; |
---|
1375 | 1379 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); |
---|
1376 | 1380 | struct device *dev = usbhs_priv_to_dev(priv); |
---|
1377 | 1381 | int ret; |
---|
1378 | 1382 | |
---|
| 1383 | + pkt->dma_result = result; |
---|
1379 | 1384 | ret = usbhsf_pkt_handler(pipe, USBHSF_PKT_DMA_DONE); |
---|
1380 | 1385 | if (ret < 0) |
---|
1381 | 1386 | dev_err(dev, "dma_complete run_error %d : %d\n", |
---|