aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-09 10:22:28 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-09 10:22:28 -0500
commit13100628881a329f0cc78461b4330bb79d067c07 (patch)
treea290f2f48a22959ad4cf4a6cc204795dd111df2f /sound/soc
parent59b4cd42f2c96f5c9bf3947f28e3d2ac0148fbcc (diff)
parented79edac0df2ec7c4f48698997dc4e457d34ec06 (diff)
Merge remote-tracking branch 'asoc/topic/wm8750' into asoc-next
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/wm8750.c86
1 files changed, 66 insertions, 20 deletions
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 89151ca5e776..7665d68c4558 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/regmap.h>
21#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/of_device.h> 24#include <linux/of_device.h>
@@ -34,24 +35,55 @@
34 * We can't read the WM8750 register space when we 35 * We can't read the WM8750 register space when we
35 * are using 2 wire for device control, so we cache them instead. 36 * are using 2 wire for device control, so we cache them instead.
36 */ 37 */
37static const u16 wm8750_reg[] = { 38static const struct reg_default wm8750_reg_defaults[] = {
38 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */ 39 { 0, 0x0097 },
39 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */ 40 { 1, 0x0097 },
40 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */ 41 { 2, 0x0079 },
41 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */ 42 { 3, 0x0079 },
42 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */ 43 { 4, 0x0000 },
43 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */ 44 { 5, 0x0008 },
44 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */ 45 { 6, 0x0000 },
45 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */ 46 { 7, 0x000a },
46 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */ 47 { 8, 0x0000 },
47 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */ 48 { 9, 0x0000 },
48 0x0079, 0x0079, 0x0079, /* 40 */ 49 { 10, 0x00ff },
50 { 11, 0x00ff },
51 { 12, 0x000f },
52 { 13, 0x000f },
53 { 14, 0x0000 },
54 { 15, 0x0000 },
55 { 16, 0x0000 },
56 { 17, 0x007b },
57 { 18, 0x0000 },
58 { 19, 0x0032 },
59 { 20, 0x0000 },
60 { 21, 0x00c3 },
61 { 22, 0x00c3 },
62 { 23, 0x00c0 },
63 { 24, 0x0000 },
64 { 25, 0x0000 },
65 { 26, 0x0000 },
66 { 27, 0x0000 },
67 { 28, 0x0000 },
68 { 29, 0x0000 },
69 { 30, 0x0000 },
70 { 31, 0x0000 },
71 { 32, 0x0000 },
72 { 33, 0x0000 },
73 { 34, 0x0050 },
74 { 35, 0x0050 },
75 { 36, 0x0050 },
76 { 37, 0x0050 },
77 { 38, 0x0050 },
78 { 39, 0x0050 },
79 { 40, 0x0079 },
80 { 41, 0x0079 },
81 { 42, 0x0079 },
49}; 82};
50 83
51/* codec private data */ 84/* codec private data */
52struct wm8750_priv { 85struct wm8750_priv {
53 unsigned int sysclk; 86 unsigned int sysclk;
54 enum snd_soc_control_type control_type;
55}; 87};
56 88
57#define wm8750_reset(c) snd_soc_write(c, WM8750_RESET, 0) 89#define wm8750_reset(c) snd_soc_write(c, WM8750_RESET, 0)
@@ -668,10 +700,9 @@ static int wm8750_resume(struct snd_soc_codec *codec)
668 700
669static int wm8750_probe(struct snd_soc_codec *codec) 701static int wm8750_probe(struct snd_soc_codec *codec)
670{ 702{
671 struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec);
672 int ret; 703 int ret;
673 704
674 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8750->control_type); 705 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
675 if (ret < 0) { 706 if (ret < 0) {
676 printk(KERN_ERR "wm8750: failed to set cache I/O: %d\n", ret); 707 printk(KERN_ERR "wm8750: failed to set cache I/O: %d\n", ret);
677 return ret; 708 return ret;
@@ -711,9 +742,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8750 = {
711 .suspend = wm8750_suspend, 742 .suspend = wm8750_suspend,
712 .resume = wm8750_resume, 743 .resume = wm8750_resume,
713 .set_bias_level = wm8750_set_bias_level, 744 .set_bias_level = wm8750_set_bias_level,
714 .reg_cache_size = ARRAY_SIZE(wm8750_reg),
715 .reg_word_size = sizeof(u16),
716 .reg_cache_default = wm8750_reg,
717 745
718 .controls = wm8750_snd_controls, 746 .controls = wm8750_snd_controls,
719 .num_controls = ARRAY_SIZE(wm8750_snd_controls), 747 .num_controls = ARRAY_SIZE(wm8750_snd_controls),
@@ -730,10 +758,21 @@ static const struct of_device_id wm8750_of_match[] = {
730}; 758};
731MODULE_DEVICE_TABLE(of, wm8750_of_match); 759MODULE_DEVICE_TABLE(of, wm8750_of_match);
732 760
761static const struct regmap_config wm8750_regmap = {
762 .reg_bits = 7,
763 .val_bits = 9,
764 .max_register = WM8750_MOUTV,
765
766 .reg_defaults = wm8750_reg_defaults,
767 .num_reg_defaults = ARRAY_SIZE(wm8750_reg_defaults),
768 .cache_type = REGCACHE_RBTREE,
769};
770
733#if defined(CONFIG_SPI_MASTER) 771#if defined(CONFIG_SPI_MASTER)
734static int __devinit wm8750_spi_probe(struct spi_device *spi) 772static int __devinit wm8750_spi_probe(struct spi_device *spi)
735{ 773{
736 struct wm8750_priv *wm8750; 774 struct wm8750_priv *wm8750;
775 struct regmap *regmap;
737 int ret; 776 int ret;
738 777
739 wm8750 = devm_kzalloc(&spi->dev, sizeof(struct wm8750_priv), 778 wm8750 = devm_kzalloc(&spi->dev, sizeof(struct wm8750_priv),
@@ -741,7 +780,10 @@ static int __devinit wm8750_spi_probe(struct spi_device *spi)
741 if (wm8750 == NULL) 780 if (wm8750 == NULL)
742 return -ENOMEM; 781 return -ENOMEM;
743 782
744 wm8750->control_type = SND_SOC_SPI; 783 regmap = devm_regmap_init_spi(spi, &wm8750_regmap);
784 if (IS_ERR(regmap))
785 return PTR_ERR(regmap);
786
745 spi_set_drvdata(spi, wm8750); 787 spi_set_drvdata(spi, wm8750);
746 788
747 ret = snd_soc_register_codec(&spi->dev, 789 ret = snd_soc_register_codec(&spi->dev,
@@ -779,6 +821,7 @@ static __devinit int wm8750_i2c_probe(struct i2c_client *i2c,
779 const struct i2c_device_id *id) 821 const struct i2c_device_id *id)
780{ 822{
781 struct wm8750_priv *wm8750; 823 struct wm8750_priv *wm8750;
824 struct regmap *regmap;
782 int ret; 825 int ret;
783 826
784 wm8750 = devm_kzalloc(&i2c->dev, sizeof(struct wm8750_priv), 827 wm8750 = devm_kzalloc(&i2c->dev, sizeof(struct wm8750_priv),
@@ -787,7 +830,10 @@ static __devinit int wm8750_i2c_probe(struct i2c_client *i2c,
787 return -ENOMEM; 830 return -ENOMEM;
788 831
789 i2c_set_clientdata(i2c, wm8750); 832 i2c_set_clientdata(i2c, wm8750);
790 wm8750->control_type = SND_SOC_I2C; 833
834 regmap = devm_regmap_init_i2c(i2c, &wm8750_regmap);
835 if (IS_ERR(regmap))
836 return PTR_ERR(regmap);
791 837
792 ret = snd_soc_register_codec(&i2c->dev, 838 ret = snd_soc_register_codec(&i2c->dev,
793 &soc_codec_dev_wm8750, &wm8750_dai, 1); 839 &soc_codec_dev_wm8750, &wm8750_dai, 1);