diff options
Diffstat (limited to 'drivers/dma/edma.c')
| -rw-r--r-- | drivers/dma/edma.c | 73 |
1 files changed, 23 insertions, 50 deletions
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index b969206439b7..276157f22612 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | #include <linux/dmaengine.h> | 16 | #include <linux/dmaengine.h> |
| 17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
| 18 | #include <linux/edma.h> | ||
| 18 | #include <linux/err.h> | 19 | #include <linux/err.h> |
| 19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 20 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
| @@ -244,8 +245,9 @@ static void edma_execute(struct edma_chan *echan) | |||
| 244 | } | 245 | } |
| 245 | } | 246 | } |
| 246 | 247 | ||
| 247 | static int edma_terminate_all(struct edma_chan *echan) | 248 | static int edma_terminate_all(struct dma_chan *chan) |
| 248 | { | 249 | { |
| 250 | struct edma_chan *echan = to_edma_chan(chan); | ||
| 249 | unsigned long flags; | 251 | unsigned long flags; |
| 250 | LIST_HEAD(head); | 252 | LIST_HEAD(head); |
| 251 | 253 | ||
| @@ -273,9 +275,11 @@ static int edma_terminate_all(struct edma_chan *echan) | |||
| 273 | return 0; | 275 | return 0; |
| 274 | } | 276 | } |
| 275 | 277 | ||
| 276 | static int edma_slave_config(struct edma_chan *echan, | 278 | static int edma_slave_config(struct dma_chan *chan, |
| 277 | struct dma_slave_config *cfg) | 279 | struct dma_slave_config *cfg) |
| 278 | { | 280 | { |
| 281 | struct edma_chan *echan = to_edma_chan(chan); | ||
| 282 | |||
| 279 | if (cfg->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES || | 283 | if (cfg->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES || |
| 280 | cfg->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES) | 284 | cfg->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES) |
| 281 | return -EINVAL; | 285 | return -EINVAL; |
| @@ -285,8 +289,10 @@ static int edma_slave_config(struct edma_chan *echan, | |||
| 285 | return 0; | 289 | return 0; |
| 286 | } | 290 | } |
| 287 | 291 | ||
| 288 | static int edma_dma_pause(struct edma_chan *echan) | 292 | static int edma_dma_pause(struct dma_chan *chan) |
| 289 | { | 293 | { |
| 294 | struct edma_chan *echan = to_edma_chan(chan); | ||
| 295 | |||
| 290 | /* Pause/Resume only allowed with cyclic mode */ | 296 | /* Pause/Resume only allowed with cyclic mode */ |
| 291 | if (!echan->edesc || !echan->edesc->cyclic) | 297 | if (!echan->edesc || !echan->edesc->cyclic) |
| 292 | return -EINVAL; | 298 | return -EINVAL; |
| @@ -295,8 +301,10 @@ static int edma_dma_pause(struct edma_chan *echan) | |||
| 295 | return 0; | 301 | return 0; |
| 296 | } | 302 | } |
| 297 | 303 | ||
| 298 | static int edma_dma_resume(struct edma_chan *echan) | 304 | static int edma_dma_resume(struct dma_chan *chan) |
| 299 | { | 305 | { |
| 306 | struct edma_chan *echan = to_edma_chan(chan); | ||
| 307 | |||
| 300 | /* Pause/Resume only allowed with cyclic mode */ | 308 | /* Pause/Resume only allowed with cyclic mode */ |
| 301 | if (!echan->edesc->cyclic) | 309 | if (!echan->edesc->cyclic) |
| 302 | return -EINVAL; | 310 | return -EINVAL; |
| @@ -305,36 +313,6 @@ static int edma_dma_resume(struct edma_chan *echan) | |||
| 305 | return 0; | 313 | return 0; |
| 306 | } | 314 | } |
| 307 | 315 | ||
| 308 | static int edma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, | ||
| 309 | unsigned long arg) | ||
| 310 | { | ||
| 311 | int ret = 0; | ||
| 312 | struct dma_slave_config *config; | ||
| 313 | struct edma_chan *echan = to_edma_chan(chan); | ||
| 314 | |||
| 315 | switch (cmd) { | ||
| 316 | case DMA_TERMINATE_ALL: | ||
| 317 | edma_terminate_all(echan); | ||
| 318 | break; | ||
| 319 | case DMA_SLAVE_CONFIG: | ||
| 320 | config = (struct dma_slave_config *)arg; | ||
| 321 | ret = edma_slave_config(echan, config); | ||
| 322 | break; | ||
| 323 | case DMA_PAUSE: | ||
| 324 | ret = edma_dma_pause(echan); | ||
| 325 | break; | ||
| 326 | |||
| 327 | case DMA_RESUME: | ||
| 328 | ret = edma_dma_resume(echan); | ||
| 329 | break; | ||
| 330 | |||
| 331 | default: | ||
| 332 | ret = -ENOSYS; | ||
| 333 | } | ||
| 334 | |||
| 335 | return ret; | ||
| 336 | } | ||
| 337 | |||
| 338 | /* | 316 | /* |
| 339 | * A PaRAM set configuration abstraction used by other modes | 317 | * A PaRAM set configuration abstraction used by other modes |
| 340 | * @chan: Channel who's PaRAM set we're configuring | 318 | * @chan: Channel who's PaRAM set we're configuring |
| @@ -557,7 +535,7 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg( | |||
| 557 | return vchan_tx_prep(&echan->vchan, &edesc->vdesc, tx_flags); | 535 | return vchan_tx_prep(&echan->vchan, &edesc->vdesc, tx_flags); |
| 558 | } | 536 | } |
| 559 | 537 | ||
| 560 | struct dma_async_tx_descriptor *edma_prep_dma_memcpy( | 538 | static struct dma_async_tx_descriptor *edma_prep_dma_memcpy( |
| 561 | struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, | 539 | struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, |
| 562 | size_t len, unsigned long tx_flags) | 540 | size_t len, unsigned long tx_flags) |
| 563 | { | 541 | { |
| @@ -994,19 +972,6 @@ static void __init edma_chan_init(struct edma_cc *ecc, | |||
| 994 | BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \ | 972 | BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \ |
| 995 | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES)) | 973 | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES)) |
| 996 | 974 | ||
| 997 | static int edma_dma_device_slave_caps(struct dma_chan *dchan, | ||
| 998 | struct dma_slave_caps *caps) | ||
| 999 | { | ||
| 1000 | caps->src_addr_widths = EDMA_DMA_BUSWIDTHS; | ||
| 1001 | caps->dstn_addr_widths = EDMA_DMA_BUSWIDTHS; | ||
| 1002 | caps->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); | ||
| 1003 | caps->cmd_pause = true; | ||
| 1004 | caps->cmd_terminate = true; | ||
| 1005 | caps->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; | ||
| 1006 | |||
| 1007 | return 0; | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma, | 975 | static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma, |
| 1011 | struct device *dev) | 976 | struct device *dev) |
| 1012 | { | 977 | { |
| @@ -1017,8 +982,16 @@ static void edma_dma_init(struct edma_cc *ecc, struct dma_device *dma, | |||
| 1017 | dma->device_free_chan_resources = edma_free_chan_resources; | 982 | dma->device_free_chan_resources = edma_free_chan_resources; |
| 1018 | dma->device_issue_pending = edma_issue_pending; | 983 | dma->device_issue_pending = edma_issue_pending; |
| 1019 | dma->device_tx_status = edma_tx_status; | 984 | dma->device_tx_status = edma_tx_status; |
| 1020 | dma->device_control = edma_control; | 985 | dma->device_config = edma_slave_config; |
| 1021 | dma->device_slave_caps = edma_dma_device_slave_caps; | 986 | dma->device_pause = edma_dma_pause; |
| 987 | dma->device_resume = edma_dma_resume; | ||
| 988 | dma->device_terminate_all = edma_terminate_all; | ||
| 989 | |||
| 990 | dma->src_addr_widths = EDMA_DMA_BUSWIDTHS; | ||
| 991 | dma->dst_addr_widths = EDMA_DMA_BUSWIDTHS; | ||
| 992 | dma->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); | ||
| 993 | dma->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; | ||
| 994 | |||
| 1022 | dma->dev = dev; | 995 | dma->dev = dev; |
| 1023 | 996 | ||
| 1024 | /* | 997 | /* |
