Revert "asoc: tegra: integration of slave mode support."
[linux-2.6.git] / sound / soc / tegra / tegra_max98088.c
1 /*
2  * tegra_max98088.c - Tegra machine ASoC driver for boards using MAX98088 codec.
3  *
4  * Author: Sumit Bhattacharya <sumitb@nvidia.com>
5  * Copyright (C) 2011 - NVIDIA, Inc.
6  *
7  * Based on code copyright/by:
8  *
9  * (c) 2010, 2011 Nvidia Graphics Pvt. Ltd.
10  *
11  * Copyright 2007 Wolfson Microelectronics PLC.
12  * Author: Graeme Gregory
13  *         graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27  * 02110-1301 USA
28  *
29  */
30
31 #include <asm/mach-types.h>
32
33 #include <linux/clk.h>
34 #include <linux/module.h>
35 #include <linux/platform_device.h>
36 #include <linux/slab.h>
37 #include <linux/gpio.h>
38 #include <linux/regulator/consumer.h>
39 #ifdef CONFIG_SWITCH
40 #include <linux/switch.h>
41 #endif
42
43 #include <mach/tegra_asoc_pdata.h>
44
45 #include <sound/core.h>
46 #include <sound/jack.h>
47 #include <sound/pcm.h>
48 #include <sound/pcm_params.h>
49 #include <sound/soc.h>
50
51 #include "../codecs/max98088.h"
52
53 #include "tegra_pcm.h"
54 #include "tegra_asoc_utils.h"
55 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
56 #include "tegra30_ahub.h"
57 #include "tegra30_i2s.h"
58 #include "tegra30_dam.h"
59 #endif
60
61 #define DRV_NAME "tegra-snd-max98088"
62
63 #define GPIO_SPKR_EN    BIT(0)
64 #define GPIO_HP_MUTE    BIT(1)
65 #define GPIO_INT_MIC_EN BIT(2)
66 #define GPIO_EXT_MIC_EN BIT(3)
67
68 #define DAI_LINK_HIFI           0
69 #define DAI_LINK_SPDIF          1
70 #define DAI_LINK_BTSCO          2
71 #define DAI_LINK_VOICE_CALL     3
72 #define DAI_LINK_BT_VOICE_CALL  4
73 #define NUM_DAI_LINKS   5
74
75 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
76 const char *tegra_max98088_i2s_dai_name[TEGRA30_NR_I2S_IFC] = {
77         "tegra30-i2s.0",
78         "tegra30-i2s.1",
79         "tegra30-i2s.2",
80         "tegra30-i2s.3",
81         "tegra30-i2s.4",
82 };
83 #endif
84
85 extern int g_is_call_mode;
86
87 struct tegra_max98088 {
88         struct tegra_asoc_utils_data util_data;
89         struct tegra_asoc_platform_data *pdata;
90         int gpio_requested;
91         bool init_done;
92         int is_call_mode;
93         int is_device_bt;
94 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
95         struct codec_config codec_info[NUM_I2S_DEVICES];
96 #endif
97         enum snd_soc_bias_level bias_level;
98         struct snd_soc_card *pcard;
99         volatile int clock_enabled;
100 };
101
102 static int tegra_call_mode_info(struct snd_kcontrol *kcontrol,
103                         struct snd_ctl_elem_info *uinfo)
104 {
105         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
106         uinfo->count = 1;
107         uinfo->value.integer.min = 0;
108         uinfo->value.integer.max = 1;
109         return 0;
110 }
111
112 static int tegra_call_mode_get(struct snd_kcontrol *kcontrol,
113                 struct snd_ctl_elem_value *ucontrol)
114 {
115         struct tegra_max98088 *machine = snd_kcontrol_chip(kcontrol);
116
117         ucontrol->value.integer.value[0] = machine->is_call_mode;
118
119         return 0;
120 }
121
122 static int tegra_call_mode_put(struct snd_kcontrol *kcontrol,
123                 struct snd_ctl_elem_value *ucontrol)
124 {
125         struct tegra_max98088 *machine = snd_kcontrol_chip(kcontrol);
126         int is_call_mode_new = ucontrol->value.integer.value[0];
127         int codec_index;
128         unsigned int i;
129
130         if (machine->is_call_mode == is_call_mode_new)
131                 return 0;
132
133         if (machine->is_device_bt)
134                 codec_index = BT_SCO;
135         else
136                 codec_index = HIFI_CODEC;
137
138         if (is_call_mode_new) {
139 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
140                 if (machine->codec_info[codec_index].rate == 0 ||
141                         machine->codec_info[codec_index].channels == 0)
142                                 return -EINVAL;
143
144                 for (i = 0; i < machine->pcard->num_links; i++)
145                         machine->pcard->dai_link[i].ignore_suspend = 1;
146
147                 tegra30_make_voice_call_connections(
148                         &machine->codec_info[codec_index],
149                         &machine->codec_info[BASEBAND]);
150 #endif
151         } else {
152 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
153                 tegra30_break_voice_call_connections(
154                         &machine->codec_info[codec_index],
155                         &machine->codec_info[BASEBAND]);
156
157                 for (i = 0; i < machine->pcard->num_links; i++)
158                         machine->pcard->dai_link[i].ignore_suspend = 0;
159 #endif
160         }
161
162         machine->is_call_mode = is_call_mode_new;
163         g_is_call_mode = machine->is_call_mode;
164
165         return 1;
166 }
167
168 struct snd_kcontrol_new tegra_call_mode_control = {
169         .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
170         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
171         .name = "Call Mode Switch",
172         .private_value = 0xffff,
173         .info = tegra_call_mode_info,
174         .get = tegra_call_mode_get,
175         .put = tegra_call_mode_put
176 };
177
178 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
179 static int tegra_max98088_set_dam_cif(int dam_ifc, int srate,
180                         int channels, int bit_size, int src_on, int src_srate,
181                         int src_channels, int src_bit_size)
182 {
183         tegra30_dam_set_gain(dam_ifc, TEGRA30_DAM_CHIN1, 0x1000);
184         tegra30_dam_set_samplerate(dam_ifc, TEGRA30_DAM_CHOUT,
185                                 srate);
186         tegra30_dam_set_samplerate(dam_ifc, TEGRA30_DAM_CHIN1,
187                                 srate);
188         tegra30_dam_set_acif(dam_ifc, TEGRA30_DAM_CHIN1,
189                 channels, bit_size, channels,
190                                 bit_size);
191         tegra30_dam_set_acif(dam_ifc, TEGRA30_DAM_CHOUT,
192                 channels, bit_size, channels,
193                                 bit_size);
194
195         if (src_on) {
196                 tegra30_dam_set_gain(dam_ifc, TEGRA30_DAM_CHIN0_SRC, 0x1000);
197                 tegra30_dam_set_samplerate(dam_ifc, TEGRA30_DAM_CHIN0_SRC,
198                         src_srate);
199                 tegra30_dam_set_acif(dam_ifc, TEGRA30_DAM_CHIN0_SRC,
200                         src_channels, src_bit_size, 1, 16);
201         }
202
203         return 0;
204 }
205 #endif
206
207 static int tegra_max98088_hw_params(struct snd_pcm_substream *substream,
208                                         struct snd_pcm_hw_params *params)
209 {
210         struct snd_soc_pcm_runtime *rtd = substream->private_data;
211         struct snd_soc_dai *codec_dai = rtd->codec_dai;
212         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
213         struct snd_soc_codec *codec = rtd->codec;
214         struct snd_soc_card *card = codec->card;
215         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
216 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
217         struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(cpu_dai);
218 #endif
219         int srate, mclk, sample_size, i2s_daifmt;
220         int err;
221         struct clk *clk;
222         int rate;
223
224         switch (params_format(params)) {
225         case SNDRV_PCM_FORMAT_S16_LE:
226                 sample_size = 16;
227                 break;
228         default:
229                 return -EINVAL;
230         }
231
232         srate = params_rate(params);
233         switch (srate) {
234         case 8000:
235         case 16000:
236         case 24000:
237         case 32000:
238         case 48000:
239         case 64000:
240         case 96000:
241                 mclk = 12288000;
242                 break;
243         case 11025:
244         case 22050:
245         case 44100:
246         case 88200:
247                 mclk = 11289600;
248                 break;
249         default:
250                 mclk = 12000000;
251                 break;
252         }
253
254
255 #if defined(CONFIG_ARCH_TEGRA_2x_SOC)
256         clk = clk_get_sys(NULL, "cdev1");
257 #else
258         clk = clk_get_sys("extern1", NULL);
259 #endif
260         if (IS_ERR(clk)) {
261                 dev_err(card->dev, "Can't retrieve clk cdev1\n");
262                 err = PTR_ERR(clk);
263                 return err;
264         }
265
266         rate = clk_get_rate(clk);
267         printk("extern1 rate=%d\n",rate);
268
269 #if TEGRA30_I2S_MASTER_PLAYBACK
270         i2s_daifmt = SND_SOC_DAIFMT_I2S |
271                                 SND_SOC_DAIFMT_NB_NF |
272                                 SND_SOC_DAIFMT_CBS_CFS;
273 #else
274         i2s_daifmt = SND_SOC_DAIFMT_I2S |
275                                 SND_SOC_DAIFMT_NB_NF |
276                                 SND_SOC_DAIFMT_CBM_CFM;
277         mclk = rate;
278 #endif
279
280         err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
281         if (err < 0) {
282                 if (!(machine->util_data.set_mclk % mclk))
283                         mclk = machine->util_data.set_mclk;
284                 else {
285                         dev_err(card->dev, "Can't configure clocks\n");
286                         return err;
287                 }
288         }
289
290         tegra_asoc_utils_lock_clk_rate(&machine->util_data, 1);
291
292         err = snd_soc_dai_set_fmt(codec_dai,i2s_daifmt);
293         if (err < 0) {
294                 dev_err(card->dev, "codec_dai fmt not set\n");
295                 return err;
296         }
297
298         err = snd_soc_dai_set_fmt(cpu_dai, i2s_daifmt);
299         if (err < 0) {
300                 dev_err(card->dev, "cpu_dai fmt not set\n");
301                 return err;
302         }
303
304         err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
305                                         SND_SOC_CLOCK_IN);
306         if (err < 0) {
307                 dev_err(card->dev, "codec_dai clock not set\n");
308                 return err;
309         }
310
311 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
312         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
313                 tegra_max98088_set_dam_cif(i2s->dam_ifc, srate,
314                         params_channels(params), sample_size, 0, 0, 0, 0);
315 #endif
316
317         return 0;
318 }
319
320 static int tegra_spdif_hw_params(struct snd_pcm_substream *substream,
321                                         struct snd_pcm_hw_params *params)
322 {
323         struct snd_soc_pcm_runtime *rtd = substream->private_data;
324         struct snd_soc_card *card = rtd->card;
325         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
326         int srate, mclk, min_mclk;
327         int err;
328
329         srate = params_rate(params);
330         switch (srate) {
331         case 11025:
332         case 22050:
333         case 44100:
334         case 88200:
335                 mclk = 11289600;
336                 break;
337         case 8000:
338         case 16000:
339         case 32000:
340         case 48000:
341         case 64000:
342         case 96000:
343                 mclk = 12288000;
344                 break;
345         default:
346                 return -EINVAL;
347         }
348         min_mclk = 128 * srate;
349
350         err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
351         if (err < 0) {
352                 if (!(machine->util_data.set_mclk % min_mclk))
353                         mclk = machine->util_data.set_mclk;
354                 else {
355                         dev_err(card->dev, "Can't configure clocks\n");
356                         return err;
357                 }
358         }
359
360         tegra_asoc_utils_lock_clk_rate(&machine->util_data, 1);
361
362         return 0;
363 }
364
365 static int tegra_bt_hw_params(struct snd_pcm_substream *substream,
366                 struct snd_pcm_hw_params *params)
367 {
368         struct snd_soc_pcm_runtime *rtd = substream->private_data;
369 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
370         struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(rtd->cpu_dai);
371 #endif
372         struct snd_soc_card *card = rtd->card;
373         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
374         int err, srate, mclk, min_mclk, sample_size;
375
376         switch (params_format(params)) {
377         case SNDRV_PCM_FORMAT_S16_LE:
378                 sample_size = 16;
379                 break;
380         default:
381                 return -EINVAL;
382         }
383
384         srate = params_rate(params);
385         switch (srate) {
386         case 11025:
387         case 22050:
388         case 44100:
389         case 88200:
390                 mclk = 11289600;
391                 break;
392         case 8000:
393         case 16000:
394         case 32000:
395         case 48000:
396         case 64000:
397         case 96000:
398                 mclk = 12288000;
399                 break;
400         default:
401                 return -EINVAL;
402         }
403         min_mclk = 64 * srate;
404
405         err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
406         if (err < 0) {
407                 if (!(machine->util_data.set_mclk % min_mclk))
408                         mclk = machine->util_data.set_mclk;
409                 else {
410                         dev_err(card->dev, "Can't configure clocks\n");
411                         return err;
412                 }
413         }
414
415         tegra_asoc_utils_lock_clk_rate(&machine->util_data, 1);
416
417         err = snd_soc_dai_set_fmt(rtd->cpu_dai,
418                         SND_SOC_DAIFMT_DSP_A |
419                         SND_SOC_DAIFMT_NB_NF |
420                         SND_SOC_DAIFMT_CBS_CFS);
421         if (err < 0) {
422                 dev_err(rtd->codec->card->dev, "cpu_dai fmt not set\n");
423                 return err;
424         }
425
426 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
427         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
428                 tegra_max98088_set_dam_cif(i2s->dam_ifc, params_rate(params),
429                         params_channels(params), sample_size, 0, 0, 0, 0);
430 #endif
431
432         return 0;
433 }
434
435 static int tegra_hw_free(struct snd_pcm_substream *substream)
436 {
437         struct snd_soc_pcm_runtime *rtd = substream->private_data;
438         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(rtd->card);
439
440         tegra_asoc_utils_lock_clk_rate(&machine->util_data, 0);
441
442         return 0;
443 }
444
445 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
446 static int tegra_max98088_startup(struct snd_pcm_substream *substream)
447 {
448         struct snd_soc_pcm_runtime *rtd = substream->private_data;
449         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
450         struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(cpu_dai);
451         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(rtd->card);
452         struct codec_config *codec_info;
453         struct codec_config *bb_info;
454         int codec_index;
455
456         if (!i2s->is_dam_used)
457                 return 0;
458
459         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
460                 /*dam configuration*/
461                 if (!i2s->dam_ch_refcount)
462                         i2s->dam_ifc = tegra30_dam_allocate_controller();
463
464                 tegra30_dam_allocate_channel(i2s->dam_ifc, TEGRA30_DAM_CHIN1);
465                 i2s->dam_ch_refcount++;
466                 tegra30_dam_enable_clock(i2s->dam_ifc);
467
468                 tegra30_ahub_set_rx_cif_source(TEGRA30_AHUB_RXCIF_DAM0_RX1 +
469                                 (i2s->dam_ifc*2), i2s->txcif);
470
471                 /*
472                 *make the dam tx to i2s rx connection if this is the only client
473                 *using i2s for playback
474                 */
475                 if (i2s->playback_ref_count == 1)
476                         tegra30_ahub_set_rx_cif_source(
477                                 TEGRA30_AHUB_RXCIF_I2S0_RX0 + i2s->id,
478                                 TEGRA30_AHUB_TXCIF_DAM0_TX0 + i2s->dam_ifc);
479
480                 /* enable the dam*/
481                 tegra30_dam_enable(i2s->dam_ifc, TEGRA30_DAM_ENABLE,
482                                 TEGRA30_DAM_CHIN1);
483         } else {
484
485                 i2s->is_call_mode_rec = machine->is_call_mode;
486
487                 if (!i2s->is_call_mode_rec)
488                         return 0;
489
490                 if (machine->is_device_bt)
491                         codec_index = BT_SCO;
492                 else
493                         codec_index = HIFI_CODEC;
494
495                 codec_info = &machine->codec_info[codec_index];
496                 bb_info = &machine->codec_info[BASEBAND];
497
498                 /* allocate a dam for voice call recording */
499
500                 i2s->call_record_dam_ifc = tegra30_dam_allocate_controller();
501                 tegra30_dam_allocate_channel(i2s->call_record_dam_ifc,
502                         TEGRA30_DAM_CHIN0_SRC);
503                 tegra30_dam_allocate_channel(i2s->call_record_dam_ifc,
504                         TEGRA30_DAM_CHIN1);
505                 tegra30_dam_enable_clock(i2s->call_record_dam_ifc);
506
507                 /* configure the dam */
508                 tegra_max98088_set_dam_cif(i2s->call_record_dam_ifc,
509                         codec_info->rate, codec_info->channels,
510                         codec_info->bitsize, 1, bb_info->rate,
511                         bb_info->channels, bb_info->bitsize);
512
513                 /* setup the connections for voice call record */
514
515                 tegra30_ahub_unset_rx_cif_source(i2s->rxcif);
516                 tegra30_ahub_set_rx_cif_source(TEGRA30_AHUB_RXCIF_DAM0_RX0 +
517                         (i2s->call_record_dam_ifc*2),
518                         TEGRA30_AHUB_TXCIF_I2S0_TX0 + bb_info->i2s_id);
519                 tegra30_ahub_set_rx_cif_source(TEGRA30_AHUB_RXCIF_DAM0_RX1 +
520                         (i2s->call_record_dam_ifc*2),
521                         TEGRA30_AHUB_TXCIF_I2S0_TX0 + codec_info->i2s_id);
522                 tegra30_ahub_set_rx_cif_source(i2s->rxcif,
523                         TEGRA30_AHUB_TXCIF_DAM0_TX0 + i2s->call_record_dam_ifc);
524
525                 /* enable the dam*/
526
527                 tegra30_dam_enable(i2s->call_record_dam_ifc, TEGRA30_DAM_ENABLE,
528                                 TEGRA30_DAM_CHIN1);
529                 tegra30_dam_enable(i2s->call_record_dam_ifc, TEGRA30_DAM_ENABLE,
530                                 TEGRA30_DAM_CHIN0_SRC);
531         }
532
533         return 0;
534 }
535
536 static void tegra_max98088_shutdown(struct snd_pcm_substream *substream)
537 {
538         struct snd_soc_pcm_runtime *rtd = substream->private_data;
539         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
540         struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(cpu_dai);
541
542         if (!i2s->is_dam_used)
543                 return;
544
545         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
546                 /* disable the dam*/
547                 tegra30_dam_enable(i2s->dam_ifc, TEGRA30_DAM_DISABLE,
548                                 TEGRA30_DAM_CHIN1);
549
550                 /* disconnect the ahub connections*/
551                 tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_DAM0_RX1 +
552                                         (i2s->dam_ifc*2));
553
554                 /* disable the dam and free the controller */
555                 tegra30_dam_disable_clock(i2s->dam_ifc);
556                 tegra30_dam_free_channel(i2s->dam_ifc, TEGRA30_DAM_CHIN1);
557                 i2s->dam_ch_refcount--;
558                 if (!i2s->dam_ch_refcount)
559                         tegra30_dam_free_controller(i2s->dam_ifc);
560          } else {
561
562                 if (!i2s->is_call_mode_rec)
563                         return;
564
565                 i2s->is_call_mode_rec = 0;
566
567                 /* disable the dam*/
568                 tegra30_dam_enable(i2s->call_record_dam_ifc,
569                         TEGRA30_DAM_DISABLE, TEGRA30_DAM_CHIN1);
570                 tegra30_dam_enable(i2s->call_record_dam_ifc,
571                         TEGRA30_DAM_DISABLE, TEGRA30_DAM_CHIN0_SRC);
572
573                 /* disconnect the ahub connections*/
574                 tegra30_ahub_unset_rx_cif_source(i2s->rxcif);
575                 tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_DAM0_RX0 +
576                         (i2s->call_record_dam_ifc*2));
577                 tegra30_ahub_unset_rx_cif_source(TEGRA30_AHUB_RXCIF_DAM0_RX1 +
578                         (i2s->call_record_dam_ifc*2));
579
580                 /* free the dam channels and dam controller */
581                 tegra30_dam_disable_clock(i2s->call_record_dam_ifc);
582                 tegra30_dam_free_channel(i2s->call_record_dam_ifc,
583                         TEGRA30_DAM_CHIN1);
584                 tegra30_dam_free_channel(i2s->call_record_dam_ifc,
585                         TEGRA30_DAM_CHIN0_SRC);
586                 tegra30_dam_free_controller(i2s->call_record_dam_ifc);
587          }
588
589         return;
590 }
591 #endif
592
593 static int tegra_voice_call_hw_params(struct snd_pcm_substream *substream,
594                         struct snd_pcm_hw_params *params)
595 {
596         struct snd_soc_pcm_runtime *rtd = substream->private_data;
597         struct snd_soc_dai *codec_dai = rtd->codec_dai;
598         struct snd_soc_codec *codec = rtd->codec;
599         struct snd_soc_card *card = codec->card;
600         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
601         int srate, mclk;
602         int err;
603
604         srate = params_rate(params);
605         switch (srate) {
606         case 8000:
607         case 16000:
608         case 24000:
609         case 32000:
610         case 48000:
611         case 64000:
612         case 96000:
613                 mclk = 12288000;
614                 break;
615         case 11025:
616         case 22050:
617         case 44100:
618         case 88200:
619                 mclk = 11289600;
620                 break;
621         default:
622                 return -EINVAL;
623                 break;
624         }
625
626         err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
627         if (err < 0) {
628                 if (!(machine->util_data.set_mclk % mclk))
629                         mclk = machine->util_data.set_mclk;
630                 else {
631                         dev_err(card->dev, "Can't configure clocks\n");
632                         return err;
633                 }
634         }
635
636         tegra_asoc_utils_lock_clk_rate(&machine->util_data, 1);
637
638         err = snd_soc_dai_set_fmt(codec_dai,
639                                         SND_SOC_DAIFMT_I2S |
640                                         SND_SOC_DAIFMT_NB_NF |
641                                         SND_SOC_DAIFMT_CBS_CFS);
642         if (err < 0) {
643                 dev_err(card->dev, "codec_dai fmt not set\n");
644                 return err;
645         }
646
647         err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
648                                         SND_SOC_CLOCK_IN);
649         if (err < 0) {
650                 dev_err(card->dev, "codec_dai clock not set\n");
651                 return err;
652         }
653
654 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
655         /* codec configuration */
656         machine->codec_info[HIFI_CODEC].rate = params_rate(params);
657         machine->codec_info[HIFI_CODEC].channels = params_channels(params);
658         machine->codec_info[HIFI_CODEC].bitsize = 16;
659         machine->codec_info[HIFI_CODEC].is_i2smaster = 1;
660         machine->codec_info[HIFI_CODEC].is_format_dsp = 0;
661
662         /* baseband configuration */
663         machine->codec_info[BASEBAND].bitsize = 16;
664         machine->codec_info[BASEBAND].is_i2smaster = 1;
665         machine->codec_info[BASEBAND].is_format_dsp = 1;
666 #endif
667
668         machine->is_device_bt = 0;
669
670         return 0;
671 }
672
673 static void tegra_voice_call_shutdown(struct snd_pcm_substream *substream)
674 {
675         struct snd_soc_pcm_runtime *rtd = substream->private_data;
676         struct tegra_max98088 *machine  =
677                         snd_soc_card_get_drvdata(rtd->codec->card);
678
679 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
680         machine->codec_info[HIFI_CODEC].rate = 0;
681         machine->codec_info[HIFI_CODEC].channels = 0;
682 #endif
683
684         return;
685 }
686
687 static int tegra_bt_voice_call_hw_params(struct snd_pcm_substream *substream,
688                         struct snd_pcm_hw_params *params)
689 {
690         struct snd_soc_pcm_runtime *rtd = substream->private_data;
691         struct snd_soc_card *card = rtd->card;
692         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
693         int err, srate, mclk, min_mclk;
694
695         srate = params_rate(params);
696         switch (srate) {
697         case 11025:
698         case 22050:
699         case 44100:
700         case 88200:
701                 mclk = 11289600;
702                 break;
703         case 8000:
704         case 16000:
705         case 32000:
706         case 48000:
707         case 64000:
708         case 96000:
709                 mclk = 12288000;
710                 break;
711         default:
712                 return -EINVAL;
713         }
714         min_mclk = 64 * srate;
715
716         err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
717         if (err < 0) {
718                 if (!(machine->util_data.set_mclk % min_mclk))
719                         mclk = machine->util_data.set_mclk;
720                 else {
721                         dev_err(card->dev, "Can't configure clocks\n");
722                         return err;
723                 }
724         }
725
726         tegra_asoc_utils_lock_clk_rate(&machine->util_data, 1);
727
728 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
729         /* codec configuration */
730         machine->codec_info[BT_SCO].rate = params_rate(params);
731         machine->codec_info[BT_SCO].channels = params_channels(params);
732         machine->codec_info[BT_SCO].bitsize = 16;
733         machine->codec_info[BT_SCO].is_i2smaster = 1;
734         machine->codec_info[BT_SCO].is_format_dsp = 1;
735
736         /* baseband configuration */
737         machine->codec_info[BASEBAND].bitsize = 16;
738         machine->codec_info[BASEBAND].is_i2smaster = 1;
739         machine->codec_info[BASEBAND].is_format_dsp = 1;
740 #endif
741
742         machine->is_device_bt = 1;
743
744         return 0;
745 }
746
747 static void tegra_bt_voice_call_shutdown(struct snd_pcm_substream *substream)
748 {
749         struct snd_soc_pcm_runtime *rtd = substream->private_data;
750         struct tegra_max98088 *machine  =
751                         snd_soc_card_get_drvdata(rtd->codec->card);
752
753 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
754         machine->codec_info[BT_SCO].rate = 0;
755         machine->codec_info[BT_SCO].channels = 0;
756 #endif
757
758         return;
759 }
760
761 static struct snd_soc_ops tegra_max98088_ops = {
762         .hw_params = tegra_max98088_hw_params,
763         .hw_free = tegra_hw_free,
764 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
765         .startup = tegra_max98088_startup,
766         .shutdown = tegra_max98088_shutdown,
767 #endif
768 };
769
770 static struct snd_soc_ops tegra_spdif_ops = {
771         .hw_params = tegra_spdif_hw_params,
772         .hw_free = tegra_hw_free,
773 };
774
775 static struct snd_soc_ops tegra_voice_call_ops = {
776         .hw_params = tegra_voice_call_hw_params,
777         .shutdown = tegra_voice_call_shutdown,
778         .hw_free = tegra_hw_free,
779 };
780
781 static struct snd_soc_ops tegra_bt_voice_call_ops = {
782         .hw_params = tegra_bt_voice_call_hw_params,
783         .shutdown = tegra_bt_voice_call_shutdown,
784         .hw_free = tegra_hw_free,
785 };
786
787 static struct snd_soc_ops tegra_bt_ops = {
788         .hw_params = tegra_bt_hw_params,
789         .hw_free = tegra_hw_free,
790 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
791         .startup = tegra_max98088_startup,
792         .shutdown = tegra_max98088_shutdown,
793 #endif
794 };
795
796 static struct snd_soc_jack tegra_max98088_hp_jack;
797
798 #ifdef CONFIG_SWITCH
799 static struct switch_dev wired_switch_dev = {
800         .name = "h2w",
801 };
802
803 /* These values are copied from WiredAccessoryObserver */
804 enum headset_state {
805         BIT_NO_HEADSET = 0,
806         BIT_HEADSET = (1 << 0),
807         BIT_HEADSET_NO_MIC = (1 << 1),
808 };
809
810 static int headset_switch_notify(struct notifier_block *self,
811         unsigned long action, void *dev)
812 {
813         int state = 0;
814
815         switch (action) {
816         case SND_JACK_HEADPHONE:
817                 state |= BIT_HEADSET_NO_MIC;
818                 break;
819         case SND_JACK_HEADSET:
820                 state |= BIT_HEADSET;
821                 break;
822         default:
823                 state |= BIT_NO_HEADSET;
824         }
825
826         switch_set_state(&wired_switch_dev, state);
827
828         return NOTIFY_OK;
829 }
830
831 static struct notifier_block headset_switch_nb = {
832         .notifier_call = headset_switch_notify,
833 };
834 #else
835 static struct snd_soc_jack_pin tegra_max98088_hp_jack_pins[] = {
836         {
837                 .pin = "Headphone Jack",
838                 .mask = SND_JACK_HEADPHONE,
839         },
840 };
841 #endif
842
843 static int tegra_max98088_event_int_spk(struct snd_soc_dapm_widget *w,
844                                         struct snd_kcontrol *k, int event)
845 {
846         struct snd_soc_dapm_context *dapm = w->dapm;
847         struct snd_soc_card *card = dapm->card;
848         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
849         struct tegra_asoc_platform_data *pdata = machine->pdata;
850
851         if (!(machine->gpio_requested & GPIO_SPKR_EN))
852                 return 0;
853
854         gpio_set_value_cansleep(pdata->gpio_spkr_en,
855                                 SND_SOC_DAPM_EVENT_ON(event));
856
857         return 0;
858 }
859
860 static int tegra_max98088_event_hp(struct snd_soc_dapm_widget *w,
861                                         struct snd_kcontrol *k, int event)
862 {
863         struct snd_soc_dapm_context *dapm = w->dapm;
864         struct snd_soc_card *card = dapm->card;
865         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
866         struct tegra_asoc_platform_data *pdata = machine->pdata;
867
868         if (!(machine->gpio_requested & GPIO_HP_MUTE))
869                 return 0;
870
871         gpio_set_value_cansleep(pdata->gpio_hp_mute,
872                                 !SND_SOC_DAPM_EVENT_ON(event));
873
874         return 0;
875 }
876
877 static const struct snd_soc_dapm_widget tegra_max98088_dapm_widgets[] = {
878         SND_SOC_DAPM_SPK("Int Spk", tegra_max98088_event_int_spk),
879         SND_SOC_DAPM_OUTPUT("Earpiece"),
880         SND_SOC_DAPM_HP("Headphone Jack", tegra_max98088_event_hp),
881         SND_SOC_DAPM_MIC("Mic Jack", NULL),
882         SND_SOC_DAPM_INPUT("Int Mic"),
883 };
884
885 static const struct snd_soc_dapm_route enterprise_audio_map[] = {
886         {"Int Spk", NULL, "SPKL"},
887         {"Int Spk", NULL, "SPKR"},
888         {"Earpiece", NULL, "RECL"},
889         {"Earpiece", NULL, "RECR"},
890         {"Headphone Jack", NULL, "HPL"},
891         {"Headphone Jack", NULL, "HPR"},
892         {"MICBIAS", NULL, "Mic Jack"},
893         {"MIC2", NULL, "MICBIAS"},
894         {"MICBIAS", NULL, "Int Mic"},
895         {"MIC1", NULL, "MICBIAS"},
896 };
897
898 static const struct snd_kcontrol_new tegra_max98088_controls[] = {
899         SOC_DAPM_PIN_SWITCH("Int Spk"),
900         SOC_DAPM_PIN_SWITCH("Earpiece"),
901         SOC_DAPM_PIN_SWITCH("Headphone Jack"),
902         SOC_DAPM_PIN_SWITCH("Mic Jack"),
903         SOC_DAPM_PIN_SWITCH("Int Mic"),
904 };
905
906 static int tegra_max98088_init(struct snd_soc_pcm_runtime *rtd)
907 {
908         struct snd_soc_codec *codec = rtd->codec;
909         struct snd_soc_dapm_context *dapm = &codec->dapm;
910         struct snd_soc_card *card = codec->card;
911         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
912         struct tegra_asoc_platform_data *pdata = machine->pdata;
913 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
914         struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(rtd->cpu_dai);
915 #endif
916         int ret;
917
918 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
919         if (machine->codec_info[BASEBAND].i2s_id != -1)
920                 i2s->is_dam_used = true;
921 #endif
922
923         if (machine->init_done)
924                 return 0;
925
926         machine->init_done = true;
927
928         machine->pcard = card;
929         machine->bias_level = SND_SOC_BIAS_STANDBY;
930         machine->clock_enabled = 1;
931
932         if (gpio_is_valid(pdata->gpio_spkr_en)) {
933                 ret = gpio_request(pdata->gpio_spkr_en, "spkr_en");
934                 if (ret) {
935                         dev_err(card->dev, "cannot get spkr_en gpio\n");
936                         return ret;
937                 }
938                 machine->gpio_requested |= GPIO_SPKR_EN;
939
940                 gpio_direction_output(pdata->gpio_spkr_en, 0);
941         }
942
943         if (gpio_is_valid(pdata->gpio_hp_mute)) {
944                 ret = gpio_request(pdata->gpio_hp_mute, "hp_mute");
945                 if (ret) {
946                         dev_err(card->dev, "cannot get hp_mute gpio\n");
947                         return ret;
948                 }
949                 machine->gpio_requested |= GPIO_HP_MUTE;
950
951                 gpio_direction_output(pdata->gpio_hp_mute, 0);
952         }
953
954         if (gpio_is_valid(pdata->gpio_int_mic_en)) {
955                 ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en");
956                 if (ret) {
957                         dev_err(card->dev, "cannot get int_mic_en gpio\n");
958                         return ret;
959                 }
960                 machine->gpio_requested |= GPIO_INT_MIC_EN;
961
962                 /* Disable int mic; enable signal is active-high */
963                 gpio_direction_output(pdata->gpio_int_mic_en, 0);
964         }
965
966         if (gpio_is_valid(pdata->gpio_ext_mic_en)) {
967                 ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en");
968                 if (ret) {
969                         dev_err(card->dev, "cannot get ext_mic_en gpio\n");
970                         return ret;
971                 }
972                 machine->gpio_requested |= GPIO_EXT_MIC_EN;
973
974                 /* Enable ext mic; enable signal is active-low */
975                 gpio_direction_output(pdata->gpio_ext_mic_en, 0);
976         }
977
978         ret = snd_soc_add_card_controls(card, tegra_max98088_controls,
979                                    ARRAY_SIZE(tegra_max98088_controls));
980         if (ret < 0)
981                 return ret;
982
983         snd_soc_dapm_new_controls(dapm, tegra_max98088_dapm_widgets,
984                                         ARRAY_SIZE(tegra_max98088_dapm_widgets));
985
986         snd_soc_dapm_add_routes(dapm, enterprise_audio_map,
987                                         ARRAY_SIZE(enterprise_audio_map));
988
989         ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET,
990                         &tegra_max98088_hp_jack);
991         if (ret < 0)
992                 return ret;
993
994 #ifdef CONFIG_SWITCH
995         snd_soc_jack_notifier_register(&tegra_max98088_hp_jack,
996                 &headset_switch_nb);
997 #else /*gpio based headset detection*/
998         snd_soc_jack_add_pins(&tegra_max98088_hp_jack,
999                 ARRAY_SIZE(tegra_max98088_hp_jack_pins),
1000                 tegra_max98088_hp_jack_pins);
1001 #endif
1002
1003         max98088_headset_detect(codec, &tegra_max98088_hp_jack,
1004                 SND_JACK_HEADSET);
1005
1006        /* Add call mode switch control */
1007         ret = snd_ctl_add(codec->card->snd_card,
1008                         snd_ctl_new1(&tegra_call_mode_control, machine));
1009         if (ret < 0)
1010                 return ret;
1011
1012         ret = tegra_asoc_utils_register_ctls(&machine->util_data);
1013         if (ret < 0)
1014                 return ret;
1015
1016         snd_soc_dapm_nc_pin(dapm, "INA1");
1017         snd_soc_dapm_nc_pin(dapm, "INA2");
1018         snd_soc_dapm_nc_pin(dapm, "INB1");
1019         snd_soc_dapm_nc_pin(dapm, "INB2");
1020         snd_soc_dapm_sync(dapm);
1021
1022         return 0;
1023 }
1024
1025 static struct snd_soc_dai_link tegra_max98088_dai[NUM_DAI_LINKS] = {
1026         [DAI_LINK_HIFI] = {
1027                         .name = "MAX98088",
1028                         .stream_name = "MAX98088 HIFI",
1029                         .codec_name = "max98088.0-0010",
1030                         .platform_name = "tegra-pcm-audio",
1031                         .codec_dai_name = "HiFi",
1032                         .init = tegra_max98088_init,
1033                         .ops = &tegra_max98088_ops,
1034                 },
1035         [DAI_LINK_SPDIF] = {
1036                         .name = "SPDIF",
1037                         .stream_name = "SPDIF PCM",
1038                         .codec_name = "spdif-dit.0",
1039                         .platform_name = "tegra-pcm-audio",
1040                         .cpu_dai_name = "tegra30-spdif",
1041                         .codec_dai_name = "dit-hifi",
1042                         .ops = &tegra_spdif_ops,
1043                 },
1044         [DAI_LINK_BTSCO] = {
1045                         .name = "BT SCO",
1046                         .stream_name = "BT SCO PCM",
1047                         .codec_name = "spdif-dit.1",
1048                         .platform_name = "tegra-pcm-audio",
1049                         .codec_dai_name = "dit-hifi",
1050                         .init = tegra_max98088_init,
1051                         .ops = &tegra_bt_ops,
1052                 },
1053         [DAI_LINK_VOICE_CALL] = {
1054                         .name = "VOICE CALL",
1055                         .stream_name = "VOICE CALL PCM",
1056                         .codec_name = "max98088.0-0010",
1057                         .platform_name = "tegra-pcm-audio",
1058                         .cpu_dai_name = "dit-hifi",
1059                         .codec_dai_name = "HiFi",
1060                         .ops = &tegra_voice_call_ops,
1061                 },
1062         [DAI_LINK_BT_VOICE_CALL] = {
1063                         .name = "BT VOICE CALL",
1064                         .stream_name = "BT VOICE CALL PCM",
1065                         .codec_name = "spdif-dit.2",
1066                         .platform_name = "tegra-pcm-audio",
1067                         .cpu_dai_name = "dit-hifi",
1068                         .codec_dai_name = "dit-hifi",
1069                         .ops = &tegra_bt_voice_call_ops,
1070                 },
1071 };
1072
1073 static int tegra30_soc_set_bias_level(struct snd_soc_card *card,
1074                                         struct snd_soc_dapm_context *dapm,
1075                                         enum snd_soc_bias_level level)
1076 {
1077         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
1078
1079         if (machine->bias_level == SND_SOC_BIAS_OFF &&
1080                 level != SND_SOC_BIAS_OFF && (!machine->clock_enabled)) {
1081                 machine->clock_enabled = 1;
1082                 tegra_asoc_utils_clk_enable(&machine->util_data);
1083                 machine->bias_level = level;
1084         }
1085
1086         return 0;
1087 }
1088
1089 static int tegra30_soc_set_bias_level_post(struct snd_soc_card *card,
1090                                         struct snd_soc_dapm_context *dapm,
1091                                         enum snd_soc_bias_level level)
1092 {
1093         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
1094
1095         if (machine->bias_level != SND_SOC_BIAS_OFF &&
1096                 level == SND_SOC_BIAS_OFF && (machine->clock_enabled)) {
1097                 machine->clock_enabled = 0;
1098                 tegra_asoc_utils_clk_disable(&machine->util_data);
1099         }
1100
1101         machine->bias_level = level;
1102
1103         return 0 ;
1104 }
1105
1106 static struct snd_soc_card snd_soc_tegra_max98088 = {
1107         .name = "tegra-max98088",
1108         .owner = THIS_MODULE,
1109         .dai_link = tegra_max98088_dai,
1110         .num_links = ARRAY_SIZE(tegra_max98088_dai),
1111         .set_bias_level = tegra30_soc_set_bias_level,
1112         .set_bias_level_post = tegra30_soc_set_bias_level_post,
1113 };
1114
1115 static __devinit int tegra_max98088_driver_probe(struct platform_device *pdev)
1116 {
1117         struct snd_soc_card *card = &snd_soc_tegra_max98088;
1118         struct tegra_max98088 *machine;
1119         struct tegra_asoc_platform_data *pdata;
1120         int ret, i;
1121
1122         pdata = pdev->dev.platform_data;
1123         if (!pdata) {
1124                 dev_err(&pdev->dev, "No platform data supplied\n");
1125                 return -EINVAL;
1126         }
1127
1128         machine = kzalloc(sizeof(struct tegra_max98088), GFP_KERNEL);
1129         if (!machine) {
1130                 dev_err(&pdev->dev, "Can't allocate tegra_max98088 struct\n");
1131                 return -ENOMEM;
1132         }
1133
1134         machine->pdata = pdata;
1135
1136         ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev, card);
1137         if (ret)
1138                 goto err_free_machine;
1139
1140         card->dev = &pdev->dev;
1141         platform_set_drvdata(pdev, card);
1142         snd_soc_card_set_drvdata(card, machine);
1143
1144 #ifdef CONFIG_SWITCH
1145         /* Add h2w switch class support */
1146         ret = switch_dev_register(&wired_switch_dev);
1147         if (ret < 0) {
1148                 dev_err(&pdev->dev, "not able to register switch device\n");
1149                 goto err_fini_utils;
1150         }
1151 #endif
1152
1153 #ifndef CONFIG_ARCH_TEGRA_2x_SOC
1154         for (i = 0; i < NUM_I2S_DEVICES ; i++)
1155                 machine->codec_info[i].i2s_id = pdata->audio_port_id[i];
1156
1157         machine->codec_info[BASEBAND].rate = pdata->baseband_param.rate;
1158         machine->codec_info[BASEBAND].channels = pdata->baseband_param.channels;
1159         machine->codec_info[BASEBAND].is_format_dsp = 0;
1160
1161         if ((pdata->baseband_param.bit_format == TEGRA_DAIFMT_DSP_A) ||
1162         (pdata->baseband_param.bit_format == TEGRA_DAIFMT_DSP_B)) {
1163                         machine->codec_info[BASEBAND].is_format_dsp = 1;
1164         }
1165
1166         tegra_max98088_dai[DAI_LINK_HIFI].cpu_dai_name =
1167         tegra_max98088_i2s_dai_name[machine->codec_info[HIFI_CODEC].i2s_id];
1168
1169         tegra_max98088_dai[DAI_LINK_BTSCO].cpu_dai_name =
1170         tegra_max98088_i2s_dai_name[machine->codec_info[BT_SCO].i2s_id];
1171 #endif
1172
1173         card->dapm.idle_bias_off = 1;
1174         ret = snd_soc_register_card(card);
1175         if (ret) {
1176                 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
1177                         ret);
1178                 goto err_switch_unregister;
1179         }
1180
1181         if (!card->instantiated) {
1182                 dev_err(&pdev->dev, "No MAX98088 codec\n");
1183                 goto err_unregister_card;
1184         }
1185
1186         return 0;
1187
1188 err_unregister_card:
1189         snd_soc_unregister_card(card);
1190 err_switch_unregister:
1191 #ifdef CONFIG_SWITCH
1192         switch_dev_unregister(&wired_switch_dev);
1193 #endif
1194 err_fini_utils:
1195         tegra_asoc_utils_fini(&machine->util_data);
1196 err_free_machine:
1197         kfree(machine);
1198         return ret;
1199 }
1200
1201 static int __devexit tegra_max98088_driver_remove(struct platform_device *pdev)
1202 {
1203         struct snd_soc_card *card = platform_get_drvdata(pdev);
1204         struct tegra_max98088 *machine = snd_soc_card_get_drvdata(card);
1205         struct tegra_asoc_platform_data *pdata = machine->pdata;
1206
1207         snd_soc_unregister_card(card);
1208
1209 #ifdef CONFIG_SWITCH
1210         switch_dev_unregister(&wired_switch_dev);
1211 #endif
1212
1213         tegra_asoc_utils_fini(&machine->util_data);
1214
1215         if (machine->gpio_requested & GPIO_EXT_MIC_EN)
1216                 gpio_free(pdata->gpio_ext_mic_en);
1217         if (machine->gpio_requested & GPIO_INT_MIC_EN)
1218                 gpio_free(pdata->gpio_int_mic_en);
1219         if (machine->gpio_requested & GPIO_HP_MUTE)
1220                 gpio_free(pdata->gpio_hp_mute);
1221         if (machine->gpio_requested & GPIO_SPKR_EN)
1222                 gpio_free(pdata->gpio_spkr_en);
1223
1224         kfree(machine);
1225
1226         return 0;
1227 }
1228
1229 static struct platform_driver tegra_max98088_driver = {
1230         .driver = {
1231                 .name = DRV_NAME,
1232                 .owner = THIS_MODULE,
1233                 .pm = &snd_soc_pm_ops,
1234         },
1235         .probe = tegra_max98088_driver_probe,
1236         .remove = __devexit_p(tegra_max98088_driver_remove),
1237 };
1238
1239 static int __init tegra_max98088_modinit(void)
1240 {
1241         return platform_driver_register(&tegra_max98088_driver);
1242 }
1243 module_init(tegra_max98088_modinit);
1244
1245 static void __exit tegra_max98088_modexit(void)
1246 {
1247         platform_driver_unregister(&tegra_max98088_driver);
1248 }
1249 module_exit(tegra_max98088_modexit);
1250
1251 MODULE_AUTHOR("Sumit Bhattacharya <sumitb@nvidia.com>");
1252 MODULE_DESCRIPTION("Tegra+MAX98088 machine ASoC driver");
1253 MODULE_LICENSE("GPL");
1254 MODULE_ALIAS("platform:" DRV_NAME);