Skip to contentSkip to conversation

BYT/CHT clocks/max98090 updates

PATCH In review Pierre-Louis Bossart 4 participants 20 messages Sep 8, 2017 – Sep 19, 2017

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

cover BYT/CHT clocks/max98090 updates

This patchset corrects issues with an earlier submission (missing signoffs, error case not consistent) and enables the cht_bsw_max98090 machine driver on Baytrail. This should help distributions solve problems with Baytrail Chromebooks which required a specific build. These patches were tested on Lenovo 100s ('orco'/Baytrail) and Acer R11 ('cyan'/Cherrytrail), using the same build based on CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH=m. Playback on speakers/headphone and capture from internal mic work fine. UCM files are available at
https://github.com/plbossart/UCM/tree/master/byt-max98090

Thanks to Jarkko Nikula and Andy Shevchenko for their comments on an initial version reviewed internally at Intel.

Fang, Yang A (1):
ASoC: ts3a227e: add acpi table

Pierre-Louis Bossart (5):
ASoC: max98090: reduce verbosity on PLL unlock
ASoC: Intel: cht_bsw_max98090: Fix I2S config + unused code
ASoC: Intel: cht_bsw_max98090: add support for Baytrail
ASoC: Intel: atom: use cht_bsw_max98090 for Baytrail Chromebooks
ASoC: Intel: cht_bsw_max98090: add gpio-based jack detection

Thierry Escande (1):
ASoc: Intel: cht_bsw_max98090_ti: Fix jack initialization

 sound/soc/codecs/max98090.c                  |   2 +-
 sound/soc/codecs/ts3a227e.c                  |  10 ++
 sound/soc/intel/atom/sst/sst_acpi.c          |   8 ++
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 185 ++++++++++++++++++++++++---
 4 files changed, 186 insertions(+), 19 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/7 ASoC: max98090: reduce verbosity on PLL unlock

'commit b8a3ee820f7b ("ASoC: max98090: Add recovery for PLL lock failure")' enabled a workaround PLL unlocked issues, but generates annoying dev_info "PLL unlocked" messages at a 10ms rate, usually on startup.

Move to dev_info_ratelimited. This issue doesn't seem to impact audio functionality. This trace is commented out in the GalliumOS patches, it's better to keep it to check on potential quality issues

Tested on Lenovo 100s (Baytrail Chromebook)

---
 sound/soc/codecs/max98090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/max98090.c +1 -1
index 13bcfb1..f5075d1 100644
@@ -2115,7 +2115,7 @@ static void max98090_pll_work(struct work_struct *work)
 	if (!snd_soc_codec_is_active(codec))
 		return;
 
-	dev_info(codec->dev, "PLL unlocked\n");
+	dev_info_ratelimited(codec->dev, "PLL unlocked\n");
 
 	/* Toggle shutdown OFF then ON */
 	snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN,
Signature · 1 line
2.9.3
maintainer
#2 lore raw

Applied "ASoC: max98090: reduce verbosity on PLL unlock" to the asoc tree

The patch

ASoC: max98090: reduce verbosity on PLL unlock

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From d10a7d3e2af98e639e74c64185f910915a560f07 Mon Sep 17 00:00:00 2001

From: Pierre-Louis Bossart <[email protected]>
Date: Fri, 8 Sep 2017 00:13:03 -0500
Subject: [PATCH] ASoC: max98090: reduce verbosity on PLL unlock

'commit b8a3ee820f7b ("ASoC: max98090: Add recovery for PLL lock failure")' enabled a workaround PLL unlocked issues, but generates annoying dev_info "PLL unlocked" messages at a 10ms rate, usually on startup.

Move to dev_info_ratelimited. This issue doesn't seem to impact audio functionality. This trace is commented out in the GalliumOS patches, it's better to keep it to check on potential quality issues

Tested on Lenovo 100s (Baytrail Chromebook)

---
 sound/soc/codecs/max98090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/max98090.c +1 -1
index 13bcfb1ef9b4..f5075d1f79e6 100644
@@ -2115,7 +2115,7 @@ static void max98090_pll_work(struct work_struct *work)
 	if (!snd_soc_codec_is_active(codec))
 		return;
 
-	dev_info(codec->dev, "PLL unlocked\n");
+	dev_info_ratelimited(codec->dev, "PLL unlocked\n");
 
 	/* Toggle shutdown OFF then ON */
 	snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN,
Signature · 1 line
2.14.1
#3 lore raw

PATCH 2/7 ASoC: Intel: cht_bsw_max98090: Fix I2S config + unused code

In reply to Pierre-Louis Bossart

This driver probably never worked, the slots are configured for 2ch 16 bit and the SSP2 as 24 bits, the cpu_dai configured as LEFT_J and the codec_dai as I2S.

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +3 -3
index 20755ec..455a55a 100644
@@ -160,7 +160,7 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 		return ret;
 	}
 
-	fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF
+	fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBS_CFS;
 
 	ret = snd_soc_dai_set_fmt(rtd->cpu_dai, fmt);
@@ -173,8 +173,8 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 	rate->min = rate->max = 48000;
 	channels->min = channels->max = 2;
 
-	/* set SSP2 to 24-bit */
-	params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
+	/* set SSP2 to 16-bit */
+	params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
 }
 
Signature · 1 line
2.9.3
#4 lore raw

PATCH 3/7 ASoC: Intel: cht_bsw_max98090: add support for Baytrail

In reply to Pierre-Louis Bossart

Distributions such as Fedora, Ubuntu and Gallium don't currently have a means to support Baytrail Chromebooks and other platforms with the same build [1][2] due to incompatible platform drivers.

Add MCLK management to reuse this machine driver for Baytrail platforms and solve this coexistence problem at last. UCM files are provided at [3] and will eventually be submitted to the new repo.

The legacy byt-max98090 machine driver is still maintained but can only be used when the other Atom/DPCM driver is not compiled in, or when users don't want to configure extra mixers required by the Atom/sst driver.

Tested on Lenovo 100s Baytrail Chromebook w/ Mr. Chromebox BOOT_STUB firmware and Acer R11 Cherrytrail Chromebook

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1335196
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2016-August/
111641.html
[3] https://github.com/plbossart/UCM/tree/master/byt-max98090

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 78 ++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +78 -0
index 455a55a..01bacca 100644
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
@@ -35,15 +36,60 @@
 #define CHT_CODEC_DAI	"HiFi"
 
 struct cht_mc_private {
+	struct clk *mclk;
 	struct snd_soc_jack jack;
 	bool ts3a227e_present;
 };
 
+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
+			     strlen(CHT_CODEC_DAI)))
+			return rtd->codec_dai;
+	}
+	return NULL;
+}
+
+static int platform_clock_control(struct snd_soc_dapm_widget *w,
+					  struct snd_kcontrol *k, int  event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai;
+	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
+	int ret;
+
+	codec_dai = cht_get_codec_dai(card);
+	if (!codec_dai) {
+		dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
+		return -EIO;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = clk_prepare_enable(ctx->mclk);
+		if (ret < 0) {
+			dev_err(card->dev,
+				"could not configure MCLK state");
+			return ret;
+		}
+	} else {
+		clk_disable_unprepare(ctx->mclk);
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget cht_dapm_widgets[] = {
 	SND_SOC_DAPM_HP("Headphone", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
 	SND_SOC_DAPM_MIC("Int Mic", NULL),
 	SND_SOC_DAPM_SPK("Ext Spk", NULL),
+	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
+			    platform_clock_control, SND_SOC_DAPM_PRE_PMU |
+			    SND_SOC_DAPM_POST_PMD),
 };
 
 static const struct snd_soc_dapm_route cht_audio_map[] = {
@@ -60,6 +106,10 @@ static const struct snd_soc_dapm_route cht_audio_map[] = {
 	{"codec_in0", NULL, "ssp2 Rx" },
 	{"codec_in1", NULL, "ssp2 Rx" },
 	{"ssp2 Rx", NULL, "HiFi Capture"},
+	{"Headphone", NULL, "Platform Clock"},
+	{"Headset Mic", NULL, "Platform Clock"},
+	{"Int Mic", NULL, "Platform Clock"},
+	{"Ext Spk", NULL, "Platform Clock"},
 };
 
 static const struct snd_kcontrol_new cht_mc_controls[] = {
@@ -141,6 +191,25 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 	if (ctx->ts3a227e_present)
 		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
 
+	/*
+	 * The firmware might enable the clock at
+	 * boot (this information may or may not
+	 * be reflected in the enable clock register).
+	 * To change the rate we must disable the clock
+	 * first to cover these cases. Due to common
+	 * clock framework restrictions that do not allow
+	 * to disable a clock that has not been enabled,
+	 * we need to enable the clock first.
+	 */
+	ret = clk_prepare_enable(ctx->mclk);
+	if (!ret)
+		clk_disable_unprepare(ctx->mclk);
+
+	ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ);
+
+	if (ret)
+		dev_err(runtime->dev, "unable to set MCLK rate\n");
+
 	return ret;
 }
 
@@ -294,6 +363,15 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	/* register the soc card */
 	snd_soc_card_cht.dev = &pdev->dev;
 	snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
+
+	drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
+	if (IS_ERR(drv->mclk)) {
+		dev_err(&pdev->dev,
+			"Failed to get MCLK from pmc_plt_clk_3: %ld\n",
+			PTR_ERR(drv->mclk));
+		return PTR_ERR(drv->mclk);
+	}
+
 	ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
 	if (ret_val) {
 		dev_err(&pdev->dev,
Signature · 1 line
2.9.3
#5 lore raw

Re: [PATCH 3/7] ASoC: Intel: cht_bsw_max98090: add support for Baytrail

Quoted 26 lines · Pierre-Louis Bossart

Distributions such as Fedora, Ubuntu and Gallium don't currently have a means to support Baytrail Chromebooks and other platforms with the same build [1][2] due to incompatible platform drivers.

Add MCLK management to reuse this machine driver for Baytrail platforms and solve this coexistence problem at last. UCM files are provided at [3] and will eventually be submitted to the new repo.

The legacy byt-max98090 machine driver is still maintained but can only be used when the other Atom/DPCM driver is not compiled in, or when users don't want to configure extra mixers required by the Atom/sst driver.

Tested on Lenovo 100s Baytrail Chromebook w/ Mr. Chromebox BOOT_STUB firmware and Acer R11 Cherrytrail Chromebook

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1335196
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2016-August/
111641.html
[3] https://github.com/plbossart/UCM/tree/master/byt-max98090

+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)

sound/soc/intel/boards/cht_bsw_max98090_ti.c line 50

Quoted 6 lines
sound/soc/intel/boards/cht_bsw_max98090_ti.c +6 -0
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
+			     strlen(CHT_CODEC_DAI)))

Same comments as per another patch series wrt str_n_cmp() use.

Quoted 3 lines
sound/soc/intel/boards/cht_bsw_max98090_ti.c +3 -0
+			return rtd->codec_dai;
+	}
+	return NULL;
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#6 lore raw

Re: [PATCH 3/7] ASoC: Intel: cht_bsw_max98090: add support for Baytrail

Quoted 25 lines · Andy Shevchenko
Quoted 24 lines · Pierre-Louis Bossart

Distributions such as Fedora, Ubuntu and Gallium don't currently have a means to support Baytrail Chromebooks and other platforms with the same build [1][2] due to incompatible platform drivers.

Add MCLK management to reuse this machine driver for Baytrail platforms and solve this coexistence problem at last. UCM files are provided at [3] and will eventually be submitted to the new repo.

The legacy byt-max98090 machine driver is still maintained but can only be used when the other Atom/DPCM driver is not compiled in, or when users don't want to configure extra mixers required by the Atom/sst driver.

Tested on Lenovo 100s Baytrail Chromebook w/ Mr. Chromebox BOOT_STUB firmware and Acer R11 Cherrytrail Chromebook

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1335196
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2016-August/
111641.html
[3] https://github.com/plbossart/UCM/tree/master/byt-max98090

Quoted 10 lines

sound/soc/intel/boards/cht_bsw_max98090_ti.c line 50

Quoted 8 lines

+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)

sound/soc/intel/boards/cht_bsw_max98090_ti.c +6 -0
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
+			     strlen(CHT_CODEC_DAI)))

Same comments as per another patch series wrt str_n_cmp() use.

Yes, if that's alright with you I'll clean this up in all Intel machine drivers in one patch since this is all copy-paste. I just need a clear indication on what the preferred means of string comparisons is...

Quoted 6 lines
Quoted 4 lines
sound/soc/intel/boards/cht_bsw_max98090_ti.c +3 -0
+			return rtd->codec_dai;
+	}
+	return NULL;
#7 lore raw

Re: [PATCH 3/7] ASoC: Intel: cht_bsw_max98090: add support for Baytrail

Quoted 14 lines · Pierre-Louis Bossart
Quoted 12 lines · Andy Shevchenko

sound/soc/intel/boards/cht_bsw_max98090_ti.c line 50

Quoted 9 lines · Pierre-Louis Bossart

+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)

sound/soc/intel/boards/cht_bsw_max98090_ti.c +6 -0
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
+			     strlen(CHT_CODEC_DAI)))

Same comments as per another patch series wrt str_n_cmp() use.

Quoted 3 lines

Yes, if that's alright with you I'll clean this up in all Intel machine
drivers in one patch since this is all copy-paste.

Yep, I agree on your other comment to clean up all Intel ASoC drivers at once.

Quoted 2 lines

I just need a clear
indication on what the preferred means of string comparisons is...

Here just a rule of common sense. No need to use str_n_* variants on top of constant literals especially followed by strlen().

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer
#8 lore raw

Applied "ASoC: Intel: cht_bsw_max98090: add support for Baytrail" to the asoc tree

In reply to Pierre-Louis Bossart

The patch

ASoC: Intel: cht_bsw_max98090: add support for Baytrail

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 299bad365b900223cded22a6f66dbb3763da4235 Mon Sep 17 00:00:00 2001

From: Pierre-Louis Bossart <[email protected]>
Date: Fri, 8 Sep 2017 00:13:05 -0500
Subject: [PATCH] ASoC: Intel: cht_bsw_max98090: add support for Baytrail

Distributions such as Fedora, Ubuntu and Gallium don't currently have a means to support Baytrail Chromebooks and other platforms with the same build [1][2] due to incompatible platform drivers.

Add MCLK management to reuse this machine driver for Baytrail platforms and solve this coexistence problem at last. UCM files are provided at [3] and will eventually be submitted to the new repo.

The legacy byt-max98090 machine driver is still maintained but can only be used when the other Atom/DPCM driver is not compiled in, or when users don't want to configure extra mixers required by the Atom/sst driver.

Tested on Lenovo 100s Baytrail Chromebook w/ Mr. Chromebox BOOT_STUB firmware and Acer R11 Cherrytrail Chromebook

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1335196
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2016-August/
111641.html
[3] https://github.com/plbossart/UCM/tree/master/byt-max98090

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 78 ++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +78 -0
index 20755ecc7f9e..442a81bf17b4 100644
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/clk.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
@@ -35,15 +36,60 @@
 #define CHT_CODEC_DAI	"HiFi"
 
 struct cht_mc_private {
+	struct clk *mclk;
 	struct snd_soc_jack jack;
 	bool ts3a227e_present;
 };
 
+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	list_for_each_entry(rtd, &card->rtd_list, list) {
+		if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
+			     strlen(CHT_CODEC_DAI)))
+			return rtd->codec_dai;
+	}
+	return NULL;
+}
+
+static int platform_clock_control(struct snd_soc_dapm_widget *w,
+					  struct snd_kcontrol *k, int  event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai;
+	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
+	int ret;
+
+	codec_dai = cht_get_codec_dai(card);
+	if (!codec_dai) {
+		dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
+		return -EIO;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = clk_prepare_enable(ctx->mclk);
+		if (ret < 0) {
+			dev_err(card->dev,
+				"could not configure MCLK state");
+			return ret;
+		}
+	} else {
+		clk_disable_unprepare(ctx->mclk);
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget cht_dapm_widgets[] = {
 	SND_SOC_DAPM_HP("Headphone", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
 	SND_SOC_DAPM_MIC("Int Mic", NULL),
 	SND_SOC_DAPM_SPK("Ext Spk", NULL),
+	SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
+			    platform_clock_control, SND_SOC_DAPM_PRE_PMU |
+			    SND_SOC_DAPM_POST_PMD),
 };
 
 static const struct snd_soc_dapm_route cht_audio_map[] = {
@@ -60,6 +106,10 @@ static const struct snd_soc_dapm_route cht_audio_map[] = {
 	{"codec_in0", NULL, "ssp2 Rx" },
 	{"codec_in1", NULL, "ssp2 Rx" },
 	{"ssp2 Rx", NULL, "HiFi Capture"},
+	{"Headphone", NULL, "Platform Clock"},
+	{"Headset Mic", NULL, "Platform Clock"},
+	{"Int Mic", NULL, "Platform Clock"},
+	{"Ext Spk", NULL, "Platform Clock"},
 };
 
 static const struct snd_kcontrol_new cht_mc_controls[] = {
@@ -141,6 +191,25 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 	if (ctx->ts3a227e_present)
 		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
 
+	/*
+	 * The firmware might enable the clock at
+	 * boot (this information may or may not
+	 * be reflected in the enable clock register).
+	 * To change the rate we must disable the clock
+	 * first to cover these cases. Due to common
+	 * clock framework restrictions that do not allow
+	 * to disable a clock that has not been enabled,
+	 * we need to enable the clock first.
+	 */
+	ret = clk_prepare_enable(ctx->mclk);
+	if (!ret)
+		clk_disable_unprepare(ctx->mclk);
+
+	ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ);
+
+	if (ret)
+		dev_err(runtime->dev, "unable to set MCLK rate\n");
+
 	return ret;
 }
 
@@ -294,6 +363,15 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	/* register the soc card */
 	snd_soc_card_cht.dev = &pdev->dev;
 	snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
+
+	drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
+	if (IS_ERR(drv->mclk)) {
+		dev_err(&pdev->dev,
+			"Failed to get MCLK from pmc_plt_clk_3: %ld\n",
+			PTR_ERR(drv->mclk));
+		return PTR_ERR(drv->mclk);
+	}
+
 	ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
 	if (ret_val) {
 		dev_err(&pdev->dev,
Signature · 1 line
2.14.1
#9 lore raw

PATCH 4/7 ASoC: Intel: atom: use cht_bsw_max98090 for Baytrail Chromebooks

In reply to Pierre-Louis Bossart

Baytrail Chromebooks used to be managed with legacy driver which is not compatible with atom/sst drivers. Reuse CHT driver to handle max98098 codec and allow distributions to support all Atom platforms with the same build.

The legacy byt-max98090 can still be used but in a build for Baytrail+max98090 only.

---
 sound/soc/intel/atom/sst/sst_acpi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/intel/atom/sst/sst_acpi.c +8 -0
index 0e928d5..ff4a517 100644
@@ -536,6 +536,14 @@ static struct sst_acpi_mach sst_acpi_bytcr[] = {
 		.board = "cht-bsw",
 		.pdata = &byt_rvp_platform_data
 	},
+	/* use CHT driver to Baytrail Chromebooks */
+	{
+		.id = "193C9890",
+		.drv_name = "cht-bsw-max98090",
+		.fw_filename = "intel/fw_sst_0f28.bin",
+		.board = "cht-bsw",
+		.pdata = &byt_rvp_platform_data
+	},
 #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 · 1 line
2.9.3
#10 lore raw

PATCH 5/7 ASoC: ts3a227e: add acpi table

In reply to Pierre-Louis Bossart

From: "Fang, Yang A" <[email protected]>

This patch adds the acpi match table for the ts3a227e audio accessory detection device. This enables headset features like jack plug/unplug notifications, mic presence, and button pressed events.

---
 sound/soc/codecs/ts3a227e.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
sound/soc/codecs/ts3a227e.c +10 -0
index 4356843..738e04b 100644
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/regmap.h>
+#include <linux/acpi.h>
 
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -374,11 +375,20 @@ static const struct of_device_id ts3a227e_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ts3a227e_of_match);
 
+#ifdef CONFIG_ACPI
+static struct acpi_device_id ts3a227e_acpi_match[] = {
+	{ "104C227E", 0 },
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, ts3a227e_acpi_match);
+#endif
+
 static struct i2c_driver ts3a227e_driver = {
 	.driver = {
 		.name = "ts3a227e",
 		.pm = &ts3a227e_pm,
 		.of_match_table = of_match_ptr(ts3a227e_of_match),
+		.acpi_match_table = ACPI_PTR(ts3a227e_acpi_match),
 	},
 	.probe = ts3a227e_i2c_probe,
 	.id_table = ts3a227e_i2c_ids,
Signature · 1 line
2.9.3
#11 lore raw

Re: [PATCH 5/7] ASoC: ts3a227e: add acpi table

Quoted 26 lines · Pierre-Louis Bossart

From: "Fang, Yang A" <[email protected]>

This patch adds the acpi match table for the ts3a227e audio accessory detection device. This enables headset features like jack plug/unplug notifications, mic presence, and button pressed events.

---
 sound/soc/codecs/ts3a227e.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
sound/soc/codecs/ts3a227e.c +1 -0
index 4356843..738e04b 100644
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/regmap.h>
+#include <linux/acpi.h>
 
 #include <sound/core.h>
 #include <sound/jack.h>

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 384

Quoted 10 lines
sound/soc/codecs/ts3a227e.c +7 -0
@@ -374,11 +375,20 @@ static const struct of_device_id ts3a227e_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ts3a227e_of_match);
 
+#ifdef CONFIG_ACPI
+static struct acpi_device_id ts3a227e_acpi_match[] = {
+	{ "104C227E", 0 },
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, ts3a227e_acpi_match);
+#endif

so this is not present for non ACPI system,... fine

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 391

Quoted 7 lines
sound/soc/codecs/ts3a227e.c +2 -0
+
 static struct i2c_driver ts3a227e_driver = {
 	.driver = {
 		.name = "ts3a227e",
 		.pm = &ts3a227e_pm,
 		.of_match_table = of_match_ptr(ts3a227e_of_match),
+		.acpi_match_table = ACPI_PTR(ts3a227e_acpi_match),

but then this would give compiler error on those systems as .acpi_match_table is defined in driver core... can you compile this on non acpi and check

struct device_driver {
	const char		*name;
	struct bus_type		*bus;

	struct module		*owner;
	const char		*mod_name;	/* used for built-in modules */

	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
	enum probe_type probe_type;

	const struct of_device_id	*of_match_table;
	const struct acpi_device_id	*acpi_match_table;

	int (*probe) (struct device *dev);
	int (*remove) (struct device *dev);
	void (*shutdown) (struct device *dev);
	int (*suspend) (struct device *dev, pm_message_t state);
	int (*resume) (struct device *dev);
	const struct attribute_group **groups;

	const struct dev_pm_ops *pm;

	struct driver_private *p;
};
Signature · 1 line
~Vinod
#12 lore raw

Re: [PATCH 5/7] ASoC: ts3a227e: add acpi table

Quoted 11 lines

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 384

Quoted 8 lines
sound/soc/codecs/ts3a227e.c +7 -0
+#ifdef CONFIG_ACPI
+static struct acpi_device_id ts3a227e_acpi_match[] = {
+	{ "104C227E", 0 },
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, ts3a227e_acpi_match);
+#endif

so this is not present for non ACPI system,... fine

Quoted 10 lines

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 391

Quoted 7 lines
sound/soc/codecs/ts3a227e.c +2 -0
+
  static struct i2c_driver ts3a227e_driver = {
  	.driver = {
  		.name = "ts3a227e",
  		.pm = &ts3a227e_pm,
  		.of_match_table = of_match_ptr(ts3a227e_of_match),
+		.acpi_match_table = ACPI_PTR(ts3a227e_acpi_match),

but then this would give compiler error on those systems as .acpi_match_table is defined in driver core... can you compile this on non acpi and check

This is not any different from what is done for other codecs.

static struct i2c_driver rt5677_i2c_driver = {
	.driver = {
		.name = "rt5677",
		.of_match_table = rt5677_of_match,
		.acpi_match_table = ACPI_PTR(rt5677_acpi_match),
	},

And the 0day checks did not report any issues, probably because the pre-processor takes the table out when CONFIG_ACPI is not enabled:

#define ACPI_PTR(_ptr) (NULL)

so no change...

maintainer
#13 lore raw

Re: [PATCH 5/7] ASoC: ts3a227e: add acpi table

Quoted 6 lines · Pierre-Louis Bossart
Quoted 5 lines

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 391

Quoted 2 lines

.of_match_table = of_match_ptr(ts3a227e_of_match),

sound/soc/codecs/ts3a227e.c +1 -0
+		.acpi_match_table = ACPI_PTR(ts3a227e_acpi_match),

but then this would give compiler error on those systems as .acpi_match_table is defined in driver core... can you compile this on non acpi and check

Quoted 8 lines

This is not any different from what is done for other codecs.

And the 0day checks did not report any issues, probably because the pre-processor takes the table out when CONFIG_ACPI is not enabled:

#define ACPI_PTR(_ptr) (NULL)

so no change...

Right, this is the whole point of the of_match_ptr() and ACPI_PTR() macros.

#14 lore raw

Re: [PATCH 5/7] ASoC: ts3a227e: add acpi table

In reply to Pierre-Louis Bossart
Quoted 31 lines · Pierre-Louis Bossart
Quoted 11 lines

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 384

Quoted 8 lines
sound/soc/codecs/ts3a227e.c +7 -0
+#ifdef CONFIG_ACPI
+static struct acpi_device_id ts3a227e_acpi_match[] = {
+	{ "104C227E", 0 },
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, ts3a227e_acpi_match);
+#endif

so this is not present for non ACPI system,... fine

Quoted 10 lines

sound/soc/codecs/ts3a227e.c static const struct of_device_id ts3a227e_of_match[] = { · line 391

Quoted 7 lines
sound/soc/codecs/ts3a227e.c +2 -0
+
 static struct i2c_driver ts3a227e_driver = {
 	.driver = {
 		.name = "ts3a227e",
 		.pm = &ts3a227e_pm,
 		.of_match_table = of_match_ptr(ts3a227e_of_match),
+		.acpi_match_table = ACPI_PTR(ts3a227e_acpi_match),

but then this would give compiler error on those systems as .acpi_match_table is defined in driver core... can you compile this on non acpi and check

This is not any different from what is done for other codecs.

static struct i2c_driver rt5677_i2c_driver = {
	.driver = {
		.name = "rt5677",
		.of_match_table = rt5677_of_match,
		.acpi_match_table = ACPI_PTR(rt5677_acpi_match),
	},
Quoted 4 lines

And the 0day checks did not report any issues, probably because the pre-processor takes the table out when CONFIG_ACPI is not enabled:

#define ACPI_PTR(_ptr) (NULL)

Yeah thanks for pointing, missed this one :)

Quoted 1 line

so no change...

yup :)

Signature · 1 line
~Vinod
#15 lore raw

PATCH 6/7 ASoc: Intel: cht_bsw_max98090_ti: Fix jack initialization

In reply to Pierre-Louis Bossart

From: Thierry Escande <[email protected]>

If the ts3a227e audio accessory detection hardware is present and its driver probed, the jack needs to be created before enabling jack detection in the ts3a227e driver. With this patch, the jack is instantiated in the max98090 headset init function if the ts3a227e is present. This fixes a null pointer dereference as the jack detection enabling function in the ts3a driver was called before the jack is created.

[minor correction to keep error handling on jack creation the same as before by Pierre Bossart]

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 45 +++++++++++++++++++---------
 1 file changed, 31 insertions(+), 14 deletions(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +31 -14
index 01bacca..a1502c7 100644
@@ -166,23 +166,19 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
 	struct snd_soc_jack *jack = &ctx->jack;
 
-	/**
-	* TI supports 4 butons headset detection
-	* KEY_MEDIA
-	* KEY_VOICECOMMAND
-	* KEY_VOLUMEUP
-	* KEY_VOLUMEDOWN
-	*/
-	if (ctx->ts3a227e_present)
-		jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
-					SND_JACK_BTN_0 | SND_JACK_BTN_1 |
-					SND_JACK_BTN_2 | SND_JACK_BTN_3;
-	else
-		jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
+	if (ctx->ts3a227e_present) {
+		/*
+		 * The jack has already been created in the
+		 * cht_max98090_headset_init() function.
+		 */
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+		return 0;
+	}
+
+	jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
 
 	ret = snd_soc_card_jack_new(runtime->card, "Headset Jack",
 					jack_type, jack, NULL, 0);
-
 	if (ret) {
 		dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret);
 		return ret;
@@ -257,6 +253,27 @@ static int cht_max98090_headset_init(struct snd_soc_component *component)
 {
 	struct snd_soc_card *card = component->card;
 	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
+	struct snd_soc_jack *jack = &ctx->jack;
+	int jack_type;
+	int ret;
+
+	/*
+	 * TI supports 4 butons headset detection
+	 * KEY_MEDIA
+	 * KEY_VOICECOMMAND
+	 * KEY_VOLUMEUP
+	 * KEY_VOLUMEDOWN
+	 */
+	jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
+		    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+		    SND_JACK_BTN_2 | SND_JACK_BTN_3;
+
+	ret = snd_soc_card_jack_new(card, "Headset Jack", jack_type,
+				    jack, NULL, 0);
+	if (ret) {
+		dev_err(card->dev, "Headset Jack creation failed %d\n", ret);
+		return ret;
+	}
 
 	return ts3a227e_enable_jack_detect(component, &ctx->jack);
 }
Signature · 1 line
2.9.3
maintainer
#16 lore raw

Applied "ASoC: Intel: cht_bsw_max98090_ti: Fix jack initialization" to the asoc tree

The patch

ASoC: Intel: cht_bsw_max98090_ti: Fix jack initialization

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 3bbda5a38601f7675a214be2044e41d7749e6c7b Mon Sep 17 00:00:00 2001

From: Thierry Escande <[email protected]>
Date: Fri, 8 Sep 2017 00:13:08 -0500
Subject: [PATCH] ASoC: Intel: cht_bsw_max98090_ti: Fix jack initialization

If the ts3a227e audio accessory detection hardware is present and its driver probed, the jack needs to be created before enabling jack detection in the ts3a227e driver. With this patch, the jack is instantiated in the max98090 headset init function if the ts3a227e is present. This fixes a null pointer dereference as the jack detection enabling function in the ts3a driver was called before the jack is created.

[minor correction to keep error handling on jack creation the same as before by Pierre Bossart]

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 45 +++++++++++++++++++---------
 1 file changed, 31 insertions(+), 14 deletions(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +31 -14
index 442a81bf17b4..e5da091abe48 100644
@@ -166,23 +166,19 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
 	struct snd_soc_jack *jack = &ctx->jack;
 
-	/**
-	* TI supports 4 butons headset detection
-	* KEY_MEDIA
-	* KEY_VOICECOMMAND
-	* KEY_VOLUMEUP
-	* KEY_VOLUMEDOWN
-	*/
-	if (ctx->ts3a227e_present)
-		jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
-					SND_JACK_BTN_0 | SND_JACK_BTN_1 |
-					SND_JACK_BTN_2 | SND_JACK_BTN_3;
-	else
-		jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
+	if (ctx->ts3a227e_present) {
+		/*
+		 * The jack has already been created in the
+		 * cht_max98090_headset_init() function.
+		 */
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+		return 0;
+	}
+
+	jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
 
 	ret = snd_soc_card_jack_new(runtime->card, "Headset Jack",
 					jack_type, jack, NULL, 0);
-
 	if (ret) {
 		dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret);
 		return ret;
@@ -257,6 +253,27 @@ static int cht_max98090_headset_init(struct snd_soc_component *component)
 {
 	struct snd_soc_card *card = component->card;
 	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
+	struct snd_soc_jack *jack = &ctx->jack;
+	int jack_type;
+	int ret;
+
+	/*
+	 * TI supports 4 butons headset detection
+	 * KEY_MEDIA
+	 * KEY_VOICECOMMAND
+	 * KEY_VOLUMEUP
+	 * KEY_VOLUMEDOWN
+	 */
+	jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
+		    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+		    SND_JACK_BTN_2 | SND_JACK_BTN_3;
+
+	ret = snd_soc_card_jack_new(card, "Headset Jack", jack_type,
+				    jack, NULL, 0);
+	if (ret) {
+		dev_err(card->dev, "Headset Jack creation failed %d\n", ret);
+		return ret;
+	}
 
 	return ts3a227e_enable_jack_detect(component, &ctx->jack);
 }
Signature · 1 line
2.14.1
#17 lore raw

PATCH 7/7 ASoC: Intel: cht_bsw_max98090: add gpio-based jack detection

In reply to Pierre-Louis Bossart

Jacks are created but only enabled when the external TI chip is present, this probably never worked as well. Forklift the gpio-based code from the legacy byt-max98090 driver, with however a less strict error check. It's fine to let users enjoy their device even if jack detection doesn't work - it almost never does without quirks...

Tested on Lenovo100s

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 56 +++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +55 -1
index a1502c7..74c047a 100644
@@ -159,6 +159,40 @@ static struct notifier_block cht_jack_nb = {
 	.notifier_call = cht_ti_jack_event,
 };
 
+static struct snd_soc_jack_pin hs_jack_pins[] = {
+	{
+		.pin	= "Headphone",
+		.mask	= SND_JACK_HEADPHONE,
+	},
+	{
+		.pin	= "Headset Mic",
+		.mask	= SND_JACK_MICROPHONE,
+	},
+};
+
+static struct snd_soc_jack_gpio hs_jack_gpios[] = {
+	{
+		.name		= "hp",
+		.report		= SND_JACK_HEADPHONE | SND_JACK_LINEOUT,
+		.debounce_time	= 200,
+	},
+	{
+		.name		= "mic",
+		.invert		= 1,
+		.report		= SND_JACK_MICROPHONE,
+		.debounce_time	= 200,
+	},
+};
+
+static const struct acpi_gpio_params hp_gpios = { 0, 0, false };
+static const struct acpi_gpio_params mic_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_max98090_gpios[] = {
+	{ "hp-gpios", &hp_gpios, 1 },
+	{ "mic-gpios", &mic_gpios, 1 },
+	{},
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -178,15 +212,29 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 	jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
 
 	ret = snd_soc_card_jack_new(runtime->card, "Headset Jack",
-					jack_type, jack, NULL, 0);
+				    jack_type, jack,
+				    hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
 	if (ret) {
 		dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret);
 		return ret;
 	}
 
+
 	if (ctx->ts3a227e_present)
 		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
 
+	ret = snd_soc_jack_add_gpiods(runtime->card->dev->parent, jack,
+				      ARRAY_SIZE(hs_jack_gpios),
+				      hs_jack_gpios);
+	if (ret) {
+		/*
+		 * flag error but don't bail if jack detect is broken
+		 * due to platform issues or bad BIOS/configuration
+		 */
+		dev_err(runtime->dev,
+			"jack detection gpios not added, error %d\n", ret);
+	}
+
 	/*
 	 * The firmware might enable the clock at
 	 * boot (this information may or may not
@@ -363,6 +411,7 @@ static struct snd_soc_card snd_soc_card_cht = {
 
 static int snd_cht_mc_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int ret_val = 0;
 	struct cht_mc_private *drv;
 
@@ -375,6 +424,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 		/* no need probe TI jack detection chip */
 		snd_soc_card_cht.aux_dev = NULL;
 		snd_soc_card_cht.num_aux_devs = 0;
+
+		ret_val = devm_acpi_dev_add_driver_gpios(dev->parent,
+							 acpi_max98090_gpios);
+		if (ret_val)
+			dev_dbg(dev, "Unable to add GPIO mapping table\n");
 	}
 
 	/* register the soc card */
Signature · 1 line
2.9.3
maintainer
#18 lore raw

Applied "ASoC: Intel: cht_bsw_max98090: add gpio-based jack detection" to the asoc tree

The patch

ASoC: Intel: cht_bsw_max98090: add gpio-based jack detection

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 355b3552d59f471bfaf41cf7c6cc0a6fa193b303 Mon Sep 17 00:00:00 2001

From: Pierre-Louis Bossart <[email protected]>
Date: Fri, 8 Sep 2017 00:13:09 -0500
Subject: [PATCH] ASoC: Intel: cht_bsw_max98090: add gpio-based jack detection

Jacks are created but only enabled when the external TI chip is present, this probably never worked as well. Forklift the gpio-based code from the legacy byt-max98090 driver, with however a less strict error check. It's fine to let users enjoy their device even if jack detection doesn't work - it almost never does without quirks...

Tested on Lenovo100s

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 56 +++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +55 -1
index e5da091abe48..6519604b9577 100644
@@ -159,6 +159,40 @@ static struct notifier_block cht_jack_nb = {
 	.notifier_call = cht_ti_jack_event,
 };
 
+static struct snd_soc_jack_pin hs_jack_pins[] = {
+	{
+		.pin	= "Headphone",
+		.mask	= SND_JACK_HEADPHONE,
+	},
+	{
+		.pin	= "Headset Mic",
+		.mask	= SND_JACK_MICROPHONE,
+	},
+};
+
+static struct snd_soc_jack_gpio hs_jack_gpios[] = {
+	{
+		.name		= "hp",
+		.report		= SND_JACK_HEADPHONE | SND_JACK_LINEOUT,
+		.debounce_time	= 200,
+	},
+	{
+		.name		= "mic",
+		.invert		= 1,
+		.report		= SND_JACK_MICROPHONE,
+		.debounce_time	= 200,
+	},
+};
+
+static const struct acpi_gpio_params hp_gpios = { 0, 0, false };
+static const struct acpi_gpio_params mic_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_max98090_gpios[] = {
+	{ "hp-gpios", &hp_gpios, 1 },
+	{ "mic-gpios", &mic_gpios, 1 },
+	{},
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -178,15 +212,29 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 	jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
 
 	ret = snd_soc_card_jack_new(runtime->card, "Headset Jack",
-					jack_type, jack, NULL, 0);
+				    jack_type, jack,
+				    hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
 	if (ret) {
 		dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret);
 		return ret;
 	}
 
+
 	if (ctx->ts3a227e_present)
 		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
 
+	ret = snd_soc_jack_add_gpiods(runtime->card->dev->parent, jack,
+				      ARRAY_SIZE(hs_jack_gpios),
+				      hs_jack_gpios);
+	if (ret) {
+		/*
+		 * flag error but don't bail if jack detect is broken
+		 * due to platform issues or bad BIOS/configuration
+		 */
+		dev_err(runtime->dev,
+			"jack detection gpios not added, error %d\n", ret);
+	}
+
 	/*
 	 * The firmware might enable the clock at
 	 * boot (this information may or may not
@@ -363,6 +411,7 @@ static struct snd_soc_card snd_soc_card_cht = {
 
 static int snd_cht_mc_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int ret_val = 0;
 	struct cht_mc_private *drv;
 
@@ -375,6 +424,11 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 		/* no need probe TI jack detection chip */
 		snd_soc_card_cht.aux_dev = NULL;
 		snd_soc_card_cht.num_aux_devs = 0;
+
+		ret_val = devm_acpi_dev_add_driver_gpios(dev->parent,
+							 acpi_max98090_gpios);
+		if (ret_val)
+			dev_dbg(dev, "Unable to add GPIO mapping table\n");
 	}
 
 	/* register the soc card */
Signature · 1 line
2.14.1
Acked-by on the v1 series
#19 lore raw
In reply to Pierre-Louis Bossart
Quoted 11 lines · Pierre-Louis Bossart

This patchset corrects issues with an earlier submission (missing signoffs, error case not consistent) and enables the cht_bsw_max98090 machine driver on Baytrail. This should help distributions solve problems with Baytrail Chromebooks which required a specific build. These patches were tested on Lenovo 100s ('orco'/Baytrail) and Acer R11 ('cyan'/Cherrytrail), using the same build based on CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH=m. Playback on speakers/headphone and capture from internal mic work fine. UCM files are available at
https://github.com/plbossart/UCM/tree/master/byt-max98090

Quoted 2 lines

Thanks to Jarkko Nikula and Andy Shevchenko for their comments on an initial version reviewed internally at Intel.

Quoted 23 lines

Fang, Yang A (1):
ASoC: ts3a227e: add acpi table

Pierre-Louis Bossart (5):
ASoC: max98090: reduce verbosity on PLL unlock
ASoC: Intel: cht_bsw_max98090: Fix I2S config + unused code
ASoC: Intel: cht_bsw_max98090: add support for Baytrail
ASoC: Intel: atom: use cht_bsw_max98090 for Baytrail Chromebooks
ASoC: Intel: cht_bsw_max98090: add gpio-based jack detection

Thierry Escande (1):
ASoc: Intel: cht_bsw_max98090_ti: Fix jack initialization

 sound/soc/codecs/max98090.c                  |   2 +-
 sound/soc/codecs/ts3a227e.c                  |  10 ++
 sound/soc/intel/atom/sst/sst_acpi.c          |   8 ++
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 185 ++++++++++++++++++++++++---
 4 files changed, 186 insertions(+), 19 deletions(-)
Signature · 1 line
2.9.3
Signature · 1 line
~Vinod