4 * Copyright 2011 Vista Silicon S.L.
6 * Author: Javier Martin <javier.martin@vista-silicon.com>
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.
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.
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,
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>
35 #include "../codecs/tlv320aic32x4.h"
38 static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream
*substream
,
39 struct snd_pcm_hw_params
*params
)
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
;
47 dai_format
= SND_SOC_DAIFMT_DSP_B
| SND_SOC_DAIFMT_NB_NF
|
48 SND_SOC_DAIFMT_CBM_CFM
;
50 /* set codec DAI configuration */
51 snd_soc_dai_set_fmt(codec_dai
, dai_format
);
53 /* set cpu DAI configuration */
54 snd_soc_dai_set_fmt(cpu_dai
, dai_format
);
56 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0,
57 25000000, SND_SOC_CLOCK_OUT
);
59 pr_err("%s: failed setting codec sysclk\n", __func__
);
63 ret
= snd_soc_dai_set_sysclk(cpu_dai
, IMX_SSP_SYS_CLK
, 0,
66 pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n");
73 static struct snd_soc_ops mx27vis_aic32x4_snd_ops
= {
74 .hw_params
= mx27vis_aic32x4_hw_params
,
77 static const struct snd_kcontrol_new mx27vis_aic32x4_controls
[] = {
78 SOC_DAPM_PIN_SWITCH("External Mic"),
81 static const struct snd_soc_dapm_widget aic32x4_dapm_widgets
[] = {
82 SND_SOC_DAPM_MIC("External Mic", NULL
),
85 static const struct snd_soc_dapm_route aic32x4_dapm_routes
[] = {
86 {"Mic Bias", NULL
, "External Mic"},
87 {"IN1_R", NULL
, "Mic Bias"},
88 {"IN2_R", NULL
, "Mic Bias"},
89 {"IN3_R", NULL
, "Mic Bias"},
90 {"IN1_L", NULL
, "Mic Bias"},
91 {"IN2_L", NULL
, "Mic Bias"},
92 {"IN3_L", NULL
, "Mic Bias"},
95 static struct snd_soc_dai_link mx27vis_aic32x4_dai
= {
96 .name
= "tlv320aic32x4",
97 .stream_name
= "TLV320AIC32X4",
98 .codec_dai_name
= "tlv320aic32x4-hifi",
99 .platform_name
= "imx-pcm-audio.0",
100 .codec_name
= "tlv320aic32x4.0-0018",
101 .cpu_dai_name
= "imx-ssi.0",
102 .ops
= &mx27vis_aic32x4_snd_ops
,
105 static struct snd_soc_card mx27vis_aic32x4
= {
106 .name
= "visstrim_m10-audio",
107 .owner
= THIS_MODULE
,
108 .dai_link
= &mx27vis_aic32x4_dai
,
110 .controls
= mx27vis_aic32x4_controls
,
111 .num_controls
= ARRAY_SIZE(mx27vis_aic32x4_controls
),
112 .dapm_widgets
= aic32x4_dapm_widgets
,
113 .num_dapm_widgets
= ARRAY_SIZE(aic32x4_dapm_widgets
),
114 .dapm_routes
= aic32x4_dapm_routes
,
115 .num_dapm_routes
= ARRAY_SIZE(aic32x4_dapm_routes
),
118 static struct platform_device
*mx27vis_aic32x4_snd_device
;
120 static int __init
mx27vis_aic32x4_init(void)
124 mx27vis_aic32x4_snd_device
= platform_device_alloc("soc-audio", -1);
125 if (!mx27vis_aic32x4_snd_device
)
128 platform_set_drvdata(mx27vis_aic32x4_snd_device
, &mx27vis_aic32x4
);
129 ret
= platform_device_add(mx27vis_aic32x4_snd_device
);
132 printk(KERN_ERR
"ASoC: Platform device allocation failed\n");
133 platform_device_put(mx27vis_aic32x4_snd_device
);
136 /* Connect SSI0 as clock slave to SSI1 external pins */
137 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0
,
138 MXC_AUDMUX_V1_PCR_SYN
|
139 MXC_AUDMUX_V1_PCR_TFSDIR
|
140 MXC_AUDMUX_V1_PCR_TCLKDIR
|
141 MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1
) |
142 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1
)
144 mxc_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1
,
145 MXC_AUDMUX_V1_PCR_SYN
|
146 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0
)
152 static void __exit
mx27vis_aic32x4_exit(void)
154 platform_device_unregister(mx27vis_aic32x4_snd_device
);
157 module_init(mx27vis_aic32x4_init
);
158 module_exit(mx27vis_aic32x4_exit
);
160 MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
161 MODULE_DESCRIPTION("ALSA SoC AIC32X4 mx27 visstrim");
162 MODULE_LICENSE("GPL");