aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@gmail.com>2015-02-22 11:43:21 -0500
committerMark Brown <broonie@kernel.org>2015-03-04 20:05:54 -0500
commitbbed297d373471c8e4c3183bf67472a768576664 (patch)
tree051fecdb7719d685d2cedc670af1ec9a00c57af8
parentc517d838eb7d07bbe9507871fab3931deccff539 (diff)
ASoC: wm8804: Split out bus drivers
Simplify dependencies by using new style split out bus interfaces. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/Kconfig18
-rw-r--r--sound/soc/codecs/Makefile4
-rw-r--r--sound/soc/codecs/wm8804-i2c.c64
-rw-r--r--sound/soc/codecs/wm8804-spi.c56
-rw-r--r--sound/soc/codecs/wm8804.c139
-rw-r--r--sound/soc/codecs/wm8804.h7
6 files changed, 162 insertions, 126 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 064e6c18e109..1d17988df796 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -141,7 +141,8 @@ config SND_SOC_ALL_CODECS
141 select SND_SOC_WM8770 if SPI_MASTER 141 select SND_SOC_WM8770 if SPI_MASTER
142 select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI 142 select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI
143 select SND_SOC_WM8782 143 select SND_SOC_WM8782
144 select SND_SOC_WM8804 if SND_SOC_I2C_AND_SPI 144 select SND_SOC_WM8804_I2C if I2C
145 select SND_SOC_WM8804_SPI if SPI_MASTER
145 select SND_SOC_WM8900 if I2C 146 select SND_SOC_WM8900 if I2C
146 select SND_SOC_WM8903 if I2C 147 select SND_SOC_WM8903 if I2C
147 select SND_SOC_WM8904 if I2C 148 select SND_SOC_WM8904 if I2C
@@ -744,8 +745,19 @@ config SND_SOC_WM8782
744 tristate 745 tristate
745 746
746config SND_SOC_WM8804 747config SND_SOC_WM8804
747 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver" 748 tristate
748 depends on SND_SOC_I2C_AND_SPI 749
750config SND_SOC_WM8804_I2C
751 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver I2C"
752 depends on I2C
753 select SND_SOC_WM8804
754 select REGMAP_I2C
755
756config SND_SOC_WM8804_SPI
757 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver SPI"
758 depends on SPI_MASTER
759 select SND_SOC_WM8804
760 select REGMAP_SPI
749 761
750config SND_SOC_WM8900 762config SND_SOC_WM8900
751 tristate 763 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 69b8666d187a..7acb6c174cb4 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -145,6 +145,8 @@ snd-soc-wm8770-objs := wm8770.o
145snd-soc-wm8776-objs := wm8776.o 145snd-soc-wm8776-objs := wm8776.o
146snd-soc-wm8782-objs := wm8782.o 146snd-soc-wm8782-objs := wm8782.o
147snd-soc-wm8804-objs := wm8804.o 147snd-soc-wm8804-objs := wm8804.o
148snd-soc-wm8804-i2c-objs := wm8804-i2c.o
149snd-soc-wm8804-spi-objs := wm8804-spi.o
148snd-soc-wm8900-objs := wm8900.o 150snd-soc-wm8900-objs := wm8900.o
149snd-soc-wm8903-objs := wm8903.o 151snd-soc-wm8903-objs := wm8903.o
150snd-soc-wm8904-objs := wm8904.o 152snd-soc-wm8904-objs := wm8904.o
@@ -323,6 +325,8 @@ obj-$(CONFIG_SND_SOC_WM8770) += snd-soc-wm8770.o
323obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o 325obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o
324obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o 326obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o
325obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o 327obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o
328obj-$(CONFIG_SND_SOC_WM8804_I2C) += snd-soc-wm8804-i2c.o
329obj-$(CONFIG_SND_SOC_WM8804_SPI) += snd-soc-wm8804-spi.o
326obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o 330obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o
327obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o 331obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o
328obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o 332obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o
diff --git a/sound/soc/codecs/wm8804-i2c.c b/sound/soc/codecs/wm8804-i2c.c
new file mode 100644
index 000000000000..5bd4af2b4059
--- /dev/null
+++ b/sound/soc/codecs/wm8804-i2c.c
@@ -0,0 +1,64 @@
1/*
2 * wm8804-i2c.c -- WM8804 S/PDIF transceiver driver - I2C
3 *
4 * Copyright 2015 Cirrus Logic Inc
5 *
6 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/i2c.h>
16
17#include "wm8804.h"
18
19static int wm8804_i2c_probe(struct i2c_client *i2c,
20 const struct i2c_device_id *id)
21{
22 struct regmap *regmap;
23
24 regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config);
25 if (IS_ERR(regmap))
26 return PTR_ERR(regmap);
27
28 return wm8804_probe(&i2c->dev, regmap);
29}
30
31static int wm8804_i2c_remove(struct i2c_client *i2c)
32{
33 wm8804_remove(&i2c->dev);
34 return 0;
35}
36
37static const struct i2c_device_id wm8804_i2c_id[] = {
38 { "wm8804", 0 },
39 { }
40};
41MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
42
43static const struct of_device_id wm8804_of_match[] = {
44 { .compatible = "wlf,wm8804", },
45 { }
46};
47MODULE_DEVICE_TABLE(of, wm8804_of_match);
48
49static struct i2c_driver wm8804_i2c_driver = {
50 .driver = {
51 .name = "wm8804",
52 .owner = THIS_MODULE,
53 .of_match_table = wm8804_of_match,
54 },
55 .probe = wm8804_i2c_probe,
56 .remove = wm8804_i2c_remove,
57 .id_table = wm8804_i2c_id
58};
59
60module_i2c_driver(wm8804_i2c_driver);
61
62MODULE_DESCRIPTION("ASoC WM8804 driver - I2C");
63MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
64MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8804-spi.c b/sound/soc/codecs/wm8804-spi.c
new file mode 100644
index 000000000000..287e11e90794
--- /dev/null
+++ b/sound/soc/codecs/wm8804-spi.c
@@ -0,0 +1,56 @@
1/*
2 * wm8804-spi.c -- WM8804 S/PDIF transceiver driver - SPI
3 *
4 * Copyright 2015 Cirrus Logic Inc
5 *
6 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/spi/spi.h>
16
17#include "wm8804.h"
18
19static int wm8804_spi_probe(struct spi_device *spi)
20{
21 struct regmap *regmap;
22
23 regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config);
24 if (IS_ERR(regmap))
25 return PTR_ERR(regmap);
26
27 return wm8804_probe(&spi->dev, regmap);
28}
29
30static int wm8804_spi_remove(struct spi_device *spi)
31{
32 wm8804_remove(&spi->dev);
33 return 0;
34}
35
36static const struct of_device_id wm8804_of_match[] = {
37 { .compatible = "wlf,wm8804", },
38 { }
39};
40MODULE_DEVICE_TABLE(of, wm8804_of_match);
41
42static struct spi_driver wm8804_spi_driver = {
43 .driver = {
44 .name = "wm8804",
45 .owner = THIS_MODULE,
46 .of_match_table = wm8804_of_match,
47 },
48 .probe = wm8804_spi_probe,
49 .remove = wm8804_spi_remove
50};
51
52module_spi_driver(wm8804_spi_driver);
53
54MODULE_DESCRIPTION("ASoC WM8804 driver - SPI");
55MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
56MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index b2b0e68f707e..b5a04fc5060f 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -15,10 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/i2c.h>
19#include <linux/of_device.h> 18#include <linux/of_device.h>
20#include <linux/spi/spi.h>
21#include <linux/regmap.h>
22#include <linux/regulator/consumer.h> 19#include <linux/regulator/consumer.h>
23#include <linux/slab.h> 20#include <linux/slab.h>
24#include <sound/core.h> 21#include <sound/core.h>
@@ -518,7 +515,7 @@ static int wm8804_set_bias_level(struct snd_soc_codec *codec,
518 return 0; 515 return 0;
519} 516}
520 517
521static int wm8804_remove(struct snd_soc_codec *codec) 518static int wm8804_codec_remove(struct snd_soc_codec *codec)
522{ 519{
523 struct wm8804_priv *wm8804; 520 struct wm8804_priv *wm8804;
524 int i; 521 int i;
@@ -531,7 +528,7 @@ static int wm8804_remove(struct snd_soc_codec *codec)
531 return 0; 528 return 0;
532} 529}
533 530
534static int wm8804_probe(struct snd_soc_codec *codec) 531static int wm8804_codec_probe(struct snd_soc_codec *codec)
535{ 532{
536 struct wm8804_priv *wm8804; 533 struct wm8804_priv *wm8804;
537 int i, id1, id2, ret; 534 int i, id1, id2, ret;
@@ -649,8 +646,8 @@ static struct snd_soc_dai_driver wm8804_dai = {
649}; 646};
650 647
651static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { 648static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
652 .probe = wm8804_probe, 649 .probe = wm8804_codec_probe,
653 .remove = wm8804_remove, 650 .remove = wm8804_codec_remove,
654 .set_bias_level = wm8804_set_bias_level, 651 .set_bias_level = wm8804_set_bias_level,
655 .idle_bias_off = true, 652 .idle_bias_off = true,
656 653
@@ -658,13 +655,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
658 .num_controls = ARRAY_SIZE(wm8804_snd_controls), 655 .num_controls = ARRAY_SIZE(wm8804_snd_controls),
659}; 656};
660 657
661static const struct of_device_id wm8804_of_match[] = { 658const struct regmap_config wm8804_regmap_config = {
662 { .compatible = "wlf,wm8804", },
663 { }
664};
665MODULE_DEVICE_TABLE(of, wm8804_of_match);
666
667static const struct regmap_config wm8804_regmap_config = {
668 .reg_bits = 8, 659 .reg_bits = 8,
669 .val_bits = 8, 660 .val_bits = 8,
670 661
@@ -675,128 +666,30 @@ static const struct regmap_config wm8804_regmap_config = {
675 .reg_defaults = wm8804_reg_defaults, 666 .reg_defaults = wm8804_reg_defaults,
676 .num_reg_defaults = ARRAY_SIZE(wm8804_reg_defaults), 667 .num_reg_defaults = ARRAY_SIZE(wm8804_reg_defaults),
677}; 668};
669EXPORT_SYMBOL_GPL(wm8804_regmap_config);
678 670
679#if defined(CONFIG_SPI_MASTER) 671int wm8804_probe(struct device *dev, struct regmap *regmap)
680static int wm8804_spi_probe(struct spi_device *spi)
681{ 672{
682 struct wm8804_priv *wm8804; 673 struct wm8804_priv *wm8804;
683 int ret;
684 674
685 wm8804 = devm_kzalloc(&spi->dev, sizeof *wm8804, GFP_KERNEL); 675 wm8804 = devm_kzalloc(dev, sizeof(*wm8804), GFP_KERNEL);
686 if (!wm8804) 676 if (!wm8804)
687 return -ENOMEM; 677 return -ENOMEM;
688 678
689 wm8804->regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config); 679 dev_set_drvdata(dev, wm8804);
690 if (IS_ERR(wm8804->regmap)) {
691 ret = PTR_ERR(wm8804->regmap);
692 return ret;
693 }
694
695 spi_set_drvdata(spi, wm8804);
696 680
697 ret = snd_soc_register_codec(&spi->dev, 681 wm8804->regmap = regmap;
698 &soc_codec_dev_wm8804, &wm8804_dai, 1);
699
700 return ret;
701}
702
703static int wm8804_spi_remove(struct spi_device *spi)
704{
705 snd_soc_unregister_codec(&spi->dev);
706 return 0;
707}
708
709static struct spi_driver wm8804_spi_driver = {
710 .driver = {
711 .name = "wm8804",
712 .owner = THIS_MODULE,
713 .of_match_table = wm8804_of_match,
714 },
715 .probe = wm8804_spi_probe,
716 .remove = wm8804_spi_remove
717};
718#endif
719
720#if IS_ENABLED(CONFIG_I2C)
721static int wm8804_i2c_probe(struct i2c_client *i2c,
722 const struct i2c_device_id *id)
723{
724 struct wm8804_priv *wm8804;
725 int ret;
726
727 wm8804 = devm_kzalloc(&i2c->dev, sizeof *wm8804, GFP_KERNEL);
728 if (!wm8804)
729 return -ENOMEM;
730 682
731 wm8804->regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config); 683 return snd_soc_register_codec(dev, &soc_codec_dev_wm8804,
732 if (IS_ERR(wm8804->regmap)) { 684 &wm8804_dai, 1);
733 ret = PTR_ERR(wm8804->regmap);
734 return ret;
735 }
736
737 i2c_set_clientdata(i2c, wm8804);
738
739 ret = snd_soc_register_codec(&i2c->dev,
740 &soc_codec_dev_wm8804, &wm8804_dai, 1);
741 return ret;
742}
743
744static int wm8804_i2c_remove(struct i2c_client *i2c)
745{
746 snd_soc_unregister_codec(&i2c->dev);
747 return 0;
748}
749
750static const struct i2c_device_id wm8804_i2c_id[] = {
751 { "wm8804", 0 },
752 { }
753};
754MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
755
756static struct i2c_driver wm8804_i2c_driver = {
757 .driver = {
758 .name = "wm8804",
759 .owner = THIS_MODULE,
760 .of_match_table = wm8804_of_match,
761 },
762 .probe = wm8804_i2c_probe,
763 .remove = wm8804_i2c_remove,
764 .id_table = wm8804_i2c_id
765};
766#endif
767
768static int __init wm8804_modinit(void)
769{
770 int ret = 0;
771
772#if IS_ENABLED(CONFIG_I2C)
773 ret = i2c_add_driver(&wm8804_i2c_driver);
774 if (ret) {
775 printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
776 ret);
777 }
778#endif
779#if defined(CONFIG_SPI_MASTER)
780 ret = spi_register_driver(&wm8804_spi_driver);
781 if (ret != 0) {
782 printk(KERN_ERR "Failed to register wm8804 SPI driver: %d\n",
783 ret);
784 }
785#endif
786 return ret;
787} 685}
788module_init(wm8804_modinit); 686EXPORT_SYMBOL_GPL(wm8804_probe);
789 687
790static void __exit wm8804_exit(void) 688void wm8804_remove(struct device *dev)
791{ 689{
792#if IS_ENABLED(CONFIG_I2C) 690 snd_soc_unregister_codec(dev);
793 i2c_del_driver(&wm8804_i2c_driver);
794#endif
795#if defined(CONFIG_SPI_MASTER)
796 spi_unregister_driver(&wm8804_spi_driver);
797#endif
798} 691}
799module_exit(wm8804_exit); 692EXPORT_SYMBOL_GPL(wm8804_remove);
800 693
801MODULE_DESCRIPTION("ASoC WM8804 driver"); 694MODULE_DESCRIPTION("ASoC WM8804 driver");
802MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>"); 695MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm8804.h b/sound/soc/codecs/wm8804.h
index e72d4f4ba6b1..a39a2563dc67 100644
--- a/sound/soc/codecs/wm8804.h
+++ b/sound/soc/codecs/wm8804.h
@@ -13,6 +13,8 @@
13#ifndef _WM8804_H 13#ifndef _WM8804_H
14#define _WM8804_H 14#define _WM8804_H
15 15
16#include <linux/regmap.h>
17
16/* 18/*
17 * Register values. 19 * Register values.
18 */ 20 */
@@ -62,4 +64,9 @@
62#define WM8804_MCLKDIV_256FS 0 64#define WM8804_MCLKDIV_256FS 0
63#define WM8804_MCLKDIV_128FS 1 65#define WM8804_MCLKDIV_128FS 1
64 66
67extern const struct regmap_config wm8804_regmap_config;
68
69int wm8804_probe(struct device *dev, struct regmap *regmap);
70void wm8804_remove(struct device *dev);
71
65#endif /* _WM8804_H */ 72#endif /* _WM8804_H */