Revert "microblaze_mmu_v2: Update signal returning address"
[linux/fpc-iii.git] / sound / soc / fsl / eukrea-tlv320.c
blobefb9ede01208f8cbe6f66b597f1253ecd780e96f
1 /*
2 * eukrea-tlv320.c -- SoC audio for eukrea_cpuimxXX in I2S mode
4 * Copyright 2010 Eric Bénard, Eukréa Electromatique <eric@eukrea.com>
6 * based on sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c
7 * which is Copyright 2009 Simtec Electronics
8 * and on sound/soc/imx/phycore-ac97.c which is
9 * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
18 #include <linux/module.h>
19 #include <linux/moduleparam.h>
20 #include <linux/device.h>
21 #include <linux/i2c.h>
22 #include <sound/core.h>
23 #include <sound/pcm.h>
24 #include <sound/soc.h>
25 #include <asm/mach-types.h>
27 #include "../codecs/tlv320aic23.h"
28 #include "imx-ssi.h"
29 #include "imx-audmux.h"
31 #define CODEC_CLOCK 12000000
33 static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream,
34 struct snd_pcm_hw_params *params)
36 struct snd_soc_pcm_runtime *rtd = substream->private_data;
37 struct snd_soc_dai *codec_dai = rtd->codec_dai;
38 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
39 int ret;
41 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
42 SND_SOC_DAIFMT_NB_NF |
43 SND_SOC_DAIFMT_CBM_CFM);
44 if (ret) {
45 pr_err("%s: failed set cpu dai format\n", __func__);
46 return ret;
49 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
50 SND_SOC_DAIFMT_NB_NF |
51 SND_SOC_DAIFMT_CBM_CFM);
52 if (ret) {
53 pr_err("%s: failed set codec dai format\n", __func__);
54 return ret;
57 ret = snd_soc_dai_set_sysclk(codec_dai, 0,
58 CODEC_CLOCK, SND_SOC_CLOCK_OUT);
59 if (ret) {
60 pr_err("%s: failed setting codec sysclk\n", __func__);
61 return ret;
63 snd_soc_dai_set_tdm_slot(cpu_dai, 0xffffffc, 0xffffffc, 2, 0);
65 ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, 0,
66 SND_SOC_CLOCK_IN);
67 if (ret) {
68 pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n");
69 return ret;
72 return 0;
75 static struct snd_soc_ops eukrea_tlv320_snd_ops = {
76 .hw_params = eukrea_tlv320_hw_params,
79 static struct snd_soc_dai_link eukrea_tlv320_dai = {
80 .name = "tlv320aic23",
81 .stream_name = "TLV320AIC23",
82 .codec_dai_name = "tlv320aic23-hifi",
83 .platform_name = "imx-fiq-pcm-audio.0",
84 .codec_name = "tlv320aic23-codec.0-001a",
85 .cpu_dai_name = "imx-ssi.0",
86 .ops = &eukrea_tlv320_snd_ops,
89 static struct snd_soc_card eukrea_tlv320 = {
90 .name = "cpuimx-audio",
91 .owner = THIS_MODULE,
92 .dai_link = &eukrea_tlv320_dai,
93 .num_links = 1,
96 static struct platform_device *eukrea_tlv320_snd_device;
98 static int __init eukrea_tlv320_init(void)
100 int ret;
101 int int_port = 0, ext_port;
103 if (machine_is_eukrea_cpuimx27()) {
104 imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
105 IMX_AUDMUX_V1_PCR_SYN |
106 IMX_AUDMUX_V1_PCR_TFSDIR |
107 IMX_AUDMUX_V1_PCR_TCLKDIR |
108 IMX_AUDMUX_V1_PCR_RFSDIR |
109 IMX_AUDMUX_V1_PCR_RCLKDIR |
110 IMX_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
111 IMX_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
112 IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4)
114 imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4,
115 IMX_AUDMUX_V1_PCR_SYN |
116 IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
118 } else if (machine_is_eukrea_cpuimx25sd() ||
119 machine_is_eukrea_cpuimx35sd() ||
120 machine_is_eukrea_cpuimx51sd()) {
121 ext_port = machine_is_eukrea_cpuimx25sd() ? 4 : 3;
122 imx_audmux_v2_configure_port(int_port,
123 IMX_AUDMUX_V2_PTCR_SYN |
124 IMX_AUDMUX_V2_PTCR_TFSDIR |
125 IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) |
126 IMX_AUDMUX_V2_PTCR_TCLKDIR |
127 IMX_AUDMUX_V2_PTCR_TCSEL(ext_port),
128 IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port)
130 imx_audmux_v2_configure_port(ext_port,
131 IMX_AUDMUX_V2_PTCR_SYN,
132 IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)
134 } else {
135 /* return happy. We might run on a totally different machine */
136 return 0;
139 eukrea_tlv320_snd_device = platform_device_alloc("soc-audio", -1);
140 if (!eukrea_tlv320_snd_device)
141 return -ENOMEM;
143 platform_set_drvdata(eukrea_tlv320_snd_device, &eukrea_tlv320);
144 ret = platform_device_add(eukrea_tlv320_snd_device);
146 if (ret) {
147 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
148 platform_device_put(eukrea_tlv320_snd_device);
151 return ret;
154 static void __exit eukrea_tlv320_exit(void)
156 platform_device_unregister(eukrea_tlv320_snd_device);
159 module_init(eukrea_tlv320_init);
160 module_exit(eukrea_tlv320_exit);
162 MODULE_AUTHOR("Eric Bénard <eric@eukrea.com>");
163 MODULE_DESCRIPTION("CPUIMX ALSA SoC driver");
164 MODULE_LICENSE("GPL");