rename packages/ to recipes/ per earlier agreement
[openembedded.git] / recipes / linux / linux-omap-pm / 0001-ASoC-Add-support-for-OMAP3-EVM.patch
1 From c1dad0b6b434300ae64c902d11611c54c513ea10 Mon Sep 17 00:00:00 2001
2 From: Anuj Aggarwal <anuj.aggarwal@ti.com>
3 Date: Fri, 21 Nov 2008 17:41:03 +0530
4 Subject: [PATCH] ASoC: Add support for OMAP3 EVM
5
6 This patch adds ALSA SoC support for OMAP3 EVM using TWL4030 audio codec.
7
8 Signed-off-by: Anuj Aggarwal <anuj.aggarwal@ti.com>
9 ---
10  sound/soc/omap/Kconfig    |    8 +++
11  sound/soc/omap/Makefile   |    3 +-
12  sound/soc/omap/omap3evm.c |  147 +++++++++++++++++++++++++++++++++++++++++++++
13  3 files changed, 157 insertions(+), 1 deletions(-)
14  create mode 100644 sound/soc/omap/omap3evm.c
15
16 diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
17 index 0daeee4..deb6ba9 100644
18 --- a/sound/soc/omap/Kconfig
19 +++ b/sound/soc/omap/Kconfig
20 @@ -22,6 +22,14 @@ config SND_OMAP_SOC_OMAP3_BEAGLE
21         help
22           Say Y if you want to add support for SoC audio on the Beagleboard.
23  
24 +config SND_OMAP_SOC_OMAP3EVM
25 +        tristate "SoC Audio support for OMAP3EVM board"
26 +        depends on SND_OMAP_SOC && MACH_OMAP3EVM
27 +        select SND_OMAP_SOC_MCBSP
28 +        select SND_SOC_TWL4030
29 +        help
30 +          Say Y if you want to add support for SoC audio on the omap3evm board.
31 +
32  config SND_OMAP_SOC_OSK5912
33         tristate "SoC Audio support for omap osk5912"
34         depends on SND_OMAP_SOC && MACH_OMAP_OSK
35 diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
36 index 4bae404..ef31c25 100644
37 --- a/sound/soc/omap/Makefile
38 +++ b/sound/soc/omap/Makefile
39 @@ -10,9 +10,10 @@ snd-soc-n810-objs := n810.o
40  snd-soc-omap3beagle-objs := omap3beagle.o
41  snd-soc-osk5912-objs := osk5912.o
42  snd-soc-overo-objs := overo.o
43 +snd-soc-omap3evm-objs := omap3evm.o
44  
45  obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o
46  obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o
47  obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o
48  obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o
49 -
50 +obj-$(CONFIG_MACH_OMAP3EVM) += snd-soc-omap3evm.o
51 diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c
52 new file mode 100644
53 index 0000000..570af55
54 --- /dev/null
55 +++ b/sound/soc/omap/omap3evm.c
56 @@ -0,0 +1,147 @@
57 +/*
58 + * omap3evm.c  -- ALSA SoC support for OMAP3 EVM
59 + *
60 + * Author: Anuj Aggarwal <anuj.aggarwal@ti.com>
61 + *
62 + * Based on sound/soc/omap/beagle.c by Steve Sakoman
63 + *
64 + * Copyright (C) 2008 Texas Instruments, Incorporated
65 + *
66 + * This program is free software; you can redistribute it and/or modify it
67 + * under the terms of the GNU General Public License as published by the
68 + * Free Software Foundation version 2.
69 + *
70 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
71 + * whether express or implied; without even the implied warranty of
72 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
73 + * General Public License for more details.
74 + */
75 +
76 +#include <linux/clk.h>
77 +#include <linux/platform_device.h>
78 +#include <sound/core.h>
79 +#include <sound/pcm.h>
80 +#include <sound/soc.h>
81 +#include <sound/soc-dapm.h>
82 +
83 +#include <asm/mach-types.h>
84 +#include <mach/hardware.h>
85 +#include <mach/gpio.h>
86 +#include <mach/mcbsp.h>
87 +
88 +#include "omap-mcbsp.h"
89 +#include "omap-pcm.h"
90 +#include "../codecs/twl4030.h"
91 +
92 +static int omap3evm_hw_params(struct snd_pcm_substream *substream,
93 +       struct snd_pcm_hw_params *params)
94 +{
95 +       struct snd_soc_pcm_runtime *rtd = substream->private_data;
96 +       struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
97 +       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
98 +       int ret;
99 +
100 +       /* Set codec DAI configuration */
101 +       ret = snd_soc_dai_set_fmt(codec_dai,
102 +                                 SND_SOC_DAIFMT_I2S |
103 +                                 SND_SOC_DAIFMT_NB_NF |
104 +                                 SND_SOC_DAIFMT_CBM_CFM);
105 +       if (ret < 0) {
106 +               printk(KERN_ERR "can't set codec DAI configuration\n");
107 +               return ret;
108 +       }
109 +
110 +       /* Set cpu DAI configuration */
111 +       ret = snd_soc_dai_set_fmt(cpu_dai,
112 +                                 SND_SOC_DAIFMT_I2S |
113 +                                 SND_SOC_DAIFMT_NB_NF |
114 +                                 SND_SOC_DAIFMT_CBM_CFM);
115 +       if (ret < 0) {
116 +               printk(KERN_ERR "can't set cpu DAI configuration\n");
117 +               return ret;
118 +       }
119 +
120 +       /* Set the codec system clock for DAC and ADC */
121 +       ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
122 +                                    SND_SOC_CLOCK_IN);
123 +       if (ret < 0) {
124 +               printk(KERN_ERR "can't set codec system clock\n");
125 +               return ret;
126 +       }
127 +
128 +       return 0;
129 +}
130 +
131 +static struct snd_soc_ops omap3evm_ops = {
132 +       .hw_params = omap3evm_hw_params,
133 +};
134 +
135 +/* Digital audio interface glue - connects codec <--> CPU */
136 +static struct snd_soc_dai_link omap3evm_dai = {
137 +       .name = "TWL4030",
138 +       .stream_name = "TWL4030",
139 +       .cpu_dai = &omap_mcbsp_dai[0],
140 +       .codec_dai = &twl4030_dai,
141 +       .ops = &omap3evm_ops,
142 +};
143 +
144 +/* Audio machine driver */
145 +static struct snd_soc_machine snd_soc_machine_omap3evm = {
146 +       .name = "omap3evm",
147 +       .dai_link = &omap3evm_dai,
148 +       .num_links = 1,
149 +};
150 +
151 +/* Audio subsystem */
152 +static struct snd_soc_device omap3evm_snd_devdata = {
153 +       .machine = &snd_soc_machine_omap3evm,
154 +       .platform = &omap_soc_platform,
155 +       .codec_dev = &soc_codec_dev_twl4030,
156 +};
157 +
158 +static struct platform_device *omap3evm_snd_device;
159 +
160 +static int __init omap3evm_soc_init(void)
161 +{
162 +       int ret;
163 +
164 +       if (!machine_is_omap3evm()) {
165 +               pr_debug("Not OMAP3 EVM!\n");
166 +               return -ENODEV;
167 +       }
168 +       pr_info("OMAP3 EVM SoC init\n");
169 +
170 +       omap3evm_snd_device = platform_device_alloc("soc-audio", -1);
171 +       if (!omap3evm_snd_device) {
172 +               printk(KERN_ERR "Platform device allocation failed\n");
173 +               return -ENOMEM;
174 +       }
175 +
176 +       platform_set_drvdata(omap3evm_snd_device, &omap3evm_snd_devdata);
177 +       omap3evm_snd_devdata.dev = &omap3evm_snd_device->dev;
178 +       *(unsigned int *)omap3evm_dai.cpu_dai->private_data = 1; /* McBSP2 */
179 +
180 +       ret = platform_device_add(omap3evm_snd_device);
181 +       if (ret)
182 +               goto err1;
183 +
184 +       return 0;
185 +
186 +err1:
187 +       printk(KERN_ERR "Unable to add platform device\n");
188 +       platform_device_put(omap3evm_snd_device);
189 +
190 +       return ret;
191 +}
192 +
193 +static void __exit omap3evm_soc_exit(void)
194 +{
195 +       platform_device_unregister(omap3evm_snd_device);
196 +}
197 +
198 +module_init(omap3evm_soc_init);
199 +module_exit(omap3evm_soc_exit);
200 +
201 +MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
202 +MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM");
203 +MODULE_LICENSE("GPL");
204 -- 
205 1.5.6.5
206