From: Cliff Cai <cliff.cai@xxxxxxxxxx> Signed-off-by: Cliff Cai <cliff.cai@xxxxxxxxxx> Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx> --- sound/soc/blackfin/Kconfig | 9 ++ sound/soc/blackfin/Makefile | 2 + sound/soc/blackfin/bf5xx-adau1361.c | 144 +++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 0 deletions(-) create mode 100644 sound/soc/blackfin/bf5xx-adau1361.c diff --git a/sound/soc/blackfin/Kconfig b/sound/soc/blackfin/Kconfig index b73ee38..56eb6c6 100644 --- a/sound/soc/blackfin/Kconfig +++ b/sound/soc/blackfin/Kconfig @@ -32,6 +32,15 @@ config SND_BFIN_AD73311_SE Enter the GPIO used to control AD73311's SE pin. Acceptable values are 0 to 7 +config SND_BF5XX_SOC_ADAU1361 + tristate "SoC ADAU1361 Audio support" + depends on SND_BF5XX_I2S + select SND_BF5XX_SOC_I2S + select SND_SOC_ADAU1361 + select I2C + help + Say Y if you want to add support for ADAU1361 SoC audio. + config SND_BF5XX_SOC_ADAV80X tristate "SoC ADAV801/3 Audio support" depends on SND_BF5XX_I2S && (SPI_MASTER || I2C) diff --git a/sound/soc/blackfin/Makefile b/sound/soc/blackfin/Makefile index 872dac8..9de1fc9 100644 --- a/sound/soc/blackfin/Makefile +++ b/sound/soc/blackfin/Makefile @@ -21,6 +21,7 @@ snd-ad1980-objs := bf5xx-ad1980.o snd-ssm2602-objs := bf5xx-ssm2602.o snd-ad73311-objs := bf5xx-ad73311.o snd-ad193x-objs := bf5xx-ad193x.o +snd-adau1361-objs := bf5xx-adau1361.o snd-adav80x-objs := bf5xx-adav80x.o obj-$(CONFIG_SND_BF5XX_SOC_AD1836) += snd-ad1836.o @@ -28,4 +29,5 @@ obj-$(CONFIG_SND_BF5XX_SOC_AD1980) += snd-ad1980.o obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o +obj-$(CONFIG_SND_BF5XX_SOC_ADAU1361) += snd-adau1361.o obj-$(CONFIG_SND_BF5XX_SOC_ADAV80X) += snd-adav80x.o diff --git a/sound/soc/blackfin/bf5xx-adau1361.c b/sound/soc/blackfin/bf5xx-adau1361.c new file mode 100644 index 0000000..1748738 --- /dev/null +++ b/sound/soc/blackfin/bf5xx-adau1361.c @@ -0,0 +1,144 @@ +/* + * board driver for adau1361 sound chip + * + * Copyright 2009 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/device.h> + +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/pcm_params.h> + +#include <asm/dma.h> +#include <asm/portmux.h> +#include <linux/gpio.h> +#include "../codecs/adau1361.h" +#include "bf5xx-sport.h" +#include "bf5xx-i2s-pcm.h" +#include "bf5xx-i2s.h" + +static int bf5xx_adau1361_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->dai->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + unsigned int pll_in = 0, pll_out = 0; + int ret = 0; + + switch (params_rate(params)) { + case 11025: + case 22050: + case 44100: + case 88200: + pll_out = ADAU1361_PLL_FREQ_441; + break; + case 8000: + case 12000: + case 16000: + case 24000: + case 32000: + case 48000: + case 64000: + case 96000: + pll_out = ADAU1361_PLL_FREQ_48; + break; + default: + pll_out = ADAU1361_PLL_FREQ_441; + break; + } + + /* set codec DAI configuration */ + ret = codec_dai->ops->set_fmt(codec_dai, + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM); + if (ret < 0) + return ret; + + /* set cpu DAI configuration */ + ret = cpu_dai->ops->set_fmt(cpu_dai, + SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM); + if (ret < 0) + return ret; + + /* set the codec system clock for DAC and ADC */ + pll_in = ADAU1361_MCLK_RATE; /* fixed rate MCLK */ + ret = codec_dai->ops->set_sysclk(codec_dai, ADAU1361_MCLK_ID, pll_in, + SND_SOC_CLOCK_IN); + if (ret < 0) + return ret; + + /* codec PLL input is PCLK/4 */ + ret = codec_dai->ops->set_pll(codec_dai, 0, 0, pll_in, pll_out); + if (ret < 0) + return ret; + + return 0; +} + +static struct snd_soc_ops bf5xx_adau1361_ops = { + .hw_params = bf5xx_adau1361_hw_params, +}; + +static struct snd_soc_dai_link bf5xx_adau1361_dai = { + .name = "adau1361", + .stream_name = "adau1361", + .cpu_dai = &bf5xx_i2s_dai, + .codec_dai = &adau1361_dai, + .ops = &bf5xx_adau1361_ops, +}; + +static struct snd_soc_card bf5xx_adau1361 = { + .name = "bf5xx_adau1361", + .platform = &bf5xx_i2s_soc_platform, + .dai_link = &bf5xx_adau1361_dai, + .num_links = 1, +}; + +static struct snd_soc_device bf5xx_adau1361_snd_devdata = { + .card = &bf5xx_adau1361, + .codec_dev = &soc_codec_dev_adau1361, +}; + +static struct platform_device *bf5xx_adau1361_snd_device; + +static int __init bf5xx_adau1361_init(void) +{ + int ret; + + pr_debug("%s enter\n", __func__); + bf5xx_adau1361_snd_device = platform_device_alloc("soc-audio", -1); + if (!bf5xx_adau1361_snd_device) + return -ENOMEM; + + platform_set_drvdata(bf5xx_adau1361_snd_device, + &bf5xx_adau1361_snd_devdata); + bf5xx_adau1361_snd_devdata.dev = &bf5xx_adau1361_snd_device->dev; + ret = platform_device_add(bf5xx_adau1361_snd_device); + + if (ret) + platform_device_put(bf5xx_adau1361_snd_device); + + return ret; +} +module_init(bf5xx_adau1361_init); + +static void __exit bf5xx_adau1361_exit(void) +{ + pr_debug("%s enter\n", __func__); + platform_device_unregister(bf5xx_adau1361_snd_device); +} +module_exit(bf5xx_adau1361_exit); + +/* Module information */ +MODULE_AUTHOR("Cliff Cai"); +MODULE_DESCRIPTION("ALSA SoC adau1361"); +MODULE_LICENSE("GPL"); -- 1.7.2 _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel