brcm2708: update to latest patches from RPi foundation
[openwrt/staging/stintel.git] / target / linux / brcm2708 / patches-4.19 / 950-0234-staging-bcm2835-audio-Drop-DT-dependency.patch
1 From 02f72e788103e9c9a170ddd5f2f71f55ae8c98ed Mon Sep 17 00:00:00 2001
2 From: Stefan Wahren <stefan.wahren@i2se.com>
3 Date: Thu, 18 Oct 2018 19:54:01 +0200
4 Subject: [PATCH 234/782] staging: bcm2835-audio: Drop DT dependency
5
6 Just like the bcm2835-video make this a platform driver which is probed
7 by vchiq. In order to change the number of channels use a module
8 parameter instead, but use the maximum as default.
9
10 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
11 ---
12 .../vc04_services/bcm2835-audio/bcm2835.c | 41 +++++++++----------
13 1 file changed, 19 insertions(+), 22 deletions(-)
14
15 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
16 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
17 @@ -4,15 +4,17 @@
18 #include <linux/platform_device.h>
19
20 #include <linux/init.h>
21 +#include <linux/dma-mapping.h>
22 +#include <linux/of_device.h>
23 #include <linux/slab.h>
24 #include <linux/module.h>
25 -#include <linux/of.h>
26
27 #include "bcm2835.h"
28
29 static bool enable_hdmi;
30 static bool enable_headphones;
31 static bool enable_compat_alsa = true;
32 +static int num_channels = MAX_SUBSTREAMS;
33
34 module_param(enable_hdmi, bool, 0444);
35 MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device");
36 @@ -21,6 +23,8 @@ MODULE_PARM_DESC(enable_headphones, "Ena
37 module_param(enable_compat_alsa, bool, 0444);
38 MODULE_PARM_DESC(enable_compat_alsa,
39 "Enables ALSA compatibility virtual audio device");
40 +module_param(num_channels, int, 0644);
41 +MODULE_PARM_DESC(num_channels, "Number of audio channels (default: 8)");
42
43 static void snd_devm_unregister_child(struct device *dev, void *res)
44 {
45 @@ -407,31 +411,30 @@ static int snd_add_child_devices(struct
46 return 0;
47 }
48
49 -static int snd_bcm2835_alsa_probe_dt(struct platform_device *pdev)
50 +static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
51 {
52 struct device *dev = &pdev->dev;
53 - u32 numchans;
54 int err;
55
56 - err = of_property_read_u32(dev->of_node, "brcm,pwm-channels",
57 - &numchans);
58 - if (err) {
59 - dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'");
60 - return err;
61 + if (num_channels <= 0 || num_channels > MAX_SUBSTREAMS) {
62 + num_channels = MAX_SUBSTREAMS;
63 + dev_warn(dev, "Illegal num_channels value, will use %u\n",
64 + num_channels);
65 }
66
67 - if (numchans == 0 || numchans > MAX_SUBSTREAMS) {
68 - numchans = MAX_SUBSTREAMS;
69 - dev_warn(dev,
70 - "Illegal 'brcm,pwm-channels' value, will use %u\n",
71 - numchans);
72 + dev->coherent_dma_mask = DMA_BIT_MASK(32);
73 + dev->dma_mask = &dev->coherent_dma_mask;
74 + err = of_dma_configure(dev, NULL, true);
75 + if (err) {
76 + dev_err(dev, "Unable to setup DMA: %d\n", err);
77 + return err;
78 }
79
80 err = bcm2835_devm_add_vchi_ctx(dev);
81 if (err)
82 return err;
83
84 - err = snd_add_child_devices(dev, numchans);
85 + err = snd_add_child_devices(dev, num_channels);
86 if (err)
87 return err;
88
89 @@ -453,21 +456,14 @@ static int snd_bcm2835_alsa_resume(struc
90
91 #endif
92
93 -static const struct of_device_id snd_bcm2835_of_match_table[] = {
94 - { .compatible = "brcm,bcm2835-audio",},
95 - {},
96 -};
97 -MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table);
98 -
99 static struct platform_driver bcm2835_alsa0_driver = {
100 - .probe = snd_bcm2835_alsa_probe_dt,
101 + .probe = snd_bcm2835_alsa_probe,
102 #ifdef CONFIG_PM
103 .suspend = snd_bcm2835_alsa_suspend,
104 .resume = snd_bcm2835_alsa_resume,
105 #endif
106 .driver = {
107 .name = "bcm2835_audio",
108 - .of_match_table = snd_bcm2835_of_match_table,
109 },
110 };
111 module_platform_driver(bcm2835_alsa0_driver);
112 @@ -475,3 +471,4 @@ module_platform_driver(bcm2835_alsa0_dri
113 MODULE_AUTHOR("Dom Cobley");
114 MODULE_DESCRIPTION("Alsa driver for BCM2835 chip");
115 MODULE_LICENSE("GPL");
116 +MODULE_ALIAS("platform:bcm2835_audio");