aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Thomson <Adam.Thomson.Opensource@diasemi.com>2016-04-22 09:16:26 -0400
committerMark Brown <broonie@kernel.org>2016-04-22 11:26:19 -0400
commitae48a35c408732413880d0ac0d6467baa5b3d68a (patch)
tree155fc72494d60bb00bcce2ca5dd35b913a398f70
parentf55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff)
ASoC: da7218: Update PLL ranges and dividers to improve locking
The expected MCLK frequency ranges and the associated dividers are updated to improve PLL locking in a corner scenario, with low MCLK frequency near an input divider change boundary. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/da7218.c32
-rw-r--r--sound/soc/codecs/da7218.h21
2 files changed, 28 insertions, 25 deletions
diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c
index 93575f251866..99ce23e113bf 100644
--- a/sound/soc/codecs/da7218.c
+++ b/sound/soc/codecs/da7218.c
@@ -1868,27 +1868,27 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1868 1868
1869 /* Verify 32KHz, 2MHz - 54MHz MCLK provided, and set input divider */ 1869 /* Verify 32KHz, 2MHz - 54MHz MCLK provided, and set input divider */
1870 if (da7218->mclk_rate == 32768) { 1870 if (da7218->mclk_rate == 32768) {
1871 indiv_bits = DA7218_PLL_INDIV_2_5_MHZ; 1871 indiv_bits = DA7218_PLL_INDIV_9_TO_18_MHZ;
1872 indiv = DA7218_PLL_INDIV_2_10_MHZ_VAL; 1872 indiv = DA7218_PLL_INDIV_9_TO_18_MHZ_VAL;
1873 } else if (da7218->mclk_rate < 2000000) { 1873 } else if (da7218->mclk_rate < 2000000) {
1874 dev_err(codec->dev, "PLL input clock %d below valid range\n", 1874 dev_err(codec->dev, "PLL input clock %d below valid range\n",
1875 da7218->mclk_rate); 1875 da7218->mclk_rate);
1876 return -EINVAL; 1876 return -EINVAL;
1877 } else if (da7218->mclk_rate <= 5000000) { 1877 } else if (da7218->mclk_rate <= 4500000) {
1878 indiv_bits = DA7218_PLL_INDIV_2_5_MHZ; 1878 indiv_bits = DA7218_PLL_INDIV_2_TO_4_5_MHZ;
1879 indiv = DA7218_PLL_INDIV_2_10_MHZ_VAL; 1879 indiv = DA7218_PLL_INDIV_2_TO_4_5_MHZ_VAL;
1880 } else if (da7218->mclk_rate <= 10000000) { 1880 } else if (da7218->mclk_rate <= 9000000) {
1881 indiv_bits = DA7218_PLL_INDIV_5_10_MHZ; 1881 indiv_bits = DA7218_PLL_INDIV_4_5_TO_9_MHZ;
1882 indiv = DA7218_PLL_INDIV_2_10_MHZ_VAL; 1882 indiv = DA7218_PLL_INDIV_4_5_TO_9_MHZ_VAL;
1883 } else if (da7218->mclk_rate <= 20000000) { 1883 } else if (da7218->mclk_rate <= 18000000) {
1884 indiv_bits = DA7218_PLL_INDIV_10_20_MHZ; 1884 indiv_bits = DA7218_PLL_INDIV_9_TO_18_MHZ;
1885 indiv = DA7218_PLL_INDIV_10_20_MHZ_VAL; 1885 indiv = DA7218_PLL_INDIV_9_TO_18_MHZ_VAL;
1886 } else if (da7218->mclk_rate <= 40000000) { 1886 } else if (da7218->mclk_rate <= 36000000) {
1887 indiv_bits = DA7218_PLL_INDIV_20_40_MHZ; 1887 indiv_bits = DA7218_PLL_INDIV_18_TO_36_MHZ;
1888 indiv = DA7218_PLL_INDIV_20_40_MHZ_VAL; 1888 indiv = DA7218_PLL_INDIV_18_TO_36_MHZ_VAL;
1889 } else if (da7218->mclk_rate <= 54000000) { 1889 } else if (da7218->mclk_rate <= 54000000) {
1890 indiv_bits = DA7218_PLL_INDIV_40_54_MHZ; 1890 indiv_bits = DA7218_PLL_INDIV_36_TO_54_MHZ;
1891 indiv = DA7218_PLL_INDIV_40_54_MHZ_VAL; 1891 indiv = DA7218_PLL_INDIV_36_TO_54_MHZ_VAL;
1892 } else { 1892 } else {
1893 dev_err(codec->dev, "PLL input clock %d above valid range\n", 1893 dev_err(codec->dev, "PLL input clock %d above valid range\n",
1894 da7218->mclk_rate); 1894 da7218->mclk_rate);
diff --git a/sound/soc/codecs/da7218.h b/sound/soc/codecs/da7218.h
index c2c59049a2ad..477cd37723cf 100644
--- a/sound/soc/codecs/da7218.h
+++ b/sound/soc/codecs/da7218.h
@@ -876,15 +876,11 @@
876/* DA7218_PLL_CTRL = 0x91 */ 876/* DA7218_PLL_CTRL = 0x91 */
877#define DA7218_PLL_INDIV_SHIFT 0 877#define DA7218_PLL_INDIV_SHIFT 0
878#define DA7218_PLL_INDIV_MASK (0x7 << 0) 878#define DA7218_PLL_INDIV_MASK (0x7 << 0)
879#define DA7218_PLL_INDIV_2_5_MHZ (0x0 << 0) 879#define DA7218_PLL_INDIV_2_TO_4_5_MHZ (0x0 << 0)
880#define DA7218_PLL_INDIV_5_10_MHZ (0x1 << 0) 880#define DA7218_PLL_INDIV_4_5_TO_9_MHZ (0x1 << 0)
881#define DA7218_PLL_INDIV_10_20_MHZ (0x2 << 0) 881#define DA7218_PLL_INDIV_9_TO_18_MHZ (0x2 << 0)
882#define DA7218_PLL_INDIV_20_40_MHZ (0x3 << 0) 882#define DA7218_PLL_INDIV_18_TO_36_MHZ (0x3 << 0)
883#define DA7218_PLL_INDIV_40_54_MHZ (0x4 << 0) 883#define DA7218_PLL_INDIV_36_TO_54_MHZ (0x4 << 0)
884#define DA7218_PLL_INDIV_2_10_MHZ_VAL 2
885#define DA7218_PLL_INDIV_10_20_MHZ_VAL 4
886#define DA7218_PLL_INDIV_20_40_MHZ_VAL 8
887#define DA7218_PLL_INDIV_40_54_MHZ_VAL 16
888#define DA7218_PLL_MCLK_SQR_EN_SHIFT 4 884#define DA7218_PLL_MCLK_SQR_EN_SHIFT 4
889#define DA7218_PLL_MCLK_SQR_EN_MASK (0x1 << 4) 885#define DA7218_PLL_MCLK_SQR_EN_MASK (0x1 << 4)
890#define DA7218_PLL_MODE_SHIFT 6 886#define DA7218_PLL_MODE_SHIFT 6
@@ -1336,6 +1332,13 @@
1336#define DA7218_PLL_FREQ_OUT_90316 90316800 1332#define DA7218_PLL_FREQ_OUT_90316 90316800
1337#define DA7218_PLL_FREQ_OUT_98304 98304000 1333#define DA7218_PLL_FREQ_OUT_98304 98304000
1338 1334
1335/* PLL Frequency Dividers */
1336#define DA7218_PLL_INDIV_2_TO_4_5_MHZ_VAL 1
1337#define DA7218_PLL_INDIV_4_5_TO_9_MHZ_VAL 2
1338#define DA7218_PLL_INDIV_9_TO_18_MHZ_VAL 4
1339#define DA7218_PLL_INDIV_18_TO_36_MHZ_VAL 8
1340#define DA7218_PLL_INDIV_36_TO_54_MHZ_VAL 16
1341
1339/* ALC Calibration */ 1342/* ALC Calibration */
1340#define DA7218_ALC_CALIB_DELAY_MIN 2500 1343#define DA7218_ALC_CALIB_DELAY_MIN 2500
1341#define DA7218_ALC_CALIB_DELAY_MAX 5000 1344#define DA7218_ALC_CALIB_DELAY_MAX 5000