diff options
author | Mike Frysinger <vapier.adi@gmail.com> | 2009-02-06 05:12:35 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-02-06 07:07:39 -0500 |
commit | 8836c273e4d44d088157b7ccbd2c108cefe70565 (patch) | |
tree | d77775a17e501c8e0170c31c22c69bb6bd1a1d21 /sound/soc/blackfin | |
parent | 92a950ff2b7091a735c32a6e57b8136650bc7812 (diff) |
ASoC: Blackfin: drop unnecessary dma casts
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/blackfin')
-rw-r--r-- | sound/soc/blackfin/bf5xx-sport.c | 104 |
1 files changed, 43 insertions, 61 deletions
diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c index 3b99e484d555..b7953c8cf838 100644 --- a/sound/soc/blackfin/bf5xx-sport.c +++ b/sound/soc/blackfin/bf5xx-sport.c | |||
@@ -133,7 +133,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, | |||
133 | int i; | 133 | int i; |
134 | 134 | ||
135 | for (i = 0; i < fragcount; ++i) { | 135 | for (i = 0; i < fragcount; ++i) { |
136 | desc[i].next_desc_addr = (unsigned long)&(desc[i + 1]); | 136 | desc[i].next_desc_addr = &(desc[i + 1]); |
137 | desc[i].start_addr = (unsigned long)buf + i*fragsize; | 137 | desc[i].start_addr = (unsigned long)buf + i*fragsize; |
138 | desc[i].cfg = cfg; | 138 | desc[i].cfg = cfg; |
139 | desc[i].x_count = x_count; | 139 | desc[i].x_count = x_count; |
@@ -143,12 +143,12 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /* make circular */ | 145 | /* make circular */ |
146 | desc[fragcount-1].next_desc_addr = (unsigned long)desc; | 146 | desc[fragcount-1].next_desc_addr = desc; |
147 | 147 | ||
148 | pr_debug("setup desc: desc0=%p, next0=%lx, desc1=%p," | 148 | pr_debug("setup desc: desc0=%p, next0=%p, desc1=%p," |
149 | "next1=%lx\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", | 149 | "next1=%p\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", |
150 | &(desc[0]), desc[0].next_desc_addr, | 150 | desc, desc[0].next_desc_addr, |
151 | &(desc[1]), desc[1].next_desc_addr, | 151 | desc+1, desc[1].next_desc_addr, |
152 | desc[0].x_count, desc[0].y_count, | 152 | desc[0].x_count, desc[0].y_count, |
153 | desc[0].start_addr, desc[0].cfg); | 153 | desc[0].start_addr, desc[0].cfg); |
154 | } | 154 | } |
@@ -184,22 +184,20 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) | |||
184 | BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); | 184 | BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); |
185 | 185 | ||
186 | /* Maybe the dummy buffer descriptor ring is damaged */ | 186 | /* Maybe the dummy buffer descriptor ring is damaged */ |
187 | sport->dummy_rx_desc->next_desc_addr = \ | 187 | sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; |
188 | (unsigned long)(sport->dummy_rx_desc+1); | ||
189 | 188 | ||
190 | local_irq_save(flags); | 189 | local_irq_save(flags); |
191 | desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_rx_chan); | 190 | desc = get_dma_next_desc_ptr(sport->dma_rx_chan); |
192 | /* Copy the descriptor which will be damaged to backup */ | 191 | /* Copy the descriptor which will be damaged to backup */ |
193 | temp_desc = *desc; | 192 | temp_desc = *desc; |
194 | desc->x_count = 0xa; | 193 | desc->x_count = 0xa; |
195 | desc->y_count = 0; | 194 | desc->y_count = 0; |
196 | desc->next_desc_addr = (unsigned long)(sport->dummy_rx_desc); | 195 | desc->next_desc_addr = sport->dummy_rx_desc; |
197 | local_irq_restore(flags); | 196 | local_irq_restore(flags); |
198 | /* Waiting for dummy buffer descriptor is already hooked*/ | 197 | /* Waiting for dummy buffer descriptor is already hooked*/ |
199 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - | 198 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - |
200 | sizeof(struct dmasg)) != | 199 | sizeof(struct dmasg)) != sport->dummy_rx_desc) |
201 | (unsigned long)sport->dummy_rx_desc) | 200 | continue; |
202 | ; | ||
203 | sport->curr_rx_desc = sport->dummy_rx_desc; | 201 | sport->curr_rx_desc = sport->dummy_rx_desc; |
204 | /* Restore the damaged descriptor */ | 202 | /* Restore the damaged descriptor */ |
205 | *desc = temp_desc; | 203 | *desc = temp_desc; |
@@ -210,14 +208,12 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) | |||
210 | static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) | 208 | static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) |
211 | { | 209 | { |
212 | if (dummy) { | 210 | if (dummy) { |
213 | sport->dummy_rx_desc->next_desc_addr = \ | 211 | sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc; |
214 | (unsigned long) sport->dummy_rx_desc; | ||
215 | sport->curr_rx_desc = sport->dummy_rx_desc; | 212 | sport->curr_rx_desc = sport->dummy_rx_desc; |
216 | } else | 213 | } else |
217 | sport->curr_rx_desc = sport->dma_rx_desc; | 214 | sport->curr_rx_desc = sport->dma_rx_desc; |
218 | 215 | ||
219 | set_dma_next_desc_addr(sport->dma_rx_chan, \ | 216 | set_dma_next_desc_addr(sport->dma_rx_chan, sport->curr_rx_desc); |
220 | (unsigned long)(sport->curr_rx_desc)); | ||
221 | set_dma_x_count(sport->dma_rx_chan, 0); | 217 | set_dma_x_count(sport->dma_rx_chan, 0); |
222 | set_dma_x_modify(sport->dma_rx_chan, 0); | 218 | set_dma_x_modify(sport->dma_rx_chan, 0); |
223 | set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ | 219 | set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ |
@@ -231,14 +227,12 @@ static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) | |||
231 | static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) | 227 | static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) |
232 | { | 228 | { |
233 | if (dummy) { | 229 | if (dummy) { |
234 | sport->dummy_tx_desc->next_desc_addr = \ | 230 | sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc; |
235 | (unsigned long) sport->dummy_tx_desc; | ||
236 | sport->curr_tx_desc = sport->dummy_tx_desc; | 231 | sport->curr_tx_desc = sport->dummy_tx_desc; |
237 | } else | 232 | } else |
238 | sport->curr_tx_desc = sport->dma_tx_desc; | 233 | sport->curr_tx_desc = sport->dma_tx_desc; |
239 | 234 | ||
240 | set_dma_next_desc_addr(sport->dma_tx_chan, \ | 235 | set_dma_next_desc_addr(sport->dma_tx_chan, sport->curr_tx_desc); |
241 | (unsigned long)(sport->curr_tx_desc)); | ||
242 | set_dma_x_count(sport->dma_tx_chan, 0); | 236 | set_dma_x_count(sport->dma_tx_chan, 0); |
243 | set_dma_x_modify(sport->dma_tx_chan, 0); | 237 | set_dma_x_modify(sport->dma_tx_chan, 0); |
244 | set_dma_config(sport->dma_tx_chan, | 238 | set_dma_config(sport->dma_tx_chan, |
@@ -261,11 +255,9 @@ int sport_rx_start(struct sport_device *sport) | |||
261 | BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); | 255 | BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); |
262 | local_irq_save(flags); | 256 | local_irq_save(flags); |
263 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - | 257 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - |
264 | sizeof(struct dmasg)) != | 258 | sizeof(struct dmasg)) != sport->dummy_rx_desc) |
265 | (unsigned long)sport->dummy_rx_desc) | 259 | continue; |
266 | ; | 260 | sport->dummy_rx_desc->next_desc_addr = sport->dma_rx_desc; |
267 | sport->dummy_rx_desc->next_desc_addr = | ||
268 | (unsigned long)(sport->dma_rx_desc); | ||
269 | local_irq_restore(flags); | 261 | local_irq_restore(flags); |
270 | sport->curr_rx_desc = sport->dma_rx_desc; | 262 | sport->curr_rx_desc = sport->dma_rx_desc; |
271 | } else { | 263 | } else { |
@@ -310,23 +302,21 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) | |||
310 | BUG_ON(sport->dummy_tx_desc == NULL); | 302 | BUG_ON(sport->dummy_tx_desc == NULL); |
311 | BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); | 303 | BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); |
312 | 304 | ||
313 | sport->dummy_tx_desc->next_desc_addr = \ | 305 | sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; |
314 | (unsigned long)(sport->dummy_tx_desc+1); | ||
315 | 306 | ||
316 | /* Shorten the time on last normal descriptor */ | 307 | /* Shorten the time on last normal descriptor */ |
317 | local_irq_save(flags); | 308 | local_irq_save(flags); |
318 | desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_tx_chan); | 309 | desc = get_dma_next_desc_ptr(sport->dma_tx_chan); |
319 | /* Store the descriptor which will be damaged */ | 310 | /* Store the descriptor which will be damaged */ |
320 | temp_desc = *desc; | 311 | temp_desc = *desc; |
321 | desc->x_count = 0xa; | 312 | desc->x_count = 0xa; |
322 | desc->y_count = 0; | 313 | desc->y_count = 0; |
323 | desc->next_desc_addr = (unsigned long)(sport->dummy_tx_desc); | 314 | desc->next_desc_addr = sport->dummy_tx_desc; |
324 | local_irq_restore(flags); | 315 | local_irq_restore(flags); |
325 | /* Waiting for dummy buffer descriptor is already hooked*/ | 316 | /* Waiting for dummy buffer descriptor is already hooked*/ |
326 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ | 317 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ |
327 | sizeof(struct dmasg)) != \ | 318 | sizeof(struct dmasg)) != sport->dummy_tx_desc) |
328 | (unsigned long)sport->dummy_tx_desc) | 319 | continue; |
329 | ; | ||
330 | sport->curr_tx_desc = sport->dummy_tx_desc; | 320 | sport->curr_tx_desc = sport->dummy_tx_desc; |
331 | /* Restore the damaged descriptor */ | 321 | /* Restore the damaged descriptor */ |
332 | *desc = temp_desc; | 322 | *desc = temp_desc; |
@@ -347,11 +337,9 @@ int sport_tx_start(struct sport_device *sport) | |||
347 | /* Hook the normal buffer descriptor */ | 337 | /* Hook the normal buffer descriptor */ |
348 | local_irq_save(flags); | 338 | local_irq_save(flags); |
349 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - | 339 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - |
350 | sizeof(struct dmasg)) != | 340 | sizeof(struct dmasg)) != sport->dummy_tx_desc) |
351 | (unsigned long)sport->dummy_tx_desc) | 341 | continue; |
352 | ; | 342 | sport->dummy_tx_desc->next_desc_addr = sport->dma_tx_desc; |
353 | sport->dummy_tx_desc->next_desc_addr = | ||
354 | (unsigned long)(sport->dma_tx_desc); | ||
355 | local_irq_restore(flags); | 343 | local_irq_restore(flags); |
356 | sport->curr_tx_desc = sport->dma_tx_desc; | 344 | sport->curr_tx_desc = sport->dma_tx_desc; |
357 | } else { | 345 | } else { |
@@ -536,19 +524,17 @@ static int sport_config_rx_dummy(struct sport_device *sport) | |||
536 | unsigned config; | 524 | unsigned config; |
537 | 525 | ||
538 | pr_debug("%s entered\n", __func__); | 526 | pr_debug("%s entered\n", __func__); |
539 | #if L1_DATA_A_LENGTH != 0 | 527 | if (L1_DATA_A_LENGTH) |
540 | desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); | 528 | desc = l1_data_sram_zalloc(2 * sizeof(*desc)); |
541 | #else | 529 | else { |
542 | { | ||
543 | dma_addr_t addr; | 530 | dma_addr_t addr; |
544 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); | 531 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); |
532 | memset(desc, 0, 2 * sizeof(*desc)); | ||
545 | } | 533 | } |
546 | #endif | ||
547 | if (desc == NULL) { | 534 | if (desc == NULL) { |
548 | pr_err("Failed to allocate memory for dummy rx desc\n"); | 535 | pr_err("Failed to allocate memory for dummy rx desc\n"); |
549 | return -ENOMEM; | 536 | return -ENOMEM; |
550 | } | 537 | } |
551 | memset(desc, 0, 2 * sizeof(*desc)); | ||
552 | sport->dummy_rx_desc = desc; | 538 | sport->dummy_rx_desc = desc; |
553 | desc->start_addr = (unsigned long)sport->dummy_buf; | 539 | desc->start_addr = (unsigned long)sport->dummy_buf; |
554 | config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) | 540 | config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) |
@@ -559,8 +545,8 @@ static int sport_config_rx_dummy(struct sport_device *sport) | |||
559 | desc->y_count = 0; | 545 | desc->y_count = 0; |
560 | desc->y_modify = 0; | 546 | desc->y_modify = 0; |
561 | memcpy(desc+1, desc, sizeof(*desc)); | 547 | memcpy(desc+1, desc, sizeof(*desc)); |
562 | desc->next_desc_addr = (unsigned long)(desc+1); | 548 | desc->next_desc_addr = desc + 1; |
563 | desc[1].next_desc_addr = (unsigned long)desc; | 549 | desc[1].next_desc_addr = desc; |
564 | return 0; | 550 | return 0; |
565 | } | 551 | } |
566 | 552 | ||
@@ -571,19 +557,17 @@ static int sport_config_tx_dummy(struct sport_device *sport) | |||
571 | 557 | ||
572 | pr_debug("%s entered\n", __func__); | 558 | pr_debug("%s entered\n", __func__); |
573 | 559 | ||
574 | #if L1_DATA_A_LENGTH != 0 | 560 | if (L1_DATA_A_LENGTH) |
575 | desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); | 561 | desc = l1_data_sram_zalloc(2 * sizeof(*desc)); |
576 | #else | 562 | else { |
577 | { | ||
578 | dma_addr_t addr; | 563 | dma_addr_t addr; |
579 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); | 564 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); |
565 | memset(desc, 0, 2 * sizeof(*desc)); | ||
580 | } | 566 | } |
581 | #endif | ||
582 | if (!desc) { | 567 | if (!desc) { |
583 | pr_err("Failed to allocate memory for dummy tx desc\n"); | 568 | pr_err("Failed to allocate memory for dummy tx desc\n"); |
584 | return -ENOMEM; | 569 | return -ENOMEM; |
585 | } | 570 | } |
586 | memset(desc, 0, 2 * sizeof(*desc)); | ||
587 | sport->dummy_tx_desc = desc; | 571 | sport->dummy_tx_desc = desc; |
588 | desc->start_addr = (unsigned long)sport->dummy_buf + \ | 572 | desc->start_addr = (unsigned long)sport->dummy_buf + \ |
589 | sport->dummy_count; | 573 | sport->dummy_count; |
@@ -595,8 +579,8 @@ static int sport_config_tx_dummy(struct sport_device *sport) | |||
595 | desc->y_count = 0; | 579 | desc->y_count = 0; |
596 | desc->y_modify = 0; | 580 | desc->y_modify = 0; |
597 | memcpy(desc+1, desc, sizeof(*desc)); | 581 | memcpy(desc+1, desc, sizeof(*desc)); |
598 | desc->next_desc_addr = (unsigned long)(desc+1); | 582 | desc->next_desc_addr = desc + 1; |
599 | desc[1].next_desc_addr = (unsigned long)desc; | 583 | desc[1].next_desc_addr = desc; |
600 | return 0; | 584 | return 0; |
601 | } | 585 | } |
602 | 586 | ||
@@ -872,17 +856,15 @@ struct sport_device *sport_init(struct sport_param *param, unsigned wdsize, | |||
872 | sport->wdsize = wdsize; | 856 | sport->wdsize = wdsize; |
873 | sport->dummy_count = dummy_count; | 857 | sport->dummy_count = dummy_count; |
874 | 858 | ||
875 | #if L1_DATA_A_LENGTH != 0 | 859 | if (L1_DATA_A_LENGTH) |
876 | sport->dummy_buf = l1_data_sram_alloc(dummy_count * 2); | 860 | sport->dummy_buf = l1_data_sram_zalloc(dummy_count * 2); |
877 | #else | 861 | else |
878 | sport->dummy_buf = kmalloc(dummy_count * 2, GFP_KERNEL); | 862 | sport->dummy_buf = kzalloc(dummy_count * 2, GFP_KERNEL); |
879 | #endif | ||
880 | if (sport->dummy_buf == NULL) { | 863 | if (sport->dummy_buf == NULL) { |
881 | pr_err("Failed to allocate dummy buffer\n"); | 864 | pr_err("Failed to allocate dummy buffer\n"); |
882 | goto __error; | 865 | goto __error; |
883 | } | 866 | } |
884 | 867 | ||
885 | memset(sport->dummy_buf, 0, dummy_count * 2); | ||
886 | ret = sport_config_rx_dummy(sport); | 868 | ret = sport_config_rx_dummy(sport); |
887 | if (ret) { | 869 | if (ret) { |
888 | pr_err("Failed to config rx dummy ring\n"); | 870 | pr_err("Failed to config rx dummy ring\n"); |
@@ -939,6 +921,7 @@ void sport_done(struct sport_device *sport) | |||
939 | sport = NULL; | 921 | sport = NULL; |
940 | } | 922 | } |
941 | EXPORT_SYMBOL(sport_done); | 923 | EXPORT_SYMBOL(sport_done); |
924 | |||
942 | /* | 925 | /* |
943 | * It is only used to send several bytes when dma is not enabled | 926 | * It is only used to send several bytes when dma is not enabled |
944 | * sport controller is configured but not enabled. | 927 | * sport controller is configured but not enabled. |
@@ -1029,4 +1012,3 @@ EXPORT_SYMBOL(sport_send_and_recv); | |||
1029 | MODULE_AUTHOR("Roy Huang"); | 1012 | MODULE_AUTHOR("Roy Huang"); |
1030 | MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); | 1013 | MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); |
1031 | MODULE_LICENSE("GPL"); | 1014 | MODULE_LICENSE("GPL"); |
1032 | |||