aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-03-06 22:44:08 -0500
committerMark Brown <broonie@linaro.org>2014-03-09 03:38:22 -0400
commit22066226b50e40591d67aef1d5525abce7515df2 (patch)
treee42d822fbf02203c6a0831d832a71a95100884e3
parentf951f835a9719996e08e5c2932afc65ebfdbf47a (diff)
ASoC: pcm512x: Split out bus drivers
Move to the new style of defining the bus interfaces in separate modules in order to simplify dependencies. Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/codecs/Kconfig18
-rw-r--r--sound/soc/codecs/Makefile4
-rw-r--r--sound/soc/codecs/pcm512x-i2c.c71
-rw-r--r--sound/soc/codecs/pcm512x-spi.c69
-rw-r--r--sound/soc/codecs/pcm512x.c134
-rw-r--r--sound/soc/codecs/pcm512x.h9
6 files changed, 176 insertions, 129 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index fa47a8336be3..cebe3ceef4bd 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -59,7 +59,8 @@ config SND_SOC_ALL_CODECS
59 select SND_SOC_PCM1681 if I2C 59 select SND_SOC_PCM1681 if I2C
60 select SND_SOC_PCM1792A if SPI_MASTER 60 select SND_SOC_PCM1792A if SPI_MASTER
61 select SND_SOC_PCM3008 61 select SND_SOC_PCM3008
62 select SND_SOC_PCM512x if SND_SOC_I2C_AND_SPI 62 select SND_SOC_PCM512x_I2C if I2C
63 select SND_SOC_PCM512x_SPI if SPI_MASTER
63 select SND_SOC_RT5631 if I2C 64 select SND_SOC_RT5631 if I2C
64 select SND_SOC_RT5640 if I2C 65 select SND_SOC_RT5640 if I2C
65 select SND_SOC_SGTL5000 if I2C 66 select SND_SOC_SGTL5000 if I2C
@@ -315,8 +316,19 @@ config SND_SOC_PCM3008
315 tristate 316 tristate
316 317
317config SND_SOC_PCM512x 318config SND_SOC_PCM512x
318 tristate "Texas Instruments PCM512x CODECs" 319 tristate
319 select REGMAP 320
321config SND_SOC_PCM512x_I2C
322 tristate "Texas Instruments PCM512x CODECs - I2C"
323 depends on I2C
324 select SND_SOC_PCM512x
325 select REGMAP_I2C
326
327config SND_SOC_PCM512x_SPI
328 tristate "Texas Instruments PCM512x CODECs - SPI"
329 depends on SPI_MASTER
330 select SND_SOC_PCM512x
331 select REGMAP_SPI
320 332
321config SND_SOC_RT5631 333config SND_SOC_RT5631
322 tristate 334 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index d3b536fc075d..c1191c05c88e 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -47,6 +47,8 @@ snd-soc-pcm1681-objs := pcm1681.o
47snd-soc-pcm1792a-codec-objs := pcm1792a.o 47snd-soc-pcm1792a-codec-objs := pcm1792a.o
48snd-soc-pcm3008-objs := pcm3008.o 48snd-soc-pcm3008-objs := pcm3008.o
49snd-soc-pcm512x-objs := pcm512x.o 49snd-soc-pcm512x-objs := pcm512x.o
50snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
51snd-soc-pcm512x-spi-objs := pcm512x-spi.o
50snd-soc-rt5631-objs := rt5631.o 52snd-soc-rt5631-objs := rt5631.o
51snd-soc-rt5640-objs := rt5640.o 53snd-soc-rt5640-objs := rt5640.o
52snd-soc-sgtl5000-objs := sgtl5000.o 54snd-soc-sgtl5000-objs := sgtl5000.o
@@ -181,6 +183,8 @@ obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o
181obj-$(CONFIG_SND_SOC_PCM1792A) += snd-soc-pcm1792a-codec.o 183obj-$(CONFIG_SND_SOC_PCM1792A) += snd-soc-pcm1792a-codec.o
182obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o 184obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
183obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o 185obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o
186obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o
187obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o
184obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o 188obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
185obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o 189obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o
186obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o 190obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
diff --git a/sound/soc/codecs/pcm512x-i2c.c b/sound/soc/codecs/pcm512x-i2c.c
new file mode 100644
index 000000000000..4d62230bd378
--- /dev/null
+++ b/sound/soc/codecs/pcm512x-i2c.c
@@ -0,0 +1,71 @@
1/*
2 * Driver for the PCM512x CODECs
3 *
4 * Author: Mark Brown <broonie@linaro.org>
5 * Copyright 2014 Linaro Ltd
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17#include <linux/init.h>
18#include <linux/module.h>
19#include <linux/i2c.h>
20
21#include "pcm512x.h"
22
23static int pcm512x_i2c_probe(struct i2c_client *i2c,
24 const struct i2c_device_id *id)
25{
26 struct regmap *regmap;
27
28 regmap = devm_regmap_init_i2c(i2c, &pcm512x_regmap);
29 if (IS_ERR(regmap))
30 return PTR_ERR(regmap);
31
32 return pcm512x_probe(&i2c->dev, regmap);
33}
34
35static int pcm512x_i2c_remove(struct i2c_client *i2c)
36{
37 pcm512x_remove(&i2c->dev);
38 return 0;
39}
40
41static const struct i2c_device_id pcm512x_i2c_id[] = {
42 { "pcm5121", },
43 { "pcm5122", },
44 { }
45};
46MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
47
48static const struct of_device_id pcm512x_of_match[] = {
49 { .compatible = "ti,pcm5121", },
50 { .compatible = "ti,pcm5122", },
51 { }
52};
53MODULE_DEVICE_TABLE(of, pcm512x_of_match);
54
55static struct i2c_driver pcm512x_i2c_driver = {
56 .probe = pcm512x_i2c_probe,
57 .remove = pcm512x_i2c_remove,
58 .id_table = pcm512x_i2c_id,
59 .driver = {
60 .name = "pcm512x",
61 .owner = THIS_MODULE,
62 .of_match_table = pcm512x_of_match,
63 .pm = &pcm512x_pm_ops,
64 },
65};
66
67module_i2c_driver(pcm512x_i2c_driver);
68
69MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C");
70MODULE_AUTHOR("Mark Brown <broonie@linaro.org>");
71MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/pcm512x-spi.c b/sound/soc/codecs/pcm512x-spi.c
new file mode 100644
index 000000000000..f297058c0038
--- /dev/null
+++ b/sound/soc/codecs/pcm512x-spi.c
@@ -0,0 +1,69 @@
1/*
2 * Driver for the PCM512x CODECs
3 *
4 * Author: Mark Brown <broonie@linaro.org>
5 * Copyright 2014 Linaro Ltd
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17#include <linux/init.h>
18#include <linux/module.h>
19#include <linux/spi/spi.h>
20
21#include "pcm512x.h"
22
23static int pcm512x_spi_probe(struct spi_device *spi)
24{
25 struct regmap *regmap;
26 int ret;
27
28 regmap = devm_regmap_init_spi(spi, &pcm512x_regmap);
29 if (IS_ERR(regmap)) {
30 ret = PTR_ERR(regmap);
31 return ret;
32 }
33
34 return pcm512x_probe(&spi->dev, regmap);
35}
36
37static int pcm512x_spi_remove(struct spi_device *spi)
38{
39 pcm512x_remove(&spi->dev);
40 return 0;
41}
42
43static const struct spi_device_id pcm512x_spi_id[] = {
44 { "pcm5121", },
45 { "pcm5122", },
46 { },
47};
48MODULE_DEVICE_TABLE(spi, pcm512x_spi_id);
49
50static const struct of_device_id pcm512x_of_match[] = {
51 { .compatible = "ti,pcm5121", },
52 { .compatible = "ti,pcm5122", },
53 { }
54};
55MODULE_DEVICE_TABLE(of, pcm512x_of_match);
56
57static struct spi_driver pcm512x_spi_driver = {
58 .probe = pcm512x_spi_probe,
59 .remove = pcm512x_spi_remove,
60 .id_table = pcm512x_spi_id,
61 .driver = {
62 .name = "pcm512x",
63 .owner = THIS_MODULE,
64 .of_match_table = pcm512x_of_match,
65 .pm = &pcm512x_pm_ops,
66 },
67};
68
69module_spi_driver(pcm512x_spi_driver);
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 3a0bbb6ab242..0c907051cc7b 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -18,11 +18,9 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/i2c.h>
22#include <linux/pm_runtime.h> 21#include <linux/pm_runtime.h>
23#include <linux/regmap.h> 22#include <linux/regmap.h>
24#include <linux/regulator/consumer.h> 23#include <linux/regulator/consumer.h>
25#include <linux/spi/spi.h>
26#include <sound/soc.h> 24#include <sound/soc.h>
27#include <sound/soc-dapm.h> 25#include <sound/soc-dapm.h>
28#include <sound/tlv.h> 26#include <sound/tlv.h>
@@ -375,7 +373,7 @@ static const struct regmap_range_cfg pcm512x_range = {
375 .window_start = 0, .window_len = 0x100, 373 .window_start = 0, .window_len = 0x100,
376}; 374};
377 375
378static const struct regmap_config pcm512x_regmap = { 376const struct regmap_config pcm512x_regmap = {
379 .reg_bits = 8, 377 .reg_bits = 8,
380 .val_bits = 8, 378 .val_bits = 8,
381 379
@@ -390,15 +388,9 @@ static const struct regmap_config pcm512x_regmap = {
390 .num_reg_defaults = ARRAY_SIZE(pcm512x_reg_defaults), 388 .num_reg_defaults = ARRAY_SIZE(pcm512x_reg_defaults),
391 .cache_type = REGCACHE_RBTREE, 389 .cache_type = REGCACHE_RBTREE,
392}; 390};
391EXPORT_SYMBOL_GPL(pcm512x_regmap);
393 392
394static const struct of_device_id pcm512x_of_match[] = { 393int pcm512x_probe(struct device *dev, struct regmap *regmap)
395 { .compatible = "ti,pcm5121", },
396 { .compatible = "ti,pcm5122", },
397 { }
398};
399MODULE_DEVICE_TABLE(of, pcm512x_of_match);
400
401static int pcm512x_probe(struct device *dev, struct regmap *regmap)
402{ 394{
403 struct pcm512x_priv *pcm512x; 395 struct pcm512x_priv *pcm512x;
404 int i, ret; 396 int i, ret;
@@ -510,8 +502,9 @@ err:
510 pcm512x->supplies); 502 pcm512x->supplies);
511 return ret; 503 return ret;
512} 504}
505EXPORT_SYMBOL_GPL(pcm512x_probe);
513 506
514static void pcm512x_remove(struct device *dev) 507void pcm512x_remove(struct device *dev)
515{ 508{
516 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); 509 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev);
517 510
@@ -522,6 +515,7 @@ static void pcm512x_remove(struct device *dev)
522 regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), 515 regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies),
523 pcm512x->supplies); 516 pcm512x->supplies);
524} 517}
518EXPORT_SYMBOL_GPL(pcm512x_remove);
525 519
526static int pcm512x_suspend(struct device *dev) 520static int pcm512x_suspend(struct device *dev)
527{ 521{
@@ -585,122 +579,10 @@ static int pcm512x_resume(struct device *dev)
585 return 0; 579 return 0;
586} 580}
587 581
588static const struct dev_pm_ops pcm512x_pm_ops = { 582const struct dev_pm_ops pcm512x_pm_ops = {
589 SET_RUNTIME_PM_OPS(pcm512x_suspend, pcm512x_resume, NULL) 583 SET_RUNTIME_PM_OPS(pcm512x_suspend, pcm512x_resume, NULL)
590}; 584};
591 585EXPORT_SYMBOL_GPL(pcm512x_pm_ops);
592#if IS_ENABLED(CONFIG_I2C)
593static int pcm512x_i2c_probe(struct i2c_client *i2c,
594 const struct i2c_device_id *id)
595{
596 struct regmap *regmap;
597
598 regmap = devm_regmap_init_i2c(i2c, &pcm512x_regmap);
599 if (IS_ERR(regmap))
600 return PTR_ERR(regmap);
601
602 return pcm512x_probe(&i2c->dev, regmap);
603}
604
605static int pcm512x_i2c_remove(struct i2c_client *i2c)
606{
607 pcm512x_remove(&i2c->dev);
608 return 0;
609}
610
611static const struct i2c_device_id pcm512x_i2c_id[] = {
612 { "pcm5121", },
613 { "pcm5122", },
614 { }
615};
616MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
617
618static struct i2c_driver pcm512x_i2c_driver = {
619 .probe = pcm512x_i2c_probe,
620 .remove = pcm512x_i2c_remove,
621 .id_table = pcm512x_i2c_id,
622 .driver = {
623 .name = "pcm512x",
624 .owner = THIS_MODULE,
625 .of_match_table = pcm512x_of_match,
626 .pm = &pcm512x_pm_ops,
627 },
628};
629#endif
630
631#if defined(CONFIG_SPI_MASTER)
632static int pcm512x_spi_probe(struct spi_device *spi)
633{
634 struct regmap *regmap;
635 int ret;
636
637 regmap = devm_regmap_init_spi(spi, &pcm512x_regmap);
638 if (IS_ERR(regmap)) {
639 ret = PTR_ERR(regmap);
640 return ret;
641 }
642
643 return pcm512x_probe(&spi->dev, regmap);
644}
645
646static int pcm512x_spi_remove(struct spi_device *spi)
647{
648 pcm512x_remove(&spi->dev);
649 return 0;
650}
651
652static const struct spi_device_id pcm512x_spi_id[] = {
653 { "pcm5121", },
654 { "pcm5122", },
655 { },
656};
657MODULE_DEVICE_TABLE(spi, pcm512x_spi_id);
658
659static struct spi_driver pcm512x_spi_driver = {
660 .probe = pcm512x_spi_probe,
661 .remove = pcm512x_spi_remove,
662 .id_table = pcm512x_spi_id,
663 .driver = {
664 .name = "pcm512x",
665 .owner = THIS_MODULE,
666 .of_match_table = pcm512x_of_match,
667 .pm = &pcm512x_pm_ops,
668 },
669};
670#endif
671
672static int __init pcm512x_modinit(void)
673{
674 int ret = 0;
675
676#if IS_ENABLED(CONFIG_I2C)
677 ret = i2c_add_driver(&pcm512x_i2c_driver);
678 if (ret) {
679 printk(KERN_ERR "Failed to register pcm512x I2C driver: %d\n",
680 ret);
681 }
682#endif
683#if defined(CONFIG_SPI_MASTER)
684 ret = spi_register_driver(&pcm512x_spi_driver);
685 if (ret != 0) {
686 printk(KERN_ERR "Failed to register pcm512x SPI driver: %d\n",
687 ret);
688 }
689#endif
690 return ret;
691}
692module_init(pcm512x_modinit);
693
694static void __exit pcm512x_exit(void)
695{
696#if IS_ENABLED(CONFIG_I2C)
697 i2c_del_driver(&pcm512x_i2c_driver);
698#endif
699#if defined(CONFIG_SPI_MASTER)
700 spi_unregister_driver(&pcm512x_spi_driver);
701#endif
702}
703module_exit(pcm512x_exit);
704 586
705MODULE_DESCRIPTION("ASoC PCM512x codec driver"); 587MODULE_DESCRIPTION("ASoC PCM512x codec driver");
706MODULE_AUTHOR("Mark Brown <broonie@linaro.org>"); 588MODULE_AUTHOR("Mark Brown <broonie@linaro.org>");
diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h
index ac4a52c9ccf4..6ee76aaca09a 100644
--- a/sound/soc/codecs/pcm512x.h
+++ b/sound/soc/codecs/pcm512x.h
@@ -17,6 +17,9 @@
17#ifndef _SND_SOC_PCM512X 17#ifndef _SND_SOC_PCM512X
18#define _SND_SOC_PCM512X 18#define _SND_SOC_PCM512X
19 19
20#include <linux/pm.h>
21#include <linux/regmap.h>
22
20#define PCM512x_VIRT_BASE 0x100 23#define PCM512x_VIRT_BASE 0x100
21#define PCM512x_PAGE_LEN 0x100 24#define PCM512x_PAGE_LEN 0x100
22#define PCM512x_PAGE_BASE(n) (PCM512x_VIRT_BASE + (PCM512x_PAGE_LEN * n)) 25#define PCM512x_PAGE_BASE(n) (PCM512x_VIRT_BASE + (PCM512x_PAGE_LEN * n))
@@ -159,4 +162,10 @@
159#define PCM512x_AGBR_SHIFT 0 162#define PCM512x_AGBR_SHIFT 0
160#define PCM512x_AGBL_SHIFT 4 163#define PCM512x_AGBL_SHIFT 4
161 164
165extern const struct dev_pm_ops pcm512x_pm_ops;
166extern const struct regmap_config pcm512x_regmap;
167
168int pcm512x_probe(struct device *dev, struct regmap *regmap);
169void pcm512x_remove(struct device *dev);
170
162#endif 171#endif