aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorPhilippe Rétornaz <philippe.retornaz@epfl.ch>2012-05-15 07:53:51 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-05-18 11:42:21 -0400
commit6b0a795a17d36cc880591c935cf84fce228193ad (patch)
treea51d3f598402e36e4c44a4e5ad6565ee5d4d2e2c /sound/soc
parent8b908b8660f919a1a5135bc46acae12445767903 (diff)
ASoC: add imx-mc13783 sound support
Signed-off-by: Philippe Rétornaz <philippe.retornaz@epfl.ch> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/fsl/Kconfig8
-rw-r--r--sound/soc/fsl/Makefile2
-rw-r--r--sound/soc/fsl/imx-mc13783.c163
3 files changed, 173 insertions, 0 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 0094789c43ff..3f2dd3a0377a 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -171,4 +171,12 @@ config SND_SOC_IMX_SGTL5000
171 Say Y if you want to add support for SoC audio on an i.MX board with 171 Say Y if you want to add support for SoC audio on an i.MX board with
172 a sgtl5000 codec. 172 a sgtl5000 codec.
173 173
174config SND_SOC_IMX_MC13783
175 tristate "SoC Audio support for I.MX boards with mc13783"
176 depends on MFD_MC13783
177 select SND_SOC_IMX_SSI
178 select SND_SOC_IMX_AUDMUX
179 select SND_SOC_MC13783
180 select SND_SOC_IMX_PCM_DMA
181
174endif # SND_IMX_SOC 182endif # SND_IMX_SOC
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 638d3852601a..5f3cf3f52ea0 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -41,9 +41,11 @@ snd-soc-phycore-ac97-objs := phycore-ac97.o
41snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o 41snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o
42snd-soc-wm1133-ev1-objs := wm1133-ev1.o 42snd-soc-wm1133-ev1-objs := wm1133-ev1.o
43snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o 43snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o
44snd-soc-imx-mc13783-objs := imx-mc13783.o
44 45
45obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o 46obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
46obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o 47obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o
47obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o 48obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o
48obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o 49obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o
49obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o 50obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
51obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
diff --git a/sound/soc/fsl/imx-mc13783.c b/sound/soc/fsl/imx-mc13783.c
new file mode 100644
index 000000000000..a7b717004e4e
--- /dev/null
+++ b/sound/soc/fsl/imx-mc13783.c
@@ -0,0 +1,163 @@
1/*
2 * imx-mc13783.c -- SoC audio for imx based boards with mc13783 codec
3 *
4 * Copyright 2012 Philippe Retornaz, <philippe.retornaz@epfl.ch>
5 *
6 * Heavly based on phycore-mc13783:
7 * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 */
15
16#include <linux/module.h>
17#include <linux/moduleparam.h>
18#include <linux/device.h>
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/soc.h>
22#include <sound/soc-dapm.h>
23#include <asm/mach-types.h>
24
25#include "../codecs/mc13783.h"
26#include "imx-ssi.h"
27#include "imx-audmux.h"
28
29#define FMT_SSI (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | \
30 SND_SOC_DAIFMT_CBM_CFM)
31
32static int imx_mc13783_hifi_hw_params(struct snd_pcm_substream *substream,
33 struct snd_pcm_hw_params *params)
34{
35 struct snd_soc_pcm_runtime *rtd = substream->private_data;
36 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
37 struct snd_soc_dai *codec_dai = rtd->codec_dai;
38 int ret;
39
40 ret = snd_soc_dai_set_fmt(codec_dai, FMT_SSI);
41 if (ret)
42 return ret;
43
44 ret = snd_soc_dai_set_fmt(cpu_dai, FMT_SSI);
45 if (ret)
46 return ret;
47
48 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xfffffffc, 0xfffffffc,
49 4, 16);
50 if (ret)
51 return ret;
52
53 ret = snd_soc_dai_set_sysclk(codec_dai, MC13783_CLK_CLIA, 26000000, 0);
54 if (ret)
55 return ret;
56
57 ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x0, 0xfffffffc, 2, 16);
58 if (ret)
59 return ret;
60
61 return 0;
62}
63
64static struct snd_soc_ops imx_mc13783_hifi_ops = {
65 .hw_params = imx_mc13783_hifi_hw_params,
66};
67
68static struct snd_soc_dai_link imx_mc13783_dai_mc13783[] = {
69 {
70 .name = "MC13783",
71 .stream_name = "Sound",
72 .codec_dai_name = "mc13783-hifi",
73 .codec_name = "mc13783-codec",
74 .cpu_dai_name = "imx-ssi.0",
75 .platform_name = "imx-pcm-audio.0",
76 .ops = &imx_mc13783_hifi_ops,
77 .symmetric_rates = 1,
78 },
79};
80
81static const struct snd_soc_dapm_widget imx_mc13783_widget[] = {
82 SND_SOC_DAPM_MIC("Mic", NULL),
83 SND_SOC_DAPM_HP("Headphone", NULL),
84 SND_SOC_DAPM_SPK("Speaker", NULL),
85};
86
87static const struct snd_soc_dapm_route imx_mc13783_routes[] = {
88 {"Speaker", NULL, "LSP"},
89 {"Headphone", NULL, "HSL"},
90 {"Headphone", NULL, "HSR"},
91
92 {"MC1LIN", NULL, "MC1 Bias"},
93 {"MC2IN", NULL, "MC2 Bias"},
94 {"MC1 Bias", NULL, "Mic"},
95 {"MC2 Bias", NULL, "Mic"},
96};
97
98static struct snd_soc_card imx_mc13783 = {
99 .name = "imx_mc13783",
100 .dai_link = imx_mc13783_dai_mc13783,
101 .num_links = ARRAY_SIZE(imx_mc13783_dai_mc13783),
102 .dapm_widgets = imx_mc13783_widget,
103 .num_dapm_widgets = ARRAY_SIZE(imx_mc13783_widget),
104 .dapm_routes = imx_mc13783_routes,
105 .num_dapm_routes = ARRAY_SIZE(imx_mc13783_routes),
106};
107
108static int __devinit imx_mc13783_probe(struct platform_device *pdev)
109{
110 int ret;
111
112 imx_mc13783.dev = &pdev->dev;
113
114 ret = snd_soc_register_card(&imx_mc13783);
115 if (ret) {
116 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
117 ret);
118 return ret;
119 }
120
121 imx_audmux_v2_configure_port(MX31_AUDMUX_PORT4_SSI_PINS_4,
122 IMX_AUDMUX_V2_PTCR_SYN,
123 IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0) |
124 IMX_AUDMUX_V2_PDCR_MODE(1) |
125 IMX_AUDMUX_V2_PDCR_INMMASK(0xfc));
126 imx_audmux_v2_configure_port(MX31_AUDMUX_PORT1_SSI0,
127 IMX_AUDMUX_V2_PTCR_SYN |
128 IMX_AUDMUX_V2_PTCR_TFSDIR |
129 IMX_AUDMUX_V2_PTCR_TFSEL(MX31_AUDMUX_PORT4_SSI_PINS_4) |
130 IMX_AUDMUX_V2_PTCR_TCLKDIR |
131 IMX_AUDMUX_V2_PTCR_TCSEL(MX31_AUDMUX_PORT4_SSI_PINS_4) |
132 IMX_AUDMUX_V2_PTCR_RFSDIR |
133 IMX_AUDMUX_V2_PTCR_RFSEL(MX31_AUDMUX_PORT4_SSI_PINS_4) |
134 IMX_AUDMUX_V2_PTCR_RCLKDIR |
135 IMX_AUDMUX_V2_PTCR_RCSEL(MX31_AUDMUX_PORT4_SSI_PINS_4),
136 IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT4_SSI_PINS_4));
137
138 return ret;
139}
140
141static int __devexit imx_mc13783_remove(struct platform_device *pdev)
142{
143 snd_soc_unregister_card(&imx_mc13783);
144
145 return 0;
146}
147
148static struct platform_driver imx_mc13783_audio_driver = {
149 .driver = {
150 .name = "imx_mc13783",
151 .owner = THIS_MODULE,
152 },
153 .probe = imx_mc13783_probe,
154 .remove = __devexit_p(imx_mc13783_remove)
155};
156
157module_platform_driver(imx_mc13783_audio_driver);
158
159MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
160MODULE_AUTHOR("Philippe Retornaz <philippe.retornaz@epfl.ch");
161MODULE_DESCRIPTION("imx with mc13783 codec ALSA SoC driver");
162MODULE_LICENSE("GPL");
163MODULE_ALIAS("platform:imx_mc13783");