brcm2708: add 3.14 support
[openwrt.git] / target / linux / brcm2708 / patches-3.14 / 0053-Move-GPIO-setup-to-hw_params.patch
1 From 3eae00b73609f4e5a19260bfa4ca9021f295c0af Mon Sep 17 00:00:00 2001
2 From: Gordon Hollingworth <gordon@holliweb.co.uk>
3 Date: Fri, 2 May 2014 16:13:59 +0100
4 Subject: [PATCH 53/54] Move GPIO setup to hw_params.
5
6 This is used to stop the I2S driver from breaking
7 the GPIO setup for other uses of the PCM interface
8 ---
9  sound/soc/bcm/bcm2708-i2s.c | 55 +++++++++++++++++++++++----------------------
10  1 file changed, 28 insertions(+), 27 deletions(-)
11
12 diff --git a/sound/soc/bcm/bcm2708-i2s.c b/sound/soc/bcm/bcm2708-i2s.c
13 index b25e158..9976571 100644
14 --- a/sound/soc/bcm/bcm2708-i2s.c
15 +++ b/sound/soc/bcm/bcm2708-i2s.c
16 @@ -305,6 +305,31 @@ static int bcm2708_i2s_set_dai_bclk_ratio(struct snd_soc_dai *dai,
17         return 0;
18  }
19  
20 +
21 +static void bcm2708_i2s_setup_gpio(void)
22 +{
23 +       /*
24 +        * This is the common way to handle the GPIO pins for
25 +        * the Raspberry Pi.
26 +        * TODO Better way would be to handle
27 +        * this in the device tree!
28 +        */
29 +#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
30 +#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
31 +
32 +       unsigned int *gpio;
33 +       int pin;
34 +       gpio = ioremap(GPIO_BASE, SZ_16K);
35 +
36 +       /* SPI is on GPIO 7..11 */
37 +       for (pin = 28; pin <= 31; pin++) {
38 +               INP_GPIO(pin);          /* set mode to GPIO input first */
39 +               SET_GPIO_ALT(pin, 2);   /* set mode to ALT 0 */
40 +       }
41 +#undef INP_GPIO
42 +#undef SET_GPIO_ALT
43 +}
44 +
45  static int bcm2708_i2s_hw_params(struct snd_pcm_substream *substream,
46                                  struct snd_pcm_hw_params *params,
47                                  struct snd_soc_dai *dai)
48 @@ -334,6 +359,9 @@ static int bcm2708_i2s_hw_params(struct snd_pcm_substream *substream,
49         if (csreg & (BCM2708_I2S_TXON | BCM2708_I2S_RXON))
50                 return 0;
51  
52 +
53 +       bcm2708_i2s_setup_gpio();
54 +
55         /*
56          * Adjust the data length according to the format.
57          * We prefill the half frame length with an integer
58 @@ -790,31 +818,6 @@ static const struct snd_soc_component_driver bcm2708_i2s_component = {
59         .name           = "bcm2708-i2s-comp",
60  };
61  
62 -
63 -static void bcm2708_i2s_setup_gpio(void)
64 -{
65 -       /*
66 -        * This is the common way to handle the GPIO pins for
67 -        * the Raspberry Pi.
68 -        * TODO Better way would be to handle
69 -        * this in the device tree!
70 -        */
71 -#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
72 -#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
73 -
74 -       unsigned int *gpio;
75 -       int pin;
76 -       gpio = ioremap(GPIO_BASE, SZ_16K);
77 -
78 -       /* SPI is on GPIO 7..11 */
79 -       for (pin = 28; pin <= 31; pin++) {
80 -               INP_GPIO(pin);          /* set mode to GPIO input first */
81 -               SET_GPIO_ALT(pin, 2);   /* set mode to ALT 0 */
82 -       }
83 -#undef INP_GPIO
84 -#undef SET_GPIO_ALT
85 -}
86 -
87  static const struct snd_pcm_hardware bcm2708_pcm_hardware = {
88         .info                   = SNDRV_PCM_INFO_INTERLEAVED |
89                                   SNDRV_PCM_INFO_JOINT_DUPLEX,
90 @@ -865,8 +868,6 @@ static int bcm2708_i2s_probe(struct platform_device *pdev)
91         if (IS_ERR(dev))
92                 return PTR_ERR(dev);
93  
94 -       bcm2708_i2s_setup_gpio();
95 -
96         dev->i2s_regmap = regmap[0];
97         dev->clk_regmap = regmap[1];
98  
99 -- 
100 1.9.1
101