Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 1 | /* |
| 2 | * sdp4430.c -- SoC audio for TI OMAP4430 SDP |
| 3 | * |
Liam Girdwood | 63a0670 | 2011-05-01 13:45:18 +0100 | [diff] [blame] | 4 | * Author: Misael Lopez Cruz <misael.lopez@ti.com> |
| 5 | * Liam Girdwood <lrg@ti.com> |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * version 2 as published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 19 | * 02110-1301 USA |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/platform_device.h> |
Sebastien Guiriec | 71e450b | 2011-07-03 22:26:58 +0200 | [diff] [blame] | 25 | #include <linux/i2c.h> |
Misael Lopez Cruz | f4b3dc3 | 2011-05-01 21:27:00 -0500 | [diff] [blame] | 26 | #include <linux/mfd/twl6040.h> |
| 27 | |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 28 | #include <sound/core.h> |
| 29 | #include <sound/pcm.h> |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 30 | #include <sound/pcm_params.h> |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 31 | #include <sound/soc.h> |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 32 | #include <sound/soc-dapm.h> |
Jorge Eduardo Candelaria | 96dc227 | 2010-12-10 20:45:19 -0600 | [diff] [blame] | 33 | #include <sound/jack.h> |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 34 | #include <sound/soc-dsp.h> |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 35 | |
| 36 | #include <asm/mach-types.h> |
| 37 | #include <plat/hardware.h> |
| 38 | #include <plat/mux.h> |
| 39 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 40 | #include "omap-mcpdm.h" |
| 41 | #include "omap-abe.h" |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 42 | #include "omap-pcm.h" |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 43 | #include "omap-mcbsp.h" |
| 44 | #include "omap-dmic.h" |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 45 | #include "../codecs/twl6040.h" |
| 46 | |
| 47 | static int twl6040_power_mode; |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 48 | static int mcbsp_cfg; |
Liam Girdwood | 8cc5705 | 2011-02-07 21:18:06 +0000 | [diff] [blame] | 49 | static struct i2c_client *tps6130x_client; |
| 50 | static struct i2c_board_info tps6130x_hwmon_info = { |
| 51 | I2C_BOARD_INFO("tps6130x", 0x33), |
| 52 | }; |
| 53 | |
| 54 | /* configure the TPS6130x Handsfree Boost Converter */ |
| 55 | static int sdp4430_tps6130x_configure(void) |
| 56 | { |
| 57 | u8 data[2]; |
| 58 | |
| 59 | data[0] = 0x01; |
| 60 | data[1] = 0x60; |
| 61 | if (i2c_master_send(tps6130x_client, data, 2) != 2) |
| 62 | printk(KERN_ERR "I2C write to TPS6130x failed\n"); |
| 63 | |
| 64 | data[0] = 0x02; |
| 65 | if (i2c_master_send(tps6130x_client, data, 2) != 2) |
| 66 | printk(KERN_ERR "I2C write to TPS6130x failed\n"); |
| 67 | |
| 68 | return 0; |
| 69 | } |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 70 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 71 | static int sdp4430_mcpdm_hw_params(struct snd_pcm_substream *substream, |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 72 | struct snd_pcm_hw_params *params) |
| 73 | { |
| 74 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 75 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 76 | struct snd_soc_pcm_runtime *modem_rtd; |
| 77 | struct snd_pcm_substream *modem_substream[2]; |
| 78 | struct snd_soc_dsp_params *dsp_params; |
| 79 | int clk_id, freq, ret, stream = substream->stream; |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 80 | |
| 81 | if (twl6040_power_mode) { |
| 82 | clk_id = TWL6040_SYSCLK_SEL_HPPLL; |
| 83 | freq = 38400000; |
| 84 | } else { |
| 85 | clk_id = TWL6040_SYSCLK_SEL_LPPLL; |
| 86 | freq = 32768; |
| 87 | } |
| 88 | |
| 89 | /* set the codec mclk */ |
| 90 | ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq, |
| 91 | SND_SOC_CLOCK_IN); |
| 92 | if (ret) { |
| 93 | printk(KERN_ERR "can't set codec system clock\n"); |
| 94 | return ret; |
| 95 | } |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 96 | list_for_each_entry(dsp_params, &rtd->dsp[stream].fe_clients, list_fe) { |
| 97 | |
| 98 | if (dsp_params->fe->cpu_dai->id != ABE_FRONTEND_DAI_MODEM) |
| 99 | continue; |
| 100 | |
| 101 | if (!mcbsp_cfg) { |
| 102 | modem_substream[stream] = |
| 103 | snd_soc_get_dai_substream(rtd->card, |
| 104 | OMAP_ABE_BE_MM_EXT1, |
| 105 | substream->stream); |
| 106 | if (modem_substream[stream] == NULL) |
| 107 | return -ENODEV; |
| 108 | |
| 109 | modem_rtd = modem_substream[stream]->private_data; |
| 110 | |
| 111 | /* Set cpu DAI configuration */ |
| 112 | ret = snd_soc_dai_set_fmt(modem_rtd->cpu_dai, |
| 113 | SND_SOC_DAIFMT_I2S | |
| 114 | SND_SOC_DAIFMT_NB_NF | |
| 115 | SND_SOC_DAIFMT_CBM_CFM); |
| 116 | mcbsp_cfg = 1; |
| 117 | } |
| 118 | if (ret < 0) { |
| 119 | printk(KERN_ERR "can't set Modem cpu DAI configuration\n"); |
| 120 | return ret; |
| 121 | } |
| 122 | } |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 123 | return ret; |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 124 | } |
| 125 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 126 | static struct snd_soc_ops sdp4430_mcpdm_ops = { |
| 127 | .hw_params = sdp4430_mcpdm_hw_params, |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 128 | }; |
| 129 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 130 | static int sdp4430_mcbsp_hw_params(struct snd_pcm_substream *substream, |
| 131 | struct snd_pcm_hw_params *params) |
| 132 | { |
| 133 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 134 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 135 | int ret = 0; |
| 136 | unsigned int be_id; |
| 137 | |
| 138 | be_id = rtd->dai_link->be_id; |
| 139 | |
| 140 | if (be_id == OMAP_ABE_DAI_MM_FM) { |
| 141 | /* Set cpu DAI configuration */ |
| 142 | ret = snd_soc_dai_set_fmt(cpu_dai, |
| 143 | SND_SOC_DAIFMT_I2S | |
| 144 | SND_SOC_DAIFMT_NB_NF | |
| 145 | SND_SOC_DAIFMT_CBM_CFM); |
| 146 | } else if (be_id == OMAP_ABE_DAI_BT_VX) { |
| 147 | ret = snd_soc_dai_set_fmt(cpu_dai, |
| 148 | SND_SOC_DAIFMT_DSP_B | |
| 149 | SND_SOC_DAIFMT_NB_IF | |
| 150 | SND_SOC_DAIFMT_CBM_CFM); |
| 151 | } |
| 152 | |
| 153 | if (ret < 0) { |
| 154 | printk(KERN_ERR "can't set cpu DAI configuration\n"); |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | /* |
| 159 | * TODO: where does this clock come from (external source??) - |
| 160 | * do we need to enable it. |
| 161 | */ |
| 162 | /* Set McBSP clock to external */ |
| 163 | ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_FCLK, |
| 164 | 64 * params_rate(params), |
| 165 | SND_SOC_CLOCK_IN); |
| 166 | if (ret < 0) { |
| 167 | printk(KERN_ERR "can't set cpu system clock\n"); |
| 168 | return ret; |
| 169 | } |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | static struct snd_soc_ops sdp4430_mcbsp_ops = { |
| 174 | .hw_params = sdp4430_mcbsp_hw_params, |
| 175 | }; |
| 176 | |
| 177 | static int sdp4430_dmic_hw_params(struct snd_pcm_substream *substream, |
| 178 | struct snd_pcm_hw_params *params) |
| 179 | { |
| 180 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 181 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 182 | int ret = 0; |
| 183 | |
| 184 | ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_SYSCLK_PAD_CLKS, |
| 185 | 19200000, SND_SOC_CLOCK_IN); |
| 186 | if (ret < 0) { |
| 187 | printk(KERN_ERR "can't set DMIC cpu system clock\n"); |
| 188 | return ret; |
| 189 | } |
| 190 | ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_DMIC_CLKDIV, 8); |
| 191 | if (ret < 0) { |
| 192 | printk(KERN_ERR "can't set DMIC cpu clock divider\n"); |
| 193 | return ret; |
| 194 | } |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | static struct snd_soc_ops sdp4430_dmic_ops = { |
| 199 | .hw_params = sdp4430_dmic_hw_params, |
| 200 | }; |
| 201 | |
| 202 | static int mcbsp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 203 | struct snd_pcm_hw_params *params) |
| 204 | { |
| 205 | struct snd_interval *channels = hw_param_interval(params, |
| 206 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 207 | unsigned int be_id = rtd->dai_link->be_id; |
| 208 | |
| 209 | if (be_id == OMAP_ABE_DAI_MM_FM) |
| 210 | channels->min = 2; |
| 211 | else if (be_id == OMAP_ABE_DAI_BT_VX) |
| 212 | channels->min = 1; |
| 213 | snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - |
| 214 | SNDRV_PCM_HW_PARAM_FIRST_MASK], |
| 215 | SNDRV_PCM_FORMAT_S16_LE); |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | static int dmic_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 220 | struct snd_pcm_hw_params *params) |
| 221 | { |
| 222 | struct snd_interval *rate = hw_param_interval(params, |
| 223 | SNDRV_PCM_HW_PARAM_RATE); |
| 224 | |
| 225 | /* The ABE will covert the FE rate to 96k */ |
| 226 | rate->min = rate->max = 96000; |
| 227 | |
| 228 | snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - |
| 229 | SNDRV_PCM_HW_PARAM_FIRST_MASK], |
| 230 | SNDRV_PCM_FORMAT_S32_LE); |
| 231 | return 0; |
| 232 | } |
| 233 | |
Jorge Eduardo Candelaria | 96dc227 | 2010-12-10 20:45:19 -0600 | [diff] [blame] | 234 | /* Headset jack */ |
| 235 | static struct snd_soc_jack hs_jack; |
| 236 | |
| 237 | /*Headset jack detection DAPM pins */ |
| 238 | static struct snd_soc_jack_pin hs_jack_pins[] = { |
| 239 | { |
| 240 | .pin = "Headset Mic", |
| 241 | .mask = SND_JACK_MICROPHONE, |
| 242 | }, |
| 243 | { |
| 244 | .pin = "Headset Stereophone", |
| 245 | .mask = SND_JACK_HEADPHONE, |
| 246 | }, |
| 247 | }; |
| 248 | |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 249 | static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, |
| 250 | struct snd_ctl_elem_value *ucontrol) |
| 251 | { |
| 252 | ucontrol->value.integer.value[0] = twl6040_power_mode; |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | static int sdp4430_set_power_mode(struct snd_kcontrol *kcontrol, |
| 257 | struct snd_ctl_elem_value *ucontrol) |
| 258 | { |
| 259 | if (twl6040_power_mode == ucontrol->value.integer.value[0]) |
| 260 | return 0; |
| 261 | |
| 262 | twl6040_power_mode = ucontrol->value.integer.value[0]; |
| 263 | |
| 264 | return 1; |
| 265 | } |
| 266 | |
| 267 | static const char *power_texts[] = {"Low-Power", "High-Performance"}; |
| 268 | |
| 269 | static const struct soc_enum sdp4430_enum[] = { |
| 270 | SOC_ENUM_SINGLE_EXT(2, power_texts), |
| 271 | }; |
| 272 | |
| 273 | static const struct snd_kcontrol_new sdp4430_controls[] = { |
| 274 | SOC_ENUM_EXT("TWL6040 Power Mode", sdp4430_enum[0], |
| 275 | sdp4430_get_power_mode, sdp4430_set_power_mode), |
| 276 | }; |
| 277 | |
| 278 | /* SDP4430 machine DAPM */ |
| 279 | static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { |
| 280 | SND_SOC_DAPM_MIC("Ext Mic", NULL), |
| 281 | SND_SOC_DAPM_SPK("Ext Spk", NULL), |
| 282 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 283 | SND_SOC_DAPM_HP("Headset Stereophone", NULL), |
Jorge Eduardo Candelaria | 7254e2b | 2010-05-18 12:44:17 -0500 | [diff] [blame] | 284 | SND_SOC_DAPM_SPK("Earphone Spk", NULL), |
Jorge Eduardo Candelaria | 23ac3b6 | 2010-12-08 10:55:05 -0600 | [diff] [blame] | 285 | SND_SOC_DAPM_INPUT("Aux/FM Stereo In"), |
Misael Lopez Cruz | 685a473 | 2011-04-25 20:23:20 -0500 | [diff] [blame] | 286 | SND_SOC_DAPM_MIC("Digital Mic 0", NULL), |
| 287 | SND_SOC_DAPM_MIC("Digital Mic 1", NULL), |
| 288 | SND_SOC_DAPM_MIC("Digital Mic 2", NULL), |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | static const struct snd_soc_dapm_route audio_map[] = { |
| 292 | /* External Mics: MAINMIC, SUBMIC with bias*/ |
| 293 | {"MAINMIC", NULL, "Main Mic Bias"}, |
| 294 | {"SUBMIC", NULL, "Main Mic Bias"}, |
| 295 | {"Main Mic Bias", NULL, "Ext Mic"}, |
| 296 | |
| 297 | /* External Speakers: HFL, HFR */ |
| 298 | {"Ext Spk", NULL, "HFL"}, |
| 299 | {"Ext Spk", NULL, "HFR"}, |
| 300 | |
| 301 | /* Headset Mic: HSMIC with bias */ |
| 302 | {"HSMIC", NULL, "Headset Mic Bias"}, |
| 303 | {"Headset Mic Bias", NULL, "Headset Mic"}, |
| 304 | |
| 305 | /* Headset Stereophone (Headphone): HSOL, HSOR */ |
| 306 | {"Headset Stereophone", NULL, "HSOL"}, |
| 307 | {"Headset Stereophone", NULL, "HSOR"}, |
Jorge Eduardo Candelaria | 7254e2b | 2010-05-18 12:44:17 -0500 | [diff] [blame] | 308 | |
| 309 | /* Earphone speaker */ |
| 310 | {"Earphone Spk", NULL, "EP"}, |
Jorge Eduardo Candelaria | 23ac3b6 | 2010-12-08 10:55:05 -0600 | [diff] [blame] | 311 | |
| 312 | /* Aux/FM Stereo In: AFML, AFMR */ |
| 313 | {"AFML", NULL, "Aux/FM Stereo In"}, |
| 314 | {"AFMR", NULL, "Aux/FM Stereo In"}, |
Misael Lopez Cruz | 685a473 | 2011-04-25 20:23:20 -0500 | [diff] [blame] | 315 | |
| 316 | /* Digital Mics: DMic0, DMic1, DMic2 with bias */ |
| 317 | {"DMIC0", NULL, "Digital Mic1 Bias"}, |
| 318 | {"Digital Mic1 Bias", NULL, "Digital Mic 0"}, |
| 319 | |
| 320 | {"DMIC1", NULL, "Digital Mic1 Bias"}, |
| 321 | {"Digital Mic1 Bias", NULL, "Digital Mic 1"}, |
| 322 | |
| 323 | {"DMIC2", NULL, "Digital Mic1 Bias"}, |
| 324 | {"Digital Mic1 Bias", NULL, "Digital Mic 2"}, |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 325 | }; |
| 326 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 327 | static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 328 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 329 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 330 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 331 | int ret; |
| 332 | |
| 333 | /* Add SDP4430 specific controls */ |
| 334 | ret = snd_soc_add_controls(codec, sdp4430_controls, |
| 335 | ARRAY_SIZE(sdp4430_controls)); |
| 336 | if (ret) |
| 337 | return ret; |
| 338 | |
| 339 | /* Add SDP4430 specific widgets */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 340 | ret = snd_soc_dapm_new_controls(dapm, sdp4430_twl6040_dapm_widgets, |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 341 | ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); |
| 342 | if (ret) |
| 343 | return ret; |
| 344 | |
| 345 | /* Set up SDP4430 specific audio path audio_map */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 346 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 347 | |
| 348 | /* SDP4430 connected pins */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 349 | snd_soc_dapm_enable_pin(dapm, "Ext Mic"); |
| 350 | snd_soc_dapm_enable_pin(dapm, "Ext Spk"); |
Jorge Eduardo Candelaria | 23ac3b6 | 2010-12-08 10:55:05 -0600 | [diff] [blame] | 351 | snd_soc_dapm_enable_pin(dapm, "AFML"); |
| 352 | snd_soc_dapm_enable_pin(dapm, "AFMR"); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 353 | snd_soc_dapm_enable_pin(dapm, "Headset Mic"); |
| 354 | snd_soc_dapm_enable_pin(dapm, "Headset Stereophone"); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 355 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 356 | /* allow audio paths from the audio modem to run during suspend */ |
| 357 | snd_soc_dapm_ignore_suspend(dapm, "Ext Mic"); |
| 358 | snd_soc_dapm_ignore_suspend(dapm, "Ext Spk"); |
| 359 | snd_soc_dapm_ignore_suspend(dapm, "AFML"); |
| 360 | snd_soc_dapm_ignore_suspend(dapm, "AFMR"); |
| 361 | snd_soc_dapm_ignore_suspend(dapm, "Headset Mic"); |
| 362 | snd_soc_dapm_ignore_suspend(dapm, "Headset Stereophone"); |
Misael Lopez Cruz | 685a473 | 2011-04-25 20:23:20 -0500 | [diff] [blame] | 363 | snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 0"); |
| 364 | snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 1"); |
| 365 | snd_soc_dapm_ignore_suspend(dapm, "Digital Mic 2"); |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 366 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 367 | ret = snd_soc_dapm_sync(dapm); |
Jorge Eduardo Candelaria | 96dc227 | 2010-12-10 20:45:19 -0600 | [diff] [blame] | 368 | if (ret) |
| 369 | return ret; |
| 370 | |
| 371 | /* Headset jack detection */ |
| 372 | ret = snd_soc_jack_new(codec, "Headset Jack", |
| 373 | SND_JACK_HEADSET, &hs_jack); |
| 374 | if (ret) |
| 375 | return ret; |
| 376 | |
| 377 | ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), |
| 378 | hs_jack_pins); |
| 379 | |
| 380 | if (machine_is_omap_4430sdp()) |
| 381 | twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); |
| 382 | else |
| 383 | snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 384 | |
Misael Lopez Cruz | ae141a2 | 2011-04-29 01:52:45 -0500 | [diff] [blame] | 385 | /* wait 500 ms before switching of HS power */ |
| 386 | rtd->pmdown_time = 500; |
| 387 | |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 388 | return ret; |
| 389 | } |
| 390 | |
Misael Lopez Cruz | ae141a2 | 2011-04-29 01:52:45 -0500 | [diff] [blame] | 391 | static int sdp4430_twl6040_dl2_init(struct snd_soc_pcm_runtime *rtd) |
| 392 | { |
| 393 | /* wait 500 ms before switching of HF power */ |
| 394 | rtd->pmdown_time = 500; |
| 395 | |
| 396 | return 0; |
| 397 | } |
| 398 | |
Misael Lopez Cruz | 47415f0 | 2011-04-27 23:56:32 -0500 | [diff] [blame] | 399 | /* SDP4430 digital microphones DAPM */ |
| 400 | static const struct snd_soc_dapm_widget sdp4430_dmic_dapm_widgets[] = { |
| 401 | SND_SOC_DAPM_MIC("Digital Mic Legacy", NULL), |
| 402 | }; |
| 403 | |
| 404 | static const struct snd_soc_dapm_route dmic_audio_map[] = { |
| 405 | {"DMic", NULL, "Digital Mic1 Bias"}, |
| 406 | {"Digital Mic1 Bias", NULL, "Digital Mic Legacy"}, |
| 407 | }; |
| 408 | |
| 409 | static int sdp4430_dmic_init(struct snd_soc_pcm_runtime *rtd) |
| 410 | { |
| 411 | struct snd_soc_codec *codec = rtd->codec; |
| 412 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 413 | int ret; |
| 414 | |
| 415 | ret = snd_soc_dapm_new_controls(dapm, sdp4430_dmic_dapm_widgets, |
| 416 | ARRAY_SIZE(sdp4430_dmic_dapm_widgets)); |
| 417 | if (ret) |
| 418 | return ret; |
| 419 | |
| 420 | ret = snd_soc_dapm_add_routes(dapm, dmic_audio_map, |
| 421 | ARRAY_SIZE(dmic_audio_map)); |
| 422 | if (ret) |
| 423 | return ret; |
| 424 | |
| 425 | snd_soc_dapm_enable_pin(dapm, "Digital Mic Legacy"); |
| 426 | |
| 427 | ret = snd_soc_dapm_sync(dapm); |
| 428 | |
| 429 | return ret; |
| 430 | } |
| 431 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 432 | /* TODO: make this a separate BT CODEC driver or DUMMY */ |
| 433 | static struct snd_soc_dai_driver dai[] = { |
| 434 | { |
| 435 | .name = "Bluetooth", |
| 436 | .playback = { |
| 437 | .stream_name = "Playback", |
| 438 | .channels_min = 1, |
| 439 | .channels_max = 2, |
| 440 | .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | |
| 441 | SNDRV_PCM_RATE_48000, |
| 442 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 443 | }, |
| 444 | .capture = { |
| 445 | .stream_name = "Capture", |
| 446 | .channels_min = 1, |
| 447 | .channels_max = 2, |
| 448 | .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | |
| 449 | SNDRV_PCM_RATE_48000, |
| 450 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 451 | }, |
| 452 | }, |
| 453 | /* TODO: make this a separate FM CODEC driver or DUMMY */ |
| 454 | { |
| 455 | .name = "FM Digital", |
| 456 | .playback = { |
| 457 | .stream_name = "Playback", |
| 458 | .channels_min = 1, |
| 459 | .channels_max = 2, |
| 460 | .rates = SNDRV_PCM_RATE_48000, |
| 461 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 462 | }, |
| 463 | .capture = { |
| 464 | .stream_name = "Capture", |
| 465 | .channels_min = 1, |
| 466 | .channels_max = 2, |
| 467 | .rates = SNDRV_PCM_RATE_48000, |
| 468 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 469 | }, |
| 470 | }, |
| 471 | { |
| 472 | .name = "HDMI", |
| 473 | .playback = { |
| 474 | .stream_name = "Playback", |
| 475 | .channels_min = 2, |
| 476 | .channels_max = 8, |
| 477 | .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | |
| 478 | SNDRV_PCM_RATE_48000, |
| 479 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, |
| 480 | }, |
| 481 | }, |
| 482 | }; |
| 483 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 484 | struct snd_soc_dsp_link fe_media = { |
Liam Girdwood | 767dfac | 2011-06-03 14:26:23 +0100 | [diff] [blame] | 485 | .playback = true, |
| 486 | .capture = true, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 487 | .trigger = |
| 488 | {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE}, |
| 489 | }; |
| 490 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 491 | struct snd_soc_dsp_link fe_media_capture = { |
Liam Girdwood | 767dfac | 2011-06-03 14:26:23 +0100 | [diff] [blame] | 492 | .capture = true, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 493 | .trigger = |
| 494 | {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE}, |
| 495 | }; |
| 496 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 497 | struct snd_soc_dsp_link fe_tones = { |
Liam Girdwood | 767dfac | 2011-06-03 14:26:23 +0100 | [diff] [blame] | 498 | .playback = true, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 499 | .trigger = |
| 500 | {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE}, |
| 501 | }; |
| 502 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 503 | struct snd_soc_dsp_link fe_vib = { |
Liam Girdwood | 767dfac | 2011-06-03 14:26:23 +0100 | [diff] [blame] | 504 | .playback = true, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 505 | .trigger = |
| 506 | {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE}, |
| 507 | }; |
| 508 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 509 | struct snd_soc_dsp_link fe_modem = { |
Liam Girdwood | 767dfac | 2011-06-03 14:26:23 +0100 | [diff] [blame] | 510 | .playback = true, |
| 511 | .capture = true, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 512 | .trigger = |
| 513 | {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE}, |
| 514 | }; |
| 515 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 516 | struct snd_soc_dsp_link fe_lp_media = { |
Liam Girdwood | 767dfac | 2011-06-03 14:26:23 +0100 | [diff] [blame] | 517 | .playback = true, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 518 | .trigger = |
| 519 | {SND_SOC_DSP_TRIGGER_BESPOKE, SND_SOC_DSP_TRIGGER_BESPOKE}, |
| 520 | }; |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 521 | /* Digital audio interface glue - connects codec <--> CPU */ |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 522 | static struct snd_soc_dai_link sdp4430_dai[] = { |
| 523 | |
| 524 | /* |
| 525 | * Frontend DAIs - i.e. userspace visible interfaces (ALSA PCMs) |
| 526 | */ |
| 527 | |
| 528 | { |
| 529 | .name = "SDP4430 Media", |
| 530 | .stream_name = "Multimedia", |
| 531 | |
| 532 | /* ABE components - MM-UL & MM_DL */ |
| 533 | .cpu_dai_name = "MultiMedia1", |
| 534 | .platform_name = "omap-pcm-audio", |
| 535 | |
| 536 | .dynamic = 1, /* BE is dynamic */ |
| 537 | .dsp_link = &fe_media, |
| 538 | }, |
| 539 | { |
| 540 | .name = "SDP4430 Media Capture", |
| 541 | .stream_name = "Multimedia Capture", |
| 542 | |
| 543 | /* ABE components - MM-UL2 */ |
| 544 | .cpu_dai_name = "MultiMedia2", |
| 545 | .platform_name = "omap-pcm-audio", |
| 546 | |
| 547 | .dynamic = 1, /* BE is dynamic */ |
| 548 | .dsp_link = &fe_media_capture, |
| 549 | }, |
| 550 | { |
| 551 | .name = "SDP4430 Voice", |
| 552 | .stream_name = "Voice", |
| 553 | |
| 554 | /* ABE components - VX-UL & VX-DL */ |
| 555 | .cpu_dai_name = "Voice", |
| 556 | .platform_name = "omap-pcm-audio", |
| 557 | |
| 558 | .dynamic = 1, /* BE is dynamic */ |
| 559 | .dsp_link = &fe_media, |
| 560 | .no_host_mode = SND_SOC_DAI_LINK_OPT_HOST, |
| 561 | }, |
| 562 | { |
| 563 | .name = "SDP4430 Tones Playback", |
| 564 | .stream_name = "Tone Playback", |
| 565 | |
| 566 | /* ABE components - TONES_DL */ |
| 567 | .cpu_dai_name = "Tones", |
| 568 | .platform_name = "omap-pcm-audio", |
| 569 | |
| 570 | .dynamic = 1, /* BE is dynamic */ |
| 571 | .dsp_link = &fe_tones, |
| 572 | }, |
| 573 | { |
| 574 | .name = "SDP4430 Vibra Playback", |
| 575 | .stream_name = "VIB-DL", |
| 576 | |
| 577 | /* ABE components - DMIC UL 2 */ |
| 578 | .cpu_dai_name = "Vibra", |
| 579 | .platform_name = "omap-pcm-audio", |
| 580 | |
| 581 | .dynamic = 1, /* BE is dynamic */ |
| 582 | .dsp_link = &fe_vib, |
| 583 | }, |
| 584 | { |
| 585 | .name = "SDP4430 MODEM", |
| 586 | .stream_name = "MODEM", |
| 587 | |
| 588 | /* ABE components - MODEM <-> McBSP2 */ |
| 589 | .cpu_dai_name = "MODEM", |
| 590 | .platform_name = "aess", |
| 591 | |
| 592 | .dynamic = 1, /* BE is dynamic */ |
| 593 | .dsp_link = &fe_modem, |
| 594 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 595 | .ignore_suspend = 1, |
| 596 | }, |
| 597 | { |
| 598 | .name = "SDP4430 Media LP", |
| 599 | .stream_name = "Multimedia", |
| 600 | |
| 601 | /* ABE components - MM-DL (mmap) */ |
| 602 | .cpu_dai_name = "MultiMedia1 LP", |
| 603 | .platform_name = "aess", |
| 604 | |
| 605 | .dynamic = 1, /* BE is dynamic */ |
| 606 | .dsp_link = &fe_lp_media, |
| 607 | }, |
| 608 | { |
| 609 | .name = "Legacy McBSP", |
| 610 | .stream_name = "Multimedia", |
| 611 | |
| 612 | /* ABE components - MCBSP2 - MM-EXT */ |
| 613 | .cpu_dai_name = "omap-mcbsp-dai.1", |
| 614 | .platform_name = "omap-pcm-audio", |
| 615 | |
| 616 | /* FM */ |
| 617 | .codec_dai_name = "FM Digital", |
| 618 | |
| 619 | .no_codec = 1, /* TODO: have a dummy CODEC */ |
| 620 | .ops = &sdp4430_mcbsp_ops, |
| 621 | }, |
| 622 | { |
| 623 | .name = "Legacy McPDM", |
| 624 | .stream_name = "Headset Playback", |
| 625 | |
| 626 | /* ABE components - DL1 */ |
| 627 | .cpu_dai_name = "mcpdm-dl", |
| 628 | .platform_name = "omap-pcm-audio", |
| 629 | |
| 630 | /* Phoenix - DL1 DAC */ |
| 631 | .codec_dai_name = "twl6040-dl1", |
| 632 | .codec_name = "twl6040-codec", |
| 633 | |
| 634 | .ops = &sdp4430_mcpdm_ops, |
| 635 | }, |
| 636 | { |
| 637 | .name = "Legacy DMIC", |
| 638 | .stream_name = "DMIC Capture", |
| 639 | |
| 640 | /* ABE components - DMIC0 */ |
| 641 | .cpu_dai_name = "omap-dmic-dai-0", |
| 642 | .platform_name = "omap-pcm-audio", |
| 643 | |
| 644 | /* DMIC codec */ |
| 645 | .codec_dai_name = "dmic-hifi", |
| 646 | .codec_name = "dmic-codec.0", |
| 647 | |
Misael Lopez Cruz | 47415f0 | 2011-04-27 23:56:32 -0500 | [diff] [blame] | 648 | .init = sdp4430_dmic_init, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 649 | .ops = &sdp4430_dmic_ops, |
| 650 | }, |
| 651 | |
| 652 | /* |
| 653 | * Backend DAIs - i.e. dynamically matched interfaces, invisible to userspace. |
| 654 | * Matched to above interfaces at runtime, based upon use case. |
| 655 | */ |
| 656 | |
| 657 | { |
| 658 | .name = OMAP_ABE_BE_PDM_DL1, |
| 659 | .stream_name = "HS Playback", |
| 660 | |
| 661 | /* ABE components - DL1 */ |
| 662 | .cpu_dai_name = "mcpdm-dl1", |
| 663 | .platform_name = "aess", |
| 664 | |
| 665 | /* Phoenix - DL1 DAC */ |
| 666 | .codec_dai_name = "twl6040-dl1", |
| 667 | .codec_name = "twl6040-codec", |
| 668 | |
| 669 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 670 | .init = sdp4430_twl6040_init, |
| 671 | .ops = &sdp4430_mcpdm_ops, |
| 672 | .be_id = OMAP_ABE_DAI_PDM_DL1, |
| 673 | }, |
| 674 | { |
| 675 | .name = OMAP_ABE_BE_PDM_UL1, |
| 676 | .stream_name = "Analog Capture", |
| 677 | |
| 678 | /* ABE components - UL1 */ |
| 679 | .cpu_dai_name = "mcpdm-ul1", |
| 680 | .platform_name = "aess", |
| 681 | |
| 682 | /* Phoenix - UL ADC */ |
| 683 | .codec_dai_name = "twl6040-ul", |
| 684 | .codec_name = "twl6040-codec", |
| 685 | |
| 686 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 687 | .ops = &sdp4430_mcpdm_ops, |
| 688 | .be_id = OMAP_ABE_DAI_PDM_UL, |
| 689 | }, |
| 690 | { |
| 691 | .name = OMAP_ABE_BE_PDM_DL2, |
| 692 | .stream_name = "HF Playback", |
| 693 | |
| 694 | /* ABE components - DL2 */ |
| 695 | .cpu_dai_name = "mcpdm-dl2", |
| 696 | .platform_name = "aess", |
| 697 | |
| 698 | /* Phoenix - DL2 DAC */ |
| 699 | .codec_dai_name = "twl6040-dl2", |
| 700 | .codec_name = "twl6040-codec", |
| 701 | |
| 702 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
Misael Lopez Cruz | ae141a2 | 2011-04-29 01:52:45 -0500 | [diff] [blame] | 703 | .init = sdp4430_twl6040_dl2_init, |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 704 | .ops = &sdp4430_mcpdm_ops, |
| 705 | .be_id = OMAP_ABE_DAI_PDM_DL2, |
| 706 | }, |
| 707 | { |
| 708 | .name = OMAP_ABE_BE_PDM_VIB, |
| 709 | .stream_name = "Vibra", |
| 710 | |
| 711 | /* ABE components - VIB1 DL */ |
| 712 | .cpu_dai_name = "mcpdm-vib", |
| 713 | .platform_name = "aess", |
| 714 | |
| 715 | /* Phoenix - PDM to PWM */ |
| 716 | .codec_dai_name = "twl6040-vib", |
| 717 | .codec_name = "twl6040-codec", |
| 718 | |
| 719 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 720 | .ops = &sdp4430_mcpdm_ops, |
| 721 | .be_id = OMAP_ABE_DAI_PDM_VIB, |
| 722 | }, |
| 723 | { |
| 724 | .name = OMAP_ABE_BE_BT_VX, |
| 725 | .stream_name = "BT", |
| 726 | |
| 727 | /* ABE components - MCBSP1 - BT-VX */ |
| 728 | .cpu_dai_name = "omap-mcbsp-dai.0", |
| 729 | .platform_name = "aess", |
| 730 | |
| 731 | /* Bluetooth */ |
| 732 | .codec_dai_name = "Bluetooth", |
| 733 | |
| 734 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 735 | .no_codec = 1, /* TODO: have a dummy CODEC */ |
| 736 | .be_hw_params_fixup = mcbsp_be_hw_params_fixup, |
| 737 | .ops = &sdp4430_mcbsp_ops, |
| 738 | .be_id = OMAP_ABE_DAI_BT_VX, |
| 739 | }, |
| 740 | { |
| 741 | .name = OMAP_ABE_BE_MM_EXT0, |
| 742 | .stream_name = "FM", |
| 743 | |
| 744 | /* ABE components - MCBSP2 - MM-EXT */ |
| 745 | .cpu_dai_name = "omap-mcbsp-dai.1", |
| 746 | .platform_name = "aess", |
| 747 | |
| 748 | /* FM */ |
| 749 | .codec_dai_name = "FM Digital", |
| 750 | |
| 751 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 752 | .no_codec = 1, /* TODO: have a dummy CODEC */ |
| 753 | .be_hw_params_fixup = mcbsp_be_hw_params_fixup, |
| 754 | .ops = &sdp4430_mcbsp_ops, |
| 755 | .be_id = OMAP_ABE_DAI_MM_FM, |
| 756 | }, |
| 757 | { |
| 758 | .name = OMAP_ABE_BE_MM_EXT1, |
| 759 | .stream_name = "MODEM", |
| 760 | |
| 761 | /* ABE components - MCBSP2 - MM-EXT */ |
| 762 | .cpu_dai_name = "omap-mcbsp-dai.1", |
| 763 | .platform_name = "aess", |
| 764 | |
| 765 | /* MODEM */ |
| 766 | .codec_dai_name = "MODEM", |
| 767 | |
| 768 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 769 | .no_codec = 1, /* TODO: have a dummy CODEC */ |
| 770 | .be_hw_params_fixup = mcbsp_be_hw_params_fixup, |
| 771 | .ops = &sdp4430_mcbsp_ops, |
| 772 | .be_id = OMAP_ABE_DAI_MODEM, |
| 773 | .ignore_suspend = 1, |
| 774 | }, |
| 775 | { |
| 776 | .name = OMAP_ABE_BE_DMIC0, |
Misael Lopez Cruz | 4f226b6 | 2011-06-06 19:46:45 -0500 | [diff] [blame] | 777 | .stream_name = "DMIC0 Capture", |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 778 | |
| 779 | /* ABE components - DMIC UL 1 */ |
| 780 | .cpu_dai_name = "omap-dmic-abe-dai-0", |
| 781 | .platform_name = "aess", |
| 782 | |
| 783 | /* DMIC 0 */ |
| 784 | .codec_dai_name = "dmic-hifi", |
| 785 | .codec_name = "dmic-codec.0", |
| 786 | .ops = &sdp4430_dmic_ops, |
| 787 | |
| 788 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 789 | .be_hw_params_fixup = dmic_be_hw_params_fixup, |
| 790 | .be_id = OMAP_ABE_DAI_DMIC0, |
| 791 | }, |
| 792 | { |
| 793 | .name = OMAP_ABE_BE_DMIC1, |
Misael Lopez Cruz | 4f226b6 | 2011-06-06 19:46:45 -0500 | [diff] [blame] | 794 | .stream_name = "DMIC1 Capture", |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 795 | |
| 796 | /* ABE components - DMIC UL 1 */ |
| 797 | .cpu_dai_name = "omap-dmic-abe-dai-1", |
| 798 | .platform_name = "aess", |
| 799 | |
| 800 | /* DMIC 1 */ |
| 801 | .codec_dai_name = "dmic-hifi", |
| 802 | .codec_name = "dmic-codec.1", |
| 803 | .ops = &sdp4430_dmic_ops, |
| 804 | |
| 805 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 806 | .be_hw_params_fixup = dmic_be_hw_params_fixup, |
| 807 | .be_id = OMAP_ABE_DAI_DMIC1, |
| 808 | }, |
| 809 | { |
| 810 | .name = OMAP_ABE_BE_DMIC2, |
Misael Lopez Cruz | 4f226b6 | 2011-06-06 19:46:45 -0500 | [diff] [blame] | 811 | .stream_name = "DMIC2 Capture", |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 812 | |
| 813 | /* ABE components - DMIC UL 2 */ |
| 814 | .cpu_dai_name = "omap-dmic-abe-dai-2", |
| 815 | .platform_name = "aess", |
| 816 | |
| 817 | /* DMIC 2 */ |
| 818 | .codec_dai_name = "dmic-hifi", |
| 819 | .codec_name = "dmic-codec.2", |
| 820 | .ops = &sdp4430_dmic_ops, |
| 821 | |
| 822 | .no_pcm = 1, /* don't create ALSA pcm for this */ |
| 823 | .be_hw_params_fixup = dmic_be_hw_params_fixup, |
| 824 | .be_id = OMAP_ABE_DAI_DMIC2, |
| 825 | }, |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 826 | }; |
| 827 | |
| 828 | /* Audio machine driver */ |
| 829 | static struct snd_soc_card snd_soc_sdp4430 = { |
Liam Girdwood | 62e16e8 | 2011-02-07 21:09:59 +0000 | [diff] [blame] | 830 | .driver_name = "OMAP4", |
| 831 | .long_name = "TI OMAP4 Board", |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 832 | .dai_link = sdp4430_dai, |
| 833 | .num_links = ARRAY_SIZE(sdp4430_dai), |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 834 | }; |
| 835 | |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 836 | static struct platform_device *sdp4430_snd_device; |
Liam Girdwood | 8cc5705 | 2011-02-07 21:18:06 +0000 | [diff] [blame] | 837 | static struct i2c_adapter *adapter; |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 838 | |
| 839 | static int __init sdp4430_soc_init(void) |
| 840 | { |
| 841 | int ret; |
| 842 | |
Liam Girdwood | 62e16e8 | 2011-02-07 21:09:59 +0000 | [diff] [blame] | 843 | if (!machine_is_omap_4430sdp() && !machine_is_omap4_panda()) { |
| 844 | pr_debug("Not SDP4430 or PandaBoard!\n"); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 845 | return -ENODEV; |
Liam Girdwood | 62e16e8 | 2011-02-07 21:09:59 +0000 | [diff] [blame] | 846 | } |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 847 | printk(KERN_INFO "SDP4430 SoC init\n"); |
Liam Girdwood | 62e16e8 | 2011-02-07 21:09:59 +0000 | [diff] [blame] | 848 | if (machine_is_omap_4430sdp()) |
| 849 | snd_soc_sdp4430.name = "SDP4430"; |
| 850 | else if (machine_is_omap4_panda()) |
| 851 | snd_soc_sdp4430.name = "Panda"; |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 852 | |
| 853 | sdp4430_snd_device = platform_device_alloc("soc-audio", -1); |
| 854 | if (!sdp4430_snd_device) { |
| 855 | printk(KERN_ERR "Platform device allocation failed\n"); |
| 856 | return -ENOMEM; |
| 857 | } |
| 858 | |
Liam Girdwood | ede6aa9 | 2011-02-07 21:07:48 +0000 | [diff] [blame] | 859 | ret = snd_soc_register_dais(&sdp4430_snd_device->dev, dai, ARRAY_SIZE(dai)); |
| 860 | if (ret < 0) |
Liam Girdwood | 8cc5705 | 2011-02-07 21:18:06 +0000 | [diff] [blame] | 861 | goto err_dai; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 862 | platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 863 | |
| 864 | ret = platform_device_add(sdp4430_snd_device); |
| 865 | if (ret) |
Liam Girdwood | 8cc5705 | 2011-02-07 21:18:06 +0000 | [diff] [blame] | 866 | goto err_dev; |
| 867 | |
| 868 | adapter = i2c_get_adapter(1); |
| 869 | if (!adapter) { |
| 870 | printk(KERN_ERR "can't get i2c adapter\n"); |
| 871 | ret = -ENODEV; |
| 872 | goto err_adap; |
| 873 | } |
| 874 | |
| 875 | tps6130x_client = i2c_new_device(adapter, &tps6130x_hwmon_info); |
| 876 | if (!tps6130x_client) { |
| 877 | printk(KERN_ERR "can't add i2c device\n"); |
| 878 | ret = -ENODEV; |
| 879 | goto err_i2c; |
| 880 | } |
| 881 | |
| 882 | /* Only configure the TPS6130x on SDP4430 */ |
| 883 | if (machine_is_omap_4430sdp()) |
| 884 | sdp4430_tps6130x_configure(); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 885 | |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 886 | return 0; |
| 887 | |
Liam Girdwood | 8cc5705 | 2011-02-07 21:18:06 +0000 | [diff] [blame] | 888 | err_i2c: |
| 889 | i2c_put_adapter(adapter); |
| 890 | err_adap: |
| 891 | platform_device_del(sdp4430_snd_device); |
| 892 | err_dev: |
| 893 | snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai)); |
| 894 | err_dai: |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 895 | platform_device_put(sdp4430_snd_device); |
| 896 | return ret; |
| 897 | } |
| 898 | module_init(sdp4430_soc_init); |
| 899 | |
| 900 | static void __exit sdp4430_soc_exit(void) |
| 901 | { |
| 902 | platform_device_unregister(sdp4430_snd_device); |
Liam Girdwood | 8cc5705 | 2011-02-07 21:18:06 +0000 | [diff] [blame] | 903 | snd_soc_unregister_dais(&sdp4430_snd_device->dev, ARRAY_SIZE(dai)); |
| 904 | i2c_unregister_device(tps6130x_client); |
| 905 | i2c_put_adapter(adapter); |
Misael Lopez Cruz | 5e64d6a | 2010-05-17 19:53:10 -0500 | [diff] [blame] | 906 | } |
| 907 | module_exit(sdp4430_soc_exit); |
| 908 | |
| 909 | MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>"); |
| 910 | MODULE_DESCRIPTION("ALSA SoC SDP4430"); |
| 911 | MODULE_LICENSE("GPL"); |
| 912 | |