Merge branch 'for-linus' of git://selinuxproject.org/~jmorris/linux-security
[deliverable/linux.git] / sound / soc / imx / mx27vis-aic32x4.c
1 /*
2 * mx27vis-aic32x4.c
3 *
4 * Copyright 2011 Vista Silicon S.L.
5 *
6 * Author: Javier Martin <javier.martin@vista-silicon.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23
24 #include <linux/module.h>
25 #include <linux/moduleparam.h>
26 #include <linux/device.h>
27 #include <linux/i2c.h>
28 #include <sound/core.h>
29 #include <sound/pcm.h>
30 #include <sound/soc.h>
31 #include <sound/soc-dapm.h>
32 #include <asm/mach-types.h>
33 #include <mach/audmux.h>
34
35 #include "../codecs/tlv320aic32x4.h"
36 #include "imx-ssi.h"
37
38 static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params)
40 {
41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *codec_dai = rtd->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
44 int ret;
45 u32 dai_format;
46
47 dai_format = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
48 SND_SOC_DAIFMT_CBM_CFM;
49
50 /* set codec DAI configuration */
51 snd_soc_dai_set_fmt(codec_dai, dai_format);
52
53 /* set cpu DAI configuration */
54 snd_soc_dai_set_fmt(cpu_dai, dai_format);
55
56 ret = snd_soc_dai_set_sysclk(codec_dai, 0,
57 25000000, SND_SOC_CLOCK_OUT);
58 if (ret) {
59 pr_err("%s: failed setting codec sysclk\n", __func__);
60 return ret;
61 }
62
63 ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, 0,
64 SND_SOC_CLOCK_IN);
65 if (ret) {
66 pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n");
67 return ret;
68 }
69
70 return 0;
71 }
72
73 static struct snd_soc_ops mx27vis_aic32x4_snd_ops = {
74 .hw_params = mx27vis_aic32x4_hw_params,
75 };
76
77 static struct snd_soc_dai_link mx27vis_aic32x4_dai = {
78 .name = "tlv320aic32x4",
79 .stream_name = "TLV320AIC32X4",
80 .codec_dai_name = "tlv320aic32x4-hifi",
81 .platform_name = "imx-pcm-audio.0",
82 .codec_name = "tlv320aic32x4.0-0018",
83 .cpu_dai_name = "imx-ssi.0",
84 .ops = &mx27vis_aic32x4_snd_ops,
85 };
86
87 static struct snd_soc_card mx27vis_aic32x4 = {
88 .name = "visstrim_m10-audio",
89 .owner = THIS_MODULE,
90 .dai_link = &mx27vis_aic32x4_dai,
91 .num_links = 1,
92 };
93
94 static struct platform_device *mx27vis_aic32x4_snd_device;
95
96 static int __init mx27vis_aic32x4_init(void)
97 {
98 int ret;
99
100 mx27vis_aic32x4_snd_device = platform_device_alloc("soc-audio", -1);
101 if (!mx27vis_aic32x4_snd_device)
102 return -ENOMEM;
103
104 platform_set_drvdata(mx27vis_aic32x4_snd_device, &mx27vis_aic32x4);
105 ret = platform_device_add(mx27vis_aic32x4_snd_device);
106
107 if (ret) {
108 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
109 platform_device_put(mx27vis_aic32x4_snd_device);
110 }
111
112 /* Connect SSI0 as clock slave to SSI1 external pins */
113 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
114 MXC_AUDMUX_V1_PCR_SYN |
115 MXC_AUDMUX_V1_PCR_TFSDIR |
116 MXC_AUDMUX_V1_PCR_TCLKDIR |
117 MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) |
118 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1)
119 );
120 mxc_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1,
121 MXC_AUDMUX_V1_PCR_SYN |
122 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
123 );
124
125 return ret;
126 }
127
128 static void __exit mx27vis_aic32x4_exit(void)
129 {
130 platform_device_unregister(mx27vis_aic32x4_snd_device);
131 }
132
133 module_init(mx27vis_aic32x4_init);
134 module_exit(mx27vis_aic32x4_exit);
135
136 MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
137 MODULE_DESCRIPTION("ALSA SoC AIC32X4 mx27 visstrim");
138 MODULE_LICENSE("GPL");
This page took 0.03467 seconds and 6 git commands to generate.