Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma

* 'next' of git://git.infradead.org/users/vkoul/slave-dma: (53 commits)
ARM: mach-shmobile: specify CHCLR registers on SH7372
dma: shdma: fix runtime PM: clear channel buffers on reset
dma/imx-sdma: save irq flags when use spin_lock in sdma_tx_submit
dmaengine/ste_dma40: clear LNK on channel startup
dmaengine: intel_mid_dma: remove legacy pm interface
ASoC: mxs: correct 'direction' of device_prep_dma_cyclic
dmaengine: intel_mid_dma: error path fix
dmaengine: intel_mid_dma: locking and freeing fixes
mtd: gpmi-nand: move to dma_transfer_direction
mtd: fix compile error for gpmi-nand
mmc: mxs-mmc: fix the dma_transfer_direction migration
dmaengine: add DMA_TRANS_NONE to dma_transfer_direction
dma: mxs-dma: Don't use CLKGATE bits in CTRL0 to disable DMA channels
dma: mxs-dma: make mxs_dma_prep_slave_sg() multi user safe
dma: mxs-dma: Always leave mxs_dma_init() with the clock disabled.
dma: mxs-dma: fix a typo in comment
DMA: PL330: Remove pm_runtime_xxx calls from pl330 probe/remove
video i.MX IPU: Fix display connections
i.MX IPU DMA: Fix wrong burstsize settings
dmaengine/ste_dma40: allow fixed physical channel
...

Fix up conflicts in drivers/dma/{Kconfig,mxs-dma.c,pl330.c}

The conflicts looked pretty trivial, but I'll ask people to verify them.

+1872 -530
+14
Documentation/devicetree/bindings/dma/atmel-dma.txt
··· 1 + * Atmel Direct Memory Access Controller (DMA) 2 + 3 + Required properties: 4 + - compatible: Should be "atmel,<chip>-dma" 5 + - reg: Should contain DMA registers location and length 6 + - interrupts: Should contain DMA interrupt 7 + 8 + Examples: 9 + 10 + dma@ffffec00 { 11 + compatible = "atmel,at91sam9g45-dma"; 12 + reg = <0xffffec00 0x200>; 13 + interrupts = <21>; 14 + };
+8
Documentation/dmaengine.txt
··· 75 75 slave_sg - DMA a list of scatter gather buffers from/to a peripheral 76 76 dma_cyclic - Perform a cyclic DMA operation from/to a peripheral till the 77 77 operation is explicitly stopped. 78 + interleaved_dma - This is common to Slave as well as M2M clients. For slave 79 + address of devices' fifo could be already known to the driver. 80 + Various types of operations could be expressed by setting 81 + appropriate values to the 'dma_interleaved_template' members. 78 82 79 83 A non-NULL return of this transfer API represents a "descriptor" for 80 84 the given transaction. ··· 92 88 struct dma_async_tx_descriptor *(*chan->device->device_prep_dma_cyclic)( 93 89 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, 94 90 size_t period_len, enum dma_data_direction direction); 91 + 92 + struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)( 93 + struct dma_chan *chan, struct dma_interleaved_template *xt, 94 + unsigned long flags); 95 95 96 96 The peripheral driver is expected to have mapped the scatterlist for 97 97 the DMA operation prior to calling device_prep_slave_sg, and must
+1
MAINTAINERS
··· 745 745 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 746 746 S: Maintained 747 747 F: arch/arm/mach-prima2/ 748 + F: drivers/dma/sirf-dma* 748 749 749 750 ARM/EBSA110 MACHINE SUPPORT 750 751 M: Russell King <linux@arm.linux.org.uk>
+3 -3
arch/arm/mach-ep93xx/include/mach/dma.h
··· 37 37 */ 38 38 struct ep93xx_dma_data { 39 39 int port; 40 - enum dma_data_direction direction; 40 + enum dma_transfer_direction direction; 41 41 const char *name; 42 42 }; 43 43 ··· 80 80 * channel supports given DMA direction. Only M2P channels have such 81 81 * limitation, for M2M channels the direction is configurable. 82 82 */ 83 - static inline enum dma_data_direction 83 + static inline enum dma_transfer_direction 84 84 ep93xx_dma_chan_direction(struct dma_chan *chan) 85 85 { 86 86 if (!ep93xx_dma_chan_is_m2p(chan)) 87 87 return DMA_NONE; 88 88 89 89 /* even channels are for TX, odd for RX */ 90 - return (chan->chan_id % 2 == 0) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 90 + return (chan->chan_id % 2 == 0) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; 91 91 } 92 92 93 93 #endif /* __ASM_ARCH_DMA_H */
+12 -3
arch/arm/mach-shmobile/setup-sh7372.c
··· 445 445 }, 446 446 }; 447 447 448 + #define SH7372_CHCLR 0x220 449 + 448 450 static const struct sh_dmae_channel sh7372_dmae_channels[] = { 449 451 { 450 452 .offset = 0, 451 453 .dmars = 0, 452 454 .dmars_bit = 0, 455 + .chclr_offset = SH7372_CHCLR + 0, 453 456 }, { 454 457 .offset = 0x10, 455 458 .dmars = 0, 456 459 .dmars_bit = 8, 460 + .chclr_offset = SH7372_CHCLR + 0x10, 457 461 }, { 458 462 .offset = 0x20, 459 463 .dmars = 4, 460 464 .dmars_bit = 0, 465 + .chclr_offset = SH7372_CHCLR + 0x20, 461 466 }, { 462 467 .offset = 0x30, 463 468 .dmars = 4, 464 469 .dmars_bit = 8, 470 + .chclr_offset = SH7372_CHCLR + 0x30, 465 471 }, { 466 472 .offset = 0x50, 467 473 .dmars = 8, 468 474 .dmars_bit = 0, 475 + .chclr_offset = SH7372_CHCLR + 0x50, 469 476 }, { 470 477 .offset = 0x60, 471 478 .dmars = 8, 472 479 .dmars_bit = 8, 480 + .chclr_offset = SH7372_CHCLR + 0x60, 473 481 } 474 482 }; 475 483 ··· 495 487 .ts_shift = ts_shift, 496 488 .ts_shift_num = ARRAY_SIZE(ts_shift), 497 489 .dmaor_init = DMAOR_DME, 490 + .chclr_present = 1, 498 491 }; 499 492 500 493 /* Resource order important! */ ··· 503 494 { 504 495 /* Channel registers and DMAOR */ 505 496 .start = 0xfe008020, 506 - .end = 0xfe00808f, 497 + .end = 0xfe00828f, 507 498 .flags = IORESOURCE_MEM, 508 499 }, 509 500 { ··· 531 522 { 532 523 /* Channel registers and DMAOR */ 533 524 .start = 0xfe018020, 534 - .end = 0xfe01808f, 525 + .end = 0xfe01828f, 535 526 .flags = IORESOURCE_MEM, 536 527 }, 537 528 { ··· 559 550 { 560 551 /* Channel registers and DMAOR */ 561 552 .start = 0xfe028020, 562 - .end = 0xfe02808f, 553 + .end = 0xfe02828f, 563 554 .flags = IORESOURCE_MEM, 564 555 }, 565 556 {
+15
arch/arm/plat-mxc/include/mach/mx3fb.h
··· 22 22 #define FB_SYNC_SWAP_RGB 0x04000000 23 23 #define FB_SYNC_CLK_SEL_EN 0x02000000 24 24 25 + /* 26 + * Specify the way your display is connected. The IPU can arbitrarily 27 + * map the internal colors to the external data lines. We only support 28 + * the following mappings at the moment. 29 + */ 30 + enum disp_data_mapping { 31 + /* blue -> d[0..5], green -> d[6..11], red -> d[12..17] */ 32 + IPU_DISP_DATA_MAPPING_RGB666, 33 + /* blue -> d[0..4], green -> d[5..10], red -> d[11..15] */ 34 + IPU_DISP_DATA_MAPPING_RGB565, 35 + /* blue -> d[0..7], green -> d[8..15], red -> d[16..23] */ 36 + IPU_DISP_DATA_MAPPING_RGB888, 37 + }; 38 + 25 39 /** 26 40 * struct mx3fb_platform_data - mx3fb platform data 27 41 * ··· 47 33 const char *name; 48 34 const struct fb_videomode *mode; 49 35 int num_modes; 36 + enum disp_data_mapping disp_data_fmt; 50 37 }; 51 38 52 39 #endif
+8 -3
arch/arm/plat-nomadik/include/plat/ste_dma40.h
··· 113 113 * @dst_dev_type: Dst device type 114 114 * @src_info: Parameters for dst half channel 115 115 * @dst_info: Parameters for dst half channel 116 - * 116 + * @use_fixed_channel: if true, use physical channel specified by phy_channel 117 + * @phy_channel: physical channel to use, only if use_fixed_channel is true 117 118 * 118 119 * This structure has to be filled by the client drivers. 119 120 * It is recommended to do all dma configurations for clients in the machine. ··· 130 129 int dst_dev_type; 131 130 struct stedma40_half_channel_info src_info; 132 131 struct stedma40_half_channel_info dst_info; 132 + 133 + bool use_fixed_channel; 134 + int phy_channel; 133 135 }; 134 136 135 137 /** ··· 157 153 struct stedma40_chan_cfg *memcpy_conf_phy; 158 154 struct stedma40_chan_cfg *memcpy_conf_log; 159 155 int disabled_channels[STEDMA40_MAX_PHYS]; 156 + bool use_esram_lcla; 160 157 }; 161 158 162 159 #ifdef CONFIG_STE_DMA40 ··· 192 187 dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan, 193 188 dma_addr_t addr, 194 189 unsigned int size, 195 - enum dma_data_direction direction, 190 + enum dma_transfer_direction direction, 196 191 unsigned long flags) 197 192 { 198 193 struct scatterlist sg; ··· 214 209 dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan, 215 210 dma_addr_t addr, 216 211 unsigned int size, 217 - enum dma_data_direction direction, 212 + enum dma_transfer_direction direction, 218 213 unsigned long flags) 219 214 { 220 215 return NULL;
+2 -2
arch/arm/plat-samsung/dma-ops.c
··· 37 37 (void *)dma_ch; 38 38 chan = dma_request_channel(mask, pl330_filter, filter_param); 39 39 40 - if (info->direction == DMA_FROM_DEVICE) { 40 + if (info->direction == DMA_DEV_TO_MEM) { 41 41 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 42 42 slave_config.direction = info->direction; 43 43 slave_config.src_addr = info->fifo; 44 44 slave_config.src_addr_width = info->width; 45 45 slave_config.src_maxburst = 1; 46 46 dmaengine_slave_config(chan, &slave_config); 47 - } else if (info->direction == DMA_TO_DEVICE) { 47 + } else if (info->direction == DMA_MEM_TO_DEV) { 48 48 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 49 49 slave_config.direction = info->direction; 50 50 slave_config.dst_addr = info->fifo;
+2 -2
arch/arm/plat-samsung/include/plat/dma-ops.h
··· 17 17 18 18 struct samsung_dma_prep_info { 19 19 enum dma_transaction_type cap; 20 - enum dma_data_direction direction; 20 + enum dma_transfer_direction direction; 21 21 dma_addr_t buf; 22 22 unsigned long period; 23 23 unsigned long len; ··· 27 27 28 28 struct samsung_dma_info { 29 29 enum dma_transaction_type cap; 30 - enum dma_data_direction direction; 30 + enum dma_transfer_direction direction; 31 31 enum dma_slave_buswidth width; 32 32 dma_addr_t fifo; 33 33 struct s3c2410_dma_client *client;
+17 -10
drivers/dma/Kconfig
··· 124 124 125 125 config MX3_IPU 126 126 bool "MX3x Image Processing Unit support" 127 - depends on SOC_IMX31 || SOC_IMX35 127 + depends on ARCH_MXC 128 128 select DMA_ENGINE 129 129 default y 130 130 help ··· 187 187 help 188 188 Enable support for the Timberdale FPGA DMA engine. 189 189 190 + config SIRF_DMA 191 + tristate "CSR SiRFprimaII DMA support" 192 + depends on ARCH_PRIMA2 193 + select DMA_ENGINE 194 + help 195 + Enable support for the CSR SiRFprimaII DMA engine. 196 + 190 197 config ARCH_HAS_ASYNC_TX_FIND_CHANNEL 191 198 bool 192 199 ··· 208 201 platform_data for a dma-pl330 device. 209 202 210 203 config PCH_DMA 211 - tristate "Intel EG20T PCH / OKI Semi IOH(ML7213/ML7223) DMA support" 204 + tristate "Intel EG20T PCH / LAPIS Semicon IOH(ML7213/ML7223/ML7831) DMA" 212 205 depends on PCI && X86 213 206 select DMA_ENGINE 214 207 help 215 208 Enable support for Intel EG20T PCH DMA engine. 216 209 217 - This driver also can be used for OKI SEMICONDUCTOR IOH(Input/ 218 - Output Hub), ML7213 and ML7223. 219 - ML7213 IOH is for IVI(In-Vehicle Infotainment) use and ML7223 IOH is 220 - for MP(Media Phone) use. 221 - ML7213/ML7223 is companion chip for Intel Atom E6xx series. 222 - ML7213/ML7223 is completely compatible for Intel EG20T PCH. 210 + This driver also can be used for LAPIS Semiconductor IOH(Input/ 211 + Output Hub), ML7213, ML7223 and ML7831. 212 + ML7213 IOH is for IVI(In-Vehicle Infotainment) use, ML7223 IOH is 213 + for MP(Media Phone) use and ML7831 IOH is for general purpose use. 214 + ML7213/ML7223/ML7831 is companion chip for Intel Atom E6xx series. 215 + ML7213/ML7223/ML7831 is completely compatible for Intel EG20T PCH. 223 216 224 217 config IMX_SDMA 225 218 tristate "i.MX SDMA support" 226 - depends on ARCH_MX25 || SOC_IMX31 || SOC_IMX35 || ARCH_MX5 219 + depends on ARCH_MXC 227 220 select DMA_ENGINE 228 221 help 229 222 Support the i.MX SDMA engine. This engine is integrated into 230 - Freescale i.MX25/31/35/51 chips. 223 + Freescale i.MX25/31/35/51/53 chips. 231 224 232 225 config IMX_DMA 233 226 tristate "i.MX DMA support"
+1
drivers/dma/Makefile
··· 21 21 obj-$(CONFIG_IMX_DMA) += imx-dma.o 22 22 obj-$(CONFIG_MXS_DMA) += mxs-dma.o 23 23 obj-$(CONFIG_TIMB_DMA) += timb_dma.o 24 + obj-$(CONFIG_SIRF_DMA) += sirf-dma.o 24 25 obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o 25 26 obj-$(CONFIG_PL330_DMA) += pl330.o 26 27 obj-$(CONFIG_PCH_DMA) += pch_dma.o
+22 -19
drivers/dma/amba-pl08x.c
··· 854 854 int ret; 855 855 856 856 /* Check if we already have a channel */ 857 - if (plchan->phychan) 858 - return 0; 857 + if (plchan->phychan) { 858 + ch = plchan->phychan; 859 + goto got_channel; 860 + } 859 861 860 862 ch = pl08x_get_phy_channel(pl08x, plchan); 861 863 if (!ch) { ··· 882 880 return -EBUSY; 883 881 } 884 882 ch->signal = ret; 885 - 886 - /* Assign the flow control signal to this channel */ 887 - if (txd->direction == DMA_TO_DEVICE) 888 - txd->ccfg |= ch->signal << PL080_CONFIG_DST_SEL_SHIFT; 889 - else if (txd->direction == DMA_FROM_DEVICE) 890 - txd->ccfg |= ch->signal << PL080_CONFIG_SRC_SEL_SHIFT; 891 883 } 892 884 885 + plchan->phychan = ch; 893 886 dev_dbg(&pl08x->adev->dev, "allocated physical channel %d and signal %d for xfer on %s\n", 894 887 ch->id, 895 888 ch->signal, 896 889 plchan->name); 897 890 891 + got_channel: 892 + /* Assign the flow control signal to this channel */ 893 + if (txd->direction == DMA_MEM_TO_DEV) 894 + txd->ccfg |= ch->signal << PL080_CONFIG_DST_SEL_SHIFT; 895 + else if (txd->direction == DMA_DEV_TO_MEM) 896 + txd->ccfg |= ch->signal << PL080_CONFIG_SRC_SEL_SHIFT; 897 + 898 898 plchan->phychan_hold++; 899 - plchan->phychan = ch; 900 899 901 900 return 0; 902 901 } ··· 1105 1102 1106 1103 /* Transfer direction */ 1107 1104 plchan->runtime_direction = config->direction; 1108 - if (config->direction == DMA_TO_DEVICE) { 1105 + if (config->direction == DMA_MEM_TO_DEV) { 1109 1106 addr_width = config->dst_addr_width; 1110 1107 maxburst = config->dst_maxburst; 1111 - } else if (config->direction == DMA_FROM_DEVICE) { 1108 + } else if (config->direction == DMA_DEV_TO_MEM) { 1112 1109 addr_width = config->src_addr_width; 1113 1110 maxburst = config->src_maxburst; 1114 1111 } else { ··· 1139 1136 cctl |= burst << PL080_CONTROL_SB_SIZE_SHIFT; 1140 1137 cctl |= burst << PL080_CONTROL_DB_SIZE_SHIFT; 1141 1138 1142 - if (plchan->runtime_direction == DMA_FROM_DEVICE) { 1139 + if (plchan->runtime_direction == DMA_DEV_TO_MEM) { 1143 1140 plchan->src_addr = config->src_addr; 1144 1141 plchan->src_cctl = pl08x_cctl(cctl) | PL080_CONTROL_DST_INCR | 1145 1142 pl08x_select_bus(plchan->cd->periph_buses, ··· 1155 1152 "configured channel %s (%s) for %s, data width %d, " 1156 1153 "maxburst %d words, LE, CCTL=0x%08x\n", 1157 1154 dma_chan_name(chan), plchan->name, 1158 - (config->direction == DMA_FROM_DEVICE) ? "RX" : "TX", 1155 + (config->direction == DMA_DEV_TO_MEM) ? "RX" : "TX", 1159 1156 addr_width, 1160 1157 maxburst, 1161 1158 cctl); ··· 1325 1322 1326 1323 static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( 1327 1324 struct dma_chan *chan, struct scatterlist *sgl, 1328 - unsigned int sg_len, enum dma_data_direction direction, 1325 + unsigned int sg_len, enum dma_transfer_direction direction, 1329 1326 unsigned long flags) 1330 1327 { 1331 1328 struct pl08x_dma_chan *plchan = to_pl08x_chan(chan); ··· 1357 1354 */ 1358 1355 txd->direction = direction; 1359 1356 1360 - if (direction == DMA_TO_DEVICE) { 1357 + if (direction == DMA_MEM_TO_DEV) { 1361 1358 txd->cctl = plchan->dst_cctl; 1362 1359 slave_addr = plchan->dst_addr; 1363 - } else if (direction == DMA_FROM_DEVICE) { 1360 + } else if (direction == DMA_DEV_TO_MEM) { 1364 1361 txd->cctl = plchan->src_cctl; 1365 1362 slave_addr = plchan->src_addr; 1366 1363 } else { ··· 1371 1368 } 1372 1369 1373 1370 if (plchan->cd->device_fc) 1374 - tmp = (direction == DMA_TO_DEVICE) ? PL080_FLOW_MEM2PER_PER : 1371 + tmp = (direction == DMA_MEM_TO_DEV) ? PL080_FLOW_MEM2PER_PER : 1375 1372 PL080_FLOW_PER2MEM_PER; 1376 1373 else 1377 - tmp = (direction == DMA_TO_DEVICE) ? PL080_FLOW_MEM2PER : 1374 + tmp = (direction == DMA_MEM_TO_DEV) ? PL080_FLOW_MEM2PER : 1378 1375 PL080_FLOW_PER2MEM; 1379 1376 1380 1377 txd->ccfg |= tmp << PL080_CONFIG_FLOW_CONTROL_SHIFT; ··· 1390 1387 list_add_tail(&dsg->node, &txd->dsg_list); 1391 1388 1392 1389 dsg->len = sg_dma_len(sg); 1393 - if (direction == DMA_TO_DEVICE) { 1390 + if (direction == DMA_MEM_TO_DEV) { 1394 1391 dsg->src_addr = sg_phys(sg); 1395 1392 dsg->dst_addr = slave_addr; 1396 1393 } else {
+81 -22
drivers/dma/at_hdmac.c
··· 23 23 #include <linux/module.h> 24 24 #include <linux/platform_device.h> 25 25 #include <linux/slab.h> 26 + #include <linux/of.h> 27 + #include <linux/of_device.h> 26 28 27 29 #include "at_hdmac_regs.h" 28 30 ··· 662 660 */ 663 661 static struct dma_async_tx_descriptor * 664 662 atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 665 - unsigned int sg_len, enum dma_data_direction direction, 663 + unsigned int sg_len, enum dma_transfer_direction direction, 666 664 unsigned long flags) 667 665 { 668 666 struct at_dma_chan *atchan = to_at_dma_chan(chan); ··· 680 678 681 679 dev_vdbg(chan2dev(chan), "prep_slave_sg (%d): %s f0x%lx\n", 682 680 sg_len, 683 - direction == DMA_TO_DEVICE ? "TO DEVICE" : "FROM DEVICE", 681 + direction == DMA_MEM_TO_DEV ? "TO DEVICE" : "FROM DEVICE", 684 682 flags); 685 683 686 684 if (unlikely(!atslave || !sg_len)) { ··· 694 692 ctrlb = ATC_IEN; 695 693 696 694 switch (direction) { 697 - case DMA_TO_DEVICE: 695 + case DMA_MEM_TO_DEV: 698 696 ctrla |= ATC_DST_WIDTH(reg_width); 699 697 ctrlb |= ATC_DST_ADDR_MODE_FIXED 700 698 | ATC_SRC_ADDR_MODE_INCR ··· 727 725 total_len += len; 728 726 } 729 727 break; 730 - case DMA_FROM_DEVICE: 728 + case DMA_DEV_TO_MEM: 731 729 ctrla |= ATC_SRC_WIDTH(reg_width); 732 730 ctrlb |= ATC_DST_ADDR_MODE_INCR 733 731 | ATC_SRC_ADDR_MODE_FIXED ··· 789 787 */ 790 788 static int 791 789 atc_dma_cyclic_check_values(unsigned int reg_width, dma_addr_t buf_addr, 792 - size_t period_len, enum dma_data_direction direction) 790 + size_t period_len, enum dma_transfer_direction direction) 793 791 { 794 792 if (period_len > (ATC_BTSIZE_MAX << reg_width)) 795 793 goto err_out; ··· 797 795 goto err_out; 798 796 if (unlikely(buf_addr & ((1 << reg_width) - 1))) 799 797 goto err_out; 800 - if (unlikely(!(direction & (DMA_TO_DEVICE | DMA_FROM_DEVICE)))) 798 + if (unlikely(!(direction & (DMA_DEV_TO_MEM | DMA_MEM_TO_DEV)))) 801 799 goto err_out; 802 800 803 801 return 0; ··· 812 810 static int 813 811 atc_dma_cyclic_fill_desc(struct at_dma_slave *atslave, struct at_desc *desc, 814 812 unsigned int period_index, dma_addr_t buf_addr, 815 - size_t period_len, enum dma_data_direction direction) 813 + size_t period_len, enum dma_transfer_direction direction) 816 814 { 817 815 u32 ctrla; 818 816 unsigned int reg_width = atslave->reg_width; ··· 824 822 | period_len >> reg_width; 825 823 826 824 switch (direction) { 827 - case DMA_TO_DEVICE: 825 + case DMA_MEM_TO_DEV: 828 826 desc->lli.saddr = buf_addr + (period_len * period_index); 829 827 desc->lli.daddr = atslave->tx_reg; 830 828 desc->lli.ctrla = ctrla; ··· 835 833 | ATC_DIF(AT_DMA_PER_IF); 836 834 break; 837 835 838 - case DMA_FROM_DEVICE: 836 + case DMA_DEV_TO_MEM: 839 837 desc->lli.saddr = atslave->rx_reg; 840 838 desc->lli.daddr = buf_addr + (period_len * period_index); 841 839 desc->lli.ctrla = ctrla; ··· 863 861 */ 864 862 static struct dma_async_tx_descriptor * 865 863 atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, 866 - size_t period_len, enum dma_data_direction direction) 864 + size_t period_len, enum dma_transfer_direction direction) 867 865 { 868 866 struct at_dma_chan *atchan = to_at_dma_chan(chan); 869 867 struct at_dma_slave *atslave = chan->private; ··· 874 872 unsigned int i; 875 873 876 874 dev_vdbg(chan2dev(chan), "prep_dma_cyclic: %s buf@0x%08x - %d (%d/%d)\n", 877 - direction == DMA_TO_DEVICE ? "TO DEVICE" : "FROM DEVICE", 875 + direction == DMA_MEM_TO_DEV ? "TO DEVICE" : "FROM DEVICE", 878 876 buf_addr, 879 877 periods, buf_len, period_len); 880 878 ··· 1177 1175 1178 1176 /*-- Module Management -----------------------------------------------*/ 1179 1177 1178 + /* cap_mask is a multi-u32 bitfield, fill it with proper C code. */ 1179 + static struct at_dma_platform_data at91sam9rl_config = { 1180 + .nr_channels = 2, 1181 + }; 1182 + static struct at_dma_platform_data at91sam9g45_config = { 1183 + .nr_channels = 8, 1184 + }; 1185 + 1186 + #if defined(CONFIG_OF) 1187 + static const struct of_device_id atmel_dma_dt_ids[] = { 1188 + { 1189 + .compatible = "atmel,at91sam9rl-dma", 1190 + .data = &at91sam9rl_config, 1191 + }, { 1192 + .compatible = "atmel,at91sam9g45-dma", 1193 + .data = &at91sam9g45_config, 1194 + }, { 1195 + /* sentinel */ 1196 + } 1197 + }; 1198 + 1199 + MODULE_DEVICE_TABLE(of, atmel_dma_dt_ids); 1200 + #endif 1201 + 1202 + static const struct platform_device_id atdma_devtypes[] = { 1203 + { 1204 + .name = "at91sam9rl_dma", 1205 + .driver_data = (unsigned long) &at91sam9rl_config, 1206 + }, { 1207 + .name = "at91sam9g45_dma", 1208 + .driver_data = (unsigned long) &at91sam9g45_config, 1209 + }, { 1210 + /* sentinel */ 1211 + } 1212 + }; 1213 + 1214 + static inline struct at_dma_platform_data * __init at_dma_get_driver_data( 1215 + struct platform_device *pdev) 1216 + { 1217 + if (pdev->dev.of_node) { 1218 + const struct of_device_id *match; 1219 + match = of_match_node(atmel_dma_dt_ids, pdev->dev.of_node); 1220 + if (match == NULL) 1221 + return NULL; 1222 + return match->data; 1223 + } 1224 + return (struct at_dma_platform_data *) 1225 + platform_get_device_id(pdev)->driver_data; 1226 + } 1227 + 1180 1228 /** 1181 1229 * at_dma_off - disable DMA controller 1182 1230 * @atdma: the Atmel HDAMC device ··· 1245 1193 1246 1194 static int __init at_dma_probe(struct platform_device *pdev) 1247 1195 { 1248 - struct at_dma_platform_data *pdata; 1249 1196 struct resource *io; 1250 1197 struct at_dma *atdma; 1251 1198 size_t size; 1252 1199 int irq; 1253 1200 int err; 1254 1201 int i; 1202 + struct at_dma_platform_data *plat_dat; 1255 1203 1256 - /* get DMA Controller parameters from platform */ 1257 - pdata = pdev->dev.platform_data; 1258 - if (!pdata || pdata->nr_channels > AT_DMA_MAX_NR_CHANNELS) 1259 - return -EINVAL; 1204 + /* setup platform data for each SoC */ 1205 + dma_cap_set(DMA_MEMCPY, at91sam9rl_config.cap_mask); 1206 + dma_cap_set(DMA_MEMCPY, at91sam9g45_config.cap_mask); 1207 + dma_cap_set(DMA_SLAVE, at91sam9g45_config.cap_mask); 1208 + 1209 + /* get DMA parameters from controller type */ 1210 + plat_dat = at_dma_get_driver_data(pdev); 1211 + if (!plat_dat) 1212 + return -ENODEV; 1260 1213 1261 1214 io = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1262 1215 if (!io) ··· 1272 1215 return irq; 1273 1216 1274 1217 size = sizeof(struct at_dma); 1275 - size += pdata->nr_channels * sizeof(struct at_dma_chan); 1218 + size += plat_dat->nr_channels * sizeof(struct at_dma_chan); 1276 1219 atdma = kzalloc(size, GFP_KERNEL); 1277 1220 if (!atdma) 1278 1221 return -ENOMEM; 1279 1222 1280 - /* discover transaction capabilites from the platform data */ 1281 - atdma->dma_common.cap_mask = pdata->cap_mask; 1282 - atdma->all_chan_mask = (1 << pdata->nr_channels) - 1; 1223 + /* discover transaction capabilities */ 1224 + atdma->dma_common.cap_mask = plat_dat->cap_mask; 1225 + atdma->all_chan_mask = (1 << plat_dat->nr_channels) - 1; 1283 1226 1284 1227 size = resource_size(io); 1285 1228 if (!request_mem_region(io->start, size, pdev->dev.driver->name)) { ··· 1325 1268 1326 1269 /* initialize channels related values */ 1327 1270 INIT_LIST_HEAD(&atdma->dma_common.channels); 1328 - for (i = 0; i < pdata->nr_channels; i++) { 1271 + for (i = 0; i < plat_dat->nr_channels; i++) { 1329 1272 struct at_dma_chan *atchan = &atdma->chan[i]; 1330 1273 1331 1274 atchan->chan_common.device = &atdma->dma_common; ··· 1370 1313 dev_info(&pdev->dev, "Atmel AHB DMA Controller ( %s%s), %d channels\n", 1371 1314 dma_has_cap(DMA_MEMCPY, atdma->dma_common.cap_mask) ? "cpy " : "", 1372 1315 dma_has_cap(DMA_SLAVE, atdma->dma_common.cap_mask) ? "slave " : "", 1373 - pdata->nr_channels); 1316 + plat_dat->nr_channels); 1374 1317 1375 1318 dma_async_device_register(&atdma->dma_common); 1376 1319 ··· 1552 1495 static struct platform_driver at_dma_driver = { 1553 1496 .remove = __exit_p(at_dma_remove), 1554 1497 .shutdown = at_dma_shutdown, 1498 + .id_table = atdma_devtypes, 1555 1499 .driver = { 1556 1500 .name = "at_hdmac", 1557 1501 .pm = &at_dma_dev_pm_ops, 1502 + .of_match_table = of_match_ptr(atmel_dma_dt_ids), 1558 1503 }, 1559 1504 }; 1560 1505
+1
drivers/dma/at_hdmac_regs.h
··· 251 251 /** 252 252 * struct at_dma - internal representation of an Atmel HDMA Controller 253 253 * @chan_common: common dmaengine dma_device object members 254 + * @atdma_devtype: identifier of DMA controller compatibility 254 255 * @ch_regs: memory mapped register base 255 256 * @clk: dma controller clock 256 257 * @save_imr: interrupt mask register that is saved on suspend/resume cycle
+6 -6
drivers/dma/coh901318.c
··· 39 39 struct scatterlist *sg; 40 40 unsigned int sg_len; 41 41 struct coh901318_lli *lli; 42 - enum dma_data_direction dir; 42 + enum dma_transfer_direction dir; 43 43 unsigned long flags; 44 44 u32 head_config; 45 45 u32 head_ctrl; ··· 1034 1034 1035 1035 static struct dma_async_tx_descriptor * 1036 1036 coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 1037 - unsigned int sg_len, enum dma_data_direction direction, 1037 + unsigned int sg_len, enum dma_transfer_direction direction, 1038 1038 unsigned long flags) 1039 1039 { 1040 1040 struct coh901318_chan *cohc = to_coh901318_chan(chan); ··· 1077 1077 ctrl_last |= cohc->runtime_ctrl; 1078 1078 ctrl |= cohc->runtime_ctrl; 1079 1079 1080 - if (direction == DMA_TO_DEVICE) { 1080 + if (direction == DMA_MEM_TO_DEV) { 1081 1081 u32 tx_flags = COH901318_CX_CTRL_PRDD_SOURCE | 1082 1082 COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE; 1083 1083 ··· 1085 1085 ctrl_chained |= tx_flags; 1086 1086 ctrl_last |= tx_flags; 1087 1087 ctrl |= tx_flags; 1088 - } else if (direction == DMA_FROM_DEVICE) { 1088 + } else if (direction == DMA_DEV_TO_MEM) { 1089 1089 u32 rx_flags = COH901318_CX_CTRL_PRDD_DEST | 1090 1090 COH901318_CX_CTRL_DST_ADDR_INC_ENABLE; 1091 1091 ··· 1274 1274 int i = 0; 1275 1275 1276 1276 /* We only support mem to per or per to mem transfers */ 1277 - if (config->direction == DMA_FROM_DEVICE) { 1277 + if (config->direction == DMA_DEV_TO_MEM) { 1278 1278 addr = config->src_addr; 1279 1279 addr_width = config->src_addr_width; 1280 1280 maxburst = config->src_maxburst; 1281 - } else if (config->direction == DMA_TO_DEVICE) { 1281 + } else if (config->direction == DMA_MEM_TO_DEV) { 1282 1282 addr = config->dst_addr; 1283 1283 addr_width = config->dst_addr_width; 1284 1284 maxburst = config->dst_maxburst;
+11 -12
drivers/dma/coh901318_lli.c
··· 7 7 * Author: Per Friden <per.friden@stericsson.com> 8 8 */ 9 9 10 - #include <linux/dma-mapping.h> 11 10 #include <linux/spinlock.h> 12 - #include <linux/dmapool.h> 13 11 #include <linux/memory.h> 14 12 #include <linux/gfp.h> 13 + #include <linux/dmapool.h> 15 14 #include <mach/coh901318.h> 16 15 17 16 #include "coh901318_lli.h" ··· 176 177 struct coh901318_lli *lli, 177 178 dma_addr_t buf, unsigned int size, 178 179 dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_eom, 179 - enum dma_data_direction dir) 180 + enum dma_transfer_direction dir) 180 181 { 181 182 int s = size; 182 183 dma_addr_t src; 183 184 dma_addr_t dst; 184 185 185 186 186 - if (dir == DMA_TO_DEVICE) { 187 + if (dir == DMA_MEM_TO_DEV) { 187 188 src = buf; 188 189 dst = dev_addr; 189 190 190 - } else if (dir == DMA_FROM_DEVICE) { 191 + } else if (dir == DMA_DEV_TO_MEM) { 191 192 192 193 src = dev_addr; 193 194 dst = buf; ··· 214 215 215 216 lli = coh901318_lli_next(lli); 216 217 217 - if (dir == DMA_TO_DEVICE) 218 + if (dir == DMA_MEM_TO_DEV) 218 219 src += block_size; 219 - else if (dir == DMA_FROM_DEVICE) 220 + else if (dir == DMA_DEV_TO_MEM) 220 221 dst += block_size; 221 222 } 222 223 ··· 233 234 struct scatterlist *sgl, unsigned int nents, 234 235 dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl, 235 236 u32 ctrl_last, 236 - enum dma_data_direction dir, u32 ctrl_irq_mask) 237 + enum dma_transfer_direction dir, u32 ctrl_irq_mask) 237 238 { 238 239 int i; 239 240 struct scatterlist *sg; ··· 248 249 249 250 spin_lock(&pool->lock); 250 251 251 - if (dir == DMA_TO_DEVICE) 252 + if (dir == DMA_MEM_TO_DEV) 252 253 dst = dev_addr; 253 - else if (dir == DMA_FROM_DEVICE) 254 + else if (dir == DMA_DEV_TO_MEM) 254 255 src = dev_addr; 255 256 else 256 257 goto err; ··· 268 269 ctrl_sg = ctrl ? ctrl : ctrl_last; 269 270 270 271 271 - if (dir == DMA_TO_DEVICE) 272 + if (dir == DMA_MEM_TO_DEV) 272 273 /* increment source address */ 273 274 src = sg_phys(sg); 274 275 else ··· 292 293 lli->src_addr = src; 293 294 lli->dst_addr = dst; 294 295 295 - if (dir == DMA_FROM_DEVICE) 296 + if (dir == DMA_DEV_TO_MEM) 296 297 dst += elem_size; 297 298 else 298 299 src += elem_size;
+2 -2
drivers/dma/coh901318_lli.h
··· 97 97 struct coh901318_lli *lli, 98 98 dma_addr_t buf, unsigned int size, 99 99 dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_last, 100 - enum dma_data_direction dir); 100 + enum dma_transfer_direction dir); 101 101 102 102 /** 103 103 * coh901318_lli_fill_single() - Prepares the lli:s for dma scatter list transfer ··· 119 119 struct scatterlist *sg, unsigned int nents, 120 120 dma_addr_t dev_addr, u32 ctrl_chained, 121 121 u32 ctrl, u32 ctrl_last, 122 - enum dma_data_direction dir, u32 ctrl_irq_mask); 122 + enum dma_transfer_direction dir, u32 ctrl_irq_mask); 123 123 124 124 #endif /* COH901318_LLI_H */
+2 -2
drivers/dma/dmaengine.c
··· 693 693 !device->device_prep_dma_interrupt); 694 694 BUG_ON(dma_has_cap(DMA_SG, device->cap_mask) && 695 695 !device->device_prep_dma_sg); 696 - BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) && 697 - !device->device_prep_slave_sg); 698 696 BUG_ON(dma_has_cap(DMA_CYCLIC, device->cap_mask) && 699 697 !device->device_prep_dma_cyclic); 700 698 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) && 701 699 !device->device_control); 700 + BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && 701 + !device->device_prep_interleaved_dma); 702 702 703 703 BUG_ON(!device->device_alloc_chan_resources); 704 704 BUG_ON(!device->device_free_chan_resources);
+48 -35
drivers/dma/dw_dmac.c
··· 166 166 return cookie; 167 167 } 168 168 169 + static void dwc_initialize(struct dw_dma_chan *dwc) 170 + { 171 + struct dw_dma *dw = to_dw_dma(dwc->chan.device); 172 + struct dw_dma_slave *dws = dwc->chan.private; 173 + u32 cfghi = DWC_CFGH_FIFO_MODE; 174 + u32 cfglo = DWC_CFGL_CH_PRIOR(dwc->priority); 175 + 176 + if (dwc->initialized == true) 177 + return; 178 + 179 + if (dws) { 180 + /* 181 + * We need controller-specific data to set up slave 182 + * transfers. 183 + */ 184 + BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev); 185 + 186 + cfghi = dws->cfg_hi; 187 + cfglo |= dws->cfg_lo & ~DWC_CFGL_CH_PRIOR_MASK; 188 + } 189 + 190 + channel_writel(dwc, CFG_LO, cfglo); 191 + channel_writel(dwc, CFG_HI, cfghi); 192 + 193 + /* Enable interrupts */ 194 + channel_set_bit(dw, MASK.XFER, dwc->mask); 195 + channel_set_bit(dw, MASK.BLOCK, dwc->mask); 196 + channel_set_bit(dw, MASK.ERROR, dwc->mask); 197 + 198 + dwc->initialized = true; 199 + } 200 + 169 201 /*----------------------------------------------------------------------*/ 170 202 171 203 /* Called with dwc->lock held and bh disabled */ ··· 220 188 /* The tasklet will hopefully advance the queue... */ 221 189 return; 222 190 } 191 + 192 + dwc_initialize(dwc); 223 193 224 194 channel_writel(dwc, LLP, first->txd.phys); 225 195 channel_writel(dwc, CTL_LO, ··· 730 696 731 697 static struct dma_async_tx_descriptor * 732 698 dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 733 - unsigned int sg_len, enum dma_data_direction direction, 699 + unsigned int sg_len, enum dma_transfer_direction direction, 734 700 unsigned long flags) 735 701 { 736 702 struct dw_dma_chan *dwc = to_dw_dma_chan(chan); ··· 754 720 prev = first = NULL; 755 721 756 722 switch (direction) { 757 - case DMA_TO_DEVICE: 723 + case DMA_MEM_TO_DEV: 758 724 ctllo = (DWC_DEFAULT_CTLLO(chan->private) 759 725 | DWC_CTLL_DST_WIDTH(reg_width) 760 726 | DWC_CTLL_DST_FIX ··· 811 777 goto slave_sg_todev_fill_desc; 812 778 } 813 779 break; 814 - case DMA_FROM_DEVICE: 780 + case DMA_DEV_TO_MEM: 815 781 ctllo = (DWC_DEFAULT_CTLLO(chan->private) 816 782 | DWC_CTLL_SRC_WIDTH(reg_width) 817 783 | DWC_CTLL_DST_INC ··· 993 959 struct dw_dma_chan *dwc = to_dw_dma_chan(chan); 994 960 struct dw_dma *dw = to_dw_dma(chan->device); 995 961 struct dw_desc *desc; 996 - struct dw_dma_slave *dws; 997 962 int i; 998 - u32 cfghi; 999 - u32 cfglo; 1000 963 unsigned long flags; 1001 964 1002 965 dev_vdbg(chan2dev(chan), "alloc_chan_resources\n"); ··· 1005 974 } 1006 975 1007 976 dwc->completed = chan->cookie = 1; 1008 - 1009 - cfghi = DWC_CFGH_FIFO_MODE; 1010 - cfglo = 0; 1011 - 1012 - dws = chan->private; 1013 - if (dws) { 1014 - /* 1015 - * We need controller-specific data to set up slave 1016 - * transfers. 1017 - */ 1018 - BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev); 1019 - 1020 - cfghi = dws->cfg_hi; 1021 - cfglo = dws->cfg_lo & ~DWC_CFGL_CH_PRIOR_MASK; 1022 - } 1023 - 1024 - cfglo |= DWC_CFGL_CH_PRIOR(dwc->priority); 1025 - 1026 - channel_writel(dwc, CFG_LO, cfglo); 1027 - channel_writel(dwc, CFG_HI, cfghi); 1028 977 1029 978 /* 1030 979 * NOTE: some controllers may have additional features that we ··· 1037 1026 i = ++dwc->descs_allocated; 1038 1027 } 1039 1028 1040 - /* Enable interrupts */ 1041 - channel_set_bit(dw, MASK.XFER, dwc->mask); 1042 - channel_set_bit(dw, MASK.BLOCK, dwc->mask); 1043 - channel_set_bit(dw, MASK.ERROR, dwc->mask); 1044 - 1045 1029 spin_unlock_irqrestore(&dwc->lock, flags); 1046 1030 1047 1031 dev_dbg(chan2dev(chan), ··· 1064 1058 spin_lock_irqsave(&dwc->lock, flags); 1065 1059 list_splice_init(&dwc->free_list, &list); 1066 1060 dwc->descs_allocated = 0; 1061 + dwc->initialized = false; 1067 1062 1068 1063 /* Disable interrupts */ 1069 1064 channel_clear_bit(dw, MASK.XFER, dwc->mask); ··· 1172 1165 */ 1173 1166 struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan, 1174 1167 dma_addr_t buf_addr, size_t buf_len, size_t period_len, 1175 - enum dma_data_direction direction) 1168 + enum dma_transfer_direction direction) 1176 1169 { 1177 1170 struct dw_dma_chan *dwc = to_dw_dma_chan(chan); 1178 1171 struct dw_cyclic_desc *cdesc; ··· 1213 1206 goto out_err; 1214 1207 if (unlikely(buf_addr & ((1 << reg_width) - 1))) 1215 1208 goto out_err; 1216 - if (unlikely(!(direction & (DMA_TO_DEVICE | DMA_FROM_DEVICE)))) 1209 + if (unlikely(!(direction & (DMA_MEM_TO_DEV | DMA_DEV_TO_MEM)))) 1217 1210 goto out_err; 1218 1211 1219 1212 retval = ERR_PTR(-ENOMEM); ··· 1235 1228 goto out_err_desc_get; 1236 1229 1237 1230 switch (direction) { 1238 - case DMA_TO_DEVICE: 1231 + case DMA_MEM_TO_DEV: 1239 1232 desc->lli.dar = dws->tx_reg; 1240 1233 desc->lli.sar = buf_addr + (period_len * i); 1241 1234 desc->lli.ctllo = (DWC_DEFAULT_CTLLO(chan->private) ··· 1246 1239 | DWC_CTLL_FC(dws->fc) 1247 1240 | DWC_CTLL_INT_EN); 1248 1241 break; 1249 - case DMA_FROM_DEVICE: 1242 + case DMA_DEV_TO_MEM: 1250 1243 desc->lli.dar = buf_addr + (period_len * i); 1251 1244 desc->lli.sar = dws->rx_reg; 1252 1245 desc->lli.ctllo = (DWC_DEFAULT_CTLLO(chan->private) ··· 1342 1335 1343 1336 static void dw_dma_off(struct dw_dma *dw) 1344 1337 { 1338 + int i; 1339 + 1345 1340 dma_writel(dw, CFG, 0); 1346 1341 1347 1342 channel_clear_bit(dw, MASK.XFER, dw->all_chan_mask); ··· 1354 1345 1355 1346 while (dma_readl(dw, CFG) & DW_CFG_DMA_EN) 1356 1347 cpu_relax(); 1348 + 1349 + for (i = 0; i < dw->dma.chancnt; i++) 1350 + dw->chan[i].initialized = false; 1357 1351 } 1358 1352 1359 1353 static int __init dw_probe(struct platform_device *pdev) ··· 1545 1533 1546 1534 dw_dma_off(platform_get_drvdata(pdev)); 1547 1535 clk_disable(dw->clk); 1536 + 1548 1537 return 0; 1549 1538 } 1550 1539
+1
drivers/dma/dw_dmac_regs.h
··· 140 140 u8 mask; 141 141 u8 priority; 142 142 bool paused; 143 + bool initialized; 143 144 144 145 spinlock_t lock; 145 146
+63 -27
drivers/dma/ep93xx_dma.c
··· 246 246 static struct ep93xx_dma_desc * 247 247 ep93xx_dma_get_active(struct ep93xx_dma_chan *edmac) 248 248 { 249 + if (list_empty(&edmac->active)) 250 + return NULL; 251 + 249 252 return list_first_entry(&edmac->active, struct ep93xx_dma_desc, node); 250 253 } 251 254 ··· 266 263 */ 267 264 static bool ep93xx_dma_advance_active(struct ep93xx_dma_chan *edmac) 268 265 { 266 + struct ep93xx_dma_desc *desc; 267 + 269 268 list_rotate_left(&edmac->active); 270 269 271 270 if (test_bit(EP93XX_DMA_IS_CYCLIC, &edmac->flags)) 272 271 return true; 273 272 273 + desc = ep93xx_dma_get_active(edmac); 274 + if (!desc) 275 + return false; 276 + 274 277 /* 275 278 * If txd.cookie is set it means that we are back in the first 276 279 * descriptor in the chain and hence done with it. 277 280 */ 278 - return !ep93xx_dma_get_active(edmac)->txd.cookie; 281 + return !desc->txd.cookie; 279 282 } 280 283 281 284 /* ··· 336 327 337 328 static void m2p_fill_desc(struct ep93xx_dma_chan *edmac) 338 329 { 339 - struct ep93xx_dma_desc *desc = ep93xx_dma_get_active(edmac); 330 + struct ep93xx_dma_desc *desc; 340 331 u32 bus_addr; 341 332 342 - if (ep93xx_dma_chan_direction(&edmac->chan) == DMA_TO_DEVICE) 333 + desc = ep93xx_dma_get_active(edmac); 334 + if (!desc) { 335 + dev_warn(chan2dev(edmac), "M2P: empty descriptor list\n"); 336 + return; 337 + } 338 + 339 + if (ep93xx_dma_chan_direction(&edmac->chan) == DMA_MEM_TO_DEV) 343 340 bus_addr = desc->src_addr; 344 341 else 345 342 bus_addr = desc->dst_addr; ··· 458 443 control = (5 << M2M_CONTROL_PWSC_SHIFT); 459 444 control |= M2M_CONTROL_NO_HDSK; 460 445 461 - if (data->direction == DMA_TO_DEVICE) { 446 + if (data->direction == DMA_MEM_TO_DEV) { 462 447 control |= M2M_CONTROL_DAH; 463 448 control |= M2M_CONTROL_TM_TX; 464 449 control |= M2M_CONTROL_RSS_SSPTX; ··· 474 459 * This IDE part is totally untested. Values below are taken 475 460 * from the EP93xx Users's Guide and might not be correct. 476 461 */ 477 - control |= M2M_CONTROL_NO_HDSK; 478 - control |= M2M_CONTROL_RSS_IDE; 479 - control |= M2M_CONTROL_PW_16; 480 - 481 - if (data->direction == DMA_TO_DEVICE) { 462 + if (data->direction == DMA_MEM_TO_DEV) { 482 463 /* Worst case from the UG */ 483 464 control = (3 << M2M_CONTROL_PWSC_SHIFT); 484 465 control |= M2M_CONTROL_DAH; ··· 484 473 control |= M2M_CONTROL_SAH; 485 474 control |= M2M_CONTROL_TM_RX; 486 475 } 476 + 477 + control |= M2M_CONTROL_NO_HDSK; 478 + control |= M2M_CONTROL_RSS_IDE; 479 + control |= M2M_CONTROL_PW_16; 487 480 break; 488 481 489 482 default: ··· 506 491 507 492 static void m2m_fill_desc(struct ep93xx_dma_chan *edmac) 508 493 { 509 - struct ep93xx_dma_desc *desc = ep93xx_dma_get_active(edmac); 494 + struct ep93xx_dma_desc *desc; 495 + 496 + desc = ep93xx_dma_get_active(edmac); 497 + if (!desc) { 498 + dev_warn(chan2dev(edmac), "M2M: empty descriptor list\n"); 499 + return; 500 + } 510 501 511 502 if (edmac->buffer == 0) { 512 503 writel(desc->src_addr, edmac->regs + M2M_SAR_BASE0); ··· 690 669 { 691 670 struct ep93xx_dma_chan *edmac = (struct ep93xx_dma_chan *)data; 692 671 struct ep93xx_dma_desc *desc, *d; 693 - dma_async_tx_callback callback; 694 - void *callback_param; 672 + dma_async_tx_callback callback = NULL; 673 + void *callback_param = NULL; 695 674 LIST_HEAD(list); 696 675 697 676 spin_lock_irq(&edmac->lock); 677 + /* 678 + * If dma_terminate_all() was called before we get to run, the active 679 + * list has become empty. If that happens we aren't supposed to do 680 + * anything more than call ep93xx_dma_advance_work(). 681 + */ 698 682 desc = ep93xx_dma_get_active(edmac); 699 - if (desc->complete) { 700 - edmac->last_completed = desc->txd.cookie; 701 - list_splice_init(&edmac->active, &list); 683 + if (desc) { 684 + if (desc->complete) { 685 + edmac->last_completed = desc->txd.cookie; 686 + list_splice_init(&edmac->active, &list); 687 + } 688 + callback = desc->txd.callback; 689 + callback_param = desc->txd.callback_param; 702 690 } 703 691 spin_unlock_irq(&edmac->lock); 704 692 705 693 /* Pick up the next descriptor from the queue */ 706 694 ep93xx_dma_advance_work(edmac); 707 - 708 - callback = desc->txd.callback; 709 - callback_param = desc->txd.callback_param; 710 695 711 696 /* Now we can release all the chained descriptors */ 712 697 list_for_each_entry_safe(desc, d, &list, node) { ··· 733 706 static irqreturn_t ep93xx_dma_interrupt(int irq, void *dev_id) 734 707 { 735 708 struct ep93xx_dma_chan *edmac = dev_id; 709 + struct ep93xx_dma_desc *desc; 736 710 irqreturn_t ret = IRQ_HANDLED; 737 711 738 712 spin_lock(&edmac->lock); 739 713 714 + desc = ep93xx_dma_get_active(edmac); 715 + if (!desc) { 716 + dev_warn(chan2dev(edmac), 717 + "got interrupt while active list is empty\n"); 718 + spin_unlock(&edmac->lock); 719 + return IRQ_NONE; 720 + } 721 + 740 722 switch (edmac->edma->hw_interrupt(edmac)) { 741 723 case INTERRUPT_DONE: 742 - ep93xx_dma_get_active(edmac)->complete = true; 724 + desc->complete = true; 743 725 tasklet_schedule(&edmac->tasklet); 744 726 break; 745 727 ··· 839 803 switch (data->port) { 840 804 case EP93XX_DMA_SSP: 841 805 case EP93XX_DMA_IDE: 842 - if (data->direction != DMA_TO_DEVICE && 843 - data->direction != DMA_FROM_DEVICE) 806 + if (data->direction != DMA_MEM_TO_DEV && 807 + data->direction != DMA_DEV_TO_MEM) 844 808 return -EINVAL; 845 809 break; 846 810 default: ··· 988 952 */ 989 953 static struct dma_async_tx_descriptor * 990 954 ep93xx_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 991 - unsigned int sg_len, enum dma_data_direction dir, 955 + unsigned int sg_len, enum dma_transfer_direction dir, 992 956 unsigned long flags) 993 957 { 994 958 struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan); ··· 1024 988 goto fail; 1025 989 } 1026 990 1027 - if (dir == DMA_TO_DEVICE) { 991 + if (dir == DMA_MEM_TO_DEV) { 1028 992 desc->src_addr = sg_dma_address(sg); 1029 993 desc->dst_addr = edmac->runtime_addr; 1030 994 } else { ··· 1068 1032 static struct dma_async_tx_descriptor * 1069 1033 ep93xx_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr, 1070 1034 size_t buf_len, size_t period_len, 1071 - enum dma_data_direction dir) 1035 + enum dma_transfer_direction dir) 1072 1036 { 1073 1037 struct ep93xx_dma_chan *edmac = to_ep93xx_dma_chan(chan); 1074 1038 struct ep93xx_dma_desc *desc, *first; ··· 1101 1065 goto fail; 1102 1066 } 1103 1067 1104 - if (dir == DMA_TO_DEVICE) { 1068 + if (dir == DMA_MEM_TO_DEV) { 1105 1069 desc->src_addr = dma_addr + offset; 1106 1070 desc->dst_addr = edmac->runtime_addr; 1107 1071 } else { ··· 1169 1133 return -EINVAL; 1170 1134 1171 1135 switch (config->direction) { 1172 - case DMA_FROM_DEVICE: 1136 + case DMA_DEV_TO_MEM: 1173 1137 width = config->src_addr_width; 1174 1138 addr = config->src_addr; 1175 1139 break; 1176 1140 1177 - case DMA_TO_DEVICE: 1141 + case DMA_MEM_TO_DEV: 1178 1142 width = config->dst_addr_width; 1179 1143 addr = config->dst_addr; 1180 1144 break;
+2 -2
drivers/dma/fsldma.c
··· 772 772 */ 773 773 static struct dma_async_tx_descriptor *fsl_dma_prep_slave_sg( 774 774 struct dma_chan *dchan, struct scatterlist *sgl, unsigned int sg_len, 775 - enum dma_data_direction direction, unsigned long flags) 775 + enum dma_transfer_direction direction, unsigned long flags) 776 776 { 777 777 /* 778 778 * This operation is not supported on the Freescale DMA controller ··· 819 819 return -ENXIO; 820 820 821 821 /* we set the controller burst size depending on direction */ 822 - if (config->direction == DMA_TO_DEVICE) 822 + if (config->direction == DMA_MEM_TO_DEV) 823 823 size = config->dst_addr_width * config->dst_maxburst; 824 824 else 825 825 size = config->src_addr_width * config->src_maxburst;
+5 -5
drivers/dma/imx-dma.c
··· 107 107 imx_dma_disable(imxdmac->imxdma_channel); 108 108 return 0; 109 109 case DMA_SLAVE_CONFIG: 110 - if (dmaengine_cfg->direction == DMA_FROM_DEVICE) { 110 + if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) { 111 111 imxdmac->per_address = dmaengine_cfg->src_addr; 112 112 imxdmac->watermark_level = dmaengine_cfg->src_maxburst; 113 113 imxdmac->word_size = dmaengine_cfg->src_addr_width; ··· 224 224 225 225 static struct dma_async_tx_descriptor *imxdma_prep_slave_sg( 226 226 struct dma_chan *chan, struct scatterlist *sgl, 227 - unsigned int sg_len, enum dma_data_direction direction, 227 + unsigned int sg_len, enum dma_transfer_direction direction, 228 228 unsigned long flags) 229 229 { 230 230 struct imxdma_channel *imxdmac = to_imxdma_chan(chan); ··· 241 241 dma_length += sg->length; 242 242 } 243 243 244 - if (direction == DMA_FROM_DEVICE) 244 + if (direction == DMA_DEV_TO_MEM) 245 245 dmamode = DMA_MODE_READ; 246 246 else 247 247 dmamode = DMA_MODE_WRITE; ··· 271 271 272 272 static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic( 273 273 struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, 274 - size_t period_len, enum dma_data_direction direction) 274 + size_t period_len, enum dma_transfer_direction direction) 275 275 { 276 276 struct imxdma_channel *imxdmac = to_imxdma_chan(chan); 277 277 struct imxdma_engine *imxdma = imxdmac->imxdma; ··· 317 317 imxdmac->sg_list[periods].page_link = 318 318 ((unsigned long)imxdmac->sg_list | 0x01) & ~0x02; 319 319 320 - if (direction == DMA_FROM_DEVICE) 320 + if (direction == DMA_DEV_TO_MEM) 321 321 dmamode = DMA_MODE_READ; 322 322 else 323 323 dmamode = DMA_MODE_WRITE;
+18 -9
drivers/dma/imx-sdma.c
··· 247 247 struct sdma_channel { 248 248 struct sdma_engine *sdma; 249 249 unsigned int channel; 250 - enum dma_data_direction direction; 250 + enum dma_transfer_direction direction; 251 251 enum sdma_peripheral_type peripheral_type; 252 252 unsigned int event_id0; 253 253 unsigned int event_id1; ··· 268 268 struct dma_async_tx_descriptor desc; 269 269 dma_cookie_t last_completed; 270 270 enum dma_status status; 271 + unsigned int chn_count; 272 + unsigned int chn_real_count; 271 273 }; 272 274 273 275 #define IMX_DMA_SG_LOOP (1 << 0) ··· 505 503 struct sdma_buffer_descriptor *bd; 506 504 int i, error = 0; 507 505 506 + sdmac->chn_real_count = 0; 508 507 /* 509 508 * non loop mode. Iterate over all descriptors, collect 510 509 * errors and call callback function ··· 515 512 516 513 if (bd->mode.status & (BD_DONE | BD_RROR)) 517 514 error = -EIO; 515 + sdmac->chn_real_count += bd->mode.count; 518 516 } 519 517 520 518 if (error) ··· 523 519 else 524 520 sdmac->status = DMA_SUCCESS; 525 521 522 + sdmac->last_completed = sdmac->desc.cookie; 526 523 if (sdmac->desc.callback) 527 524 sdmac->desc.callback(sdmac->desc.callback_param); 528 - sdmac->last_completed = sdmac->desc.cookie; 529 525 } 530 526 531 527 static void mxc_sdma_handle_channel(struct sdma_channel *sdmac) ··· 654 650 struct sdma_buffer_descriptor *bd0 = sdma->channel[0].bd; 655 651 int ret; 656 652 657 - if (sdmac->direction == DMA_FROM_DEVICE) { 653 + if (sdmac->direction == DMA_DEV_TO_MEM) { 658 654 load_address = sdmac->pc_from_device; 659 655 } else { 660 656 load_address = sdmac->pc_to_device; ··· 836 832 837 833 static dma_cookie_t sdma_tx_submit(struct dma_async_tx_descriptor *tx) 838 834 { 835 + unsigned long flags; 839 836 struct sdma_channel *sdmac = to_sdma_chan(tx->chan); 840 837 struct sdma_engine *sdma = sdmac->sdma; 841 838 dma_cookie_t cookie; 842 839 843 - spin_lock_irq(&sdmac->lock); 840 + spin_lock_irqsave(&sdmac->lock, flags); 844 841 845 842 cookie = sdma_assign_cookie(sdmac); 846 843 847 844 sdma_enable_channel(sdma, sdmac->channel); 848 845 849 - spin_unlock_irq(&sdmac->lock); 846 + spin_unlock_irqrestore(&sdmac->lock, flags); 850 847 851 848 return cookie; 852 849 } ··· 916 911 917 912 static struct dma_async_tx_descriptor *sdma_prep_slave_sg( 918 913 struct dma_chan *chan, struct scatterlist *sgl, 919 - unsigned int sg_len, enum dma_data_direction direction, 914 + unsigned int sg_len, enum dma_transfer_direction direction, 920 915 unsigned long flags) 921 916 { 922 917 struct sdma_channel *sdmac = to_sdma_chan(chan); ··· 946 941 goto err_out; 947 942 } 948 943 944 + sdmac->chn_count = 0; 949 945 for_each_sg(sgl, sg, sg_len, i) { 950 946 struct sdma_buffer_descriptor *bd = &sdmac->bd[i]; 951 947 int param; ··· 963 957 } 964 958 965 959 bd->mode.count = count; 960 + sdmac->chn_count += count; 966 961 967 962 if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) { 968 963 ret = -EINVAL; ··· 1015 1008 1016 1009 static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( 1017 1010 struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, 1018 - size_t period_len, enum dma_data_direction direction) 1011 + size_t period_len, enum dma_transfer_direction direction) 1019 1012 { 1020 1013 struct sdma_channel *sdmac = to_sdma_chan(chan); 1021 1014 struct sdma_engine *sdma = sdmac->sdma; ··· 1100 1093 sdma_disable_channel(sdmac); 1101 1094 return 0; 1102 1095 case DMA_SLAVE_CONFIG: 1103 - if (dmaengine_cfg->direction == DMA_FROM_DEVICE) { 1096 + if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) { 1104 1097 sdmac->per_address = dmaengine_cfg->src_addr; 1105 1098 sdmac->watermark_level = dmaengine_cfg->src_maxburst; 1106 1099 sdmac->word_size = dmaengine_cfg->src_addr_width; ··· 1109 1102 sdmac->watermark_level = dmaengine_cfg->dst_maxburst; 1110 1103 sdmac->word_size = dmaengine_cfg->dst_addr_width; 1111 1104 } 1105 + sdmac->direction = dmaengine_cfg->direction; 1112 1106 return sdma_config_channel(sdmac); 1113 1107 default: 1114 1108 return -ENOSYS; ··· 1127 1119 1128 1120 last_used = chan->cookie; 1129 1121 1130 - dma_set_tx_state(txstate, sdmac->last_completed, last_used, 0); 1122 + dma_set_tx_state(txstate, sdmac->last_completed, last_used, 1123 + sdmac->chn_count - sdmac->chn_real_count); 1131 1124 1132 1125 return sdmac->status; 1133 1126 }
+25 -14
drivers/dma/intel_mid_dma.c
··· 280 280 * callbacks but must be called with the lock held. 281 281 */ 282 282 static void midc_descriptor_complete(struct intel_mid_dma_chan *midc, 283 - struct intel_mid_dma_desc *desc) 283 + struct intel_mid_dma_desc *desc) 284 + __releases(&midc->lock) __acquires(&midc->lock) 284 285 { 285 286 struct dma_async_tx_descriptor *txd = &desc->txd; 286 287 dma_async_tx_callback callback_txd = NULL; ··· 312 311 pci_pool_free(desc->lli_pool, desc->lli, 313 312 desc->lli_phys); 314 313 pci_pool_destroy(desc->lli_pool); 314 + desc->lli = NULL; 315 315 } 316 316 list_move(&desc->desc_node, &midc->free_list); 317 317 midc->busy = false; ··· 397 395 midc->dma->block_size); 398 396 /*Populate SAR and DAR values*/ 399 397 sg_phy_addr = sg_phys(sg); 400 - if (desc->dirn == DMA_TO_DEVICE) { 398 + if (desc->dirn == DMA_MEM_TO_DEV) { 401 399 lli_bloc_desc->sar = sg_phy_addr; 402 400 lli_bloc_desc->dar = mids->dma_slave.dst_addr; 403 - } else if (desc->dirn == DMA_FROM_DEVICE) { 401 + } else if (desc->dirn == DMA_DEV_TO_MEM) { 404 402 lli_bloc_desc->sar = mids->dma_slave.src_addr; 405 403 lli_bloc_desc->dar = sg_phy_addr; 406 404 } ··· 492 490 493 491 ret = dma_async_is_complete(cookie, last_complete, last_used); 494 492 if (ret != DMA_SUCCESS) { 493 + spin_lock_bh(&midc->lock); 495 494 midc_scan_descriptors(to_middma_device(chan->device), midc); 495 + spin_unlock_bh(&midc->lock); 496 496 497 497 last_complete = midc->completed; 498 498 last_used = chan->cookie; ··· 570 566 pci_pool_free(desc->lli_pool, desc->lli, 571 567 desc->lli_phys); 572 568 pci_pool_destroy(desc->lli_pool); 569 + desc->lli = NULL; 573 570 } 574 571 list_move(&desc->desc_node, &midc->free_list); 575 572 } ··· 637 632 if (midc->dma->pimr_mask) { 638 633 cfg_hi.cfgx.protctl = 0x0; /*default value*/ 639 634 cfg_hi.cfgx.fifo_mode = 1; 640 - if (mids->dma_slave.direction == DMA_TO_DEVICE) { 635 + if (mids->dma_slave.direction == DMA_MEM_TO_DEV) { 641 636 cfg_hi.cfgx.src_per = 0; 642 637 if (mids->device_instance == 0) 643 638 cfg_hi.cfgx.dst_per = 3; 644 639 if (mids->device_instance == 1) 645 640 cfg_hi.cfgx.dst_per = 1; 646 - } else if (mids->dma_slave.direction == DMA_FROM_DEVICE) { 641 + } else if (mids->dma_slave.direction == DMA_DEV_TO_MEM) { 647 642 if (mids->device_instance == 0) 648 643 cfg_hi.cfgx.src_per = 2; 649 644 if (mids->device_instance == 1) ··· 687 682 ctl_lo.ctlx.sinc = 0; 688 683 ctl_lo.ctlx.dinc = 0; 689 684 } else { 690 - if (mids->dma_slave.direction == DMA_TO_DEVICE) { 685 + if (mids->dma_slave.direction == DMA_MEM_TO_DEV) { 691 686 ctl_lo.ctlx.sinc = 0; 692 687 ctl_lo.ctlx.dinc = 2; 693 688 ctl_lo.ctlx.tt_fc = 1; 694 - } else if (mids->dma_slave.direction == DMA_FROM_DEVICE) { 689 + } else if (mids->dma_slave.direction == DMA_DEV_TO_MEM) { 695 690 ctl_lo.ctlx.sinc = 2; 696 691 ctl_lo.ctlx.dinc = 0; 697 692 ctl_lo.ctlx.tt_fc = 2; ··· 737 732 */ 738 733 static struct dma_async_tx_descriptor *intel_mid_dma_prep_slave_sg( 739 734 struct dma_chan *chan, struct scatterlist *sgl, 740 - unsigned int sg_len, enum dma_data_direction direction, 735 + unsigned int sg_len, enum dma_transfer_direction direction, 741 736 unsigned long flags) 742 737 { 743 738 struct intel_mid_dma_chan *midc = NULL; ··· 873 868 pm_runtime_get_sync(&mid->pdev->dev); 874 869 875 870 if (mid->state == SUSPENDED) { 876 - if (dma_resume(mid->pdev)) { 871 + if (dma_resume(&mid->pdev->dev)) { 877 872 pr_err("ERR_MDMA: resume failed"); 878 873 return -EFAULT; 879 874 } ··· 1104 1099 LNW_PERIPHRAL_MASK_SIZE); 1105 1100 if (dma->mask_reg == NULL) { 1106 1101 pr_err("ERR_MDMA:Can't map periphral intr space !!\n"); 1107 - return -ENOMEM; 1102 + err = -ENOMEM; 1103 + goto err_ioremap; 1108 1104 } 1109 1105 } else 1110 1106 dma->mask_reg = NULL; ··· 1202 1196 err_engine: 1203 1197 free_irq(pdev->irq, dma); 1204 1198 err_irq: 1199 + if (dma->mask_reg) 1200 + iounmap(dma->mask_reg); 1201 + err_ioremap: 1205 1202 pci_pool_destroy(dma->dma_pool); 1206 1203 err_dma_pool: 1207 1204 pr_err("ERR_MDMA:setup_dma failed: %d\n", err); ··· 1346 1337 * 1347 1338 * This function is called by OS when a power event occurs 1348 1339 */ 1349 - int dma_suspend(struct pci_dev *pci, pm_message_t state) 1340 + static int dma_suspend(struct device *dev) 1350 1341 { 1342 + struct pci_dev *pci = to_pci_dev(dev); 1351 1343 int i; 1352 1344 struct middma_device *device = pci_get_drvdata(pci); 1353 1345 pr_debug("MDMA: dma_suspend called\n"); ··· 1372 1362 * 1373 1363 * This function is called by OS when a power event occurs 1374 1364 */ 1375 - int dma_resume(struct pci_dev *pci) 1365 + int dma_resume(struct device *dev) 1376 1366 { 1367 + struct pci_dev *pci = to_pci_dev(dev); 1377 1368 int ret; 1378 1369 struct middma_device *device = pci_get_drvdata(pci); 1379 1370 ··· 1440 1429 .runtime_suspend = dma_runtime_suspend, 1441 1430 .runtime_resume = dma_runtime_resume, 1442 1431 .runtime_idle = dma_runtime_idle, 1432 + .suspend = dma_suspend, 1433 + .resume = dma_resume, 1443 1434 }; 1444 1435 1445 1436 static struct pci_driver intel_mid_dma_pci_driver = { ··· 1450 1437 .probe = intel_mid_dma_probe, 1451 1438 .remove = __devexit_p(intel_mid_dma_remove), 1452 1439 #ifdef CONFIG_PM 1453 - .suspend = dma_suspend, 1454 - .resume = dma_resume, 1455 1440 .driver = { 1456 1441 .pm = &intel_mid_dma_pm, 1457 1442 },
+2 -2
drivers/dma/intel_mid_dma_regs.h
··· 262 262 unsigned int lli_length; 263 263 unsigned int current_lli; 264 264 dma_addr_t next; 265 - enum dma_data_direction dirn; 265 + enum dma_transfer_direction dirn; 266 266 enum dma_status status; 267 267 enum dma_slave_buswidth width; /*width of DMA txn*/ 268 268 enum intel_mid_dma_mode cfg_mode; /*mode configuration*/ ··· 296 296 } 297 297 298 298 299 - int dma_resume(struct pci_dev *pci); 299 + int dma_resume(struct device *dev); 300 300 301 301 #endif /*__INTEL_MID_DMAC_REGS_H__*/
+2 -14
drivers/dma/iop-adma.c
··· 1735 1735 spin_unlock_bh(&iop_chan->lock); 1736 1736 } 1737 1737 1738 - MODULE_ALIAS("platform:iop-adma"); 1739 - 1740 1738 static struct platform_driver iop_adma_driver = { 1741 1739 .probe = iop_adma_probe, 1742 1740 .remove = __devexit_p(iop_adma_remove), ··· 1744 1746 }, 1745 1747 }; 1746 1748 1747 - static int __init iop_adma_init (void) 1748 - { 1749 - return platform_driver_register(&iop_adma_driver); 1750 - } 1751 - 1752 - static void __exit iop_adma_exit (void) 1753 - { 1754 - platform_driver_unregister(&iop_adma_driver); 1755 - return; 1756 - } 1757 - module_exit(iop_adma_exit); 1758 - module_init(iop_adma_init); 1749 + module_platform_driver(iop_adma_driver); 1759 1750 1760 1751 MODULE_AUTHOR("Intel Corporation"); 1761 1752 MODULE_DESCRIPTION("IOP ADMA Engine Driver"); 1762 1753 MODULE_LICENSE("GPL"); 1754 + MODULE_ALIAS("platform:iop-adma");
+3 -26
drivers/dma/ipu/ipu_idmac.c
··· 312 312 case IPU_PIX_FMT_RGB565: 313 313 params->ip.bpp = 2; 314 314 params->ip.pfs = 4; 315 - params->ip.npb = 7; 315 + params->ip.npb = 15; 316 316 params->ip.sat = 2; /* SAT = 32-bit access */ 317 317 params->ip.ofs0 = 0; /* Red bit offset */ 318 318 params->ip.ofs1 = 5; /* Green bit offset */ ··· 420 420 } 421 421 422 422 params->pp.nsb = 1; 423 - } 424 - 425 - static void ipu_ch_param_set_burst_size(union chan_param_mem *params, 426 - uint16_t burst_pixels) 427 - { 428 - params->pp.npb = burst_pixels - 1; 429 423 } 430 424 431 425 static void ipu_ch_param_set_buffer(union chan_param_mem *params, ··· 684 690 ipu_ch_param_set_size(&params, pixel_fmt, width, height, stride_bytes); 685 691 ipu_ch_param_set_buffer(&params, phyaddr_0, phyaddr_1); 686 692 ipu_ch_param_set_rotation(&params, rot_mode); 687 - /* Some channels (rotation) have restriction on burst length */ 688 - switch (channel) { 689 - case IDMAC_IC_7: /* Hangs with burst 8, 16, other values 690 - invalid - Table 44-30 */ 691 - /* 692 - ipu_ch_param_set_burst_size(&params, 8); 693 - */ 694 - break; 695 - case IDMAC_SDC_0: 696 - case IDMAC_SDC_1: 697 - /* In original code only IPU_PIX_FMT_RGB565 was setting burst */ 698 - ipu_ch_param_set_burst_size(&params, 16); 699 - break; 700 - case IDMAC_IC_0: 701 - default: 702 - break; 703 - } 704 693 705 694 spin_lock_irqsave(&ipu->lock, flags); 706 695 ··· 1341 1364 /* Allocate and initialise a transfer descriptor. */ 1342 1365 static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan, 1343 1366 struct scatterlist *sgl, unsigned int sg_len, 1344 - enum dma_data_direction direction, unsigned long tx_flags) 1367 + enum dma_transfer_direction direction, unsigned long tx_flags) 1345 1368 { 1346 1369 struct idmac_channel *ichan = to_idmac_chan(chan); 1347 1370 struct idmac_tx_desc *desc = NULL; ··· 1353 1376 chan->chan_id != IDMAC_IC_7) 1354 1377 return NULL; 1355 1378 1356 - if (direction != DMA_FROM_DEVICE && direction != DMA_TO_DEVICE) { 1379 + if (direction != DMA_DEV_TO_MEM && direction != DMA_MEM_TO_DEV) { 1357 1380 dev_err(chan->device->dev, "Invalid DMA direction %d!\n", direction); 1358 1381 return NULL; 1359 1382 }
+1 -11
drivers/dma/mpc512x_dma.c
··· 835 835 }, 836 836 }; 837 837 838 - static int __init mpc_dma_init(void) 839 - { 840 - return platform_driver_register(&mpc_dma_driver); 841 - } 842 - module_init(mpc_dma_init); 843 - 844 - static void __exit mpc_dma_exit(void) 845 - { 846 - platform_driver_unregister(&mpc_dma_driver); 847 - } 848 - module_exit(mpc_dma_exit); 838 + module_platform_driver(mpc_dma_driver); 849 839 850 840 MODULE_LICENSE("GPL"); 851 841 MODULE_AUTHOR("Piotr Ziecik <kosmo@semihalf.com>");
+13 -40
drivers/dma/mxs-dma.c
··· 44 44 #define HW_APBHX_CTRL0 0x000 45 45 #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29) 46 46 #define BM_APBH_CTRL0_APB_BURST_EN (1 << 28) 47 - #define BP_APBH_CTRL0_CLKGATE_CHANNEL 8 48 47 #define BP_APBH_CTRL0_RESET_CHANNEL 16 49 48 #define HW_APBHX_CTRL1 0x010 50 49 #define HW_APBHX_CTRL2 0x020 ··· 110 111 int chan_irq; 111 112 struct mxs_dma_ccw *ccw; 112 113 dma_addr_t ccw_phys; 114 + int desc_count; 113 115 dma_cookie_t last_completed; 114 116 enum dma_status status; 115 117 unsigned int flags; ··· 130 130 struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS]; 131 131 }; 132 132 133 - static inline void mxs_dma_clkgate(struct mxs_dma_chan *mxs_chan, int enable) 134 - { 135 - struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; 136 - int chan_id = mxs_chan->chan.chan_id; 137 - int set_clr = enable ? MXS_CLR_ADDR : MXS_SET_ADDR; 138 - 139 - /* enable apbh channel clock */ 140 - if (dma_is_apbh()) { 141 - if (apbh_is_old()) 142 - writel(1 << (chan_id + BP_APBH_CTRL0_CLKGATE_CHANNEL), 143 - mxs_dma->base + HW_APBHX_CTRL0 + set_clr); 144 - else 145 - writel(1 << chan_id, 146 - mxs_dma->base + HW_APBHX_CTRL0 + set_clr); 147 - } 148 - } 149 - 150 133 static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan) 151 134 { 152 135 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; ··· 148 165 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; 149 166 int chan_id = mxs_chan->chan.chan_id; 150 167 151 - /* clkgate needs to be enabled before writing other registers */ 152 - mxs_dma_clkgate(mxs_chan, 1); 153 - 154 168 /* set cmd_addr up */ 155 169 writel(mxs_chan->ccw_phys, 156 170 mxs_dma->base + HW_APBHX_CHn_NXTCMDAR(chan_id)); ··· 158 178 159 179 static void mxs_dma_disable_chan(struct mxs_dma_chan *mxs_chan) 160 180 { 161 - /* disable apbh channel clock */ 162 - mxs_dma_clkgate(mxs_chan, 0); 163 - 164 181 mxs_chan->status = DMA_SUCCESS; 165 182 } 166 183 ··· 245 268 /* 246 269 * When both completion and error of termination bits set at the 247 270 * same time, we do not take it as an error. IOW, it only becomes 248 - * an error we need to handler here in case of ether it's (1) an bus 271 + * an error we need to handle here in case of either it's (1) a bus 249 272 * error or (2) a termination error with no completion. 250 273 */ 251 274 stat2 = ((stat2 >> MXS_DMA_CHANNELS) & stat2) | /* (1) */ ··· 315 338 if (ret) 316 339 goto err_clk; 317 340 318 - /* clkgate needs to be enabled for reset to finish */ 319 - mxs_dma_clkgate(mxs_chan, 1); 320 341 mxs_dma_reset_chan(mxs_chan); 321 - mxs_dma_clkgate(mxs_chan, 0); 322 342 323 343 dma_async_tx_descriptor_init(&mxs_chan->desc, chan); 324 344 mxs_chan->desc.tx_submit = mxs_dma_tx_submit; ··· 351 377 352 378 static struct dma_async_tx_descriptor *mxs_dma_prep_slave_sg( 353 379 struct dma_chan *chan, struct scatterlist *sgl, 354 - unsigned int sg_len, enum dma_data_direction direction, 380 + unsigned int sg_len, enum dma_transfer_direction direction, 355 381 unsigned long append) 356 382 { 357 383 struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); ··· 360 386 struct scatterlist *sg; 361 387 int i, j; 362 388 u32 *pio; 363 - static int idx; 389 + int idx = append ? mxs_chan->desc_count : 0; 364 390 365 391 if (mxs_chan->status == DMA_IN_PROGRESS && !append) 366 392 return NULL; ··· 391 417 idx = 0; 392 418 } 393 419 394 - if (direction == DMA_NONE) { 420 + if (direction == DMA_TRANS_NONE) { 395 421 ccw = &mxs_chan->ccw[idx++]; 396 422 pio = (u32 *) sgl; 397 423 ··· 424 450 ccw->bits |= CCW_CHAIN; 425 451 ccw->bits |= CCW_HALT_ON_TERM; 426 452 ccw->bits |= CCW_TERM_FLUSH; 427 - ccw->bits |= BF_CCW(direction == DMA_FROM_DEVICE ? 453 + ccw->bits |= BF_CCW(direction == DMA_DEV_TO_MEM ? 428 454 MXS_DMA_CMD_WRITE : MXS_DMA_CMD_READ, 429 455 COMMAND); 430 456 ··· 436 462 } 437 463 } 438 464 } 465 + mxs_chan->desc_count = idx; 439 466 440 467 return &mxs_chan->desc; 441 468 ··· 447 472 448 473 static struct dma_async_tx_descriptor *mxs_dma_prep_dma_cyclic( 449 474 struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, 450 - size_t period_len, enum dma_data_direction direction) 475 + size_t period_len, enum dma_transfer_direction direction) 451 476 { 452 477 struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan); 453 478 struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; ··· 490 515 ccw->bits |= CCW_IRQ; 491 516 ccw->bits |= CCW_HALT_ON_TERM; 492 517 ccw->bits |= CCW_TERM_FLUSH; 493 - ccw->bits |= BF_CCW(direction == DMA_FROM_DEVICE ? 518 + ccw->bits |= BF_CCW(direction == DMA_DEV_TO_MEM ? 494 519 MXS_DMA_CMD_WRITE : MXS_DMA_CMD_READ, COMMAND); 495 520 496 521 dma_addr += period_len; ··· 498 523 499 524 i++; 500 525 } 526 + mxs_chan->desc_count = i; 501 527 502 528 return &mxs_chan->desc; 503 529 ··· 515 539 516 540 switch (cmd) { 517 541 case DMA_TERMINATE_ALL: 518 - mxs_dma_disable_chan(mxs_chan); 519 542 mxs_dma_reset_chan(mxs_chan); 543 + mxs_dma_disable_chan(mxs_chan); 520 544 break; 521 545 case DMA_PAUSE: 522 546 mxs_dma_pause_chan(mxs_chan); ··· 556 580 557 581 ret = clk_prepare_enable(mxs_dma->clk); 558 582 if (ret) 559 - goto err_out; 583 + return ret; 560 584 561 585 ret = mxs_reset_block(mxs_dma->base); 562 586 if (ret) ··· 580 604 writel(MXS_DMA_CHANNELS_MASK << MXS_DMA_CHANNELS, 581 605 mxs_dma->base + HW_APBHX_CTRL1 + MXS_SET_ADDR); 582 606 583 - clk_disable_unprepare(mxs_dma->clk); 584 - 585 - return 0; 586 - 587 607 err_out: 608 + clk_disable_unprepare(mxs_dma->clk); 588 609 return ret; 589 610 } 590 611
+12 -8
drivers/dma/pch_dma.c
··· 1 1 /* 2 2 * Topcliff PCH DMA controller driver 3 3 * Copyright (c) 2010 Intel Corporation 4 - * Copyright (C) 2011 OKI SEMICONDUCTOR CO., LTD. 4 + * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify 7 7 * it under the terms of the GNU General Public License version 2 as ··· 99 99 struct pch_dma_chan { 100 100 struct dma_chan chan; 101 101 void __iomem *membase; 102 - enum dma_data_direction dir; 102 + enum dma_transfer_direction dir; 103 103 struct tasklet_struct tasklet; 104 104 unsigned long err_status; 105 105 ··· 224 224 mask_ctl = DMA_MASK_CTL0_MODE & ~(DMA_CTL0_MODE_MASK_BITS << 225 225 (DMA_CTL0_BITS_PER_CH * chan->chan_id)); 226 226 val &= mask_mode; 227 - if (pd_chan->dir == DMA_TO_DEVICE) 227 + if (pd_chan->dir == DMA_MEM_TO_DEV) 228 228 val |= 0x1 << (DMA_CTL0_BITS_PER_CH * chan->chan_id + 229 229 DMA_CTL0_DIR_SHIFT_BITS); 230 230 else ··· 242 242 mask_ctl = DMA_MASK_CTL2_MODE & ~(DMA_CTL0_MODE_MASK_BITS << 243 243 (DMA_CTL0_BITS_PER_CH * ch)); 244 244 val &= mask_mode; 245 - if (pd_chan->dir == DMA_TO_DEVICE) 245 + if (pd_chan->dir == DMA_MEM_TO_DEV) 246 246 val |= 0x1 << (DMA_CTL0_BITS_PER_CH * ch + 247 247 DMA_CTL0_DIR_SHIFT_BITS); 248 248 else ··· 607 607 608 608 static struct dma_async_tx_descriptor *pd_prep_slave_sg(struct dma_chan *chan, 609 609 struct scatterlist *sgl, unsigned int sg_len, 610 - enum dma_data_direction direction, unsigned long flags) 610 + enum dma_transfer_direction direction, unsigned long flags) 611 611 { 612 612 struct pch_dma_chan *pd_chan = to_pd_chan(chan); 613 613 struct pch_dma_slave *pd_slave = chan->private; ··· 623 623 return NULL; 624 624 } 625 625 626 - if (direction == DMA_FROM_DEVICE) 626 + if (direction == DMA_DEV_TO_MEM) 627 627 reg = pd_slave->rx_reg; 628 - else if (direction == DMA_TO_DEVICE) 628 + else if (direction == DMA_MEM_TO_DEV) 629 629 reg = pd_slave->tx_reg; 630 630 else 631 631 return NULL; ··· 1018 1018 #define PCI_DEVICE_ID_ML7223_DMA2_4CH 0x800E 1019 1019 #define PCI_DEVICE_ID_ML7223_DMA3_4CH 0x8017 1020 1020 #define PCI_DEVICE_ID_ML7223_DMA4_4CH 0x803B 1021 + #define PCI_DEVICE_ID_ML7831_DMA1_8CH 0x8810 1022 + #define PCI_DEVICE_ID_ML7831_DMA2_4CH 0x8815 1021 1023 1022 1024 DEFINE_PCI_DEVICE_TABLE(pch_dma_id_table) = { 1023 1025 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_EG20T_PCH_DMA_8CH), 8 }, ··· 1032 1030 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA2_4CH), 4}, /* Video SPI */ 1033 1031 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA3_4CH), 4}, /* Security */ 1034 1032 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA4_4CH), 4}, /* FPGA */ 1033 + { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_DMA1_8CH), 8}, /* UART */ 1034 + { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_DMA2_4CH), 4}, /* SPI */ 1035 1035 { 0, }, 1036 1036 }; 1037 1037 ··· 1061 1057 module_init(pch_dma_init); 1062 1058 module_exit(pch_dma_exit); 1063 1059 1064 - MODULE_DESCRIPTION("Intel EG20T PCH / OKI SEMICONDUCTOR ML7213 IOH " 1060 + MODULE_DESCRIPTION("Intel EG20T PCH / LAPIS Semicon ML7213/ML7223/ML7831 IOH " 1065 1061 "DMA controller driver"); 1066 1062 MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>"); 1067 1063 MODULE_LICENSE("GPL v2");
+9 -22
drivers/dma/pl330.c
··· 350 350 case DMA_SLAVE_CONFIG: 351 351 slave_config = (struct dma_slave_config *)arg; 352 352 353 - if (slave_config->direction == DMA_TO_DEVICE) { 353 + if (slave_config->direction == DMA_MEM_TO_DEV) { 354 354 if (slave_config->dst_addr) 355 355 pch->fifo_addr = slave_config->dst_addr; 356 356 if (slave_config->dst_addr_width) 357 357 pch->burst_sz = __ffs(slave_config->dst_addr_width); 358 358 if (slave_config->dst_maxburst) 359 359 pch->burst_len = slave_config->dst_maxburst; 360 - } else if (slave_config->direction == DMA_FROM_DEVICE) { 360 + } else if (slave_config->direction == DMA_DEV_TO_MEM) { 361 361 if (slave_config->src_addr) 362 362 pch->fifo_addr = slave_config->src_addr; 363 363 if (slave_config->src_addr_width) ··· 621 621 622 622 static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( 623 623 struct dma_chan *chan, dma_addr_t dma_addr, size_t len, 624 - size_t period_len, enum dma_data_direction direction) 624 + size_t period_len, enum dma_transfer_direction direction) 625 625 { 626 626 struct dma_pl330_desc *desc; 627 627 struct dma_pl330_chan *pch = to_pchan(chan); ··· 636 636 } 637 637 638 638 switch (direction) { 639 - case DMA_TO_DEVICE: 639 + case DMA_MEM_TO_DEV: 640 640 desc->rqcfg.src_inc = 1; 641 641 desc->rqcfg.dst_inc = 0; 642 642 desc->req.rqtype = MEMTODEV; 643 643 src = dma_addr; 644 644 dst = pch->fifo_addr; 645 645 break; 646 - case DMA_FROM_DEVICE: 646 + case DMA_DEV_TO_MEM: 647 647 desc->rqcfg.src_inc = 0; 648 648 desc->rqcfg.dst_inc = 1; 649 649 desc->req.rqtype = DEVTOMEM; ··· 710 710 711 711 static struct dma_async_tx_descriptor * 712 712 pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 713 - unsigned int sg_len, enum dma_data_direction direction, 713 + unsigned int sg_len, enum dma_transfer_direction direction, 714 714 unsigned long flg) 715 715 { 716 716 struct dma_pl330_desc *first, *desc = NULL; ··· 759 759 else 760 760 list_add_tail(&desc->node, &first->node); 761 761 762 - if (direction == DMA_TO_DEVICE) { 762 + if (direction == DMA_MEM_TO_DEV) { 763 763 desc->rqcfg.src_inc = 1; 764 764 desc->rqcfg.dst_inc = 0; 765 765 desc->req.rqtype = MEMTODEV; ··· 834 834 835 835 amba_set_drvdata(adev, pdmac); 836 836 837 - #ifdef CONFIG_PM_RUNTIME 838 - /* to use the runtime PM helper functions */ 839 - pm_runtime_enable(&adev->dev); 840 - 841 - /* enable the power domain */ 842 - if (pm_runtime_get_sync(&adev->dev)) { 843 - dev_err(&adev->dev, "failed to get runtime pm\n"); 844 - ret = -ENODEV; 845 - goto probe_err1; 846 - } 847 - #else 837 + #ifndef CONFIG_PM_RUNTIME 848 838 /* enable dma clk */ 849 839 clk_enable(pdmac->clk); 850 840 #endif ··· 967 977 res = &adev->res; 968 978 release_mem_region(res->start, resource_size(res)); 969 979 970 - #ifdef CONFIG_PM_RUNTIME 971 - pm_runtime_put(&adev->dev); 972 - pm_runtime_disable(&adev->dev); 973 - #else 980 + #ifndef CONFIG_PM_RUNTIME 974 981 clk_disable(pdmac->clk); 975 982 #endif 976 983
+43 -29
drivers/dma/shdma.c
··· 23 23 #include <linux/interrupt.h> 24 24 #include <linux/dmaengine.h> 25 25 #include <linux/delay.h> 26 - #include <linux/dma-mapping.h> 27 26 #include <linux/platform_device.h> 28 27 #include <linux/pm_runtime.h> 29 28 #include <linux/sh_dma.h> ··· 56 57 static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SH_DMA_SLAVE_NUMBER)]; 57 58 58 59 static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all); 60 + static void sh_chan_xfer_ld_queue(struct sh_dmae_chan *sh_chan); 61 + 62 + static void chclr_write(struct sh_dmae_chan *sh_dc, u32 data) 63 + { 64 + struct sh_dmae_device *shdev = to_sh_dev(sh_dc); 65 + 66 + __raw_writel(data, shdev->chan_reg + 67 + shdev->pdata->channel[sh_dc->id].chclr_offset); 68 + } 59 69 60 70 static void sh_dmae_writel(struct sh_dmae_chan *sh_dc, u32 data, u32 reg) 61 71 { ··· 137 129 138 130 dmaor = dmaor_read(shdev) & ~(DMAOR_NMIF | DMAOR_AE | DMAOR_DME); 139 131 132 + if (shdev->pdata->chclr_present) { 133 + int i; 134 + for (i = 0; i < shdev->pdata->channel_num; i++) { 135 + struct sh_dmae_chan *sh_chan = shdev->chan[i]; 136 + if (sh_chan) 137 + chclr_write(sh_chan, 0); 138 + } 139 + } 140 + 140 141 dmaor_write(shdev, dmaor | shdev->pdata->dmaor_init); 141 142 142 143 dmaor = dmaor_read(shdev); ··· 156 139 dev_warn(shdev->common.dev, "Can't initialize DMAOR.\n"); 157 140 return -EIO; 158 141 } 142 + if (shdev->pdata->dmaor_init & ~dmaor) 143 + dev_warn(shdev->common.dev, 144 + "DMAOR=0x%x hasn't latched the initial value 0x%x.\n", 145 + dmaor, shdev->pdata->dmaor_init); 159 146 return 0; 160 147 } 161 148 ··· 280 259 return 0; 281 260 } 282 261 283 - static void sh_chan_xfer_ld_queue(struct sh_dmae_chan *sh_chan); 284 - 285 262 static dma_cookie_t sh_dmae_tx_submit(struct dma_async_tx_descriptor *tx) 286 263 { 287 264 struct sh_desc *desc = tx_to_sh_desc(tx), *chunk, *last = desc, *c; ··· 359 340 sh_chan_xfer_ld_queue(sh_chan); 360 341 sh_chan->pm_state = DMAE_PM_ESTABLISHED; 361 342 } 343 + } else { 344 + sh_chan->pm_state = DMAE_PM_PENDING; 362 345 } 363 346 364 347 spin_unlock_irq(&sh_chan->desc_lock); ··· 500 479 * @sh_chan: DMA channel 501 480 * @flags: DMA transfer flags 502 481 * @dest: destination DMA address, incremented when direction equals 503 - * DMA_FROM_DEVICE or DMA_BIDIRECTIONAL 482 + * DMA_DEV_TO_MEM 504 483 * @src: source DMA address, incremented when direction equals 505 - * DMA_TO_DEVICE or DMA_BIDIRECTIONAL 484 + * DMA_MEM_TO_DEV 506 485 * @len: DMA transfer length 507 486 * @first: if NULL, set to the current descriptor and cookie set to -EBUSY 508 487 * @direction: needed for slave DMA to decide which address to keep constant, 509 - * equals DMA_BIDIRECTIONAL for MEMCPY 488 + * equals DMA_MEM_TO_MEM for MEMCPY 510 489 * Returns 0 or an error 511 490 * Locks: called with desc_lock held 512 491 */ 513 492 static struct sh_desc *sh_dmae_add_desc(struct sh_dmae_chan *sh_chan, 514 493 unsigned long flags, dma_addr_t *dest, dma_addr_t *src, size_t *len, 515 - struct sh_desc **first, enum dma_data_direction direction) 494 + struct sh_desc **first, enum dma_transfer_direction direction) 516 495 { 517 496 struct sh_desc *new; 518 497 size_t copy_size; ··· 552 531 new->direction = direction; 553 532 554 533 *len -= copy_size; 555 - if (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE) 534 + if (direction == DMA_MEM_TO_MEM || direction == DMA_MEM_TO_DEV) 556 535 *src += copy_size; 557 - if (direction == DMA_BIDIRECTIONAL || direction == DMA_FROM_DEVICE) 536 + if (direction == DMA_MEM_TO_MEM || direction == DMA_DEV_TO_MEM) 558 537 *dest += copy_size; 559 538 560 539 return new; ··· 567 546 * converted to scatter-gather to guarantee consistent locking and a correct 568 547 * list manipulation. For slave DMA direction carries the usual meaning, and, 569 548 * logically, the SG list is RAM and the addr variable contains slave address, 570 - * e.g., the FIFO I/O register. For MEMCPY direction equals DMA_BIDIRECTIONAL 549 + * e.g., the FIFO I/O register. For MEMCPY direction equals DMA_MEM_TO_MEM 571 550 * and the SG list contains only one element and points at the source buffer. 572 551 */ 573 552 static struct dma_async_tx_descriptor *sh_dmae_prep_sg(struct sh_dmae_chan *sh_chan, 574 553 struct scatterlist *sgl, unsigned int sg_len, dma_addr_t *addr, 575 - enum dma_data_direction direction, unsigned long flags) 554 + enum dma_transfer_direction direction, unsigned long flags) 576 555 { 577 556 struct scatterlist *sg; 578 557 struct sh_desc *first = NULL, *new = NULL /* compiler... */; ··· 613 592 dev_dbg(sh_chan->dev, "Add SG #%d@%p[%d], dma %llx\n", 614 593 i, sg, len, (unsigned long long)sg_addr); 615 594 616 - if (direction == DMA_FROM_DEVICE) 595 + if (direction == DMA_DEV_TO_MEM) 617 596 new = sh_dmae_add_desc(sh_chan, flags, 618 597 &sg_addr, addr, &len, &first, 619 598 direction); ··· 667 646 sg_dma_address(&sg) = dma_src; 668 647 sg_dma_len(&sg) = len; 669 648 670 - return sh_dmae_prep_sg(sh_chan, &sg, 1, &dma_dest, DMA_BIDIRECTIONAL, 649 + return sh_dmae_prep_sg(sh_chan, &sg, 1, &dma_dest, DMA_MEM_TO_MEM, 671 650 flags); 672 651 } 673 652 674 653 static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg( 675 654 struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, 676 - enum dma_data_direction direction, unsigned long flags) 655 + enum dma_transfer_direction direction, unsigned long flags) 677 656 { 678 657 struct sh_dmae_slave *param; 679 658 struct sh_dmae_chan *sh_chan; ··· 1017 996 spin_lock_irq(&sh_chan->desc_lock); 1018 997 list_for_each_entry(desc, &sh_chan->ld_queue, node) { 1019 998 if (desc->mark == DESC_SUBMITTED && 1020 - ((desc->direction == DMA_FROM_DEVICE && 999 + ((desc->direction == DMA_DEV_TO_MEM && 1021 1000 (desc->hw.dar + desc->hw.tcr) == dar_buf) || 1022 1001 (desc->hw.sar + desc->hw.tcr) == sar_buf)) { 1023 1002 dev_dbg(sh_chan->dev, "done #%d@%p dst %u\n", ··· 1246 1225 1247 1226 platform_set_drvdata(pdev, shdev); 1248 1227 1228 + shdev->common.dev = &pdev->dev; 1229 + 1249 1230 pm_runtime_enable(&pdev->dev); 1250 1231 pm_runtime_get_sync(&pdev->dev); 1251 1232 ··· 1277 1254 shdev->common.device_prep_slave_sg = sh_dmae_prep_slave_sg; 1278 1255 shdev->common.device_control = sh_dmae_control; 1279 1256 1280 - shdev->common.dev = &pdev->dev; 1281 1257 /* Default transfer size of 32 bytes requires 32-byte alignment */ 1282 1258 shdev->common.copy_align = LOG2_DEFAULT_XFER_SIZE; 1283 1259 ··· 1457 1435 #ifdef CONFIG_PM 1458 1436 static int sh_dmae_suspend(struct device *dev) 1459 1437 { 1460 - struct sh_dmae_device *shdev = dev_get_drvdata(dev); 1461 - int i; 1462 - 1463 - for (i = 0; i < shdev->pdata->channel_num; i++) { 1464 - struct sh_dmae_chan *sh_chan = shdev->chan[i]; 1465 - if (sh_chan->descs_allocated) 1466 - sh_chan->pm_error = pm_runtime_put_sync(dev); 1467 - } 1468 - 1469 1438 return 0; 1470 1439 } 1471 1440 1472 1441 static int sh_dmae_resume(struct device *dev) 1473 1442 { 1474 1443 struct sh_dmae_device *shdev = dev_get_drvdata(dev); 1475 - int i; 1444 + int i, ret; 1445 + 1446 + ret = sh_dmae_rst(shdev); 1447 + if (ret < 0) 1448 + dev_err(dev, "Failed to reset!\n"); 1476 1449 1477 1450 for (i = 0; i < shdev->pdata->channel_num; i++) { 1478 1451 struct sh_dmae_chan *sh_chan = shdev->chan[i]; ··· 1475 1458 1476 1459 if (!sh_chan->descs_allocated) 1477 1460 continue; 1478 - 1479 - if (!sh_chan->pm_error) 1480 - pm_runtime_get_sync(dev); 1481 1461 1482 1462 if (param) { 1483 1463 const struct sh_dmae_slave_config *cfg = param->config;
+707
drivers/dma/sirf-dma.c
··· 1 + /* 2 + * DMA controller driver for CSR SiRFprimaII 3 + * 4 + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 + * 6 + * Licensed under GPLv2 or later. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/dmaengine.h> 11 + #include <linux/dma-mapping.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/io.h> 14 + #include <linux/slab.h> 15 + #include <linux/of_irq.h> 16 + #include <linux/of_address.h> 17 + #include <linux/of_device.h> 18 + #include <linux/of_platform.h> 19 + #include <linux/sirfsoc_dma.h> 20 + 21 + #define SIRFSOC_DMA_DESCRIPTORS 16 22 + #define SIRFSOC_DMA_CHANNELS 16 23 + 24 + #define SIRFSOC_DMA_CH_ADDR 0x00 25 + #define SIRFSOC_DMA_CH_XLEN 0x04 26 + #define SIRFSOC_DMA_CH_YLEN 0x08 27 + #define SIRFSOC_DMA_CH_CTRL 0x0C 28 + 29 + #define SIRFSOC_DMA_WIDTH_0 0x100 30 + #define SIRFSOC_DMA_CH_VALID 0x140 31 + #define SIRFSOC_DMA_CH_INT 0x144 32 + #define SIRFSOC_DMA_INT_EN 0x148 33 + #define SIRFSOC_DMA_CH_LOOP_CTRL 0x150 34 + 35 + #define SIRFSOC_DMA_MODE_CTRL_BIT 4 36 + #define SIRFSOC_DMA_DIR_CTRL_BIT 5 37 + 38 + /* xlen and dma_width register is in 4 bytes boundary */ 39 + #define SIRFSOC_DMA_WORD_LEN 4 40 + 41 + struct sirfsoc_dma_desc { 42 + struct dma_async_tx_descriptor desc; 43 + struct list_head node; 44 + 45 + /* SiRFprimaII 2D-DMA parameters */ 46 + 47 + int xlen; /* DMA xlen */ 48 + int ylen; /* DMA ylen */ 49 + int width; /* DMA width */ 50 + int dir; 51 + bool cyclic; /* is loop DMA? */ 52 + u32 addr; /* DMA buffer address */ 53 + }; 54 + 55 + struct sirfsoc_dma_chan { 56 + struct dma_chan chan; 57 + struct list_head free; 58 + struct list_head prepared; 59 + struct list_head queued; 60 + struct list_head active; 61 + struct list_head completed; 62 + dma_cookie_t completed_cookie; 63 + unsigned long happened_cyclic; 64 + unsigned long completed_cyclic; 65 + 66 + /* Lock for this structure */ 67 + spinlock_t lock; 68 + 69 + int mode; 70 + }; 71 + 72 + struct sirfsoc_dma { 73 + struct dma_device dma; 74 + struct tasklet_struct tasklet; 75 + struct sirfsoc_dma_chan channels[SIRFSOC_DMA_CHANNELS]; 76 + void __iomem *base; 77 + int irq; 78 + }; 79 + 80 + #define DRV_NAME "sirfsoc_dma" 81 + 82 + /* Convert struct dma_chan to struct sirfsoc_dma_chan */ 83 + static inline 84 + struct sirfsoc_dma_chan *dma_chan_to_sirfsoc_dma_chan(struct dma_chan *c) 85 + { 86 + return container_of(c, struct sirfsoc_dma_chan, chan); 87 + } 88 + 89 + /* Convert struct dma_chan to struct sirfsoc_dma */ 90 + static inline struct sirfsoc_dma *dma_chan_to_sirfsoc_dma(struct dma_chan *c) 91 + { 92 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(c); 93 + return container_of(schan, struct sirfsoc_dma, channels[c->chan_id]); 94 + } 95 + 96 + /* Execute all queued DMA descriptors */ 97 + static void sirfsoc_dma_execute(struct sirfsoc_dma_chan *schan) 98 + { 99 + struct sirfsoc_dma *sdma = dma_chan_to_sirfsoc_dma(&schan->chan); 100 + int cid = schan->chan.chan_id; 101 + struct sirfsoc_dma_desc *sdesc = NULL; 102 + 103 + /* 104 + * lock has been held by functions calling this, so we don't hold 105 + * lock again 106 + */ 107 + 108 + sdesc = list_first_entry(&schan->queued, struct sirfsoc_dma_desc, 109 + node); 110 + /* Move the first queued descriptor to active list */ 111 + list_move_tail(&schan->queued, &schan->active); 112 + 113 + /* Start the DMA transfer */ 114 + writel_relaxed(sdesc->width, sdma->base + SIRFSOC_DMA_WIDTH_0 + 115 + cid * 4); 116 + writel_relaxed(cid | (schan->mode << SIRFSOC_DMA_MODE_CTRL_BIT) | 117 + (sdesc->dir << SIRFSOC_DMA_DIR_CTRL_BIT), 118 + sdma->base + cid * 0x10 + SIRFSOC_DMA_CH_CTRL); 119 + writel_relaxed(sdesc->xlen, sdma->base + cid * 0x10 + 120 + SIRFSOC_DMA_CH_XLEN); 121 + writel_relaxed(sdesc->ylen, sdma->base + cid * 0x10 + 122 + SIRFSOC_DMA_CH_YLEN); 123 + writel_relaxed(readl_relaxed(sdma->base + SIRFSOC_DMA_INT_EN) | 124 + (1 << cid), sdma->base + SIRFSOC_DMA_INT_EN); 125 + 126 + /* 127 + * writel has an implict memory write barrier to make sure data is 128 + * flushed into memory before starting DMA 129 + */ 130 + writel(sdesc->addr >> 2, sdma->base + cid * 0x10 + SIRFSOC_DMA_CH_ADDR); 131 + 132 + if (sdesc->cyclic) { 133 + writel((1 << cid) | 1 << (cid + 16) | 134 + readl_relaxed(sdma->base + SIRFSOC_DMA_CH_LOOP_CTRL), 135 + sdma->base + SIRFSOC_DMA_CH_LOOP_CTRL); 136 + schan->happened_cyclic = schan->completed_cyclic = 0; 137 + } 138 + } 139 + 140 + /* Interrupt handler */ 141 + static irqreturn_t sirfsoc_dma_irq(int irq, void *data) 142 + { 143 + struct sirfsoc_dma *sdma = data; 144 + struct sirfsoc_dma_chan *schan; 145 + struct sirfsoc_dma_desc *sdesc = NULL; 146 + u32 is; 147 + int ch; 148 + 149 + is = readl(sdma->base + SIRFSOC_DMA_CH_INT); 150 + while ((ch = fls(is) - 1) >= 0) { 151 + is &= ~(1 << ch); 152 + writel_relaxed(1 << ch, sdma->base + SIRFSOC_DMA_CH_INT); 153 + schan = &sdma->channels[ch]; 154 + 155 + spin_lock(&schan->lock); 156 + 157 + sdesc = list_first_entry(&schan->active, struct sirfsoc_dma_desc, 158 + node); 159 + if (!sdesc->cyclic) { 160 + /* Execute queued descriptors */ 161 + list_splice_tail_init(&schan->active, &schan->completed); 162 + if (!list_empty(&schan->queued)) 163 + sirfsoc_dma_execute(schan); 164 + } else 165 + schan->happened_cyclic++; 166 + 167 + spin_unlock(&schan->lock); 168 + } 169 + 170 + /* Schedule tasklet */ 171 + tasklet_schedule(&sdma->tasklet); 172 + 173 + return IRQ_HANDLED; 174 + } 175 + 176 + /* process completed descriptors */ 177 + static void sirfsoc_dma_process_completed(struct sirfsoc_dma *sdma) 178 + { 179 + dma_cookie_t last_cookie = 0; 180 + struct sirfsoc_dma_chan *schan; 181 + struct sirfsoc_dma_desc *sdesc; 182 + struct dma_async_tx_descriptor *desc; 183 + unsigned long flags; 184 + unsigned long happened_cyclic; 185 + LIST_HEAD(list); 186 + int i; 187 + 188 + for (i = 0; i < sdma->dma.chancnt; i++) { 189 + schan = &sdma->channels[i]; 190 + 191 + /* Get all completed descriptors */ 192 + spin_lock_irqsave(&schan->lock, flags); 193 + if (!list_empty(&schan->completed)) { 194 + list_splice_tail_init(&schan->completed, &list); 195 + spin_unlock_irqrestore(&schan->lock, flags); 196 + 197 + /* Execute callbacks and run dependencies */ 198 + list_for_each_entry(sdesc, &list, node) { 199 + desc = &sdesc->desc; 200 + 201 + if (desc->callback) 202 + desc->callback(desc->callback_param); 203 + 204 + last_cookie = desc->cookie; 205 + dma_run_dependencies(desc); 206 + } 207 + 208 + /* Free descriptors */ 209 + spin_lock_irqsave(&schan->lock, flags); 210 + list_splice_tail_init(&list, &schan->free); 211 + schan->completed_cookie = last_cookie; 212 + spin_unlock_irqrestore(&schan->lock, flags); 213 + } else { 214 + /* for cyclic channel, desc is always in active list */ 215 + sdesc = list_first_entry(&schan->active, struct sirfsoc_dma_desc, 216 + node); 217 + 218 + if (!sdesc || (sdesc && !sdesc->cyclic)) { 219 + /* without active cyclic DMA */ 220 + spin_unlock_irqrestore(&schan->lock, flags); 221 + continue; 222 + } 223 + 224 + /* cyclic DMA */ 225 + happened_cyclic = schan->happened_cyclic; 226 + spin_unlock_irqrestore(&schan->lock, flags); 227 + 228 + desc = &sdesc->desc; 229 + while (happened_cyclic != schan->completed_cyclic) { 230 + if (desc->callback) 231 + desc->callback(desc->callback_param); 232 + schan->completed_cyclic++; 233 + } 234 + } 235 + } 236 + } 237 + 238 + /* DMA Tasklet */ 239 + static void sirfsoc_dma_tasklet(unsigned long data) 240 + { 241 + struct sirfsoc_dma *sdma = (void *)data; 242 + 243 + sirfsoc_dma_process_completed(sdma); 244 + } 245 + 246 + /* Submit descriptor to hardware */ 247 + static dma_cookie_t sirfsoc_dma_tx_submit(struct dma_async_tx_descriptor *txd) 248 + { 249 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(txd->chan); 250 + struct sirfsoc_dma_desc *sdesc; 251 + unsigned long flags; 252 + dma_cookie_t cookie; 253 + 254 + sdesc = container_of(txd, struct sirfsoc_dma_desc, desc); 255 + 256 + spin_lock_irqsave(&schan->lock, flags); 257 + 258 + /* Move descriptor to queue */ 259 + list_move_tail(&sdesc->node, &schan->queued); 260 + 261 + /* Update cookie */ 262 + cookie = schan->chan.cookie + 1; 263 + if (cookie <= 0) 264 + cookie = 1; 265 + 266 + schan->chan.cookie = cookie; 267 + sdesc->desc.cookie = cookie; 268 + 269 + spin_unlock_irqrestore(&schan->lock, flags); 270 + 271 + return cookie; 272 + } 273 + 274 + static int sirfsoc_dma_slave_config(struct sirfsoc_dma_chan *schan, 275 + struct dma_slave_config *config) 276 + { 277 + unsigned long flags; 278 + 279 + if ((config->src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) || 280 + (config->dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)) 281 + return -EINVAL; 282 + 283 + spin_lock_irqsave(&schan->lock, flags); 284 + schan->mode = (config->src_maxburst == 4 ? 1 : 0); 285 + spin_unlock_irqrestore(&schan->lock, flags); 286 + 287 + return 0; 288 + } 289 + 290 + static int sirfsoc_dma_terminate_all(struct sirfsoc_dma_chan *schan) 291 + { 292 + struct sirfsoc_dma *sdma = dma_chan_to_sirfsoc_dma(&schan->chan); 293 + int cid = schan->chan.chan_id; 294 + unsigned long flags; 295 + 296 + writel_relaxed(readl_relaxed(sdma->base + SIRFSOC_DMA_INT_EN) & 297 + ~(1 << cid), sdma->base + SIRFSOC_DMA_INT_EN); 298 + writel_relaxed(1 << cid, sdma->base + SIRFSOC_DMA_CH_VALID); 299 + 300 + writel_relaxed(readl_relaxed(sdma->base + SIRFSOC_DMA_CH_LOOP_CTRL) 301 + & ~((1 << cid) | 1 << (cid + 16)), 302 + sdma->base + SIRFSOC_DMA_CH_LOOP_CTRL); 303 + 304 + spin_lock_irqsave(&schan->lock, flags); 305 + list_splice_tail_init(&schan->active, &schan->free); 306 + list_splice_tail_init(&schan->queued, &schan->free); 307 + spin_unlock_irqrestore(&schan->lock, flags); 308 + 309 + return 0; 310 + } 311 + 312 + static int sirfsoc_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, 313 + unsigned long arg) 314 + { 315 + struct dma_slave_config *config; 316 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 317 + 318 + switch (cmd) { 319 + case DMA_TERMINATE_ALL: 320 + return sirfsoc_dma_terminate_all(schan); 321 + case DMA_SLAVE_CONFIG: 322 + config = (struct dma_slave_config *)arg; 323 + return sirfsoc_dma_slave_config(schan, config); 324 + 325 + default: 326 + break; 327 + } 328 + 329 + return -ENOSYS; 330 + } 331 + 332 + /* Alloc channel resources */ 333 + static int sirfsoc_dma_alloc_chan_resources(struct dma_chan *chan) 334 + { 335 + struct sirfsoc_dma *sdma = dma_chan_to_sirfsoc_dma(chan); 336 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 337 + struct sirfsoc_dma_desc *sdesc; 338 + unsigned long flags; 339 + LIST_HEAD(descs); 340 + int i; 341 + 342 + /* Alloc descriptors for this channel */ 343 + for (i = 0; i < SIRFSOC_DMA_DESCRIPTORS; i++) { 344 + sdesc = kzalloc(sizeof(*sdesc), GFP_KERNEL); 345 + if (!sdesc) { 346 + dev_notice(sdma->dma.dev, "Memory allocation error. " 347 + "Allocated only %u descriptors\n", i); 348 + break; 349 + } 350 + 351 + dma_async_tx_descriptor_init(&sdesc->desc, chan); 352 + sdesc->desc.flags = DMA_CTRL_ACK; 353 + sdesc->desc.tx_submit = sirfsoc_dma_tx_submit; 354 + 355 + list_add_tail(&sdesc->node, &descs); 356 + } 357 + 358 + /* Return error only if no descriptors were allocated */ 359 + if (i == 0) 360 + return -ENOMEM; 361 + 362 + spin_lock_irqsave(&schan->lock, flags); 363 + 364 + list_splice_tail_init(&descs, &schan->free); 365 + spin_unlock_irqrestore(&schan->lock, flags); 366 + 367 + return i; 368 + } 369 + 370 + /* Free channel resources */ 371 + static void sirfsoc_dma_free_chan_resources(struct dma_chan *chan) 372 + { 373 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 374 + struct sirfsoc_dma_desc *sdesc, *tmp; 375 + unsigned long flags; 376 + LIST_HEAD(descs); 377 + 378 + spin_lock_irqsave(&schan->lock, flags); 379 + 380 + /* Channel must be idle */ 381 + BUG_ON(!list_empty(&schan->prepared)); 382 + BUG_ON(!list_empty(&schan->queued)); 383 + BUG_ON(!list_empty(&schan->active)); 384 + BUG_ON(!list_empty(&schan->completed)); 385 + 386 + /* Move data */ 387 + list_splice_tail_init(&schan->free, &descs); 388 + 389 + spin_unlock_irqrestore(&schan->lock, flags); 390 + 391 + /* Free descriptors */ 392 + list_for_each_entry_safe(sdesc, tmp, &descs, node) 393 + kfree(sdesc); 394 + } 395 + 396 + /* Send pending descriptor to hardware */ 397 + static void sirfsoc_dma_issue_pending(struct dma_chan *chan) 398 + { 399 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 400 + unsigned long flags; 401 + 402 + spin_lock_irqsave(&schan->lock, flags); 403 + 404 + if (list_empty(&schan->active) && !list_empty(&schan->queued)) 405 + sirfsoc_dma_execute(schan); 406 + 407 + spin_unlock_irqrestore(&schan->lock, flags); 408 + } 409 + 410 + /* Check request completion status */ 411 + static enum dma_status 412 + sirfsoc_dma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, 413 + struct dma_tx_state *txstate) 414 + { 415 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 416 + unsigned long flags; 417 + dma_cookie_t last_used; 418 + dma_cookie_t last_complete; 419 + 420 + spin_lock_irqsave(&schan->lock, flags); 421 + last_used = schan->chan.cookie; 422 + last_complete = schan->completed_cookie; 423 + spin_unlock_irqrestore(&schan->lock, flags); 424 + 425 + dma_set_tx_state(txstate, last_complete, last_used, 0); 426 + return dma_async_is_complete(cookie, last_complete, last_used); 427 + } 428 + 429 + static struct dma_async_tx_descriptor *sirfsoc_dma_prep_interleaved( 430 + struct dma_chan *chan, struct dma_interleaved_template *xt, 431 + unsigned long flags) 432 + { 433 + struct sirfsoc_dma *sdma = dma_chan_to_sirfsoc_dma(chan); 434 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 435 + struct sirfsoc_dma_desc *sdesc = NULL; 436 + unsigned long iflags; 437 + int ret; 438 + 439 + if ((xt->dir != DMA_MEM_TO_DEV) || (xt->dir != DMA_DEV_TO_MEM)) { 440 + ret = -EINVAL; 441 + goto err_dir; 442 + } 443 + 444 + /* Get free descriptor */ 445 + spin_lock_irqsave(&schan->lock, iflags); 446 + if (!list_empty(&schan->free)) { 447 + sdesc = list_first_entry(&schan->free, struct sirfsoc_dma_desc, 448 + node); 449 + list_del(&sdesc->node); 450 + } 451 + spin_unlock_irqrestore(&schan->lock, iflags); 452 + 453 + if (!sdesc) { 454 + /* try to free completed descriptors */ 455 + sirfsoc_dma_process_completed(sdma); 456 + ret = 0; 457 + goto no_desc; 458 + } 459 + 460 + /* Place descriptor in prepared list */ 461 + spin_lock_irqsave(&schan->lock, iflags); 462 + 463 + /* 464 + * Number of chunks in a frame can only be 1 for prima2 465 + * and ylen (number of frame - 1) must be at least 0 466 + */ 467 + if ((xt->frame_size == 1) && (xt->numf > 0)) { 468 + sdesc->cyclic = 0; 469 + sdesc->xlen = xt->sgl[0].size / SIRFSOC_DMA_WORD_LEN; 470 + sdesc->width = (xt->sgl[0].size + xt->sgl[0].icg) / 471 + SIRFSOC_DMA_WORD_LEN; 472 + sdesc->ylen = xt->numf - 1; 473 + if (xt->dir == DMA_MEM_TO_DEV) { 474 + sdesc->addr = xt->src_start; 475 + sdesc->dir = 1; 476 + } else { 477 + sdesc->addr = xt->dst_start; 478 + sdesc->dir = 0; 479 + } 480 + 481 + list_add_tail(&sdesc->node, &schan->prepared); 482 + } else { 483 + pr_err("sirfsoc DMA Invalid xfer\n"); 484 + ret = -EINVAL; 485 + goto err_xfer; 486 + } 487 + spin_unlock_irqrestore(&schan->lock, iflags); 488 + 489 + return &sdesc->desc; 490 + err_xfer: 491 + spin_unlock_irqrestore(&schan->lock, iflags); 492 + no_desc: 493 + err_dir: 494 + return ERR_PTR(ret); 495 + } 496 + 497 + static struct dma_async_tx_descriptor * 498 + sirfsoc_dma_prep_cyclic(struct dma_chan *chan, dma_addr_t addr, 499 + size_t buf_len, size_t period_len, 500 + enum dma_transfer_direction direction) 501 + { 502 + struct sirfsoc_dma_chan *schan = dma_chan_to_sirfsoc_dma_chan(chan); 503 + struct sirfsoc_dma_desc *sdesc = NULL; 504 + unsigned long iflags; 505 + 506 + /* 507 + * we only support cycle transfer with 2 period 508 + * If the X-length is set to 0, it would be the loop mode. 509 + * The DMA address keeps increasing until reaching the end of a loop 510 + * area whose size is defined by (DMA_WIDTH x (Y_LENGTH + 1)). Then 511 + * the DMA address goes back to the beginning of this area. 512 + * In loop mode, the DMA data region is divided into two parts, BUFA 513 + * and BUFB. DMA controller generates interrupts twice in each loop: 514 + * when the DMA address reaches the end of BUFA or the end of the 515 + * BUFB 516 + */ 517 + if (buf_len != 2 * period_len) 518 + return ERR_PTR(-EINVAL); 519 + 520 + /* Get free descriptor */ 521 + spin_lock_irqsave(&schan->lock, iflags); 522 + if (!list_empty(&schan->free)) { 523 + sdesc = list_first_entry(&schan->free, struct sirfsoc_dma_desc, 524 + node); 525 + list_del(&sdesc->node); 526 + } 527 + spin_unlock_irqrestore(&schan->lock, iflags); 528 + 529 + if (!sdesc) 530 + return 0; 531 + 532 + /* Place descriptor in prepared list */ 533 + spin_lock_irqsave(&schan->lock, iflags); 534 + sdesc->addr = addr; 535 + sdesc->cyclic = 1; 536 + sdesc->xlen = 0; 537 + sdesc->ylen = buf_len / SIRFSOC_DMA_WORD_LEN - 1; 538 + sdesc->width = 1; 539 + list_add_tail(&sdesc->node, &schan->prepared); 540 + spin_unlock_irqrestore(&schan->lock, iflags); 541 + 542 + return &sdesc->desc; 543 + } 544 + 545 + /* 546 + * The DMA controller consists of 16 independent DMA channels. 547 + * Each channel is allocated to a different function 548 + */ 549 + bool sirfsoc_dma_filter_id(struct dma_chan *chan, void *chan_id) 550 + { 551 + unsigned int ch_nr = (unsigned int) chan_id; 552 + 553 + if (ch_nr == chan->chan_id + 554 + chan->device->dev_id * SIRFSOC_DMA_CHANNELS) 555 + return true; 556 + 557 + return false; 558 + } 559 + EXPORT_SYMBOL(sirfsoc_dma_filter_id); 560 + 561 + static int __devinit sirfsoc_dma_probe(struct platform_device *op) 562 + { 563 + struct device_node *dn = op->dev.of_node; 564 + struct device *dev = &op->dev; 565 + struct dma_device *dma; 566 + struct sirfsoc_dma *sdma; 567 + struct sirfsoc_dma_chan *schan; 568 + struct resource res; 569 + ulong regs_start, regs_size; 570 + u32 id; 571 + int ret, i; 572 + 573 + sdma = devm_kzalloc(dev, sizeof(*sdma), GFP_KERNEL); 574 + if (!sdma) { 575 + dev_err(dev, "Memory exhausted!\n"); 576 + return -ENOMEM; 577 + } 578 + 579 + if (of_property_read_u32(dn, "cell-index", &id)) { 580 + dev_err(dev, "Fail to get DMAC index\n"); 581 + ret = -ENODEV; 582 + goto free_mem; 583 + } 584 + 585 + sdma->irq = irq_of_parse_and_map(dn, 0); 586 + if (sdma->irq == NO_IRQ) { 587 + dev_err(dev, "Error mapping IRQ!\n"); 588 + ret = -EINVAL; 589 + goto free_mem; 590 + } 591 + 592 + ret = of_address_to_resource(dn, 0, &res); 593 + if (ret) { 594 + dev_err(dev, "Error parsing memory region!\n"); 595 + goto free_mem; 596 + } 597 + 598 + regs_start = res.start; 599 + regs_size = resource_size(&res); 600 + 601 + sdma->base = devm_ioremap(dev, regs_start, regs_size); 602 + if (!sdma->base) { 603 + dev_err(dev, "Error mapping memory region!\n"); 604 + ret = -ENOMEM; 605 + goto irq_dispose; 606 + } 607 + 608 + ret = devm_request_irq(dev, sdma->irq, &sirfsoc_dma_irq, 0, DRV_NAME, 609 + sdma); 610 + if (ret) { 611 + dev_err(dev, "Error requesting IRQ!\n"); 612 + ret = -EINVAL; 613 + goto unmap_mem; 614 + } 615 + 616 + dma = &sdma->dma; 617 + dma->dev = dev; 618 + dma->chancnt = SIRFSOC_DMA_CHANNELS; 619 + 620 + dma->device_alloc_chan_resources = sirfsoc_dma_alloc_chan_resources; 621 + dma->device_free_chan_resources = sirfsoc_dma_free_chan_resources; 622 + dma->device_issue_pending = sirfsoc_dma_issue_pending; 623 + dma->device_control = sirfsoc_dma_control; 624 + dma->device_tx_status = sirfsoc_dma_tx_status; 625 + dma->device_prep_interleaved_dma = sirfsoc_dma_prep_interleaved; 626 + dma->device_prep_dma_cyclic = sirfsoc_dma_prep_cyclic; 627 + 628 + INIT_LIST_HEAD(&dma->channels); 629 + dma_cap_set(DMA_SLAVE, dma->cap_mask); 630 + dma_cap_set(DMA_CYCLIC, dma->cap_mask); 631 + dma_cap_set(DMA_INTERLEAVE, dma->cap_mask); 632 + dma_cap_set(DMA_PRIVATE, dma->cap_mask); 633 + 634 + for (i = 0; i < dma->chancnt; i++) { 635 + schan = &sdma->channels[i]; 636 + 637 + schan->chan.device = dma; 638 + schan->chan.cookie = 1; 639 + schan->completed_cookie = schan->chan.cookie; 640 + 641 + INIT_LIST_HEAD(&schan->free); 642 + INIT_LIST_HEAD(&schan->prepared); 643 + INIT_LIST_HEAD(&schan->queued); 644 + INIT_LIST_HEAD(&schan->active); 645 + INIT_LIST_HEAD(&schan->completed); 646 + 647 + spin_lock_init(&schan->lock); 648 + list_add_tail(&schan->chan.device_node, &dma->channels); 649 + } 650 + 651 + tasklet_init(&sdma->tasklet, sirfsoc_dma_tasklet, (unsigned long)sdma); 652 + 653 + /* Register DMA engine */ 654 + dev_set_drvdata(dev, sdma); 655 + ret = dma_async_device_register(dma); 656 + if (ret) 657 + goto free_irq; 658 + 659 + dev_info(dev, "initialized SIRFSOC DMAC driver\n"); 660 + 661 + return 0; 662 + 663 + free_irq: 664 + devm_free_irq(dev, sdma->irq, sdma); 665 + irq_dispose: 666 + irq_dispose_mapping(sdma->irq); 667 + unmap_mem: 668 + iounmap(sdma->base); 669 + free_mem: 670 + devm_kfree(dev, sdma); 671 + return ret; 672 + } 673 + 674 + static int __devexit sirfsoc_dma_remove(struct platform_device *op) 675 + { 676 + struct device *dev = &op->dev; 677 + struct sirfsoc_dma *sdma = dev_get_drvdata(dev); 678 + 679 + dma_async_device_unregister(&sdma->dma); 680 + devm_free_irq(dev, sdma->irq, sdma); 681 + irq_dispose_mapping(sdma->irq); 682 + iounmap(sdma->base); 683 + devm_kfree(dev, sdma); 684 + return 0; 685 + } 686 + 687 + static struct of_device_id sirfsoc_dma_match[] = { 688 + { .compatible = "sirf,prima2-dmac", }, 689 + {}, 690 + }; 691 + 692 + static struct platform_driver sirfsoc_dma_driver = { 693 + .probe = sirfsoc_dma_probe, 694 + .remove = __devexit_p(sirfsoc_dma_remove), 695 + .driver = { 696 + .name = DRV_NAME, 697 + .owner = THIS_MODULE, 698 + .of_match_table = sirfsoc_dma_match, 699 + }, 700 + }; 701 + 702 + module_platform_driver(sirfsoc_dma_driver); 703 + 704 + MODULE_AUTHOR("Rongjun Ying <rongjun.ying@csr.com>, " 705 + "Barry Song <baohua.song@csr.com>"); 706 + MODULE_DESCRIPTION("SIRFSOC DMA control driver"); 707 + MODULE_LICENSE("GPL v2");
+391 -50
drivers/dma/ste_dma40.c
··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/clk.h> 16 16 #include <linux/delay.h> 17 + #include <linux/pm.h> 18 + #include <linux/pm_runtime.h> 17 19 #include <linux/err.h> 18 20 #include <linux/amba/bus.h> 19 21 ··· 33 31 34 32 /* Maximum iterations taken before giving up suspending a channel */ 35 33 #define D40_SUSPEND_MAX_IT 500 34 + 35 + /* Milliseconds */ 36 + #define DMA40_AUTOSUSPEND_DELAY 100 36 37 37 38 /* Hardware requirement on LCLA alignment */ 38 39 #define LCLA_ALIGNMENT 0x40000 ··· 65 60 D40_DMA_RUN = 1, 66 61 D40_DMA_SUSPEND_REQ = 2, 67 62 D40_DMA_SUSPENDED = 3 63 + }; 64 + 65 + /* 66 + * These are the registers that has to be saved and later restored 67 + * when the DMA hw is powered off. 68 + * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works. 69 + */ 70 + static u32 d40_backup_regs[] = { 71 + D40_DREG_LCPA, 72 + D40_DREG_LCLA, 73 + D40_DREG_PRMSE, 74 + D40_DREG_PRMSO, 75 + D40_DREG_PRMOE, 76 + D40_DREG_PRMOO, 77 + }; 78 + 79 + #define BACKUP_REGS_SZ ARRAY_SIZE(d40_backup_regs) 80 + 81 + /* TODO: Check if all these registers have to be saved/restored on dma40 v3 */ 82 + static u32 d40_backup_regs_v3[] = { 83 + D40_DREG_PSEG1, 84 + D40_DREG_PSEG2, 85 + D40_DREG_PSEG3, 86 + D40_DREG_PSEG4, 87 + D40_DREG_PCEG1, 88 + D40_DREG_PCEG2, 89 + D40_DREG_PCEG3, 90 + D40_DREG_PCEG4, 91 + D40_DREG_RSEG1, 92 + D40_DREG_RSEG2, 93 + D40_DREG_RSEG3, 94 + D40_DREG_RSEG4, 95 + D40_DREG_RCEG1, 96 + D40_DREG_RCEG2, 97 + D40_DREG_RCEG3, 98 + D40_DREG_RCEG4, 99 + }; 100 + 101 + #define BACKUP_REGS_SZ_V3 ARRAY_SIZE(d40_backup_regs_v3) 102 + 103 + static u32 d40_backup_regs_chan[] = { 104 + D40_CHAN_REG_SSCFG, 105 + D40_CHAN_REG_SSELT, 106 + D40_CHAN_REG_SSPTR, 107 + D40_CHAN_REG_SSLNK, 108 + D40_CHAN_REG_SDCFG, 109 + D40_CHAN_REG_SDELT, 110 + D40_CHAN_REG_SDPTR, 111 + D40_CHAN_REG_SDLNK, 68 112 }; 69 113 70 114 /** ··· 150 96 * during a transfer. 151 97 * @node: List entry. 152 98 * @is_in_client_list: true if the client owns this descriptor. 153 - * the previous one. 99 + * @cyclic: true if this is a cyclic job 154 100 * 155 101 * This descriptor is used for both logical and physical transfers. 156 102 */ ··· 197 143 * channels. 198 144 * 199 145 * @lock: A lock protection this entity. 146 + * @reserved: True if used by secure world or otherwise. 200 147 * @num: The physical channel number of this entity. 201 148 * @allocated_src: Bit mapped to show which src event line's are mapped to 202 149 * this physical channel. Can also be free or physically allocated. ··· 207 152 */ 208 153 struct d40_phy_res { 209 154 spinlock_t lock; 155 + bool reserved; 210 156 int num; 211 157 u32 allocated_src; 212 158 u32 allocated_dst; ··· 241 185 * @src_def_cfg: Default cfg register setting for src. 242 186 * @dst_def_cfg: Default cfg register setting for dst. 243 187 * @log_def: Default logical channel settings. 244 - * @lcla: Space for one dst src pair for logical channel transfers. 245 188 * @lcpa: Pointer to dst and src lcpa settings. 246 189 * @runtime_addr: runtime configured address. 247 190 * @runtime_direction: runtime configured direction. ··· 272 217 struct d40_log_lli_full *lcpa; 273 218 /* Runtime reconfiguration */ 274 219 dma_addr_t runtime_addr; 275 - enum dma_data_direction runtime_direction; 220 + enum dma_transfer_direction runtime_direction; 276 221 }; 277 222 278 223 /** ··· 296 241 * @dma_both: dma_device channels that can do both memcpy and slave transfers. 297 242 * @dma_slave: dma_device channels that can do only do slave transfers. 298 243 * @dma_memcpy: dma_device channels that can do only do memcpy transfers. 244 + * @phy_chans: Room for all possible physical channels in system. 299 245 * @log_chans: Room for all possible logical channels in system. 300 246 * @lookup_log_chans: Used to map interrupt number to logical channel. Points 301 247 * to log_chans entries. ··· 304 248 * to phy_chans entries. 305 249 * @plat_data: Pointer to provided platform_data which is the driver 306 250 * configuration. 251 + * @lcpa_regulator: Pointer to hold the regulator for the esram bank for lcla. 307 252 * @phy_res: Vector containing all physical channels. 308 253 * @lcla_pool: lcla pool settings and data. 309 254 * @lcpa_base: The virtual mapped address of LCPA. 310 255 * @phy_lcpa: The physical address of the LCPA. 311 256 * @lcpa_size: The size of the LCPA area. 312 257 * @desc_slab: cache for descriptors. 258 + * @reg_val_backup: Here the values of some hardware registers are stored 259 + * before the DMA is powered off. They are restored when the power is back on. 260 + * @reg_val_backup_v3: Backup of registers that only exits on dma40 v3 and 261 + * later. 262 + * @reg_val_backup_chan: Backup data for standard channel parameter registers. 263 + * @gcc_pwr_off_mask: Mask to maintain the channels that can be turned off. 264 + * @initialized: true if the dma has been initialized 313 265 */ 314 266 struct d40_base { 315 267 spinlock_t interrupt_lock; ··· 339 275 struct d40_chan **lookup_log_chans; 340 276 struct d40_chan **lookup_phy_chans; 341 277 struct stedma40_platform_data *plat_data; 278 + struct regulator *lcpa_regulator; 342 279 /* Physical half channels */ 343 280 struct d40_phy_res *phy_res; 344 281 struct d40_lcla_pool lcla_pool; ··· 347 282 dma_addr_t phy_lcpa; 348 283 resource_size_t lcpa_size; 349 284 struct kmem_cache *desc_slab; 285 + u32 reg_val_backup[BACKUP_REGS_SZ]; 286 + u32 reg_val_backup_v3[BACKUP_REGS_SZ_V3]; 287 + u32 *reg_val_backup_chan; 288 + u16 gcc_pwr_off_mask; 289 + bool initialized; 350 290 }; 351 291 352 292 /** ··· 549 479 struct d40_desc *d; 550 480 struct d40_desc *_d; 551 481 552 - list_for_each_entry_safe(d, _d, &d40c->client, node) 482 + list_for_each_entry_safe(d, _d, &d40c->client, node) { 553 483 if (async_tx_test_ack(&d->txd)) { 554 484 d40_desc_remove(d); 555 485 desc = d; 556 486 memset(desc, 0, sizeof(*desc)); 557 487 break; 558 488 } 489 + } 559 490 } 560 491 561 492 if (!desc) ··· 607 536 bool cyclic = desc->cyclic; 608 537 int curr_lcla = -EINVAL; 609 538 int first_lcla = 0; 539 + bool use_esram_lcla = chan->base->plat_data->use_esram_lcla; 610 540 bool linkback; 611 541 612 542 /* ··· 680 608 &lli->src[lli_current], 681 609 next_lcla, flags); 682 610 683 - dma_sync_single_range_for_device(chan->base->dev, 684 - pool->dma_addr, lcla_offset, 685 - 2 * sizeof(struct d40_log_lli), 686 - DMA_TO_DEVICE); 687 - 611 + /* 612 + * Cache maintenance is not needed if lcla is 613 + * mapped in esram 614 + */ 615 + if (!use_esram_lcla) { 616 + dma_sync_single_range_for_device(chan->base->dev, 617 + pool->dma_addr, lcla_offset, 618 + 2 * sizeof(struct d40_log_lli), 619 + DMA_TO_DEVICE); 620 + } 688 621 curr_lcla = next_lcla; 689 622 690 623 if (curr_lcla == -EINVAL || curr_lcla == first_lcla) { ··· 817 740 return len; 818 741 } 819 742 820 - /* Support functions for logical channels */ 743 + 744 + #ifdef CONFIG_PM 745 + static void dma40_backup(void __iomem *baseaddr, u32 *backup, 746 + u32 *regaddr, int num, bool save) 747 + { 748 + int i; 749 + 750 + for (i = 0; i < num; i++) { 751 + void __iomem *addr = baseaddr + regaddr[i]; 752 + 753 + if (save) 754 + backup[i] = readl_relaxed(addr); 755 + else 756 + writel_relaxed(backup[i], addr); 757 + } 758 + } 759 + 760 + static void d40_save_restore_registers(struct d40_base *base, bool save) 761 + { 762 + int i; 763 + 764 + /* Save/Restore channel specific registers */ 765 + for (i = 0; i < base->num_phy_chans; i++) { 766 + void __iomem *addr; 767 + int idx; 768 + 769 + if (base->phy_res[i].reserved) 770 + continue; 771 + 772 + addr = base->virtbase + D40_DREG_PCBASE + i * D40_DREG_PCDELTA; 773 + idx = i * ARRAY_SIZE(d40_backup_regs_chan); 774 + 775 + dma40_backup(addr, &base->reg_val_backup_chan[idx], 776 + d40_backup_regs_chan, 777 + ARRAY_SIZE(d40_backup_regs_chan), 778 + save); 779 + } 780 + 781 + /* Save/Restore global registers */ 782 + dma40_backup(base->virtbase, base->reg_val_backup, 783 + d40_backup_regs, ARRAY_SIZE(d40_backup_regs), 784 + save); 785 + 786 + /* Save/Restore registers only existing on dma40 v3 and later */ 787 + if (base->rev >= 3) 788 + dma40_backup(base->virtbase, base->reg_val_backup_v3, 789 + d40_backup_regs_v3, 790 + ARRAY_SIZE(d40_backup_regs_v3), 791 + save); 792 + } 793 + #else 794 + static void d40_save_restore_registers(struct d40_base *base, bool save) 795 + { 796 + } 797 + #endif 821 798 822 799 static int d40_channel_execute_command(struct d40_chan *d40c, 823 800 enum d40_command command) ··· 1104 973 /* Set LIDX for lcla */ 1105 974 writel(lidx, chanbase + D40_CHAN_REG_SSELT); 1106 975 writel(lidx, chanbase + D40_CHAN_REG_SDELT); 976 + 977 + /* Clear LNK which will be used by d40_chan_has_events() */ 978 + writel(0, chanbase + D40_CHAN_REG_SSLNK); 979 + writel(0, chanbase + D40_CHAN_REG_SDLNK); 1107 980 } 1108 981 } 1109 982 ··· 1148 1013 if (!d40c->busy) 1149 1014 return 0; 1150 1015 1016 + pm_runtime_get_sync(d40c->base->dev); 1151 1017 spin_lock_irqsave(&d40c->lock, flags); 1152 1018 1153 1019 res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ); ··· 1161 1025 D40_DMA_RUN); 1162 1026 } 1163 1027 } 1164 - 1028 + pm_runtime_mark_last_busy(d40c->base->dev); 1029 + pm_runtime_put_autosuspend(d40c->base->dev); 1165 1030 spin_unlock_irqrestore(&d40c->lock, flags); 1166 1031 return res; 1167 1032 } ··· 1176 1039 return 0; 1177 1040 1178 1041 spin_lock_irqsave(&d40c->lock, flags); 1179 - 1042 + pm_runtime_get_sync(d40c->base->dev); 1180 1043 if (d40c->base->rev == 0) 1181 1044 if (chan_is_logical(d40c)) { 1182 1045 res = d40_channel_execute_command(d40c, ··· 1194 1057 } 1195 1058 1196 1059 no_suspend: 1060 + pm_runtime_mark_last_busy(d40c->base->dev); 1061 + pm_runtime_put_autosuspend(d40c->base->dev); 1197 1062 spin_unlock_irqrestore(&d40c->lock, flags); 1198 1063 return res; 1199 1064 } ··· 1268 1129 d40d = d40_first_queued(d40c); 1269 1130 1270 1131 if (d40d != NULL) { 1271 - d40c->busy = true; 1132 + if (!d40c->busy) 1133 + d40c->busy = true; 1134 + 1135 + pm_runtime_get_sync(d40c->base->dev); 1272 1136 1273 1137 /* Remove from queue */ 1274 1138 d40_desc_remove(d40d); ··· 1332 1190 1333 1191 if (d40_queue_start(d40c) == NULL) 1334 1192 d40c->busy = false; 1193 + pm_runtime_mark_last_busy(d40c->base->dev); 1194 + pm_runtime_put_autosuspend(d40c->base->dev); 1335 1195 } 1336 1196 1337 1197 d40c->pending_tx++; ··· 1549 1405 return res; 1550 1406 } 1551 1407 1552 - static bool d40_alloc_mask_set(struct d40_phy_res *phy, bool is_src, 1553 - int log_event_line, bool is_log) 1408 + static bool d40_alloc_mask_set(struct d40_phy_res *phy, 1409 + bool is_src, int log_event_line, bool is_log, 1410 + bool *first_user) 1554 1411 { 1555 1412 unsigned long flags; 1556 1413 spin_lock_irqsave(&phy->lock, flags); 1414 + 1415 + *first_user = ((phy->allocated_src | phy->allocated_dst) 1416 + == D40_ALLOC_FREE); 1417 + 1557 1418 if (!is_log) { 1558 1419 /* Physical interrupts are masked per physical full channel */ 1559 1420 if (phy->allocated_src == D40_ALLOC_FREE && ··· 1639 1490 return is_free; 1640 1491 } 1641 1492 1642 - static int d40_allocate_channel(struct d40_chan *d40c) 1493 + static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) 1643 1494 { 1644 1495 int dev_type; 1645 1496 int event_group; ··· 1675 1526 for (i = 0; i < d40c->base->num_phy_chans; i++) { 1676 1527 1677 1528 if (d40_alloc_mask_set(&phys[i], is_src, 1678 - 0, is_log)) 1529 + 0, is_log, 1530 + first_phy_user)) 1679 1531 goto found_phy; 1680 1532 } 1681 1533 } else ··· 1686 1536 if (d40_alloc_mask_set(&phys[i], 1687 1537 is_src, 1688 1538 0, 1689 - is_log)) 1539 + is_log, 1540 + first_phy_user)) 1690 1541 goto found_phy; 1691 1542 } 1692 1543 } ··· 1703 1552 /* Find logical channel */ 1704 1553 for (j = 0; j < d40c->base->num_phy_chans; j += 8) { 1705 1554 int phy_num = j + event_group * 2; 1555 + 1556 + if (d40c->dma_cfg.use_fixed_channel) { 1557 + i = d40c->dma_cfg.phy_channel; 1558 + 1559 + if ((i != phy_num) && (i != phy_num + 1)) { 1560 + dev_err(chan2dev(d40c), 1561 + "invalid fixed phy channel %d\n", i); 1562 + return -EINVAL; 1563 + } 1564 + 1565 + if (d40_alloc_mask_set(&phys[i], is_src, event_line, 1566 + is_log, first_phy_user)) 1567 + goto found_log; 1568 + 1569 + dev_err(chan2dev(d40c), 1570 + "could not allocate fixed phy channel %d\n", i); 1571 + return -EINVAL; 1572 + } 1573 + 1706 1574 /* 1707 1575 * Spread logical channels across all available physical rather 1708 1576 * than pack every logical channel at the first available phy ··· 1730 1560 if (is_src) { 1731 1561 for (i = phy_num; i < phy_num + 2; i++) { 1732 1562 if (d40_alloc_mask_set(&phys[i], is_src, 1733 - event_line, is_log)) 1563 + event_line, is_log, 1564 + first_phy_user)) 1734 1565 goto found_log; 1735 1566 } 1736 1567 } else { 1737 1568 for (i = phy_num + 1; i >= phy_num; i--) { 1738 1569 if (d40_alloc_mask_set(&phys[i], is_src, 1739 - event_line, is_log)) 1570 + event_line, is_log, 1571 + first_phy_user)) 1740 1572 goto found_log; 1741 1573 } 1742 1574 } ··· 1815 1643 return -EINVAL; 1816 1644 } 1817 1645 1646 + pm_runtime_get_sync(d40c->base->dev); 1818 1647 res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ); 1819 1648 if (res) { 1820 1649 chan_err(d40c, "suspend failed\n"); 1821 - return res; 1650 + goto out; 1822 1651 } 1823 1652 1824 1653 if (chan_is_logical(d40c)) { ··· 1837 1664 if (d40_chan_has_events(d40c)) { 1838 1665 res = d40_channel_execute_command(d40c, 1839 1666 D40_DMA_RUN); 1840 - if (res) { 1667 + if (res) 1841 1668 chan_err(d40c, 1842 1669 "Executing RUN command\n"); 1843 - return res; 1844 - } 1845 1670 } 1846 - return 0; 1671 + goto out; 1847 1672 } 1848 1673 } else { 1849 1674 (void) d40_alloc_mask_free(phy, is_src, 0); ··· 1851 1680 res = d40_channel_execute_command(d40c, D40_DMA_STOP); 1852 1681 if (res) { 1853 1682 chan_err(d40c, "Failed to stop channel\n"); 1854 - return res; 1683 + goto out; 1855 1684 } 1685 + 1686 + if (d40c->busy) { 1687 + pm_runtime_mark_last_busy(d40c->base->dev); 1688 + pm_runtime_put_autosuspend(d40c->base->dev); 1689 + } 1690 + 1691 + d40c->busy = false; 1856 1692 d40c->phy_chan = NULL; 1857 1693 d40c->configured = false; 1858 1694 d40c->base->lookup_phy_chans[phy->num] = NULL; 1695 + out: 1859 1696 1860 - return 0; 1697 + pm_runtime_mark_last_busy(d40c->base->dev); 1698 + pm_runtime_put_autosuspend(d40c->base->dev); 1699 + return res; 1861 1700 } 1862 1701 1863 1702 static bool d40_is_paused(struct d40_chan *d40c) ··· 2036 1855 } 2037 1856 2038 1857 static dma_addr_t 2039 - d40_get_dev_addr(struct d40_chan *chan, enum dma_data_direction direction) 1858 + d40_get_dev_addr(struct d40_chan *chan, enum dma_transfer_direction direction) 2040 1859 { 2041 1860 struct stedma40_platform_data *plat = chan->base->plat_data; 2042 1861 struct stedma40_chan_cfg *cfg = &chan->dma_cfg; ··· 2045 1864 if (chan->runtime_addr) 2046 1865 return chan->runtime_addr; 2047 1866 2048 - if (direction == DMA_FROM_DEVICE) 1867 + if (direction == DMA_DEV_TO_MEM) 2049 1868 addr = plat->dev_rx[cfg->src_dev_type]; 2050 - else if (direction == DMA_TO_DEVICE) 1869 + else if (direction == DMA_MEM_TO_DEV) 2051 1870 addr = plat->dev_tx[cfg->dst_dev_type]; 2052 1871 2053 1872 return addr; ··· 2056 1875 static struct dma_async_tx_descriptor * 2057 1876 d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src, 2058 1877 struct scatterlist *sg_dst, unsigned int sg_len, 2059 - enum dma_data_direction direction, unsigned long dma_flags) 1878 + enum dma_transfer_direction direction, unsigned long dma_flags) 2060 1879 { 2061 1880 struct d40_chan *chan = container_of(dchan, struct d40_chan, chan); 2062 1881 dma_addr_t src_dev_addr = 0; ··· 2083 1902 if (direction != DMA_NONE) { 2084 1903 dma_addr_t dev_addr = d40_get_dev_addr(chan, direction); 2085 1904 2086 - if (direction == DMA_FROM_DEVICE) 1905 + if (direction == DMA_DEV_TO_MEM) 2087 1906 src_dev_addr = dev_addr; 2088 - else if (direction == DMA_TO_DEVICE) 1907 + else if (direction == DMA_MEM_TO_DEV) 2089 1908 dst_dev_addr = dev_addr; 2090 1909 } 2091 1910 ··· 2192 2011 goto fail; 2193 2012 } 2194 2013 } 2195 - is_free_phy = (d40c->phy_chan == NULL); 2196 2014 2197 - err = d40_allocate_channel(d40c); 2015 + err = d40_allocate_channel(d40c, &is_free_phy); 2198 2016 if (err) { 2199 2017 chan_err(d40c, "Failed to allocate channel\n"); 2018 + d40c->configured = false; 2200 2019 goto fail; 2201 2020 } 2202 2021 2022 + pm_runtime_get_sync(d40c->base->dev); 2203 2023 /* Fill in basic CFG register values */ 2204 2024 d40_phy_cfg(&d40c->dma_cfg, &d40c->src_def_cfg, 2205 2025 &d40c->dst_def_cfg, chan_is_logical(d40c)); ··· 2220 2038 D40_LCPA_CHAN_SIZE + D40_LCPA_CHAN_DST_DELTA; 2221 2039 } 2222 2040 2041 + dev_dbg(chan2dev(d40c), "allocated %s channel (phy %d%s)\n", 2042 + chan_is_logical(d40c) ? "logical" : "physical", 2043 + d40c->phy_chan->num, 2044 + d40c->dma_cfg.use_fixed_channel ? ", fixed" : ""); 2045 + 2046 + 2223 2047 /* 2224 2048 * Only write channel configuration to the DMA if the physical 2225 2049 * resource is free. In case of multiple logical channels ··· 2234 2046 if (is_free_phy) 2235 2047 d40_config_write(d40c); 2236 2048 fail: 2049 + pm_runtime_mark_last_busy(d40c->base->dev); 2050 + pm_runtime_put_autosuspend(d40c->base->dev); 2237 2051 spin_unlock_irqrestore(&d40c->lock, flags); 2238 2052 return err; 2239 2053 } ··· 2298 2108 static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan, 2299 2109 struct scatterlist *sgl, 2300 2110 unsigned int sg_len, 2301 - enum dma_data_direction direction, 2111 + enum dma_transfer_direction direction, 2302 2112 unsigned long dma_flags) 2303 2113 { 2304 - if (direction != DMA_FROM_DEVICE && direction != DMA_TO_DEVICE) 2114 + if (direction != DMA_DEV_TO_MEM && direction != DMA_MEM_TO_DEV) 2305 2115 return NULL; 2306 2116 2307 2117 return d40_prep_sg(chan, sgl, sgl, sg_len, direction, dma_flags); ··· 2310 2120 static struct dma_async_tx_descriptor * 2311 2121 dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr, 2312 2122 size_t buf_len, size_t period_len, 2313 - enum dma_data_direction direction) 2123 + enum dma_transfer_direction direction) 2314 2124 { 2315 2125 unsigned int periods = buf_len / period_len; 2316 2126 struct dma_async_tx_descriptor *txd; ··· 2459 2269 dst_addr_width = config->dst_addr_width; 2460 2270 dst_maxburst = config->dst_maxburst; 2461 2271 2462 - if (config->direction == DMA_FROM_DEVICE) { 2272 + if (config->direction == DMA_DEV_TO_MEM) { 2463 2273 dma_addr_t dev_addr_rx = 2464 2274 d40c->base->plat_data->dev_rx[cfg->src_dev_type]; 2465 2275 ··· 2482 2292 if (dst_maxburst == 0) 2483 2293 dst_maxburst = src_maxburst; 2484 2294 2485 - } else if (config->direction == DMA_TO_DEVICE) { 2295 + } else if (config->direction == DMA_MEM_TO_DEV) { 2486 2296 dma_addr_t dev_addr_tx = 2487 2297 d40c->base->plat_data->dev_tx[cfg->dst_dev_type]; 2488 2298 ··· 2547 2357 "configured channel %s for %s, data width %d/%d, " 2548 2358 "maxburst %d/%d elements, LE, no flow control\n", 2549 2359 dma_chan_name(chan), 2550 - (config->direction == DMA_FROM_DEVICE) ? "RX" : "TX", 2360 + (config->direction == DMA_DEV_TO_MEM) ? "RX" : "TX", 2551 2361 src_addr_width, dst_addr_width, 2552 2362 src_maxburst, dst_maxburst); 2553 2363 ··· 2709 2519 return err; 2710 2520 } 2711 2521 2522 + /* Suspend resume functionality */ 2523 + #ifdef CONFIG_PM 2524 + static int dma40_pm_suspend(struct device *dev) 2525 + { 2526 + struct platform_device *pdev = to_platform_device(dev); 2527 + struct d40_base *base = platform_get_drvdata(pdev); 2528 + int ret = 0; 2529 + if (!pm_runtime_suspended(dev)) 2530 + return -EBUSY; 2531 + 2532 + if (base->lcpa_regulator) 2533 + ret = regulator_disable(base->lcpa_regulator); 2534 + return ret; 2535 + } 2536 + 2537 + static int dma40_runtime_suspend(struct device *dev) 2538 + { 2539 + struct platform_device *pdev = to_platform_device(dev); 2540 + struct d40_base *base = platform_get_drvdata(pdev); 2541 + 2542 + d40_save_restore_registers(base, true); 2543 + 2544 + /* Don't disable/enable clocks for v1 due to HW bugs */ 2545 + if (base->rev != 1) 2546 + writel_relaxed(base->gcc_pwr_off_mask, 2547 + base->virtbase + D40_DREG_GCC); 2548 + 2549 + return 0; 2550 + } 2551 + 2552 + static int dma40_runtime_resume(struct device *dev) 2553 + { 2554 + struct platform_device *pdev = to_platform_device(dev); 2555 + struct d40_base *base = platform_get_drvdata(pdev); 2556 + 2557 + if (base->initialized) 2558 + d40_save_restore_registers(base, false); 2559 + 2560 + writel_relaxed(D40_DREG_GCC_ENABLE_ALL, 2561 + base->virtbase + D40_DREG_GCC); 2562 + return 0; 2563 + } 2564 + 2565 + static int dma40_resume(struct device *dev) 2566 + { 2567 + struct platform_device *pdev = to_platform_device(dev); 2568 + struct d40_base *base = platform_get_drvdata(pdev); 2569 + int ret = 0; 2570 + 2571 + if (base->lcpa_regulator) 2572 + ret = regulator_enable(base->lcpa_regulator); 2573 + 2574 + return ret; 2575 + } 2576 + 2577 + static const struct dev_pm_ops dma40_pm_ops = { 2578 + .suspend = dma40_pm_suspend, 2579 + .runtime_suspend = dma40_runtime_suspend, 2580 + .runtime_resume = dma40_runtime_resume, 2581 + .resume = dma40_resume, 2582 + }; 2583 + #define DMA40_PM_OPS (&dma40_pm_ops) 2584 + #else 2585 + #define DMA40_PM_OPS NULL 2586 + #endif 2587 + 2712 2588 /* Initialization functions. */ 2713 2589 2714 2590 static int __init d40_phy_res_init(struct d40_base *base) ··· 2783 2527 int num_phy_chans_avail = 0; 2784 2528 u32 val[2]; 2785 2529 int odd_even_bit = -2; 2530 + int gcc = D40_DREG_GCC_ENA; 2786 2531 2787 2532 val[0] = readl(base->virtbase + D40_DREG_PRSME); 2788 2533 val[1] = readl(base->virtbase + D40_DREG_PRSMO); ··· 2795 2538 /* Mark security only channels as occupied */ 2796 2539 base->phy_res[i].allocated_src = D40_ALLOC_PHY; 2797 2540 base->phy_res[i].allocated_dst = D40_ALLOC_PHY; 2541 + base->phy_res[i].reserved = true; 2542 + gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(i), 2543 + D40_DREG_GCC_SRC); 2544 + gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(i), 2545 + D40_DREG_GCC_DST); 2546 + 2547 + 2798 2548 } else { 2799 2549 base->phy_res[i].allocated_src = D40_ALLOC_FREE; 2800 2550 base->phy_res[i].allocated_dst = D40_ALLOC_FREE; 2551 + base->phy_res[i].reserved = false; 2801 2552 num_phy_chans_avail++; 2802 2553 } 2803 2554 spin_lock_init(&base->phy_res[i].lock); ··· 2817 2552 2818 2553 base->phy_res[chan].allocated_src = D40_ALLOC_PHY; 2819 2554 base->phy_res[chan].allocated_dst = D40_ALLOC_PHY; 2555 + base->phy_res[chan].reserved = true; 2556 + gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(chan), 2557 + D40_DREG_GCC_SRC); 2558 + gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(chan), 2559 + D40_DREG_GCC_DST); 2820 2560 num_phy_chans_avail--; 2821 2561 } 2822 2562 ··· 2841 2571 2842 2572 val[0] = val[0] >> 2; 2843 2573 } 2574 + 2575 + /* 2576 + * To keep things simple, Enable all clocks initially. 2577 + * The clocks will get managed later post channel allocation. 2578 + * The clocks for the event lines on which reserved channels exists 2579 + * are not managed here. 2580 + */ 2581 + writel(D40_DREG_GCC_ENABLE_ALL, base->virtbase + D40_DREG_GCC); 2582 + base->gcc_pwr_off_mask = gcc; 2844 2583 2845 2584 return num_phy_chans_avail; 2846 2585 } ··· 2978 2699 goto failure; 2979 2700 } 2980 2701 2981 - base->lcla_pool.alloc_map = kzalloc(num_phy_chans * 2982 - sizeof(struct d40_desc *) * 2983 - D40_LCLA_LINK_PER_EVENT_GRP, 2702 + base->reg_val_backup_chan = kmalloc(base->num_phy_chans * 2703 + sizeof(d40_backup_regs_chan), 2984 2704 GFP_KERNEL); 2705 + if (!base->reg_val_backup_chan) 2706 + goto failure; 2707 + 2708 + base->lcla_pool.alloc_map = 2709 + kzalloc(num_phy_chans * sizeof(struct d40_desc *) 2710 + * D40_LCLA_LINK_PER_EVENT_GRP, GFP_KERNEL); 2985 2711 if (!base->lcla_pool.alloc_map) 2986 2712 goto failure; 2987 2713 ··· 3025 2741 static void __init d40_hw_init(struct d40_base *base) 3026 2742 { 3027 2743 3028 - static const struct d40_reg_val dma_init_reg[] = { 2744 + static struct d40_reg_val dma_init_reg[] = { 3029 2745 /* Clock every part of the DMA block from start */ 3030 - { .reg = D40_DREG_GCC, .val = 0x0000ff01}, 2746 + { .reg = D40_DREG_GCC, .val = D40_DREG_GCC_ENABLE_ALL}, 3031 2747 3032 2748 /* Interrupts on all logical channels */ 3033 2749 { .reg = D40_DREG_LCMIS0, .val = 0xFFFFFFFF}, ··· 3227 2943 d40_err(&pdev->dev, "Failed to ioremap LCPA region\n"); 3228 2944 goto failure; 3229 2945 } 2946 + /* If lcla has to be located in ESRAM we don't need to allocate */ 2947 + if (base->plat_data->use_esram_lcla) { 2948 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 2949 + "lcla_esram"); 2950 + if (!res) { 2951 + ret = -ENOENT; 2952 + d40_err(&pdev->dev, 2953 + "No \"lcla_esram\" memory resource\n"); 2954 + goto failure; 2955 + } 2956 + base->lcla_pool.base = ioremap(res->start, 2957 + resource_size(res)); 2958 + if (!base->lcla_pool.base) { 2959 + ret = -ENOMEM; 2960 + d40_err(&pdev->dev, "Failed to ioremap LCLA region\n"); 2961 + goto failure; 2962 + } 2963 + writel(res->start, base->virtbase + D40_DREG_LCLA); 3230 2964 3231 - ret = d40_lcla_allocate(base); 3232 - if (ret) { 3233 - d40_err(&pdev->dev, "Failed to allocate LCLA area\n"); 3234 - goto failure; 2965 + } else { 2966 + ret = d40_lcla_allocate(base); 2967 + if (ret) { 2968 + d40_err(&pdev->dev, "Failed to allocate LCLA area\n"); 2969 + goto failure; 2970 + } 3235 2971 } 3236 2972 3237 2973 spin_lock_init(&base->lcla_pool.lock); ··· 3264 2960 goto failure; 3265 2961 } 3266 2962 2963 + pm_runtime_irq_safe(base->dev); 2964 + pm_runtime_set_autosuspend_delay(base->dev, DMA40_AUTOSUSPEND_DELAY); 2965 + pm_runtime_use_autosuspend(base->dev); 2966 + pm_runtime_enable(base->dev); 2967 + pm_runtime_resume(base->dev); 2968 + 2969 + if (base->plat_data->use_esram_lcla) { 2970 + 2971 + base->lcpa_regulator = regulator_get(base->dev, "lcla_esram"); 2972 + if (IS_ERR(base->lcpa_regulator)) { 2973 + d40_err(&pdev->dev, "Failed to get lcpa_regulator\n"); 2974 + base->lcpa_regulator = NULL; 2975 + goto failure; 2976 + } 2977 + 2978 + ret = regulator_enable(base->lcpa_regulator); 2979 + if (ret) { 2980 + d40_err(&pdev->dev, 2981 + "Failed to enable lcpa_regulator\n"); 2982 + regulator_put(base->lcpa_regulator); 2983 + base->lcpa_regulator = NULL; 2984 + goto failure; 2985 + } 2986 + } 2987 + 2988 + base->initialized = true; 3267 2989 err = d40_dmaengine_init(base, num_reserved_chans); 3268 2990 if (err) 3269 2991 goto failure; ··· 3305 2975 kmem_cache_destroy(base->desc_slab); 3306 2976 if (base->virtbase) 3307 2977 iounmap(base->virtbase); 2978 + 2979 + if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { 2980 + iounmap(base->lcla_pool.base); 2981 + base->lcla_pool.base = NULL; 2982 + } 3308 2983 3309 2984 if (base->lcla_pool.dma_addr) 3310 2985 dma_unmap_single(base->dev, base->lcla_pool.dma_addr, ··· 3333 2998 clk_put(base->clk); 3334 2999 } 3335 3000 3001 + if (base->lcpa_regulator) { 3002 + regulator_disable(base->lcpa_regulator); 3003 + regulator_put(base->lcpa_regulator); 3004 + } 3005 + 3336 3006 kfree(base->lcla_pool.alloc_map); 3337 3007 kfree(base->lookup_log_chans); 3338 3008 kfree(base->lookup_phy_chans); ··· 3353 3013 .driver = { 3354 3014 .owner = THIS_MODULE, 3355 3015 .name = D40_NAME, 3016 + .pm = DMA40_PM_OPS, 3356 3017 }, 3357 3018 }; 3358 3019
+11
drivers/dma/ste_dma40_ll.h
··· 16 16 17 17 #define D40_TYPE_TO_GROUP(type) (type / 16) 18 18 #define D40_TYPE_TO_EVENT(type) (type % 16) 19 + #define D40_GROUP_SIZE 8 20 + #define D40_PHYS_TO_GROUP(phys) ((phys & (D40_GROUP_SIZE - 1)) / 2) 19 21 20 22 /* Most bits of the CFG register are the same in log as in phy mode */ 21 23 #define D40_SREG_CFG_MST_POS 15 ··· 125 123 126 124 /* DMA Register Offsets */ 127 125 #define D40_DREG_GCC 0x000 126 + #define D40_DREG_GCC_ENA 0x1 127 + /* This assumes that there are only 4 event groups */ 128 + #define D40_DREG_GCC_ENABLE_ALL 0xff01 129 + #define D40_DREG_GCC_EVTGRP_POS 8 130 + #define D40_DREG_GCC_SRC 0 131 + #define D40_DREG_GCC_DST 1 132 + #define D40_DREG_GCC_EVTGRP_ENA(x, y) \ 133 + (1 << (D40_DREG_GCC_EVTGRP_POS + 2 * x + y)) 134 + 128 135 #define D40_DREG_PRTYP 0x004 129 136 #define D40_DREG_PRSME 0x008 130 137 #define D40_DREG_PRSMO 0x00C
+10 -20
drivers/dma/timb_dma.c
··· 90 90 struct list_head queue; 91 91 struct list_head free_list; 92 92 unsigned int bytes_per_line; 93 - enum dma_data_direction direction; 93 + enum dma_transfer_direction direction; 94 94 unsigned int descs; /* Descriptors to allocate */ 95 95 unsigned int desc_elems; /* number of elems per descriptor */ 96 96 }; ··· 166 166 167 167 if (single) 168 168 dma_unmap_single(chan2dev(&td_chan->chan), addr, len, 169 - td_chan->direction); 169 + DMA_TO_DEVICE); 170 170 else 171 171 dma_unmap_page(chan2dev(&td_chan->chan), addr, len, 172 - td_chan->direction); 172 + DMA_TO_DEVICE); 173 173 } 174 174 175 175 static void __td_unmap_descs(struct timb_dma_desc *td_desc, bool single) ··· 235 235 "td_chan: %p, chan: %d, membase: %p\n", 236 236 td_chan, td_chan->chan.chan_id, td_chan->membase); 237 237 238 - if (td_chan->direction == DMA_FROM_DEVICE) { 238 + if (td_chan->direction == DMA_DEV_TO_MEM) { 239 239 240 240 /* descriptor address */ 241 241 iowrite32(0, td_chan->membase + TIMBDMA_OFFS_RX_DHAR); ··· 278 278 txd->cookie); 279 279 280 280 /* make sure to stop the transfer */ 281 - if (td_chan->direction == DMA_FROM_DEVICE) 281 + if (td_chan->direction == DMA_DEV_TO_MEM) 282 282 iowrite32(0, td_chan->membase + TIMBDMA_OFFS_RX_ER); 283 283 /* Currently no support for stopping DMA transfers 284 284 else ··· 558 558 559 559 static struct dma_async_tx_descriptor *td_prep_slave_sg(struct dma_chan *chan, 560 560 struct scatterlist *sgl, unsigned int sg_len, 561 - enum dma_data_direction direction, unsigned long flags) 561 + enum dma_transfer_direction direction, unsigned long flags) 562 562 { 563 563 struct timb_dma_chan *td_chan = 564 564 container_of(chan, struct timb_dma_chan, chan); ··· 606 606 } 607 607 608 608 dma_sync_single_for_device(chan2dmadev(chan), td_desc->txd.phys, 609 - td_desc->desc_list_len, DMA_TO_DEVICE); 609 + td_desc->desc_list_len, DMA_MEM_TO_DEV); 610 610 611 611 return &td_desc->txd; 612 612 } ··· 775 775 td_chan->descs = pchan->descriptors; 776 776 td_chan->desc_elems = pchan->descriptor_elements; 777 777 td_chan->bytes_per_line = pchan->bytes_per_line; 778 - td_chan->direction = pchan->rx ? DMA_FROM_DEVICE : 779 - DMA_TO_DEVICE; 778 + td_chan->direction = pchan->rx ? DMA_DEV_TO_MEM : 779 + DMA_MEM_TO_DEV; 780 780 781 781 td_chan->membase = td->membase + 782 782 (i / 2) * TIMBDMA_INSTANCE_OFFSET + ··· 841 841 .remove = __exit_p(td_remove), 842 842 }; 843 843 844 - static int __init td_init(void) 845 - { 846 - return platform_driver_register(&td_driver); 847 - } 848 - module_init(td_init); 849 - 850 - static void __exit td_exit(void) 851 - { 852 - platform_driver_unregister(&td_driver); 853 - } 854 - module_exit(td_exit); 844 + module_platform_driver(td_driver); 855 845 856 846 MODULE_LICENSE("GPL v2"); 857 847 MODULE_DESCRIPTION("Timberdale DMA controller driver");
+6 -6
drivers/dma/txx9dmac.c
··· 845 845 846 846 static struct dma_async_tx_descriptor * 847 847 txx9dmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 848 - unsigned int sg_len, enum dma_data_direction direction, 848 + unsigned int sg_len, enum dma_transfer_direction direction, 849 849 unsigned long flags) 850 850 { 851 851 struct txx9dmac_chan *dc = to_txx9dmac_chan(chan); ··· 860 860 861 861 BUG_ON(!ds || !ds->reg_width); 862 862 if (ds->tx_reg) 863 - BUG_ON(direction != DMA_TO_DEVICE); 863 + BUG_ON(direction != DMA_MEM_TO_DEV); 864 864 else 865 - BUG_ON(direction != DMA_FROM_DEVICE); 865 + BUG_ON(direction != DMA_DEV_TO_MEM); 866 866 if (unlikely(!sg_len)) 867 867 return NULL; 868 868 ··· 882 882 mem = sg_dma_address(sg); 883 883 884 884 if (__is_dmac64(ddev)) { 885 - if (direction == DMA_TO_DEVICE) { 885 + if (direction == DMA_MEM_TO_DEV) { 886 886 desc->hwdesc.SAR = mem; 887 887 desc->hwdesc.DAR = ds->tx_reg; 888 888 } else { ··· 891 891 } 892 892 desc->hwdesc.CNTR = sg_dma_len(sg); 893 893 } else { 894 - if (direction == DMA_TO_DEVICE) { 894 + if (direction == DMA_MEM_TO_DEV) { 895 895 desc->hwdesc32.SAR = mem; 896 896 desc->hwdesc32.DAR = ds->tx_reg; 897 897 } else { ··· 900 900 } 901 901 desc->hwdesc32.CNTR = sg_dma_len(sg); 902 902 } 903 - if (direction == DMA_TO_DEVICE) { 903 + if (direction == DMA_MEM_TO_DEV) { 904 904 sai = ds->reg_width; 905 905 dai = 0; 906 906 } else {
+1 -1
drivers/media/video/mx3_camera.c
··· 287 287 sg_dma_len(sg) = new_size; 288 288 289 289 txd = ichan->dma_chan.device->device_prep_slave_sg( 290 - &ichan->dma_chan, sg, 1, DMA_FROM_DEVICE, 290 + &ichan->dma_chan, sg, 1, DMA_DEV_TO_MEM, 291 291 DMA_PREP_INTERRUPT); 292 292 if (!txd) 293 293 goto error;
+1 -1
drivers/media/video/timblogiw.c
··· 565 565 spin_unlock_irq(&fh->queue_lock); 566 566 567 567 desc = fh->chan->device->device_prep_slave_sg(fh->chan, 568 - buf->sg, sg_elems, DMA_FROM_DEVICE, 568 + buf->sg, sg_elems, DMA_DEV_TO_MEM, 569 569 DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP); 570 570 if (!desc) { 571 571 spin_lock_irq(&fh->queue_lock);
+1 -1
drivers/misc/carma/carma-fpga-program.c
··· 513 513 * transaction, and then put it under external control 514 514 */ 515 515 memset(&config, 0, sizeof(config)); 516 - config.direction = DMA_TO_DEVICE; 516 + config.direction = DMA_MEM_TO_DEV; 517 517 config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 518 518 config.dst_maxburst = fpga_fifo_size(priv->regs) / 2 / 4; 519 519 ret = chan->device->device_control(chan, DMA_SLAVE_CONFIG,
+7 -3
drivers/mmc/host/atmel-mci.c
··· 823 823 struct scatterlist *sg; 824 824 unsigned int i; 825 825 enum dma_data_direction direction; 826 + enum dma_transfer_direction slave_dirn; 826 827 unsigned int sglen; 827 828 u32 iflags; 828 829 ··· 861 860 if (host->caps.has_dma) 862 861 atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(3) | ATMCI_DMAEN); 863 862 864 - if (data->flags & MMC_DATA_READ) 863 + if (data->flags & MMC_DATA_READ) { 865 864 direction = DMA_FROM_DEVICE; 866 - else 865 + slave_dirn = DMA_DEV_TO_MEM; 866 + } else { 867 867 direction = DMA_TO_DEVICE; 868 + slave_dirn = DMA_MEM_TO_DEV; 869 + } 868 870 869 871 sglen = dma_map_sg(chan->device->dev, data->sg, 870 872 data->sg_len, direction); 871 873 872 874 desc = chan->device->device_prep_slave_sg(chan, 873 - data->sg, sglen, direction, 875 + data->sg, sglen, slave_dirn, 874 876 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 875 877 if (!desc) 876 878 goto unmap_exit;
+7 -4
drivers/mmc/host/mmci.c
··· 374 374 struct dma_chan *chan; 375 375 struct dma_device *device; 376 376 struct dma_async_tx_descriptor *desc; 377 + enum dma_data_direction buffer_dirn; 377 378 int nr_sg; 378 379 379 380 /* Check if next job is already prepared */ ··· 388 387 } 389 388 390 389 if (data->flags & MMC_DATA_READ) { 391 - conf.direction = DMA_FROM_DEVICE; 390 + conf.direction = DMA_DEV_TO_MEM; 391 + buffer_dirn = DMA_FROM_DEVICE; 392 392 chan = host->dma_rx_channel; 393 393 } else { 394 - conf.direction = DMA_TO_DEVICE; 394 + conf.direction = DMA_MEM_TO_DEV; 395 + buffer_dirn = DMA_TO_DEVICE; 395 396 chan = host->dma_tx_channel; 396 397 } 397 398 ··· 406 403 return -EINVAL; 407 404 408 405 device = chan->device; 409 - nr_sg = dma_map_sg(device->dev, data->sg, data->sg_len, conf.direction); 406 + nr_sg = dma_map_sg(device->dev, data->sg, data->sg_len, buffer_dirn); 410 407 if (nr_sg == 0) 411 408 return -EINVAL; 412 409 ··· 429 426 unmap_exit: 430 427 if (!next) 431 428 dmaengine_terminate_all(chan); 432 - dma_unmap_sg(device->dev, data->sg, data->sg_len, conf.direction); 429 + dma_unmap_sg(device->dev, data->sg, data->sg_len, buffer_dirn); 433 430 return -ENOMEM; 434 431 } 435 432
+7 -3
drivers/mmc/host/mxcmmc.c
··· 218 218 unsigned int blksz = data->blksz; 219 219 unsigned int datasize = nob * blksz; 220 220 struct scatterlist *sg; 221 + enum dma_transfer_direction slave_dirn; 221 222 int i, nents; 222 223 223 224 if (data->flags & MMC_DATA_STREAM) ··· 241 240 } 242 241 } 243 242 244 - if (data->flags & MMC_DATA_READ) 243 + if (data->flags & MMC_DATA_READ) { 245 244 host->dma_dir = DMA_FROM_DEVICE; 246 - else 245 + slave_dirn = DMA_DEV_TO_MEM; 246 + } else { 247 247 host->dma_dir = DMA_TO_DEVICE; 248 + slave_dirn = DMA_MEM_TO_DEV; 249 + } 248 250 249 251 nents = dma_map_sg(host->dma->device->dev, data->sg, 250 252 data->sg_len, host->dma_dir); ··· 255 251 return -EINVAL; 256 252 257 253 host->desc = host->dma->device->device_prep_slave_sg(host->dma, 258 - data->sg, data->sg_len, host->dma_dir, 254 + data->sg, data->sg_len, slave_dirn, 259 255 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 260 256 261 257 if (!host->desc) {
+9 -1
drivers/mmc/host/mxs-mmc.c
··· 154 154 struct dma_chan *dmach; 155 155 struct mxs_dma_data dma_data; 156 156 unsigned int dma_dir; 157 + enum dma_transfer_direction slave_dirn; 157 158 u32 ssp_pio_words[SSP_PIO_NUM]; 158 159 159 160 unsigned int version; ··· 325 324 } 326 325 327 326 desc = host->dmach->device->device_prep_slave_sg(host->dmach, 328 - sgl, sg_len, host->dma_dir, append); 327 + sgl, sg_len, host->slave_dirn, append); 329 328 if (desc) { 330 329 desc->callback = mxs_mmc_dma_irq_callback; 331 330 desc->callback_param = host; ··· 357 356 host->ssp_pio_words[1] = cmd0; 358 357 host->ssp_pio_words[2] = cmd1; 359 358 host->dma_dir = DMA_NONE; 359 + host->slave_dirn = DMA_TRANS_NONE; 360 360 desc = mxs_mmc_prep_dma(host, 0); 361 361 if (!desc) 362 362 goto out; ··· 397 395 host->ssp_pio_words[1] = cmd0; 398 396 host->ssp_pio_words[2] = cmd1; 399 397 host->dma_dir = DMA_NONE; 398 + host->slave_dirn = DMA_TRANS_NONE; 400 399 desc = mxs_mmc_prep_dma(host, 0); 401 400 if (!desc) 402 401 goto out; ··· 436 433 int i; 437 434 438 435 unsigned short dma_data_dir, timeout; 436 + enum dma_transfer_direction slave_dirn; 439 437 unsigned int data_size = 0, log2_blksz; 440 438 unsigned int blocks = data->blocks; 441 439 ··· 452 448 453 449 if (data->flags & MMC_DATA_WRITE) { 454 450 dma_data_dir = DMA_TO_DEVICE; 451 + slave_dirn = DMA_MEM_TO_DEV; 455 452 read = 0; 456 453 } else { 457 454 dma_data_dir = DMA_FROM_DEVICE; 455 + slave_dirn = DMA_DEV_TO_MEM; 458 456 read = BM_SSP_CTRL0_READ; 459 457 } 460 458 ··· 516 510 host->ssp_pio_words[1] = cmd0; 517 511 host->ssp_pio_words[2] = cmd1; 518 512 host->dma_dir = DMA_NONE; 513 + host->slave_dirn = DMA_TRANS_NONE; 519 514 desc = mxs_mmc_prep_dma(host, 0); 520 515 if (!desc) 521 516 goto out; ··· 525 518 WARN_ON(host->data != NULL); 526 519 host->data = data; 527 520 host->dma_dir = dma_data_dir; 521 + host->slave_dirn = slave_dirn; 528 522 desc = mxs_mmc_prep_dma(host, 1); 529 523 if (!desc) 530 524 goto out;
+2 -2
drivers/mmc/host/sh_mmcif.c
··· 286 286 if (ret > 0) { 287 287 host->dma_active = true; 288 288 desc = chan->device->device_prep_slave_sg(chan, sg, ret, 289 - DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 289 + DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 290 290 } 291 291 292 292 if (desc) { ··· 335 335 if (ret > 0) { 336 336 host->dma_active = true; 337 337 desc = chan->device->device_prep_slave_sg(chan, sg, ret, 338 - DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 338 + DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 339 339 } 340 340 341 341 if (desc) {
+2 -2
drivers/mmc/host/tmio_mmc_dma.c
··· 77 77 ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_FROM_DEVICE); 78 78 if (ret > 0) 79 79 desc = chan->device->device_prep_slave_sg(chan, sg, ret, 80 - DMA_FROM_DEVICE, DMA_CTRL_ACK); 80 + DMA_DEV_TO_MEM, DMA_CTRL_ACK); 81 81 82 82 if (desc) { 83 83 cookie = dmaengine_submit(desc); ··· 158 158 ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE); 159 159 if (ret > 0) 160 160 desc = chan->device->device_prep_slave_sg(chan, sg, ret, 161 - DMA_TO_DEVICE, DMA_CTRL_ACK); 161 + DMA_MEM_TO_DEV, DMA_CTRL_ACK); 162 162 163 163 if (desc) { 164 164 cookie = dmaengine_submit(desc);
+12 -10
drivers/mtd/nand/gpmi-nand/gpmi-lib.c
··· 827 827 pio[1] = pio[2] = 0; 828 828 desc = channel->device->device_prep_slave_sg(channel, 829 829 (struct scatterlist *)pio, 830 - ARRAY_SIZE(pio), DMA_NONE, 0); 830 + ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); 831 831 if (!desc) { 832 832 pr_err("step 1 error\n"); 833 833 return -1; ··· 839 839 sg_init_one(sgl, this->cmd_buffer, this->command_length); 840 840 dma_map_sg(this->dev, sgl, 1, DMA_TO_DEVICE); 841 841 desc = channel->device->device_prep_slave_sg(channel, 842 - sgl, 1, DMA_TO_DEVICE, 1); 842 + sgl, 1, DMA_MEM_TO_DEV, 1); 843 843 if (!desc) { 844 844 pr_err("step 2 error\n"); 845 845 return -1; ··· 872 872 pio[1] = 0; 873 873 desc = channel->device->device_prep_slave_sg(channel, 874 874 (struct scatterlist *)pio, 875 - ARRAY_SIZE(pio), DMA_NONE, 0); 875 + ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); 876 876 if (!desc) { 877 877 pr_err("step 1 error\n"); 878 878 return -1; ··· 881 881 /* [2] send DMA request */ 882 882 prepare_data_dma(this, DMA_TO_DEVICE); 883 883 desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl, 884 - 1, DMA_TO_DEVICE, 1); 884 + 1, DMA_MEM_TO_DEV, 1); 885 885 if (!desc) { 886 886 pr_err("step 2 error\n"); 887 887 return -1; ··· 908 908 pio[1] = 0; 909 909 desc = channel->device->device_prep_slave_sg(channel, 910 910 (struct scatterlist *)pio, 911 - ARRAY_SIZE(pio), DMA_NONE, 0); 911 + ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); 912 912 if (!desc) { 913 913 pr_err("step 1 error\n"); 914 914 return -1; ··· 917 917 /* [2] : send DMA request */ 918 918 prepare_data_dma(this, DMA_FROM_DEVICE); 919 919 desc = channel->device->device_prep_slave_sg(channel, &this->data_sgl, 920 - 1, DMA_FROM_DEVICE, 1); 920 + 1, DMA_DEV_TO_MEM, 1); 921 921 if (!desc) { 922 922 pr_err("step 2 error\n"); 923 923 return -1; ··· 964 964 965 965 desc = channel->device->device_prep_slave_sg(channel, 966 966 (struct scatterlist *)pio, 967 - ARRAY_SIZE(pio), DMA_NONE, 0); 967 + ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); 968 968 if (!desc) { 969 969 pr_err("step 2 error\n"); 970 970 return -1; ··· 998 998 | BF_GPMI_CTRL0_XFER_COUNT(0); 999 999 pio[1] = 0; 1000 1000 desc = channel->device->device_prep_slave_sg(channel, 1001 - (struct scatterlist *)pio, 2, DMA_NONE, 0); 1001 + (struct scatterlist *)pio, 2, 1002 + DMA_TRANS_NONE, 0); 1002 1003 if (!desc) { 1003 1004 pr_err("step 1 error\n"); 1004 1005 return -1; ··· 1028 1027 pio[5] = auxiliary; 1029 1028 desc = channel->device->device_prep_slave_sg(channel, 1030 1029 (struct scatterlist *)pio, 1031 - ARRAY_SIZE(pio), DMA_NONE, 1); 1030 + ARRAY_SIZE(pio), DMA_TRANS_NONE, 1); 1032 1031 if (!desc) { 1033 1032 pr_err("step 2 error\n"); 1034 1033 return -1; ··· 1046 1045 | BF_GPMI_CTRL0_XFER_COUNT(geo->page_size); 1047 1046 pio[1] = 0; 1048 1047 desc = channel->device->device_prep_slave_sg(channel, 1049 - (struct scatterlist *)pio, 2, DMA_NONE, 1); 1048 + (struct scatterlist *)pio, 2, 1049 + DMA_TRANS_NONE, 1); 1050 1050 if (!desc) { 1051 1051 pr_err("step 3 error\n"); 1052 1052 return -1;
+2 -2
drivers/net/ethernet/micrel/ks8842.c
··· 459 459 sg_dma_len(&ctl->sg) += 4 - sg_dma_len(&ctl->sg) % 4; 460 460 461 461 ctl->adesc = ctl->chan->device->device_prep_slave_sg(ctl->chan, 462 - &ctl->sg, 1, DMA_TO_DEVICE, 462 + &ctl->sg, 1, DMA_MEM_TO_DEV, 463 463 DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP); 464 464 if (!ctl->adesc) 465 465 return NETDEV_TX_BUSY; ··· 571 571 sg_dma_len(sg) = DMA_BUFFER_SIZE; 572 572 573 573 ctl->adesc = ctl->chan->device->device_prep_slave_sg(ctl->chan, 574 - sg, 1, DMA_FROM_DEVICE, 574 + sg, 1, DMA_DEV_TO_MEM, 575 575 DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP); 576 576 577 577 if (!ctl->adesc)
+4 -4
drivers/spi/spi-dw-mid.c
··· 131 131 rxchan = dws->rxchan; 132 132 133 133 /* 2. Prepare the TX dma transfer */ 134 - txconf.direction = DMA_TO_DEVICE; 134 + txconf.direction = DMA_MEM_TO_DEV; 135 135 txconf.dst_addr = dws->dma_addr; 136 136 txconf.dst_maxburst = LNW_DMA_MSIZE_16; 137 137 txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ··· 147 147 txdesc = txchan->device->device_prep_slave_sg(txchan, 148 148 &dws->tx_sgl, 149 149 1, 150 - DMA_TO_DEVICE, 150 + DMA_MEM_TO_DEV, 151 151 DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); 152 152 txdesc->callback = dw_spi_dma_done; 153 153 txdesc->callback_param = dws; 154 154 155 155 /* 3. Prepare the RX dma transfer */ 156 - rxconf.direction = DMA_FROM_DEVICE; 156 + rxconf.direction = DMA_DEV_TO_MEM; 157 157 rxconf.src_addr = dws->dma_addr; 158 158 rxconf.src_maxburst = LNW_DMA_MSIZE_16; 159 159 rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ··· 169 169 rxdesc = rxchan->device->device_prep_slave_sg(rxchan, 170 170 &dws->rx_sgl, 171 171 1, 172 - DMA_FROM_DEVICE, 172 + DMA_DEV_TO_MEM, 173 173 DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_DEST_UNMAP); 174 174 rxdesc->callback = dw_spi_dma_done; 175 175 rxdesc->callback_param = dws;
+6 -3
drivers/spi/spi-ep93xx.c
··· 551 551 struct dma_async_tx_descriptor *txd; 552 552 enum dma_slave_buswidth buswidth; 553 553 struct dma_slave_config conf; 554 + enum dma_transfer_direction slave_dirn; 554 555 struct scatterlist *sg; 555 556 struct sg_table *sgt; 556 557 struct dma_chan *chan; ··· 574 573 575 574 conf.src_addr = espi->sspdr_phys; 576 575 conf.src_addr_width = buswidth; 576 + slave_dirn = DMA_DEV_TO_MEM; 577 577 } else { 578 578 chan = espi->dma_tx; 579 579 buf = t->tx_buf; ··· 582 580 583 581 conf.dst_addr = espi->sspdr_phys; 584 582 conf.dst_addr_width = buswidth; 583 + slave_dirn = DMA_MEM_TO_DEV; 585 584 } 586 585 587 586 ret = dmaengine_slave_config(chan, &conf); ··· 634 631 return ERR_PTR(-ENOMEM); 635 632 636 633 txd = chan->device->device_prep_slave_sg(chan, sgt->sgl, nents, 637 - dir, DMA_CTRL_ACK); 634 + slave_dirn, DMA_CTRL_ACK); 638 635 if (!txd) { 639 636 dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir); 640 637 return ERR_PTR(-ENOMEM); ··· 982 979 dma_cap_set(DMA_SLAVE, mask); 983 980 984 981 espi->dma_rx_data.port = EP93XX_DMA_SSP; 985 - espi->dma_rx_data.direction = DMA_FROM_DEVICE; 982 + espi->dma_rx_data.direction = DMA_DEV_TO_MEM; 986 983 espi->dma_rx_data.name = "ep93xx-spi-rx"; 987 984 988 985 espi->dma_rx = dma_request_channel(mask, ep93xx_spi_dma_filter, ··· 993 990 } 994 991 995 992 espi->dma_tx_data.port = EP93XX_DMA_SSP; 996 - espi->dma_tx_data.direction = DMA_TO_DEVICE; 993 + espi->dma_tx_data.direction = DMA_MEM_TO_DEV; 997 994 espi->dma_tx_data.name = "ep93xx-spi-tx"; 998 995 999 996 espi->dma_tx = dma_request_channel(mask, ep93xx_spi_dma_filter,
+4 -4
drivers/spi/spi-pl022.c
··· 900 900 { 901 901 struct dma_slave_config rx_conf = { 902 902 .src_addr = SSP_DR(pl022->phybase), 903 - .direction = DMA_FROM_DEVICE, 903 + .direction = DMA_DEV_TO_MEM, 904 904 }; 905 905 struct dma_slave_config tx_conf = { 906 906 .dst_addr = SSP_DR(pl022->phybase), 907 - .direction = DMA_TO_DEVICE, 907 + .direction = DMA_MEM_TO_DEV, 908 908 }; 909 909 unsigned int pages; 910 910 int ret; ··· 1041 1041 rxdesc = rxchan->device->device_prep_slave_sg(rxchan, 1042 1042 pl022->sgt_rx.sgl, 1043 1043 rx_sglen, 1044 - DMA_FROM_DEVICE, 1044 + DMA_DEV_TO_MEM, 1045 1045 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 1046 1046 if (!rxdesc) 1047 1047 goto err_rxdesc; ··· 1049 1049 txdesc = txchan->device->device_prep_slave_sg(txchan, 1050 1050 pl022->sgt_tx.sgl, 1051 1051 tx_sglen, 1052 - DMA_TO_DEVICE, 1052 + DMA_MEM_TO_DEV, 1053 1053 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 1054 1054 if (!txdesc) 1055 1055 goto err_txdesc;
+2 -2
drivers/spi/spi-topcliff-pch.c
··· 1079 1079 } 1080 1080 sg = dma->sg_rx_p; 1081 1081 desc_rx = dma->chan_rx->device->device_prep_slave_sg(dma->chan_rx, sg, 1082 - num, DMA_FROM_DEVICE, 1082 + num, DMA_DEV_TO_MEM, 1083 1083 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 1084 1084 if (!desc_rx) { 1085 1085 dev_err(&data->master->dev, "%s:device_prep_slave_sg Failed\n", ··· 1124 1124 } 1125 1125 sg = dma->sg_tx_p; 1126 1126 desc_tx = dma->chan_tx->device->device_prep_slave_sg(dma->chan_tx, 1127 - sg, num, DMA_TO_DEVICE, 1127 + sg, num, DMA_MEM_TO_DEV, 1128 1128 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 1129 1129 if (!desc_tx) { 1130 1130 dev_err(&data->master->dev, "%s:device_prep_slave_sg Failed\n",
+4 -4
drivers/tty/serial/amba-pl011.c
··· 268 268 struct dma_slave_config tx_conf = { 269 269 .dst_addr = uap->port.mapbase + UART01x_DR, 270 270 .dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, 271 - .direction = DMA_TO_DEVICE, 271 + .direction = DMA_MEM_TO_DEV, 272 272 .dst_maxburst = uap->fifosize >> 1, 273 273 }; 274 274 struct dma_chan *chan; ··· 301 301 struct dma_slave_config rx_conf = { 302 302 .src_addr = uap->port.mapbase + UART01x_DR, 303 303 .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, 304 - .direction = DMA_FROM_DEVICE, 304 + .direction = DMA_DEV_TO_MEM, 305 305 .src_maxburst = uap->fifosize >> 1, 306 306 }; 307 307 ··· 480 480 return -EBUSY; 481 481 } 482 482 483 - desc = dma_dev->device_prep_slave_sg(chan, &dmatx->sg, 1, DMA_TO_DEVICE, 483 + desc = dma_dev->device_prep_slave_sg(chan, &dmatx->sg, 1, DMA_MEM_TO_DEV, 484 484 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 485 485 if (!desc) { 486 486 dma_unmap_sg(dma_dev->dev, &dmatx->sg, 1, DMA_TO_DEVICE); ··· 676 676 &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; 677 677 dma_dev = rxchan->device; 678 678 desc = rxchan->device->device_prep_slave_sg(rxchan, &sgbuf->sg, 1, 679 - DMA_FROM_DEVICE, 679 + DMA_DEV_TO_MEM, 680 680 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 681 681 /* 682 682 * If the DMA engine is busy and cannot prepare a
+2 -2
drivers/tty/serial/pch_uart.c
··· 764 764 sg_dma_address(sg) = priv->rx_buf_dma; 765 765 766 766 desc = priv->chan_rx->device->device_prep_slave_sg(priv->chan_rx, 767 - sg, 1, DMA_FROM_DEVICE, 767 + sg, 1, DMA_DEV_TO_MEM, 768 768 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 769 769 770 770 if (!desc) ··· 923 923 } 924 924 925 925 desc = priv->chan_tx->device->device_prep_slave_sg(priv->chan_tx, 926 - priv->sg_tx_p, nent, DMA_TO_DEVICE, 926 + priv->sg_tx_p, nent, DMA_MEM_TO_DEV, 927 927 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 928 928 if (!desc) { 929 929 dev_err(priv->port.dev, "%s:device_prep_slave_sg Failed\n",
+2 -2
drivers/tty/serial/sh-sci.c
··· 1339 1339 struct dma_async_tx_descriptor *desc; 1340 1340 1341 1341 desc = chan->device->device_prep_slave_sg(chan, 1342 - sg, 1, DMA_FROM_DEVICE, DMA_PREP_INTERRUPT); 1342 + sg, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT); 1343 1343 1344 1344 if (desc) { 1345 1345 s->desc_rx[i] = desc; ··· 1454 1454 BUG_ON(!sg_dma_len(sg)); 1455 1455 1456 1456 desc = chan->device->device_prep_slave_sg(chan, 1457 - sg, s->sg_len_tx, DMA_TO_DEVICE, 1457 + sg, s->sg_len_tx, DMA_MEM_TO_DEV, 1458 1458 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 1459 1459 if (!desc) { 1460 1460 /* switch to PIO */
+2 -2
drivers/usb/musb/ux500_dma.c
··· 84 84 struct musb_hw_ep *hw_ep = ux500_channel->hw_ep; 85 85 struct dma_chan *dma_chan = ux500_channel->dma_chan; 86 86 struct dma_async_tx_descriptor *dma_desc; 87 - enum dma_data_direction direction; 87 + enum dma_transfer_direction direction; 88 88 struct scatterlist sg; 89 89 struct dma_slave_config slave_conf; 90 90 enum dma_slave_buswidth addr_width; ··· 104 104 sg_dma_address(&sg) = dma_addr; 105 105 sg_dma_len(&sg) = len; 106 106 107 - direction = ux500_channel->is_tx ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 107 + direction = ux500_channel->is_tx ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; 108 108 addr_width = (len & 0x3) ? DMA_SLAVE_BUSWIDTH_1_BYTE : 109 109 DMA_SLAVE_BUSWIDTH_4_BYTES; 110 110
+2 -2
drivers/usb/renesas_usbhs/fifo.c
··· 772 772 struct dma_async_tx_descriptor *desc; 773 773 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt); 774 774 struct device *dev = usbhs_priv_to_dev(priv); 775 - enum dma_data_direction dir; 775 + enum dma_transfer_direction dir; 776 776 dma_cookie_t cookie; 777 777 778 - dir = usbhs_pipe_is_dir_in(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 778 + dir = usbhs_pipe_is_dir_in(pipe) ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV; 779 779 780 780 sg_init_table(&sg, 1); 781 781 sg_set_page(&sg, virt_to_page(pkt->dma),
+24 -41
drivers/video/mx3fb.c
··· 245 245 246 246 uint32_t h_start_width; 247 247 uint32_t v_start_width; 248 + enum disp_data_mapping disp_data_fmt; 248 249 }; 249 250 250 251 struct dma_chan_request { ··· 288 287 __raw_writel(value, mx3fb->reg_base + reg); 289 288 } 290 289 291 - static const uint32_t di_mappings[] = { 292 - 0x1600AAAA, 0x00E05555, 0x00070000, 3, /* RGB888 */ 293 - 0x0005000F, 0x000B000F, 0x0011000F, 1, /* RGB666 */ 294 - 0x0011000F, 0x000B000F, 0x0005000F, 1, /* BGR666 */ 295 - 0x0004003F, 0x000A000F, 0x000F003F, 1 /* RGB565 */ 290 + struct di_mapping { 291 + uint32_t b0, b1, b2; 292 + }; 293 + 294 + static const struct di_mapping di_mappings[] = { 295 + [IPU_DISP_DATA_MAPPING_RGB666] = { 0x0005000f, 0x000b000f, 0x0011000f }, 296 + [IPU_DISP_DATA_MAPPING_RGB565] = { 0x0004003f, 0x000a000f, 0x000f003f }, 297 + [IPU_DISP_DATA_MAPPING_RGB888] = { 0x00070000, 0x000f0000, 0x00170000 }, 296 298 }; 297 299 298 300 static void sdc_fb_init(struct mx3fb_info *fbi) ··· 338 334 /* This enables the channel */ 339 335 if (mx3_fbi->cookie < 0) { 340 336 mx3_fbi->txd = dma_chan->device->device_prep_slave_sg(dma_chan, 341 - &mx3_fbi->sg[0], 1, DMA_TO_DEVICE, DMA_PREP_INTERRUPT); 337 + &mx3_fbi->sg[0], 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT); 342 338 if (!mx3_fbi->txd) { 343 339 dev_err(mx3fb->dev, "Cannot allocate descriptor on %d\n", 344 340 dma_chan->chan_id); ··· 429 425 * @pixel_clk: desired pixel clock frequency in Hz. 430 426 * @width: width of panel in pixels. 431 427 * @height: height of panel in pixels. 432 - * @pixel_fmt: pixel format of buffer as FOURCC ASCII code. 433 428 * @h_start_width: number of pixel clocks between the HSYNC signal pulse 434 429 * and the start of valid data. 435 430 * @h_sync_width: width of the HSYNC signal in units of pixel clocks. ··· 445 442 static int sdc_init_panel(struct mx3fb_data *mx3fb, enum ipu_panel panel, 446 443 uint32_t pixel_clk, 447 444 uint16_t width, uint16_t height, 448 - enum pixel_fmt pixel_fmt, 449 445 uint16_t h_start_width, uint16_t h_sync_width, 450 446 uint16_t h_end_width, uint16_t v_start_width, 451 447 uint16_t v_sync_width, uint16_t v_end_width, ··· 455 453 uint32_t old_conf; 456 454 uint32_t div; 457 455 struct clk *ipu_clk; 456 + const struct di_mapping *map; 458 457 459 458 dev_dbg(mx3fb->dev, "panel size = %d x %d", width, height); 460 459 ··· 543 540 sig.Vsync_pol << DI_D3_VSYNC_POL_SHIFT; 544 541 mx3fb_write_reg(mx3fb, old_conf, DI_DISP_SIG_POL); 545 542 546 - switch (pixel_fmt) { 547 - case IPU_PIX_FMT_RGB24: 548 - mx3fb_write_reg(mx3fb, di_mappings[0], DI_DISP3_B0_MAP); 549 - mx3fb_write_reg(mx3fb, di_mappings[1], DI_DISP3_B1_MAP); 550 - mx3fb_write_reg(mx3fb, di_mappings[2], DI_DISP3_B2_MAP); 551 - mx3fb_write_reg(mx3fb, mx3fb_read_reg(mx3fb, DI_DISP_ACC_CC) | 552 - ((di_mappings[3] - 1) << 12), DI_DISP_ACC_CC); 553 - break; 554 - case IPU_PIX_FMT_RGB666: 555 - mx3fb_write_reg(mx3fb, di_mappings[4], DI_DISP3_B0_MAP); 556 - mx3fb_write_reg(mx3fb, di_mappings[5], DI_DISP3_B1_MAP); 557 - mx3fb_write_reg(mx3fb, di_mappings[6], DI_DISP3_B2_MAP); 558 - mx3fb_write_reg(mx3fb, mx3fb_read_reg(mx3fb, DI_DISP_ACC_CC) | 559 - ((di_mappings[7] - 1) << 12), DI_DISP_ACC_CC); 560 - break; 561 - case IPU_PIX_FMT_BGR666: 562 - mx3fb_write_reg(mx3fb, di_mappings[8], DI_DISP3_B0_MAP); 563 - mx3fb_write_reg(mx3fb, di_mappings[9], DI_DISP3_B1_MAP); 564 - mx3fb_write_reg(mx3fb, di_mappings[10], DI_DISP3_B2_MAP); 565 - mx3fb_write_reg(mx3fb, mx3fb_read_reg(mx3fb, DI_DISP_ACC_CC) | 566 - ((di_mappings[11] - 1) << 12), DI_DISP_ACC_CC); 567 - break; 568 - default: 569 - mx3fb_write_reg(mx3fb, di_mappings[12], DI_DISP3_B0_MAP); 570 - mx3fb_write_reg(mx3fb, di_mappings[13], DI_DISP3_B1_MAP); 571 - mx3fb_write_reg(mx3fb, di_mappings[14], DI_DISP3_B2_MAP); 572 - mx3fb_write_reg(mx3fb, mx3fb_read_reg(mx3fb, DI_DISP_ACC_CC) | 573 - ((di_mappings[15] - 1) << 12), DI_DISP_ACC_CC); 574 - break; 575 - } 543 + map = &di_mappings[mx3fb->disp_data_fmt]; 544 + mx3fb_write_reg(mx3fb, map->b0, DI_DISP3_B0_MAP); 545 + mx3fb_write_reg(mx3fb, map->b1, DI_DISP3_B1_MAP); 546 + mx3fb_write_reg(mx3fb, map->b2, DI_DISP3_B2_MAP); 576 547 577 548 spin_unlock_irqrestore(&mx3fb->lock, lock_flags); 578 549 ··· 757 780 if (sdc_init_panel(mx3fb, mode, 758 781 (PICOS2KHZ(fbi->var.pixclock)) * 1000UL, 759 782 fbi->var.xres, fbi->var.yres, 760 - (fbi->var.sync & FB_SYNC_SWAP_RGB) ? 761 - IPU_PIX_FMT_BGR666 : IPU_PIX_FMT_RGB666, 762 783 fbi->var.left_margin, 763 784 fbi->var.hsync_len, 764 785 fbi->var.right_margin + ··· 1092 1117 async_tx_ack(mx3_fbi->txd); 1093 1118 1094 1119 txd = dma_chan->device->device_prep_slave_sg(dma_chan, sg + 1095 - mx3_fbi->cur_ipu_buf, 1, DMA_TO_DEVICE, DMA_PREP_INTERRUPT); 1120 + mx3_fbi->cur_ipu_buf, 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT); 1096 1121 if (!txd) { 1097 1122 dev_err(fbi->device, 1098 1123 "Error preparing a DMA transaction descriptor.\n"); ··· 1324 1349 const struct fb_videomode *mode; 1325 1350 int ret, num_modes; 1326 1351 1352 + if (mx3fb_pdata->disp_data_fmt >= ARRAY_SIZE(di_mappings)) { 1353 + dev_err(dev, "Illegal display data format %d\n", 1354 + mx3fb_pdata->disp_data_fmt); 1355 + return -EINVAL; 1356 + } 1357 + 1327 1358 ichan->client = mx3fb; 1328 1359 irq = ichan->eof_irq; 1329 1360 ··· 1382 1401 mx3fbi->ipu_ch = ichan->dma_chan.chan_id; 1383 1402 mx3fbi->mx3fb = mx3fb; 1384 1403 mx3fbi->blank = FB_BLANK_NORMAL; 1404 + 1405 + mx3fb->disp_data_fmt = mx3fb_pdata->disp_data_fmt; 1385 1406 1386 1407 init_completion(&mx3fbi->flip_cmpl); 1387 1408 disable_irq(ichan->eof_irq);
+2 -2
include/linux/amba/pl08x.h
··· 134 134 struct dma_async_tx_descriptor tx; 135 135 struct list_head node; 136 136 struct list_head dsg_list; 137 - enum dma_data_direction direction; 137 + enum dma_transfer_direction direction; 138 138 dma_addr_t llis_bus; 139 139 struct pl08x_lli *llis_va; 140 140 /* Default cctl value for LLIs */ ··· 197 197 dma_addr_t dst_addr; 198 198 u32 src_cctl; 199 199 u32 dst_cctl; 200 - enum dma_data_direction runtime_direction; 200 + enum dma_transfer_direction runtime_direction; 201 201 dma_cookie_t lc; 202 202 struct list_head pend_list; 203 203 struct pl08x_txd *at;
+92 -7
include/linux/dmaengine.h
··· 23 23 24 24 #include <linux/device.h> 25 25 #include <linux/uio.h> 26 - #include <linux/dma-direction.h> 27 26 #include <linux/scatterlist.h> 28 27 #include <linux/bitmap.h> 29 28 #include <asm/page.h> ··· 71 72 DMA_ASYNC_TX, 72 73 DMA_SLAVE, 73 74 DMA_CYCLIC, 75 + DMA_INTERLEAVE, 76 + /* last transaction type for creation of the capabilities mask */ 77 + DMA_TX_TYPE_END, 74 78 }; 75 79 76 - /* last transaction type for creation of the capabilities mask */ 77 - #define DMA_TX_TYPE_END (DMA_CYCLIC + 1) 80 + /** 81 + * enum dma_transfer_direction - dma transfer mode and direction indicator 82 + * @DMA_MEM_TO_MEM: Async/Memcpy mode 83 + * @DMA_MEM_TO_DEV: Slave mode & From Memory to Device 84 + * @DMA_DEV_TO_MEM: Slave mode & From Device to Memory 85 + * @DMA_DEV_TO_DEV: Slave mode & From Device to Device 86 + */ 87 + enum dma_transfer_direction { 88 + DMA_MEM_TO_MEM, 89 + DMA_MEM_TO_DEV, 90 + DMA_DEV_TO_MEM, 91 + DMA_DEV_TO_DEV, 92 + DMA_TRANS_NONE, 93 + }; 78 94 95 + /** 96 + * Interleaved Transfer Request 97 + * ---------------------------- 98 + * A chunk is collection of contiguous bytes to be transfered. 99 + * The gap(in bytes) between two chunks is called inter-chunk-gap(ICG). 100 + * ICGs may or maynot change between chunks. 101 + * A FRAME is the smallest series of contiguous {chunk,icg} pairs, 102 + * that when repeated an integral number of times, specifies the transfer. 103 + * A transfer template is specification of a Frame, the number of times 104 + * it is to be repeated and other per-transfer attributes. 105 + * 106 + * Practically, a client driver would have ready a template for each 107 + * type of transfer it is going to need during its lifetime and 108 + * set only 'src_start' and 'dst_start' before submitting the requests. 109 + * 110 + * 111 + * | Frame-1 | Frame-2 | ~ | Frame-'numf' | 112 + * |====....==.===...=...|====....==.===...=...| ~ |====....==.===...=...| 113 + * 114 + * == Chunk size 115 + * ... ICG 116 + */ 117 + 118 + /** 119 + * struct data_chunk - Element of scatter-gather list that makes a frame. 120 + * @size: Number of bytes to read from source. 121 + * size_dst := fn(op, size_src), so doesn't mean much for destination. 122 + * @icg: Number of bytes to jump after last src/dst address of this 123 + * chunk and before first src/dst address for next chunk. 124 + * Ignored for dst(assumed 0), if dst_inc is true and dst_sgl is false. 125 + * Ignored for src(assumed 0), if src_inc is true and src_sgl is false. 126 + */ 127 + struct data_chunk { 128 + size_t size; 129 + size_t icg; 130 + }; 131 + 132 + /** 133 + * struct dma_interleaved_template - Template to convey DMAC the transfer pattern 134 + * and attributes. 135 + * @src_start: Bus address of source for the first chunk. 136 + * @dst_start: Bus address of destination for the first chunk. 137 + * @dir: Specifies the type of Source and Destination. 138 + * @src_inc: If the source address increments after reading from it. 139 + * @dst_inc: If the destination address increments after writing to it. 140 + * @src_sgl: If the 'icg' of sgl[] applies to Source (scattered read). 141 + * Otherwise, source is read contiguously (icg ignored). 142 + * Ignored if src_inc is false. 143 + * @dst_sgl: If the 'icg' of sgl[] applies to Destination (scattered write). 144 + * Otherwise, destination is filled contiguously (icg ignored). 145 + * Ignored if dst_inc is false. 146 + * @numf: Number of frames in this template. 147 + * @frame_size: Number of chunks in a frame i.e, size of sgl[]. 148 + * @sgl: Array of {chunk,icg} pairs that make up a frame. 149 + */ 150 + struct dma_interleaved_template { 151 + dma_addr_t src_start; 152 + dma_addr_t dst_start; 153 + enum dma_transfer_direction dir; 154 + bool src_inc; 155 + bool dst_inc; 156 + bool src_sgl; 157 + bool dst_sgl; 158 + size_t numf; 159 + size_t frame_size; 160 + struct data_chunk sgl[0]; 161 + }; 79 162 80 163 /** 81 164 * enum dma_ctrl_flags - DMA flags to augment operation preparation, ··· 350 269 * struct, if applicable. 351 270 */ 352 271 struct dma_slave_config { 353 - enum dma_data_direction direction; 272 + enum dma_transfer_direction direction; 354 273 dma_addr_t src_addr; 355 274 dma_addr_t dst_addr; 356 275 enum dma_slave_buswidth src_addr_width; ··· 514 433 * @device_prep_dma_cyclic: prepare a cyclic dma operation suitable for audio. 515 434 * The function takes a buffer of size buf_len. The callback function will 516 435 * be called after period_len bytes have been transferred. 436 + * @device_prep_interleaved_dma: Transfer expression in a generic way. 517 437 * @device_control: manipulate all pending operations on a channel, returns 518 438 * zero or error code 519 439 * @device_tx_status: poll for transaction completion, the optional ··· 574 492 575 493 struct dma_async_tx_descriptor *(*device_prep_slave_sg)( 576 494 struct dma_chan *chan, struct scatterlist *sgl, 577 - unsigned int sg_len, enum dma_data_direction direction, 495 + unsigned int sg_len, enum dma_transfer_direction direction, 578 496 unsigned long flags); 579 497 struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)( 580 498 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, 581 - size_t period_len, enum dma_data_direction direction); 499 + size_t period_len, enum dma_transfer_direction direction); 500 + struct dma_async_tx_descriptor *(*device_prep_interleaved_dma)( 501 + struct dma_chan *chan, struct dma_interleaved_template *xt, 502 + unsigned long flags); 582 503 int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd, 583 504 unsigned long arg); 584 505 ··· 607 522 608 523 static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single( 609 524 struct dma_chan *chan, void *buf, size_t len, 610 - enum dma_data_direction dir, unsigned long flags) 525 + enum dma_transfer_direction dir, unsigned long flags) 611 526 { 612 527 struct scatterlist sg; 613 528 sg_init_one(&sg, buf, len);
+1 -1
include/linux/dw_dmac.h
··· 127 127 128 128 struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan, 129 129 dma_addr_t buf_addr, size_t buf_len, size_t period_len, 130 - enum dma_data_direction direction); 130 + enum dma_transfer_direction direction); 131 131 void dw_dma_cyclic_free(struct dma_chan *chan); 132 132 int dw_dma_cyclic_start(struct dma_chan *chan); 133 133 void dw_dma_cyclic_stop(struct dma_chan *chan);
+68
include/linux/mtd/gpmi-nand.h
··· 1 + /* 2 + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along 15 + * with this program; if not, write to the Free Software Foundation, Inc., 16 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 + */ 18 + 19 + #ifndef __MACH_MXS_GPMI_NAND_H__ 20 + #define __MACH_MXS_GPMI_NAND_H__ 21 + 22 + /* The size of the resources is fixed. */ 23 + #define GPMI_NAND_RES_SIZE 6 24 + 25 + /* Resource names for the GPMI NAND driver. */ 26 + #define GPMI_NAND_GPMI_REGS_ADDR_RES_NAME "GPMI NAND GPMI Registers" 27 + #define GPMI_NAND_GPMI_INTERRUPT_RES_NAME "GPMI NAND GPMI Interrupt" 28 + #define GPMI_NAND_BCH_REGS_ADDR_RES_NAME "GPMI NAND BCH Registers" 29 + #define GPMI_NAND_BCH_INTERRUPT_RES_NAME "GPMI NAND BCH Interrupt" 30 + #define GPMI_NAND_DMA_CHANNELS_RES_NAME "GPMI NAND DMA Channels" 31 + #define GPMI_NAND_DMA_INTERRUPT_RES_NAME "GPMI NAND DMA Interrupt" 32 + 33 + /** 34 + * struct gpmi_nand_platform_data - GPMI NAND driver platform data. 35 + * 36 + * This structure communicates platform-specific information to the GPMI NAND 37 + * driver that can't be expressed as resources. 38 + * 39 + * @platform_init: A pointer to a function the driver will call to 40 + * initialize the platform (e.g., set up the pin mux). 41 + * @min_prop_delay_in_ns: Minimum propagation delay of GPMI signals to and 42 + * from the NAND Flash device, in nanoseconds. 43 + * @max_prop_delay_in_ns: Maximum propagation delay of GPMI signals to and 44 + * from the NAND Flash device, in nanoseconds. 45 + * @max_chip_count: The maximum number of chips for which the driver 46 + * should configure the hardware. This value most 47 + * likely reflects the number of pins that are 48 + * connected to a NAND Flash device. If this is 49 + * greater than the SoC hardware can support, the 50 + * driver will print a message and fail to initialize. 51 + * @partitions: An optional pointer to an array of partition 52 + * descriptions. 53 + * @partition_count: The number of elements in the partitions array. 54 + */ 55 + struct gpmi_nand_platform_data { 56 + /* SoC hardware information. */ 57 + int (*platform_init)(void); 58 + 59 + /* NAND Flash information. */ 60 + unsigned int min_prop_delay_in_ns; 61 + unsigned int max_prop_delay_in_ns; 62 + unsigned int max_chip_count; 63 + 64 + /* Medium information. */ 65 + struct mtd_partition *partitions; 66 + unsigned partition_count; 67 + }; 68 + #endif
+3 -1
include/linux/sh_dma.h
··· 30 30 struct sh_dmae_regs hw; 31 31 struct list_head node; 32 32 struct dma_async_tx_descriptor async_tx; 33 - enum dma_data_direction direction; 33 + enum dma_transfer_direction direction; 34 34 dma_cookie_t cookie; 35 35 size_t partial; 36 36 int chunks; ··· 48 48 unsigned int offset; 49 49 unsigned int dmars; 50 50 unsigned int dmars_bit; 51 + unsigned int chclr_offset; 51 52 }; 52 53 53 54 struct sh_dmae_pdata { ··· 69 68 unsigned int dmaor_is_32bit:1; 70 69 unsigned int needs_tend_set:1; 71 70 unsigned int no_dmars:1; 71 + unsigned int chclr_present:1; 72 72 }; 73 73 74 74 /* DMA register */
+6
include/linux/sirfsoc_dma.h
··· 1 + #ifndef _SIRFSOC_DMA_H_ 2 + #define _SIRFSOC_DMA_H_ 3 + 4 + bool sirfsoc_dma_filter_id(struct dma_chan *chan, void *chan_id); 5 + 6 + #endif
+1 -1
sound/atmel/abdac.c
··· 133 133 period_len = frames_to_bytes(runtime, runtime->period_size); 134 134 135 135 cdesc = dw_dma_cyclic_prep(chan, runtime->dma_addr, buffer_len, 136 - period_len, DMA_TO_DEVICE); 136 + period_len, DMA_MEM_TO_DEV); 137 137 if (IS_ERR(cdesc)) { 138 138 dev_dbg(&dac->pdev->dev, "could not prepare cyclic DMA\n"); 139 139 return PTR_ERR(cdesc);
+5 -5
sound/atmel/ac97c.c
··· 102 102 103 103 static int atmel_ac97c_prepare_dma(struct atmel_ac97c *chip, 104 104 struct snd_pcm_substream *substream, 105 - enum dma_data_direction direction) 105 + enum dma_transfer_direction direction) 106 106 { 107 107 struct dma_chan *chan; 108 108 struct dw_cyclic_desc *cdesc; ··· 118 118 return -EINVAL; 119 119 } 120 120 121 - if (direction == DMA_TO_DEVICE) 121 + if (direction == DMA_MEM_TO_DEV) 122 122 chan = chip->dma.tx_chan; 123 123 else 124 124 chan = chip->dma.rx_chan; ··· 133 133 return PTR_ERR(cdesc); 134 134 } 135 135 136 - if (direction == DMA_TO_DEVICE) { 136 + if (direction == DMA_MEM_TO_DEV) { 137 137 cdesc->period_callback = atmel_ac97c_dma_playback_period_done; 138 138 set_bit(DMA_TX_READY, &chip->flags); 139 139 } else { ··· 393 393 if (cpu_is_at32ap7000()) { 394 394 if (!test_bit(DMA_TX_READY, &chip->flags)) 395 395 retval = atmel_ac97c_prepare_dma(chip, substream, 396 - DMA_TO_DEVICE); 396 + DMA_MEM_TO_DEV); 397 397 } else { 398 398 /* Initialize and start the PDC */ 399 399 writel(runtime->dma_addr, chip->regs + ATMEL_PDC_TPR); ··· 484 484 if (cpu_is_at32ap7000()) { 485 485 if (!test_bit(DMA_RX_READY, &chip->flags)) 486 486 retval = atmel_ac97c_prepare_dma(chip, substream, 487 - DMA_FROM_DEVICE); 487 + DMA_DEV_TO_MEM); 488 488 } else { 489 489 /* Initialize and start the PDC */ 490 490 writel(runtime->dma_addr, chip->regs + ATMEL_PDC_RPR);
+2 -2
sound/soc/ep93xx/ep93xx-pcm.c
··· 113 113 rtd->dma_data.name = dma_params->name; 114 114 115 115 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 116 - rtd->dma_data.direction = DMA_TO_DEVICE; 116 + rtd->dma_data.direction = DMA_MEM_TO_DEV; 117 117 else 118 - rtd->dma_data.direction = DMA_FROM_DEVICE; 118 + rtd->dma_data.direction = DMA_DEV_TO_MEM; 119 119 120 120 rtd->dma_chan = dma_request_channel(mask, ep93xx_pcm_dma_filter, 121 121 &rtd->dma_data);
+3 -3
sound/soc/imx/imx-pcm-dma-mx2.c
··· 107 107 } 108 108 109 109 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 110 - slave_config.direction = DMA_TO_DEVICE; 110 + slave_config.direction = DMA_MEM_TO_DEV; 111 111 slave_config.dst_addr = dma_params->dma_addr; 112 112 slave_config.dst_addr_width = buswidth; 113 113 slave_config.dst_maxburst = dma_params->burstsize; 114 114 } else { 115 - slave_config.direction = DMA_FROM_DEVICE; 115 + slave_config.direction = DMA_DEV_TO_MEM; 116 116 slave_config.src_addr = dma_params->dma_addr; 117 117 slave_config.src_addr_width = buswidth; 118 118 slave_config.src_maxburst = dma_params->burstsize; ··· 159 159 iprtd->period_bytes * iprtd->periods, 160 160 iprtd->period_bytes, 161 161 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 162 - DMA_TO_DEVICE : DMA_FROM_DEVICE); 162 + DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); 163 163 if (!iprtd->desc) { 164 164 dev_err(&chan->dev->device, "cannot prepare slave dma\n"); 165 165 return -EINVAL;
+1 -1
sound/soc/mxs/mxs-pcm.c
··· 136 136 iprtd->period_bytes * iprtd->periods, 137 137 iprtd->period_bytes, 138 138 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 139 - DMA_TO_DEVICE : DMA_FROM_DEVICE); 139 + DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); 140 140 if (!iprtd->desc) { 141 141 dev_err(&chan->dev->device, "cannot prepare slave dma\n"); 142 142 return -EINVAL;
+2 -2
sound/soc/samsung/dma.c
··· 86 86 dma_info.cap = (samsung_dma_has_circular() ? DMA_CYCLIC : DMA_SLAVE); 87 87 dma_info.direction = 88 88 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK 89 - ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 89 + ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); 90 90 dma_info.fp = audio_buffdone; 91 91 dma_info.fp_param = substream; 92 92 dma_info.period = prtd->dma_period; ··· 171 171 dma_info.client = prtd->params->client; 172 172 dma_info.direction = 173 173 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK 174 - ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 174 + ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); 175 175 dma_info.width = prtd->params->dma_size; 176 176 dma_info.fifo = prtd->params->dma_addr; 177 177 prtd->params->ch = prtd->params->ops->request(
+2 -2
sound/soc/sh/siu_pcm.c
··· 131 131 sg_dma_address(&sg) = buff; 132 132 133 133 desc = siu_stream->chan->device->device_prep_slave_sg(siu_stream->chan, 134 - &sg, 1, DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 134 + &sg, 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 135 135 if (!desc) { 136 136 dev_err(dev, "Failed to allocate a dma descriptor\n"); 137 137 return -ENOMEM; ··· 181 181 sg_dma_address(&sg) = buff; 182 182 183 183 desc = siu_stream->chan->device->device_prep_slave_sg(siu_stream->chan, 184 - &sg, 1, DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 184 + &sg, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 185 185 if (!desc) { 186 186 dev_err(dev, "Failed to allocate dma descriptor\n"); 187 187 return -ENOMEM;
+1 -1
sound/soc/txx9/txx9aclc.c
··· 134 134 sg_dma_address(&sg) = buf_dma_addr; 135 135 desc = chan->device->device_prep_slave_sg(chan, &sg, 1, 136 136 dmadata->substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 137 - DMA_TO_DEVICE : DMA_FROM_DEVICE, 137 + DMA_MEM_TO_DEV : DMA_DEV_TO_MEM, 138 138 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 139 139 if (!desc) { 140 140 dev_err(&chan->dev->device, "cannot prepare slave dma\n");