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.
6 This is used to stop the I2S driver from breaking
7 the GPIO setup for other uses of the PCM interface
9 sound/soc/bcm/bcm2708-i2s.c | 55 +++++++++++++++++++++++----------------------
10 1 file changed, 28 insertions(+), 27 deletions(-)
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
19 +static void bcm2708_i2s_setup_gpio(void)
22 + * This is the common way to handle the GPIO pins for
24 + * TODO Better way would be to handle
25 + * this in the device tree!
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))
32 + gpio = ioremap(GPIO_BASE, SZ_16K);
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 */
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))
51 + bcm2708_i2s_setup_gpio();
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",
61 -static void bcm2708_i2s_setup_gpio(void)
64 - * This is the common way to handle the GPIO pins for
66 - * TODO Better way would be to handle
67 - * this in the device tree!
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))
74 - gpio = ioremap(GPIO_BASE, SZ_16K);
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 */
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
92 - bcm2708_i2s_setup_gpio();
94 dev->i2s_regmap = regmap[0];
95 dev->clk_regmap = regmap[1];