aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/sgtl5000.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/sgtl5000.c')
-rw-r--r--sound/soc/codecs/sgtl5000.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index e997d271728d..6bb77d76561b 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -626,6 +626,9 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
626 } else { 626 } else {
627 dev_err(codec->dev, 627 dev_err(codec->dev,
628 "PLL not supported in slave mode\n"); 628 "PLL not supported in slave mode\n");
629 dev_err(codec->dev, "%d ratio is not supported. "
630 "SYS_MCLK needs to be 256, 384 or 512 * fs\n",
631 sgtl5000->sysclk / sys_fs);
629 return -EINVAL; 632 return -EINVAL;
630 } 633 }
631 } 634 }
@@ -1073,26 +1076,6 @@ static bool sgtl5000_readable(struct device *dev, unsigned int reg)
1073 } 1076 }
1074} 1077}
1075 1078
1076#ifdef CONFIG_SUSPEND
1077static int sgtl5000_suspend(struct snd_soc_codec *codec)
1078{
1079 sgtl5000_set_bias_level(codec, SND_SOC_BIAS_OFF);
1080
1081 return 0;
1082}
1083
1084static int sgtl5000_resume(struct snd_soc_codec *codec)
1085{
1086 /* Bring the codec back up to standby to enable regulators */
1087 sgtl5000_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1088
1089 return 0;
1090}
1091#else
1092#define sgtl5000_suspend NULL
1093#define sgtl5000_resume NULL
1094#endif /* CONFIG_SUSPEND */
1095
1096/* 1079/*
1097 * sgtl5000 has 3 internal power supplies: 1080 * sgtl5000 has 3 internal power supplies:
1098 * 1. VAG, normally set to vdda/2 1081 * 1. VAG, normally set to vdda/2
@@ -1352,11 +1335,6 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
1352 */ 1335 */
1353 snd_soc_write(codec, SGTL5000_DAP_CTRL, 0); 1336 snd_soc_write(codec, SGTL5000_DAP_CTRL, 0);
1354 1337
1355 /* leading to standby state */
1356 ret = sgtl5000_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1357 if (ret)
1358 goto err;
1359
1360 return 0; 1338 return 0;
1361 1339
1362err: 1340err:
@@ -1373,8 +1351,6 @@ static int sgtl5000_remove(struct snd_soc_codec *codec)
1373{ 1351{
1374 struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); 1352 struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
1375 1353
1376 sgtl5000_set_bias_level(codec, SND_SOC_BIAS_OFF);
1377
1378 regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), 1354 regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
1379 sgtl5000->supplies); 1355 sgtl5000->supplies);
1380 regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), 1356 regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies),
@@ -1387,9 +1363,8 @@ static int sgtl5000_remove(struct snd_soc_codec *codec)
1387static struct snd_soc_codec_driver sgtl5000_driver = { 1363static struct snd_soc_codec_driver sgtl5000_driver = {
1388 .probe = sgtl5000_probe, 1364 .probe = sgtl5000_probe,
1389 .remove = sgtl5000_remove, 1365 .remove = sgtl5000_remove,
1390 .suspend = sgtl5000_suspend,
1391 .resume = sgtl5000_resume,
1392 .set_bias_level = sgtl5000_set_bias_level, 1366 .set_bias_level = sgtl5000_set_bias_level,
1367 .suspend_bias_off = true,
1393 .controls = sgtl5000_snd_controls, 1368 .controls = sgtl5000_snd_controls,
1394 .num_controls = ARRAY_SIZE(sgtl5000_snd_controls), 1369 .num_controls = ARRAY_SIZE(sgtl5000_snd_controls),
1395 .dapm_widgets = sgtl5000_dapm_widgets, 1370 .dapm_widgets = sgtl5000_dapm_widgets,
@@ -1442,6 +1417,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1442{ 1417{
1443 struct sgtl5000_priv *sgtl5000; 1418 struct sgtl5000_priv *sgtl5000;
1444 int ret, reg, rev; 1419 int ret, reg, rev;
1420 unsigned int mclk;
1445 1421
1446 sgtl5000 = devm_kzalloc(&client->dev, sizeof(struct sgtl5000_priv), 1422 sgtl5000 = devm_kzalloc(&client->dev, sizeof(struct sgtl5000_priv),
1447 GFP_KERNEL); 1423 GFP_KERNEL);
@@ -1465,6 +1441,14 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1465 return ret; 1441 return ret;
1466 } 1442 }
1467 1443
1444 /* SGTL5000 SYS_MCLK should be between 8 and 27 MHz */
1445 mclk = clk_get_rate(sgtl5000->mclk);
1446 if (mclk < 8000000 || mclk > 27000000) {
1447 dev_err(&client->dev, "Invalid SYS_CLK frequency: %u.%03uMHz\n",
1448 mclk / 1000000, mclk / 1000 % 1000);
1449 return -EINVAL;
1450 }
1451
1468 ret = clk_prepare_enable(sgtl5000->mclk); 1452 ret = clk_prepare_enable(sgtl5000->mclk);
1469 if (ret) 1453 if (ret)
1470 return ret; 1454 return ret;