diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 19:43:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 19:43:47 -0500 |
commit | 6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83 (patch) | |
tree | 9c83c87a8670ef678d95f8d6f76a07f24a09a49f /drivers/misc/carma | |
parent | e6b5be2be4e30037eb551e0ed09dd97bd00d85d3 (diff) | |
parent | 91905b6f4afe51e23a3f58df93e4cdc5e49cf40c (diff) |
Merge tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH:
"Here's the big char/misc driver update for 3.19-rc1
Lots of little things all over the place in different drivers, and a
new subsystem, "coresight" has been added. Full details are in the
shortlog"
* tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (73 commits)
parport: parport_pc, do not remove parent devices early
spmi: Remove shutdown/suspend/resume kernel-doc
carma-fpga-program: drop videobuf dependency
carma-fpga: drop videobuf dependency
carma-fpga-program.c: fix compile errors
i8k: Fix temperature bug handling in i8k_get_temp()
cxl: Name interrupts in /proc/interrupt
CXL: Return error to PSL if IRQ demultiplexing fails & print clearer warning
coresight-replicator: remove .owner field for driver
coresight: fixed comments in coresight.h
coresight: fix typo in comment in coresight-priv.h
coresight: bindings for coresight drivers
coresight: Adding ABI documentation
w1: support auto-load of w1_bq27000 module.
w1: avoid potential u16 overflow
cn: verify msg->len before making callback
mei: export fw status registers through sysfs
mei: read and print all six FW status registers
mei: txe: add cherrytrail device id
mei: kill cached host and me csr values
...
Diffstat (limited to 'drivers/misc/carma')
-rw-r--r-- | drivers/misc/carma/Kconfig | 6 | ||||
-rw-r--r-- | drivers/misc/carma/carma-fpga-program.c | 104 | ||||
-rw-r--r-- | drivers/misc/carma/carma-fpga.c | 98 |
3 files changed, 166 insertions, 42 deletions
diff --git a/drivers/misc/carma/Kconfig b/drivers/misc/carma/Kconfig index c90370ed712b..295882bfb14e 100644 --- a/drivers/misc/carma/Kconfig +++ b/drivers/misc/carma/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config CARMA_FPGA | 1 | config CARMA_FPGA |
2 | tristate "CARMA DATA-FPGA Access Driver" | 2 | tristate "CARMA DATA-FPGA Access Driver" |
3 | depends on FSL_SOC && PPC_83xx && MEDIA_SUPPORT && HAS_DMA && FSL_DMA | 3 | depends on FSL_SOC && PPC_83xx && HAS_DMA && FSL_DMA |
4 | select VIDEOBUF_DMA_SG | ||
5 | default n | 4 | default n |
6 | help | 5 | help |
7 | Say Y here to include support for communicating with the data | 6 | Say Y here to include support for communicating with the data |
@@ -9,8 +8,7 @@ config CARMA_FPGA | |||
9 | 8 | ||
10 | config CARMA_FPGA_PROGRAM | 9 | config CARMA_FPGA_PROGRAM |
11 | tristate "CARMA DATA-FPGA Programmer" | 10 | tristate "CARMA DATA-FPGA Programmer" |
12 | depends on FSL_SOC && PPC_83xx && MEDIA_SUPPORT && HAS_DMA && FSL_DMA | 11 | depends on FSL_SOC && PPC_83xx && HAS_DMA && FSL_DMA |
13 | select VIDEOBUF_DMA_SG | ||
14 | default n | 12 | default n |
15 | help | 13 | help |
16 | Say Y here to include support for programming the data processing | 14 | Say Y here to include support for programming the data processing |
diff --git a/drivers/misc/carma/carma-fpga-program.c b/drivers/misc/carma/carma-fpga-program.c index 6fa52f71f51c..06166ac000e0 100644 --- a/drivers/misc/carma/carma-fpga-program.c +++ b/drivers/misc/carma/carma-fpga-program.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/fsldma.h> | 19 | #include <linux/fsldma.h> |
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/highmem.h> | 21 | #include <linux/highmem.h> |
22 | #include <linux/vmalloc.h> | ||
22 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
@@ -30,8 +31,6 @@ | |||
30 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
31 | #include <linux/io.h> | 32 | #include <linux/io.h> |
32 | 33 | ||
33 | #include <media/videobuf-dma-sg.h> | ||
34 | |||
35 | /* MPC8349EMDS specific get_immrbase() */ | 34 | /* MPC8349EMDS specific get_immrbase() */ |
36 | #include <sysdev/fsl_soc.h> | 35 | #include <sysdev/fsl_soc.h> |
37 | 36 | ||
@@ -67,14 +66,79 @@ struct fpga_dev { | |||
67 | /* FPGA Bitfile */ | 66 | /* FPGA Bitfile */ |
68 | struct mutex lock; | 67 | struct mutex lock; |
69 | 68 | ||
70 | struct videobuf_dmabuf vb; | 69 | void *vaddr; |
71 | bool vb_allocated; | 70 | struct scatterlist *sglist; |
71 | int sglen; | ||
72 | int nr_pages; | ||
73 | bool buf_allocated; | ||
72 | 74 | ||
73 | /* max size and written bytes */ | 75 | /* max size and written bytes */ |
74 | size_t fw_size; | 76 | size_t fw_size; |
75 | size_t bytes; | 77 | size_t bytes; |
76 | }; | 78 | }; |
77 | 79 | ||
80 | static int fpga_dma_init(struct fpga_dev *priv, int nr_pages) | ||
81 | { | ||
82 | struct page *pg; | ||
83 | int i; | ||
84 | |||
85 | priv->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); | ||
86 | if (NULL == priv->vaddr) { | ||
87 | pr_debug("vmalloc_32(%d pages) failed\n", nr_pages); | ||
88 | return -ENOMEM; | ||
89 | } | ||
90 | |||
91 | pr_debug("vmalloc is at addr 0x%08lx, size=%d\n", | ||
92 | (unsigned long)priv->vaddr, | ||
93 | nr_pages << PAGE_SHIFT); | ||
94 | |||
95 | memset(priv->vaddr, 0, nr_pages << PAGE_SHIFT); | ||
96 | priv->nr_pages = nr_pages; | ||
97 | |||
98 | priv->sglist = vzalloc(priv->nr_pages * sizeof(*priv->sglist)); | ||
99 | if (NULL == priv->sglist) | ||
100 | goto vzalloc_err; | ||
101 | |||
102 | sg_init_table(priv->sglist, priv->nr_pages); | ||
103 | for (i = 0; i < priv->nr_pages; i++) { | ||
104 | pg = vmalloc_to_page(priv->vaddr + i * PAGE_SIZE); | ||
105 | if (NULL == pg) | ||
106 | goto vmalloc_to_page_err; | ||
107 | sg_set_page(&priv->sglist[i], pg, PAGE_SIZE, 0); | ||
108 | } | ||
109 | return 0; | ||
110 | |||
111 | vmalloc_to_page_err: | ||
112 | vfree(priv->sglist); | ||
113 | priv->sglist = NULL; | ||
114 | vzalloc_err: | ||
115 | vfree(priv->vaddr); | ||
116 | priv->vaddr = NULL; | ||
117 | return -ENOMEM; | ||
118 | } | ||
119 | |||
120 | static int fpga_dma_map(struct fpga_dev *priv) | ||
121 | { | ||
122 | priv->sglen = dma_map_sg(priv->dev, priv->sglist, | ||
123 | priv->nr_pages, DMA_TO_DEVICE); | ||
124 | |||
125 | if (0 == priv->sglen) { | ||
126 | pr_warn("%s: dma_map_sg failed\n", __func__); | ||
127 | return -ENOMEM; | ||
128 | } | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static int fpga_dma_unmap(struct fpga_dev *priv) | ||
133 | { | ||
134 | if (!priv->sglen) | ||
135 | return 0; | ||
136 | |||
137 | dma_unmap_sg(priv->dev, priv->sglist, priv->sglen, DMA_TO_DEVICE); | ||
138 | priv->sglen = 0; | ||
139 | return 0; | ||
140 | } | ||
141 | |||
78 | /* | 142 | /* |
79 | * FPGA Bitfile Helpers | 143 | * FPGA Bitfile Helpers |
80 | */ | 144 | */ |
@@ -87,8 +151,9 @@ struct fpga_dev { | |||
87 | */ | 151 | */ |
88 | static void fpga_drop_firmware_data(struct fpga_dev *priv) | 152 | static void fpga_drop_firmware_data(struct fpga_dev *priv) |
89 | { | 153 | { |
90 | videobuf_dma_free(&priv->vb); | 154 | vfree(priv->sglist); |
91 | priv->vb_allocated = false; | 155 | vfree(priv->vaddr); |
156 | priv->buf_allocated = false; | ||
92 | priv->bytes = 0; | 157 | priv->bytes = 0; |
93 | } | 158 | } |
94 | 159 | ||
@@ -427,7 +492,7 @@ static noinline int fpga_program_cpu(struct fpga_dev *priv) | |||
427 | dev_dbg(priv->dev, "enabled the controller\n"); | 492 | dev_dbg(priv->dev, "enabled the controller\n"); |
428 | 493 | ||
429 | /* Write each chunk of the FPGA bitfile to FPGA programmer */ | 494 | /* Write each chunk of the FPGA bitfile to FPGA programmer */ |
430 | ret = fpga_program_block(priv, priv->vb.vaddr, priv->bytes); | 495 | ret = fpga_program_block(priv, priv->vaddr, priv->bytes); |
431 | if (ret) | 496 | if (ret) |
432 | goto out_disable_controller; | 497 | goto out_disable_controller; |
433 | 498 | ||
@@ -463,7 +528,6 @@ out_disable_controller: | |||
463 | */ | 528 | */ |
464 | static noinline int fpga_program_dma(struct fpga_dev *priv) | 529 | static noinline int fpga_program_dma(struct fpga_dev *priv) |
465 | { | 530 | { |
466 | struct videobuf_dmabuf *vb = &priv->vb; | ||
467 | struct dma_chan *chan = priv->chan; | 531 | struct dma_chan *chan = priv->chan; |
468 | struct dma_async_tx_descriptor *tx; | 532 | struct dma_async_tx_descriptor *tx; |
469 | size_t num_pages, len, avail = 0; | 533 | size_t num_pages, len, avail = 0; |
@@ -505,7 +569,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
505 | } | 569 | } |
506 | 570 | ||
507 | /* Map the buffer for DMA */ | 571 | /* Map the buffer for DMA */ |
508 | ret = videobuf_dma_map(priv->dev, &priv->vb); | 572 | ret = fpga_dma_map(priv); |
509 | if (ret) { | 573 | if (ret) { |
510 | dev_err(priv->dev, "Unable to map buffer for DMA\n"); | 574 | dev_err(priv->dev, "Unable to map buffer for DMA\n"); |
511 | goto out_free_table; | 575 | goto out_free_table; |
@@ -525,7 +589,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
525 | goto out_dma_unmap; | 589 | goto out_dma_unmap; |
526 | } | 590 | } |
527 | 591 | ||
528 | ret = fsl_dma_external_start(chan, 1) | 592 | ret = fsl_dma_external_start(chan, 1); |
529 | if (ret) { | 593 | if (ret) { |
530 | dev_err(priv->dev, "DMA external control setup failed\n"); | 594 | dev_err(priv->dev, "DMA external control setup failed\n"); |
531 | goto out_dma_unmap; | 595 | goto out_dma_unmap; |
@@ -534,7 +598,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
534 | /* setup and submit the DMA transaction */ | 598 | /* setup and submit the DMA transaction */ |
535 | 599 | ||
536 | tx = dmaengine_prep_dma_sg(chan, table.sgl, num_pages, | 600 | tx = dmaengine_prep_dma_sg(chan, table.sgl, num_pages, |
537 | vb->sglist, vb->sglen, 0); | 601 | priv->sglist, priv->sglen, 0); |
538 | if (!tx) { | 602 | if (!tx) { |
539 | dev_err(priv->dev, "Unable to prep DMA transaction\n"); | 603 | dev_err(priv->dev, "Unable to prep DMA transaction\n"); |
540 | ret = -ENOMEM; | 604 | ret = -ENOMEM; |
@@ -572,7 +636,7 @@ static noinline int fpga_program_dma(struct fpga_dev *priv) | |||
572 | out_disable_controller: | 636 | out_disable_controller: |
573 | fpga_programmer_disable(priv); | 637 | fpga_programmer_disable(priv); |
574 | out_dma_unmap: | 638 | out_dma_unmap: |
575 | videobuf_dma_unmap(priv->dev, vb); | 639 | fpga_dma_unmap(priv); |
576 | out_free_table: | 640 | out_free_table: |
577 | sg_free_table(&table); | 641 | sg_free_table(&table); |
578 | out_return: | 642 | out_return: |
@@ -702,12 +766,12 @@ static int fpga_open(struct inode *inode, struct file *filp) | |||
702 | priv->bytes = 0; | 766 | priv->bytes = 0; |
703 | 767 | ||
704 | /* Check if we have already allocated a buffer */ | 768 | /* Check if we have already allocated a buffer */ |
705 | if (priv->vb_allocated) | 769 | if (priv->buf_allocated) |
706 | return 0; | 770 | return 0; |
707 | 771 | ||
708 | /* Allocate a buffer to hold enough data for the bitfile */ | 772 | /* Allocate a buffer to hold enough data for the bitfile */ |
709 | nr_pages = DIV_ROUND_UP(priv->fw_size, PAGE_SIZE); | 773 | nr_pages = DIV_ROUND_UP(priv->fw_size, PAGE_SIZE); |
710 | ret = videobuf_dma_init_kernel(&priv->vb, DMA_TO_DEVICE, nr_pages); | 774 | ret = fpga_dma_init(priv, nr_pages); |
711 | if (ret) { | 775 | if (ret) { |
712 | dev_err(priv->dev, "unable to allocate data buffer\n"); | 776 | dev_err(priv->dev, "unable to allocate data buffer\n"); |
713 | mutex_unlock(&priv->lock); | 777 | mutex_unlock(&priv->lock); |
@@ -715,7 +779,7 @@ static int fpga_open(struct inode *inode, struct file *filp) | |||
715 | return ret; | 779 | return ret; |
716 | } | 780 | } |
717 | 781 | ||
718 | priv->vb_allocated = true; | 782 | priv->buf_allocated = true; |
719 | return 0; | 783 | return 0; |
720 | } | 784 | } |
721 | 785 | ||
@@ -738,7 +802,7 @@ static ssize_t fpga_write(struct file *filp, const char __user *buf, | |||
738 | return -ENOSPC; | 802 | return -ENOSPC; |
739 | 803 | ||
740 | count = min_t(size_t, priv->fw_size - priv->bytes, count); | 804 | count = min_t(size_t, priv->fw_size - priv->bytes, count); |
741 | if (copy_from_user(priv->vb.vaddr + priv->bytes, buf, count)) | 805 | if (copy_from_user(priv->vaddr + priv->bytes, buf, count)) |
742 | return -EFAULT; | 806 | return -EFAULT; |
743 | 807 | ||
744 | priv->bytes += count; | 808 | priv->bytes += count; |
@@ -749,20 +813,19 @@ static ssize_t fpga_read(struct file *filp, char __user *buf, size_t count, | |||
749 | loff_t *f_pos) | 813 | loff_t *f_pos) |
750 | { | 814 | { |
751 | struct fpga_dev *priv = filp->private_data; | 815 | struct fpga_dev *priv = filp->private_data; |
752 | return simple_read_from_buffer(buf, count, ppos, | 816 | return simple_read_from_buffer(buf, count, f_pos, |
753 | priv->vb.vaddr, priv->bytes); | 817 | priv->vaddr, priv->bytes); |
754 | } | 818 | } |
755 | 819 | ||
756 | static loff_t fpga_llseek(struct file *filp, loff_t offset, int origin) | 820 | static loff_t fpga_llseek(struct file *filp, loff_t offset, int origin) |
757 | { | 821 | { |
758 | struct fpga_dev *priv = filp->private_data; | 822 | struct fpga_dev *priv = filp->private_data; |
759 | loff_t newpos; | ||
760 | 823 | ||
761 | /* only read-only opens are allowed to seek */ | 824 | /* only read-only opens are allowed to seek */ |
762 | if ((filp->f_flags & O_ACCMODE) != O_RDONLY) | 825 | if ((filp->f_flags & O_ACCMODE) != O_RDONLY) |
763 | return -EINVAL; | 826 | return -EINVAL; |
764 | 827 | ||
765 | return fixed_size_llseek(file, offset, origin, priv->fw_size); | 828 | return fixed_size_llseek(filp, offset, origin, priv->fw_size); |
766 | } | 829 | } |
767 | 830 | ||
768 | static const struct file_operations fpga_fops = { | 831 | static const struct file_operations fpga_fops = { |
@@ -953,7 +1016,6 @@ static int fpga_of_probe(struct platform_device *op) | |||
953 | priv->dev = &op->dev; | 1016 | priv->dev = &op->dev; |
954 | mutex_init(&priv->lock); | 1017 | mutex_init(&priv->lock); |
955 | init_completion(&priv->completion); | 1018 | init_completion(&priv->completion); |
956 | videobuf_dma_init(&priv->vb); | ||
957 | 1019 | ||
958 | dev_set_drvdata(priv->dev, priv); | 1020 | dev_set_drvdata(priv->dev, priv); |
959 | dma_cap_zero(mask); | 1021 | dma_cap_zero(mask); |
diff --git a/drivers/misc/carma/carma-fpga.c b/drivers/misc/carma/carma-fpga.c index cdf2d7b902bb..68cdfe151bdb 100644 --- a/drivers/misc/carma/carma-fpga.c +++ b/drivers/misc/carma/carma-fpga.c | |||
@@ -98,6 +98,7 @@ | |||
98 | #include <linux/seq_file.h> | 98 | #include <linux/seq_file.h> |
99 | #include <linux/highmem.h> | 99 | #include <linux/highmem.h> |
100 | #include <linux/debugfs.h> | 100 | #include <linux/debugfs.h> |
101 | #include <linux/vmalloc.h> | ||
101 | #include <linux/kernel.h> | 102 | #include <linux/kernel.h> |
102 | #include <linux/module.h> | 103 | #include <linux/module.h> |
103 | #include <linux/poll.h> | 104 | #include <linux/poll.h> |
@@ -105,8 +106,6 @@ | |||
105 | #include <linux/kref.h> | 106 | #include <linux/kref.h> |
106 | #include <linux/io.h> | 107 | #include <linux/io.h> |
107 | 108 | ||
108 | #include <media/videobuf-dma-sg.h> | ||
109 | |||
110 | /* system controller registers */ | 109 | /* system controller registers */ |
111 | #define SYS_IRQ_SOURCE_CTL 0x24 | 110 | #define SYS_IRQ_SOURCE_CTL 0x24 |
112 | #define SYS_IRQ_OUTPUT_EN 0x28 | 111 | #define SYS_IRQ_OUTPUT_EN 0x28 |
@@ -142,7 +141,10 @@ struct fpga_info { | |||
142 | 141 | ||
143 | struct data_buf { | 142 | struct data_buf { |
144 | struct list_head entry; | 143 | struct list_head entry; |
145 | struct videobuf_dmabuf vb; | 144 | void *vaddr; |
145 | struct scatterlist *sglist; | ||
146 | int sglen; | ||
147 | int nr_pages; | ||
146 | size_t size; | 148 | size_t size; |
147 | }; | 149 | }; |
148 | 150 | ||
@@ -207,6 +209,68 @@ static void fpga_device_release(struct kref *ref) | |||
207 | * Data Buffer Allocation Helpers | 209 | * Data Buffer Allocation Helpers |
208 | */ | 210 | */ |
209 | 211 | ||
212 | static int carma_dma_init(struct data_buf *buf, int nr_pages) | ||
213 | { | ||
214 | struct page *pg; | ||
215 | int i; | ||
216 | |||
217 | buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); | ||
218 | if (NULL == buf->vaddr) { | ||
219 | pr_debug("vmalloc_32(%d pages) failed\n", nr_pages); | ||
220 | return -ENOMEM; | ||
221 | } | ||
222 | |||
223 | pr_debug("vmalloc is at addr 0x%08lx, size=%d\n", | ||
224 | (unsigned long)buf->vaddr, | ||
225 | nr_pages << PAGE_SHIFT); | ||
226 | |||
227 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); | ||
228 | buf->nr_pages = nr_pages; | ||
229 | |||
230 | buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); | ||
231 | if (NULL == buf->sglist) | ||
232 | goto vzalloc_err; | ||
233 | |||
234 | sg_init_table(buf->sglist, buf->nr_pages); | ||
235 | for (i = 0; i < buf->nr_pages; i++) { | ||
236 | pg = vmalloc_to_page(buf->vaddr + i * PAGE_SIZE); | ||
237 | if (NULL == pg) | ||
238 | goto vmalloc_to_page_err; | ||
239 | sg_set_page(&buf->sglist[i], pg, PAGE_SIZE, 0); | ||
240 | } | ||
241 | return 0; | ||
242 | |||
243 | vmalloc_to_page_err: | ||
244 | vfree(buf->sglist); | ||
245 | buf->sglist = NULL; | ||
246 | vzalloc_err: | ||
247 | vfree(buf->vaddr); | ||
248 | buf->vaddr = NULL; | ||
249 | return -ENOMEM; | ||
250 | } | ||
251 | |||
252 | static int carma_dma_map(struct device *dev, struct data_buf *buf) | ||
253 | { | ||
254 | buf->sglen = dma_map_sg(dev, buf->sglist, | ||
255 | buf->nr_pages, DMA_FROM_DEVICE); | ||
256 | |||
257 | if (0 == buf->sglen) { | ||
258 | pr_warn("%s: dma_map_sg failed\n", __func__); | ||
259 | return -ENOMEM; | ||
260 | } | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | static int carma_dma_unmap(struct device *dev, struct data_buf *buf) | ||
265 | { | ||
266 | if (!buf->sglen) | ||
267 | return 0; | ||
268 | |||
269 | dma_unmap_sg(dev, buf->sglist, buf->sglen, DMA_FROM_DEVICE); | ||
270 | buf->sglen = 0; | ||
271 | return 0; | ||
272 | } | ||
273 | |||
210 | /** | 274 | /** |
211 | * data_free_buffer() - free a single data buffer and all allocated memory | 275 | * data_free_buffer() - free a single data buffer and all allocated memory |
212 | * @buf: the buffer to free | 276 | * @buf: the buffer to free |
@@ -221,7 +285,8 @@ static void data_free_buffer(struct data_buf *buf) | |||
221 | return; | 285 | return; |
222 | 286 | ||
223 | /* free all memory */ | 287 | /* free all memory */ |
224 | videobuf_dma_free(&buf->vb); | 288 | vfree(buf->sglist); |
289 | vfree(buf->vaddr); | ||
225 | kfree(buf); | 290 | kfree(buf); |
226 | } | 291 | } |
227 | 292 | ||
@@ -230,7 +295,7 @@ static void data_free_buffer(struct data_buf *buf) | |||
230 | * @bytes: the number of bytes required | 295 | * @bytes: the number of bytes required |
231 | * | 296 | * |
232 | * This allocates all space needed for a data buffer. It must be mapped before | 297 | * This allocates all space needed for a data buffer. It must be mapped before |
233 | * use in a DMA transaction using videobuf_dma_map(). | 298 | * use in a DMA transaction using carma_dma_map(). |
234 | * | 299 | * |
235 | * Returns NULL on failure | 300 | * Returns NULL on failure |
236 | */ | 301 | */ |
@@ -252,9 +317,8 @@ static struct data_buf *data_alloc_buffer(const size_t bytes) | |||
252 | INIT_LIST_HEAD(&buf->entry); | 317 | INIT_LIST_HEAD(&buf->entry); |
253 | buf->size = bytes; | 318 | buf->size = bytes; |
254 | 319 | ||
255 | /* allocate the videobuf */ | 320 | /* allocate the buffer */ |
256 | videobuf_dma_init(&buf->vb); | 321 | ret = carma_dma_init(buf, nr_pages); |
257 | ret = videobuf_dma_init_kernel(&buf->vb, DMA_FROM_DEVICE, nr_pages); | ||
258 | if (ret) | 322 | if (ret) |
259 | goto out_free_buf; | 323 | goto out_free_buf; |
260 | 324 | ||
@@ -285,13 +349,13 @@ static void data_free_buffers(struct fpga_device *priv) | |||
285 | 349 | ||
286 | list_for_each_entry_safe(buf, tmp, &priv->free, entry) { | 350 | list_for_each_entry_safe(buf, tmp, &priv->free, entry) { |
287 | list_del_init(&buf->entry); | 351 | list_del_init(&buf->entry); |
288 | videobuf_dma_unmap(priv->dev, &buf->vb); | 352 | carma_dma_unmap(priv->dev, buf); |
289 | data_free_buffer(buf); | 353 | data_free_buffer(buf); |
290 | } | 354 | } |
291 | 355 | ||
292 | list_for_each_entry_safe(buf, tmp, &priv->used, entry) { | 356 | list_for_each_entry_safe(buf, tmp, &priv->used, entry) { |
293 | list_del_init(&buf->entry); | 357 | list_del_init(&buf->entry); |
294 | videobuf_dma_unmap(priv->dev, &buf->vb); | 358 | carma_dma_unmap(priv->dev, buf); |
295 | data_free_buffer(buf); | 359 | data_free_buffer(buf); |
296 | } | 360 | } |
297 | 361 | ||
@@ -330,7 +394,7 @@ static int data_alloc_buffers(struct fpga_device *priv) | |||
330 | break; | 394 | break; |
331 | 395 | ||
332 | /* map it for DMA */ | 396 | /* map it for DMA */ |
333 | ret = videobuf_dma_map(priv->dev, &buf->vb); | 397 | ret = carma_dma_map(priv->dev, buf); |
334 | if (ret) { | 398 | if (ret) { |
335 | data_free_buffer(buf); | 399 | data_free_buffer(buf); |
336 | break; | 400 | break; |
@@ -634,8 +698,8 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf) | |||
634 | dma_addr_t dst, src; | 698 | dma_addr_t dst, src; |
635 | unsigned long dma_flags = 0; | 699 | unsigned long dma_flags = 0; |
636 | 700 | ||
637 | dst_sg = buf->vb.sglist; | 701 | dst_sg = buf->sglist; |
638 | dst_nents = buf->vb.sglen; | 702 | dst_nents = buf->sglen; |
639 | 703 | ||
640 | src_sg = priv->corl_table.sgl; | 704 | src_sg = priv->corl_table.sgl; |
641 | src_nents = priv->corl_nents; | 705 | src_nents = priv->corl_nents; |
@@ -1134,7 +1198,7 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count, | |||
1134 | spin_unlock_irq(&priv->lock); | 1198 | spin_unlock_irq(&priv->lock); |
1135 | 1199 | ||
1136 | /* Buffers are always mapped: unmap it */ | 1200 | /* Buffers are always mapped: unmap it */ |
1137 | videobuf_dma_unmap(priv->dev, &dbuf->vb); | 1201 | carma_dma_unmap(priv->dev, dbuf); |
1138 | 1202 | ||
1139 | /* save the buffer for later */ | 1203 | /* save the buffer for later */ |
1140 | reader->buf = dbuf; | 1204 | reader->buf = dbuf; |
@@ -1143,7 +1207,7 @@ static ssize_t data_read(struct file *filp, char __user *ubuf, size_t count, | |||
1143 | have_buffer: | 1207 | have_buffer: |
1144 | /* Get the number of bytes available */ | 1208 | /* Get the number of bytes available */ |
1145 | avail = dbuf->size - reader->buf_start; | 1209 | avail = dbuf->size - reader->buf_start; |
1146 | data = dbuf->vb.vaddr + reader->buf_start; | 1210 | data = dbuf->vaddr + reader->buf_start; |
1147 | 1211 | ||
1148 | /* Get the number of bytes we can transfer */ | 1212 | /* Get the number of bytes we can transfer */ |
1149 | count = min(count, avail); | 1213 | count = min(count, avail); |
@@ -1171,7 +1235,7 @@ have_buffer: | |||
1171 | * If it fails, we pretend that the read never happed and return | 1235 | * If it fails, we pretend that the read never happed and return |
1172 | * -EFAULT to userspace. The read will be retried. | 1236 | * -EFAULT to userspace. The read will be retried. |
1173 | */ | 1237 | */ |
1174 | ret = videobuf_dma_map(priv->dev, &dbuf->vb); | 1238 | ret = carma_dma_map(priv->dev, dbuf); |
1175 | if (ret) { | 1239 | if (ret) { |
1176 | dev_err(priv->dev, "unable to remap buffer for DMA\n"); | 1240 | dev_err(priv->dev, "unable to remap buffer for DMA\n"); |
1177 | return -EFAULT; | 1241 | return -EFAULT; |
@@ -1203,7 +1267,7 @@ out_unlock: | |||
1203 | spin_unlock_irq(&priv->lock); | 1267 | spin_unlock_irq(&priv->lock); |
1204 | 1268 | ||
1205 | if (drop_buffer) { | 1269 | if (drop_buffer) { |
1206 | videobuf_dma_unmap(priv->dev, &dbuf->vb); | 1270 | carma_dma_unmap(priv->dev, dbuf); |
1207 | data_free_buffer(dbuf); | 1271 | data_free_buffer(dbuf); |
1208 | } | 1272 | } |
1209 | 1273 | ||