aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/atmel/tse850-pcm5142.c4
-rw-r--r--sound/soc/codecs/ak4613.c2
-rw-r--r--sound/soc/codecs/cs35l35.c10
-rw-r--r--sound/soc/codecs/da7219-aad.c31
-rw-r--r--sound/soc/codecs/da7219.c53
-rw-r--r--sound/soc/codecs/da7219.h5
-rw-r--r--sound/soc/soc-compress.c6
7 files changed, 80 insertions, 31 deletions
diff --git a/sound/soc/atmel/tse850-pcm5142.c b/sound/soc/atmel/tse850-pcm5142.c
index a72c7d642026..3a1393283156 100644
--- a/sound/soc/atmel/tse850-pcm5142.c
+++ b/sound/soc/atmel/tse850-pcm5142.c
@@ -227,7 +227,7 @@ int tse850_put_ana(struct snd_kcontrol *kctrl,
227static const char * const mux_text[] = { "Mixer", "Loop" }; 227static const char * const mux_text[] = { "Mixer", "Loop" };
228 228
229static const struct soc_enum mux_enum = 229static const struct soc_enum mux_enum =
230 SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, mux_text); 230 SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(mux_text), mux_text);
231 231
232static const struct snd_kcontrol_new mux1 = 232static const struct snd_kcontrol_new mux1 =
233 SOC_DAPM_ENUM_EXT("MUX1", mux_enum, tse850_get_mux1, tse850_put_mux1); 233 SOC_DAPM_ENUM_EXT("MUX1", mux_enum, tse850_get_mux1, tse850_put_mux1);
@@ -252,7 +252,7 @@ static const char * const ana_text[] = {
252}; 252};
253 253
254static const struct soc_enum ana_enum = 254static const struct soc_enum ana_enum =
255 SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 9, ana_text); 255 SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(ana_text), ana_text);
256 256
257static const struct snd_kcontrol_new out = 257static const struct snd_kcontrol_new out =
258 SOC_DAPM_ENUM_EXT("ANA", ana_enum, tse850_get_ana, tse850_put_ana); 258 SOC_DAPM_ENUM_EXT("ANA", ana_enum, tse850_get_ana, tse850_put_ana);
diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c
index b2dfddead227..987918628d5b 100644
--- a/sound/soc/codecs/ak4613.c
+++ b/sound/soc/codecs/ak4613.c
@@ -345,7 +345,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
345 if (ak4613_dai_fmt_matching(priv->iface, is_play, fmt, width)) 345 if (ak4613_dai_fmt_matching(priv->iface, is_play, fmt, width))
346 iface = priv->iface; 346 iface = priv->iface;
347 } else { 347 } else {
348 for (i = ARRAY_SIZE(ak4613_iface); i >= 0; i--) { 348 for (i = ARRAY_SIZE(ak4613_iface) - 1; i >= 0; i--) {
349 if (!ak4613_dai_fmt_matching(ak4613_iface + i, 349 if (!ak4613_dai_fmt_matching(ak4613_iface + i,
350 is_play, 350 is_play,
351 fmt, width)) 351 fmt, width))
diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c
index f8aef5869b03..5ff12e4116e5 100644
--- a/sound/soc/codecs/cs35l35.c
+++ b/sound/soc/codecs/cs35l35.c
@@ -162,6 +162,14 @@ static bool cs35l35_precious_register(struct device *dev, unsigned int reg)
162 } 162 }
163} 163}
164 164
165static void cs35l35_reset(struct cs35l35_private *cs35l35)
166{
167 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0);
168 usleep_range(2000, 2100);
169 gpiod_set_value_cansleep(cs35l35->reset_gpio, 1);
170 usleep_range(1000, 1100);
171}
172
165static int cs35l35_wait_for_pdn(struct cs35l35_private *cs35l35) 173static int cs35l35_wait_for_pdn(struct cs35l35_private *cs35l35)
166{ 174{
167 int ret; 175 int ret;
@@ -1454,7 +1462,7 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
1454 } 1462 }
1455 } 1463 }
1456 1464
1457 gpiod_set_value_cansleep(cs35l35->reset_gpio, 1); 1465 cs35l35_reset(cs35l35);
1458 1466
1459 init_completion(&cs35l35->pdn_done); 1467 init_completion(&cs35l35->pdn_done);
1460 1468
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
index 6274d79c1353..1d1d10dd92ae 100644
--- a/sound/soc/codecs/da7219-aad.c
+++ b/sound/soc/codecs/da7219-aad.c
@@ -115,19 +115,21 @@ static void da7219_aad_hptest_work(struct work_struct *work)
115 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 115 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
116 116
117 u16 tonegen_freq_hptest; 117 u16 tonegen_freq_hptest;
118 u8 pll_srm_sts, gain_ramp_ctrl, accdet_cfg8; 118 u8 pll_srm_sts, pll_ctrl, gain_ramp_ctrl, accdet_cfg8;
119 int report = 0, ret = 0; 119 int report = 0, ret = 0;
120 120
121 /* Lock DAPM and any Kcontrols that are affected by this test */ 121 /* Lock DAPM, Kcontrols affected by this test and the PLL */
122 snd_soc_dapm_mutex_lock(dapm); 122 snd_soc_dapm_mutex_lock(dapm);
123 mutex_lock(&da7219->lock); 123 mutex_lock(&da7219->ctrl_lock);
124 mutex_lock(&da7219->pll_lock);
124 125
125 /* Ensure MCLK is available for HP test procedure */ 126 /* Ensure MCLK is available for HP test procedure */
126 if (da7219->mclk) { 127 if (da7219->mclk) {
127 ret = clk_prepare_enable(da7219->mclk); 128 ret = clk_prepare_enable(da7219->mclk);
128 if (ret) { 129 if (ret) {
129 dev_err(codec->dev, "Failed to enable mclk - %d\n", ret); 130 dev_err(codec->dev, "Failed to enable mclk - %d\n", ret);
130 mutex_unlock(&da7219->lock); 131 mutex_unlock(&da7219->pll_lock);
132 mutex_unlock(&da7219->ctrl_lock);
131 snd_soc_dapm_mutex_unlock(dapm); 133 snd_soc_dapm_mutex_unlock(dapm);
132 return; 134 return;
133 } 135 }
@@ -136,12 +138,21 @@ static void da7219_aad_hptest_work(struct work_struct *work)
136 /* 138 /*
137 * If MCLK not present, then we're using the internal oscillator and 139 * If MCLK not present, then we're using the internal oscillator and
138 * require different frequency settings to achieve the same result. 140 * require different frequency settings to achieve the same result.
141 *
142 * If MCLK is present, but PLL is not enabled then we enable it here to
143 * ensure a consistent detection procedure.
139 */ 144 */
140 pll_srm_sts = snd_soc_read(codec, DA7219_PLL_SRM_STS); 145 pll_srm_sts = snd_soc_read(codec, DA7219_PLL_SRM_STS);
141 if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) 146 if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) {
142 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ); 147 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ);
143 else 148
149 pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL);
150 if ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS)
151 da7219_set_pll(codec, DA7219_SYSCLK_PLL,
152 DA7219_PLL_FREQ_OUT_98304);
153 } else {
144 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC); 154 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC);
155 }
145 156
146 /* Ensure gain ramping at fastest rate */ 157 /* Ensure gain ramping at fastest rate */
147 gain_ramp_ctrl = snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); 158 gain_ramp_ctrl = snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL);
@@ -302,11 +313,17 @@ static void da7219_aad_hptest_work(struct work_struct *work)
302 snd_soc_update_bits(codec, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, 313 snd_soc_update_bits(codec, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK,
303 DA7219_HP_R_AMP_OE_MASK); 314 DA7219_HP_R_AMP_OE_MASK);
304 315
316 /* Restore PLL to previous configuration, if re-configured */
317 if ((pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) &&
318 ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS))
319 da7219_set_pll(codec, DA7219_SYSCLK_MCLK, 0);
320
305 /* Remove MCLK, if previously enabled */ 321 /* Remove MCLK, if previously enabled */
306 if (da7219->mclk) 322 if (da7219->mclk)
307 clk_disable_unprepare(da7219->mclk); 323 clk_disable_unprepare(da7219->mclk);
308 324
309 mutex_unlock(&da7219->lock); 325 mutex_unlock(&da7219->pll_lock);
326 mutex_unlock(&da7219->ctrl_lock);
310 snd_soc_dapm_mutex_unlock(dapm); 327 snd_soc_dapm_mutex_unlock(dapm);
311 328
312 /* 329 /*
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 99601627f83c..f71d72c22bfc 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -260,9 +260,9 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol,
260 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 260 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
261 int ret; 261 int ret;
262 262
263 mutex_lock(&da7219->lock); 263 mutex_lock(&da7219->ctrl_lock);
264 ret = snd_soc_get_volsw(kcontrol, ucontrol); 264 ret = snd_soc_get_volsw(kcontrol, ucontrol);
265 mutex_unlock(&da7219->lock); 265 mutex_unlock(&da7219->ctrl_lock);
266 266
267 return ret; 267 return ret;
268} 268}
@@ -274,9 +274,9 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
274 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 274 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
275 int ret; 275 int ret;
276 276
277 mutex_lock(&da7219->lock); 277 mutex_lock(&da7219->ctrl_lock);
278 ret = snd_soc_put_volsw(kcontrol, ucontrol); 278 ret = snd_soc_put_volsw(kcontrol, ucontrol);
279 mutex_unlock(&da7219->lock); 279 mutex_unlock(&da7219->ctrl_lock);
280 280
281 return ret; 281 return ret;
282} 282}
@@ -288,9 +288,9 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
288 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 288 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
289 int ret; 289 int ret;
290 290
291 mutex_lock(&da7219->lock); 291 mutex_lock(&da7219->ctrl_lock);
292 ret = snd_soc_get_enum_double(kcontrol, ucontrol); 292 ret = snd_soc_get_enum_double(kcontrol, ucontrol);
293 mutex_unlock(&da7219->lock); 293 mutex_unlock(&da7219->ctrl_lock);
294 294
295 return ret; 295 return ret;
296} 296}
@@ -302,9 +302,9 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
302 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 302 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
303 int ret; 303 int ret;
304 304
305 mutex_lock(&da7219->lock); 305 mutex_lock(&da7219->ctrl_lock);
306 ret = snd_soc_put_enum_double(kcontrol, ucontrol); 306 ret = snd_soc_put_enum_double(kcontrol, ucontrol);
307 mutex_unlock(&da7219->lock); 307 mutex_unlock(&da7219->ctrl_lock);
308 308
309 return ret; 309 return ret;
310} 310}
@@ -424,9 +424,9 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol,
424 u16 val; 424 u16 val;
425 int ret; 425 int ret;
426 426
427 mutex_lock(&da7219->lock); 427 mutex_lock(&da7219->ctrl_lock);
428 ret = regmap_raw_read(da7219->regmap, reg, &val, sizeof(val)); 428 ret = regmap_raw_read(da7219->regmap, reg, &val, sizeof(val));
429 mutex_unlock(&da7219->lock); 429 mutex_unlock(&da7219->ctrl_lock);
430 430
431 if (ret) 431 if (ret)
432 return ret; 432 return ret;
@@ -458,9 +458,9 @@ static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol,
458 */ 458 */
459 val = cpu_to_le16(ucontrol->value.integer.value[0]); 459 val = cpu_to_le16(ucontrol->value.integer.value[0]);
460 460
461 mutex_lock(&da7219->lock); 461 mutex_lock(&da7219->ctrl_lock);
462 ret = regmap_raw_write(da7219->regmap, reg, &val, sizeof(val)); 462 ret = regmap_raw_write(da7219->regmap, reg, &val, sizeof(val));
463 mutex_unlock(&da7219->lock); 463 mutex_unlock(&da7219->ctrl_lock);
464 464
465 return ret; 465 return ret;
466} 466}
@@ -801,7 +801,7 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w,
801 ++i; 801 ++i;
802 msleep(50); 802 msleep(50);
803 } 803 }
804 } while ((i < DA7219_SRM_CHECK_RETRIES) && (!srm_lock)); 804 } while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock));
805 805
806 if (!srm_lock) 806 if (!srm_lock)
807 dev_warn(codec->dev, "SRM failed to lock\n"); 807 dev_warn(codec->dev, "SRM failed to lock\n");
@@ -1129,6 +1129,8 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1129 return -EINVAL; 1129 return -EINVAL;
1130 } 1130 }
1131 1131
1132 mutex_lock(&da7219->pll_lock);
1133
1132 switch (clk_id) { 1134 switch (clk_id) {
1133 case DA7219_CLKSRC_MCLK_SQR: 1135 case DA7219_CLKSRC_MCLK_SQR:
1134 snd_soc_update_bits(codec, DA7219_PLL_CTRL, 1136 snd_soc_update_bits(codec, DA7219_PLL_CTRL,
@@ -1141,6 +1143,7 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1141 break; 1143 break;
1142 default: 1144 default:
1143 dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id); 1145 dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id);
1146 mutex_unlock(&da7219->pll_lock);
1144 return -EINVAL; 1147 return -EINVAL;
1145 } 1148 }
1146 1149
@@ -1152,19 +1155,20 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1152 if (ret) { 1155 if (ret) {
1153 dev_err(codec_dai->dev, "Failed to set clock rate %d\n", 1156 dev_err(codec_dai->dev, "Failed to set clock rate %d\n",
1154 freq); 1157 freq);
1158 mutex_unlock(&da7219->pll_lock);
1155 return ret; 1159 return ret;
1156 } 1160 }
1157 } 1161 }
1158 1162
1159 da7219->mclk_rate = freq; 1163 da7219->mclk_rate = freq;
1160 1164
1165 mutex_unlock(&da7219->pll_lock);
1166
1161 return 0; 1167 return 0;
1162} 1168}
1163 1169
1164static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 1170int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
1165 int source, unsigned int fref, unsigned int fout)
1166{ 1171{
1167 struct snd_soc_codec *codec = codec_dai->codec;
1168 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 1172 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
1169 1173
1170 u8 pll_ctrl, indiv_bits, indiv; 1174 u8 pll_ctrl, indiv_bits, indiv;
@@ -1237,6 +1241,20 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1237 return 0; 1241 return 0;
1238} 1242}
1239 1243
1244static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1245 int source, unsigned int fref, unsigned int fout)
1246{
1247 struct snd_soc_codec *codec = codec_dai->codec;
1248 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
1249 int ret;
1250
1251 mutex_lock(&da7219->pll_lock);
1252 ret = da7219_set_pll(codec, source, fout);
1253 mutex_unlock(&da7219->pll_lock);
1254
1255 return ret;
1256}
1257
1240static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 1258static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1241{ 1259{
1242 struct snd_soc_codec *codec = codec_dai->codec; 1260 struct snd_soc_codec *codec = codec_dai->codec;
@@ -1741,7 +1759,8 @@ static int da7219_probe(struct snd_soc_codec *codec)
1741 unsigned int rev; 1759 unsigned int rev;
1742 int ret; 1760 int ret;
1743 1761
1744 mutex_init(&da7219->lock); 1762 mutex_init(&da7219->ctrl_lock);
1763 mutex_init(&da7219->pll_lock);
1745 1764
1746 /* Regulator configuration */ 1765 /* Regulator configuration */
1747 ret = da7219_handle_supplies(codec); 1766 ret = da7219_handle_supplies(codec);
diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h
index 6baba7455fa1..8d6c3c8c8026 100644
--- a/sound/soc/codecs/da7219.h
+++ b/sound/soc/codecs/da7219.h
@@ -810,7 +810,8 @@ struct da7219_priv {
810 bool wakeup_source; 810 bool wakeup_source;
811 struct regulator_bulk_data supplies[DA7219_NUM_SUPPLIES]; 811 struct regulator_bulk_data supplies[DA7219_NUM_SUPPLIES];
812 struct regmap *regmap; 812 struct regmap *regmap;
813 struct mutex lock; 813 struct mutex ctrl_lock;
814 struct mutex pll_lock;
814 815
815 struct clk *mclk; 816 struct clk *mclk;
816 unsigned int mclk_rate; 817 unsigned int mclk_rate;
@@ -821,4 +822,6 @@ struct da7219_priv {
821 u8 gain_ramp_ctrl; 822 u8 gain_ramp_ctrl;
822}; 823};
823 824
825int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout);
826
824#endif /* __DA7219_H */ 827#endif /* __DA7219_H */
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index bfd71b873ca2..206f36bf43e8 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -81,7 +81,8 @@ out:
81static int soc_compr_open_fe(struct snd_compr_stream *cstream) 81static int soc_compr_open_fe(struct snd_compr_stream *cstream)
82{ 82{
83 struct snd_soc_pcm_runtime *fe = cstream->private_data; 83 struct snd_soc_pcm_runtime *fe = cstream->private_data;
84 struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; 84 struct snd_pcm_substream *fe_substream =
85 fe->pcm->streams[cstream->direction].substream;
85 struct snd_soc_platform *platform = fe->platform; 86 struct snd_soc_platform *platform = fe->platform;
86 struct snd_soc_dai *cpu_dai = fe->cpu_dai; 87 struct snd_soc_dai *cpu_dai = fe->cpu_dai;
87 struct snd_soc_dpcm *dpcm; 88 struct snd_soc_dpcm *dpcm;
@@ -467,7 +468,8 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
467 struct snd_compr_params *params) 468 struct snd_compr_params *params)
468{ 469{
469 struct snd_soc_pcm_runtime *fe = cstream->private_data; 470 struct snd_soc_pcm_runtime *fe = cstream->private_data;
470 struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; 471 struct snd_pcm_substream *fe_substream =
472 fe->pcm->streams[cstream->direction].substream;
471 struct snd_soc_platform *platform = fe->platform; 473 struct snd_soc_platform *platform = fe->platform;
472 struct snd_soc_dai *cpu_dai = fe->cpu_dai; 474 struct snd_soc_dai *cpu_dai = fe->cpu_dai;
473 int ret = 0, stream; 475 int ret = 0, stream;