Commit 2c782f59 authored by Mark Brown's avatar Mark Brown

ASoC: Implement support for CLK_POUT as MCLK on Zylonite

The Zylonite supports switching the MCLK for the WM9713 between the
AC97CLK and CLK_POUT outputs of the PXA processor via switch SW15 on
the board. This patch adds support for configuring the system to use
CLK_POUT.

Unfortunately it is not possible to read the state of SW15 from software
so this feature is controlled by a module option 'clk_pout' which should
be set to a non-zero value to enable the use of CLK_POUT.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent c42f69bb
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/clk.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -26,6 +27,17 @@ ...@@ -26,6 +27,17 @@
#include "pxa2xx-ac97.h" #include "pxa2xx-ac97.h"
#include "pxa-ssp.h" #include "pxa-ssp.h"
/*
* There is a physical switch SW15 on the board which changes the MCLK
* for the WM9713 between the standard AC97 master clock and the
* output of the CLK_POUT signal from the PXA.
*/
static int clk_pout;
module_param(clk_pout, int, 0);
MODULE_PARM_DESC(clk_pout, "Use CLK_POUT as WM9713 MCLK (SW15 on board).");
static struct clk *pout;
static struct snd_soc_card zylonite; static struct snd_soc_card zylonite;
static const struct snd_soc_dapm_widget zylonite_dapm_widgets[] = { static const struct snd_soc_dapm_widget zylonite_dapm_widgets[] = {
...@@ -61,10 +73,8 @@ static const struct snd_soc_dapm_route audio_map[] = { ...@@ -61,10 +73,8 @@ static const struct snd_soc_dapm_route audio_map[] = {
static int zylonite_wm9713_init(struct snd_soc_codec *codec) static int zylonite_wm9713_init(struct snd_soc_codec *codec)
{ {
/* Currently we only support use of the AC97 clock here. If if (clk_pout)
* CLK_POUT is selected by SW15 then the clock API will need snd_soc_dai_set_pll(&codec->dai[0], 0, clk_get_rate(pout), 0);
* to be used to request and enable it here.
*/
snd_soc_dapm_new_controls(codec, zylonite_dapm_widgets, snd_soc_dapm_new_controls(codec, zylonite_dapm_widgets,
ARRAY_SIZE(zylonite_dapm_widgets)); ARRAY_SIZE(zylonite_dapm_widgets));
...@@ -85,7 +95,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, ...@@ -85,7 +95,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
unsigned int pll_out = 0;
unsigned int acds = 0; unsigned int acds = 0;
unsigned int wm9713_div = 0; unsigned int wm9713_div = 0;
int ret = 0; int ret = 0;
...@@ -93,16 +102,13 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, ...@@ -93,16 +102,13 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
switch (params_rate(params)) { switch (params_rate(params)) {
case 8000: case 8000:
wm9713_div = 12; wm9713_div = 12;
pll_out = 2048000;
break; break;
case 16000: case 16000:
wm9713_div = 6; wm9713_div = 6;
pll_out = 4096000;
break; break;
case 48000: case 48000:
default: default:
wm9713_div = 2; wm9713_div = 2;
pll_out = 12288000;
acds = 1; acds = 1;
break; break;
} }
...@@ -123,10 +129,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, ...@@ -123,10 +129,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, pll_out);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds); ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -135,9 +137,10 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, ...@@ -135,9 +137,10 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Note that if the PLL is in use the WM9713_PCMCLK_PLL_DIV needs if (clk_pout)
* to be set instead. ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_PLL_DIV,
*/ WM9713_PCMDIV(wm9713_div));
else
ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_DIV, ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_DIV,
WM9713_PCMDIV(wm9713_div)); WM9713_PCMDIV(wm9713_div));
if (ret < 0) if (ret < 0)
...@@ -173,8 +176,72 @@ static struct snd_soc_dai_link zylonite_dai[] = { ...@@ -173,8 +176,72 @@ static struct snd_soc_dai_link zylonite_dai[] = {
}, },
}; };
static int zylonite_probe(struct platform_device *pdev)
{
int ret;
if (clk_pout) {
pout = clk_get(NULL, "CLK_POUT");
if (IS_ERR(pout)) {
dev_err(&pdev->dev, "Unable to obtain CLK_POUT: %ld\n",
PTR_ERR(pout));
return PTR_ERR(pout);
}
ret = clk_enable(pout);
if (ret != 0) {
dev_err(&pdev->dev, "Unable to enable CLK_POUT: %d\n",
ret);
clk_put(pout);
return ret;
}
dev_dbg(&pdev->dev, "MCLK enabled at %luHz\n",
clk_get_rate(pout));
}
return 0;
}
static int zylonite_remove(struct platform_device *pdev)
{
if (clk_pout) {
clk_disable(pout);
clk_put(pout);
}
return 0;
}
static int zylonite_suspend_post(struct platform_device *pdev,
pm_message_t state)
{
if (clk_pout)
clk_disable(pout);
return 0;
}
static int zylonite_resume_pre(struct platform_device *pdev)
{
int ret = 0;
if (clk_pout) {
ret = clk_enable(pout);
if (ret != 0)
dev_err(&pdev->dev, "Unable to enable CLK_POUT: %d\n",
ret);
}
return ret;
}
static struct snd_soc_card zylonite = { static struct snd_soc_card zylonite = {
.name = "Zylonite", .name = "Zylonite",
.probe = &zylonite_probe,
.remove = &zylonite_remove,
.suspend_post = &zylonite_suspend_post,
.resume_pre = &zylonite_resume_pre,
.platform = &pxa2xx_soc_platform, .platform = &pxa2xx_soc_platform,
.dai_link = zylonite_dai, .dai_link = zylonite_dai,
.num_links = ARRAY_SIZE(zylonite_dai), .num_links = ARRAY_SIZE(zylonite_dai),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment