Skip to contentSkip to conversation

ARM: pxa: add support for Raumfeld DDX

PATCH Superseded Daniel Mack 3 participants 9 messages Nov 7, 2011 – Nov 16, 2011

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: pxa: add support for Raumfeld DDX

This new product features a STA32x codec. To support it, some rework of the regulator initialization for the Raumfeld platform is necessary.

Cc Eric Miao <[email protected]>
Cc Mark Brown <[email protected]>
Cc Liam Girdwood <[email protected]>

---

Mark, Liam, Eric - which tree would be good to the this merged?

 arch/arm/mach-pxa/raumfeld.c |  119 +++++++++++++++++---
 sound/soc/pxa/Kconfig        |    2 +
 sound/soc/pxa/raumfeld.c     |  249 +++++++++++++++++++++++++++++++++++++++---
 3 files changed, 338 insertions(+), 32 deletions(-)
arch/arm/mach-pxa/raumfeld.c +101 -18
index 7856fe4..22366ff 100644
@@ -850,7 +850,7 @@ struct regulator_init_data audio_va_initdata = {
 	},
 };
 
-static struct fixed_voltage_config audio_va_config = {
+static struct fixed_voltage_config cs4270_va_config = {
 	.supply_name		= "audio_va",
 	.microvolts		= 5000000,
 	.gpio			= GPIO_AUDIO_VA_ENABLE,
@@ -859,47 +859,114 @@ static struct fixed_voltage_config audio_va_config = {
 	.init_data		= &audio_va_initdata,
 };
 
-static struct platform_device audio_va_device = {
+static struct platform_device cs4270_va_device = {
 	.name	= "reg-fixed-voltage",
 	.id	= 0,
 	.dev	= {
-		.platform_data = &audio_va_config,
+		.platform_data = &cs4270_va_config,
 	},
 };
 
 /* Dummy supplies for Codec's VD/VLC */
 
-static struct regulator_consumer_supply audio_dummy_supplies[] = {
+static struct regulator_consumer_supply cs4270_dummy_supplies[] = {
 	REGULATOR_SUPPLY("vd", "0-0048"),
 	REGULATOR_SUPPLY("vlc", "0-0048"),
 };
 
-struct regulator_init_data audio_dummy_initdata = {
-	.consumer_supplies = audio_dummy_supplies,
-	.num_consumer_supplies = ARRAY_SIZE(audio_dummy_supplies),
+struct regulator_init_data cs4270_dummy_initdata = {
+	.consumer_supplies = cs4270_dummy_supplies,
+	.num_consumer_supplies = ARRAY_SIZE(cs4270_dummy_supplies),
 	.constraints = {
 		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
 	},
 };
 
-static struct fixed_voltage_config audio_dummy_config = {
-	.supply_name		= "audio_vd",
+static struct fixed_voltage_config cs4270_dummy_config = {
+	.supply_name		= "cs4270_vd",
 	.microvolts		= 3300000,
 	.gpio			= -1,
-	.init_data		= &audio_dummy_initdata,
+	.init_data		= &cs4270_dummy_initdata,
 };
 
-static struct platform_device audio_supply_dummy_device = {
+static struct platform_device cs4270_supply_dummy_device = {
 	.name	= "reg-fixed-voltage",
 	.id	= 1,
 	.dev	= {
-		.platform_data = &audio_dummy_config,
+		.platform_data = &cs4270_dummy_config,
 	},
 };
 
-static struct platform_device *audio_regulator_devices[] = {
-	&audio_va_device,
-	&audio_supply_dummy_device,
+static struct platform_device *cs4270_regulator_devices[] = {
+	&cs4270_va_device,
+	&cs4270_supply_dummy_device,
+};
+
+/* Fixed regulator for sta32x Vdda supply
+ * 0-001a maps to the sta32x codec devname (derived from i2c bus num + addr)
+ */
+
+static struct regulator_consumer_supply sta32x_va_consumer_supply =
+	REGULATOR_SUPPLY("Vdda", "0-001a");
+
+struct regulator_init_data sta32x_va_initdata = {
+	.consumer_supplies = &sta32x_va_consumer_supply,
+	.num_consumer_supplies = 1,
+	.constraints = {
+		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
+	},
+};
+
+static struct fixed_voltage_config sta32x_va_config = {
+	.supply_name		= "audio_va",
+	.microvolts		= 3300000,
+	.gpio			= GPIO_AUDIO_VA_ENABLE,
+	.enable_high		= 1,
+	.enabled_at_boot	= 0,
+	.init_data		= &sta32x_va_initdata,
+};
+
+static struct platform_device sta32x_va_device = {
+	.name	= "reg-fixed-voltage",
+	.id	= 0,
+	.dev	= {
+		.platform_data = &sta32x_va_config,
+	},
+};
+
+/* Dummy supplies for sta32x codec's Vdd3/Vcc */
+
+static struct regulator_consumer_supply sta32x_dummy_supplies[] = {
+	REGULATOR_SUPPLY("Vdd3", "0-001a"),
+	REGULATOR_SUPPLY("Vcc", "0-001a"),
+};
+
+struct regulator_init_data sta32x_dummy_initdata = {
+	.consumer_supplies = sta32x_dummy_supplies,
+	.num_consumer_supplies = ARRAY_SIZE(sta32x_dummy_supplies),
+	.constraints = {
+		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
+	},
+};
+
+static struct fixed_voltage_config sta32x_dummy_config = {
+	.supply_name	    = "audio_vd",
+	.microvolts	     = 3300000,
+	.gpio		   = -1,
+	.init_data	      = &sta32x_dummy_initdata,
+};
+
+static struct platform_device sta32x_supply_dummy_device = {
+	.name   = "reg-fixed-voltage",
+	.id     = 1,
+	.dev    = {
+		.platform_data = &sta32x_dummy_config,
+	},
+};
+
+static struct platform_device *sta32x_regulator_devices[] = {
+	&sta32x_va_device,
+	&sta32x_supply_dummy_device,
 };
 
 /**
@@ -948,6 +1015,11 @@ static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
 	.addr	= 0x48,
 };
 
+static struct i2c_board_info raumfeld_ddx_i2c_board_info __initdata = {
+	.type   = "sta326",
+	.addr   = 0x1a,
+};
+
 static struct eeti_ts_platform_data eeti_ts_pdata = {
 	.irq_active_high = 1,
 };
@@ -987,7 +1059,10 @@ static void __init raumfeld_audio_init(void)
 	else
 		gpio_direction_output(GPIO_MCLK_RESET, 1);
 
-	platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
+	if ((system_rev & 0xff00) == 0x0400)
+		platform_add_devices(ARRAY_AND_SIZE(sta32x_regulator_devices));
+	else
+		platform_add_devices(ARRAY_AND_SIZE(cs4270_regulator_devices));
 }
 
 static void __init raumfeld_common_init(void)
@@ -1060,7 +1135,11 @@ static void __init raumfeld_connector_init(void)
 {
 	pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_connector_pin_config));
 	spi_register_board_info(ARRAY_AND_SIZE(connector_spi_devices));
-	i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
+
+	if ((system_rev & 0xff00) == 0x0400)
+		i2c_register_board_info(0, &raumfeld_ddx_i2c_board_info, 1);
+	else
+		i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
 
 	platform_device_register(&smc91x_device);
 
@@ -1072,7 +1151,11 @@ static void __init raumfeld_speaker_init(void)
 {
 	pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_speaker_pin_config));
 	spi_register_board_info(ARRAY_AND_SIZE(speaker_spi_devices));
-	i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
+
+	if ((system_rev & 0xff00) == 0x0400)
+		i2c_register_board_info(0, &raumfeld_ddx_i2c_board_info, 1);
+	else
+		i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1);
 
 	platform_device_register(&smc91x_device);
 	platform_device_register(&rotary_encoder_device);
sound/soc/pxa/Kconfig +2 -0
index 33ebc46..e6db56a 100644
@@ -152,6 +152,8 @@ config SND_SOC_RAUMFELD
 	select SND_PXA_SOC_SSP
 	select SND_SOC_CS4270
 	select SND_SOC_AK4104
+	select SND_SOC_STA32X
+	select SND_SOC_WM8782
 	help
 	  Say Y if you want to add support for SoC audio on Raumfeld devices
 
sound/soc/pxa/raumfeld.c +235 -14

300 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#1 lore raw
Quoted 3 lines · Daniel Mack
 arch/arm/mach-pxa/raumfeld.c |  119 +++++++++++++++++---
 sound/soc/pxa/Kconfig        |    2 +
 sound/soc/pxa/raumfeld.c     |  249 +++++++++++++++++++++++++++++++++++++++---

Is there any cross dependency between these bits? I honestly didn't notice the ASoC bit in here...

sound/soc/pxa/Kconfig config SND_SOC_RAUMFELD · line 156

Quoted 9 lines

index 33ebc46..e6db56a 100644

sound/soc/pxa/Kconfig +2 -0
@@ -152,6 +152,8 @@ config SND_SOC_RAUMFELD
 	select SND_PXA_SOC_SSP
 	select SND_SOC_CS4270
 	select SND_SOC_AK4104
+	select SND_SOC_STA32X
+	select SND_SOC_WM8782

Is this really a single driver? Looking at the code it looks like there's little if any code sharing between the different machines, it'd help with maintainability to have multiple simple drivers.

sound/soc/pxa/Kconfig config SND_SOC_RAUMFELD

Quoted 8 lines
sound/soc/pxa/Kconfig +8 -0
+	/* PXA DMA cannot do zero extend for 24bit samples,
+	* thus only 16bit (two samples packet into 32bit word)
+	* or 32bit samples are possible
+	*/
+	snd_pcm_hw_constraint_mask64(substream->runtime,
+				    SNDRV_PCM_HW_PARAM_FORMAT,
+				    SNDRV_PCM_FMTBIT_S16_LE  | SNDRV_PCM_FMTBIT_S16_BE |
+				    SNDRV_PCM_FMTBIT_S32_LE  | SNDRV_PCM_FMTBIT_S32_BE);

If the PXA DMA controller can't do 24 bit audio it should be imposing this constraint.

sound/soc/pxa/Kconfig

Quoted 8 lines
sound/soc/pxa/Kconfig +8 -0
+static void raumfeld_sta32x_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	/* set freq to 0 to enable all possible codec sample rates */
+	snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
+}

Are you sure this does the right thing with simultaneous playback and record?

sound/soc/pxa/Kconfig

Quoted 3 lines
sound/soc/pxa/Kconfig +3 -0
+	fmt = SND_SOC_DAIFMT_I2S |
+	      SND_SOC_DAIFMT_NB_NF |
+	      SND_SOC_DAIFMT_CBS_CFS;

Set this using dai_fmt in hte machine driver.

#2 lore raw
Quoted 7 lines · Mark Brown
Quoted 3 lines · Daniel Mack
 arch/arm/mach-pxa/raumfeld.c |  119 +++++++++++++++++---
 sound/soc/pxa/Kconfig        |    2 +
 sound/soc/pxa/raumfeld.c     |  249 +++++++++++++++++++++++++++++++++++++++---

Is there any cross dependency between these bits?

You're right - I assumed there are, but it seems that I was mistaken. I'll split this up and re-submit, so it can go trhough appropriate channels.

Quoted 2 lines

I honestly didn't
notice the ASoC bit in here...

That's at least parially my fault, as something in my work flow crippled the email addresses in the patch, so git send-email didn't actually put you on Cc:.

Quoted 5 lines
Quoted 5 lines

index 33ebc46..e6db56a 100644

sound/soc/pxa/Kconfig +0 -0
@@ -152,6 +152,8 @@ config SND_SOC_RAUMFELD
 	select SND_PXA_SOC_SSP
Quoted 8 lines

sound/soc/pxa/Kconfig config SND_SOC_RAUMFELD · line 156

Quoted 4 lines
sound/soc/pxa/Kconfig +2 -0
 	select SND_SOC_CS4270
 	select SND_SOC_AK4104
+	select SND_SOC_STA32X
+	select SND_SOC_WM8782

Is this really a single driver? Looking at the code it looks like there's little if any code sharing between the different machines, it'd help with maintainability to have multiple simple drivers.

Hmm. This new version of Raumfeld's hardware features a new ADC and DAC, and the configuration to use is determined by looking at the system revision. If this would be split into multiple smaller drivers, there would be need for a 'master' to dispatch the possible options. I think I'll do that once the next generation is about to land, and leave it as it is for now. Ok for you?

Quoted 12 lines

sound/soc/pxa/Kconfig config SND_SOC_RAUMFELD

Quoted 9 lines
sound/soc/pxa/Kconfig +8 -0
+	/* PXA DMA cannot do zero extend for 24bit samples,
+	* thus only 16bit (two samples packet into 32bit word)
+	* or 32bit samples are possible
+	*/
+	snd_pcm_hw_constraint_mask64(substream->runtime,
+				    SNDRV_PCM_HW_PARAM_FORMAT,
+				    SNDRV_PCM_FMTBIT_S16_LE  | SNDRV_PCM_FMTBIT_S16_BE |
+				    SNDRV_PCM_FMTBIT_S32_LE  | SNDRV_PCM_FMTBIT_S32_BE);

If the PXA DMA controller can't do 24 bit audio it should be imposing this constraint.

Right. Will fix this in the CPU DAI.

Quoted 11 lines

sound/soc/pxa/Kconfig

Quoted 8 lines
sound/soc/pxa/Kconfig +8 -0
+static void raumfeld_sta32x_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	/* set freq to 0 to enable all possible codec sample rates */
+	snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
+}

Are you sure this does the right thing with simultaneous playback and record?

Yes, this works fine. We use this code since awhile already.

Quoted 5 lines

sound/soc/pxa/Kconfig

Quoted 3 lines
sound/soc/pxa/Kconfig +3 -0
+	fmt = SND_SOC_DAIFMT_I2S |
+	      SND_SOC_DAIFMT_NB_NF |
+	      SND_SOC_DAIFMT_CBS_CFS;

Set this using dai_fmt in hte machine driver.

Can you elaborate on this one? I couldn't find an example for this, sorry.

Daniel

#3 lore raw
Quoted 10 lines · Daniel Mack
Quoted 3 lines · Mark Brown

Is this really a single driver? Looking at the code it looks like there's little if any code sharing between the different machines, it'd help with maintainability to have multiple simple drivers.

Hmm. This new version of Raumfeld's hardware features a new ADC and DAC, and the configuration to use is determined by looking at the system revision. If this would be split into multiple smaller drivers, there would be need for a 'master' to dispatch the possible options. I think

No, not really.

Quoted 2 lines

I'll do that once the next generation is about to land, and leave it as it is for now. Ok for you?

What I'd expect here is that the arch/arm code would register a different platform device depending on which board it's running on (though actually controlling I2C device registration is enough as ASoC won't probe the sound driver until the components appear).

Quoted 7 lines
Quoted 5 lines

sound/soc/pxa/raumfeld.c static struct snd_soc_ops raumfeld_ak4104_ops = { · line 309

Quoted 3 lines
sound/soc/pxa/raumfeld.c +3 -0
+	fmt = SND_SOC_DAIFMT_I2S |
+	      SND_SOC_DAIFMT_NB_NF |
+	      SND_SOC_DAIFMT_CBS_CFS;

Set this using dai_fmt in hte machine driver.

Can you elaborate on this one? I couldn't find an example for this, sorry.

Look at the snd_soc_dai_link definition, and things like speyside.

#4 lore raw
Quoted 14 lines · Mark Brown
Quoted 10 lines · Daniel Mack
Quoted 3 lines · Mark Brown

Is this really a single driver? Looking at the code it looks like there's little if any code sharing between the different machines, it'd help with maintainability to have multiple simple drivers.

Hmm. This new version of Raumfeld's hardware features a new ADC and DAC, and the configuration to use is determined by looking at the system revision. If this would be split into multiple smaller drivers, there would be need for a 'master' to dispatch the possible options. I think

No, not really.

Quoted 7 lines
Quoted 2 lines

I'll do that once the next generation is about to land, and leave it as it is for now. Ok for you?

What I'd expect here is that the arch/arm code would register a different platform device depending on which board it's running on (though actually controlling I2C device registration is enough as ASoC won't probe the sound driver until the components appear).

Ok, I can do this. However, the two driver will share some logic wrt GPIO lines that put the codecs into reset. But ok, we can live with that I guess, as it in fact makes the driver smaller and easier to read.

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

sound/soc/pxa/raumfeld.c static struct snd_soc_ops raumfeld_ak4104_ops = { · line 309

Quoted 3 lines
sound/soc/pxa/raumfeld.c +3 -0
+	fmt = SND_SOC_DAIFMT_I2S |
+	      SND_SOC_DAIFMT_NB_NF |
+	      SND_SOC_DAIFMT_CBS_CFS;

Set this using dai_fmt in hte machine driver.

Can you elaborate on this one? I couldn't find an example for this, sorry.

Look at the snd_soc_dai_link definition, and things like speyside.

Sorry, I still don't get it. All implementations I can find call snd_soc_dai_set_fmt() for the cpu and codec dais from the .ops->hw_params function they reference from their snd_soc_dai_links. Just like this new code does as well. What am I missing?

Thanks for your review,

Daniel

#5 lore raw
Quoted 10 lines · Daniel Mack
Quoted 4 lines · Mark Brown

What I'd expect here is that the arch/arm code would register a different platform device depending on which board it's running on (though actually controlling I2C device registration is enough as ASoC won't probe the sound driver until the components appear).

Ok, I can do this. However, the two driver will share some logic wrt GPIO lines that put the codecs into reset. But ok, we can live with that I guess, as it in fact makes the driver smaller and easier to read.

Hrm, I'd expect that that logic would be in the CODEC drivers - they really do need to know that their registers went away.

Quoted 6 lines
Quoted 1 line

Look at the snd_soc_dai_link definition, and things like speyside.

Sorry, I still don't get it. All implementations I can find call snd_soc_dai_set_fmt() for the cpu and codec dais from the .ops->hw_params function they reference from their snd_soc_dai_links. Just like this new code does as well. What am I missing?

Are you *sure* you're looking at current code? The dai_fmt field isn't that obscurely named...

#6 lore raw
Quoted 8 lines · Mark Brown
Quoted 4 lines · Daniel Mack

Sorry, I still don't get it. All implementations I can find call snd_soc_dai_set_fmt() for the cpu and codec dais from the .ops->hw_params function they reference from their snd_soc_dai_links. Just like this new code does as well. What am I missing?

Are you *sure* you're looking at current code? The dai_fmt field isn't that obscurely named...

Grrr. Sorry for that. We're based on 3.1 here, I should have noticed. I'll rebase, do all necessary cleanups and resubmit.

Daniel

#7 lore raw
In reply to Daniel Mack
Quoted 15 lines · Daniel Mack
Quoted 13 lines · Mark Brown

sound/soc/pxa/raumfeld.c static struct snd_soc_ops raumfeld_ak4104_ops = { · line 250

Quoted 8 lines · Daniel Mack
sound/soc/pxa/raumfeld.c +8 -0
+	/* PXA DMA cannot do zero extend for 24bit samples,
+	* thus only 16bit (two samples packet into 32bit word)
+	* or 32bit samples are possible
+	*/
+	snd_pcm_hw_constraint_mask64(substream->runtime,
+				    SNDRV_PCM_HW_PARAM_FORMAT,
+				    SNDRV_PCM_FMTBIT_S16_LE  | SNDRV_PCM_FMTBIT_S16_BE |
+				    SNDRV_PCM_FMTBIT_S32_LE  | SNDRV_PCM_FMTBIT_S32_BE);

If the PXA DMA controller can't do 24 bit audio it should be imposing this constraint.

Quoted 1 line

Right. Will fix this in the CPU DAI.

IIRC the PXA can handle 24bit audio, and the STA32x can handle it, too. However due to constraints in the clock ratios on the Raumfeld board this mode cannot be used. Thus this constraint is in sound/soc/pxa/raumfeld.c.

Does that make sense? It's been a while since I worked on this code, maybe I misremember. And I failed to mention it in the code comment :-(

Johannes

#8 lore raw
Quoted 3 lines · Johannes Stezenbach

IIRC the PXA can handle 24bit audio, and the STA32x can handle it, too. However due to constraints in the clock ratios on the Raumfeld board this mode cannot be used. Thus this constraint is in sound/soc/pxa/raumfeld.c.

If that's the case then the comment needs to be updated as currently what it says is that this is a CPU side limitation.