1 From 931a943a992c5c1e41f76c87858c160e2466fd2d 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 287/782] Revert "staging: bcm2835-audio: Drop DT dependency"
6 This reverts commit 933bc853bb764e476b0b0f633588f46d20f1f76a.
8 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
10 .../vc04_services/bcm2835-audio/bcm2835.c | 41 ++++++++++---------
11 1 file changed, 22 insertions(+), 19 deletions(-)
13 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
14 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
16 #include <linux/platform_device.h>
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>
27 static bool enable_hdmi;
28 static bool enable_headphones;
29 static bool enable_compat_alsa = true;
30 -static int num_channels = MAX_SUBSTREAMS;
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)");
41 static void snd_devm_unregister_child(struct device *dev, void *res)
43 @@ -411,30 +407,31 @@ static int snd_add_child_devices(struct
47 -static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
48 +static int snd_bcm2835_alsa_probe_dt(struct platform_device *pdev)
50 struct device *dev = &pdev->dev;
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",
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",
66 - dev_err(dev, "Unable to setup DMA: %d\n", err);
67 + dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'");
71 + if (numchans == 0 || numchans > MAX_SUBSTREAMS) {
72 + numchans = MAX_SUBSTREAMS;
74 + "Illegal 'brcm,pwm-channels' value, will use %u\n",
78 err = bcm2835_devm_add_vchi_ctx(dev);
82 - err = snd_add_child_devices(dev, num_channels);
83 + err = snd_add_child_devices(dev, numchans);
87 @@ -456,14 +453,21 @@ static int snd_bcm2835_alsa_resume(struc
91 +static const struct of_device_id snd_bcm2835_of_match_table[] = {
92 + { .compatible = "brcm,bcm2835-audio",},
95 +MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table);
97 static struct platform_driver bcm2835_alsa0_driver = {
98 - .probe = snd_bcm2835_alsa_probe,
99 + .probe = snd_bcm2835_alsa_probe_dt,
101 .suspend = snd_bcm2835_alsa_suspend,
102 .resume = snd_bcm2835_alsa_resume,
105 .name = "bcm2835_audio",
106 + .of_match_table = snd_bcm2835_of_match_table,
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");