aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi_bfin5xx.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 52beb5c924b7..ce4692cdb3b2 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -294,16 +294,14 @@ static void u8_cs_chg_writer(struct driver_data *drv_data)
294{ 294{
295 struct chip_data *chip = drv_data->cur_chip; 295 struct chip_data *chip = drv_data->cur_chip;
296 296
297 /* poll for SPI completion before start */
298 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
299 cpu_relax();
300
301 while (drv_data->tx < drv_data->tx_end) { 297 while (drv_data->tx < drv_data->tx_end) {
302 cs_active(drv_data, chip); 298 cs_active(drv_data, chip);
303 299
304 write_TDBR(drv_data, (*(u8 *) (drv_data->tx))); 300 write_TDBR(drv_data, (*(u8 *) (drv_data->tx)));
305 while (read_STAT(drv_data) & BIT_STAT_TXS) 301 while (read_STAT(drv_data) & BIT_STAT_TXS)
306 cpu_relax(); 302 cpu_relax();
303 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
304 cpu_relax();
307 305
308 cs_deactive(drv_data, chip); 306 cs_deactive(drv_data, chip);
309 307
@@ -342,31 +340,20 @@ static void u8_cs_chg_reader(struct driver_data *drv_data)
342{ 340{
343 struct chip_data *chip = drv_data->cur_chip; 341 struct chip_data *chip = drv_data->cur_chip;
344 342
345 /* poll for SPI completion before start */ 343 while (drv_data->rx < drv_data->rx_end) {
346 while (!(read_STAT(drv_data) & BIT_STAT_SPIF)) 344 cs_active(drv_data, chip);
347 cpu_relax(); 345 read_RDBR(drv_data); /* kick off */
348
349 /* clear TDBR buffer before read(else it will be shifted out) */
350 write_TDBR(drv_data, 0xFFFF);
351 346
352 cs_active(drv_data, chip); 347 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
353 dummy_read(drv_data); 348 cpu_relax();
349 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
350 cpu_relax();
354 351
355 while (drv_data->rx < drv_data->rx_end - 1) { 352 *(u8 *) (drv_data->rx) = read_SHAW(drv_data);
356 cs_deactive(drv_data, chip); 353 cs_deactive(drv_data, chip);
357 354
358 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
359 cpu_relax();
360 cs_active(drv_data, chip);
361 *(u8 *) (drv_data->rx) = read_RDBR(drv_data);
362 ++drv_data->rx; 355 ++drv_data->rx;
363 } 356 }
364 cs_deactive(drv_data, chip);
365
366 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
367 cpu_relax();
368 *(u8 *) (drv_data->rx) = read_SHAW(drv_data);
369 ++drv_data->rx;
370} 357}
371 358
372static void u8_duplex(struct driver_data *drv_data) 359static void u8_duplex(struct driver_data *drv_data)
@@ -392,15 +379,12 @@ static void u8_cs_chg_duplex(struct driver_data *drv_data)
392{ 379{
393 struct chip_data *chip = drv_data->cur_chip; 380 struct chip_data *chip = drv_data->cur_chip;
394 381
395 /* poll for SPI completion before start */
396 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
397 cpu_relax();
398
399 while (drv_data->rx < drv_data->rx_end) { 382 while (drv_data->rx < drv_data->rx_end) {
400 cs_active(drv_data, chip); 383 cs_active(drv_data, chip);
401 384
402 write_TDBR(drv_data, (*(u8 *) (drv_data->tx))); 385 write_TDBR(drv_data, (*(u8 *) (drv_data->tx)));
403 while (read_STAT(drv_data) & BIT_STAT_TXS) 386
387 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
404 cpu_relax(); 388 cpu_relax();
405 while (!(read_STAT(drv_data) & BIT_STAT_RXS)) 389 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
406 cpu_relax(); 390 cpu_relax();