kernel: refresh patches
[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 --- a/sound/soc/bcm/bcm2708-i2s.c
13 +++ b/sound/soc/bcm/bcm2708-i2s.c
14 @@ -305,6 +305,31 @@ static int bcm2708_i2s_set_dai_bclk_rati
15         return 0;
16  }
17  
18 +
19 +static void bcm2708_i2s_setup_gpio(void)
20 +{
21 +       /*
22 +        * This is the common way to handle the GPIO pins for
23 +        * the Raspberry Pi.
24 +        * TODO Better way would be to handle
25 +        * this in the device tree!
26 +        */
27 +#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
28 +#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
29 +
30 +       unsigned int *gpio;
31 +       int pin;
32 +       gpio = ioremap(GPIO_BASE, SZ_16K);
33 +
34 +       /* SPI is on GPIO 7..11 */
35 +       for (pin = 28; pin <= 31; pin++) {
36 +               INP_GPIO(pin);          /* set mode to GPIO input first */
37 +               SET_GPIO_ALT(pin, 2);   /* set mode to ALT 0 */
38 +       }
39 +#undef INP_GPIO
40 +#undef SET_GPIO_ALT
41 +}
42 +
43  static int bcm2708_i2s_hw_params(struct snd_pcm_substream *substream,
44                                  struct snd_pcm_hw_params *params,
45                                  struct snd_soc_dai *dai)
46 @@ -334,6 +359,9 @@ static int bcm2708_i2s_hw_params(struct 
47         if (csreg & (BCM2708_I2S_TXON | BCM2708_I2S_RXON))
48                 return 0;
49  
50 +
51 +       bcm2708_i2s_setup_gpio();
52 +
53         /*
54          * Adjust the data length according to the format.
55          * We prefill the half frame length with an integer
56 @@ -790,31 +818,6 @@ static const struct snd_soc_component_dr
57         .name           = "bcm2708-i2s-comp",
58  };
59  
60 -
61 -static void bcm2708_i2s_setup_gpio(void)
62 -{
63 -       /*
64 -        * This is the common way to handle the GPIO pins for
65 -        * the Raspberry Pi.
66 -        * TODO Better way would be to handle
67 -        * this in the device tree!
68 -        */
69 -#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
70 -#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
71 -
72 -       unsigned int *gpio;
73 -       int pin;
74 -       gpio = ioremap(GPIO_BASE, SZ_16K);
75 -
76 -       /* SPI is on GPIO 7..11 */
77 -       for (pin = 28; pin <= 31; pin++) {
78 -               INP_GPIO(pin);          /* set mode to GPIO input first */
79 -               SET_GPIO_ALT(pin, 2);   /* set mode to ALT 0 */
80 -       }
81 -#undef INP_GPIO
82 -#undef SET_GPIO_ALT
83 -}
84 -
85  static const struct snd_pcm_hardware bcm2708_pcm_hardware = {
86         .info                   = SNDRV_PCM_INFO_INTERLEAVED |
87                                   SNDRV_PCM_INFO_JOINT_DUPLEX,
88 @@ -865,8 +868,6 @@ static int bcm2708_i2s_probe(struct plat
89         if (IS_ERR(dev))
90                 return PTR_ERR(dev);
91  
92 -       bcm2708_i2s_setup_gpio();
93 -
94         dev->i2s_regmap = regmap[0];
95         dev->clk_regmap = regmap[1];
96