Commit 87ae7bbe authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Chris Ball

mmc: sdhi/tmio: add DT DMA support

Add support for initialising DMA from the Device Tree.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent eec95ee2
...@@ -144,6 +144,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) ...@@ -144,6 +144,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
struct tmio_mmc_host *host; struct tmio_mmc_host *host;
int irq, ret, i = 0; int irq, ret, i = 0;
bool multiplexed_isr = true; bool multiplexed_isr = true;
struct tmio_mmc_dma *dma_priv;
priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL);
if (priv == NULL) { if (priv == NULL) {
...@@ -152,6 +153,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) ...@@ -152,6 +153,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
} }
mmc_data = &priv->mmc_data; mmc_data = &priv->mmc_data;
dma_priv = &priv->dma_priv;
if (p) { if (p) {
if (p->init) { if (p->init) {
...@@ -184,8 +186,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) ...@@ -184,8 +186,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
mmc_data->get_cd = sh_mobile_sdhi_get_cd; mmc_data->get_cd = sh_mobile_sdhi_get_cd;
if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
struct tmio_mmc_dma *dma_priv = &priv->dma_priv;
/* /*
* Yes, we have to provide slave IDs twice to TMIO: * Yes, we have to provide slave IDs twice to TMIO:
* once as a filter parameter and once for channel * once as a filter parameter and once for channel
...@@ -195,14 +195,14 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) ...@@ -195,14 +195,14 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
dma_priv->chan_priv_rx = (void *)p->dma_slave_rx; dma_priv->chan_priv_rx = (void *)p->dma_slave_rx;
dma_priv->slave_id_tx = p->dma_slave_tx; dma_priv->slave_id_tx = p->dma_slave_tx;
dma_priv->slave_id_rx = p->dma_slave_rx; dma_priv->slave_id_rx = p->dma_slave_rx;
dma_priv->alignment_shift = 1; /* 2-byte alignment */
dma_priv->filter = shdma_chan_filter;
mmc_data->dma = dma_priv;
} }
} }
dma_priv->alignment_shift = 1; /* 2-byte alignment */
dma_priv->filter = shdma_chan_filter;
mmc_data->dma = dma_priv;
/* /*
* All SDHI blocks support 2-byte and larger block sizes in 4-bit * All SDHI blocks support 2-byte and larger block sizes in 4-bit
* bus width mode. * bus width mode.
......
...@@ -264,7 +264,8 @@ static void tmio_mmc_tasklet_fn(unsigned long arg) ...@@ -264,7 +264,8 @@ static void tmio_mmc_tasklet_fn(unsigned long arg)
void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata)
{ {
/* We can only either use DMA for both Tx and Rx or not use it at all */ /* We can only either use DMA for both Tx and Rx or not use it at all */
if (!pdata->dma) if (!pdata->dma || (!host->pdev->dev.of_node &&
(!pdata->dma->chan_priv_tx || !pdata->dma->chan_priv_rx)))
return; return;
if (!host->chan_tx && !host->chan_rx) { if (!host->chan_tx && !host->chan_rx) {
...@@ -280,15 +281,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat ...@@ -280,15 +281,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
dma_cap_zero(mask); dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask); dma_cap_set(DMA_SLAVE, mask);
host->chan_tx = dma_request_channel(mask, pdata->dma->filter, host->chan_tx = dma_request_slave_channel_compat(mask,
pdata->dma->chan_priv_tx); pdata->dma->filter, pdata->dma->chan_priv_tx,
&host->pdev->dev, "tx");
dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__, dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__,
host->chan_tx); host->chan_tx);
if (!host->chan_tx) if (!host->chan_tx)
return; return;
cfg.slave_id = pdata->dma->slave_id_tx; if (pdata->dma->chan_priv_tx)
cfg.slave_id = pdata->dma->slave_id_tx;
cfg.direction = DMA_MEM_TO_DEV; cfg.direction = DMA_MEM_TO_DEV;
cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift); cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift);
cfg.src_addr = 0; cfg.src_addr = 0;
...@@ -296,15 +299,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat ...@@ -296,15 +299,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
if (ret < 0) if (ret < 0)
goto ecfgtx; goto ecfgtx;
host->chan_rx = dma_request_channel(mask, pdata->dma->filter, host->chan_rx = dma_request_slave_channel_compat(mask,
pdata->dma->chan_priv_rx); pdata->dma->filter, pdata->dma->chan_priv_rx,
&host->pdev->dev, "rx");
dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__,
host->chan_rx); host->chan_rx);
if (!host->chan_rx) if (!host->chan_rx)
goto ereqrx; goto ereqrx;
cfg.slave_id = pdata->dma->slave_id_rx; if (pdata->dma->chan_priv_rx)
cfg.slave_id = pdata->dma->slave_id_rx;
cfg.direction = DMA_DEV_TO_MEM; cfg.direction = DMA_DEV_TO_MEM;
cfg.src_addr = cfg.dst_addr; cfg.src_addr = cfg.dst_addr;
cfg.dst_addr = 0; cfg.dst_addr = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment