simple-card.c 17.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * ASoC simple sound card support
 *
 * Copyright (C) 2012 Renesas Solutions Corp.
 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
11
#include <linux/clk.h>
12
#include <linux/device.h>
13
#include <linux/gpio.h>
14
#include <linux/module.h>
15
#include <linux/of.h>
16
#include <linux/of_gpio.h>
17
#include <linux/platform_device.h>
18
#include <linux/string.h>
19
#include <sound/jack.h>
20
#include <sound/simple_card.h>
21 22
#include <sound/soc-dai.h>
#include <sound/soc.h>
23

24 25
struct simple_card_data {
	struct snd_soc_card snd_card;
26 27 28
	struct simple_dai_props {
		struct asoc_simple_dai cpu_dai;
		struct asoc_simple_dai codec_dai;
29
		unsigned int mclk_fs;
30
	} *dai_props;
31
	unsigned int mclk_fs;
32
	int gpio_hp_det;
33
	int gpio_hp_det_invert;
34
	int gpio_mic_det;
35
	int gpio_mic_det_invert;
36
	struct snd_soc_dai_link dai_link[];	/* dynamically allocated */
37 38
};

39
#define simple_priv_to_dev(priv) ((priv)->snd_card.dev)
40 41
#define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i)
#define simple_priv_to_props(priv, i) ((priv)->dai_props + i)
42

43 44
#define PREFIX	"simple-audio-card,"

45 46 47 48 49
static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
	struct simple_dai_props *dai_props =
50
		&priv->dai_props[rtd->num];
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
	int ret;

	ret = clk_prepare_enable(dai_props->cpu_dai.clk);
	if (ret)
		return ret;
	
	ret = clk_prepare_enable(dai_props->codec_dai.clk);
	if (ret)
		clk_disable_unprepare(dai_props->cpu_dai.clk);

	return ret;
}

static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
	struct simple_dai_props *dai_props =
69
		&priv->dai_props[rtd->num];
70 71 72 73 74 75

	clk_disable_unprepare(dai_props->cpu_dai.clk);

	clk_disable_unprepare(dai_props->codec_dai.clk);
}

76 77 78 79 80
static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
				      struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai = rtd->codec_dai;
81
	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
82
	struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
83
	struct simple_dai_props *dai_props = &priv->dai_props[rtd->num];
84
	unsigned int mclk, mclk_fs = 0;
85 86
	int ret = 0;

87 88 89 90 91 92 93
	if (priv->mclk_fs)
		mclk_fs = priv->mclk_fs;
	else if (dai_props->mclk_fs)
		mclk_fs = dai_props->mclk_fs;

	if (mclk_fs) {
		mclk = params_rate(params) * mclk_fs;
94 95
		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
					     SND_SOC_CLOCK_IN);
96 97 98 99 100 101 102
		if (ret && ret != -ENOTSUPP)
			goto err;

		ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
					     SND_SOC_CLOCK_OUT);
		if (ret && ret != -ENOTSUPP)
			goto err;
103
	}
104
	return 0;
105
err:
106 107 108 109
	return ret;
}

static struct snd_soc_ops asoc_simple_card_ops = {
110 111
	.startup = asoc_simple_card_startup,
	.shutdown = asoc_simple_card_shutdown,
112 113 114
	.hw_params = asoc_simple_card_hw_params,
};

115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
static struct snd_soc_jack simple_card_hp_jack;
static struct snd_soc_jack_pin simple_card_hp_jack_pins[] = {
	{
		.pin = "Headphones",
		.mask = SND_JACK_HEADPHONE,
	},
};
static struct snd_soc_jack_gpio simple_card_hp_jack_gpio = {
	.name = "Headphone detection",
	.report = SND_JACK_HEADPHONE,
	.debounce_time = 150,
};

static struct snd_soc_jack simple_card_mic_jack;
static struct snd_soc_jack_pin simple_card_mic_jack_pins[] = {
	{
		.pin = "Mic Jack",
		.mask = SND_JACK_MICROPHONE,
	},
};
static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = {
	.name = "Mic detection",
	.report = SND_JACK_MICROPHONE,
	.debounce_time = 150,
};

141
static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
142
				       struct asoc_simple_dai *set)
143
{
144
	int ret;
145

146
	if (set->sysclk) {
147
		ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
148 149 150 151 152 153
		if (ret && ret != -ENOTSUPP) {
			dev_err(dai->dev, "simple-card: set_sysclk error\n");
			goto err;
		}
	}

154
	if (set->slots) {
155 156 157
		ret = snd_soc_dai_set_tdm_slot(dai,
					       set->tx_slot_mask,
					       set->rx_slot_mask,
158 159 160 161 162 163 164 165
						set->slots,
						set->slot_width);
		if (ret && ret != -ENOTSUPP) {
			dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
			goto err;
		}
	}

166
	ret = 0;
167

168
err:
169 170 171
	return ret;
}

172 173
static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
{
174
	struct simple_card_data *priv =	snd_soc_card_get_drvdata(rtd->card);
175 176
	struct snd_soc_dai *codec = rtd->codec_dai;
	struct snd_soc_dai *cpu = rtd->cpu_dai;
177
	struct simple_dai_props *dai_props;
178
	int ret;
179

180
	dai_props = &priv->dai_props[rtd->num];
181
	ret = __asoc_simple_card_dai_init(codec, &dai_props->codec_dai);
182 183
	if (ret < 0)
		return ret;
184

185
	ret = __asoc_simple_card_dai_init(cpu, &dai_props->cpu_dai);
186 187
	if (ret < 0)
		return ret;
188

189
	if (gpio_is_valid(priv->gpio_hp_det)) {
190 191 192 193 194
		snd_soc_card_jack_new(rtd->card, "Headphones",
				      SND_JACK_HEADPHONE,
				      &simple_card_hp_jack,
				      simple_card_hp_jack_pins,
				      ARRAY_SIZE(simple_card_hp_jack_pins));
195 196

		simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det;
197
		simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert;
198 199 200 201 202
		snd_soc_jack_add_gpios(&simple_card_hp_jack, 1,
				       &simple_card_hp_jack_gpio);
	}

	if (gpio_is_valid(priv->gpio_mic_det)) {
203 204 205 206 207
		snd_soc_card_jack_new(rtd->card, "Mic Jack",
				      SND_JACK_MICROPHONE,
				      &simple_card_mic_jack,
				      simple_card_mic_jack_pins,
				      ARRAY_SIZE(simple_card_mic_jack_pins));
208
		simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det;
209
		simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert;
210 211 212
		snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
				       &simple_card_mic_jack_gpio);
	}
213 214 215
	return 0;
}

216 217 218
static int
asoc_simple_card_sub_parse_of(struct device_node *np,
			      struct asoc_simple_dai *dai,
219
			      struct device_node **p_node,
220 221
			      const char **name,
			      int *args_count)
222
{
223
	struct of_phandle_args args;
224
	struct clk *clk;
225
	u32 val;
226 227
	int ret;

228 229 230
	if (!np)
		return 0;

231
	/*
232
	 * Get node via "sound-dai = <&phandle port>"
233 234
	 * it will be used as xxx_of_node on soc_bind_dai_link()
	 */
235 236 237 238 239 240 241 242 243
	ret = of_parse_phandle_with_args(np, "sound-dai",
					 "#sound-dai-cells", 0, &args);
	if (ret)
		return ret;

	*p_node = args.np;

	if (args_count)
		*args_count = args.args_count;
244

245
	/* Get dai->name */
246 247 248 249 250 251 252 253
	if (name) {
		ret = snd_soc_of_get_dai_name(np, name);
		if (ret < 0)
			return ret;
	}

	if (!dai)
		return 0;
254

255
	/* Parse TDM slot */
256 257 258
	ret = snd_soc_of_parse_tdm_slot(np, &dai->tx_slot_mask,
					&dai->rx_slot_mask,
					&dai->slots, &dai->slot_width);
259
	if (ret)
260
		return ret;
261

262
	/*
263 264
	 * Parse dai->sysclk come from "clocks = <&xxx>"
	 * (if system has common clock)
265
	 *  or "system-clock-frequency = <xxx>"
266
	 *  or device's module clock.
267
	 */
268 269 270 271
	if (of_property_read_bool(np, "clocks")) {
		clk = of_clk_get(np, 0);
		if (IS_ERR(clk)) {
			ret = PTR_ERR(clk);
272
			return ret;
273 274 275
		}

		dai->sysclk = clk_get_rate(clk);
276
		dai->clk = clk;
277 278
	} else if (!of_property_read_u32(np, "system-clock-frequency", &val)) {
		dai->sysclk = val;
279
	} else {
280
		clk = of_clk_get(args.np, 0);
281 282
		if (!IS_ERR(clk))
			dai->sysclk = clk_get_rate(clk);
283
	}
284

285
	return 0;
286 287
}

288 289 290 291 292
static int asoc_simple_card_parse_daifmt(struct device_node *node,
					 struct simple_card_data *priv,
					 struct device_node *codec,
					 char *prefix, int idx)
{
293
	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
	struct device *dev = simple_priv_to_dev(priv);
	struct device_node *bitclkmaster = NULL;
	struct device_node *framemaster = NULL;
	unsigned int daifmt;

	daifmt = snd_soc_of_parse_daifmt(node, prefix,
					 &bitclkmaster, &framemaster);
	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;

	if (strlen(prefix) && !bitclkmaster && !framemaster) {
		/*
		 * No dai-link level and master setting was not found from
		 * sound node level, revert back to legacy DT parsing and
		 * take the settings from codec node.
		 */
		dev_dbg(dev, "Revert to legacy daifmt parsing\n");

311
		daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) |
312 313 314 315 316 317 318 319 320 321
			(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
	} else {
		if (codec == bitclkmaster)
			daifmt |= (codec == framemaster) ?
				SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
		else
			daifmt |= (codec == framemaster) ?
				SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
	}

322 323
	dai_link->dai_fmt = daifmt;

324 325 326 327 328 329
	of_node_put(bitclkmaster);
	of_node_put(framemaster);

	return 0;
}

330
static int asoc_simple_card_dai_link_of(struct device_node *node,
331
					struct simple_card_data *priv,
332
					int idx,
333
					bool is_top_level_node)
334
{
335
	struct device *dev = simple_priv_to_dev(priv);
336 337
	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, idx);
	struct simple_dai_props *dai_props = simple_priv_to_props(priv, idx);
338
	struct device_node *cpu = NULL;
339
	struct device_node *plat = NULL;
340
	struct device_node *codec = NULL;
341 342 343
	char *name;
	char prop[128];
	char *prefix = "";
344
	int ret, cpu_args;
345
	u32 val;
346

347
	/* For single DAI link & old style of DT node */
348
	if (is_top_level_node)
349
		prefix = PREFIX;
350 351

	snprintf(prop, sizeof(prop), "%scpu", prefix);
352 353
	cpu = of_get_child_by_name(node, prop);

354 355 356
	snprintf(prop, sizeof(prop), "%splat", prefix);
	plat = of_get_child_by_name(node, prop);

357 358 359 360
	snprintf(prop, sizeof(prop), "%scodec", prefix);
	codec = of_get_child_by_name(node, prop);

	if (!cpu || !codec) {
361
		ret = -EINVAL;
362
		dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop);
363
		goto dai_link_of_err;
364
	}
365

366
	ret = asoc_simple_card_parse_daifmt(node, priv,
367
					    codec, prefix, idx);
368 369 370
	if (ret < 0)
		goto dai_link_of_err;

371 372 373
	if (!of_property_read_u32(node, "mclk-fs", &val))
		dai_props->mclk_fs = val;

374
	ret = asoc_simple_card_sub_parse_of(cpu, &dai_props->cpu_dai,
375
					    &dai_link->cpu_of_node,
376 377
					    &dai_link->cpu_dai_name,
					    &cpu_args);
378
	if (ret < 0)
379 380
		goto dai_link_of_err;

381
	ret = asoc_simple_card_sub_parse_of(codec, &dai_props->codec_dai,
382
					    &dai_link->codec_of_node,
383
					    &dai_link->codec_dai_name, NULL);
384 385 386
	if (ret < 0)
		goto dai_link_of_err;

387 388 389 390 391 392
	ret = asoc_simple_card_sub_parse_of(plat, NULL,
					    &dai_link->platform_of_node,
					    NULL, NULL);
	if (ret < 0)
		goto dai_link_of_err;

393
	if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) {
394 395
		ret = -EINVAL;
		goto dai_link_of_err;
396 397
	}

398 399
	/* Assumes platform == cpu */
	if (!dai_link->platform_of_node)
400
		dai_link->platform_of_node = dai_link->cpu_of_node;
401

402
	/* DAI link name is created from CPU/CODEC dai name */
403 404 405 406
	name = devm_kzalloc(dev,
			    strlen(dai_link->cpu_dai_name)   +
			    strlen(dai_link->codec_dai_name) + 2,
			    GFP_KERNEL);
407 408 409 410 411
	if (!name) {
		ret = -ENOMEM;
		goto dai_link_of_err;
	}

412 413 414
	sprintf(name, "%s-%s", dai_link->cpu_dai_name,
				dai_link->codec_dai_name);
	dai_link->name = dai_link->stream_name = name;
415
	dai_link->ops = &asoc_simple_card_ops;
416
	dai_link->init = asoc_simple_card_dai_init;
417 418

	dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
419 420
	dev_dbg(dev, "\tformat : %04x\n", dai_link->dai_fmt);
	dev_dbg(dev, "\tcpu : %s / %d\n",
421 422
		dai_link->cpu_dai_name,
		dai_props->cpu_dai.sysclk);
423
	dev_dbg(dev, "\tcodec : %s / %d\n",
424 425 426
		dai_link->codec_dai_name,
		dai_props->codec_dai.sysclk);

427
	/*
428 429 430 431 432
	 * In soc_bind_dai_link() will check cpu name after
	 * of_node matching if dai_link has cpu_dai_name.
	 * but, it will never match if name was created by
	 * fmt_single_name() remove cpu_dai_name if cpu_args
	 * was 0. See:
433 434 435
	 *	fmt_single_name()
	 *	fmt_multiple_name()
	 */
436 437
	if (!cpu_args)
		dai_link->cpu_dai_name = NULL;
438

439
dai_link_of_err:
440 441 442
	of_node_put(cpu);
	of_node_put(codec);

443 444 445
	return ret;
}

446
static int asoc_simple_card_parse_of(struct device_node *node,
447
				     struct simple_card_data *priv)
448
{
449
	struct device *dev = simple_priv_to_dev(priv);
450
	enum of_gpio_flags flags;
451
	u32 val;
452
	int ret;
453

454 455 456
	if (!node)
		return -EINVAL;

457
	/* Parse the card name from DT */
458
	snd_soc_of_parse_card_name(&priv->snd_card, PREFIX "name");
459

460
	/* The off-codec widgets */
461
	if (of_property_read_bool(node, PREFIX "widgets")) {
462
		ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card,
463
					PREFIX "widgets");
464 465 466 467
		if (ret)
			return ret;
	}

468
	/* DAPM routes */
469
	if (of_property_read_bool(node, PREFIX "routing")) {
470
		ret = snd_soc_of_parse_audio_routing(&priv->snd_card,
471
					PREFIX "routing");
472 473 474
		if (ret)
			return ret;
	}
475

476
	/* Factor to mclk, used in hw_params() */
477
	ret = of_property_read_u32(node, PREFIX "mclk-fs", &val);
478 479
	if (ret == 0)
		priv->mclk_fs = val;
480

481 482 483
	dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ?
		priv->snd_card.name : "");

484
	/* Single/Muti DAI link(s) & New style of DT node */
485
	if (of_get_child_by_name(node, PREFIX "dai-link")) {
486
		struct device_node *np = NULL;
487 488 489
		int i = 0;

		for_each_child_of_node(node, np) {
490
			dev_dbg(dev, "\tlink %d:\n", i);
491
			ret = asoc_simple_card_dai_link_of(np, priv,
492
							   i, false);
493 494 495 496
			if (ret < 0) {
				of_node_put(np);
				return ret;
			}
497
			i++;
498
		}
499
	} else {
500
		/* For single DAI link & old style of DT node */
501
		ret = asoc_simple_card_dai_link_of(node, priv, 0, true);
502
		if (ret < 0)
503
			return ret;
504
	}
505

506
	priv->gpio_hp_det = of_get_named_gpio_flags(node,
507
				PREFIX "hp-det-gpio", 0, &flags);
508
	priv->gpio_hp_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW);
509 510 511
	if (priv->gpio_hp_det == -EPROBE_DEFER)
		return -EPROBE_DEFER;

512
	priv->gpio_mic_det = of_get_named_gpio_flags(node,
513
				PREFIX "mic-det-gpio", 0, &flags);
514
	priv->gpio_mic_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW);
515 516 517
	if (priv->gpio_mic_det == -EPROBE_DEFER)
		return -EPROBE_DEFER;

518
	if (!priv->snd_card.name)
519
		priv->snd_card.name = priv->snd_card.dai_link->name;
520

521 522 523
	return 0;
}

524
/* Decrease the reference count of the device nodes */
525
static int asoc_simple_card_unref(struct snd_soc_card *card)
526 527 528 529 530 531 532
{
	struct snd_soc_dai_link *dai_link;
	int num_links;

	for (num_links = 0, dai_link = card->dai_link;
	     num_links < card->num_links;
	     num_links++, dai_link++) {
533 534
		of_node_put(dai_link->cpu_of_node);
		of_node_put(dai_link->codec_of_node);
535 536 537 538
	}
	return 0;
}

539 540
static int asoc_simple_card_probe(struct platform_device *pdev)
{
541
	struct simple_card_data *priv;
542
	struct snd_soc_dai_link *dai_link;
543
	struct device_node *np = pdev->dev.of_node;
544
	struct device *dev = &pdev->dev;
545
	int num_links, ret;
546

547
	/* Get the number of DAI links */
548
	if (np && of_get_child_by_name(np, PREFIX "dai-link"))
549
		num_links = of_get_child_count(np);
550
	else
551
		num_links = 1;
552

553
	/* Allocate the private data and the DAI link array */
554
	priv = devm_kzalloc(dev,
555
			sizeof(*priv) + sizeof(*dai_link) * num_links,
556
			GFP_KERNEL);
557
	if (!priv)
558 559
		return -ENOMEM;

560
	/* Init snd_soc_card */
561 562
	priv->snd_card.owner = THIS_MODULE;
	priv->snd_card.dev = dev;
563
	dai_link = priv->dai_link;
564
	priv->snd_card.dai_link = dai_link;
565
	priv->snd_card.num_links = num_links;
566

567 568 569
	priv->gpio_hp_det = -ENOENT;
	priv->gpio_mic_det = -ENOENT;

570
	/* Get room for the other properties */
571
	priv->dai_props = devm_kzalloc(dev,
572
			sizeof(*priv->dai_props) * num_links,
573 574 575 576
			GFP_KERNEL);
	if (!priv->dai_props)
		return -ENOMEM;

577
	if (np && of_device_is_available(np)) {
578

579
		ret = asoc_simple_card_parse_of(np, priv);
580 581 582
		if (ret < 0) {
			if (ret != -EPROBE_DEFER)
				dev_err(dev, "parse error %d\n", ret);
583
			goto err;
584
		}
585

586
	} else {
587 588 589 590
		struct asoc_simple_card_info *cinfo;

		cinfo = dev->platform_data;
		if (!cinfo) {
591 592 593
			dev_err(dev, "no info for asoc-simple-card\n");
			return -EINVAL;
		}
594

595 596 597 598
		if (!cinfo->name ||
		    !cinfo->codec_dai.name ||
		    !cinfo->codec ||
		    !cinfo->platform ||
599 600 601 602
		    !cinfo->cpu_dai.name) {
			dev_err(dev, "insufficient asoc_simple_card_info settings\n");
			return -EINVAL;
		}
603

604
		priv->snd_card.name	= (cinfo->card) ? cinfo->card : cinfo->name;
605 606 607 608
		dai_link->name		= cinfo->name;
		dai_link->stream_name	= cinfo->name;
		dai_link->platform_name	= cinfo->platform;
		dai_link->codec_name	= cinfo->codec;
609 610
		dai_link->cpu_dai_name	= cinfo->cpu_dai.name;
		dai_link->codec_dai_name = cinfo->codec_dai.name;
611
		dai_link->dai_fmt	= cinfo->daifmt;
612
		dai_link->init		= asoc_simple_card_dai_init;
613 614 615 616
		memcpy(&priv->dai_props->cpu_dai, &cinfo->cpu_dai,
					sizeof(priv->dai_props->cpu_dai));
		memcpy(&priv->dai_props->codec_dai, &cinfo->codec_dai,
					sizeof(priv->dai_props->codec_dai));
617

618 619
	}

620
	snd_soc_card_set_drvdata(&priv->snd_card, priv);
621

622
	ret = devm_snd_soc_register_card(&pdev->dev, &priv->snd_card);
623 624
	if (ret >= 0)
		return ret;
625 626

err:
627
	asoc_simple_card_unref(&priv->snd_card);
628
	return ret;
629 630
}

631 632
static int asoc_simple_card_remove(struct platform_device *pdev)
{
633 634 635 636 637 638 639 640 641 642
	struct snd_soc_card *card = platform_get_drvdata(pdev);
	struct simple_card_data *priv = snd_soc_card_get_drvdata(card);

	if (gpio_is_valid(priv->gpio_hp_det))
		snd_soc_jack_free_gpios(&simple_card_hp_jack, 1,
					&simple_card_hp_jack_gpio);
	if (gpio_is_valid(priv->gpio_mic_det))
		snd_soc_jack_free_gpios(&simple_card_mic_jack, 1,
					&simple_card_mic_jack_gpio);

643
	return asoc_simple_card_unref(card);
644 645
}

646 647 648 649 650 651
static const struct of_device_id asoc_simple_of_match[] = {
	{ .compatible = "simple-audio-card", },
	{},
};
MODULE_DEVICE_TABLE(of, asoc_simple_of_match);

652 653
static struct platform_driver asoc_simple_card = {
	.driver = {
654
		.name = "asoc-simple-card",
655
		.pm = &snd_soc_pm_ops,
656
		.of_match_table = asoc_simple_of_match,
657
	},
658
	.probe = asoc_simple_card_probe,
659
	.remove = asoc_simple_card_remove,
660 661 662 663
};

module_platform_driver(asoc_simple_card);

664
MODULE_ALIAS("platform:asoc-simple-card");
665 666 667
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ASoC Simple Sound Card");
MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");