Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * corgi.c -- SoC audio for Corgi |
| 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 | a1eb4b3 | 2006-10-12 14:31:16 +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. |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/moduleparam.h> |
| 18 | #include <linux/timer.h> |
| 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/platform_device.h> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 21 | #include <sound/core.h> |
| 22 | #include <sound/pcm.h> |
| 23 | #include <sound/soc.h> |
| 24 | #include <sound/soc-dapm.h> |
| 25 | |
| 26 | #include <asm/mach-types.h> |
| 27 | #include <asm/hardware/scoop.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/pxa-regs.h> |
| 29 | #include <mach/hardware.h> |
| 30 | #include <mach/corgi.h> |
| 31 | #include <mach/audio.h> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 32 | |
| 33 | #include "../codecs/wm8731.h" |
| 34 | #include "pxa2xx-pcm.h" |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 35 | #include "pxa2xx-i2s.h" |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 36 | |
| 37 | #define CORGI_HP 0 |
| 38 | #define CORGI_MIC 1 |
| 39 | #define CORGI_LINE 2 |
| 40 | #define CORGI_HEADSET 3 |
| 41 | #define CORGI_HP_OFF 4 |
| 42 | #define CORGI_SPK_ON 0 |
| 43 | #define CORGI_SPK_OFF 1 |
| 44 | |
| 45 | /* audio clock in Hz - rounded from 12.235MHz */ |
| 46 | #define CORGI_AUDIO_CLOCK 12288000 |
| 47 | |
| 48 | static int corgi_jack_func; |
| 49 | static int corgi_spk_func; |
| 50 | |
| 51 | static void corgi_ext_control(struct snd_soc_codec *codec) |
| 52 | { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 53 | /* set up jack connection */ |
| 54 | switch (corgi_jack_func) { |
| 55 | case CORGI_HP: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 56 | /* set = unmute headphone */ |
| 57 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); |
| 58 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 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"); |
| 62 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 63 | break; |
| 64 | case CORGI_MIC: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 65 | /* reset = mute headphone */ |
| 66 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); |
| 67 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 68 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); |
| 69 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 70 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 71 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 72 | break; |
| 73 | case CORGI_LINE: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 74 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); |
| 75 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 76 | snd_soc_dapm_disable_pin(codec, "Mic Jack"); |
| 77 | snd_soc_dapm_enable_pin(codec, "Line Jack"); |
| 78 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 79 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 80 | break; |
| 81 | case CORGI_HEADSET: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 82 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); |
| 83 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 84 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); |
| 85 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 86 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 87 | snd_soc_dapm_enable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 88 | break; |
| 89 | } |
| 90 | |
| 91 | if (corgi_spk_func == CORGI_SPK_ON) |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 92 | snd_soc_dapm_enable_pin(codec, "Ext Spk"); |
| 93 | else |
| 94 | snd_soc_dapm_disable_pin(codec, "Ext Spk"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 95 | |
| 96 | /* signal a DAPM event */ |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 97 | snd_soc_dapm_sync(codec); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static int corgi_startup(struct snd_pcm_substream *substream) |
| 101 | { |
| 102 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 103 | struct snd_soc_codec *codec = rtd->socdev->codec; |
| 104 | |
| 105 | /* check the jack status at stream startup */ |
| 106 | corgi_ext_control(codec); |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | /* we need to unmute the HP at shutdown as the mute burns power on corgi */ |
| 111 | static int corgi_shutdown(struct snd_pcm_substream *substream) |
| 112 | { |
| 113 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 114 | struct snd_soc_codec *codec = rtd->socdev->codec; |
| 115 | |
| 116 | /* set = unmute headphone */ |
| 117 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L); |
| 118 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R); |
| 119 | return 0; |
| 120 | } |
| 121 | |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 122 | static int corgi_hw_params(struct snd_pcm_substream *substream, |
| 123 | struct snd_pcm_hw_params *params) |
| 124 | { |
| 125 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | 917f93a | 2008-07-07 16:08:11 +0100 | [diff] [blame] | 126 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; |
| 127 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 128 | unsigned int clk = 0; |
| 129 | int ret = 0; |
| 130 | |
| 131 | switch (params_rate(params)) { |
| 132 | case 8000: |
| 133 | case 16000: |
| 134 | case 48000: |
| 135 | case 96000: |
| 136 | clk = 12288000; |
| 137 | break; |
| 138 | case 11025: |
| 139 | case 22050: |
| 140 | case 44100: |
| 141 | clk = 11289600; |
| 142 | break; |
| 143 | } |
| 144 | |
| 145 | /* set codec DAI configuration */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 146 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 147 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); |
| 148 | if (ret < 0) |
| 149 | return ret; |
| 150 | |
| 151 | /* set cpu DAI configuration */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 152 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 153 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); |
| 154 | if (ret < 0) |
| 155 | return ret; |
| 156 | |
| 157 | /* set the codec system clock for DAC and ADC */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 158 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK, clk, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 159 | SND_SOC_CLOCK_IN); |
| 160 | if (ret < 0) |
| 161 | return ret; |
| 162 | |
| 163 | /* set the I2S system clock as input (unused) */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 164 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 165 | SND_SOC_CLOCK_IN); |
| 166 | if (ret < 0) |
| 167 | return ret; |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 172 | static struct snd_soc_ops corgi_ops = { |
| 173 | .startup = corgi_startup, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 174 | .hw_params = corgi_hw_params, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 175 | .shutdown = corgi_shutdown, |
| 176 | }; |
| 177 | |
| 178 | static int corgi_get_jack(struct snd_kcontrol *kcontrol, |
| 179 | struct snd_ctl_elem_value *ucontrol) |
| 180 | { |
| 181 | ucontrol->value.integer.value[0] = corgi_jack_func; |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | static int corgi_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 (corgi_jack_func == ucontrol->value.integer.value[0]) |
| 191 | return 0; |
| 192 | |
| 193 | corgi_jack_func = ucontrol->value.integer.value[0]; |
| 194 | corgi_ext_control(codec); |
| 195 | return 1; |
| 196 | } |
| 197 | |
| 198 | static int corgi_get_spk(struct snd_kcontrol *kcontrol, |
| 199 | struct snd_ctl_elem_value *ucontrol) |
| 200 | { |
| 201 | ucontrol->value.integer.value[0] = corgi_spk_func; |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static int corgi_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 (corgi_spk_func == ucontrol->value.integer.value[0]) |
| 211 | return 0; |
| 212 | |
| 213 | corgi_spk_func = ucontrol->value.integer.value[0]; |
| 214 | corgi_ext_control(codec); |
| 215 | return 1; |
| 216 | } |
| 217 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 218 | static int corgi_amp_event(struct snd_soc_dapm_widget *w, |
| 219 | struct snd_kcontrol *k, int event) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 220 | { |
| 221 | if (SND_SOC_DAPM_EVENT_ON(event)) |
| 222 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); |
| 223 | else |
| 224 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 229 | static int corgi_mic_event(struct snd_soc_dapm_widget *w, |
| 230 | struct snd_kcontrol *k, int event) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 231 | { |
| 232 | if (SND_SOC_DAPM_EVENT_ON(event)) |
| 233 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS); |
| 234 | else |
| 235 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS); |
| 236 | |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | /* corgi machine dapm widgets */ |
| 241 | static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { |
| 242 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 243 | SND_SOC_DAPM_MIC("Mic Jack", corgi_mic_event), |
| 244 | SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event), |
| 245 | SND_SOC_DAPM_LINE("Line Jack", NULL), |
| 246 | SND_SOC_DAPM_HP("Headset Jack", NULL), |
| 247 | }; |
| 248 | |
| 249 | /* Corgi machine audio map (connections to the codec pins) */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 250 | static const struct snd_soc_dapm_route audio_map[] = { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 251 | |
| 252 | /* headset Jack - in = micin, out = LHPOUT*/ |
| 253 | {"Headset Jack", NULL, "LHPOUT"}, |
| 254 | |
| 255 | /* headphone connected to LHPOUT1, RHPOUT1 */ |
| 256 | {"Headphone Jack", NULL, "LHPOUT"}, |
| 257 | {"Headphone Jack", NULL, "RHPOUT"}, |
| 258 | |
| 259 | /* speaker connected to LOUT, ROUT */ |
| 260 | {"Ext Spk", NULL, "ROUT"}, |
| 261 | {"Ext Spk", NULL, "LOUT"}, |
| 262 | |
| 263 | /* mic is connected to MICIN (via right channel of headphone jack) */ |
| 264 | {"MICIN", NULL, "Mic Jack"}, |
| 265 | |
| 266 | /* Same as the above but no mic bias for line signals */ |
| 267 | {"MICIN", NULL, "Line Jack"}, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", |
| 271 | "Off"}; |
| 272 | static const char *spk_function[] = {"On", "Off"}; |
| 273 | static const struct soc_enum corgi_enum[] = { |
| 274 | SOC_ENUM_SINGLE_EXT(5, jack_function), |
| 275 | SOC_ENUM_SINGLE_EXT(2, spk_function), |
| 276 | }; |
| 277 | |
| 278 | static const struct snd_kcontrol_new wm8731_corgi_controls[] = { |
| 279 | SOC_ENUM_EXT("Jack Function", corgi_enum[0], corgi_get_jack, |
| 280 | corgi_set_jack), |
| 281 | SOC_ENUM_EXT("Speaker Function", corgi_enum[1], corgi_get_spk, |
| 282 | corgi_set_spk), |
| 283 | }; |
| 284 | |
| 285 | /* |
| 286 | * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device |
| 287 | */ |
| 288 | static int corgi_wm8731_init(struct snd_soc_codec *codec) |
| 289 | { |
| 290 | int i, err; |
| 291 | |
Mark Brown | 35f5e54 | 2008-09-27 10:45:09 +0100 | [diff] [blame] | 292 | snd_soc_dapm_nc_pin(codec, "LLINEIN"); |
| 293 | snd_soc_dapm_nc_pin(codec, "RLINEIN"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 294 | |
| 295 | /* Add corgi specific controls */ |
| 296 | for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) { |
| 297 | err = snd_ctl_add(codec->card, |
Mark Brown | 1bfcd36 | 2008-04-23 15:12:19 +0200 | [diff] [blame] | 298 | snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 299 | if (err < 0) |
| 300 | return err; |
| 301 | } |
| 302 | |
| 303 | /* Add corgi specific widgets */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 304 | snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, |
| 305 | ARRAY_SIZE(wm8731_dapm_widgets)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 306 | |
| 307 | /* Set up corgi specific audio path audio_map */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 308 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 309 | |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 310 | snd_soc_dapm_sync(codec); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 314 | /* corgi digital audio interface glue - connects codec <--> CPU */ |
| 315 | static struct snd_soc_dai_link corgi_dai = { |
| 316 | .name = "WM8731", |
| 317 | .stream_name = "WM8731", |
| 318 | .cpu_dai = &pxa_i2s_dai, |
| 319 | .codec_dai = &wm8731_dai, |
| 320 | .init = corgi_wm8731_init, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 321 | .ops = &corgi_ops, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | /* corgi audio machine driver */ |
| 325 | static struct snd_soc_machine snd_soc_machine_corgi = { |
| 326 | .name = "Corgi", |
| 327 | .dai_link = &corgi_dai, |
| 328 | .num_links = 1, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 329 | }; |
| 330 | |
| 331 | /* corgi audio private data */ |
| 332 | static struct wm8731_setup_data corgi_wm8731_setup = { |
Jean Delvare | 81297c8 | 2008-09-01 18:47:01 +0100 | [diff] [blame] | 333 | .i2c_bus = 0, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 334 | .i2c_address = 0x1b, |
| 335 | }; |
| 336 | |
| 337 | /* corgi audio subsystem */ |
| 338 | static struct snd_soc_device corgi_snd_devdata = { |
| 339 | .machine = &snd_soc_machine_corgi, |
| 340 | .platform = &pxa2xx_soc_platform, |
| 341 | .codec_dev = &soc_codec_dev_wm8731, |
| 342 | .codec_data = &corgi_wm8731_setup, |
| 343 | }; |
| 344 | |
| 345 | static struct platform_device *corgi_snd_device; |
| 346 | |
| 347 | static int __init corgi_init(void) |
| 348 | { |
| 349 | int ret; |
| 350 | |
Mark Brown | 1bfcd36 | 2008-04-23 15:12:19 +0200 | [diff] [blame] | 351 | if (!(machine_is_corgi() || machine_is_shepherd() || |
| 352 | machine_is_husky())) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 353 | return -ENODEV; |
| 354 | |
| 355 | corgi_snd_device = platform_device_alloc("soc-audio", -1); |
| 356 | if (!corgi_snd_device) |
| 357 | return -ENOMEM; |
| 358 | |
| 359 | platform_set_drvdata(corgi_snd_device, &corgi_snd_devdata); |
| 360 | corgi_snd_devdata.dev = &corgi_snd_device->dev; |
| 361 | ret = platform_device_add(corgi_snd_device); |
| 362 | |
| 363 | if (ret) |
| 364 | platform_device_put(corgi_snd_device); |
| 365 | |
| 366 | return ret; |
| 367 | } |
| 368 | |
| 369 | static void __exit corgi_exit(void) |
| 370 | { |
| 371 | platform_device_unregister(corgi_snd_device); |
| 372 | } |
| 373 | |
| 374 | module_init(corgi_init); |
| 375 | module_exit(corgi_exit); |
| 376 | |
| 377 | /* Module information */ |
| 378 | MODULE_AUTHOR("Richard Purdie"); |
| 379 | MODULE_DESCRIPTION("ALSA SoC Corgi"); |
| 380 | MODULE_LICENSE("GPL"); |