aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2010-03-05 16:43:26 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 14:26:36 -0500
commit118cd17d4137f34c747c32765c1cb4d3910c04d4 (patch)
tree37770764fb27313fa15ebb1bc29c13673614f185 /drivers/mmc
parent3fb7fb4a01d09f81d1daaf65e52d929734bd691f (diff)
sdhci: add adma descriptor set call
The code to write the ADMA descriptor into memory is repeated several times throughout sdhci_adma_table_pre, and thus should be moved into a common function. This will also be useful if the patch to make the write more efficient is accepted. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Cc: Pierre Ossman <pierre@ossman.eu> Cc: <linux-mmc@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c279fbc4c2e5..fcdd00785033 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -376,6 +376,20 @@ static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags)
376 local_irq_restore(*flags); 376 local_irq_restore(*flags);
377} 377}
378 378
379static void sdhci_set_adma_desc(u8 *desc, u32 addr, int len, unsigned cmd)
380{
381 desc[7] = (addr >> 24) & 0xff;
382 desc[6] = (addr >> 16) & 0xff;
383 desc[5] = (addr >> 8) & 0xff;
384 desc[4] = (addr >> 0) & 0xff;
385
386 desc[3] = (len >> 8) & 0xff;
387 desc[2] = (len >> 0) & 0xff;
388
389 desc[0] = cmd & 0xff;
390 desc[1] = cmd >> 8;
391}
392
379static int sdhci_adma_table_pre(struct sdhci_host *host, 393static int sdhci_adma_table_pre(struct sdhci_host *host,
380 struct mmc_data *data) 394 struct mmc_data *data)
381{ 395{
@@ -443,19 +457,11 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
443 sdhci_kunmap_atomic(buffer, &flags); 457 sdhci_kunmap_atomic(buffer, &flags);
444 } 458 }
445 459
446 desc[7] = (align_addr >> 24) & 0xff; 460 /* tran, valid */
447 desc[6] = (align_addr >> 16) & 0xff; 461 sdhci_set_adma_desc(desc, align_addr, offset, 0x21);
448 desc[5] = (align_addr >> 8) & 0xff;
449 desc[4] = (align_addr >> 0) & 0xff;
450 462
451 BUG_ON(offset > 65536); 463 BUG_ON(offset > 65536);
452 464
453 desc[3] = (offset >> 8) & 0xff;
454 desc[2] = (offset >> 0) & 0xff;
455
456 desc[1] = 0x00;
457 desc[0] = 0x21; /* tran, valid */
458
459 align += 4; 465 align += 4;
460 align_addr += 4; 466 align_addr += 4;
461 467
@@ -465,19 +471,10 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
465 len -= offset; 471 len -= offset;
466 } 472 }
467 473
468 desc[7] = (addr >> 24) & 0xff;
469 desc[6] = (addr >> 16) & 0xff;
470 desc[5] = (addr >> 8) & 0xff;
471 desc[4] = (addr >> 0) & 0xff;
472
473 BUG_ON(len > 65536); 474 BUG_ON(len > 65536);
474 475
475 desc[3] = (len >> 8) & 0xff; 476 /* tran, valid */
476 desc[2] = (len >> 0) & 0xff; 477 sdhci_set_adma_desc(desc, addr, len, 0x21);
477
478 desc[1] = 0x00;
479 desc[0] = 0x21; /* tran, valid */
480
481 desc += 8; 478 desc += 8;
482 479
483 /* 480 /*
@@ -490,16 +487,9 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
490 /* 487 /*
491 * Add a terminating entry. 488 * Add a terminating entry.
492 */ 489 */
493 desc[7] = 0;
494 desc[6] = 0;
495 desc[5] = 0;
496 desc[4] = 0;
497
498 desc[3] = 0;
499 desc[2] = 0;
500 490
501 desc[1] = 0x00; 491 /* nop, end, valid */
502 desc[0] = 0x03; /* nop, end, valid */ 492 sdhci_set_adma_desc(desc, 0, 0, 0x3);
503 493
504 /* 494 /*
505 * Resync align buffer as we might have changed it. 495 * Resync align buffer as we might have changed it.