diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-05-15 05:51:39 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-05-23 15:14:17 -0400 |
commit | 3fc63d762ff4595c90d4b9b5682a9655fc28cae4 (patch) | |
tree | c891b6b873e4a287651f52a40d80c319cc62c3e0 | |
parent | 8703ffdd90c696bd66bb3247e59e76811fbdf22e (diff) |
crypto: ux500/cryp - Set DMA configuration though dma_slave_config()
The DMA controller currently takes configuration information from
information passed though dma_channel_request(), but it shouldn't.
Using the API, the DMA channel should only be configured during
a dma_slave_config() call.
Cc: David S. Miller <davem@davemloft.net>
Cc: Andreas Westin <andreas.westin@stericsson.com>
Cc: linux-crypto@vger.kernel.org
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/crypto/ux500/cryp/cryp.h | 7 | ||||
-rw-r--r-- | drivers/crypto/ux500/cryp/cryp_core.c | 17 |
2 files changed, 23 insertions, 1 deletions
diff --git a/drivers/crypto/ux500/cryp/cryp.h b/drivers/crypto/ux500/cryp/cryp.h index 14cfd05b777a..d1d6606fe56c 100644 --- a/drivers/crypto/ux500/cryp/cryp.h +++ b/drivers/crypto/ux500/cryp/cryp.h | |||
@@ -114,6 +114,9 @@ enum cryp_status_id { | |||
114 | }; | 114 | }; |
115 | 115 | ||
116 | /* Cryp DMA interface */ | 116 | /* Cryp DMA interface */ |
117 | #define CRYP_DMA_TX_FIFO 0x08 | ||
118 | #define CRYP_DMA_RX_FIFO 0x10 | ||
119 | |||
117 | enum cryp_dma_req_type { | 120 | enum cryp_dma_req_type { |
118 | CRYP_DMA_DISABLE_BOTH, | 121 | CRYP_DMA_DISABLE_BOTH, |
119 | CRYP_DMA_ENABLE_IN_DATA, | 122 | CRYP_DMA_ENABLE_IN_DATA, |
@@ -217,7 +220,8 @@ struct cryp_dma { | |||
217 | 220 | ||
218 | /** | 221 | /** |
219 | * struct cryp_device_data - structure for a cryp device. | 222 | * struct cryp_device_data - structure for a cryp device. |
220 | * @base: Pointer to the hardware base address. | 223 | * @base: Pointer to virtual base address of the cryp device. |
224 | * @phybase: Pointer to physical memory location of the cryp device. | ||
221 | * @dev: Pointer to the devices dev structure. | 225 | * @dev: Pointer to the devices dev structure. |
222 | * @clk: Pointer to the device's clock control. | 226 | * @clk: Pointer to the device's clock control. |
223 | * @pwr_regulator: Pointer to the device's power control. | 227 | * @pwr_regulator: Pointer to the device's power control. |
@@ -232,6 +236,7 @@ struct cryp_dma { | |||
232 | */ | 236 | */ |
233 | struct cryp_device_data { | 237 | struct cryp_device_data { |
234 | struct cryp_register __iomem *base; | 238 | struct cryp_register __iomem *base; |
239 | phys_addr_t phybase; | ||
235 | struct device *dev; | 240 | struct device *dev; |
236 | struct clk *clk; | 241 | struct clk *clk; |
237 | struct regulator *pwr_regulator; | 242 | struct regulator *pwr_regulator; |
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c index ccdf17392411..d9c863d5ba7d 100644 --- a/drivers/crypto/ux500/cryp/cryp_core.c +++ b/drivers/crypto/ux500/cryp/cryp_core.c | |||
@@ -475,6 +475,19 @@ static int cryp_get_device_data(struct cryp_ctx *ctx, | |||
475 | static void cryp_dma_setup_channel(struct cryp_device_data *device_data, | 475 | static void cryp_dma_setup_channel(struct cryp_device_data *device_data, |
476 | struct device *dev) | 476 | struct device *dev) |
477 | { | 477 | { |
478 | struct dma_slave_config mem2cryp = { | ||
479 | .direction = DMA_MEM_TO_DEV, | ||
480 | .dst_addr = device_data->phybase + CRYP_DMA_TX_FIFO, | ||
481 | .dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, | ||
482 | .dst_maxburst = 4, | ||
483 | }; | ||
484 | struct dma_slave_config cryp2mem = { | ||
485 | .direction = DMA_DEV_TO_MEM, | ||
486 | .src_addr = device_data->phybase + CRYP_DMA_RX_FIFO, | ||
487 | .src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, | ||
488 | .src_maxburst = 4, | ||
489 | }; | ||
490 | |||
478 | dma_cap_zero(device_data->dma.mask); | 491 | dma_cap_zero(device_data->dma.mask); |
479 | dma_cap_set(DMA_SLAVE, device_data->dma.mask); | 492 | dma_cap_set(DMA_SLAVE, device_data->dma.mask); |
480 | 493 | ||
@@ -490,6 +503,9 @@ static void cryp_dma_setup_channel(struct cryp_device_data *device_data, | |||
490 | stedma40_filter, | 503 | stedma40_filter, |
491 | device_data->dma.cfg_cryp2mem); | 504 | device_data->dma.cfg_cryp2mem); |
492 | 505 | ||
506 | dmaengine_slave_config(device_data->dma.chan_mem2cryp, &mem2cryp); | ||
507 | dmaengine_slave_config(device_data->dma.chan_cryp2mem, &cryp2mem); | ||
508 | |||
493 | init_completion(&device_data->dma.cryp_dma_complete); | 509 | init_completion(&device_data->dma.cryp_dma_complete); |
494 | } | 510 | } |
495 | 511 | ||
@@ -1431,6 +1447,7 @@ static int ux500_cryp_probe(struct platform_device *pdev) | |||
1431 | goto out_kfree; | 1447 | goto out_kfree; |
1432 | } | 1448 | } |
1433 | 1449 | ||
1450 | device_data->phybase = res->start; | ||
1434 | device_data->base = ioremap(res->start, resource_size(res)); | 1451 | device_data->base = ioremap(res->start, resource_size(res)); |
1435 | if (!device_data->base) { | 1452 | if (!device_data->base) { |
1436 | dev_err(dev, "[%s]: ioremap failed!", __func__); | 1453 | dev_err(dev, "[%s]: ioremap failed!", __func__); |