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