aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-3.14/0053-Move-GPIO-setup-to-hw_params.patch
blob: 130da2b5e22a02d5a11b29001dbe2144888073f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 3eae00b73609f4e5a19260bfa4ca9021f295c0af Mon Sep 17 00:00:00 2001
From: Gordon Hollingworth <gordon@holliweb.co.uk>
Date: Fri, 2 May 2014 16:13:59 +0100
Subject: [PATCH 53/54] Move GPIO setup to hw_params.

This is used to stop the I2S driver from breaking
the GPIO setup for other uses of the PCM interface
---
 sound/soc/bcm/bcm2708-i2s.c | 55 +++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

--- a/sound/soc/bcm/bcm2708-i2s.c
+++ b/sound/soc/bcm/bcm2708-i2s.c
@@ -305,6 +305,31 @@ static int bcm2708_i2s_set_dai_bclk_rati
 	return 0;
 }
 
+
+static void bcm2708_i2s_setup_gpio(void)
+{
+	/*
+	 * This is the common way to handle the GPIO pins for
+	 * the Raspberry Pi.
+	 * TODO Better way would be to handle
+	 * this in the device tree!
+	 */
+#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
+#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
+
+	unsigned int *gpio;
+	int pin;
+	gpio = ioremap(GPIO_BASE, SZ_16K);
+
+	/* SPI is on GPIO 7..11 */
+	for (pin = 28; pin <= 31; pin++) {
+		INP_GPIO(pin);		/* set mode to GPIO input first */
+		SET_GPIO_ALT(pin, 2);	/* set mode to ALT 0 */
+	}
+#undef INP_GPIO
+#undef SET_GPIO_ALT
+}
+
 static int bcm2708_i2s_hw_params(struct snd_pcm_substream *substream,
 				 struct snd_pcm_hw_params *params,
 				 struct snd_soc_dai *dai)
@@ -334,6 +359,9 @@ static int bcm2708_i2s_hw_params(struct 
 	if (csreg & (BCM2708_I2S_TXON | BCM2708_I2S_RXON))
 		return 0;
 
+
+	bcm2708_i2s_setup_gpio();
+
 	/*
 	 * Adjust the data length according to the format.
 	 * We prefill the half frame length with an integer
@@ -790,31 +818,6 @@ static const struct snd_soc_component_dr
 	.name		= "bcm2708-i2s-comp",
 };
 
-
-static void bcm2708_i2s_setup_gpio(void)
-{
-	/*
-	 * This is the common way to handle the GPIO pins for
-	 * the Raspberry Pi.
-	 * TODO Better way would be to handle
-	 * this in the device tree!
-	 */
-#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
-#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
-
-	unsigned int *gpio;
-	int pin;
-	gpio = ioremap(GPIO_BASE, SZ_16K);
-
-	/* SPI is on GPIO 7..11 */
-	for (pin = 28; pin <= 31; pin++) {
-		INP_GPIO(pin);		/* set mode to GPIO input first */
-		SET_GPIO_ALT(pin, 2);	/* set mode to ALT 0 */
-	}
-#undef INP_GPIO
-#undef SET_GPIO_ALT
-}
-
 static const struct snd_pcm_hardware bcm2708_pcm_hardware = {
 	.info			= SNDRV_PCM_INFO_INTERLEAVED |
 				  SNDRV_PCM_INFO_JOINT_DUPLEX,
@@ -865,8 +868,6 @@ static int bcm2708_i2s_probe(struct plat
 	if (IS_ERR(dev))
 		return PTR_ERR(dev);
 
-	bcm2708_i2s_setup_gpio();
-
 	dev->i2s_regmap = regmap[0];
 	dev->clk_regmap = regmap[1];