* [PATCH V2 0/2] ASoC: max98090/max98095: Add master clock handing
@ 2014-05-26 8:28 Tushar Behera
2014-05-26 8:28 ` [PATCH V2 1/2] ASoC: max98090: Add master clock handling Tushar Behera
2014-05-26 8:28 ` [PATCH 2/2] ASoC: max98095: " Tushar Behera
0 siblings, 2 replies; 7+ messages in thread
From: Tushar Behera @ 2014-05-26 8:28 UTC (permalink / raw)
To: alsa-devel, linux-kernel, devicetree
Cc: tiwai, perex, broonie, dianders, swarren
These CODECs are used on Snow/Peach-pit boards and the master clock
needs to be set at 24MHz.
Adding support in respective codec drivers so that we can update the
master clock frequency from sound card driver through set_sysclk.
Changes for V2:
1. Added PROBE_DEFER if clock driver has not yet been probed
2. Moved clk_prepare_enable from .probe to .set_bias_level
3. Moved clk_disable_unprepare from .remove to .set_bias_level
Tushar Behera (2):
ASoC: max98090: Add master clock handling
ASoC: max98095: Add master clock handling
.../devicetree/bindings/sound/max98090.txt | 6 +++++
.../devicetree/bindings/sound/max98095.txt | 6 +++++
sound/soc/codecs/max98090.c | 23 +++++++++++++++++++
sound/soc/codecs/max98090.h | 1 +
sound/soc/codecs/max98095.c | 24 ++++++++++++++++++++
5 files changed, 60 insertions(+)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2 1/2] ASoC: max98090: Add master clock handling
2014-05-26 8:28 [PATCH V2 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
@ 2014-05-26 8:28 ` Tushar Behera
2014-05-26 15:18 ` Mark Brown
2014-05-26 8:28 ` [PATCH 2/2] ASoC: max98095: " Tushar Behera
1 sibling, 1 reply; 7+ messages in thread
From: Tushar Behera @ 2014-05-26 8:28 UTC (permalink / raw)
To: alsa-devel, linux-kernel, devicetree
Cc: tiwai, perex, broonie, dianders, swarren
If master clock is provided through device tree, then update
the master clock frequency during set_sysclk.
Documentation has been updated to reflect the change.
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
.../devicetree/bindings/sound/max98090.txt | 6 +++++
sound/soc/codecs/max98090.c | 23 ++++++++++++++++++++
sound/soc/codecs/max98090.h | 1 +
3 files changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt
index e4c8b36..a5e63fa 100644
--- a/Documentation/devicetree/bindings/sound/max98090.txt
+++ b/Documentation/devicetree/bindings/sound/max98090.txt
@@ -10,6 +10,12 @@ Required properties:
- interrupts : The CODEC's interrupt output.
+Optional properties:
+
+- clocks: The phandle of the master clock to the CODEC
+
+- clock-names: Should be "mclk"
+
Pins on the device (for linking into audio routes):
* MIC1
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 9b76f5a..9275785 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -17,6 +17,7 @@
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/acpi.h>
+#include <linux/clk.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -1800,6 +1801,19 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
break;
case SND_SOC_BIAS_PREPARE:
+ /*
+ * SND_SOC_BIAS_PREPARE is called while preparing for a
+ * transition to ON or away from ON. If current bias_level
+ * is SND_SOC_BIAS_ON, then it is preparing for a transition
+ * away from ON. Disable the clock in that case, otherwise
+ * enable it.
+ */
+ if (!IS_ERR(max98090->mclk)) {
+ if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
+ clk_disable_unprepare(max98090->mclk);
+ else
+ clk_prepare_enable(max98090->mclk);
+ }
break;
case SND_SOC_BIAS_STANDBY:
@@ -1929,6 +1943,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
if (freq == max98090->sysclk)
return 0;
+ if (!IS_ERR(max98090->mclk)) {
+ freq = clk_round_rate(max98090->mclk, freq);
+ clk_set_rate(max98090->mclk, freq);
+ }
+
/* Setup clocks for slave mode, and using the PLL
* PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
* 0x02 (when master clk is 20MHz to 40MHz)..
@@ -2213,6 +2232,10 @@ static int max98090_probe(struct snd_soc_codec *codec)
dev_dbg(codec->dev, "max98090_probe\n");
+ max98090->mclk = devm_clk_get(codec->dev, "mclk");
+ if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
max98090->codec = codec;
/* Reset the codec, the DSP core, and disable all interrupts */
diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h
index 5a3c8d0..cf1b606 100644
--- a/sound/soc/codecs/max98090.h
+++ b/sound/soc/codecs/max98090.h
@@ -1524,6 +1524,7 @@ struct max98090_priv {
struct snd_soc_codec *codec;
enum max98090_type devtype;
struct max98090_pdata *pdata;
+ struct clk *mclk;
unsigned int sysclk;
unsigned int bclk;
unsigned int lrclk;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2 1/2] ASoC: max98090: Add master clock handling
2014-05-26 8:28 ` [PATCH V2 1/2] ASoC: max98090: Add master clock handling Tushar Behera
@ 2014-05-26 15:18 ` Mark Brown
0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-05-26 15:18 UTC (permalink / raw)
To: Tushar Behera
Cc: alsa-devel, linux-kernel, devicetree, tiwai, perex, dianders,
swarren
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
On Mon, May 26, 2014 at 01:58:21PM +0530, Tushar Behera wrote:
> If master clock is provided through device tree, then update
> the master clock frequency during set_sysclk.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] ASoC: max98095: Add master clock handling
2014-05-26 8:28 [PATCH V2 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
2014-05-26 8:28 ` [PATCH V2 1/2] ASoC: max98090: Add master clock handling Tushar Behera
@ 2014-05-26 8:28 ` Tushar Behera
2014-05-26 15:19 ` Mark Brown
1 sibling, 1 reply; 7+ messages in thread
From: Tushar Behera @ 2014-05-26 8:28 UTC (permalink / raw)
To: alsa-devel, linux-kernel, devicetree
Cc: tiwai, perex, broonie, dianders, swarren
If master clock is provided through device tree, then update
the master clock frequency during set_sysclk.
Documentation has been updated to reflect the change.
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
.../devicetree/bindings/sound/max98095.txt | 6 +++++
sound/soc/codecs/max98095.c | 24 ++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/max98095.txt b/Documentation/devicetree/bindings/sound/max98095.txt
index bacbeaa..318a4c8 100644
--- a/Documentation/devicetree/bindings/sound/max98095.txt
+++ b/Documentation/devicetree/bindings/sound/max98095.txt
@@ -8,6 +8,12 @@ Required properties:
- reg : The I2C address of the device.
+Optional properties:
+
+- clocks: The phandle of the master clock to the CODEC
+
+- clock-names: Should be "mclk"
+
Example:
max98095: codec@11 {
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index d6c1e4c..89ec004 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
+#include <linux/clk.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -42,6 +43,7 @@ struct max98095_priv {
struct regmap *regmap;
enum max98095_type devtype;
struct max98095_pdata *pdata;
+ struct clk *mclk;
unsigned int sysclk;
struct max98095_cdata dai[3];
const char **eq_texts;
@@ -1395,6 +1397,11 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai,
if (freq == max98095->sysclk)
return 0;
+ if (!IS_ERR(max98095->mclk)) {
+ freq = clk_round_rate(max98095->mclk, freq);
+ clk_set_rate(max98095->mclk, freq);
+ }
+
/* Setup clocks for slave mode, and using the PLL
* PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
* 0x02 (when master clk is 20MHz to 40MHz)..
@@ -1634,6 +1641,19 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec,
break;
case SND_SOC_BIAS_PREPARE:
+ /*
+ * SND_SOC_BIAS_PREPARE is called while preparing for a
+ * transition to ON or away from ON. If current bias_level
+ * is SND_SOC_BIAS_ON, then it is preparing for a transition
+ * away from ON. Disable the clock in that case, otherwise
+ * enable it.
+ */
+ if (!IS_ERR(max98095->mclk)) {
+ if (codec->dapm.bias_level == SND_SOC_BIAS_ON)
+ clk_disable_unprepare(max98095->mclk);
+ else
+ clk_prepare_enable(max98095->mclk);
+ }
break;
case SND_SOC_BIAS_STANDBY:
@@ -2238,6 +2258,10 @@ static int max98095_probe(struct snd_soc_codec *codec)
struct i2c_client *client;
int ret = 0;
+ max98095->mclk = devm_clk_get(codec->dev, "mclk");
+ if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
/* reset the codec, the DSP core, and disable all interrupts */
max98095_reset(codec);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ASoC: max98095: Add master clock handling
2014-05-26 8:28 ` [PATCH 2/2] ASoC: max98095: " Tushar Behera
@ 2014-05-26 15:19 ` Mark Brown
0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-05-26 15:19 UTC (permalink / raw)
To: Tushar Behera
Cc: alsa-devel, linux-kernel, devicetree, tiwai, perex, dianders,
swarren
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
On Mon, May 26, 2014 at 01:58:22PM +0530, Tushar Behera wrote:
> If master clock is provided through device tree, then update
> the master clock frequency during set_sysclk.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/2] ASoC: max98090/max98095: Add master clock handing
@ 2014-05-22 9:17 Tushar Behera
2014-05-22 9:17 ` [PATCH 2/2] ASoC: max98095: Add master clock handling Tushar Behera
0 siblings, 1 reply; 7+ messages in thread
From: Tushar Behera @ 2014-05-22 9:17 UTC (permalink / raw)
To: alsa-devel, linux-kernel, devicetree
Cc: tiwai, perex, broonie, dianders, jerry.wong
These CODECs are used on Snow/Peach-pit boards and the master clock
needs to be set at 24MHz.
Adding support in respective codec drivers so that we can update the
master clock frequency from sound card driver through set_sysclk.
These patches are prepared as per review comments on following patch.
[PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver
https://lkml.org/lkml/2014/5/20/4
Tushar Behera (2):
ASoC: max98090: Add master clock handling
ASoC: max98095: Add master clock handling
.../devicetree/bindings/sound/max98090.txt | 6 ++++++
.../devicetree/bindings/sound/max98095.txt | 6 ++++++
sound/soc/codecs/max98090.c | 13 +++++++++++++
sound/soc/codecs/max98090.h | 1 +
sound/soc/codecs/max98095.c | 14 ++++++++++++++
5 files changed, 40 insertions(+)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] ASoC: max98095: Add master clock handling
2014-05-22 9:17 [PATCH 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
@ 2014-05-22 9:17 ` Tushar Behera
2014-05-22 10:31 ` Mark Brown
0 siblings, 1 reply; 7+ messages in thread
From: Tushar Behera @ 2014-05-22 9:17 UTC (permalink / raw)
To: alsa-devel, linux-kernel, devicetree
Cc: tiwai, perex, broonie, dianders, jerry.wong
If master clock is provided through device tree, then update
the master clock frequency during set_sysclk.
Documentation has been updated to reflect the change.
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
.../devicetree/bindings/sound/max98095.txt | 6 ++++++
sound/soc/codecs/max98095.c | 14 ++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/max98095.txt b/Documentation/devicetree/bindings/sound/max98095.txt
index bacbeaa..318a4c8 100644
--- a/Documentation/devicetree/bindings/sound/max98095.txt
+++ b/Documentation/devicetree/bindings/sound/max98095.txt
@@ -8,6 +8,12 @@ Required properties:
- reg : The I2C address of the device.
+Optional properties:
+
+- clocks: The phandle of the master clock to the CODEC
+
+- clock-names: Should be "mclk"
+
Example:
max98095: codec@11 {
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index d6c1e4c..4d66b95 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
+#include <linux/clk.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -42,6 +43,7 @@ struct max98095_priv {
struct regmap *regmap;
enum max98095_type devtype;
struct max98095_pdata *pdata;
+ struct clk *mclk;
unsigned int sysclk;
struct max98095_cdata dai[3];
const char **eq_texts;
@@ -1395,6 +1397,11 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai,
if (freq == max98095->sysclk)
return 0;
+ if (!IS_ERR(max98095->mclk)) {
+ freq = clk_round_rate(max98095->mclk, freq);
+ clk_set_rate(max98095->mclk, freq);
+ }
+
/* Setup clocks for slave mode, and using the PLL
* PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
* 0x02 (when master clk is 20MHz to 40MHz)..
@@ -2238,6 +2245,10 @@ static int max98095_probe(struct snd_soc_codec *codec)
struct i2c_client *client;
int ret = 0;
+ max98095->mclk = devm_clk_get(codec->dev, "mclk");
+ if (!IS_ERR(max98095->mclk))
+ clk_prepare_enable(max98095->mclk);
+
/* reset the codec, the DSP core, and disable all interrupts */
max98095_reset(codec);
@@ -2340,6 +2351,9 @@ static int max98095_remove(struct snd_soc_codec *codec)
if (max98095->headphone_jack || max98095->mic_jack)
max98095_jack_detect_disable(codec);
+ if (!IS_ERR(max98095->mclk))
+ clk_disable_unprepare(max98095->mclk);
+
if (client->irq)
free_irq(client->irq, codec);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] ASoC: max98095: Add master clock handling
2014-05-22 9:17 ` [PATCH 2/2] ASoC: max98095: Add master clock handling Tushar Behera
@ 2014-05-22 10:31 ` Mark Brown
0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-05-22 10:31 UTC (permalink / raw)
To: Tushar Behera
Cc: alsa-devel, linux-kernel, devicetree, tiwai, perex, dianders,
jerry.wong, Jarkko Nikula
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
On Thu, May 22, 2014 at 02:47:08PM +0530, Tushar Behera wrote:
> If master clock is provided through device tree, then update
> the master clock frequency during set_sysclk.
Same issues here.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-05-26 15:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-26 8:28 [PATCH V2 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
2014-05-26 8:28 ` [PATCH V2 1/2] ASoC: max98090: Add master clock handling Tushar Behera
2014-05-26 15:18 ` Mark Brown
2014-05-26 8:28 ` [PATCH 2/2] ASoC: max98095: " Tushar Behera
2014-05-26 15:19 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2014-05-22 9:17 [PATCH 0/2] ASoC: max98090/max98095: Add master clock handing Tushar Behera
2014-05-22 9:17 ` [PATCH 2/2] ASoC: max98095: Add master clock handling Tushar Behera
2014-05-22 10:31 ` Mark Brown
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).