Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 102169
b: refs/heads/master
c: 4ac24a8
h: refs/heads/master
i:
  102167: ec263a4
v: v3
  • Loading branch information
Nicolas Ferre authored and Pierre Ossman committed Jul 15, 2008
1 parent f716ff0 commit a99eab1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c5a89c6c0805959f813e8342d6f4040860f6d7db
refs/heads/master: 4ac24a8722b97d5b4cfc48a4fbd0b2489e358d4d
40 changes: 34 additions & 6 deletions trunk/drivers/mmc/host/at91_mci.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ static void at91_mci_post_dma_read(struct at91mci_host *host)

dma_unmap_page(NULL, sg->dma_address, sg->length, DMA_FROM_DEVICE);

data->bytes_xfered += sg->length;

if (cpu_is_at91rm9200()) { /* AT91RM9200 errata */
unsigned int *buffer;
int index;
Expand All @@ -357,6 +355,8 @@ static void at91_mci_post_dma_read(struct at91mci_host *host)
}

flush_dcache_page(sg_page(sg));

data->bytes_xfered += sg->length;
}

/* Is there another transfer to trigger? */
Expand Down Expand Up @@ -397,10 +397,32 @@ static void at91_mci_handle_transmitted(struct at91mci_host *host)
at91_mci_write(host, AT91_MCI_IER, AT91_MCI_BLKE);
} else
at91_mci_write(host, AT91_MCI_IER, AT91_MCI_NOTBUSY);
}

/*
* Update bytes tranfered count during a write operation
*/
static void at91_mci_update_bytes_xfered(struct at91mci_host *host)
{
struct mmc_data *data;

data->bytes_xfered = host->total_length;
/* always deal with the effective request (and not the current cmd) */

if (host->request->cmd && host->request->cmd->error != 0)
return;

if (host->request->data) {
data = host->request->data;
if (data->flags & MMC_DATA_WRITE) {
/* card is in IDLE mode now */
pr_debug("-> bytes_xfered %d, total_length = %d\n",
data->bytes_xfered, host->total_length);
data->bytes_xfered = host->total_length;
}
}
}


/*Handle after command sent ready*/
static int at91_mci_handle_cmdrdy(struct at91mci_host *host)
{
Expand All @@ -413,8 +435,7 @@ static int at91_mci_handle_cmdrdy(struct at91mci_host *host)
} else return 1;
} else if (host->cmd->data->flags & MMC_DATA_WRITE) {
/*After sendding multi-block-write command, start DMA transfer*/
at91_mci_write(host, AT91_MCI_IER, AT91_MCI_TXBUFE);
at91_mci_write(host, AT91_MCI_IER, AT91_MCI_BLKE);
at91_mci_write(host, AT91_MCI_IER, AT91_MCI_TXBUFE | AT91_MCI_BLKE);
at91_mci_write(host, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN);
}

Expand Down Expand Up @@ -817,6 +838,7 @@ static irqreturn_t at91_mci_irq(int irq, void *devid)

if (int_status & AT91_MCI_NOTBUSY) {
pr_debug("Card is ready\n");
at91_mci_update_bytes_xfered(host);
completed = 1;
}

Expand All @@ -825,7 +847,13 @@ static irqreturn_t at91_mci_irq(int irq, void *devid)

if (int_status & AT91_MCI_BLKE) {
pr_debug("Block transfer has ended\n");
completed = 1;
if (host->request->data && host->request->data->blocks > 1) {
/* multi block write : complete multi write
* command and send stop */
completed = 1;
} else {
at91_mci_write(host, AT91_MCI_IER, AT91_MCI_NOTBUSY);
}
}

if (int_status & AT91_MCI_TXRDY)
Expand Down

0 comments on commit a99eab1

Please sign in to comment.