forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/usb/renesas_usbhs/fifo.c
....@@ -3,6 +3,7 @@
33 * Renesas USB driver
44 *
55 * Copyright (C) 2011 Renesas Solutions Corp.
6
+ * Copyright (C) 2019 Renesas Electronics Corporation
67 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
78 */
89 #include <linux/delay.h>
....@@ -12,7 +13,6 @@
1213 #include "pipe.h"
1314
1415 #define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo))
15
-#define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f)
1616
1717 #define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */
1818
....@@ -333,10 +333,7 @@
333333 }
334334
335335 /* "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);
340337
341338 /* check ISEL and CURPIPE value */
342339 while (timeout--) {
....@@ -551,8 +548,13 @@
551548 }
552549
553550 /* 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
+ }
556558
557559 /*
558560 * variable update
....@@ -809,7 +811,8 @@
809811 return info->dma_map_ctrl(chan->device->dev, pkt, map);
810812 }
811813
812
-static void usbhsf_dma_complete(void *arg);
814
+static void usbhsf_dma_complete(void *arg,
815
+ const struct dmaengine_result *result);
813816 static void usbhsf_dma_xfer_preparing(struct usbhs_pkt *pkt)
814817 {
815818 struct usbhs_pipe *pipe = pkt->pipe;
....@@ -819,6 +822,7 @@
819822 struct dma_chan *chan;
820823 struct device *dev = usbhs_priv_to_dev(priv);
821824 enum dma_transfer_direction dir;
825
+ dma_cookie_t cookie;
822826
823827 fifo = usbhs_pipe_to_fifo(pipe);
824828 if (!fifo)
....@@ -833,11 +837,11 @@
833837 if (!desc)
834838 return;
835839
836
- desc->callback = usbhsf_dma_complete;
837
- desc->callback_param = pipe;
840
+ desc->callback_result = usbhsf_dma_complete;
841
+ desc->callback_param = pkt;
838842
839
- pkt->cookie = dmaengine_submit(desc);
840
- if (pkt->cookie < 0) {
843
+ cookie = dmaengine_submit(desc);
844
+ if (cookie < 0) {
841845 dev_err(dev, "Failed to submit dma descriptor\n");
842846 return;
843847 }
....@@ -1158,12 +1162,10 @@
11581162 struct dma_chan *chan, int dtln)
11591163 {
11601164 struct usbhs_pipe *pipe = pkt->pipe;
1161
- struct dma_tx_state state;
11621165 size_t received_size;
11631166 int maxp = usbhs_pipe_get_maxpacket(pipe);
11641167
1165
- dmaengine_tx_status(chan, pkt->cookie, &state);
1166
- received_size = pkt->length - state.residue;
1168
+ received_size = pkt->length - pkt->dma_result->residue;
11671169
11681170 if (dtln) {
11691171 received_size -= USBHS_USB_DMAC_XFER_SIZE;
....@@ -1279,11 +1281,11 @@
12791281 */
12801282 snprintf(name, sizeof(name), "ch%d", channel);
12811283 if (channel & 1) {
1282
- fifo->tx_chan = dma_request_slave_channel_reason(dev, name);
1284
+ fifo->tx_chan = dma_request_chan(dev, name);
12831285 if (IS_ERR(fifo->tx_chan))
12841286 fifo->tx_chan = NULL;
12851287 } else {
1286
- fifo->rx_chan = dma_request_slave_channel_reason(dev, name);
1288
+ fifo->rx_chan = dma_request_chan(dev, name);
12871289 if (IS_ERR(fifo->rx_chan))
12881290 fifo->rx_chan = NULL;
12891291 }
....@@ -1294,7 +1296,7 @@
12941296 {
12951297 struct device *dev = usbhs_priv_to_dev(priv);
12961298
1297
- if (dev->of_node)
1299
+ if (dev_of_node(dev))
12981300 usbhsf_dma_init_dt(dev, fifo, channel);
12991301 else
13001302 usbhsf_dma_init_pdev(fifo);
....@@ -1369,13 +1371,16 @@
13691371 return 0;
13701372 }
13711373
1372
-static void usbhsf_dma_complete(void *arg)
1374
+static void usbhsf_dma_complete(void *arg,
1375
+ const struct dmaengine_result *result)
13731376 {
1374
- struct usbhs_pipe *pipe = arg;
1377
+ struct usbhs_pkt *pkt = arg;
1378
+ struct usbhs_pipe *pipe = pkt->pipe;
13751379 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
13761380 struct device *dev = usbhs_priv_to_dev(priv);
13771381 int ret;
13781382
1383
+ pkt->dma_result = result;
13791384 ret = usbhsf_pkt_handler(pipe, USBHSF_PKT_DMA_DONE);
13801385 if (ret < 0)
13811386 dev_err(dev, "dma_complete run_error %d : %d\n",