Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132846
b: refs/heads/master
c: 5de7f9b
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Feb 18, 2009
1 parent 1a5e6d4 commit 7c4a83e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 40135ea07190316a789b2edfbf7c8131598bdf81
refs/heads/master: 5de7f9b20069257aa5f0bb74723c8603adc5841a
68 changes: 65 additions & 3 deletions trunk/sound/soc/atmel/sam9g20_wm8731.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@
#include "atmel-pcm.h"
#include "atmel_ssc_dai.h"

#define MCLK_RATE 12000000

static struct clk *mclk;

static int at91sam9g20ek_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
int ret;

/* codec system clock is supplied by PCK0, set to 12MHz */
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
12000000, SND_SOC_CLOCK_IN);
if (ret < 0)
MCLK_RATE, SND_SOC_CLOCK_IN);
if (ret < 0) {
clk_disable(mclk);
return ret;
}

return 0;
}
Expand Down Expand Up @@ -190,6 +194,31 @@ static struct snd_soc_ops at91sam9g20ek_ops = {
.shutdown = at91sam9g20ek_shutdown,
};

static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
enum snd_soc_bias_level level)
{
static int mclk_on;
int ret = 0;

switch (level) {
case SND_SOC_BIAS_ON:
case SND_SOC_BIAS_PREPARE:
if (!mclk_on)
ret = clk_enable(mclk);
if (ret == 0)
mclk_on = 1;
break;

case SND_SOC_BIAS_OFF:
case SND_SOC_BIAS_STANDBY:
if (mclk_on)
clk_disable(mclk);
mclk_on = 0;
break;
}

return ret;
}

static const struct snd_soc_dapm_widget at91sam9g20ek_dapm_widgets[] = {
SND_SOC_DAPM_MIC("Int Mic", NULL),
Expand Down Expand Up @@ -248,6 +277,7 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
.platform = &atmel_soc_platform,
.dai_link = &at91sam9g20ek_dai,
.num_links = 1,
.set_bias_level = at91sam9g20ek_set_bias_level,
};

static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = {
Expand All @@ -267,11 +297,37 @@ static int __init at91sam9g20ek_init(void)
{
struct atmel_ssc_info *ssc_p = at91sam9g20ek_dai.cpu_dai->private_data;
struct ssc_device *ssc = NULL;
struct clk *pllb;
int ret;

if (!machine_is_at91sam9g20ek())
return -ENODEV;

/*
* Codec MCLK is supplied by PCK0 - set it up.
*/
mclk = clk_get(NULL, "pck0");
if (IS_ERR(mclk)) {
printk(KERN_ERR "ASoC: Failed to get MCLK\n");
ret = PTR_ERR(mclk);
goto err;
}

pllb = clk_get(NULL, "pllb");
if (IS_ERR(mclk)) {
printk(KERN_ERR "ASoC: Failed to get PLLB\n");
ret = PTR_ERR(mclk);
goto err_mclk;
}
ret = clk_set_parent(mclk, pllb);
clk_put(pllb);
if (ret != 0) {
printk(KERN_ERR "ASoC: Failed to set MCLK parent\n");
goto err_mclk;
}

clk_set_rate(mclk, MCLK_RATE);

/*
* Request SSC device
*/
Expand Down Expand Up @@ -303,6 +359,10 @@ static int __init at91sam9g20ek_init(void)
return ret;

err_ssc:
err_mclk:
clk_put(mclk);
mclk = NULL;
err:
return ret;
}

Expand All @@ -320,6 +380,8 @@ static void __exit at91sam9g20ek_exit(void)

platform_device_unregister(at91sam9g20ek_snd_device);
at91sam9g20ek_snd_device = NULL;
clk_put(mclk);
mclk = NULL;
}

module_init(at91sam9g20ek_init);
Expand Down

0 comments on commit 7c4a83e

Please sign in to comment.