diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2014-11-10 06:02:45 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-11-12 10:10:39 -0500 |
commit | 3a2634a5b4aadc08c3bbe316fd03524ca1300572 (patch) | |
tree | 58a08d781ac2ea2cdf05f4f6da7223640a6252fe /drivers/usb/renesas_usbhs | |
parent | c907e423530f40132f258cafb0ec709b30a6bd29 (diff) |
usb: renesas_usbhs: standardize d{0,1}fifo control
To expand DnFIFOs in the future, this patch standardizes the d{0,1}fifo
control using new macros.
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs')
-rw-r--r-- | drivers/usb/renesas_usbhs/fifo.c | 70 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/fifo.h | 5 |
2 files changed, 37 insertions, 38 deletions
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 341508a54c87..6c775b71671a 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.dfifo[0])) | ||
25 | #define usbhsf_get_d1fifo(p) (&((p)->fifo_info.dfifo[1])) | ||
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 */ |
@@ -761,18 +759,13 @@ static struct usbhs_fifo *usbhsf_get_dma_fifo(struct usbhs_priv *priv, | |||
761 | struct usbhs_pkt *pkt) | 759 | struct usbhs_pkt *pkt) |
762 | { | 760 | { |
763 | struct usbhs_fifo *fifo; | 761 | struct usbhs_fifo *fifo; |
762 | int i; | ||
764 | 763 | ||
765 | /* DMA :: D0FIFO */ | 764 | usbhs_for_each_dfifo(priv, fifo, i) { |
766 | fifo = usbhsf_get_d0fifo(priv); | 765 | if (usbhsf_dma_chan_get(fifo, pkt) && |
767 | if (usbhsf_dma_chan_get(fifo, pkt) && | 766 | !usbhsf_fifo_is_busy(fifo)) |
768 | !usbhsf_fifo_is_busy(fifo)) | 767 | return fifo; |
769 | return fifo; | 768 | } |
770 | |||
771 | /* DMA :: D1FIFO */ | ||
772 | fifo = usbhsf_get_d1fifo(priv); | ||
773 | if (usbhsf_dma_chan_get(fifo, pkt) && | ||
774 | !usbhsf_fifo_is_busy(fifo)) | ||
775 | return fifo; | ||
776 | 769 | ||
777 | return NULL; | 770 | return NULL; |
778 | } | 771 | } |
@@ -1185,8 +1178,8 @@ void usbhs_fifo_init(struct usbhs_priv *priv) | |||
1185 | { | 1178 | { |
1186 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); | 1179 | struct usbhs_mod *mod = usbhs_mod_get_current(priv); |
1187 | struct usbhs_fifo *cfifo = usbhsf_get_cfifo(priv); | 1180 | struct usbhs_fifo *cfifo = usbhsf_get_cfifo(priv); |
1188 | struct usbhs_fifo *d0fifo = usbhsf_get_d0fifo(priv); | 1181 | struct usbhs_fifo *dfifo; |
1189 | struct usbhs_fifo *d1fifo = usbhsf_get_d1fifo(priv); | 1182 | int i; |
1190 | 1183 | ||
1191 | mod->irq_empty = usbhsf_irq_empty; | 1184 | mod->irq_empty = usbhsf_irq_empty; |
1192 | mod->irq_ready = usbhsf_irq_ready; | 1185 | mod->irq_ready = usbhsf_irq_ready; |
@@ -1194,8 +1187,8 @@ void usbhs_fifo_init(struct usbhs_priv *priv) | |||
1194 | mod->irq_brdysts = 0; | 1187 | mod->irq_brdysts = 0; |
1195 | 1188 | ||
1196 | cfifo->pipe = NULL; | 1189 | cfifo->pipe = NULL; |
1197 | d0fifo->pipe = NULL; | 1190 | usbhs_for_each_dfifo(priv, dfifo, i) |
1198 | d1fifo->pipe = NULL; | 1191 | dfifo->pipe = NULL; |
1199 | } | 1192 | } |
1200 | 1193 | ||
1201 | void usbhs_fifo_quit(struct usbhs_priv *priv) | 1194 | void usbhs_fifo_quit(struct usbhs_priv *priv) |
@@ -1208,6 +1201,20 @@ void usbhs_fifo_quit(struct usbhs_priv *priv) | |||
1208 | mod->irq_brdysts = 0; | 1201 | mod->irq_brdysts = 0; |
1209 | } | 1202 | } |
1210 | 1203 | ||
1204 | #define USBHS_DFIFO_INIT(priv, fifo, channel) \ | ||
1205 | do { \ | ||
1206 | fifo = usbhsf_get_dnfifo(priv, channel); \ | ||
1207 | fifo->name = "D"#channel"FIFO"; \ | ||
1208 | fifo->port = D##channel##FIFO; \ | ||
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 | |||
1211 | int usbhs_fifo_probe(struct usbhs_priv *priv) | 1218 | int usbhs_fifo_probe(struct usbhs_priv *priv) |
1212 | { | 1219 | { |
1213 | struct usbhs_fifo *fifo; | 1220 | struct usbhs_fifo *fifo; |
@@ -1219,31 +1226,18 @@ int usbhs_fifo_probe(struct usbhs_priv *priv) | |||
1219 | fifo->sel = CFIFOSEL; | 1226 | fifo->sel = CFIFOSEL; |
1220 | fifo->ctr = CFIFOCTR; | 1227 | fifo->ctr = CFIFOCTR; |
1221 | 1228 | ||
1222 | /* D0FIFO */ | 1229 | /* DFIFO */ |
1223 | fifo = usbhsf_get_d0fifo(priv); | 1230 | USBHS_DFIFO_INIT(priv, fifo, 0); |
1224 | fifo->name = "D0FIFO"; | 1231 | USBHS_DFIFO_INIT(priv, fifo, 1); |
1225 | fifo->port = D0FIFO; | ||
1226 | fifo->sel = D0FIFOSEL; | ||
1227 | fifo->ctr = D0FIFOCTR; | ||
1228 | fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_tx_id); | ||
1229 | fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d0_rx_id); | ||
1230 | usbhsf_dma_init(priv, fifo); | ||
1231 | |||
1232 | /* D1FIFO */ | ||
1233 | fifo = usbhsf_get_d1fifo(priv); | ||
1234 | fifo->name = "D1FIFO"; | ||
1235 | fifo->port = D1FIFO; | ||
1236 | fifo->sel = D1FIFOSEL; | ||
1237 | fifo->ctr = D1FIFOCTR; | ||
1238 | fifo->tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_tx_id); | ||
1239 | fifo->rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, d1_rx_id); | ||
1240 | usbhsf_dma_init(priv, fifo); | ||
1241 | 1232 | ||
1242 | return 0; | 1233 | return 0; |
1243 | } | 1234 | } |
1244 | 1235 | ||
1245 | void usbhs_fifo_remove(struct usbhs_priv *priv) | 1236 | void usbhs_fifo_remove(struct usbhs_priv *priv) |
1246 | { | 1237 | { |
1247 | usbhsf_dma_quit(priv, usbhsf_get_d0fifo(priv)); | 1238 | struct usbhs_fifo *fifo; |
1248 | usbhsf_dma_quit(priv, usbhsf_get_d1fifo(priv)); | 1239 | int i; |
1240 | |||
1241 | usbhs_for_each_dfifo(priv, fifo, i) | ||
1242 | usbhsf_dma_quit(priv, fifo); | ||
1249 | } | 1243 | } |
diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h index e1e51c631729..899729ac085f 100644 --- a/drivers/usb/renesas_usbhs/fifo.h +++ b/drivers/usb/renesas_usbhs/fifo.h | |||
@@ -43,6 +43,11 @@ struct usbhs_fifo_info { | |||
43 | struct usbhs_fifo cfifo; | 43 | struct usbhs_fifo cfifo; |
44 | struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO]; | 44 | struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO]; |
45 | }; | 45 | }; |
46 | #define usbhsf_get_dnfifo(p, n) (&((p)->fifo_info.dfifo[n])) | ||
47 | #define usbhs_for_each_dfifo(priv, dfifo, i) \ | ||
48 | for ((i) = 0, dfifo = usbhsf_get_dnfifo(priv, (i)); \ | ||
49 | ((i) < USBHS_MAX_NUM_DFIFO); \ | ||
50 | (i)++, dfifo = usbhsf_get_dnfifo(priv, (i))) | ||
46 | 51 | ||
47 | struct usbhs_pkt_handle; | 52 | struct usbhs_pkt_handle; |
48 | struct usbhs_pkt { | 53 | struct usbhs_pkt { |