@@ -305,6 +305,31 @@ static int bcm2708_i2s_set_dai_bclk_ratio(struct snd_soc_dai *dai,
305
305
return 0 ;
306
306
}
307
307
308
+
309
+ static void bcm2708_i2s_setup_gpio (void )
310
+ {
311
+ /*
312
+ * This is the common way to handle the GPIO pins for
313
+ * the Raspberry Pi.
314
+ * TODO Better way would be to handle
315
+ * this in the device tree!
316
+ */
317
+ #define INP_GPIO (g ) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
318
+ #define SET_GPIO_ALT (g ,a ) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
319
+
320
+ unsigned int * gpio ;
321
+ int pin ;
322
+ gpio = ioremap (GPIO_BASE , SZ_16K );
323
+
324
+ /* SPI is on GPIO 7..11 */
325
+ for (pin = 28 ; pin <= 31 ; pin ++ ) {
326
+ INP_GPIO (pin ); /* set mode to GPIO input first */
327
+ SET_GPIO_ALT (pin , 2 ); /* set mode to ALT 0 */
328
+ }
329
+ #undef INP_GPIO
330
+ #undef SET_GPIO_ALT
331
+ }
332
+
308
333
static int bcm2708_i2s_hw_params (struct snd_pcm_substream * substream ,
309
334
struct snd_pcm_hw_params * params ,
310
335
struct snd_soc_dai * dai )
@@ -334,6 +359,9 @@ static int bcm2708_i2s_hw_params(struct snd_pcm_substream *substream,
334
359
if (csreg & (BCM2708_I2S_TXON | BCM2708_I2S_RXON ))
335
360
return 0 ;
336
361
362
+
363
+ bcm2708_i2s_setup_gpio ();
364
+
337
365
/*
338
366
* Adjust the data length according to the format.
339
367
* We prefill the half frame length with an integer
@@ -790,31 +818,6 @@ static const struct snd_soc_component_driver bcm2708_i2s_component = {
790
818
.name = "bcm2708-i2s-comp" ,
791
819
};
792
820
793
-
794
- static void bcm2708_i2s_setup_gpio (void )
795
- {
796
- /*
797
- * This is the common way to handle the GPIO pins for
798
- * the Raspberry Pi.
799
- * TODO Better way would be to handle
800
- * this in the device tree!
801
- */
802
- #define INP_GPIO (g ) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
803
- #define SET_GPIO_ALT (g ,a ) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
804
-
805
- unsigned int * gpio ;
806
- int pin ;
807
- gpio = ioremap (GPIO_BASE , SZ_16K );
808
-
809
- /* SPI is on GPIO 7..11 */
810
- for (pin = 28 ; pin <= 31 ; pin ++ ) {
811
- INP_GPIO (pin ); /* set mode to GPIO input first */
812
- SET_GPIO_ALT (pin , 2 ); /* set mode to ALT 0 */
813
- }
814
- #undef INP_GPIO
815
- #undef SET_GPIO_ALT
816
- }
817
-
818
821
static const struct snd_pcm_hardware bcm2708_pcm_hardware = {
819
822
.info = SNDRV_PCM_INFO_INTERLEAVED |
820
823
SNDRV_PCM_INFO_JOINT_DUPLEX ,
@@ -865,8 +868,6 @@ static int bcm2708_i2s_probe(struct platform_device *pdev)
865
868
if (IS_ERR (dev ))
866
869
return PTR_ERR (dev );
867
870
868
- bcm2708_i2s_setup_gpio ();
869
-
870
871
dev -> i2s_regmap = regmap [0 ];
871
872
dev -> clk_regmap = regmap [1 ];
872
873
0 commit comments