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> |
| 26 | #include <sound/soc-dapm.h> |
| 27 | |
| 28 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/spitz.h> |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 30 | #include "../codecs/wm8750.h" |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 31 | #include "pxa2xx-i2s.h" |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 32 | |
| 33 | #define SPITZ_HP 0 |
| 34 | #define SPITZ_MIC 1 |
| 35 | #define SPITZ_LINE 2 |
| 36 | #define SPITZ_HEADSET 3 |
| 37 | #define SPITZ_HP_OFF 4 |
| 38 | #define SPITZ_SPK_ON 0 |
| 39 | #define SPITZ_SPK_OFF 1 |
| 40 | |
| 41 | /* audio clock in Hz - rounded from 12.235MHz */ |
| 42 | #define SPITZ_AUDIO_CLOCK 12288000 |
| 43 | |
| 44 | static int spitz_jack_func; |
| 45 | static int spitz_spk_func; |
| 46 | |
| 47 | static void spitz_ext_control(struct snd_soc_codec *codec) |
| 48 | { |
| 49 | if (spitz_spk_func == SPITZ_SPK_ON) |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 50 | snd_soc_dapm_enable_pin(codec, "Ext Spk"); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 51 | else |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 52 | snd_soc_dapm_disable_pin(codec, "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 | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 58 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
| 59 | snd_soc_dapm_disable_pin(codec, "Mic Jack"); |
| 60 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 61 | snd_soc_dapm_enable_pin(codec, "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 | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 67 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 68 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
| 69 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 70 | snd_soc_dapm_enable_pin(codec, "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 | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 76 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 77 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
| 78 | snd_soc_dapm_disable_pin(codec, "Mic Jack"); |
| 79 | snd_soc_dapm_enable_pin(codec, "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 | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 85 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 86 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); |
| 87 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 88 | snd_soc_dapm_enable_pin(codec, "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 | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 95 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 96 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
| 97 | snd_soc_dapm_disable_pin(codec, "Mic Jack"); |
| 98 | snd_soc_dapm_disable_pin(codec, "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 | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 103 | snd_soc_dapm_sync(codec); |
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 | |
| 111 | /* check the jack status at stream startup */ |
| 112 | spitz_ext_control(codec); |
| 113 | return 0; |
| 114 | } |
| 115 | |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 116 | static int spitz_hw_params(struct snd_pcm_substream *substream, |
| 117 | struct snd_pcm_hw_params *params) |
| 118 | { |
| 119 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame^] | 120 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 121 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 122 | unsigned int clk = 0; |
| 123 | int ret = 0; |
| 124 | |
| 125 | switch (params_rate(params)) { |
| 126 | case 8000: |
| 127 | case 16000: |
| 128 | case 48000: |
| 129 | case 96000: |
| 130 | clk = 12288000; |
| 131 | break; |
| 132 | case 11025: |
| 133 | case 22050: |
| 134 | case 44100: |
| 135 | clk = 11289600; |
| 136 | break; |
| 137 | } |
| 138 | |
| 139 | /* set codec DAI configuration */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 140 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 141 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); |
| 142 | if (ret < 0) |
| 143 | return ret; |
| 144 | |
| 145 | /* set cpu DAI configuration */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 146 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 147 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); |
| 148 | if (ret < 0) |
| 149 | return ret; |
| 150 | |
| 151 | /* set the codec system clock for DAC and ADC */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 152 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 153 | SND_SOC_CLOCK_IN); |
| 154 | if (ret < 0) |
| 155 | return ret; |
| 156 | |
| 157 | /* set the I2S system clock as input (unused) */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 158 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 159 | SND_SOC_CLOCK_IN); |
| 160 | if (ret < 0) |
| 161 | return ret; |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 166 | static struct snd_soc_ops spitz_ops = { |
| 167 | .startup = spitz_startup, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 168 | .hw_params = spitz_hw_params, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | static int spitz_get_jack(struct snd_kcontrol *kcontrol, |
| 172 | struct snd_ctl_elem_value *ucontrol) |
| 173 | { |
| 174 | ucontrol->value.integer.value[0] = spitz_jack_func; |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | static int spitz_set_jack(struct snd_kcontrol *kcontrol, |
| 179 | struct snd_ctl_elem_value *ucontrol) |
| 180 | { |
| 181 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 182 | |
| 183 | if (spitz_jack_func == ucontrol->value.integer.value[0]) |
| 184 | return 0; |
| 185 | |
| 186 | spitz_jack_func = ucontrol->value.integer.value[0]; |
| 187 | spitz_ext_control(codec); |
| 188 | return 1; |
| 189 | } |
| 190 | |
| 191 | static int spitz_get_spk(struct snd_kcontrol *kcontrol, |
| 192 | struct snd_ctl_elem_value *ucontrol) |
| 193 | { |
| 194 | ucontrol->value.integer.value[0] = spitz_spk_func; |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | static int spitz_set_spk(struct snd_kcontrol *kcontrol, |
| 199 | struct snd_ctl_elem_value *ucontrol) |
| 200 | { |
| 201 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 202 | |
| 203 | if (spitz_spk_func == ucontrol->value.integer.value[0]) |
| 204 | return 0; |
| 205 | |
| 206 | spitz_spk_func = ucontrol->value.integer.value[0]; |
| 207 | spitz_ext_control(codec); |
| 208 | return 1; |
| 209 | } |
| 210 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 211 | static int spitz_mic_bias(struct snd_soc_dapm_widget *w, |
| 212 | struct snd_kcontrol *k, int event) |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 213 | { |
Eric Miao | fff1472 | 2008-09-05 22:15:23 +0800 | [diff] [blame] | 214 | if (machine_is_borzoi() || machine_is_spitz()) |
| 215 | gpio_set_value(SPITZ_GPIO_MIC_BIAS, |
| 216 | SND_SOC_DAPM_EVENT_ON(event)); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 217 | |
Eric Miao | f72de66 | 2008-09-06 08:46:23 +0800 | [diff] [blame] | 218 | if (machine_is_akita()) |
| 219 | gpio_set_value(AKITA_GPIO_MIC_BIAS, |
| 220 | SND_SOC_DAPM_EVENT_ON(event)); |
| 221 | |
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; |
Philipp Zabel | eb5f6d75 | 2009-03-12 11:07:54 +0100 | [diff] [blame] | 279 | int err; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 280 | |
| 281 | /* NC codec pins */ |
Mark Brown | 35f5e54 | 2008-09-27 10:45:09 +0100 | [diff] [blame] | 282 | snd_soc_dapm_nc_pin(codec, "RINPUT1"); |
| 283 | snd_soc_dapm_nc_pin(codec, "LINPUT2"); |
| 284 | snd_soc_dapm_nc_pin(codec, "RINPUT2"); |
| 285 | snd_soc_dapm_nc_pin(codec, "LINPUT3"); |
| 286 | snd_soc_dapm_nc_pin(codec, "RINPUT3"); |
| 287 | snd_soc_dapm_nc_pin(codec, "OUT3"); |
| 288 | snd_soc_dapm_nc_pin(codec, "MONO1"); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 289 | |
| 290 | /* Add spitz specific controls */ |
Philipp Zabel | eb5f6d75 | 2009-03-12 11:07:54 +0100 | [diff] [blame] | 291 | err = snd_soc_add_controls(codec, wm8750_spitz_controls, |
| 292 | ARRAY_SIZE(wm8750_spitz_controls)); |
| 293 | if (err < 0) |
| 294 | return err; |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 295 | |
| 296 | /* Add spitz specific widgets */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 297 | snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, |
| 298 | ARRAY_SIZE(wm8750_dapm_widgets)); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 299 | |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 300 | /* Set up spitz specific audio paths */ |
| 301 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 302 | |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 303 | snd_soc_dapm_sync(codec); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 304 | return 0; |
| 305 | } |
| 306 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 307 | /* spitz digital audio interface glue - connects codec <--> CPU */ |
| 308 | static struct snd_soc_dai_link spitz_dai = { |
| 309 | .name = "wm8750", |
| 310 | .stream_name = "WM8750", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame^] | 311 | .cpu_dai_name = "pxa-is2", |
| 312 | .codec_dai_name = "wm8750-hifi", |
| 313 | .platform_name = "pxa-pcm-audio", |
| 314 | .codec_name = "wm8750-codec.0-001a", |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 315 | .init = spitz_wm8750_init, |
Liam Girdwood | 97952f6 | 2007-02-02 17:22:46 +0100 | [diff] [blame] | 316 | .ops = &spitz_ops, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 317 | }; |
| 318 | |
| 319 | /* spitz audio machine driver */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 320 | static struct snd_soc_card snd_soc_spitz = { |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 321 | .name = "Spitz", |
| 322 | .dai_link = &spitz_dai, |
| 323 | .num_links = 1, |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 324 | }; |
| 325 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 326 | static struct platform_device *spitz_snd_device; |
| 327 | |
| 328 | static int __init spitz_init(void) |
| 329 | { |
| 330 | int ret; |
| 331 | |
| 332 | if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) |
| 333 | return -ENODEV; |
| 334 | |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 335 | spitz_snd_device = platform_device_alloc("soc-audio", -1); |
| 336 | if (!spitz_snd_device) |
| 337 | return -ENOMEM; |
| 338 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame^] | 339 | platform_set_drvdata(spitz_snd_device, &snd_soc_spitz); |
Liam Girdwood | 7fb290d | 2006-10-12 14:32:13 +0200 | [diff] [blame] | 340 | ret = platform_device_add(spitz_snd_device); |
| 341 | |
| 342 | if (ret) |
| 343 | platform_device_put(spitz_snd_device); |
| 344 | |
| 345 | return ret; |
| 346 | } |
| 347 | |
| 348 | static void __exit spitz_exit(void) |
| 349 | { |
| 350 | platform_device_unregister(spitz_snd_device); |
| 351 | } |
| 352 | |
| 353 | module_init(spitz_init); |
| 354 | module_exit(spitz_exit); |
| 355 | |
| 356 | MODULE_AUTHOR("Richard Purdie"); |
| 357 | MODULE_DESCRIPTION("ALSA SoC Spitz"); |
| 358 | MODULE_LICENSE("GPL"); |