Skip to content

Commit

Permalink
mmc: litex_mmc: add IRQ support for DMA data xfers
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Somlo <[email protected]>
  • Loading branch information
gsomlo committed Oct 5, 2023
1 parent cb12420 commit 94a5afb
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions drivers/mmc/host/litex_mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct litex_mmc_host {
dma_addr_t dma;

struct completion cmd_done;
struct completion data_done;
int irq;

unsigned int ref_clk;
Expand Down Expand Up @@ -258,6 +259,18 @@ static irqreturn_t litex_mmc_interrupt(int irq, void *arg)
complete(&host->cmd_done);
}

/* Check for DMA read completed */
if (pending & SDIRQ_SD_TO_MEM_DONE) {
handled |= SDIRQ_SD_TO_MEM_DONE;
complete(&host->data_done);
}

/* Check for DMA write completed */
if (pending & SDIRQ_MEM_TO_SD_DONE) {
handled |= SDIRQ_MEM_TO_SD_DONE;
complete(&host->data_done);
}

/* Acknowledge handled interrupts */
litex_write32(host->sdirq + LITEX_IRQ_PENDING, handled);

Expand Down Expand Up @@ -369,6 +382,10 @@ static void litex_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
return;
}

if (host->irq > 0) {
reinit_completion(&host->data_done);
}

litex_mmc_do_dma(host, data, &len, &direct, &transfer);
}

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

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

/* Clear & enable interrupts */
litex_write32(host->sdirq + LITEX_IRQ_PENDING,
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE);
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE |
SDIRQ_SD_TO_MEM_DONE | SDIRQ_MEM_TO_SD_DONE);
litex_write32(host->sdirq + LITEX_IRQ_ENABLE,
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE);
SDIRQ_CARD_DETECT | SDIRQ_CMD_DONE |
SDIRQ_SD_TO_MEM_DONE | SDIRQ_MEM_TO_SD_DONE);

init_completion(&host->cmd_done);
init_completion(&host->data_done);

return 0;

Expand Down

0 comments on commit 94a5afb

Please sign in to comment.