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