diff options
author | Eric Bénard <eric@eukrea.com> | 2010-05-27 04:58:55 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-06-03 14:00:38 -0400 |
commit | 91157888f28ae94761eaf25533f76a55542b2a3f (patch) | |
tree | c6140e605055c49b424df815a06e17310b80df88 /sound/soc/imx | |
parent | 0e79612012e1da66133e3c8499bc7c020f006c89 (diff) |
ASoC: imx: add eukrea-tlv320
Add the necessary files to support the TLV320AIC23B wired in I2S
on our i.MX platforms.
Signed-off-by: Eric Bénard <eric@eukrea.com>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/imx')
-rw-r--r-- | sound/soc/imx/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/imx/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/imx/eukrea-tlv320.c | 135 |
3 files changed, 146 insertions, 0 deletions
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig index 252defea93b5..079b23bb0b03 100644 --- a/sound/soc/imx/Kconfig +++ b/sound/soc/imx/Kconfig | |||
@@ -28,3 +28,12 @@ config SND_SOC_PHYCORE_AC97 | |||
28 | help | 28 | help |
29 | Say Y if you want to add support for SoC audio on Phytec phyCORE | 29 | Say Y if you want to add support for SoC audio on Phytec phyCORE |
30 | and phyCARD boards in AC97 mode | 30 | and phyCARD boards in AC97 mode |
31 | |||
32 | config SND_SOC_EUKREA_TLV320 | ||
33 | bool "Eukrea TLV320" | ||
34 | depends on MACH_EUKREA_MBIMX27_BASEBOARD | ||
35 | select SND_IMX_SOC | ||
36 | select SND_SOC_TLV320AIC23 | ||
37 | help | ||
38 | Enable I2S based access to the TLV320AIC23B codec attached | ||
39 | to the SSI4 interface | ||
diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile index 2d203635ac11..7bc57baf2b0e 100644 --- a/sound/soc/imx/Makefile +++ b/sound/soc/imx/Makefile | |||
@@ -8,8 +8,10 @@ endif | |||
8 | obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o | 8 | obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o |
9 | 9 | ||
10 | # i.MX Machine Support | 10 | # i.MX Machine Support |
11 | snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o | ||
11 | snd-soc-phycore-ac97-objs := phycore-ac97.o | 12 | snd-soc-phycore-ac97-objs := phycore-ac97.o |
12 | snd-soc-wm1133-ev1-objs := wm1133-ev1.o | 13 | snd-soc-wm1133-ev1-objs := wm1133-ev1.o |
13 | 14 | ||
15 | obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o | ||
14 | obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o | 16 | obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o |
15 | obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o | 17 | obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o |
diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/imx/eukrea-tlv320.c new file mode 100644 index 000000000000..968380a93e89 --- /dev/null +++ b/sound/soc/imx/eukrea-tlv320.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * eukrea-tlv320.c -- SoC audio for eukrea_cpuimxXX in I2S mode | ||
3 | * | ||
4 | * Copyright 2010 Eric Bénard, Eukréa Electromatique <eric@eukrea.com> | ||
5 | * | ||
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> | ||
10 | * | ||
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. | ||
15 | * | ||
16 | */ | ||
17 | |||
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 <sound/soc-dapm.h> | ||
26 | #include <asm/mach-types.h> | ||
27 | |||
28 | #include "../codecs/tlv320aic23.h" | ||
29 | #include "imx-ssi.h" | ||
30 | |||
31 | #define CODEC_CLOCK 12000000 | ||
32 | |||
33 | static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, | ||
34 | struct snd_pcm_hw_params *params) | ||
35 | { | ||
36 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
37 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
38 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
39 | int ret; | ||
40 | |||
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; | ||
47 | } | ||
48 | |||
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; | ||
55 | } | ||
56 | |||
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; | ||
62 | } | ||
63 | |||
64 | ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, 0, | ||
65 | SND_SOC_CLOCK_IN); | ||
66 | if (ret) { | ||
67 | pr_err("can't set CPU system clock IMX_SSP_SYS_CLK\n"); | ||
68 | return ret; | ||
69 | } | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static struct snd_soc_ops eukrea_tlv320_snd_ops = { | ||
75 | .hw_params = eukrea_tlv320_hw_params, | ||
76 | }; | ||
77 | |||
78 | static struct snd_soc_dai_link eukrea_tlv320_dai = { | ||
79 | .name = "tlv320aic23", | ||
80 | .stream_name = "TLV320AIC23", | ||
81 | .codec_dai = &tlv320aic23_dai, | ||
82 | .ops = &eukrea_tlv320_snd_ops, | ||
83 | }; | ||
84 | |||
85 | static struct snd_soc_card eukrea_tlv320 = { | ||
86 | .name = "cpuimx-audio", | ||
87 | .platform = &imx_soc_platform, | ||
88 | .dai_link = &eukrea_tlv320_dai, | ||
89 | .num_links = 1, | ||
90 | }; | ||
91 | |||
92 | static struct snd_soc_device eukrea_tlv320_snd_devdata = { | ||
93 | .card = &eukrea_tlv320, | ||
94 | .codec_dev = &soc_codec_dev_tlv320aic23, | ||
95 | }; | ||
96 | |||
97 | static struct platform_device *eukrea_tlv320_snd_device; | ||
98 | |||
99 | static int __init eukrea_tlv320_init(void) | ||
100 | { | ||
101 | int ret; | ||
102 | |||
103 | if (!machine_is_eukrea_cpuimx27()) | ||
104 | /* return happy. We might run on a totally different machine */ | ||
105 | return 0; | ||
106 | |||
107 | eukrea_tlv320_snd_device = platform_device_alloc("soc-audio", -1); | ||
108 | if (!eukrea_tlv320_snd_device) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | eukrea_tlv320_dai.cpu_dai = &imx_ssi_pcm_dai[0]; | ||
112 | |||
113 | platform_set_drvdata(eukrea_tlv320_snd_device, &eukrea_tlv320_snd_devdata); | ||
114 | eukrea_tlv320_snd_devdata.dev = &eukrea_tlv320_snd_device->dev; | ||
115 | ret = platform_device_add(eukrea_tlv320_snd_device); | ||
116 | |||
117 | if (ret) { | ||
118 | printk(KERN_ERR "ASoC: Platform device allocation failed\n"); | ||
119 | platform_device_put(eukrea_tlv320_snd_device); | ||
120 | } | ||
121 | |||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | static void __exit eukrea_tlv320_exit(void) | ||
126 | { | ||
127 | platform_device_unregister(eukrea_tlv320_snd_device); | ||
128 | } | ||
129 | |||
130 | module_init(eukrea_tlv320_init); | ||
131 | module_exit(eukrea_tlv320_exit); | ||
132 | |||
133 | MODULE_AUTHOR("Eric Bénard <eric@eukrea.com>"); | ||
134 | MODULE_DESCRIPTION("CPUIMX ALSA SoC driver"); | ||
135 | MODULE_LICENSE("GPL"); | ||