e800713ab836d258d5447da20b948d17fc05289d
[openwrt/staging/blogic.git] /
1 From e4f0f7daebca7005c67bf7ae3f6f59df587e91d5 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
3 Date: Sat, 3 Oct 2015 22:22:55 +0200
4 Subject: [PATCH] dmaengine: bcm2835: Load driver early and support legacy API
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Load driver early since at least bcm2708_fb doesn't support deferred
10 probing and even if it did, we don't want the video driver deferred.
11 Support the legacy DMA API which is needed by bcm2708_fb.
12 Don't mask out channel 2.
13
14 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
15 ---
16 drivers/dma/Kconfig | 2 +-
17 drivers/dma/bcm2835-dma.c | 26 +++++++++++++++++++++++++-
18 2 files changed, 26 insertions(+), 2 deletions(-)
19
20 --- a/drivers/dma/Kconfig
21 +++ b/drivers/dma/Kconfig
22 @@ -108,7 +108,7 @@ config COH901318
23
24 config DMA_BCM2835
25 tristate "BCM2835 DMA engine support"
26 - depends on ARCH_BCM2835
27 + depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
28 select DMA_ENGINE
29 select DMA_VIRTUAL_CHANNELS
30
31 --- a/drivers/dma/bcm2835-dma.c
32 +++ b/drivers/dma/bcm2835-dma.c
33 @@ -37,6 +37,7 @@
34 #include <linux/interrupt.h>
35 #include <linux/list.h>
36 #include <linux/module.h>
37 +#include <linux/platform_data/dma-bcm2708.h>
38 #include <linux/platform_device.h>
39 #include <linux/slab.h>
40 #include <linux/io.h>
41 @@ -48,6 +49,7 @@
42
43 #define BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED 14
44 #define BCM2835_DMA_CHAN_NAME_SIZE 8
45 +#define BCM2835_DMA_BULK_MASK BIT(0)
46
47 struct bcm2835_dmadev {
48 struct dma_device ddev;
49 @@ -922,6 +924,9 @@ static int bcm2835_dma_probe(struct plat
50 base = devm_ioremap_resource(&pdev->dev, res);
51 if (IS_ERR(base))
52 return PTR_ERR(base);
53 + rc = bcm_dmaman_probe(pdev, base, BCM2835_DMA_BULK_MASK);
54 + if (rc)
55 + dev_err(&pdev->dev, "Failed to initialize the legacy API\n");
56
57 od->base = base;
58
59 @@ -959,6 +964,9 @@ static int bcm2835_dma_probe(struct plat
60 goto err_no_dma;
61 }
62
63 + /* Channel 0 is used by the legacy API */
64 + chans_available &= ~BCM2835_DMA_BULK_MASK;
65 +
66 /* get irqs for each channel that we support */
67 for (i = 0; i <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; i++) {
68 /* skip masked out channels */
69 @@ -1033,6 +1041,7 @@ static int bcm2835_dma_remove(struct pla
70 {
71 struct bcm2835_dmadev *od = platform_get_drvdata(pdev);
72
73 + bcm_dmaman_remove(pdev);
74 dma_async_device_unregister(&od->ddev);
75 bcm2835_dma_free(od);
76
77 @@ -1048,7 +1057,22 @@ static struct platform_driver bcm2835_dm
78 },
79 };
80
81 -module_platform_driver(bcm2835_dma_driver);
82 +static int bcm2835_dma_init(void)
83 +{
84 + return platform_driver_register(&bcm2835_dma_driver);
85 +}
86 +
87 +static void bcm2835_dma_exit(void)
88 +{
89 + platform_driver_unregister(&bcm2835_dma_driver);
90 +}
91 +
92 +/*
93 + * Load after serial driver (arch_initcall) so we see the messages if it fails,
94 + * but before drivers (module_init) that need a DMA channel.
95 + */
96 +subsys_initcall(bcm2835_dma_init);
97 +module_exit(bcm2835_dma_exit);
98
99 MODULE_ALIAS("platform:bcm2835-dma");
100 MODULE_DESCRIPTION("BCM2835 DMA engine driver");