All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Oder Chiou <oder_chiou@realtek.com>,
	alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Mark Brown <broonie@kernel.org>, Bard Liao <bardliao@realtek.com>
Subject: Applied "ASoC: Intel: bytcr_rt5640: Configure PLL1 before using it" to the asoc tree
Date: Fri, 11 May 2018 03:48:46 +0100 (BST)	[thread overview]
Message-ID: <20180511024846.3322244007C@finisterre.ee.mobilebroadband> (raw)
In-Reply-To: <20180508153604.23711-9-hdegoede@redhat.com>

The patch

   ASoC: Intel: bytcr_rt5640: Configure PLL1 before using it

has been applied to the asoc tree at

   https://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

>From bcd9a325f0b0f407c4559779a94e802977c67274 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 8 May 2018 17:35:53 +0200
Subject: [PATCH] ASoC: Intel: bytcr_rt5640: Configure PLL1 before using it

When platform_clock_control() first selects PLL1 as sysclk the PLL_CTRL
registers have not been setup yet and we effectively have an invalid clock
configuration until byt_rt5640_aif1_hw_params() gets called.

Add a new byt_rt5640_prepare_and_enable_pll1() helper and use that from
both platform_clock_control() and byt_rt5640_aif1_hw_params() to fix this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/boards/bytcr_rt5640.c | 100 +++++++++++++-------------
 1 file changed, 49 insertions(+), 51 deletions(-)

diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index ad5fcd5a1762..c540dfdf045d 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -141,6 +141,52 @@ static void log_quirks(struct device *dev)
 	}
 }
 
+static int byt_rt5640_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai,
+					      int rate)
+{
+	int ret;
+
+	/* Configure the PLL before selecting it */
+	if (!(byt_rt5640_quirk & BYT_RT5640_MCLK_EN)) {
+		/* use bitclock as PLL input */
+		if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
+		    (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
+			/* 2x16 bit slots on SSP0 */
+			ret = snd_soc_dai_set_pll(codec_dai, 0,
+						  RT5640_PLL1_S_BCLK1,
+						  rate * 32, rate * 512);
+		} else {
+			/* 2x15 bit slots on SSP2 */
+			ret = snd_soc_dai_set_pll(codec_dai, 0,
+						  RT5640_PLL1_S_BCLK1,
+						  rate * 50, rate * 512);
+		}
+	} else {
+		if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
+			ret = snd_soc_dai_set_pll(codec_dai, 0,
+						  RT5640_PLL1_S_MCLK,
+						  25000000, rate * 512);
+		} else {
+			ret = snd_soc_dai_set_pll(codec_dai, 0,
+						  RT5640_PLL1_S_MCLK,
+						  19200000, rate * 512);
+		}
+	}
+
+	if (ret < 0) {
+		dev_err(codec_dai->codec->dev, "can't set pll: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
+				     rate * 512, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec_dai->codec->dev, "can't set clock %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
 
 #define BYT_CODEC_DAI1	"rt5640-aif1"
 #define BYT_CODEC_DAI2	"rt5640-aif2"
@@ -173,9 +219,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
 				return ret;
 			}
 		}
-		ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
-					     48000 * 512,
-					     SND_SOC_CLOCK_IN);
+		ret = byt_rt5640_prepare_and_enable_pll1(codec_dai, 48000);
 	} else {
 		/*
 		 * Set codec clock source to internal clock before
@@ -299,55 +343,9 @@ static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	int ret;
-
-	ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
-				     params_rate(params) * 512,
-				     SND_SOC_CLOCK_IN);
-
-	if (ret < 0) {
-		dev_err(rtd->dev, "can't set codec clock %d\n", ret);
-		return ret;
-	}
+	struct snd_soc_dai *dai = rtd->codec_dai;
 
-	if (!(byt_rt5640_quirk & BYT_RT5640_MCLK_EN)) {
-		/* use bitclock as PLL input */
-		if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
-			(byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
-
-			/* 2x16 bit slots on SSP0 */
-			ret = snd_soc_dai_set_pll(codec_dai, 0,
-						RT5640_PLL1_S_BCLK1,
-						params_rate(params) * 32,
-						params_rate(params) * 512);
-		} else {
-			/* 2x15 bit slots on SSP2 */
-			ret = snd_soc_dai_set_pll(codec_dai, 0,
-						RT5640_PLL1_S_BCLK1,
-						params_rate(params) * 50,
-						params_rate(params) * 512);
-		}
-	} else {
-		if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
-			ret = snd_soc_dai_set_pll(codec_dai, 0,
-						RT5640_PLL1_S_MCLK,
-						25000000,
-						params_rate(params) * 512);
-		} else {
-			ret = snd_soc_dai_set_pll(codec_dai, 0,
-						RT5640_PLL1_S_MCLK,
-						19200000,
-						params_rate(params) * 512);
-		}
-	}
-
-	if (ret < 0) {
-		dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
-		return ret;
-	}
-
-	return 0;
+	return byt_rt5640_prepare_and_enable_pll1(dai, params_rate(params));
 }
 
 static int byt_rt5640_quirk_cb(const struct dmi_system_id *id)
-- 
2.17.0

  reply	other threads:[~2018-05-11  3:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08 15:35 [PATCH 00/19] ASoC: rt5640: Add jack-detect and button-press support Hans de Goede
2018-05-08 15:35 ` [PATCH 01/19] ASoC: rt5640: Remove is_sys_clk_from_pll, it has ordering issues Hans de Goede
2018-05-08 15:35 ` [PATCH 02/19] ASoC: rt5640: Add devicetree-bindings for dmic, jack-detect Hans de Goede
2018-05-08 15:35 ` [PATCH 03/19] ASoC: rt5640: Remove unused rt5640_platform_data Hans de Goede
2018-05-11  2:16   ` Mark Brown
2018-05-11  2:52   ` Applied "ASoC: rt5640: Remove unused rt5640_platform_data" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 04/19] ASoC: rt5640: Move checking of device-properties to component probe callback Hans de Goede
2018-05-11  2:51   ` Applied "ASoC: rt5640: Move checking of device-properties to component probe callback" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 05/19] ASoC: rt5640: Allow specifying dmic data pins through device-properties Hans de Goede
2018-05-11  2:51   ` Applied "ASoC: rt5640: Allow specifying dmic data pins through device-properties" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 06/19] ASoC: rt5640: Add jack-detect support Hans de Goede
2018-05-11  2:50   ` Applied "ASoC: rt5640: Add jack-detect support" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 07/19] ASoC: rt5640: Add button press support Hans de Goede
2018-05-11  2:50   ` Applied "ASoC: rt5640: Add button press support" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 08/19] ASoC: Intel: bytcr_rt5640: Configure PLL1 before using it Hans de Goede
2018-05-11  2:48   ` Mark Brown [this message]
2018-05-08 15:35 ` [PATCH 09/19] ASoC: Intel: bytcr_rt5640: Use device-property for differential mics Hans de Goede
2018-05-11  2:48   ` Applied "ASoC: Intel: bytcr_rt5640: Use device-property for differential mics" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 10/19] ASoC: Intel: bytcr_rt5640: Use device properties for setting up dmic Hans de Goede
2018-05-11  2:25   ` Mark Brown
2018-05-08 15:35 ` [PATCH 11/19] ASoC: Intel: bytcr_rt5640: Fix Dell Venue 8 5830 Pro quirk Hans de Goede
2018-05-17 16:39   ` Applied "ASoC: Intel: bytcr_rt5640: Fix Dell Venue 8 5830 Pro quirk" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 12/19] ASoC: Intel: bytcr_rt5640: Enable jack detection Hans de Goede
2018-05-17 16:39   ` Applied "ASoC: Intel: bytcr_rt5640: Enable jack detection" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 13/19] ASoC: Intel: bytcr_rt5640: Change BYTCR default input to IN3 Hans de Goede
2018-05-17 16:39   ` Applied "ASoC: Intel: bytcr_rt5640: Change BYTCR default input to IN3" to the asoc tree Mark Brown
2018-05-08 15:35 ` [PATCH 14/19] ASoC: Intel: bytcr_rt5640: Unify BYTCR input defaults Hans de Goede
2018-05-17 16:39   ` Applied "ASoC: Intel: bytcr_rt5640: Unify BYTCR input defaults" to the asoc tree Mark Brown
2018-05-08 15:36 ` [PATCH 15/19] ASoC: Intel: bytcr_rt5640: Add default jack-detect settings Hans de Goede
2018-05-17 16:39   ` Applied "ASoC: Intel: bytcr_rt5640: Add default jack-detect settings" to the asoc tree Mark Brown
2018-05-08 15:36 ` [PATCH 16/19] ASoC: Intel: bytcr_rt5640: Sort DMI quirk list alphabetically Hans de Goede
2018-05-17 16:39   ` Applied "ASoC: Intel: bytcr_rt5640: Sort DMI quirk list alphabetically" to the asoc tree Mark Brown
2018-05-08 15:36 ` [PATCH 17/19] ASoC: Intel: bytcr_rt5640: Use dmi_first_match() for DMI quirk handling Hans de Goede
2018-05-17 16:38   ` Applied "ASoC: Intel: bytcr_rt5640: Use dmi_first_match() for DMI quirk handling" to the asoc tree Mark Brown
2018-05-08 15:36 ` [PATCH 18/19] ASoC: Intel: bytcr_rt5640: Add quirks for various devices Hans de Goede
2018-05-08 15:36 ` [PATCH 19/19] ASoC: Intel: bytcr_rt5640: Set card long_name based on quirks Hans de Goede
2018-05-08 18:35   ` Pierre-Louis Bossart
2018-05-10 10:27     ` Hans de Goede
2018-05-10 15:00       ` Pierre-Louis Bossart
2018-05-10 15:48         ` Hans de Goede
2018-05-10 17:46           ` Pierre-Louis Bossart
2018-05-10 18:01             ` Hans de Goede
2018-05-12 21:21               ` Pierre-Louis Bossart
2018-05-13  7:11                 ` Takashi Iwai
2018-05-13  7:28                   ` Hans de Goede
2018-05-18 15:55           ` Hans de Goede
2018-05-18 16:21             ` Pierre-Louis Bossart
2018-05-17 16:38   ` Applied "ASoC: Intel: bytcr_rt5640: Set card long_name based on quirks" to the asoc tree Mark Brown
2018-05-08 18:42 ` [PATCH 00/19] ASoC: rt5640: Add jack-detect and button-press support Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180511024846.3322244007C@finisterre.ee.mobilebroadband \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=hdegoede@redhat.com \
    --cc=lgirdwood@gmail.com \
    --cc=oder_chiou@realtek.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.