blob: 21604009bc1a2df338e6696c83f78a3473174254 [file] [log] [blame]
Stephen Warrena8bf1ba2011-01-07 22:36:16 -07001/*
Stephen Warrendc0a50af2011-04-12 11:40:36 -06002 * tegra_wm8903.c - Tegra machine ASoC driver for boards using WM8903 codec.
Stephen Warrena8bf1ba2011-01-07 22:36:16 -07003 *
4 * Author: Stephen Warren <swarren@nvidia.com>
Stephen Warren518de862012-03-20 14:55:49 -06005 * Copyright (C) 2010-2012 - NVIDIA, Inc.
Stephen Warrena8bf1ba2011-01-07 22:36:16 -07006 *
7 * Based on code copyright/by:
8 *
9 * (c) 2009, 2010 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
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070031#include <linux/module.h>
Stephen Warren72de2b12011-01-28 14:26:36 -070032#include <linux/platform_device.h>
33#include <linux/slab.h>
Stephen Warren6e267642011-01-28 14:26:37 -070034#include <linux/gpio.h>
Stephen Warren07cdf362011-12-12 15:55:36 -070035#include <linux/of_gpio.h>
Stephen Warren6e267642011-01-28 14:26:37 -070036
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070037#include <sound/core.h>
Stephen Warrenf7d3e402011-02-03 13:56:13 -070038#include <sound/jack.h>
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070039#include <sound/pcm.h>
40#include <sound/pcm_params.h>
41#include <sound/soc.h>
42
Stephen Warren41b5f9b2011-02-10 15:37:16 -070043#include "../codecs/wm8903.h"
44
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070045#include "tegra_asoc_utils.h"
46
Stephen Warren7b33af22011-04-12 11:29:00 -060047#define DRV_NAME "tegra-snd-wm8903"
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070048
Stephen Warrendc0a50af2011-04-12 11:40:36 -060049struct tegra_wm8903 {
Stephen Warren8f5f5e02013-02-15 17:07:35 -070050 int gpio_spkr_en;
51 int gpio_hp_det;
52 int gpio_hp_mute;
53 int gpio_int_mic_en;
54 int gpio_ext_mic_en;
Stephen Warrend64e57c2011-01-28 14:26:40 -070055 struct tegra_asoc_utils_data util_data;
Stephen Warren72de2b12011-01-28 14:26:36 -070056};
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070057
Stephen Warrendc0a50af2011-04-12 11:40:36 -060058static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070059 struct snd_pcm_hw_params *params)
60{
61 struct snd_soc_pcm_runtime *rtd = substream->private_data;
62 struct snd_soc_dai *codec_dai = rtd->codec_dai;
Lars-Peter Clausen093c4e52014-07-17 22:01:06 +020063 struct snd_soc_card *card = rtd->card;
Stephen Warrendc0a50af2011-04-12 11:40:36 -060064 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
Stephen Warren07541392011-04-19 15:25:09 -060065 int srate, mclk;
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070066 int err;
67
68 srate = params_rate(params);
69 switch (srate) {
70 case 64000:
71 case 88200:
72 case 96000:
73 mclk = 128 * srate;
74 break;
75 default:
76 mclk = 256 * srate;
77 break;
78 }
79 /* FIXME: Codec only requires >= 3MHz if OSR==0 */
80 while (mclk < 6000000)
81 mclk *= 2;
82
Stephen Warren07541392011-04-19 15:25:09 -060083 err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070084 if (err < 0) {
Stephen Warrenc244d472011-01-28 14:26:39 -070085 dev_err(card->dev, "Can't configure clocks\n");
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070086 return err;
87 }
88
Stephen Warren07541392011-04-19 15:25:09 -060089 err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
90 SND_SOC_CLOCK_IN);
91 if (err < 0) {
92 dev_err(card->dev, "codec_dai clock not set\n");
93 return err;
Stephen Warrena8bf1ba2011-01-07 22:36:16 -070094 }
95
96 return 0;
97}
98
Stephen Warrendc0a50af2011-04-12 11:40:36 -060099static struct snd_soc_ops tegra_wm8903_ops = {
100 .hw_params = tegra_wm8903_hw_params,
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700101};
102
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600103static struct snd_soc_jack tegra_wm8903_hp_jack;
Stephen Warrenf7d3e402011-02-03 13:56:13 -0700104
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600105static struct snd_soc_jack_pin tegra_wm8903_hp_jack_pins[] = {
Stephen Warrenf7d3e402011-02-03 13:56:13 -0700106 {
107 .pin = "Headphone Jack",
108 .mask = SND_JACK_HEADPHONE,
109 },
110};
111
Stephen Warren3eb25f92011-04-12 11:40:38 -0600112static struct snd_soc_jack_gpio tegra_wm8903_hp_jack_gpio = {
113 .name = "headphone detect",
114 .report = SND_JACK_HEADPHONE,
115 .debounce_time = 150,
116 .invert = 1,
Stephen Warrenf7d3e402011-02-03 13:56:13 -0700117};
118
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600119static struct snd_soc_jack tegra_wm8903_mic_jack;
Stephen Warren41b5f9b2011-02-10 15:37:16 -0700120
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600121static struct snd_soc_jack_pin tegra_wm8903_mic_jack_pins[] = {
Stephen Warren41b5f9b2011-02-10 15:37:16 -0700122 {
123 .pin = "Mic Jack",
124 .mask = SND_JACK_MICROPHONE,
125 },
126};
127
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600128static int tegra_wm8903_event_int_spk(struct snd_soc_dapm_widget *w,
Stephen Warren6e267642011-01-28 14:26:37 -0700129 struct snd_kcontrol *k, int event)
130{
Stephen Warrena32955d2011-04-19 15:25:10 -0600131 struct snd_soc_dapm_context *dapm = w->dapm;
132 struct snd_soc_card *card = dapm->card;
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600133 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
Stephen Warren6e267642011-01-28 14:26:37 -0700134
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700135 if (!gpio_is_valid(machine->gpio_spkr_en))
Stephen Warren773b1d32011-04-12 11:40:39 -0600136 return 0;
137
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700138 gpio_set_value_cansleep(machine->gpio_spkr_en,
Stephen Warrenf9eabc32011-01-31 11:00:17 -0700139 SND_SOC_DAPM_EVENT_ON(event));
Stephen Warren6e267642011-01-28 14:26:37 -0700140
141 return 0;
142}
143
Stephen Warren773b1d32011-04-12 11:40:39 -0600144static int tegra_wm8903_event_hp(struct snd_soc_dapm_widget *w,
145 struct snd_kcontrol *k, int event)
146{
Stephen Warrena32955d2011-04-19 15:25:10 -0600147 struct snd_soc_dapm_context *dapm = w->dapm;
148 struct snd_soc_card *card = dapm->card;
Stephen Warren773b1d32011-04-12 11:40:39 -0600149 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
Stephen Warren773b1d32011-04-12 11:40:39 -0600150
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700151 if (!gpio_is_valid(machine->gpio_hp_mute))
Stephen Warren773b1d32011-04-12 11:40:39 -0600152 return 0;
153
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700154 gpio_set_value_cansleep(machine->gpio_hp_mute,
Stephen Warren773b1d32011-04-12 11:40:39 -0600155 !SND_SOC_DAPM_EVENT_ON(event));
156
157 return 0;
158}
159
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600160static const struct snd_soc_dapm_widget tegra_wm8903_dapm_widgets[] = {
161 SND_SOC_DAPM_SPK("Int Spk", tegra_wm8903_event_int_spk),
Stephen Warren773b1d32011-04-12 11:40:39 -0600162 SND_SOC_DAPM_HP("Headphone Jack", tegra_wm8903_event_hp),
Stephen Warren62ffac42011-01-13 15:22:08 -0700163 SND_SOC_DAPM_MIC("Mic Jack", NULL),
164};
165
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600166static const struct snd_kcontrol_new tegra_wm8903_controls[] = {
Stephen Warren3d8bc392011-02-03 13:56:14 -0700167 SOC_DAPM_PIN_SWITCH("Int Spk"),
168};
169
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600170static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
Stephen Warren62ffac42011-01-13 15:22:08 -0700171{
Stephen Warren40db77a2012-06-06 17:15:49 -0600172 struct snd_soc_dai *codec_dai = rtd->codec_dai;
173 struct snd_soc_codec *codec = codec_dai->codec;
Lars-Peter Clausen093c4e52014-07-17 22:01:06 +0200174 struct snd_soc_card *card = rtd->card;
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600175 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
Stephen Warrenbf1b1322011-02-10 15:37:18 -0700176
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700177 if (gpio_is_valid(machine->gpio_hp_det)) {
178 tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det;
Lars-Peter Clausen7ba8cbb2015-03-04 10:33:44 +0100179 snd_soc_card_jack_new(rtd->card, "Headphone Jack",
180 SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack,
181 tegra_wm8903_hp_jack_pins,
182 ARRAY_SIZE(tegra_wm8903_hp_jack_pins));
Stephen Warren773b1d32011-04-12 11:40:39 -0600183 snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
184 1,
185 &tegra_wm8903_hp_jack_gpio);
186 }
Stephen Warrenf7d3e402011-02-03 13:56:13 -0700187
Lars-Peter Clausen7ba8cbb2015-03-04 10:33:44 +0100188 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
189 &tegra_wm8903_mic_jack,
190 tegra_wm8903_mic_jack_pins,
191 ARRAY_SIZE(tegra_wm8903_mic_jack_pins));
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600192 wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
193 0);
Stephen Warren41b5f9b2011-02-10 15:37:16 -0700194
Lars-Peter Clausen14e954f2015-04-03 13:04:07 +0200195 snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS");
Stephen Warren41b5f9b2011-02-10 15:37:16 -0700196
Stephen Warren62ffac42011-01-13 15:22:08 -0700197 return 0;
198}
199
Stephen Warren3419ae72012-06-11 11:27:19 -0600200static int tegra_wm8903_remove(struct snd_soc_card *card)
201{
202 struct snd_soc_pcm_runtime *rtd = &(card->rtd[0]);
203 struct snd_soc_dai *codec_dai = rtd->codec_dai;
204 struct snd_soc_codec *codec = codec_dai->codec;
Stephen Warrenfb6b8e72014-05-22 16:14:53 -0600205 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
206
207 if (gpio_is_valid(machine->gpio_hp_det)) {
208 snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 1,
209 &tegra_wm8903_hp_jack_gpio);
210 }
Stephen Warren3419ae72012-06-11 11:27:19 -0600211
212 wm8903_mic_detect(codec, NULL, 0, 0);
213
214 return 0;
215}
216
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600217static struct snd_soc_dai_link tegra_wm8903_dai = {
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700218 .name = "WM8903",
219 .stream_name = "WM8903 PCM",
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700220 .codec_dai_name = "wm8903-hifi",
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600221 .init = tegra_wm8903_init,
222 .ops = &tegra_wm8903_ops,
Stephen Warren408dafc2012-06-06 17:15:48 -0600223 .dai_fmt = SND_SOC_DAIFMT_I2S |
224 SND_SOC_DAIFMT_NB_NF |
225 SND_SOC_DAIFMT_CBS_CFS,
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700226};
227
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600228static struct snd_soc_card snd_soc_tegra_wm8903 = {
229 .name = "tegra-wm8903",
Axel Linb16eaf92011-12-22 21:23:01 +0800230 .owner = THIS_MODULE,
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600231 .dai_link = &tegra_wm8903_dai,
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700232 .num_links = 1,
Stephen Warren3419ae72012-06-11 11:27:19 -0600233 .remove = tegra_wm8903_remove,
Stephen Warrendea8b6e2011-04-19 15:25:12 -0600234 .controls = tegra_wm8903_controls,
235 .num_controls = ARRAY_SIZE(tegra_wm8903_controls),
236 .dapm_widgets = tegra_wm8903_dapm_widgets,
237 .num_dapm_widgets = ARRAY_SIZE(tegra_wm8903_dapm_widgets),
Stephen Warren6e5fdba2011-11-23 12:42:05 -0700238 .fully_routed = true,
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700239};
240
Bill Pemberton4652a0d2012-12-07 09:26:33 -0500241static int tegra_wm8903_driver_probe(struct platform_device *pdev)
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700242{
Stephen Warrenf51022f2012-05-22 16:08:54 -0600243 struct device_node *np = pdev->dev.of_node;
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600244 struct snd_soc_card *card = &snd_soc_tegra_wm8903;
245 struct tegra_wm8903 *machine;
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700246 int ret;
247
Stephen Warrene4e4c182011-11-22 18:21:20 -0700248 machine = devm_kzalloc(&pdev->dev, sizeof(struct tegra_wm8903),
249 GFP_KERNEL);
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600250 if (!machine) {
251 dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n");
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700252 return -ENOMEM;
Stephen Warren72de2b12011-01-28 14:26:36 -0700253 }
Stephen Warren72de2b12011-01-28 14:26:36 -0700254
255 card->dev = &pdev->dev;
256 platform_set_drvdata(pdev, card);
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600257 snd_soc_card_set_drvdata(card, machine);
Stephen Warren72de2b12011-01-28 14:26:36 -0700258
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700259 machine->gpio_spkr_en = of_get_named_gpio(np, "nvidia,spkr-en-gpios",
260 0);
261 if (machine->gpio_spkr_en == -EPROBE_DEFER)
262 return -EPROBE_DEFER;
263 if (gpio_is_valid(machine->gpio_spkr_en)) {
264 ret = devm_gpio_request_one(&pdev->dev, machine->gpio_spkr_en,
Stephen Warrene2d287c2012-05-22 16:08:55 -0600265 GPIOF_OUT_INIT_LOW, "spkr_en");
Stephen Warrenf51022f2012-05-22 16:08:54 -0600266 if (ret) {
267 dev_err(card->dev, "cannot get spkr_en gpio\n");
268 return ret;
269 }
Stephen Warrenf51022f2012-05-22 16:08:54 -0600270 }
271
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700272 machine->gpio_hp_mute = of_get_named_gpio(np, "nvidia,hp-mute-gpios",
273 0);
274 if (machine->gpio_hp_mute == -EPROBE_DEFER)
275 return -EPROBE_DEFER;
276 if (gpio_is_valid(machine->gpio_hp_mute)) {
277 ret = devm_gpio_request_one(&pdev->dev, machine->gpio_hp_mute,
Stephen Warrene2d287c2012-05-22 16:08:55 -0600278 GPIOF_OUT_INIT_HIGH, "hp_mute");
Stephen Warrenf51022f2012-05-22 16:08:54 -0600279 if (ret) {
280 dev_err(card->dev, "cannot get hp_mute gpio\n");
281 return ret;
282 }
Stephen Warrenf51022f2012-05-22 16:08:54 -0600283 }
284
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700285 machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0);
286 if (machine->gpio_hp_det == -EPROBE_DEFER)
287 return -EPROBE_DEFER;
288
289 machine->gpio_int_mic_en = of_get_named_gpio(np,
290 "nvidia,int-mic-en-gpios", 0);
291 if (machine->gpio_int_mic_en == -EPROBE_DEFER)
292 return -EPROBE_DEFER;
293 if (gpio_is_valid(machine->gpio_int_mic_en)) {
Stephen Warrene2d287c2012-05-22 16:08:55 -0600294 /* Disable int mic; enable signal is active-high */
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700295 ret = devm_gpio_request_one(&pdev->dev,
296 machine->gpio_int_mic_en,
Stephen Warrene2d287c2012-05-22 16:08:55 -0600297 GPIOF_OUT_INIT_LOW, "int_mic_en");
Stephen Warrenf51022f2012-05-22 16:08:54 -0600298 if (ret) {
299 dev_err(card->dev, "cannot get int_mic_en gpio\n");
300 return ret;
301 }
Stephen Warrenf51022f2012-05-22 16:08:54 -0600302 }
303
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700304 machine->gpio_ext_mic_en = of_get_named_gpio(np,
305 "nvidia,ext-mic-en-gpios", 0);
306 if (machine->gpio_ext_mic_en == -EPROBE_DEFER)
307 return -EPROBE_DEFER;
308 if (gpio_is_valid(machine->gpio_ext_mic_en)) {
Stephen Warrene2d287c2012-05-22 16:08:55 -0600309 /* Enable ext mic; enable signal is active-low */
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700310 ret = devm_gpio_request_one(&pdev->dev,
311 machine->gpio_ext_mic_en,
Stephen Warrene2d287c2012-05-22 16:08:55 -0600312 GPIOF_OUT_INIT_LOW, "ext_mic_en");
Stephen Warrenf51022f2012-05-22 16:08:54 -0600313 if (ret) {
314 dev_err(card->dev, "cannot get ext_mic_en gpio\n");
315 return ret;
316 }
Stephen Warrenf51022f2012-05-22 16:08:54 -0600317 }
318
Stephen Warren8f5f5e02013-02-15 17:07:35 -0700319 ret = snd_soc_of_parse_card_name(card, "nvidia,model");
320 if (ret)
321 goto err;
322
323 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing");
324 if (ret)
325 goto err;
326
327 tegra_wm8903_dai.codec_of_node = of_parse_phandle(np,
328 "nvidia,audio-codec", 0);
329 if (!tegra_wm8903_dai.codec_of_node) {
330 dev_err(&pdev->dev,
331 "Property 'nvidia,audio-codec' missing or invalid\n");
332 ret = -EINVAL;
333 goto err;
334 }
335
336 tegra_wm8903_dai.cpu_of_node = of_parse_phandle(np,
337 "nvidia,i2s-controller", 0);
338 if (!tegra_wm8903_dai.cpu_of_node) {
339 dev_err(&pdev->dev,
340 "Property 'nvidia,i2s-controller' missing or invalid\n");
341 ret = -EINVAL;
342 goto err;
343 }
344
345 tegra_wm8903_dai.platform_of_node = tegra_wm8903_dai.cpu_of_node;
346
Stephen Warren07cdf362011-12-12 15:55:36 -0700347 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
348 if (ret)
Stephen Warren518de862012-03-20 14:55:49 -0600349 goto err;
Stephen Warren07cdf362011-12-12 15:55:36 -0700350
Stephen Warren72de2b12011-01-28 14:26:36 -0700351 ret = snd_soc_register_card(card);
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700352 if (ret) {
Stephen Warren72de2b12011-01-28 14:26:36 -0700353 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700354 ret);
Stephen Warrenacb83032011-04-19 15:25:08 -0600355 goto err_fini_utils;
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700356 }
357
358 return 0;
359
Stephen Warrenacb83032011-04-19 15:25:08 -0600360err_fini_utils:
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600361 tegra_asoc_utils_fini(&machine->util_data);
Stephen Warrene4e4c182011-11-22 18:21:20 -0700362err:
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700363 return ret;
364}
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700365
Bill Pemberton4652a0d2012-12-07 09:26:33 -0500366static int tegra_wm8903_driver_remove(struct platform_device *pdev)
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700367{
Stephen Warren72de2b12011-01-28 14:26:36 -0700368 struct snd_soc_card *card = platform_get_drvdata(pdev);
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600369 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
Stephen Warren72de2b12011-01-28 14:26:36 -0700370
Stephen Warren29591ed2011-08-04 16:44:43 -0600371 snd_soc_unregister_card(card);
372
373 tegra_asoc_utils_fini(&machine->util_data);
Stephen Warren6e267642011-01-28 14:26:37 -0700374
Stephen Warren72de2b12011-01-28 14:26:36 -0700375 return 0;
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700376}
Stephen Warren72de2b12011-01-28 14:26:36 -0700377
Bill Pembertonf6e65742012-11-19 13:25:33 -0500378static const struct of_device_id tegra_wm8903_of_match[] = {
Stephen Warren07cdf362011-12-12 15:55:36 -0700379 { .compatible = "nvidia,tegra-audio-wm8903", },
380 {},
381};
382
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600383static struct platform_driver tegra_wm8903_driver = {
Stephen Warren72de2b12011-01-28 14:26:36 -0700384 .driver = {
385 .name = DRV_NAME,
Stephen Warrendeb26072011-04-05 19:35:30 -0600386 .pm = &snd_soc_pm_ops,
Stephen Warren07cdf362011-12-12 15:55:36 -0700387 .of_match_table = tegra_wm8903_of_match,
Stephen Warren72de2b12011-01-28 14:26:36 -0700388 },
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600389 .probe = tegra_wm8903_driver_probe,
Bill Pemberton4652a0d2012-12-07 09:26:33 -0500390 .remove = tegra_wm8903_driver_remove,
Stephen Warren72de2b12011-01-28 14:26:36 -0700391};
Stephen Warrene4e4c182011-11-22 18:21:20 -0700392module_platform_driver(tegra_wm8903_driver);
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700393
394MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
Stephen Warrendc0a50af2011-04-12 11:40:36 -0600395MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver");
Stephen Warrena8bf1ba2011-01-07 22:36:16 -0700396MODULE_LICENSE("GPL");
Stephen Warren8eb34202011-02-10 15:37:19 -0700397MODULE_ALIAS("platform:" DRV_NAME);
Stephen Warren07cdf362011-12-12 15:55:36 -0700398MODULE_DEVICE_TABLE(of, tegra_wm8903_of_match);