Skip to contentSkip to conversation

ASoC: Intel: add sof_pcm512x machine driver

PATCH In review Pierre-Louis Bossart 2 participants 8 messages Jan 29, 2020 – Jan 30, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Intel: add sof_pcm512x machine driver

This is an overdue upstream contribution for a platform used by nearly all SOF developers at Intel as well as the SOF CI.

While I was the initial author in 2018, these patches were updated and improved by Xiuli Pan, Ranjani Sridharan, Kai Vehmanen and Guennadi Liakhovetski who worked on the last clean-ups. Thanks y'all.

Full disclosure on the Cherrytrail/Up support: the board will only be detected with specific pin-configurations that are not handled by the mainline kernel just yet.

Pierre-Louis Bossart (3):
ASoC: Intel: sof_pcm512x: add support for SOF platforms with pcm512x
ASoC: Intel: BXT: switch pcm512x based boards to sof_pcm512x
ASoC: Intel: CHT: add support for pcm512x boards

 sound/soc/intel/boards/Kconfig                |  14 +
 sound/soc/intel/boards/Makefile               |   2 +
 sound/soc/intel/boards/sof_pcm512x.c          | 428 ++++++++++++++++++
 .../intel/common/soc-acpi-intel-bxt-match.c   |   2 +-
 .../intel/common/soc-acpi-intel-cht-match.c   |   7 +
 5 files changed, 452 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/boards/sof_pcm512x.c
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw

PATCH 1/3 ASoC: Intel: sof_pcm512x: add support for SOF platforms with pcm512x

Add support for multiple platforms, e.g. Apollolake based, using the pcm512x audio codec.

The SOF developers and CI rely on the Up^2 and Hifiberry DAC+ boards based on this codec for tests.

---
 sound/soc/intel/boards/Kconfig       |  14 +
 sound/soc/intel/boards/Makefile      |   2 +
 sound/soc/intel/boards/sof_pcm512x.c | 428 +++++++++++++++++++++++++++
 3 files changed, 444 insertions(+)
 create mode 100644 sound/soc/intel/boards/sof_pcm512x.c
sound/soc/intel/boards/Kconfig +14 -0
index 9ca2567d0059..755e1de19df9 100644
@@ -457,6 +457,20 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
 	   with rt5682 codec.
 	   Say Y if you have such a device.
 	   If unsure select "N".
+
+config SND_SOC_INTEL_SOF_PCM512x_MACH
+	tristate "SOF with TI PCM512x codec"
+	depends on I2C && ACPI
+	depends on (SND_SOC_SOF_HDA_AUDIO_CODEC && (MFD_INTEL_LPSS || COMPILE_TEST)) ||\
+		   (SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST))
+	select SND_SOC_PCM512x_I2C
+	select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC
+	help
+	  This adds support for ASoC machine driver for SOF platforms
+	  with TI PCM512x I2S audio codec.
+	  Say Y or m if you have such a device.
+	  If unsure select "N".
+
 endif ## SND_SOC_SOF_HDA_LINK || SND_SOC_SOF_BAYTRAIL
 
 if (SND_SOC_SOF_COMETLAKE_LP && SND_SOC_SOF_HDA_LINK)
sound/soc/intel/boards/Makefile +2 -0
index b74ddd49bd39..781e7ec58e47 100644
@@ -7,6 +7,7 @@ snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o hda_dsp_common.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o hda_dsp_common.o
+snd-soc-sst-sof-pcm512x-objs := sof_pcm512x.o hda_dsp_common.o
 snd-soc-sst-glk-rt5682_max98357a-objs := glk_rt5682_max98357a.o hda_dsp_common.o
 snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o
 snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o
@@ -37,6 +38,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
+obj-$(CONFIG_SND_SOC_INTEL_SOF_PCM512x_MACH) += snd-soc-sst-sof-pcm512x.o
 obj-$(CONFIG_SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH) += snd-soc-sst-glk-rt5682_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
 obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5650_MACH) += snd-soc-sst-bdw-rt5650-mach.o
sound/soc/intel/boards/sof_pcm512x.c new file +428 -0

428 lines not on this page · raw message

Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#2 lore raw

Re: [alsa-devel] [PATCH 1/3] ASoC: Intel: sof_pcm512x: add support for SOF platforms with pcm512x

sound/soc/intel/boards/sof_pcm512x.c line 89

Quoted 8 lines · Pierre-Louis Bossart
sound/soc/intel/boards/sof_pcm512x.c new file +8 -0
+static int sof_pcm512x_codec_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_component *codec = rtd->codec_dai->component;
+
+	snd_soc_component_update_bits(codec, PCM512x_GPIO_EN, 0x08, 0x08);
+	snd_soc_component_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
+	snd_soc_component_update_bits(codec, PCM512x_GPIO_CONTROL_1,
+				      0x08, 0x08);

These look like they might be a DAPM widget of some kind?

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw

Re: [alsa-devel] [PATCH 1/3] ASoC: Intel: sof_pcm512x: add support for SOF platforms with pcm512x

Thanks for the review Mark,

Quoted 10 lines

sound/soc/intel/boards/sof_pcm512x.c line 89

Quoted 8 lines
sound/soc/intel/boards/sof_pcm512x.c new file +8 -0
+static int sof_pcm512x_codec_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_component *codec = rtd->codec_dai->component;
+
+	snd_soc_component_update_bits(codec, PCM512x_GPIO_EN, 0x08, 0x08);
+	snd_soc_component_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0x0f, 0x02);
+	snd_soc_component_update_bits(codec, PCM512x_GPIO_CONTROL_1,
+				      0x08, 0x08);

These look like they might be a DAPM widget of some kind?

it's the LED support only, turned on when you play and off when you stop.
At some point, I added a gpiochip support in the PCM152x codec driver to avoid doing this, and have a nicer way of toggling the gpios. Due to lack of time, I didn't maintain this solution, but we could add it in a follow-up version if that was desired. It's really not the main functionality of this patch. -Pierre
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#4 lore raw

Re: [alsa-devel] [PATCH 1/3] ASoC: Intel: sof_pcm512x: add support for SOF platforms with pcm512x

Quoted 8 lines · Pierre-Louis Bossart
Quoted 1 line

These look like they might be a DAPM widget of some kind?

it's the LED support only, turned on when you play and off when you stop. At some point, I added a gpiochip support in the PCM152x codec driver to avoid doing this, and have a nicer way of toggling the gpios. Due to lack of time, I didn't maintain this solution, but we could add it in a follow-up version if that was desired. It's really not the main functionality of this patch.

Followup seems fine.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw

Re: [alsa-devel] [PATCH 1/3] ASoC: Intel: sof_pcm512x: add support for SOF platforms with pcm512x

Quoted 4 lines · Mark Brown
Quoted 1 line · Pierre-Louis Bossart
Quoted 1 line

These look like they might be a DAPM widget of some kind?

Quoted 8 lines
Quoted 6 lines

it's the LED support only, turned on when you play and off when you stop. At some point, I added a gpiochip support in the PCM152x codec driver to avoid doing this, and have a nicer way of toggling the gpios. Due to lack of time, I didn't maintain this solution, but we could add it in a follow-up version if that was desired. It's really not the main functionality of this patch.

Followup seems fine.

ok, will work on it, I haven't changed the code since December 2018
https://github.com/plbossart/sound/commits/hifiberry/gpios

Another thing I didn't complete is the support for the codec master mode, which would be needed for the Hifiberry DAC+ PRO versions (they have 2 oscillators for 44.1 and 48kHz support). It's a bit of a chicken-and-egg, during the probe the codec driver requests an mclk but in the case of the hifiberry the mclk is actually enabled at the codec level with a GPIO selection. I never found a clean way to do this, or an example where the clock consumer is also the clock provider. So far we only use these PRO boards in codec slave mode, which is a bit of a waste. For once we have good clocks, we should really use them...
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#6 lore raw

PATCH 2/3 ASoC: Intel: BXT: switch pcm512x based boards to sof_pcm512x

In reply to Pierre-Louis Bossart

Switch over Broxton platforms with the pcm512x codec from the legacy bxt-pcm512x to the new sof_pcm512x machine driver.

---
 sound/soc/intel/common/soc-acpi-intel-bxt-match.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/common/soc-acpi-intel-bxt-match.c +1 -1
index 4a5adae1d785..f5092bc48364 100644
@@ -65,7 +65,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_bxt_machines[] = {
 	},
 	{
 		.id = "104C5122",
-		.drv_name = "bxt-pcm512x",
+		.drv_name = "sof_pcm512x",
 		.sof_fw_filename = "sof-apl.ri",
 		.sof_tplg_filename = "sof-apl-pcm512x.tplg",
 	},
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#7 lore raw

PATCH 3/3 ASoC: Intel: CHT: add support for pcm512x boards

In reply to Pierre-Louis Bossart

Add support for Cherrytrail boards, using the pcm512x audio codec using the new sof_pcm512x machine driver.

---
 sound/soc/intel/common/soc-acpi-intel-cht-match.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/intel/common/soc-acpi-intel-cht-match.c +7 -0
index d0fb43c2b9f6..2752dc955733 100644
@@ -174,6 +174,13 @@ struct snd_soc_acpi_mach  snd_soc_acpi_intel_cherrytrail_machines[] = {
 		.sof_fw_filename = "sof-cht.ri",
 		.sof_tplg_filename = "sof-cht-cx2072x.tplg",
 	},
+	{
+		.id = "104C5122",
+		.drv_name = "sof_pcm512x",
+		.sof_fw_filename = "sof-cht.ri",
+		.sof_tplg_filename = "sof-cht-src-50khz-pcm512x.tplg",
+	},
+
 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
 	/*
 	 * This is always last in the table so that it is selected only when
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel