aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-01-10 03:29:11 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-10 07:19:39 -0500
commitbbf1453e28e4e3ee2cf5a0c34a20469b4d465f0f (patch)
tree3a7c8aa256103d0b183c3da76cc00f583012c7af /sound
parent9931faca02c604c22335f5a935a501bb2ace6e20 (diff)
ASoC: ak4642: add Device Tree support
Support for loading the ak4642 codec module via devicetree. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/ak4642.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 1f0cdab03294..c78794dc4b69 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -26,6 +26,7 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/of_device.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <sound/soc.h> 31#include <sound/soc.h>
31#include <sound/initval.h> 32#include <sound/initval.h>
@@ -513,12 +514,31 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4648 = {
513}; 514};
514 515
515#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 516#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
517static struct of_device_id ak4642_of_match[];
516static int ak4642_i2c_probe(struct i2c_client *i2c, 518static int ak4642_i2c_probe(struct i2c_client *i2c,
517 const struct i2c_device_id *id) 519 const struct i2c_device_id *id)
518{ 520{
521 struct device_node *np = i2c->dev.of_node;
522 const struct snd_soc_codec_driver *driver;
523
524 driver = NULL;
525 if (np) {
526 const struct of_device_id *of_id;
527
528 of_id = of_match_device(ak4642_of_match, &i2c->dev);
529 if (of_id)
530 driver = of_id->data;
531 } else {
532 driver = (struct snd_soc_codec_driver *)id->driver_data;
533 }
534
535 if (!driver) {
536 dev_err(&i2c->dev, "no driver\n");
537 return -EINVAL;
538 }
539
519 return snd_soc_register_codec(&i2c->dev, 540 return snd_soc_register_codec(&i2c->dev,
520 (struct snd_soc_codec_driver *)id->driver_data, 541 driver, &ak4642_dai, 1);
521 &ak4642_dai, 1);
522} 542}
523 543
524static int ak4642_i2c_remove(struct i2c_client *client) 544static int ak4642_i2c_remove(struct i2c_client *client)
@@ -527,6 +547,14 @@ static int ak4642_i2c_remove(struct i2c_client *client)
527 return 0; 547 return 0;
528} 548}
529 549
550static struct of_device_id ak4642_of_match[] __devinitconst = {
551 { .compatible = "asahi-kasei,ak4642", .data = &soc_codec_dev_ak4642},
552 { .compatible = "asahi-kasei,ak4643", .data = &soc_codec_dev_ak4642},
553 { .compatible = "asahi-kasei,ak4648", .data = &soc_codec_dev_ak4648},
554 {},
555};
556MODULE_DEVICE_TABLE(of, ak4642_of_match);
557
530static const struct i2c_device_id ak4642_i2c_id[] = { 558static const struct i2c_device_id ak4642_i2c_id[] = {
531 { "ak4642", (kernel_ulong_t)&soc_codec_dev_ak4642 }, 559 { "ak4642", (kernel_ulong_t)&soc_codec_dev_ak4642 },
532 { "ak4643", (kernel_ulong_t)&soc_codec_dev_ak4642 }, 560 { "ak4643", (kernel_ulong_t)&soc_codec_dev_ak4642 },
@@ -539,6 +567,7 @@ static struct i2c_driver ak4642_i2c_driver = {
539 .driver = { 567 .driver = {
540 .name = "ak4642-codec", 568 .name = "ak4642-codec",
541 .owner = THIS_MODULE, 569 .owner = THIS_MODULE,
570 .of_match_table = ak4642_of_match,
542 }, 571 },
543 .probe = ak4642_i2c_probe, 572 .probe = ak4642_i2c_probe,
544 .remove = ak4642_i2c_remove, 573 .remove = ak4642_i2c_remove,