bcm27xx: update patches from RPi foundation
[oweals/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0140-Revert-staging-bcm2835-audio-Drop-DT-dependency.patch
1 From 6259d03df45a2fd245f6799a83a491edad07c80d Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Fri, 15 Mar 2019 21:11:10 +0000
4 Subject: [PATCH] Revert "staging: bcm2835-audio: Drop DT dependency"
5
6 This reverts commit b7491a9fca2dc2535b9dc922550a37c5baae9d3d.
7 ---
8  .../vc04_services/bcm2835-audio/bcm2835.c     | 31 +++++++++++++------
9  1 file changed, 22 insertions(+), 9 deletions(-)
10
11 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
12 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
13 @@ -6,13 +6,13 @@
14  #include <linux/init.h>
15  #include <linux/slab.h>
16  #include <linux/module.h>
17 +#include <linux/of.h>
18  
19  #include "bcm2835.h"
20  
21  static bool enable_hdmi;
22  static bool enable_headphones;
23  static bool enable_compat_alsa = true;
24 -static int num_channels = MAX_SUBSTREAMS;
25  
26  module_param(enable_hdmi, bool, 0444);
27  MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device");
28 @@ -21,8 +21,6 @@ MODULE_PARM_DESC(enable_headphones, "Ena
29  module_param(enable_compat_alsa, bool, 0444);
30  MODULE_PARM_DESC(enable_compat_alsa,
31                  "Enables ALSA compatibility virtual audio device");
32 -module_param(num_channels, int, 0644);
33 -MODULE_PARM_DESC(num_channels, "Number of audio channels (default: 8)");
34  
35  static void bcm2835_devm_free_vchi_ctx(struct device *dev, void *res)
36  {
37 @@ -296,19 +294,28 @@ static int snd_add_child_devices(struct
38  static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
39  {
40         struct device *dev = &pdev->dev;
41 +       u32 numchans;
42         int err;
43  
44 -       if (num_channels <= 0 || num_channels > MAX_SUBSTREAMS) {
45 -               num_channels = MAX_SUBSTREAMS;
46 -               dev_warn(dev, "Illegal num_channels value, will use %u\n",
47 -                        num_channels);
48 +       err = of_property_read_u32(dev->of_node, "brcm,pwm-channels",
49 +                                  &numchans);
50 +       if (err) {
51 +               dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'");
52 +               return err;
53 +       }
54 +
55 +       if (numchans == 0 || numchans > MAX_SUBSTREAMS) {
56 +               numchans = MAX_SUBSTREAMS;
57 +               dev_warn(dev,
58 +                        "Illegal 'brcm,pwm-channels' value, will use %u\n",
59 +                        numchans);
60         }
61  
62         err = bcm2835_devm_add_vchi_ctx(dev);
63         if (err)
64                 return err;
65  
66 -       err = snd_add_child_devices(dev, num_channels);
67 +       err = snd_add_child_devices(dev, numchans);
68         if (err)
69                 return err;
70  
71 @@ -330,6 +337,12 @@ static int snd_bcm2835_alsa_resume(struc
72  
73  #endif
74  
75 +static const struct of_device_id snd_bcm2835_of_match_table[] = {
76 +       { .compatible = "brcm,bcm2835-audio",},
77 +       {},
78 +};
79 +MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table);
80 +
81  static struct platform_driver bcm2835_alsa_driver = {
82         .probe = snd_bcm2835_alsa_probe,
83  #ifdef CONFIG_PM
84 @@ -338,6 +351,7 @@ static struct platform_driver bcm2835_al
85  #endif
86         .driver = {
87                 .name = "bcm2835_audio",
88 +               .of_match_table = snd_bcm2835_of_match_table,
89         },
90  };
91  module_platform_driver(bcm2835_alsa_driver);
92 @@ -345,4 +359,3 @@ module_platform_driver(bcm2835_alsa_driv
93  MODULE_AUTHOR("Dom Cobley");
94  MODULE_DESCRIPTION("Alsa driver for BCM2835 chip");
95  MODULE_LICENSE("GPL");
96 -MODULE_ALIAS("platform:bcm2835_audio");