diff options
Diffstat (limited to 'drivers/usb/renesas_usbhs/pipe.c')
-rw-r--r-- | drivers/usb/renesas_usbhs/pipe.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 122526cfd32b..7926e1c700f1 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c | |||
@@ -93,6 +93,82 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /* | 95 | /* |
96 | * PIPEnTRN/PIPEnTRE functions | ||
97 | */ | ||
98 | static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | ||
99 | { | ||
100 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | ||
101 | struct device *dev = usbhs_priv_to_dev(priv); | ||
102 | int num = usbhs_pipe_number(pipe); | ||
103 | u16 reg; | ||
104 | |||
105 | /* | ||
106 | * It is impossible to calculate address, | ||
107 | * since PIPEnTRN addresses were mapped randomly. | ||
108 | */ | ||
109 | #define CASE_PIPExTRN(a) \ | ||
110 | case 0x ## a: \ | ||
111 | reg = PIPE ## a ## TRN; \ | ||
112 | break; | ||
113 | |||
114 | switch (num) { | ||
115 | CASE_PIPExTRN(1); | ||
116 | CASE_PIPExTRN(2); | ||
117 | CASE_PIPExTRN(3); | ||
118 | CASE_PIPExTRN(4); | ||
119 | CASE_PIPExTRN(5); | ||
120 | CASE_PIPExTRN(B); | ||
121 | CASE_PIPExTRN(C); | ||
122 | CASE_PIPExTRN(D); | ||
123 | CASE_PIPExTRN(E); | ||
124 | CASE_PIPExTRN(F); | ||
125 | CASE_PIPExTRN(9); | ||
126 | CASE_PIPExTRN(A); | ||
127 | default: | ||
128 | dev_err(dev, "unknown pipe (%d)\n", num); | ||
129 | return; | ||
130 | } | ||
131 | __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); | ||
132 | } | ||
133 | |||
134 | static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | ||
135 | { | ||
136 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | ||
137 | struct device *dev = usbhs_priv_to_dev(priv); | ||
138 | int num = usbhs_pipe_number(pipe); | ||
139 | u16 reg; | ||
140 | |||
141 | /* | ||
142 | * It is impossible to calculate address, | ||
143 | * since PIPEnTRE addresses were mapped randomly. | ||
144 | */ | ||
145 | #define CASE_PIPExTRE(a) \ | ||
146 | case 0x ## a: \ | ||
147 | reg = PIPE ## a ## TRE; \ | ||
148 | break; | ||
149 | |||
150 | switch (num) { | ||
151 | CASE_PIPExTRE(1); | ||
152 | CASE_PIPExTRE(2); | ||
153 | CASE_PIPExTRE(3); | ||
154 | CASE_PIPExTRE(4); | ||
155 | CASE_PIPExTRE(5); | ||
156 | CASE_PIPExTRE(B); | ||
157 | CASE_PIPExTRE(C); | ||
158 | CASE_PIPExTRE(D); | ||
159 | CASE_PIPExTRE(E); | ||
160 | CASE_PIPExTRE(F); | ||
161 | CASE_PIPExTRE(9); | ||
162 | CASE_PIPExTRE(A); | ||
163 | default: | ||
164 | dev_err(dev, "unknown pipe (%d)\n", num); | ||
165 | return; | ||
166 | } | ||
167 | |||
168 | __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); | ||
169 | } | ||
170 | |||
171 | /* | ||
96 | * PIPEBUF | 172 | * PIPEBUF |
97 | */ | 173 | */ |
98 | static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | 174 | static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val) |
@@ -264,6 +340,31 @@ int usbhs_pipe_is_stall(struct usbhs_pipe *pipe) | |||
264 | return (int)(pid == PID_STALL10 || pid == PID_STALL11); | 340 | return (int)(pid == PID_STALL10 || pid == PID_STALL11); |
265 | } | 341 | } |
266 | 342 | ||
343 | void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len) | ||
344 | { | ||
345 | if (!usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) | ||
346 | return; | ||
347 | |||
348 | /* | ||
349 | * clear and disable transfer counter for IN/OUT pipe | ||
350 | */ | ||
351 | usbhsp_pipe_tre_set(pipe, TRCLR | TRENB, TRCLR); | ||
352 | |||
353 | /* | ||
354 | * Only IN direction bulk pipe can use transfer count. | ||
355 | * Without using this function, | ||
356 | * received data will break if it was large data size. | ||
357 | * see PIPEnTRN/PIPEnTRE for detail | ||
358 | */ | ||
359 | if (usbhs_pipe_is_dir_in(pipe)) { | ||
360 | int maxp = usbhs_pipe_get_maxpacket(pipe); | ||
361 | |||
362 | usbhsp_pipe_trn_set(pipe, 0xffff, DIV_ROUND_UP(len, maxp)); | ||
363 | usbhsp_pipe_tre_set(pipe, TRENB, TRENB); /* enable */ | ||
364 | } | ||
365 | } | ||
366 | |||
367 | |||
267 | /* | 368 | /* |
268 | * pipe setup | 369 | * pipe setup |
269 | */ | 370 | */ |