aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZidan Wang <b50113@freescale.com>2014-11-27 03:53:08 -0500
committerMark Brown <broonie@kernel.org>2014-11-27 05:35:02 -0500
commit3ad5e861a715cbe932cd145d4612c11e5912a72f (patch)
tree8b3cfeee58ce932668c9dbeb64cb051a1ac80b21
parent0a87a6e1c09c3b93d91bf65809e79cf6cf358785 (diff)
ASoC: wm8960: Move register initialisation to I2C driver probe()
We must ensure that the clocking configuration is valid as rapidly as possible. And do software reset before the others registers updates, or the registers will be reset to the default state. Signed-off-by: Zidan Wang <b50113@freescale.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm8960.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index bc8793cd1d72..031a1ae71d94 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -128,7 +128,7 @@ struct wm8960_priv {
128 struct wm8960_data pdata; 128 struct wm8960_data pdata;
129}; 129};
130 130
131#define wm8960_reset(c) snd_soc_write(c, WM8960_RESET, 0) 131#define wm8960_reset(c) regmap_write(c, WM8960_RESET, 0)
132 132
133/* enumerated controls */ 133/* enumerated controls */
134static const char *wm8960_polarity[] = {"No Inversion", "Left Inverted", 134static const char *wm8960_polarity[] = {"No Inversion", "Left Inverted",
@@ -947,31 +947,12 @@ static int wm8960_probe(struct snd_soc_codec *codec)
947{ 947{
948 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 948 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
949 struct wm8960_data *pdata = &wm8960->pdata; 949 struct wm8960_data *pdata = &wm8960->pdata;
950 int ret;
951 950
952 if (pdata->capless) 951 if (pdata->capless)
953 wm8960->set_bias_level = wm8960_set_bias_level_capless; 952 wm8960->set_bias_level = wm8960_set_bias_level_capless;
954 else 953 else
955 wm8960->set_bias_level = wm8960_set_bias_level_out3; 954 wm8960->set_bias_level = wm8960_set_bias_level_out3;
956 955
957 ret = wm8960_reset(codec);
958 if (ret < 0) {
959 dev_err(codec->dev, "Failed to issue reset\n");
960 return ret;
961 }
962
963 /* Latch the update bits */
964 snd_soc_update_bits(codec, WM8960_LINVOL, 0x100, 0x100);
965 snd_soc_update_bits(codec, WM8960_RINVOL, 0x100, 0x100);
966 snd_soc_update_bits(codec, WM8960_LADC, 0x100, 0x100);
967 snd_soc_update_bits(codec, WM8960_RADC, 0x100, 0x100);
968 snd_soc_update_bits(codec, WM8960_LDAC, 0x100, 0x100);
969 snd_soc_update_bits(codec, WM8960_RDAC, 0x100, 0x100);
970 snd_soc_update_bits(codec, WM8960_LOUT1, 0x100, 0x100);
971 snd_soc_update_bits(codec, WM8960_ROUT1, 0x100, 0x100);
972 snd_soc_update_bits(codec, WM8960_LOUT2, 0x100, 0x100);
973 snd_soc_update_bits(codec, WM8960_ROUT2, 0x100, 0x100);
974
975 snd_soc_add_codec_controls(codec, wm8960_snd_controls, 956 snd_soc_add_codec_controls(codec, wm8960_snd_controls,
976 ARRAY_SIZE(wm8960_snd_controls)); 957 ARRAY_SIZE(wm8960_snd_controls));
977 wm8960_add_widgets(codec); 958 wm8960_add_widgets(codec);
@@ -1030,7 +1011,13 @@ static int wm8960_i2c_probe(struct i2c_client *i2c,
1030 else if (i2c->dev.of_node) 1011 else if (i2c->dev.of_node)
1031 wm8960_set_pdata_from_of(i2c, &wm8960->pdata); 1012 wm8960_set_pdata_from_of(i2c, &wm8960->pdata);
1032 1013
1033 if (pdata && pdata->shared_lrclk) { 1014 ret = wm8960_reset(wm8960->regmap);
1015 if (ret != 0) {
1016 dev_err(&i2c->dev, "Failed to issue reset\n");
1017 return ret;
1018 }
1019
1020 if (wm8960->pdata.shared_lrclk) {
1034 ret = regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 1021 ret = regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2,
1035 0x4, 0x4); 1022 0x4, 0x4);
1036 if (ret != 0) { 1023 if (ret != 0) {
@@ -1040,6 +1027,18 @@ static int wm8960_i2c_probe(struct i2c_client *i2c,
1040 } 1027 }
1041 } 1028 }
1042 1029
1030 /* Latch the update bits */
1031 regmap_update_bits(wm8960->regmap, WM8960_LINVOL, 0x100, 0x100);
1032 regmap_update_bits(wm8960->regmap, WM8960_RINVOL, 0x100, 0x100);
1033 regmap_update_bits(wm8960->regmap, WM8960_LADC, 0x100, 0x100);
1034 regmap_update_bits(wm8960->regmap, WM8960_RADC, 0x100, 0x100);
1035 regmap_update_bits(wm8960->regmap, WM8960_LDAC, 0x100, 0x100);
1036 regmap_update_bits(wm8960->regmap, WM8960_RDAC, 0x100, 0x100);
1037 regmap_update_bits(wm8960->regmap, WM8960_LOUT1, 0x100, 0x100);
1038 regmap_update_bits(wm8960->regmap, WM8960_ROUT1, 0x100, 0x100);
1039 regmap_update_bits(wm8960->regmap, WM8960_LOUT2, 0x100, 0x100);
1040 regmap_update_bits(wm8960->regmap, WM8960_ROUT2, 0x100, 0x100);
1041
1043 i2c_set_clientdata(i2c, wm8960); 1042 i2c_set_clientdata(i2c, wm8960);
1044 1043
1045 ret = snd_soc_register_codec(&i2c->dev, 1044 ret = snd_soc_register_codec(&i2c->dev,