diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-08-14 05:07:56 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-15 12:09:59 -0400 |
commit | fff8491c8b8cce5fc9190e025d1a665f2ee71a4f (patch) | |
tree | c4398c35a94fd868fded4e414a3b1ddf8df236c9 | |
parent | 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff) |
ASoC: omap-twl4030: Simple machine driver for TI SoC with twl4030 codec
Machine driver to handle simple devices using twl4030 as audio codec.
The driver supports the following boards:
- Beagleboard or Devkit8000
- Gumstix Overo or CompuLab CM-T35/CM-T3730
- IGEP v2
- OMAP3EVM
All of these boards can be switched to use this driver since their setup is
identical.
Devicetree support for the omap-twl4030 machine driver also implemented.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | Documentation/devicetree/bindings/sound/omap-twl4030.txt | 17 | ||||
-rw-r--r-- | include/linux/platform_data/omap-twl4030.h | 32 | ||||
-rw-r--r-- | sound/soc/omap/Kconfig | 13 | ||||
-rw-r--r-- | sound/soc/omap/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/omap/omap-twl4030.c | 188 |
5 files changed, 252 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/omap-twl4030.txt b/Documentation/devicetree/bindings/sound/omap-twl4030.txt new file mode 100644 index 000000000000..6fae51c7f766 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/omap-twl4030.txt | |||
@@ -0,0 +1,17 @@ | |||
1 | * Texas Instruments SoC with twl4030 based audio setups | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: "ti,omap-twl4030" | ||
5 | - ti,model: Name of the sound card (for example "omap3beagle") | ||
6 | - ti,mcbsp: phandle for the McBSP node | ||
7 | - ti,codec: phandle for the twl4030 audio node | ||
8 | |||
9 | Example: | ||
10 | |||
11 | sound { | ||
12 | compatible = "ti,omap-twl4030"; | ||
13 | ti,model = "omap3beagle"; | ||
14 | |||
15 | ti,mcbsp = <&mcbsp2>; | ||
16 | ti,codec = <&twl_audio>; | ||
17 | }; | ||
diff --git a/include/linux/platform_data/omap-twl4030.h b/include/linux/platform_data/omap-twl4030.h new file mode 100644 index 000000000000..c7bef788daab --- /dev/null +++ b/include/linux/platform_data/omap-twl4030.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /** | ||
2 | * omap-twl4030.h - ASoC machine driver for TI SoC based boards with twl4030 | ||
3 | * codec, header. | ||
4 | * | ||
5 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
22 | * 02110-1301 USA | ||
23 | */ | ||
24 | |||
25 | #ifndef _OMAP_TWL4030_H_ | ||
26 | #define _OMAP_TWL4030_H_ | ||
27 | |||
28 | struct omap_tw4030_pdata { | ||
29 | const char *card_name; | ||
30 | }; | ||
31 | |||
32 | #endif /* _OMAP_TWL4030_H_ */ | ||
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 57a2fa751085..fc83d748625f 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -95,6 +95,19 @@ config SND_OMAP_SOC_SDP3430 | |||
95 | Say Y if you want to add support for SoC audio on Texas Instruments | 95 | Say Y if you want to add support for SoC audio on Texas Instruments |
96 | SDP3430. | 96 | SDP3430. |
97 | 97 | ||
98 | config SND_OMAP_SOC_OMAP_TWL4030 | ||
99 | tristate "SoC Audio support for TI SoC based boards with twl4030 codec" | ||
100 | depends on TWL4030_CORE && SND_OMAP_SOC | ||
101 | select SND_OMAP_SOC_MCBSP | ||
102 | select SND_SOC_TWL4030 | ||
103 | help | ||
104 | Say Y if you want to add support for SoC audio on TI SoC based boards | ||
105 | using twl4030 as c codec. This driver currently supports: | ||
106 | - Beagleboard or Devkit8000 | ||
107 | - Gumstix Overo or CompuLab CM-T35/CM-T3730 | ||
108 | - IGEP v2 | ||
109 | - OMAP3EVM | ||
110 | |||
98 | config SND_OMAP_SOC_OMAP_ABE_TWL6040 | 111 | config SND_OMAP_SOC_OMAP_ABE_TWL6040 |
99 | tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" | 112 | tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" |
100 | depends on TWL6040_CORE && SND_OMAP_SOC && ARCH_OMAP4 | 113 | depends on TWL6040_CORE && SND_OMAP_SOC && ARCH_OMAP4 |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 0e14dd322565..861e640e2be9 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -21,6 +21,7 @@ snd-soc-omap3evm-objs := omap3evm.o | |||
21 | snd-soc-am3517evm-objs := am3517evm.o | 21 | snd-soc-am3517evm-objs := am3517evm.o |
22 | snd-soc-sdp3430-objs := sdp3430.o | 22 | snd-soc-sdp3430-objs := sdp3430.o |
23 | snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o | 23 | snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o |
24 | snd-soc-omap-twl4030-objs := omap-twl4030.o | ||
24 | snd-soc-omap3pandora-objs := omap3pandora.o | 25 | snd-soc-omap3pandora-objs := omap3pandora.o |
25 | snd-soc-omap3beagle-objs := omap3beagle.o | 26 | snd-soc-omap3beagle-objs := omap3beagle.o |
26 | snd-soc-zoom2-objs := zoom2.o | 27 | snd-soc-zoom2-objs := zoom2.o |
@@ -37,6 +38,7 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o | |||
37 | obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o | 38 | obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o |
38 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o | 39 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o |
39 | obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o | 40 | obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o |
41 | obj-$(CONFIG_SND_OMAP_SOC_OMAP_TWL4030) += snd-soc-omap-twl4030.o | ||
40 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o | 42 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o |
41 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o | 43 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o |
42 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o | 44 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o |
diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c new file mode 100644 index 000000000000..3b97b87971f5 --- /dev/null +++ b/sound/soc/omap/omap-twl4030.c | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | * omap-twl4030.c -- SoC audio for TI SoC based boards with twl4030 codec | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> | ||
8 | * | ||
9 | * This driver replaces the following machine drivers: | ||
10 | * omap3beagle (Author: Steve Sakoman <steve@sakoman.com>) | ||
11 | * omap3evm (Author: Anuj Aggarwal <anuj.aggarwal@ti.com>) | ||
12 | * overo (Author: Steve Sakoman <steve@sakoman.com>) | ||
13 | * igep0020 (Author: Enric Balletbo i Serra <eballetbo@iseebcn.com>) | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License | ||
17 | * version 2 as published by the Free Software Foundation. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, but | ||
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
22 | * General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
27 | * 02110-1301 USA | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | #include <linux/platform_device.h> | ||
32 | #include <linux/platform_data/omap-twl4030.h> | ||
33 | #include <linux/module.h> | ||
34 | #include <linux/of.h> | ||
35 | |||
36 | #include <sound/core.h> | ||
37 | #include <sound/pcm.h> | ||
38 | #include <sound/soc.h> | ||
39 | |||
40 | #include "omap-mcbsp.h" | ||
41 | #include "omap-pcm.h" | ||
42 | |||
43 | static int omap_twl4030_hw_params(struct snd_pcm_substream *substream, | ||
44 | struct snd_pcm_hw_params *params) | ||
45 | { | ||
46 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
47 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
48 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
49 | struct snd_soc_codec *codec = rtd->codec; | ||
50 | struct snd_soc_card *card = codec->card; | ||
51 | unsigned int fmt; | ||
52 | int ret; | ||
53 | |||
54 | switch (params_channels(params)) { | ||
55 | case 2: /* Stereo I2S mode */ | ||
56 | fmt = SND_SOC_DAIFMT_I2S | | ||
57 | SND_SOC_DAIFMT_NB_NF | | ||
58 | SND_SOC_DAIFMT_CBM_CFM; | ||
59 | break; | ||
60 | case 4: /* Four channel TDM mode */ | ||
61 | fmt = SND_SOC_DAIFMT_DSP_A | | ||
62 | SND_SOC_DAIFMT_IB_NF | | ||
63 | SND_SOC_DAIFMT_CBM_CFM; | ||
64 | break; | ||
65 | default: | ||
66 | return -EINVAL; | ||
67 | } | ||
68 | |||
69 | /* Set codec DAI configuration */ | ||
70 | ret = snd_soc_dai_set_fmt(codec_dai, fmt); | ||
71 | if (ret < 0) { | ||
72 | dev_err(card->dev, "can't set codec DAI configuration\n"); | ||
73 | return ret; | ||
74 | } | ||
75 | |||
76 | /* Set cpu DAI configuration */ | ||
77 | ret = snd_soc_dai_set_fmt(cpu_dai, fmt); | ||
78 | if (ret < 0) { | ||
79 | dev_err(card->dev, "can't set cpu DAI configuration\n"); | ||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | static struct snd_soc_ops omap_twl4030_ops = { | ||
87 | .hw_params = omap_twl4030_hw_params, | ||
88 | }; | ||
89 | |||
90 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
91 | static struct snd_soc_dai_link omap_twl4030_dai_links[] = { | ||
92 | { | ||
93 | .name = "TWL4030", | ||
94 | .stream_name = "TWL4030", | ||
95 | .cpu_dai_name = "omap-mcbsp.2", | ||
96 | .codec_dai_name = "twl4030-hifi", | ||
97 | .platform_name = "omap-pcm-audio", | ||
98 | .codec_name = "twl4030-codec", | ||
99 | .ops = &omap_twl4030_ops, | ||
100 | }, | ||
101 | }; | ||
102 | |||
103 | /* Audio machine driver */ | ||
104 | static struct snd_soc_card omap_twl4030_card = { | ||
105 | .owner = THIS_MODULE, | ||
106 | .dai_link = omap_twl4030_dai_links, | ||
107 | .num_links = ARRAY_SIZE(omap_twl4030_dai_links), | ||
108 | }; | ||
109 | |||
110 | static __devinit int omap_twl4030_probe(struct platform_device *pdev) | ||
111 | { | ||
112 | struct omap_tw4030_pdata *pdata = dev_get_platdata(&pdev->dev); | ||
113 | struct device_node *node = pdev->dev.of_node; | ||
114 | struct snd_soc_card *card = &omap_twl4030_card; | ||
115 | int ret = 0; | ||
116 | |||
117 | card->dev = &pdev->dev; | ||
118 | |||
119 | if (node) { | ||
120 | struct device_node *dai_node; | ||
121 | |||
122 | if (snd_soc_of_parse_card_name(card, "ti,model")) { | ||
123 | dev_err(&pdev->dev, "Card name is not provided\n"); | ||
124 | return -ENODEV; | ||
125 | } | ||
126 | |||
127 | dai_node = of_parse_phandle(node, "ti,mcbsp", 0); | ||
128 | if (!dai_node) { | ||
129 | dev_err(&pdev->dev, "McBSP node is not provided\n"); | ||
130 | return -EINVAL; | ||
131 | } | ||
132 | omap_twl4030_dai_links[0].cpu_dai_name = NULL; | ||
133 | omap_twl4030_dai_links[0].cpu_of_node = dai_node; | ||
134 | |||
135 | } else if (pdata) { | ||
136 | if (pdata->card_name) { | ||
137 | card->name = pdata->card_name; | ||
138 | } else { | ||
139 | dev_err(&pdev->dev, "Card name is not provided\n"); | ||
140 | return -ENODEV; | ||
141 | } | ||
142 | } else { | ||
143 | dev_err(&pdev->dev, "Missing pdata\n"); | ||
144 | return -ENODEV; | ||
145 | } | ||
146 | |||
147 | ret = snd_soc_register_card(card); | ||
148 | if (ret) { | ||
149 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | ||
150 | ret); | ||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static int __devexit omap_twl4030_remove(struct platform_device *pdev) | ||
158 | { | ||
159 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
160 | |||
161 | snd_soc_unregister_card(card); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static const struct of_device_id omap_twl4030_of_match[] = { | ||
167 | {.compatible = "ti,omap-twl4030", }, | ||
168 | { }, | ||
169 | }; | ||
170 | MODULE_DEVICE_TABLE(of, omap_twl4030_of_match); | ||
171 | |||
172 | static struct platform_driver omap_twl4030_driver = { | ||
173 | .driver = { | ||
174 | .name = "omap-twl4030", | ||
175 | .owner = THIS_MODULE, | ||
176 | .pm = &snd_soc_pm_ops, | ||
177 | .of_match_table = omap_twl4030_of_match, | ||
178 | }, | ||
179 | .probe = omap_twl4030_probe, | ||
180 | .remove = __devexit_p(omap_twl4030_remove), | ||
181 | }; | ||
182 | |||
183 | module_platform_driver(omap_twl4030_driver); | ||
184 | |||
185 | MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); | ||
186 | MODULE_DESCRIPTION("ALSA SoC for TI SoC based boards with twl4030 codec"); | ||
187 | MODULE_LICENSE("GPL"); | ||
188 | MODULE_ALIAS("platform:omap-twl4030"); | ||