Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 1 | /* |
| 2 | * spitz.c -- SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita |
| 3 | * |
| 4 | * Copyright 2005 Wolfson Microelectronics PLC. |
| 5 | * Copyright 2005 Openedhand Ltd. |
| 6 | * |
Liam Girdwood | d331124 | 2008-10-12 13:17:36 +0100 | [diff] [blame] | 7 | * Authors: Liam Girdwood <lrg@slimlogic.co.uk> |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 8 | * Richard Purdie <richard@openedhand.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
| 12 | * Free Software Foundation; either version 2 of the License, or (at your |
| 13 | * option) any later version. |
| 14 | * |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/moduleparam.h> |
| 19 | #include <linux/timer.h> |
| 20 | #include <linux/interrupt.h> |
| 21 | #include <linux/platform_device.h> |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 22 | #include <linux/gpio.h> |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 23 | #include <sound/core.h> |
| 24 | #include <sound/pcm.h> |
| 25 | #include <sound/soc.h> |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 26 | |
| 27 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/spitz.h> |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 29 | #include "../codecs/wm8750.h" |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 30 | #include "pxa2xx-i2s.h" |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 31 | |
| 32 | #define SPITZ_HP 0 |
| 33 | #define SPITZ_MIC 1 |
| 34 | #define SPITZ_LINE 2 |
| 35 | #define SPITZ_HEADSET 3 |
| 36 | #define SPITZ_HP_OFF 4 |
| 37 | #define SPITZ_SPK_ON 0 |
| 38 | #define SPITZ_SPK_OFF 1 |
| 39 | |
| 40 | /* audio clock in Hz - rounded from 12.235MHz */ |
| 41 | #define SPITZ_AUDIO_CLOCK 12288000 |
| 42 | |
| 43 | static int spitz_jack_func; |
| 44 | static int spitz_spk_func; |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 45 | static int spitz_mic_gpio; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 46 | |
| 47 | static void spitz_ext_control(struct snd_soc_codec *codec) |
| 48 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 49 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 50 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 51 | if (spitz_spk_func == SPITZ_SPK_ON) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 52 | snd_soc_dapm_enable_pin(dapm, "Ext Spk"); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 53 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 54 | snd_soc_dapm_disable_pin(dapm, "Ext Spk"); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 55 | |
| 56 | /* set up jack connection */ |
| 57 | switch (spitz_jack_func) { |
| 58 | case SPITZ_HP: |
| 59 | /* enable and unmute hp jack, disable mic bias */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 60 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
| 61 | snd_soc_dapm_disable_pin(dapm, "Mic Jack"); |
| 62 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
| 63 | snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 64 | gpio_set_value(SPITZ_GPIO_MUTE_L, 1); |
| 65 | gpio_set_value(SPITZ_GPIO_MUTE_R, 1); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 66 | break; |
| 67 | case SPITZ_MIC: |
| 68 | /* enable mic jack and bias, mute hp */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 69 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 70 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
| 71 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
| 72 | snd_soc_dapm_enable_pin(dapm, "Mic Jack"); |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 73 | gpio_set_value(SPITZ_GPIO_MUTE_L, 0); |
| 74 | gpio_set_value(SPITZ_GPIO_MUTE_R, 0); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 75 | break; |
| 76 | case SPITZ_LINE: |
| 77 | /* enable line jack, disable mic bias and mute hp */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 78 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 79 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
| 80 | snd_soc_dapm_disable_pin(dapm, "Mic Jack"); |
| 81 | snd_soc_dapm_enable_pin(dapm, "Line Jack"); |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 82 | gpio_set_value(SPITZ_GPIO_MUTE_L, 0); |
| 83 | gpio_set_value(SPITZ_GPIO_MUTE_R, 0); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 84 | break; |
| 85 | case SPITZ_HEADSET: |
| 86 | /* enable and unmute headset jack enable mic bias, mute L hp */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 87 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 88 | snd_soc_dapm_enable_pin(dapm, "Mic Jack"); |
| 89 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
| 90 | snd_soc_dapm_enable_pin(dapm, "Headset Jack"); |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 91 | gpio_set_value(SPITZ_GPIO_MUTE_L, 0); |
| 92 | gpio_set_value(SPITZ_GPIO_MUTE_R, 1); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 93 | break; |
| 94 | case SPITZ_HP_OFF: |
| 95 | |
| 96 | /* jack removed, everything off */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 97 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 98 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
| 99 | snd_soc_dapm_disable_pin(dapm, "Mic Jack"); |
| 100 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 101 | gpio_set_value(SPITZ_GPIO_MUTE_L, 0); |
| 102 | gpio_set_value(SPITZ_GPIO_MUTE_R, 0); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 103 | break; |
| 104 | } |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 105 | snd_soc_dapm_sync(dapm); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static int spitz_startup(struct snd_pcm_substream *substream) |
| 109 | { |
| 110 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 111 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 112 | |
Mark Brown | 71a2956 | 2010-11-05 13:50:48 -0400 | [diff] [blame] | 113 | mutex_lock(&codec->mutex); |
| 114 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 115 | /* check the jack status at stream startup */ |
| 116 | spitz_ext_control(codec); |
Mark Brown | 71a2956 | 2010-11-05 13:50:48 -0400 | [diff] [blame] | 117 | |
| 118 | mutex_unlock(&codec->mutex); |
| 119 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 120 | return 0; |
| 121 | } |
| 122 | |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 123 | static int spitz_hw_params(struct snd_pcm_substream *substream, |
| 124 | struct snd_pcm_hw_params *params) |
| 125 | { |
| 126 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 127 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 128 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 129 | unsigned int clk = 0; |
| 130 | int ret = 0; |
| 131 | |
| 132 | switch (params_rate(params)) { |
| 133 | case 8000: |
| 134 | case 16000: |
| 135 | case 48000: |
| 136 | case 96000: |
| 137 | clk = 12288000; |
| 138 | break; |
| 139 | case 11025: |
| 140 | case 22050: |
| 141 | case 44100: |
| 142 | clk = 11289600; |
| 143 | break; |
| 144 | } |
| 145 | |
| 146 | /* set codec DAI configuration */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 147 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 148 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); |
| 149 | if (ret < 0) |
| 150 | return ret; |
| 151 | |
| 152 | /* set cpu DAI configuration */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 153 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 154 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); |
| 155 | if (ret < 0) |
| 156 | return ret; |
| 157 | |
| 158 | /* set the codec system clock for DAC and ADC */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 159 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 160 | SND_SOC_CLOCK_IN); |
| 161 | if (ret < 0) |
| 162 | return ret; |
| 163 | |
| 164 | /* set the I2S system clock as input (unused) */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 165 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 166 | SND_SOC_CLOCK_IN); |
| 167 | if (ret < 0) |
| 168 | return ret; |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 173 | static struct snd_soc_ops spitz_ops = { |
| 174 | .startup = spitz_startup, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 175 | .hw_params = spitz_hw_params, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | static int spitz_get_jack(struct snd_kcontrol *kcontrol, |
| 179 | struct snd_ctl_elem_value *ucontrol) |
| 180 | { |
| 181 | ucontrol->value.integer.value[0] = spitz_jack_func; |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | static int spitz_set_jack(struct snd_kcontrol *kcontrol, |
| 186 | struct snd_ctl_elem_value *ucontrol) |
| 187 | { |
| 188 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 189 | |
| 190 | if (spitz_jack_func == ucontrol->value.integer.value[0]) |
| 191 | return 0; |
| 192 | |
| 193 | spitz_jack_func = ucontrol->value.integer.value[0]; |
| 194 | spitz_ext_control(codec); |
| 195 | return 1; |
| 196 | } |
| 197 | |
| 198 | static int spitz_get_spk(struct snd_kcontrol *kcontrol, |
| 199 | struct snd_ctl_elem_value *ucontrol) |
| 200 | { |
| 201 | ucontrol->value.integer.value[0] = spitz_spk_func; |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static int spitz_set_spk(struct snd_kcontrol *kcontrol, |
| 206 | struct snd_ctl_elem_value *ucontrol) |
| 207 | { |
| 208 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 209 | |
| 210 | if (spitz_spk_func == ucontrol->value.integer.value[0]) |
| 211 | return 0; |
| 212 | |
| 213 | spitz_spk_func = ucontrol->value.integer.value[0]; |
| 214 | spitz_ext_control(codec); |
| 215 | return 1; |
| 216 | } |
| 217 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 218 | static int spitz_mic_bias(struct snd_soc_dapm_widget *w, |
| 219 | struct snd_kcontrol *k, int event) |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 220 | { |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 221 | gpio_set_value_cansleep(spitz_mic_gpio, SND_SOC_DAPM_EVENT_ON(event)); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | /* spitz machine dapm widgets */ |
| 226 | static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { |
| 227 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 228 | SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), |
| 229 | SND_SOC_DAPM_SPK("Ext Spk", NULL), |
| 230 | SND_SOC_DAPM_LINE("Line Jack", NULL), |
| 231 | |
| 232 | /* headset is a mic and mono headphone */ |
| 233 | SND_SOC_DAPM_HP("Headset Jack", NULL), |
| 234 | }; |
| 235 | |
| 236 | /* Spitz machine audio_map */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 237 | static const struct snd_soc_dapm_route audio_map[] = { |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 238 | |
| 239 | /* headphone connected to LOUT1, ROUT1 */ |
| 240 | {"Headphone Jack", NULL, "LOUT1"}, |
| 241 | {"Headphone Jack", NULL, "ROUT1"}, |
| 242 | |
| 243 | /* headset connected to ROUT1 and LINPUT1 with bias (def below) */ |
| 244 | {"Headset Jack", NULL, "ROUT1"}, |
| 245 | |
| 246 | /* ext speaker connected to LOUT2, ROUT2 */ |
| 247 | {"Ext Spk", NULL , "ROUT2"}, |
| 248 | {"Ext Spk", NULL , "LOUT2"}, |
| 249 | |
| 250 | /* mic is connected to input 1 - with bias */ |
| 251 | {"LINPUT1", NULL, "Mic Bias"}, |
| 252 | {"Mic Bias", NULL, "Mic Jack"}, |
| 253 | |
| 254 | /* line is connected to input 1 - no bias */ |
| 255 | {"LINPUT1", NULL, "Line Jack"}, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", |
| 259 | "Off"}; |
| 260 | static const char *spk_function[] = {"On", "Off"}; |
| 261 | static const struct soc_enum spitz_enum[] = { |
| 262 | SOC_ENUM_SINGLE_EXT(5, jack_function), |
| 263 | SOC_ENUM_SINGLE_EXT(2, spk_function), |
| 264 | }; |
| 265 | |
| 266 | static const struct snd_kcontrol_new wm8750_spitz_controls[] = { |
| 267 | SOC_ENUM_EXT("Jack Function", spitz_enum[0], spitz_get_jack, |
| 268 | spitz_set_jack), |
| 269 | SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk, |
| 270 | spitz_set_spk), |
| 271 | }; |
| 272 | |
| 273 | /* |
| 274 | * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device |
| 275 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 276 | static int spitz_wm8750_init(struct snd_soc_pcm_runtime *rtd) |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 277 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 278 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 279 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Philipp Zabel | eb5f6d75 | 2009-03-12 11:07:54 +0100 | [diff] [blame] | 280 | int err; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 281 | |
| 282 | /* NC codec pins */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 283 | snd_soc_dapm_nc_pin(dapm, "RINPUT1"); |
| 284 | snd_soc_dapm_nc_pin(dapm, "LINPUT2"); |
| 285 | snd_soc_dapm_nc_pin(dapm, "RINPUT2"); |
| 286 | snd_soc_dapm_nc_pin(dapm, "LINPUT3"); |
| 287 | snd_soc_dapm_nc_pin(dapm, "RINPUT3"); |
| 288 | snd_soc_dapm_nc_pin(dapm, "OUT3"); |
| 289 | snd_soc_dapm_nc_pin(dapm, "MONO1"); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 290 | |
| 291 | /* Add spitz specific controls */ |
Philipp Zabel | eb5f6d75 | 2009-03-12 11:07:54 +0100 | [diff] [blame] | 292 | err = snd_soc_add_controls(codec, wm8750_spitz_controls, |
| 293 | ARRAY_SIZE(wm8750_spitz_controls)); |
| 294 | if (err < 0) |
| 295 | return err; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 296 | |
| 297 | /* Add spitz specific widgets */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 298 | snd_soc_dapm_new_controls(dapm, wm8750_dapm_widgets, |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 299 | ARRAY_SIZE(wm8750_dapm_widgets)); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 300 | |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 301 | /* Set up spitz specific audio paths */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 302 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 303 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 304 | snd_soc_dapm_sync(dapm); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 308 | /* spitz digital audio interface glue - connects codec <--> CPU */ |
| 309 | static struct snd_soc_dai_link spitz_dai = { |
| 310 | .name = "wm8750", |
| 311 | .stream_name = "WM8750", |
Dmitry Eremin-Solenikov | a3adfa0 | 2011-01-21 22:14:17 +0300 | [diff] [blame] | 312 | .cpu_dai_name = "pxa2xx-i2s", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 313 | .codec_dai_name = "wm8750-hifi", |
| 314 | .platform_name = "pxa-pcm-audio", |
Dmitry Eremin-Solenikov | a3adfa0 | 2011-01-21 22:14:17 +0300 | [diff] [blame] | 315 | .codec_name = "wm8750-codec.0-001b", |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 316 | .init = spitz_wm8750_init, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 317 | .ops = &spitz_ops, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 318 | }; |
| 319 | |
| 320 | /* spitz audio machine driver */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 321 | static struct snd_soc_card snd_soc_spitz = { |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 322 | .name = "Spitz", |
| 323 | .dai_link = &spitz_dai, |
| 324 | .num_links = 1, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 325 | }; |
| 326 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 327 | static struct platform_device *spitz_snd_device; |
| 328 | |
| 329 | static int __init spitz_init(void) |
| 330 | { |
| 331 | int ret; |
| 332 | |
| 333 | if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) |
| 334 | return -ENODEV; |
| 335 | |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 336 | if (machine_is_borzoi() || machine_is_spitz()) |
| 337 | spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS; |
| 338 | else |
| 339 | spitz_mic_gpio = AKITA_GPIO_MIC_BIAS; |
| 340 | |
| 341 | ret = gpio_request(spitz_mic_gpio, "MIC GPIO"); |
| 342 | if (ret) |
| 343 | goto err1; |
| 344 | |
| 345 | ret = gpio_direction_output(spitz_mic_gpio, 0); |
| 346 | if (ret) |
| 347 | goto err2; |
| 348 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 349 | spitz_snd_device = platform_device_alloc("soc-audio", -1); |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 350 | if (!spitz_snd_device) { |
| 351 | ret = -ENOMEM; |
| 352 | goto err2; |
| 353 | } |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 354 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 355 | platform_set_drvdata(spitz_snd_device, &snd_soc_spitz); |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 356 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 357 | ret = platform_device_add(spitz_snd_device); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 358 | if (ret) |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 359 | goto err3; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 360 | |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 361 | return 0; |
| 362 | |
| 363 | err3: |
| 364 | platform_device_put(spitz_snd_device); |
| 365 | err2: |
| 366 | gpio_free(spitz_mic_gpio); |
| 367 | err1: |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 368 | return ret; |
| 369 | } |
| 370 | |
| 371 | static void __exit spitz_exit(void) |
| 372 | { |
| 373 | platform_device_unregister(spitz_snd_device); |
Marek Vasut | 04368d0 | 2011-04-02 03:43:15 +0200 | [diff] [blame] | 374 | gpio_free(spitz_mic_gpio); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | module_init(spitz_init); |
| 378 | module_exit(spitz_exit); |
| 379 | |
| 380 | MODULE_AUTHOR("Richard Purdie"); |
| 381 | MODULE_DESCRIPTION("ALSA SoC Spitz"); |
| 382 | MODULE_LICENSE("GPL"); |