devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver
@ 2014-05-20  4:25 Tushar Behera
  2014-05-20 11:16 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Tushar Behera @ 2014-05-20  4:25 UTC (permalink / raw)
  To: alsa-devel, linux-samsung-soc, linux-kernel, devicetree,
	linux-doc
  Cc: lgirdwood, robh+dt, sbkim73, rdunlap, broonie, dianders, t.figa

For audio to work on Snow board, we need the codec master clock 'mclk'
to be properly configured.

Currently XCLKOUT is configured as 'mclk' for codec chip and it is
required to be clocked at 24MHz for the codec to work properly.

Add appropriate clock handling within Snow sound-card driver to set
'mclk' to operate at 24MHz.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 Documentation/devicetree/bindings/sound/snow.txt |    7 ++++++
 sound/soc/samsung/snow.c                         |   26 +++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/snow.txt b/Documentation/devicetree/bindings/sound/snow.txt
index 678b191..94dd29c 100644
--- a/Documentation/devicetree/bindings/sound/snow.txt
+++ b/Documentation/devicetree/bindings/sound/snow.txt
@@ -7,6 +7,10 @@ Required properties:
 - samsung,i2s-controller: The phandle of the Samsung I2S controller
 - samsung,audio-codec: The phandle of the audio codec
 
+Optional properties:
+- clocks: The phandle of the master clock to audio codec
+- clock-names: Should be "mclk"
+
 Example:
 
 sound {
@@ -14,4 +18,7 @@ sound {
 
 		samsung,i2s-controller = <&i2s0>;
 		samsung,audio-codec = <&max98095>;
+
+		clocks = <&pmu_system_controller>;
+		clock-names = "mclk";
 };
diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c
index 014c177..c910739 100644
--- a/sound/soc/samsung/snow.c
+++ b/sound/soc/samsung/snow.c
@@ -15,13 +15,18 @@
 #include <linux/platform_device.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/clk.h>
 
 #include <sound/soc.h>
 
 #include "i2s.h"
 
+/* Desired clock rate for codec mclk */
 #define FIN_PLL_RATE		24000000
 
+static struct clk *mclk;
+static unsigned long mclk_rate;
+
 static struct snd_soc_dai_link snow_dai[] = {
 	{
 		.name = "Primary",
@@ -41,7 +46,7 @@ static int snow_late_probe(struct snd_soc_card *card)
 
 	/* Set the MCLK rate for the codec */
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0,
-					FIN_PLL_RATE, SND_SOC_CLOCK_IN);
+					mclk_rate, SND_SOC_CLOCK_IN);
 	if (ret < 0)
 		return ret;
 
@@ -68,6 +73,16 @@ static int snow_probe(struct platform_device *pdev)
 	struct device_node *i2s_node, *codec_node;
 	int i, ret;
 
+	/* The codec MCLK should be clocked at 24MHz */
+	mclk = devm_clk_get(&pdev->dev, "mclk");
+	if (!IS_ERR(mclk)) {
+		clk_prepare_enable(mclk);
+		clk_set_rate(mclk, FIN_PLL_RATE);
+		mclk_rate = clk_get_rate(mclk);
+	} else {
+		mclk_rate = FIN_PLL_RATE;
+	}
+
 	i2s_node = of_parse_phandle(pdev->dev.of_node,
 				    "samsung,i2s-controller", 0);
 	if (!i2s_node) {
@@ -101,6 +116,14 @@ static int snow_probe(struct platform_device *pdev)
 	return ret;
 }
 
+static int snow_remove(struct platform_device *pdev)
+{
+	if (!IS_ERR(mclk))
+		clk_disable_unprepare(mclk);
+
+	return 0;
+}
+
 static const struct of_device_id snow_of_match[] = {
 	{ .compatible = "google,snow-audio-max98090", },
 	{ .compatible = "google,snow-audio-max98095", },
@@ -115,6 +138,7 @@ static struct platform_driver snow_driver = {
 		.of_match_table = snow_of_match,
 	},
 	.probe = snow_probe,
+	.remove = snow_remove,
 };
 
 module_platform_driver(snow_driver);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver
  2014-05-20  4:25 [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver Tushar Behera
@ 2014-05-20 11:16 ` Mark Brown
  2014-05-21  5:41   ` Tushar Behera
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2014-05-20 11:16 UTC (permalink / raw)
  To: Tushar Behera
  Cc: dianders, devicetree, alsa-devel, linux-samsung-soc, linux-doc,
	sbkim73, t.figa, rdunlap, lgirdwood, linux-kernel, robh+dt


[-- Attachment #1.1: Type: text/plain, Size: 536 bytes --]

On Tue, May 20, 2014 at 09:55:42AM +0530, Tushar Behera wrote:
> For audio to work on Snow board, we need the codec master clock 'mclk'
> to be properly configured.
> 
> Currently XCLKOUT is configured as 'mclk' for codec chip and it is
> required to be clocked at 24MHz for the codec to work properly.
> 
> Add appropriate clock handling within Snow sound-card driver to set
> 'mclk' to operate at 24MHz.

The clock here is connected to the CODEC on the board so it should be
connected to the CODEC in the device tree too.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver
  2014-05-20 11:16 ` Mark Brown
@ 2014-05-21  5:41   ` Tushar Behera
  0 siblings, 0 replies; 3+ messages in thread
From: Tushar Behera @ 2014-05-21  5:41 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, linux-samsung-soc, linux-kernel, devicetree,
	linux-doc, lgirdwood, robh+dt, sbkim73, rdunlap, dianders, t.figa

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/20/2014 04:46 PM, Mark Brown wrote:
> On Tue, May 20, 2014 at 09:55:42AM +0530, Tushar Behera wrote:
>> For audio to work on Snow board, we need the codec master clock
>> 'mclk' to be properly configured.
>> 
>> Currently XCLKOUT is configured as 'mclk' for codec chip and it
>> is required to be clocked at 24MHz for the codec to work
>> properly.
>> 
>> Add appropriate clock handling within Snow sound-card driver to
>> set 'mclk' to operate at 24MHz.
> 
> The clock here is connected to the CODEC on the board so it should
> be connected to the CODEC in the device tree too.
> 

Ok. I will move 'mclk' clock handling to respective CODEC drivers.

- -- 
Tushar Behera
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTfDxtAAoJELqclMPPkq4NkPcH/2fOwVTGgmGFarm2RSoxJcON
QcSQlNpVXEpAqslVdz+ay7VkYCWy+wiuTq4Fe/Yw5RK/Pl7DdkEX/Ltj7/Q6+CbT
38r6o5PSbZLlPcBxVjGXBiOTpK7PZLumF8c1DK4/6HzsHYDzLGTvbWVi6cy9kZzj
X3glD3PBiK/NL12IuOHsRg2wzBRE56RQCmfT2kPueWHEklebGzr/qv5UgdGWa+jb
JRVDt11klGfvIFj+Ov28yave1epzFEzrNm4ixso8MJN7J9HxlufagTheS0HkDpuX
+uY8PbRFTAdT7pjvZR4n2lPws940nk7aUqyVPTQaG9JVKk7R4FVZgBwmhMeIsMU=
=eKSS
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-21  5:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20  4:25 [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver Tushar Behera
2014-05-20 11:16 ` Mark Brown
2014-05-21  5:41   ` Tushar Behera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).