Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 1 | /* |
| 2 | * mfld_machine.c - ASoc Machine driver for Intel Medfield MID platform |
| 3 | * |
| 4 | * Copyright (C) 2010 Intel Corp |
| 5 | * Author: Vinod Koul <vinod.koul@intel.com> |
| 6 | * Author: Harsha Priya <priya.harsha@intel.com> |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; version 2 of the License. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 21 | * |
| 22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 23 | */ |
| 24 | |
| 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 26 | |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/device.h> |
| 29 | #include <linux/slab.h> |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 30 | #include <linux/io.h> |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 31 | #include <sound/pcm.h> |
| 32 | #include <sound/pcm_params.h> |
| 33 | #include <sound/soc.h> |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 34 | #include <sound/jack.h> |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 35 | #include "../codecs/sn95031.h" |
| 36 | |
| 37 | #define MID_MONO 1 |
| 38 | #define MID_STEREO 2 |
| 39 | #define MID_MAX_CAP 5 |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 40 | #define MFLD_JACK_INSERT 0x04 |
| 41 | |
| 42 | enum soc_mic_bias_zones { |
| 43 | MFLD_MV_START = 0, |
| 44 | /* mic bias volutage range for Headphones*/ |
| 45 | MFLD_MV_HP = 400, |
| 46 | /* mic bias volutage range for American Headset*/ |
| 47 | MFLD_MV_AM_HS = 650, |
| 48 | /* mic bias volutage range for Headset*/ |
| 49 | MFLD_MV_HS = 2000, |
| 50 | MFLD_MV_UNDEFINED, |
| 51 | }; |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 52 | |
| 53 | static unsigned int hs_switch; |
| 54 | static unsigned int lo_dac; |
| 55 | |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 56 | struct mfld_mc_private { |
| 57 | struct platform_device *socdev; |
| 58 | void __iomem *int_base; |
| 59 | struct snd_soc_codec *codec; |
| 60 | u8 interrupt_status; |
| 61 | }; |
| 62 | |
| 63 | struct snd_soc_jack mfld_jack; |
| 64 | |
| 65 | /*Headset jack detection DAPM pins */ |
| 66 | static struct snd_soc_jack_pin mfld_jack_pins[] = { |
| 67 | { |
| 68 | .pin = "Headphones", |
| 69 | .mask = SND_JACK_HEADPHONE, |
| 70 | }, |
| 71 | { |
| 72 | .pin = "AMIC1", |
| 73 | .mask = SND_JACK_MICROPHONE, |
| 74 | }, |
| 75 | }; |
| 76 | |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 77 | /* sound card controls */ |
| 78 | static const char *headset_switch_text[] = {"Earpiece", "Headset"}; |
| 79 | |
| 80 | static const char *lo_text[] = {"Vibra", "Headset", "IHF", "None"}; |
| 81 | |
| 82 | static const struct soc_enum headset_enum = |
| 83 | SOC_ENUM_SINGLE_EXT(2, headset_switch_text); |
| 84 | |
| 85 | static const struct soc_enum lo_enum = |
| 86 | SOC_ENUM_SINGLE_EXT(4, lo_text); |
| 87 | |
| 88 | static int headset_get_switch(struct snd_kcontrol *kcontrol, |
| 89 | struct snd_ctl_elem_value *ucontrol) |
| 90 | { |
| 91 | ucontrol->value.integer.value[0] = hs_switch; |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | static int headset_set_switch(struct snd_kcontrol *kcontrol, |
| 96 | struct snd_ctl_elem_value *ucontrol) |
| 97 | { |
| 98 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 99 | |
| 100 | if (ucontrol->value.integer.value[0] == hs_switch) |
| 101 | return 0; |
| 102 | |
| 103 | if (ucontrol->value.integer.value[0]) { |
| 104 | pr_debug("hs_set HS path\n"); |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 105 | snd_soc_dapm_enable_pin(&codec->dapm, "Headphones"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 106 | snd_soc_dapm_disable_pin(&codec->dapm, "EPOUT"); |
| 107 | } else { |
| 108 | pr_debug("hs_set EP path\n"); |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 109 | snd_soc_dapm_disable_pin(&codec->dapm, "Headphones"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 110 | snd_soc_dapm_enable_pin(&codec->dapm, "EPOUT"); |
| 111 | } |
| 112 | snd_soc_dapm_sync(&codec->dapm); |
| 113 | hs_switch = ucontrol->value.integer.value[0]; |
| 114 | |
| 115 | return 0; |
| 116 | } |
| 117 | |
| 118 | static void lo_enable_out_pins(struct snd_soc_codec *codec) |
| 119 | { |
| 120 | snd_soc_dapm_enable_pin(&codec->dapm, "IHFOUTL"); |
| 121 | snd_soc_dapm_enable_pin(&codec->dapm, "IHFOUTR"); |
| 122 | snd_soc_dapm_enable_pin(&codec->dapm, "LINEOUTL"); |
| 123 | snd_soc_dapm_enable_pin(&codec->dapm, "LINEOUTR"); |
| 124 | snd_soc_dapm_enable_pin(&codec->dapm, "VIB1OUT"); |
| 125 | snd_soc_dapm_enable_pin(&codec->dapm, "VIB2OUT"); |
| 126 | if (hs_switch) { |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 127 | snd_soc_dapm_enable_pin(&codec->dapm, "Headphones"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 128 | snd_soc_dapm_disable_pin(&codec->dapm, "EPOUT"); |
| 129 | } else { |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 130 | snd_soc_dapm_disable_pin(&codec->dapm, "Headphones"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 131 | snd_soc_dapm_enable_pin(&codec->dapm, "EPOUT"); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | static int lo_get_switch(struct snd_kcontrol *kcontrol, |
| 136 | struct snd_ctl_elem_value *ucontrol) |
| 137 | { |
| 138 | ucontrol->value.integer.value[0] = lo_dac; |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static int lo_set_switch(struct snd_kcontrol *kcontrol, |
| 143 | struct snd_ctl_elem_value *ucontrol) |
| 144 | { |
| 145 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 146 | |
| 147 | if (ucontrol->value.integer.value[0] == lo_dac) |
| 148 | return 0; |
| 149 | |
| 150 | /* we dont want to work with last state of lineout so just enable all |
| 151 | * pins and then disable pins not required |
| 152 | */ |
| 153 | lo_enable_out_pins(codec); |
| 154 | switch (ucontrol->value.integer.value[0]) { |
| 155 | case 0: |
| 156 | pr_debug("set vibra path\n"); |
| 157 | snd_soc_dapm_disable_pin(&codec->dapm, "VIB1OUT"); |
| 158 | snd_soc_dapm_disable_pin(&codec->dapm, "VIB2OUT"); |
| 159 | snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0); |
| 160 | break; |
| 161 | |
| 162 | case 1: |
| 163 | pr_debug("set hs path\n"); |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 164 | snd_soc_dapm_disable_pin(&codec->dapm, "Headphones"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 165 | snd_soc_dapm_disable_pin(&codec->dapm, "EPOUT"); |
| 166 | snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22); |
| 167 | break; |
| 168 | |
| 169 | case 2: |
| 170 | pr_debug("set spkr path\n"); |
| 171 | snd_soc_dapm_disable_pin(&codec->dapm, "IHFOUTL"); |
| 172 | snd_soc_dapm_disable_pin(&codec->dapm, "IHFOUTR"); |
| 173 | snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44); |
| 174 | break; |
| 175 | |
| 176 | case 3: |
| 177 | pr_debug("set null path\n"); |
| 178 | snd_soc_dapm_disable_pin(&codec->dapm, "LINEOUTL"); |
| 179 | snd_soc_dapm_disable_pin(&codec->dapm, "LINEOUTR"); |
| 180 | snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66); |
| 181 | break; |
| 182 | } |
| 183 | snd_soc_dapm_sync(&codec->dapm); |
| 184 | lo_dac = ucontrol->value.integer.value[0]; |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | static const struct snd_kcontrol_new mfld_snd_controls[] = { |
| 189 | SOC_ENUM_EXT("Playback Switch", headset_enum, |
| 190 | headset_get_switch, headset_set_switch), |
| 191 | SOC_ENUM_EXT("Lineout Mux", lo_enum, |
| 192 | lo_get_switch, lo_set_switch), |
| 193 | }; |
| 194 | |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 195 | static const struct snd_soc_dapm_widget mfld_widgets[] = { |
| 196 | SND_SOC_DAPM_HP("Headphones", NULL), |
| 197 | SND_SOC_DAPM_MIC("Mic", NULL), |
| 198 | }; |
| 199 | |
| 200 | static const struct snd_soc_dapm_route mfld_map[] = { |
| 201 | {"Headphones", NULL, "HPOUTR"}, |
| 202 | {"Headphones", NULL, "HPOUTL"}, |
| 203 | {"Mic", NULL, "AMIC1"}, |
| 204 | }; |
| 205 | |
| 206 | static void mfld_jack_check(unsigned int intr_status) |
| 207 | { |
| 208 | struct mfld_jack_data jack_data; |
| 209 | |
| 210 | jack_data.mfld_jack = &mfld_jack; |
| 211 | jack_data.intr_id = intr_status; |
| 212 | |
| 213 | sn95031_jack_detection(&jack_data); |
| 214 | /* TODO: add american headset detection post gpiolib support */ |
| 215 | } |
| 216 | |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 217 | static int mfld_init(struct snd_soc_pcm_runtime *runtime) |
| 218 | { |
| 219 | struct snd_soc_codec *codec = runtime->codec; |
| 220 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 221 | int ret_val; |
| 222 | |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 223 | /* Add jack sense widgets */ |
| 224 | snd_soc_dapm_new_controls(dapm, mfld_widgets, ARRAY_SIZE(mfld_widgets)); |
| 225 | |
| 226 | /* Set up the map */ |
| 227 | snd_soc_dapm_add_routes(dapm, mfld_map, ARRAY_SIZE(mfld_map)); |
| 228 | |
| 229 | /* always connected */ |
| 230 | snd_soc_dapm_enable_pin(dapm, "Headphones"); |
| 231 | snd_soc_dapm_enable_pin(dapm, "Mic"); |
| 232 | snd_soc_dapm_sync(dapm); |
| 233 | |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 234 | ret_val = snd_soc_add_controls(codec, mfld_snd_controls, |
| 235 | ARRAY_SIZE(mfld_snd_controls)); |
| 236 | if (ret_val) { |
| 237 | pr_err("soc_add_controls failed %d", ret_val); |
| 238 | return ret_val; |
| 239 | } |
| 240 | /* default is earpiece pin, userspace sets it explcitly */ |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 241 | snd_soc_dapm_disable_pin(dapm, "Headphones"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 242 | /* default is lineout NC, userspace sets it explcitly */ |
| 243 | snd_soc_dapm_disable_pin(dapm, "LINEOUTL"); |
| 244 | snd_soc_dapm_disable_pin(dapm, "LINEOUTR"); |
| 245 | lo_dac = 3; |
| 246 | hs_switch = 0; |
Harsha Priya | d316553 | 2011-01-28 22:28:32 +0530 | [diff] [blame] | 247 | /* we dont use linein in this so set to NC */ |
| 248 | snd_soc_dapm_disable_pin(dapm, "LINEINL"); |
| 249 | snd_soc_dapm_disable_pin(dapm, "LINEINR"); |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 250 | snd_soc_dapm_sync(dapm); |
| 251 | |
| 252 | /* Headset and button jack detection */ |
| 253 | ret_val = snd_soc_jack_new(codec, "Intel(R) MID Audio Jack", |
| 254 | SND_JACK_HEADSET | SND_JACK_BTN_0 | |
| 255 | SND_JACK_BTN_1, &mfld_jack); |
| 256 | if (ret_val) { |
| 257 | pr_err("jack creation failed\n"); |
| 258 | return ret_val; |
| 259 | } |
| 260 | |
| 261 | ret_val = snd_soc_jack_add_pins(&mfld_jack, |
| 262 | ARRAY_SIZE(mfld_jack_pins), mfld_jack_pins); |
| 263 | if (ret_val) { |
| 264 | pr_err("adding jack pins failed\n"); |
| 265 | return ret_val; |
| 266 | } |
| 267 | |
| 268 | /* we want to check if anything is inserted at boot, |
| 269 | * so send a fake event to codec and it will read adc |
| 270 | * to find if anything is there or not */ |
| 271 | mfld_jack_check(MFLD_JACK_INSERT); |
| 272 | return ret_val; |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | struct snd_soc_dai_link mfld_msic_dailink[] = { |
| 276 | { |
| 277 | .name = "Medfield Headset", |
| 278 | .stream_name = "Headset", |
| 279 | .cpu_dai_name = "Headset-cpu-dai", |
| 280 | .codec_dai_name = "SN95031 Headset", |
| 281 | .codec_name = "sn95031", |
| 282 | .platform_name = "sst-platform", |
| 283 | .init = mfld_init, |
| 284 | }, |
| 285 | { |
| 286 | .name = "Medfield Speaker", |
| 287 | .stream_name = "Speaker", |
| 288 | .cpu_dai_name = "Speaker-cpu-dai", |
| 289 | .codec_dai_name = "SN95031 Speaker", |
| 290 | .codec_name = "sn95031", |
| 291 | .platform_name = "sst-platform", |
| 292 | .init = NULL, |
| 293 | }, |
| 294 | { |
| 295 | .name = "Medfield Vibra", |
| 296 | .stream_name = "Vibra1", |
| 297 | .cpu_dai_name = "Vibra1-cpu-dai", |
| 298 | .codec_dai_name = "SN95031 Vibra1", |
| 299 | .codec_name = "sn95031", |
| 300 | .platform_name = "sst-platform", |
| 301 | .init = NULL, |
| 302 | }, |
| 303 | { |
| 304 | .name = "Medfield Haptics", |
| 305 | .stream_name = "Vibra2", |
| 306 | .cpu_dai_name = "Vibra2-cpu-dai", |
| 307 | .codec_dai_name = "SN95031 Vibra2", |
| 308 | .codec_name = "sn95031", |
| 309 | .platform_name = "sst-platform", |
| 310 | .init = NULL, |
| 311 | }, |
| 312 | }; |
| 313 | |
| 314 | /* SoC card */ |
| 315 | static struct snd_soc_card snd_soc_card_mfld = { |
| 316 | .name = "medfield_audio", |
| 317 | .dai_link = mfld_msic_dailink, |
| 318 | .num_links = ARRAY_SIZE(mfld_msic_dailink), |
| 319 | }; |
| 320 | |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 321 | static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev) |
| 322 | { |
| 323 | struct mfld_mc_private *mc_private = (struct mfld_mc_private *) dev; |
| 324 | |
| 325 | memcpy_fromio(&mc_private->interrupt_status, |
| 326 | ((void *)(mc_private->int_base)), |
| 327 | sizeof(u8)); |
| 328 | return IRQ_WAKE_THREAD; |
| 329 | } |
| 330 | |
| 331 | static irqreturn_t snd_mfld_jack_detection(int irq, void *data) |
| 332 | { |
| 333 | struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data; |
| 334 | |
| 335 | if (mfld_jack.codec == NULL) |
| 336 | return IRQ_HANDLED; |
| 337 | mfld_jack_check(mc_drv_ctx->interrupt_status); |
| 338 | |
| 339 | return IRQ_HANDLED; |
| 340 | } |
| 341 | |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 342 | static int __devinit snd_mfld_mc_probe(struct platform_device *pdev) |
| 343 | { |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 344 | int ret_val = 0, irq; |
| 345 | struct mfld_mc_private *mc_drv_ctx; |
| 346 | struct resource *irq_mem; |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 347 | |
| 348 | pr_debug("snd_mfld_mc_probe called\n"); |
| 349 | |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 350 | /* retrive the irq number */ |
| 351 | irq = platform_get_irq(pdev, 0); |
| 352 | |
| 353 | /* audio interrupt base of SRAM location where |
| 354 | * interrupts are stored by System FW */ |
| 355 | mc_drv_ctx = kzalloc(sizeof(*mc_drv_ctx), GFP_ATOMIC); |
| 356 | if (!mc_drv_ctx) { |
| 357 | pr_err("allocation failed\n"); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 358 | return -ENOMEM; |
| 359 | } |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 360 | |
| 361 | irq_mem = platform_get_resource_byname( |
| 362 | pdev, IORESOURCE_MEM, "IRQ_BASE"); |
| 363 | if (!irq_mem) { |
| 364 | pr_err("no mem resource given\n"); |
| 365 | ret_val = -ENODEV; |
| 366 | goto unalloc; |
| 367 | } |
| 368 | mc_drv_ctx->int_base = ioremap_nocache(irq_mem->start, |
| 369 | resource_size(irq_mem)); |
| 370 | if (!mc_drv_ctx->int_base) { |
| 371 | pr_err("Mapping of cache failed\n"); |
| 372 | ret_val = -ENOMEM; |
| 373 | goto unalloc; |
| 374 | } |
| 375 | /* register for interrupt */ |
| 376 | ret_val = request_threaded_irq(irq, snd_mfld_jack_intr_handler, |
| 377 | snd_mfld_jack_detection, |
| 378 | IRQF_SHARED, pdev->dev.driver->name, mc_drv_ctx); |
| 379 | if (ret_val) { |
| 380 | pr_err("cannot register IRQ\n"); |
| 381 | goto unalloc; |
| 382 | } |
| 383 | /* create soc device */ |
| 384 | mc_drv_ctx->socdev = platform_device_alloc("soc-audio", -1); |
| 385 | if (!mc_drv_ctx->socdev) { |
| 386 | pr_err("soc-audio device allocation failed\n"); |
| 387 | ret_val = -ENOMEM; |
| 388 | goto freeirq; |
| 389 | } |
| 390 | platform_set_drvdata(mc_drv_ctx->socdev, &snd_soc_card_mfld); |
| 391 | ret_val = platform_device_add(mc_drv_ctx->socdev); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 392 | if (ret_val) { |
| 393 | pr_err("Unable to add soc-audio device, err %d\n", ret_val); |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 394 | goto unregister; |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 395 | } |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 396 | platform_set_drvdata(pdev, mc_drv_ctx); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 397 | pr_debug("successfully exited probe\n"); |
| 398 | return ret_val; |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 399 | |
| 400 | unregister: |
| 401 | platform_device_put(mc_drv_ctx->socdev); |
| 402 | freeirq: |
| 403 | free_irq(irq, mc_drv_ctx); |
| 404 | unalloc: |
| 405 | kfree(mc_drv_ctx); |
| 406 | return ret_val; |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | static int __devexit snd_mfld_mc_remove(struct platform_device *pdev) |
| 410 | { |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 411 | struct mfld_mc_private *mc_drv_ctx = platform_get_drvdata(pdev); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 412 | |
Vinod Koul | 42aee9b | 2011-02-09 21:44:33 +0530 | [diff] [blame^] | 413 | pr_debug("snd_mfld_mc_remove called\n"); |
| 414 | free_irq(platform_get_irq(pdev, 0), mc_drv_ctx); |
| 415 | platform_device_unregister(mc_drv_ctx->socdev); |
| 416 | kfree(mc_drv_ctx); |
Vinod Koul | 55c7203 | 2011-01-04 20:16:50 +0530 | [diff] [blame] | 417 | platform_set_drvdata(pdev, NULL); |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | static struct platform_driver snd_mfld_mc_driver = { |
| 422 | .driver = { |
| 423 | .owner = THIS_MODULE, |
| 424 | .name = "msic_audio", |
| 425 | }, |
| 426 | .probe = snd_mfld_mc_probe, |
| 427 | .remove = __devexit_p(snd_mfld_mc_remove), |
| 428 | }; |
| 429 | |
| 430 | static int __init snd_mfld_driver_init(void) |
| 431 | { |
| 432 | pr_debug("snd_mfld_driver_init called\n"); |
| 433 | return platform_driver_register(&snd_mfld_mc_driver); |
| 434 | } |
| 435 | module_init(snd_mfld_driver_init); |
| 436 | |
| 437 | static void __exit snd_mfld_driver_exit(void) |
| 438 | { |
| 439 | pr_debug("snd_mfld_driver_exit called\n"); |
| 440 | platform_driver_unregister(&snd_mfld_mc_driver); |
| 441 | } |
| 442 | module_exit(snd_mfld_driver_exit); |
| 443 | |
| 444 | MODULE_DESCRIPTION("ASoC Intel(R) MID Machine driver"); |
| 445 | MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>"); |
| 446 | MODULE_AUTHOR("Harsha Priya <priya.harsha@intel.com>"); |
| 447 | MODULE_LICENSE("GPL v2"); |
| 448 | MODULE_ALIAS("platform:msic-audio"); |