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> |
Mark Brown | fc99675 | 2009-02-18 12:34:53 +0000 | [diff] [blame] | 19 | #include <linux/i2c.h> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 20 | #include <linux/interrupt.h> |
| 21 | #include <linux/platform_device.h> |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 22 | #include <linux/gpio.h> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +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/corgi.h> |
| 30 | #include <mach/audio.h> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 31 | |
| 32 | #include "../codecs/wm8731.h" |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 33 | #include "pxa2xx-i2s.h" |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 34 | |
| 35 | #define CORGI_HP 0 |
| 36 | #define CORGI_MIC 1 |
| 37 | #define CORGI_LINE 2 |
| 38 | #define CORGI_HEADSET 3 |
| 39 | #define CORGI_HP_OFF 4 |
| 40 | #define CORGI_SPK_ON 0 |
| 41 | #define CORGI_SPK_OFF 1 |
| 42 | |
| 43 | /* audio clock in Hz - rounded from 12.235MHz */ |
| 44 | #define CORGI_AUDIO_CLOCK 12288000 |
| 45 | |
| 46 | static int corgi_jack_func; |
| 47 | static int corgi_spk_func; |
| 48 | |
| 49 | static void corgi_ext_control(struct snd_soc_codec *codec) |
| 50 | { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 51 | /* set up jack connection */ |
| 52 | switch (corgi_jack_func) { |
| 53 | case CORGI_HP: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 54 | /* set = unmute headphone */ |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 55 | gpio_set_value(CORGI_GPIO_MUTE_L, 1); |
| 56 | gpio_set_value(CORGI_GPIO_MUTE_R, 1); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 57 | snd_soc_dapm_disable_pin(codec, "Mic Jack"); |
| 58 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 59 | snd_soc_dapm_enable_pin(codec, "Headphone Jack"); |
| 60 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 61 | break; |
| 62 | case CORGI_MIC: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 63 | /* reset = mute headphone */ |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 64 | gpio_set_value(CORGI_GPIO_MUTE_L, 0); |
| 65 | gpio_set_value(CORGI_GPIO_MUTE_R, 0); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 66 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); |
| 67 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 68 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 69 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 70 | break; |
| 71 | case CORGI_LINE: |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 72 | gpio_set_value(CORGI_GPIO_MUTE_L, 0); |
| 73 | gpio_set_value(CORGI_GPIO_MUTE_R, 0); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 74 | snd_soc_dapm_disable_pin(codec, "Mic Jack"); |
| 75 | snd_soc_dapm_enable_pin(codec, "Line Jack"); |
| 76 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 77 | snd_soc_dapm_disable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 78 | break; |
| 79 | case CORGI_HEADSET: |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 80 | gpio_set_value(CORGI_GPIO_MUTE_L, 0); |
| 81 | gpio_set_value(CORGI_GPIO_MUTE_R, 1); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 82 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); |
| 83 | snd_soc_dapm_disable_pin(codec, "Line Jack"); |
| 84 | snd_soc_dapm_disable_pin(codec, "Headphone Jack"); |
| 85 | snd_soc_dapm_enable_pin(codec, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 86 | break; |
| 87 | } |
| 88 | |
| 89 | if (corgi_spk_func == CORGI_SPK_ON) |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 90 | snd_soc_dapm_enable_pin(codec, "Ext Spk"); |
| 91 | else |
| 92 | snd_soc_dapm_disable_pin(codec, "Ext Spk"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 93 | |
| 94 | /* signal a DAPM event */ |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 95 | snd_soc_dapm_sync(codec); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | static int corgi_startup(struct snd_pcm_substream *substream) |
| 99 | { |
| 100 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 101 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 102 | |
| 103 | /* check the jack status at stream startup */ |
| 104 | corgi_ext_control(codec); |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | /* we need to unmute the HP at shutdown as the mute burns power on corgi */ |
Takashi Iwai | 5220ed6 | 2008-12-01 20:00:47 +0100 | [diff] [blame] | 109 | static void corgi_shutdown(struct snd_pcm_substream *substream) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 110 | { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 111 | /* set = unmute headphone */ |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 112 | gpio_set_value(CORGI_GPIO_MUTE_L, 1); |
| 113 | gpio_set_value(CORGI_GPIO_MUTE_R, 1); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 114 | } |
| 115 | |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 116 | static int corgi_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 | d928b25 | 2007-02-02 17:22:20 +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 | d928b25 | 2007-02-02 17:22:20 +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 | 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 the codec system clock for DAC and ADC */ |
Mark Brown | e771251 | 2010-08-17 23:40:24 +0100 | [diff] [blame] | 152 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, clk, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +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 | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 159 | SND_SOC_CLOCK_IN); |
| 160 | if (ret < 0) |
| 161 | return ret; |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 166 | static struct snd_soc_ops corgi_ops = { |
| 167 | .startup = corgi_startup, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 168 | .hw_params = corgi_hw_params, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 169 | .shutdown = corgi_shutdown, |
| 170 | }; |
| 171 | |
| 172 | static int corgi_get_jack(struct snd_kcontrol *kcontrol, |
| 173 | struct snd_ctl_elem_value *ucontrol) |
| 174 | { |
| 175 | ucontrol->value.integer.value[0] = corgi_jack_func; |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | static int corgi_set_jack(struct snd_kcontrol *kcontrol, |
| 180 | struct snd_ctl_elem_value *ucontrol) |
| 181 | { |
| 182 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 183 | |
| 184 | if (corgi_jack_func == ucontrol->value.integer.value[0]) |
| 185 | return 0; |
| 186 | |
| 187 | corgi_jack_func = ucontrol->value.integer.value[0]; |
| 188 | corgi_ext_control(codec); |
| 189 | return 1; |
| 190 | } |
| 191 | |
| 192 | static int corgi_get_spk(struct snd_kcontrol *kcontrol, |
| 193 | struct snd_ctl_elem_value *ucontrol) |
| 194 | { |
| 195 | ucontrol->value.integer.value[0] = corgi_spk_func; |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static int corgi_set_spk(struct snd_kcontrol *kcontrol, |
| 200 | struct snd_ctl_elem_value *ucontrol) |
| 201 | { |
| 202 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 203 | |
| 204 | if (corgi_spk_func == ucontrol->value.integer.value[0]) |
| 205 | return 0; |
| 206 | |
| 207 | corgi_spk_func = ucontrol->value.integer.value[0]; |
| 208 | corgi_ext_control(codec); |
| 209 | return 1; |
| 210 | } |
| 211 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 212 | static int corgi_amp_event(struct snd_soc_dapm_widget *w, |
| 213 | struct snd_kcontrol *k, int event) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 214 | { |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 215 | gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 216 | return 0; |
| 217 | } |
| 218 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 219 | static int corgi_mic_event(struct snd_soc_dapm_widget *w, |
| 220 | struct snd_kcontrol *k, int event) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 221 | { |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 222 | gpio_set_value(CORGI_GPIO_MIC_BIAS, SND_SOC_DAPM_EVENT_ON(event)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | /* corgi machine dapm widgets */ |
| 227 | static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { |
| 228 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 229 | SND_SOC_DAPM_MIC("Mic Jack", corgi_mic_event), |
| 230 | SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event), |
| 231 | SND_SOC_DAPM_LINE("Line Jack", NULL), |
| 232 | SND_SOC_DAPM_HP("Headset Jack", NULL), |
| 233 | }; |
| 234 | |
| 235 | /* Corgi machine audio map (connections to the codec pins) */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 236 | static const struct snd_soc_dapm_route audio_map[] = { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 237 | |
| 238 | /* headset Jack - in = micin, out = LHPOUT*/ |
| 239 | {"Headset Jack", NULL, "LHPOUT"}, |
| 240 | |
| 241 | /* headphone connected to LHPOUT1, RHPOUT1 */ |
| 242 | {"Headphone Jack", NULL, "LHPOUT"}, |
| 243 | {"Headphone Jack", NULL, "RHPOUT"}, |
| 244 | |
| 245 | /* speaker connected to LOUT, ROUT */ |
| 246 | {"Ext Spk", NULL, "ROUT"}, |
| 247 | {"Ext Spk", NULL, "LOUT"}, |
| 248 | |
| 249 | /* mic is connected to MICIN (via right channel of headphone jack) */ |
| 250 | {"MICIN", NULL, "Mic Jack"}, |
| 251 | |
| 252 | /* Same as the above but no mic bias for line signals */ |
| 253 | {"MICIN", NULL, "Line Jack"}, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 254 | }; |
| 255 | |
| 256 | static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", |
| 257 | "Off"}; |
| 258 | static const char *spk_function[] = {"On", "Off"}; |
| 259 | static const struct soc_enum corgi_enum[] = { |
| 260 | SOC_ENUM_SINGLE_EXT(5, jack_function), |
| 261 | SOC_ENUM_SINGLE_EXT(2, spk_function), |
| 262 | }; |
| 263 | |
| 264 | static const struct snd_kcontrol_new wm8731_corgi_controls[] = { |
| 265 | SOC_ENUM_EXT("Jack Function", corgi_enum[0], corgi_get_jack, |
| 266 | corgi_set_jack), |
| 267 | SOC_ENUM_EXT("Speaker Function", corgi_enum[1], corgi_get_spk, |
| 268 | corgi_set_spk), |
| 269 | }; |
| 270 | |
| 271 | /* |
| 272 | * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device |
| 273 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 274 | static int corgi_wm8731_init(struct snd_soc_pcm_runtime *rtd) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 275 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 276 | struct snd_soc_codec *codec = rtd->codec; |
Philipp Zabel | eb5f6d75 | 2009-03-12 11:07:54 +0100 | [diff] [blame] | 277 | int err; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 278 | |
Mark Brown | 35f5e54 | 2008-09-27 10:45:09 +0100 | [diff] [blame] | 279 | snd_soc_dapm_nc_pin(codec, "LLINEIN"); |
| 280 | snd_soc_dapm_nc_pin(codec, "RLINEIN"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 281 | |
| 282 | /* Add corgi specific controls */ |
Philipp Zabel | eb5f6d75 | 2009-03-12 11:07:54 +0100 | [diff] [blame] | 283 | err = snd_soc_add_controls(codec, wm8731_corgi_controls, |
| 284 | ARRAY_SIZE(wm8731_corgi_controls)); |
| 285 | if (err < 0) |
| 286 | return err; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 287 | |
| 288 | /* Add corgi specific widgets */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 289 | snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, |
| 290 | ARRAY_SIZE(wm8731_dapm_widgets)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 291 | |
| 292 | /* Set up corgi specific audio path audio_map */ |
Mark Brown | 25191c4 | 2008-05-13 14:55:48 +0200 | [diff] [blame] | 293 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 294 | |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 295 | snd_soc_dapm_sync(codec); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 296 | return 0; |
| 297 | } |
| 298 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 299 | /* corgi digital audio interface glue - connects codec <--> CPU */ |
| 300 | static struct snd_soc_dai_link corgi_dai = { |
| 301 | .name = "WM8731", |
| 302 | .stream_name = "WM8731", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 303 | .cpu_dai_name = "pxa-is2-dai", |
| 304 | .codec_dai_name = "wm8731-hifi", |
| 305 | .platform_name = "pxa-pcm-audio", |
| 306 | .codec_name = "wm8731-codec-0.001a", |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 307 | .init = corgi_wm8731_init, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 308 | .ops = &corgi_ops, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 309 | }; |
| 310 | |
| 311 | /* corgi audio machine driver */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 312 | static struct snd_soc_card snd_soc_corgi = { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 313 | .name = "Corgi", |
| 314 | .dai_link = &corgi_dai, |
| 315 | .num_links = 1, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 316 | }; |
| 317 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 318 | static struct platform_device *corgi_snd_device; |
| 319 | |
| 320 | static int __init corgi_init(void) |
| 321 | { |
| 322 | int ret; |
| 323 | |
Mark Brown | 1bfcd36 | 2008-04-23 15:12:19 +0200 | [diff] [blame] | 324 | if (!(machine_is_corgi() || machine_is_shepherd() || |
| 325 | machine_is_husky())) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 326 | return -ENODEV; |
| 327 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 328 | corgi_snd_device = platform_device_alloc("soc-audio", -1); |
| 329 | if (!corgi_snd_device) |
| 330 | return -ENOMEM; |
| 331 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 332 | platform_set_drvdata(corgi_snd_device, &snd_soc_corgi); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 333 | ret = platform_device_add(corgi_snd_device); |
| 334 | |
| 335 | if (ret) |
| 336 | platform_device_put(corgi_snd_device); |
| 337 | |
| 338 | return ret; |
| 339 | } |
| 340 | |
| 341 | static void __exit corgi_exit(void) |
| 342 | { |
| 343 | platform_device_unregister(corgi_snd_device); |
| 344 | } |
| 345 | |
| 346 | module_init(corgi_init); |
| 347 | module_exit(corgi_exit); |
| 348 | |
| 349 | /* Module information */ |
| 350 | MODULE_AUTHOR("Richard Purdie"); |
| 351 | MODULE_DESCRIPTION("ALSA SoC Corgi"); |
| 352 | MODULE_LICENSE("GPL"); |