diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2007-12-05 02:45:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-05 12:21:19 -0500 |
commit | 3f479a65b3f49ee4f058a965e6e33d97ee467b68 (patch) | |
tree | a9138d5d9429d29a0403a197a5868d98cd86288a /drivers/spi | |
parent | cc487e732089360727e60f9fdbe3ff6cc4ca3155 (diff) |
spi: spi_bfin: relocate spin/waits
Move spin/waits to more correct locations in bfin SPI driver.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi_bfin5xx.c | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index c99a2afabf0c..c7cfd95fa8ec 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c | |||
@@ -276,22 +276,26 @@ static void u8_writer(struct driver_data *drv_data) | |||
276 | dev_dbg(&drv_data->pdev->dev, | 276 | dev_dbg(&drv_data->pdev->dev, |
277 | "cr8-s is 0x%x\n", read_STAT()); | 277 | "cr8-s is 0x%x\n", read_STAT()); |
278 | 278 | ||
279 | /* poll for SPI completion before start */ | ||
280 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
281 | continue; | ||
282 | |||
279 | while (drv_data->tx < drv_data->tx_end) { | 283 | while (drv_data->tx < drv_data->tx_end) { |
280 | write_TDBR(*(u8 *) (drv_data->tx)); | 284 | write_TDBR(*(u8 *) (drv_data->tx)); |
281 | while (read_STAT() & BIT_STAT_TXS) | 285 | while (read_STAT() & BIT_STAT_TXS) |
282 | continue; | 286 | continue; |
283 | ++drv_data->tx; | 287 | ++drv_data->tx; |
284 | } | 288 | } |
285 | |||
286 | /* poll for SPI completion before returning */ | ||
287 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
288 | continue; | ||
289 | } | 289 | } |
290 | 290 | ||
291 | static void u8_cs_chg_writer(struct driver_data *drv_data) | 291 | static void u8_cs_chg_writer(struct driver_data *drv_data) |
292 | { | 292 | { |
293 | struct chip_data *chip = drv_data->cur_chip; | 293 | struct chip_data *chip = drv_data->cur_chip; |
294 | 294 | ||
295 | /* poll for SPI completion before start */ | ||
296 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
297 | continue; | ||
298 | |||
295 | while (drv_data->tx < drv_data->tx_end) { | 299 | while (drv_data->tx < drv_data->tx_end) { |
296 | cs_active(chip); | 300 | cs_active(chip); |
297 | 301 | ||
@@ -304,10 +308,6 @@ static void u8_cs_chg_writer(struct driver_data *drv_data) | |||
304 | udelay(chip->cs_chg_udelay); | 308 | udelay(chip->cs_chg_udelay); |
305 | ++drv_data->tx; | 309 | ++drv_data->tx; |
306 | } | 310 | } |
307 | |||
308 | /* poll for SPI completion before returning */ | ||
309 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
310 | continue; | ||
311 | } | 311 | } |
312 | 312 | ||
313 | static void u8_reader(struct driver_data *drv_data) | 313 | static void u8_reader(struct driver_data *drv_data) |
@@ -315,6 +315,10 @@ static void u8_reader(struct driver_data *drv_data) | |||
315 | dev_dbg(&drv_data->pdev->dev, | 315 | dev_dbg(&drv_data->pdev->dev, |
316 | "cr-8 is 0x%x\n", read_STAT()); | 316 | "cr-8 is 0x%x\n", read_STAT()); |
317 | 317 | ||
318 | /* poll for SPI completion before start */ | ||
319 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
320 | continue; | ||
321 | |||
318 | /* clear TDBR buffer before read(else it will be shifted out) */ | 322 | /* clear TDBR buffer before read(else it will be shifted out) */ |
319 | write_TDBR(0xFFFF); | 323 | write_TDBR(0xFFFF); |
320 | 324 | ||
@@ -337,6 +341,10 @@ static void u8_cs_chg_reader(struct driver_data *drv_data) | |||
337 | { | 341 | { |
338 | struct chip_data *chip = drv_data->cur_chip; | 342 | struct chip_data *chip = drv_data->cur_chip; |
339 | 343 | ||
344 | /* poll for SPI completion before start */ | ||
345 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
346 | continue; | ||
347 | |||
340 | /* clear TDBR buffer before read(else it will be shifted out) */ | 348 | /* clear TDBR buffer before read(else it will be shifted out) */ |
341 | write_TDBR(0xFFFF); | 349 | write_TDBR(0xFFFF); |
342 | 350 | ||
@@ -365,6 +373,10 @@ static void u8_cs_chg_reader(struct driver_data *drv_data) | |||
365 | 373 | ||
366 | static void u8_duplex(struct driver_data *drv_data) | 374 | static void u8_duplex(struct driver_data *drv_data) |
367 | { | 375 | { |
376 | /* poll for SPI completion before start */ | ||
377 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
378 | continue; | ||
379 | |||
368 | /* in duplex mode, clk is triggered by writing of TDBR */ | 380 | /* in duplex mode, clk is triggered by writing of TDBR */ |
369 | while (drv_data->rx < drv_data->rx_end) { | 381 | while (drv_data->rx < drv_data->rx_end) { |
370 | write_TDBR(*(u8 *) (drv_data->tx)); | 382 | write_TDBR(*(u8 *) (drv_data->tx)); |
@@ -376,16 +388,16 @@ static void u8_duplex(struct driver_data *drv_data) | |||
376 | ++drv_data->rx; | 388 | ++drv_data->rx; |
377 | ++drv_data->tx; | 389 | ++drv_data->tx; |
378 | } | 390 | } |
379 | |||
380 | /* poll for SPI completion before returning */ | ||
381 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
382 | continue; | ||
383 | } | 391 | } |
384 | 392 | ||
385 | static void u8_cs_chg_duplex(struct driver_data *drv_data) | 393 | static void u8_cs_chg_duplex(struct driver_data *drv_data) |
386 | { | 394 | { |
387 | struct chip_data *chip = drv_data->cur_chip; | 395 | struct chip_data *chip = drv_data->cur_chip; |
388 | 396 | ||
397 | /* poll for SPI completion before start */ | ||
398 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
399 | continue; | ||
400 | |||
389 | while (drv_data->rx < drv_data->rx_end) { | 401 | while (drv_data->rx < drv_data->rx_end) { |
390 | cs_active(chip); | 402 | cs_active(chip); |
391 | 403 | ||
@@ -402,10 +414,6 @@ static void u8_cs_chg_duplex(struct driver_data *drv_data) | |||
402 | ++drv_data->rx; | 414 | ++drv_data->rx; |
403 | ++drv_data->tx; | 415 | ++drv_data->tx; |
404 | } | 416 | } |
405 | |||
406 | /* poll for SPI completion before returning */ | ||
407 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
408 | continue; | ||
409 | } | 417 | } |
410 | 418 | ||
411 | static void u16_writer(struct driver_data *drv_data) | 419 | static void u16_writer(struct driver_data *drv_data) |
@@ -413,22 +421,26 @@ static void u16_writer(struct driver_data *drv_data) | |||
413 | dev_dbg(&drv_data->pdev->dev, | 421 | dev_dbg(&drv_data->pdev->dev, |
414 | "cr16 is 0x%x\n", read_STAT()); | 422 | "cr16 is 0x%x\n", read_STAT()); |
415 | 423 | ||
424 | /* poll for SPI completion before start */ | ||
425 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
426 | continue; | ||
427 | |||
416 | while (drv_data->tx < drv_data->tx_end) { | 428 | while (drv_data->tx < drv_data->tx_end) { |
417 | write_TDBR(*(u16 *) (drv_data->tx)); | 429 | write_TDBR(*(u16 *) (drv_data->tx)); |
418 | while ((read_STAT() & BIT_STAT_TXS)) | 430 | while ((read_STAT() & BIT_STAT_TXS)) |
419 | continue; | 431 | continue; |
420 | drv_data->tx += 2; | 432 | drv_data->tx += 2; |
421 | } | 433 | } |
422 | |||
423 | /* poll for SPI completion before returning */ | ||
424 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
425 | continue; | ||
426 | } | 434 | } |
427 | 435 | ||
428 | static void u16_cs_chg_writer(struct driver_data *drv_data) | 436 | static void u16_cs_chg_writer(struct driver_data *drv_data) |
429 | { | 437 | { |
430 | struct chip_data *chip = drv_data->cur_chip; | 438 | struct chip_data *chip = drv_data->cur_chip; |
431 | 439 | ||
440 | /* poll for SPI completion before start */ | ||
441 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
442 | continue; | ||
443 | |||
432 | while (drv_data->tx < drv_data->tx_end) { | 444 | while (drv_data->tx < drv_data->tx_end) { |
433 | cs_active(chip); | 445 | cs_active(chip); |
434 | 446 | ||
@@ -441,10 +453,6 @@ static void u16_cs_chg_writer(struct driver_data *drv_data) | |||
441 | udelay(chip->cs_chg_udelay); | 453 | udelay(chip->cs_chg_udelay); |
442 | drv_data->tx += 2; | 454 | drv_data->tx += 2; |
443 | } | 455 | } |
444 | |||
445 | /* poll for SPI completion before returning */ | ||
446 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
447 | continue; | ||
448 | } | 456 | } |
449 | 457 | ||
450 | static void u16_reader(struct driver_data *drv_data) | 458 | static void u16_reader(struct driver_data *drv_data) |
@@ -452,6 +460,10 @@ static void u16_reader(struct driver_data *drv_data) | |||
452 | dev_dbg(&drv_data->pdev->dev, | 460 | dev_dbg(&drv_data->pdev->dev, |
453 | "cr-16 is 0x%x\n", read_STAT()); | 461 | "cr-16 is 0x%x\n", read_STAT()); |
454 | 462 | ||
463 | /* poll for SPI completion before start */ | ||
464 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
465 | continue; | ||
466 | |||
455 | /* clear TDBR buffer before read(else it will be shifted out) */ | 467 | /* clear TDBR buffer before read(else it will be shifted out) */ |
456 | write_TDBR(0xFFFF); | 468 | write_TDBR(0xFFFF); |
457 | 469 | ||
@@ -474,6 +486,10 @@ static void u16_cs_chg_reader(struct driver_data *drv_data) | |||
474 | { | 486 | { |
475 | struct chip_data *chip = drv_data->cur_chip; | 487 | struct chip_data *chip = drv_data->cur_chip; |
476 | 488 | ||
489 | /* poll for SPI completion before start */ | ||
490 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
491 | continue; | ||
492 | |||
477 | /* clear TDBR buffer before read(else it will be shifted out) */ | 493 | /* clear TDBR buffer before read(else it will be shifted out) */ |
478 | write_TDBR(0xFFFF); | 494 | write_TDBR(0xFFFF); |
479 | 495 | ||
@@ -502,6 +518,10 @@ static void u16_cs_chg_reader(struct driver_data *drv_data) | |||
502 | 518 | ||
503 | static void u16_duplex(struct driver_data *drv_data) | 519 | static void u16_duplex(struct driver_data *drv_data) |
504 | { | 520 | { |
521 | /* poll for SPI completion before start */ | ||
522 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
523 | continue; | ||
524 | |||
505 | /* in duplex mode, clk is triggered by writing of TDBR */ | 525 | /* in duplex mode, clk is triggered by writing of TDBR */ |
506 | while (drv_data->tx < drv_data->tx_end) { | 526 | while (drv_data->tx < drv_data->tx_end) { |
507 | write_TDBR(*(u16 *) (drv_data->tx)); | 527 | write_TDBR(*(u16 *) (drv_data->tx)); |
@@ -513,16 +533,16 @@ static void u16_duplex(struct driver_data *drv_data) | |||
513 | drv_data->rx += 2; | 533 | drv_data->rx += 2; |
514 | drv_data->tx += 2; | 534 | drv_data->tx += 2; |
515 | } | 535 | } |
516 | |||
517 | /* poll for SPI completion before returning */ | ||
518 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
519 | continue; | ||
520 | } | 536 | } |
521 | 537 | ||
522 | static void u16_cs_chg_duplex(struct driver_data *drv_data) | 538 | static void u16_cs_chg_duplex(struct driver_data *drv_data) |
523 | { | 539 | { |
524 | struct chip_data *chip = drv_data->cur_chip; | 540 | struct chip_data *chip = drv_data->cur_chip; |
525 | 541 | ||
542 | /* poll for SPI completion before start */ | ||
543 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
544 | continue; | ||
545 | |||
526 | while (drv_data->tx < drv_data->tx_end) { | 546 | while (drv_data->tx < drv_data->tx_end) { |
527 | cs_active(chip); | 547 | cs_active(chip); |
528 | 548 | ||
@@ -539,10 +559,6 @@ static void u16_cs_chg_duplex(struct driver_data *drv_data) | |||
539 | drv_data->rx += 2; | 559 | drv_data->rx += 2; |
540 | drv_data->tx += 2; | 560 | drv_data->tx += 2; |
541 | } | 561 | } |
542 | |||
543 | /* poll for SPI completion before returning */ | ||
544 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
545 | continue; | ||
546 | } | 562 | } |
547 | 563 | ||
548 | /* test if ther is more transfer to be done */ | 564 | /* test if ther is more transfer to be done */ |
@@ -765,6 +781,10 @@ static void pump_transfers(unsigned long data) | |||
765 | dma_width = WDSIZE_8; | 781 | dma_width = WDSIZE_8; |
766 | } | 782 | } |
767 | 783 | ||
784 | /* poll for SPI completion before start */ | ||
785 | while (!(read_STAT() & BIT_STAT_SPIF)) | ||
786 | continue; | ||
787 | |||
768 | /* dirty hack for autobuffer DMA mode */ | 788 | /* dirty hack for autobuffer DMA mode */ |
769 | if (drv_data->tx_dma == 0xFFFF) { | 789 | if (drv_data->tx_dma == 0xFFFF) { |
770 | dev_dbg(&drv_data->pdev->dev, | 790 | dev_dbg(&drv_data->pdev->dev, |