diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-06-06 01:18:07 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-06-07 12:10:07 -0400 |
commit | 4bd0481152d0d5e8326d7e24329b0069713ed718 (patch) | |
tree | eee0db4a089f8a853305293a72bc10b3d8b8177c /drivers/usb/renesas_usbhs/fifo.c | |
parent | e8d548d549688d335236f7f6f8bcee141a207ff8 (diff) |
usb: renesas_usbhs: divide data transfer functions
DMAEngine will be supported to this driver in the future.
Then, both PIO and DMA data transfer method should be supported.
But, the transfer function can returns the result immediately
in PIO version, but it can't in DMA version.
This patch divides data transfer functions into top/bottom half
in preparation for DMAEngine support.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/renesas_usbhs/fifo.c')
-rw-r--r-- | drivers/usb/renesas_usbhs/fifo.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 3fd3adf90541..098388489813 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c | |||
@@ -20,6 +20,20 @@ | |||
20 | #include "./pipe.h" | 20 | #include "./pipe.h" |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * packet info function | ||
24 | */ | ||
25 | void usbhs_pkt_update(struct usbhs_pkt *pkt, | ||
26 | struct usbhs_pipe *pipe, | ||
27 | void *buf, int len) | ||
28 | { | ||
29 | pkt->pipe = pipe; | ||
30 | pkt->buf = buf; | ||
31 | pkt->length = len; | ||
32 | pkt->actual = 0; | ||
33 | pkt->maxp = 0; | ||
34 | } | ||
35 | |||
36 | /* | ||
23 | * FIFO ctrl | 37 | * FIFO ctrl |
24 | */ | 38 | */ |
25 | static void usbhsf_send_terminator(struct usbhs_pipe *pipe) | 39 | static void usbhsf_send_terminator(struct usbhs_pipe *pipe) |
@@ -93,13 +107,16 @@ int usbhs_fifo_prepare_write(struct usbhs_pipe *pipe) | |||
93 | return usbhsf_fifo_select(pipe, 1); | 107 | return usbhsf_fifo_select(pipe, 1); |
94 | } | 108 | } |
95 | 109 | ||
96 | int usbhs_fifo_write(struct usbhs_pipe *pipe, u8 *buf, int len) | 110 | int usbhs_fifo_write(struct usbhs_pkt *pkt) |
97 | { | 111 | { |
112 | struct usbhs_pipe *pipe = pkt->pipe; | ||
98 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | 113 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); |
114 | struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); | ||
99 | void __iomem *addr = priv->base + CFIFO; | 115 | void __iomem *addr = priv->base + CFIFO; |
100 | int maxp = usbhs_pipe_get_maxpacket(pipe); | 116 | int maxp = usbhs_pipe_get_maxpacket(pipe); |
101 | int total_len; | 117 | int total_len; |
102 | int i, ret; | 118 | u8 *buf = pkt->buf; |
119 | int i, ret, len; | ||
103 | 120 | ||
104 | ret = usbhs_pipe_is_accessible(pipe); | 121 | ret = usbhs_pipe_is_accessible(pipe); |
105 | if (ret < 0) | 122 | if (ret < 0) |
@@ -113,7 +130,7 @@ int usbhs_fifo_write(struct usbhs_pipe *pipe, u8 *buf, int len) | |||
113 | if (ret < 0) | 130 | if (ret < 0) |
114 | return ret; | 131 | return ret; |
115 | 132 | ||
116 | len = min(len, maxp); | 133 | len = min(pkt->length, maxp); |
117 | total_len = len; | 134 | total_len = len; |
118 | 135 | ||
119 | /* | 136 | /* |
@@ -135,7 +152,16 @@ int usbhs_fifo_write(struct usbhs_pipe *pipe, u8 *buf, int len) | |||
135 | if (total_len < maxp) | 152 | if (total_len < maxp) |
136 | usbhsf_send_terminator(pipe); | 153 | usbhsf_send_terminator(pipe); |
137 | 154 | ||
138 | return total_len; | 155 | usbhs_pipe_enable(pipe); |
156 | |||
157 | /* update pkt */ | ||
158 | if (info->tx_done) { | ||
159 | pkt->actual = total_len; | ||
160 | pkt->maxp = maxp; | ||
161 | info->tx_done(pkt); | ||
162 | } | ||
163 | |||
164 | return 0; | ||
139 | } | 165 | } |
140 | 166 | ||
141 | int usbhs_fifo_prepare_read(struct usbhs_pipe *pipe) | 167 | int usbhs_fifo_prepare_read(struct usbhs_pipe *pipe) |
@@ -154,13 +180,16 @@ int usbhs_fifo_prepare_read(struct usbhs_pipe *pipe) | |||
154 | return ret; | 180 | return ret; |
155 | } | 181 | } |
156 | 182 | ||
157 | int usbhs_fifo_read(struct usbhs_pipe *pipe, u8 *buf, int len) | 183 | int usbhs_fifo_read(struct usbhs_pkt *pkt) |
158 | { | 184 | { |
185 | struct usbhs_pipe *pipe = pkt->pipe; | ||
159 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | 186 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); |
187 | struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); | ||
160 | void __iomem *addr = priv->base + CFIFO; | 188 | void __iomem *addr = priv->base + CFIFO; |
161 | int rcv_len; | 189 | u8 *buf = pkt->buf; |
190 | int rcv_len, len; | ||
162 | int i, ret; | 191 | int i, ret; |
163 | int total_len; | 192 | int total_len = 0; |
164 | u32 data = 0; | 193 | u32 data = 0; |
165 | 194 | ||
166 | ret = usbhsf_fifo_select(pipe, 0); | 195 | ret = usbhsf_fifo_select(pipe, 0); |
@@ -181,10 +210,10 @@ int usbhs_fifo_read(struct usbhs_pipe *pipe, u8 *buf, int len) | |||
181 | */ | 210 | */ |
182 | if (0 == rcv_len) { | 211 | if (0 == rcv_len) { |
183 | usbhsf_fifo_clear(pipe); | 212 | usbhsf_fifo_clear(pipe); |
184 | return 0; | 213 | goto usbhs_fifo_read_end; |
185 | } | 214 | } |
186 | 215 | ||
187 | len = min(rcv_len, len); | 216 | len = min(rcv_len, pkt->length); |
188 | total_len = len; | 217 | total_len = len; |
189 | 218 | ||
190 | /* | 219 | /* |
@@ -207,5 +236,13 @@ int usbhs_fifo_read(struct usbhs_pipe *pipe, u8 *buf, int len) | |||
207 | buf[i] = (data >> ((i & 0x03) * 8)) & 0xff; | 236 | buf[i] = (data >> ((i & 0x03) * 8)) & 0xff; |
208 | } | 237 | } |
209 | 238 | ||
210 | return total_len; | 239 | usbhs_fifo_read_end: |
240 | if (info->rx_done) { | ||
241 | /* update pkt */ | ||
242 | pkt->actual = total_len; | ||
243 | pkt->maxp = usbhs_pipe_get_maxpacket(pipe); | ||
244 | info->rx_done(pkt); | ||
245 | } | ||
246 | |||
247 | return 0; | ||
211 | } | 248 | } |