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