aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs/fifo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/renesas_usbhs/fifo.c')
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c111
1 files changed, 57 insertions, 54 deletions
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index b0c97a3f1bfe..f46271ce1b15 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -21,8 +21,6 @@
21#include "pipe.h" 21#include "pipe.h"
22 22
23#define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo)) 23#define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo))
24#define usbhsf_get_d0fifo(p) (&((p)->fifo_info.d0fifo))
25#define usbhsf_get_d1fifo(p) (&((p)->fifo_info.d1fifo))
26#define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f) 24#define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f)
27 25
28#define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */ 26#define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */
@@ -577,14 +575,6 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
577 usbhs_pipe_number(pipe), 575 usbhs_pipe_number(pipe),
578 pkt->length, pkt->actual, *is_done, pkt->zero); 576 pkt->length, pkt->actual, *is_done, pkt->zero);
579 577
580 /*
581 * Transmission end
582 */
583 if (*is_done) {
584 if (usbhs_pipe_is_dcp(pipe))
585 usbhs_dcp_control_transfer_done(pipe);
586 }
587
588 usbhsf_fifo_unselect(pipe, fifo); 578 usbhsf_fifo_unselect(pipe, fifo);
589 579
590 return 0; 580 return 0;
@@ -722,14 +712,6 @@ usbhs_fifo_read_end:
722 usbhs_pipe_number(pipe), 712 usbhs_pipe_number(pipe),
723 pkt->length, pkt->actual, *is_done, pkt->zero); 713 pkt->length, pkt->actual, *is_done, pkt->zero);
724 714
725 /*
726 * Transmission end
727 */
728 if (*is_done) {
729 if (usbhs_pipe_is_dcp(pipe))
730 usbhs_dcp_control_transfer_done(pipe);
731 }
732
733usbhs_fifo_read_busy: 715usbhs_fifo_read_busy:
734 usbhsf_fifo_unselect(pipe, fifo); 716 usbhsf_fifo_unselect(pipe, fifo);
735 717
@@ -777,18 +759,13 @@ static struct usbhs_fifo *usbhsf_get_dma_fifo(struct usbhs_priv *priv,
777 struct usbhs_pkt *pkt) 759 struct usbhs_pkt *pkt)
778{ 760{
779 struct usbhs_fifo *fifo; 761 struct usbhs_fifo *fifo;
762 int i;
780 763
781 /* DMA :: D0FIFO */ 764 usbhs_for_each_dfifo(priv, fifo, i) {
782 fifo = usbhsf_get_d0fifo(priv); 765 if (usbhsf_dma_chan_get(fifo, pkt) &&
783 if (usbhsf_dma_chan_get(fifo, pkt) && 766 !usbhsf_fifo_is_busy(fifo))
784 !usbhsf_fifo_is_busy(fifo)) 767 return fifo;
785 return fifo; 768 }
786
787 /* DMA :: D1FIFO */
788 fifo = usbhsf_get_d1fifo(priv);
789 if (usbhsf_dma_chan_get(fifo, pkt) &&
790 !usbhsf_fifo_is_busy(fifo))
791 return fifo;
792 769
793 return NULL; 770 return NULL;
794} 771}
@@ -1176,6 +1153,24 @@ static void usbhsf_dma_complete(void *arg)
1176 usbhs_pipe_number(pipe), ret); 1153 usbhs_pipe_number(pipe), ret);
1177} 1154}
1178 1155
1156void usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe)
1157{
1158 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
1159 struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
1160
1161 /* clear DCP FIFO of transmission */
1162 if (usbhsf_fifo_select(pipe, fifo, 1) < 0)
1163 return;
1164 usbhsf_fifo_clear(pipe, fifo);
1165 usbhsf_fifo_unselect(pipe, fifo);
1166
1167 /* clear DCP FIFO of reception */
1168 if (usbhsf_fifo_select(pipe, fifo, 0) < 0)
1169 return;
1170 usbhsf_fifo_clear(pipe, fifo);
1171 usbhsf_fifo_unselect(pipe, fifo);
1172}
1173
1179/* 1174/*
1180 * fifo init 1175 * fifo init
1181 */ 1176 */
@@ -1183,8 +1178,8 @@ void usbhs_fifo_init(struct usbhs_priv *priv)
1183{ 1178{
1184 struct usbhs_mod *mod = usbhs_mod_get_current(priv); 1179 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
1185 struct usbhs_fifo *cfifo = usbhsf_get_cfifo(priv); 1180 struct usbhs_fifo *cfifo = usbhsf_get_cfifo(priv);
1186 struct usbhs_fifo *d0fifo = usbhsf_get_d0fifo(priv); 1181 struct usbhs_fifo *dfifo;
1187 struct usbhs_fifo *d1fifo = usbhsf_get_d1fifo(priv); 1182 int i;
1188 1183
1189 mod->irq_empty = usbhsf_irq_empty; 1184 mod->irq_empty = usbhsf_irq_empty;
1190 mod->irq_ready = usbhsf_irq_ready; 1185 mod->irq_ready = usbhsf_irq_ready;
@@ -1192,8 +1187,8 @@ void usbhs_fifo_init(struct usbhs_priv *priv)
1192 mod->irq_brdysts = 0; 1187 mod->irq_brdysts = 0;
1193 1188
1194 cfifo->pipe = NULL; 1189 cfifo->pipe = NULL;
1195 d0fifo->pipe = NULL; 1190 usbhs_for_each_dfifo(priv, dfifo, i)
1196 d1fifo->pipe = NULL; 1191 dfifo->pipe = NULL;
1197} 1192}
1198 1193
1199void usbhs_fifo_quit(struct usbhs_priv *priv) 1194void usbhs_fifo_quit(struct usbhs_priv *priv)
@@ -1206,6 +1201,25 @@ void usbhs_fifo_quit(struct usbhs_priv *priv)
1206 mod->irq_brdysts = 0; 1201 mod->irq_brdysts = 0;
1207} 1202}
1208 1203
1204#define __USBHS_DFIFO_INIT(priv, fifo, channel, fifo_port) \
1205do { \
1206 fifo = usbhsf_get_dnfifo(priv, channel); \
1207 fifo->name = "D"#channel"FIFO"; \
1208 fifo->port = fifo_port; \
1209 fifo->sel = D##channel##FIFOSEL; \
1210 fifo->ctr = D##channel##FIFOCTR; \
1211 fifo->tx_slave.shdma_slave.slave_id = \
1212 usbhs_get_dparam(priv, d##channel##_tx_id); \
1213 fifo->rx_slave.shdma_slave.slave_id = \
1214 usbhs_get_dparam(priv, d##channel##_rx_id); \
1215 usbhsf_dma_init(priv, fifo); \
1216} while (0)
1217
1218#define USBHS_DFIFO_INIT(priv, fifo, channel) \
1219 __USBHS_DFIFO_INIT(priv, fifo, channel, D##channel##FIFO)
1220#define USBHS_DFIFO_INIT_NO_PORT(priv, fifo, channel) \
1221 __USBHS_DFIFO_INIT(priv, fifo, channel, 0)
1222
1209int usbhs_fifo_probe(struct usbhs_priv *priv) 1223int usbhs_fifo_probe(struct usbhs_priv *priv)
1210{ 1224{
1211 struct usbhs_fifo *fifo; 1225 struct usbhs_fifo *fifo;
@@ -1217,31 +1231,20 @@ int usbhs_fifo_probe(struct usbhs_priv *priv)
1217 fifo->sel = CFIFOSEL; 1231 fifo->sel = CFIFOSEL;
1218 fifo->ctr = CFIFOCTR; 1232 fifo->ctr = CFIFOCTR;
1219 1233
1220 /* D0FIFO */ 1234 /* DFIFO */
1221 fifo = usbhsf_get_d0fifo(priv); 1235 USBHS_DFIFO_INIT(priv, fifo, 0);
1222 fifo->name = "D0FIFO"; 1236 USBHS_DFIFO_INIT(priv, fifo, 1);
1223 fifo->port = D0FIFO; 1237 USBHS_DFIFO_INIT_NO_PORT(priv, fifo, 2);
1224 fifo->sel = D0FIFOSEL; 1238 USBHS_DFIFO_INIT_NO_PORT(priv, fifo, 3);
1225 fifo->ctr = D0FIFOCTR;
1226 fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_tx_id);
1227 fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_rx_id);
1228 usbhsf_dma_init(priv, fifo);
1229
1230 /* D1FIFO */
1231 fifo = usbhsf_get_d1fifo(priv);
1232 fifo->name = "D1FIFO";
1233 fifo->port = D1FIFO;
1234 fifo->sel = D1FIFOSEL;
1235 fifo->ctr = D1FIFOCTR;
1236 fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_tx_id);
1237 fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_rx_id);
1238 usbhsf_dma_init(priv, fifo);
1239 1239
1240 return 0; 1240 return 0;
1241} 1241}
1242 1242
1243void usbhs_fifo_remove(struct usbhs_priv *priv) 1243void usbhs_fifo_remove(struct usbhs_priv *priv)
1244{ 1244{
1245 usbhsf_dma_quit(priv, usbhsf_get_d0fifo(priv)); 1245 struct usbhs_fifo *fifo;
1246 usbhsf_dma_quit(priv, usbhsf_get_d1fifo(priv)); 1246 int i;
1247
1248 usbhs_for_each_dfifo(priv, fifo, i)
1249 usbhsf_dma_quit(priv, fifo);
1247} 1250}