diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2015-01-12 23:57:33 -0500 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2015-01-20 04:22:09 -0500 |
commit | 7ecc09bab1e856e6730a4dd8a3bc1c28bb6ab3be (patch) | |
tree | 28bd3e18cf937772d289510546be20876ae356a2 /drivers/mmc | |
parent | 94b110aff8679b14f46fd6653ea87b42fe1555be (diff) |
mmc: tmio: tmio_mmc_host has .dma
Current .dma is implemented under tmio_mmc_data.
It goes to tmio_mmc_host by this patch.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sh_mobile_sdhi.c | 4 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc.h | 11 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc_dma.c | 24 |
3 files changed, 24 insertions, 15 deletions
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index cf062c4d87a9..288e78d2c7a1 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c | |||
@@ -213,6 +213,8 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
213 | goto eprobe; | 213 | goto eprobe; |
214 | } | 214 | } |
215 | 215 | ||
216 | host->dma = dma_priv; | ||
217 | |||
216 | mmc_data->clk_enable = sh_mobile_sdhi_clk_enable; | 218 | mmc_data->clk_enable = sh_mobile_sdhi_clk_enable; |
217 | mmc_data->clk_disable = sh_mobile_sdhi_clk_disable; | 219 | mmc_data->clk_disable = sh_mobile_sdhi_clk_disable; |
218 | mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED; | 220 | mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED; |
@@ -241,8 +243,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
241 | dma_priv->alignment_shift = 1; /* 2-byte alignment */ | 243 | dma_priv->alignment_shift = 1; /* 2-byte alignment */ |
242 | dma_priv->filter = shdma_chan_filter; | 244 | dma_priv->filter = shdma_chan_filter; |
243 | 245 | ||
244 | mmc_data->dma = dma_priv; | ||
245 | |||
246 | /* | 246 | /* |
247 | * All SDHI blocks support 2-byte and larger block sizes in 4-bit | 247 | * All SDHI blocks support 2-byte and larger block sizes in 4-bit |
248 | * bus width mode. | 248 | * bus width mode. |
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 60d6747f0df5..49a2559ff489 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h | |||
@@ -40,6 +40,16 @@ | |||
40 | 40 | ||
41 | struct tmio_mmc_data; | 41 | struct tmio_mmc_data; |
42 | 42 | ||
43 | struct tmio_mmc_dma { | ||
44 | void *chan_priv_tx; | ||
45 | void *chan_priv_rx; | ||
46 | int slave_id_tx; | ||
47 | int slave_id_rx; | ||
48 | int alignment_shift; | ||
49 | dma_addr_t dma_rx_offset; | ||
50 | bool (*filter)(struct dma_chan *chan, void *arg); | ||
51 | }; | ||
52 | |||
43 | struct tmio_mmc_host { | 53 | struct tmio_mmc_host { |
44 | void __iomem *ctl; | 54 | void __iomem *ctl; |
45 | struct mmc_command *cmd; | 55 | struct mmc_command *cmd; |
@@ -59,6 +69,7 @@ struct tmio_mmc_host { | |||
59 | 69 | ||
60 | struct platform_device *pdev; | 70 | struct platform_device *pdev; |
61 | struct tmio_mmc_data *pdata; | 71 | struct tmio_mmc_data *pdata; |
72 | struct tmio_mmc_dma *dma; | ||
62 | 73 | ||
63 | /* DMA support */ | 74 | /* DMA support */ |
64 | bool force_pio; | 75 | bool force_pio; |
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c index 7d077388b9eb..6c214d60bbb6 100644 --- a/drivers/mmc/host/tmio_mmc_dma.c +++ b/drivers/mmc/host/tmio_mmc_dma.c | |||
@@ -49,11 +49,10 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) | |||
49 | struct scatterlist *sg = host->sg_ptr, *sg_tmp; | 49 | struct scatterlist *sg = host->sg_ptr, *sg_tmp; |
50 | struct dma_async_tx_descriptor *desc = NULL; | 50 | struct dma_async_tx_descriptor *desc = NULL; |
51 | struct dma_chan *chan = host->chan_rx; | 51 | struct dma_chan *chan = host->chan_rx; |
52 | struct tmio_mmc_data *pdata = host->pdata; | ||
53 | dma_cookie_t cookie; | 52 | dma_cookie_t cookie; |
54 | int ret, i; | 53 | int ret, i; |
55 | bool aligned = true, multiple = true; | 54 | bool aligned = true, multiple = true; |
56 | unsigned int align = (1 << pdata->dma->alignment_shift) - 1; | 55 | unsigned int align = (1 << host->dma->alignment_shift) - 1; |
57 | 56 | ||
58 | for_each_sg(sg, sg_tmp, host->sg_len, i) { | 57 | for_each_sg(sg, sg_tmp, host->sg_len, i) { |
59 | if (sg_tmp->offset & align) | 58 | if (sg_tmp->offset & align) |
@@ -126,11 +125,10 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host) | |||
126 | struct scatterlist *sg = host->sg_ptr, *sg_tmp; | 125 | struct scatterlist *sg = host->sg_ptr, *sg_tmp; |
127 | struct dma_async_tx_descriptor *desc = NULL; | 126 | struct dma_async_tx_descriptor *desc = NULL; |
128 | struct dma_chan *chan = host->chan_tx; | 127 | struct dma_chan *chan = host->chan_tx; |
129 | struct tmio_mmc_data *pdata = host->pdata; | ||
130 | dma_cookie_t cookie; | 128 | dma_cookie_t cookie; |
131 | int ret, i; | 129 | int ret, i; |
132 | bool aligned = true, multiple = true; | 130 | bool aligned = true, multiple = true; |
133 | unsigned int align = (1 << pdata->dma->alignment_shift) - 1; | 131 | unsigned int align = (1 << host->dma->alignment_shift) - 1; |
134 | 132 | ||
135 | for_each_sg(sg, sg_tmp, host->sg_len, i) { | 133 | for_each_sg(sg, sg_tmp, host->sg_len, i) { |
136 | if (sg_tmp->offset & align) | 134 | if (sg_tmp->offset & align) |
@@ -262,8 +260,8 @@ out: | |||
262 | void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) | 260 | void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) |
263 | { | 261 | { |
264 | /* We can only either use DMA for both Tx and Rx or not use it at all */ | 262 | /* We can only either use DMA for both Tx and Rx or not use it at all */ |
265 | if (!pdata->dma || (!host->pdev->dev.of_node && | 263 | if (!host->dma || (!host->pdev->dev.of_node && |
266 | (!pdata->dma->chan_priv_tx || !pdata->dma->chan_priv_rx))) | 264 | (!host->dma->chan_priv_tx || !host->dma->chan_priv_rx))) |
267 | return; | 265 | return; |
268 | 266 | ||
269 | if (!host->chan_tx && !host->chan_rx) { | 267 | if (!host->chan_tx && !host->chan_rx) { |
@@ -280,7 +278,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat | |||
280 | dma_cap_set(DMA_SLAVE, mask); | 278 | dma_cap_set(DMA_SLAVE, mask); |
281 | 279 | ||
282 | host->chan_tx = dma_request_slave_channel_compat(mask, | 280 | host->chan_tx = dma_request_slave_channel_compat(mask, |
283 | pdata->dma->filter, pdata->dma->chan_priv_tx, | 281 | host->dma->filter, host->dma->chan_priv_tx, |
284 | &host->pdev->dev, "tx"); | 282 | &host->pdev->dev, "tx"); |
285 | dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__, | 283 | dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__, |
286 | host->chan_tx); | 284 | host->chan_tx); |
@@ -288,8 +286,8 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat | |||
288 | if (!host->chan_tx) | 286 | if (!host->chan_tx) |
289 | return; | 287 | return; |
290 | 288 | ||
291 | if (pdata->dma->chan_priv_tx) | 289 | if (host->dma->chan_priv_tx) |
292 | cfg.slave_id = pdata->dma->slave_id_tx; | 290 | cfg.slave_id = host->dma->slave_id_tx; |
293 | cfg.direction = DMA_MEM_TO_DEV; | 291 | cfg.direction = DMA_MEM_TO_DEV; |
294 | cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift); | 292 | cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift); |
295 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | 293 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; |
@@ -299,7 +297,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat | |||
299 | goto ecfgtx; | 297 | goto ecfgtx; |
300 | 298 | ||
301 | host->chan_rx = dma_request_slave_channel_compat(mask, | 299 | host->chan_rx = dma_request_slave_channel_compat(mask, |
302 | pdata->dma->filter, pdata->dma->chan_priv_rx, | 300 | host->dma->filter, host->dma->chan_priv_rx, |
303 | &host->pdev->dev, "rx"); | 301 | &host->pdev->dev, "rx"); |
304 | dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, | 302 | dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, |
305 | host->chan_rx); | 303 | host->chan_rx); |
@@ -307,10 +305,10 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat | |||
307 | if (!host->chan_rx) | 305 | if (!host->chan_rx) |
308 | goto ereqrx; | 306 | goto ereqrx; |
309 | 307 | ||
310 | if (pdata->dma->chan_priv_rx) | 308 | if (host->dma->chan_priv_rx) |
311 | cfg.slave_id = pdata->dma->slave_id_rx; | 309 | cfg.slave_id = host->dma->slave_id_rx; |
312 | cfg.direction = DMA_DEV_TO_MEM; | 310 | cfg.direction = DMA_DEV_TO_MEM; |
313 | cfg.src_addr = cfg.dst_addr + pdata->dma->dma_rx_offset; | 311 | cfg.src_addr = cfg.dst_addr + host->dma->dma_rx_offset; |
314 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | 312 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; |
315 | cfg.dst_addr = 0; | 313 | cfg.dst_addr = 0; |
316 | ret = dmaengine_slave_config(host->chan_rx, &cfg); | 314 | ret = dmaengine_slave_config(host->chan_rx, &cfg); |