Skip to content

Commit 94a5afb

Browse files
committed
mmc: litex_mmc: add IRQ support for DMA data xfers
Signed-off-by: Gabriel Somlo <[email protected]>
1 parent cb12420 commit 94a5afb

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

drivers/mmc/host/litex_mmc.c

+25-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct litex_mmc_host {
8787
dma_addr_t dma;
8888

8989
struct completion cmd_done;
90+
struct completion data_done;
9091
int irq;
9192

9293
unsigned int ref_clk;
@@ -258,6 +259,18 @@ static irqreturn_t litex_mmc_interrupt(int irq, void *arg)
258259
complete(&host->cmd_done);
259260
}
260261

262+
/* Check for DMA read completed */
263+
if (pending & SDIRQ_SD_TO_MEM_DONE) {
264+
handled |= SDIRQ_SD_TO_MEM_DONE;
265+
complete(&host->data_done);
266+
}
267+
268+
/* Check for DMA write completed */
269+
if (pending & SDIRQ_MEM_TO_SD_DONE) {
270+
handled |= SDIRQ_MEM_TO_SD_DONE;
271+
complete(&host->data_done);
272+
}
273+
261274
/* Acknowledge handled interrupts */
262275
litex_write32(host->sdirq + LITEX_IRQ_PENDING, handled);
263276

@@ -369,6 +382,10 @@ static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
369382
return;
370383
}
371384

385+
if (host->irq > 0) {
386+
reinit_completion(&host->data_done);
387+
}
388+
372389
litex_mmc_do_dma(host, data, &len, &direct, &transfer);
373390
}
374391

@@ -384,6 +401,9 @@ static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
384401
u8 evt;
385402

386403
/* Wait for completion of (read or write) DMA transfer */
404+
if (host->irq > 0) {
405+
wait_for_completion(&host->data_done);
406+
}
387407
cmd->error = readx_poll_timeout(litex_read8, reg,
388408
evt, evt & SD_BIT_DONE,
389409
SD_SLEEP_US, SD_TIMEOUT_US);
@@ -507,11 +527,14 @@ static int litex_mmc_irq_init(struct platform_device *pdev,
507527

508528
/* Clear & enable interrupts */
509529
litex_write32(host->sdirq + LITEX_IRQ_PENDING,
510-
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE);
530+
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE |
531+
SDIRQ_SD_TO_MEM_DONE | SDIRQ_MEM_TO_SD_DONE);
511532
litex_write32(host->sdirq + LITEX_IRQ_ENABLE,
512-
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE);
533+
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE |
534+
SDIRQ_SD_TO_MEM_DONE | SDIRQ_MEM_TO_SD_DONE);
513535

514536
init_completion(&host->cmd_done);
537+
init_completion(&host->data_done);
515538

516539
return 0;
517540

0 commit comments

Comments
 (0)