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> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +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/corgi.h> |
| 29 | #include <mach/audio.h> |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 30 | |
| 31 | #include "../codecs/wm8731.h" |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 32 | #include "pxa2xx-i2s.h" |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 33 | |
| 34 | #define CORGI_HP 0 |
| 35 | #define CORGI_MIC 1 |
| 36 | #define CORGI_LINE 2 |
| 37 | #define CORGI_HEADSET 3 |
| 38 | #define CORGI_HP_OFF 4 |
| 39 | #define CORGI_SPK_ON 0 |
| 40 | #define CORGI_SPK_OFF 1 |
| 41 | |
| 42 | /* audio clock in Hz - rounded from 12.235MHz */ |
| 43 | #define CORGI_AUDIO_CLOCK 12288000 |
| 44 | |
| 45 | static int corgi_jack_func; |
| 46 | static int corgi_spk_func; |
| 47 | |
| 48 | static void corgi_ext_control(struct snd_soc_codec *codec) |
| 49 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 50 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 51 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 52 | /* set up jack connection */ |
| 53 | switch (corgi_jack_func) { |
| 54 | case CORGI_HP: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 55 | /* set = unmute headphone */ |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 56 | gpio_set_value(CORGI_GPIO_MUTE_L, 1); |
| 57 | gpio_set_value(CORGI_GPIO_MUTE_R, 1); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 58 | snd_soc_dapm_disable_pin(dapm, "Mic Jack"); |
| 59 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
| 60 | snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); |
| 61 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 62 | break; |
| 63 | case CORGI_MIC: |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 64 | /* reset = mute headphone */ |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 65 | gpio_set_value(CORGI_GPIO_MUTE_L, 0); |
| 66 | gpio_set_value(CORGI_GPIO_MUTE_R, 0); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 67 | snd_soc_dapm_enable_pin(dapm, "Mic Jack"); |
| 68 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
| 69 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 70 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 71 | break; |
| 72 | case CORGI_LINE: |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 73 | gpio_set_value(CORGI_GPIO_MUTE_L, 0); |
| 74 | gpio_set_value(CORGI_GPIO_MUTE_R, 0); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 75 | snd_soc_dapm_disable_pin(dapm, "Mic Jack"); |
| 76 | snd_soc_dapm_enable_pin(dapm, "Line Jack"); |
| 77 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 78 | snd_soc_dapm_disable_pin(dapm, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 79 | break; |
| 80 | case CORGI_HEADSET: |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 81 | gpio_set_value(CORGI_GPIO_MUTE_L, 0); |
| 82 | gpio_set_value(CORGI_GPIO_MUTE_R, 1); |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 83 | snd_soc_dapm_enable_pin(dapm, "Mic Jack"); |
| 84 | snd_soc_dapm_disable_pin(dapm, "Line Jack"); |
| 85 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
| 86 | snd_soc_dapm_enable_pin(dapm, "Headset Jack"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 87 | break; |
| 88 | } |
| 89 | |
| 90 | if (corgi_spk_func == CORGI_SPK_ON) |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 91 | snd_soc_dapm_enable_pin(dapm, "Ext Spk"); |
Liam Girdwood | a530218 | 2008-07-07 13:35:17 +0100 | [diff] [blame] | 92 | else |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 93 | snd_soc_dapm_disable_pin(dapm, "Ext Spk"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 94 | |
| 95 | /* signal a DAPM event */ |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 96 | snd_soc_dapm_sync(dapm); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static int corgi_startup(struct snd_pcm_substream *substream) |
| 100 | { |
| 101 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 102 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 103 | |
Mark Brown | 71a2956 | 2010-11-05 13:50:48 -0400 | [diff] [blame] | 104 | mutex_lock(&codec->mutex); |
| 105 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 106 | /* check the jack status at stream startup */ |
| 107 | corgi_ext_control(codec); |
Mark Brown | 71a2956 | 2010-11-05 13:50:48 -0400 | [diff] [blame] | 108 | |
| 109 | mutex_unlock(&codec->mutex); |
| 110 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | /* 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] | 115 | static void corgi_shutdown(struct snd_pcm_substream *substream) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 116 | { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 117 | /* set = unmute headphone */ |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 118 | gpio_set_value(CORGI_GPIO_MUTE_L, 1); |
| 119 | gpio_set_value(CORGI_GPIO_MUTE_R, 1); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 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 | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 126 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 127 | struct snd_soc_dai *cpu_dai = rtd->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 | |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 145 | /* set the codec system clock for DAC and ADC */ |
Mark Brown | 9745e82 | 2010-08-17 23:40:24 +0100 | [diff] [blame] | 146 | ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, clk, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 147 | SND_SOC_CLOCK_IN); |
| 148 | if (ret < 0) |
| 149 | return ret; |
| 150 | |
| 151 | /* set the I2S system clock as input (unused) */ |
Liam Girdwood | 64105cf | 2008-07-08 13:19:18 +0100 | [diff] [blame] | 152 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0, |
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 | return 0; |
| 158 | } |
| 159 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 160 | static struct snd_soc_ops corgi_ops = { |
| 161 | .startup = corgi_startup, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 162 | .hw_params = corgi_hw_params, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 163 | .shutdown = corgi_shutdown, |
| 164 | }; |
| 165 | |
| 166 | static int corgi_get_jack(struct snd_kcontrol *kcontrol, |
| 167 | struct snd_ctl_elem_value *ucontrol) |
| 168 | { |
| 169 | ucontrol->value.integer.value[0] = corgi_jack_func; |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | static int corgi_set_jack(struct snd_kcontrol *kcontrol, |
| 174 | struct snd_ctl_elem_value *ucontrol) |
| 175 | { |
| 176 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 177 | |
| 178 | if (corgi_jack_func == ucontrol->value.integer.value[0]) |
| 179 | return 0; |
| 180 | |
| 181 | corgi_jack_func = ucontrol->value.integer.value[0]; |
| 182 | corgi_ext_control(codec); |
| 183 | return 1; |
| 184 | } |
| 185 | |
| 186 | static int corgi_get_spk(struct snd_kcontrol *kcontrol, |
| 187 | struct snd_ctl_elem_value *ucontrol) |
| 188 | { |
| 189 | ucontrol->value.integer.value[0] = corgi_spk_func; |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | static int corgi_set_spk(struct snd_kcontrol *kcontrol, |
| 194 | struct snd_ctl_elem_value *ucontrol) |
| 195 | { |
| 196 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 197 | |
| 198 | if (corgi_spk_func == ucontrol->value.integer.value[0]) |
| 199 | return 0; |
| 200 | |
| 201 | corgi_spk_func = ucontrol->value.integer.value[0]; |
| 202 | corgi_ext_control(codec); |
| 203 | return 1; |
| 204 | } |
| 205 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 206 | static int corgi_amp_event(struct snd_soc_dapm_widget *w, |
| 207 | struct snd_kcontrol *k, int event) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 208 | { |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 209 | 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] | 210 | return 0; |
| 211 | } |
| 212 | |
Jarkko Nikula | 338c7ed | 2008-02-28 12:34:48 +0100 | [diff] [blame] | 213 | static int corgi_mic_event(struct snd_soc_dapm_widget *w, |
| 214 | struct snd_kcontrol *k, int event) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 215 | { |
Eric Miao | 6168cda | 2008-09-05 18:15:22 +0800 | [diff] [blame] | 216 | 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] | 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | /* corgi machine dapm widgets */ |
| 221 | static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { |
| 222 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 223 | SND_SOC_DAPM_MIC("Mic Jack", corgi_mic_event), |
| 224 | SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event), |
| 225 | SND_SOC_DAPM_LINE("Line Jack", NULL), |
| 226 | SND_SOC_DAPM_HP("Headset Jack", NULL), |
| 227 | }; |
| 228 | |
| 229 | /* Corgi machine audio map (connections to the codec pins) */ |
Axel Lin | 32696af | 2011-12-30 11:16:32 +0800 | [diff] [blame] | 230 | static const struct snd_soc_dapm_route corgi_audio_map[] = { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 231 | |
| 232 | /* headset Jack - in = micin, out = LHPOUT*/ |
| 233 | {"Headset Jack", NULL, "LHPOUT"}, |
| 234 | |
| 235 | /* headphone connected to LHPOUT1, RHPOUT1 */ |
| 236 | {"Headphone Jack", NULL, "LHPOUT"}, |
| 237 | {"Headphone Jack", NULL, "RHPOUT"}, |
| 238 | |
| 239 | /* speaker connected to LOUT, ROUT */ |
| 240 | {"Ext Spk", NULL, "ROUT"}, |
| 241 | {"Ext Spk", NULL, "LOUT"}, |
| 242 | |
| 243 | /* mic is connected to MICIN (via right channel of headphone jack) */ |
| 244 | {"MICIN", NULL, "Mic Jack"}, |
| 245 | |
| 246 | /* Same as the above but no mic bias for line signals */ |
| 247 | {"MICIN", NULL, "Line Jack"}, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset", |
| 251 | "Off"}; |
| 252 | static const char *spk_function[] = {"On", "Off"}; |
| 253 | static const struct soc_enum corgi_enum[] = { |
| 254 | SOC_ENUM_SINGLE_EXT(5, jack_function), |
| 255 | SOC_ENUM_SINGLE_EXT(2, spk_function), |
| 256 | }; |
| 257 | |
| 258 | static const struct snd_kcontrol_new wm8731_corgi_controls[] = { |
| 259 | SOC_ENUM_EXT("Jack Function", corgi_enum[0], corgi_get_jack, |
| 260 | corgi_set_jack), |
| 261 | SOC_ENUM_EXT("Speaker Function", corgi_enum[1], corgi_get_spk, |
| 262 | corgi_set_spk), |
| 263 | }; |
| 264 | |
| 265 | /* |
| 266 | * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device |
| 267 | */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 268 | static int corgi_wm8731_init(struct snd_soc_pcm_runtime *rtd) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 269 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 270 | struct snd_soc_codec *codec = rtd->codec; |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 271 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 272 | |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 273 | snd_soc_dapm_nc_pin(dapm, "LLINEIN"); |
| 274 | snd_soc_dapm_nc_pin(dapm, "RLINEIN"); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 275 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 276 | return 0; |
| 277 | } |
| 278 | |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 279 | /* corgi digital audio interface glue - connects codec <--> CPU */ |
| 280 | static struct snd_soc_dai_link corgi_dai = { |
| 281 | .name = "WM8731", |
| 282 | .stream_name = "WM8731", |
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 = "wm8731-hifi", |
| 285 | .platform_name = "pxa-pcm-audio", |
Mark Brown | 99b59f3 | 2011-03-27 14:35:15 +0100 | [diff] [blame] | 286 | .codec_name = "wm8731.0-001b", |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 287 | .init = corgi_wm8731_init, |
Axel Lin | 74f4dd5 | 2011-12-30 11:13:24 +0800 | [diff] [blame] | 288 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 289 | SND_SOC_DAIFMT_CBS_CFS, |
Liam Girdwood | d928b25 | 2007-02-02 17:22:20 +0100 | [diff] [blame] | 290 | .ops = &corgi_ops, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | /* corgi audio machine driver */ |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 294 | static struct snd_soc_card corgi = { |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 295 | .name = "Corgi", |
Axel Lin | 561c6a1 | 2011-12-22 09:44:43 +0800 | [diff] [blame] | 296 | .owner = THIS_MODULE, |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 297 | .dai_link = &corgi_dai, |
| 298 | .num_links = 1, |
Axel Lin | 32696af | 2011-12-30 11:16:32 +0800 | [diff] [blame] | 299 | |
| 300 | .controls = wm8731_corgi_controls, |
| 301 | .num_controls = ARRAY_SIZE(wm8731_corgi_controls), |
| 302 | .dapm_widgets = wm8731_dapm_widgets, |
| 303 | .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), |
| 304 | .dapm_routes = corgi_audio_map, |
| 305 | .num_dapm_routes = ARRAY_SIZE(corgi_audio_map), |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 306 | }; |
| 307 | |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 308 | static int __devinit corgi_probe(struct platform_device *pdev) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 309 | { |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 310 | struct snd_soc_card *card = &corgi; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 311 | int ret; |
| 312 | |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 313 | card->dev = &pdev->dev; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 314 | |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 315 | ret = snd_soc_register_card(card); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 316 | if (ret) |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 317 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
| 318 | ret); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 319 | return ret; |
| 320 | } |
| 321 | |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 322 | static int __devexit corgi_remove(struct platform_device *pdev) |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 323 | { |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 324 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 325 | |
| 326 | snd_soc_unregister_card(card); |
| 327 | return 0; |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 328 | } |
| 329 | |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 330 | static struct platform_driver corgi_driver = { |
| 331 | .driver = { |
| 332 | .name = "corgi-audio", |
| 333 | .owner = THIS_MODULE, |
| 334 | }, |
| 335 | .probe = corgi_probe, |
| 336 | .remove = __devexit_p(corgi_remove), |
| 337 | }; |
| 338 | |
| 339 | module_platform_driver(corgi_driver); |
Liam Girdwood | a1eb4b3 | 2006-10-12 14:31:16 +0200 | [diff] [blame] | 340 | |
| 341 | /* Module information */ |
| 342 | MODULE_AUTHOR("Richard Purdie"); |
| 343 | MODULE_DESCRIPTION("ALSA SoC Corgi"); |
| 344 | MODULE_LICENSE("GPL"); |
Axel Lin | 34be924 | 2011-12-30 11:18:13 +0800 | [diff] [blame^] | 345 | MODULE_ALIAS("platform:corgi-audio"); |