aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolin Chen <Guangyu.Chen@freescale.com>2014-04-30 06:54:06 -0400
committerMark Brown <broonie@linaro.org>2014-05-05 15:27:39 -0400
commite41a4a79af5cad172971af8681292af33496b119 (patch)
tree944cd789db146459700088bab9231b48dd4b62f6
parentaf46929e6ee7197dfe315af3c5bb5cc75a0aec9c (diff)
ASoC: fsl_spdif: Rename all _div to _df
We should have used _df by following the reference manual at the beginning. So this patch just renames them. Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/fsl/fsl_spdif.c41
-rw-r--r--sound/soc/fsl/fsl_spdif.h12
2 files changed, 26 insertions, 27 deletions
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index 6df70a976c10..abd669e233eb 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -75,7 +75,7 @@ struct fsl_spdif_priv {
75 struct platform_device *pdev; 75 struct platform_device *pdev;
76 struct regmap *regmap; 76 struct regmap *regmap;
77 bool dpll_locked; 77 bool dpll_locked;
78 u8 txclk_div[SPDIF_TXRATE_MAX]; 78 u8 txclk_df[SPDIF_TXRATE_MAX];
79 u8 txclk_src[SPDIF_TXRATE_MAX]; 79 u8 txclk_src[SPDIF_TXRATE_MAX];
80 u8 rxclk_src; 80 u8 rxclk_src;
81 struct clk *txclk[SPDIF_TXRATE_MAX]; 81 struct clk *txclk[SPDIF_TXRATE_MAX];
@@ -351,7 +351,7 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream,
351 struct platform_device *pdev = spdif_priv->pdev; 351 struct platform_device *pdev = spdif_priv->pdev;
352 unsigned long csfs = 0; 352 unsigned long csfs = 0;
353 u32 stc, mask, rate; 353 u32 stc, mask, rate;
354 u8 clk, div; 354 u8 clk, txclk_df;
355 int ret; 355 int ret;
356 356
357 switch (sample_rate) { 357 switch (sample_rate) {
@@ -378,9 +378,9 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream,
378 return -EINVAL; 378 return -EINVAL;
379 } 379 }
380 380
381 div = spdif_priv->txclk_div[rate]; 381 txclk_df = spdif_priv->txclk_df[rate];
382 if (div == 0) { 382 if (txclk_df == 0) {
383 dev_err(&pdev->dev, "the divisor can't be zero\n"); 383 dev_err(&pdev->dev, "the txclk_df can't be zero\n");
384 return -EINVAL; 384 return -EINVAL;
385 } 385 }
386 386
@@ -389,11 +389,10 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream,
389 goto clk_set_bypass; 389 goto clk_set_bypass;
390 390
391 /* 391 /*
392 * The S/PDIF block needs a clock of 64 * fs * div. The S/PDIF block 392 * The S/PDIF block needs a clock of 64 * fs * txclk_df.
393 * will divide by (div). So request 64 * fs * (div+1) which will 393 * So request 64 * fs * (txclk_df + 1) to get rounded.
394 * get rounded.
395 */ 394 */
396 ret = clk_set_rate(spdif_priv->txclk[rate], 64 * sample_rate * (div + 1)); 395 ret = clk_set_rate(spdif_priv->txclk[rate], 64 * sample_rate * (txclk_df + 1));
397 if (ret) { 396 if (ret) {
398 dev_err(&pdev->dev, "failed to set tx clock rate\n"); 397 dev_err(&pdev->dev, "failed to set tx clock rate\n");
399 return ret; 398 return ret;
@@ -401,7 +400,7 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream,
401 400
402clk_set_bypass: 401clk_set_bypass:
403 dev_dbg(&pdev->dev, "expected clock rate = %d\n", 402 dev_dbg(&pdev->dev, "expected clock rate = %d\n",
404 (64 * sample_rate * div)); 403 (64 * sample_rate * txclk_df));
405 dev_dbg(&pdev->dev, "actual clock rate = %ld\n", 404 dev_dbg(&pdev->dev, "actual clock rate = %ld\n",
406 clk_get_rate(spdif_priv->txclk[rate])); 405 clk_get_rate(spdif_priv->txclk[rate]));
407 406
@@ -409,8 +408,8 @@ clk_set_bypass:
409 spdif_set_cstatus(ctrl, IEC958_AES3_CON_FS, csfs); 408 spdif_set_cstatus(ctrl, IEC958_AES3_CON_FS, csfs);
410 409
411 /* select clock source and divisor */ 410 /* select clock source and divisor */
412 stc = STC_TXCLK_ALL_EN | STC_TXCLK_SRC_SET(clk) | STC_TXCLK_DIV(div); 411 stc = STC_TXCLK_ALL_EN | STC_TXCLK_SRC_SET(clk) | STC_TXCLK_DF(txclk_df);
413 mask = STC_TXCLK_ALL_EN_MASK | STC_TXCLK_SRC_MASK | STC_TXCLK_DIV_MASK; 412 mask = STC_TXCLK_ALL_EN_MASK | STC_TXCLK_SRC_MASK | STC_TXCLK_DF_MASK;
414 regmap_update_bits(regmap, REG_SPDIF_STC, mask, stc); 413 regmap_update_bits(regmap, REG_SPDIF_STC, mask, stc);
415 414
416 dev_dbg(&pdev->dev, "set sample rate to %d\n", sample_rate); 415 dev_dbg(&pdev->dev, "set sample rate to %d\n", sample_rate);
@@ -1020,22 +1019,22 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
1020{ 1019{
1021 const u32 rate[] = { 32000, 44100, 48000 }; 1020 const u32 rate[] = { 32000, 44100, 48000 };
1022 u64 rate_ideal, rate_actual, sub; 1021 u64 rate_ideal, rate_actual, sub;
1023 u32 div, arate; 1022 u32 txclk_df, arate;
1024 1023
1025 for (div = 1; div <= 128; div++) { 1024 for (txclk_df = 1; txclk_df <= 128; txclk_df++) {
1026 rate_ideal = rate[index] * (div + 1) * 64; 1025 rate_ideal = rate[index] * (txclk_df + 1) * 64;
1027 if (round) 1026 if (round)
1028 rate_actual = clk_round_rate(clk, rate_ideal); 1027 rate_actual = clk_round_rate(clk, rate_ideal);
1029 else 1028 else
1030 rate_actual = clk_get_rate(clk); 1029 rate_actual = clk_get_rate(clk);
1031 1030
1032 arate = rate_actual / 64; 1031 arate = rate_actual / 64;
1033 arate /= div; 1032 arate /= txclk_df;
1034 1033
1035 if (arate == rate[index]) { 1034 if (arate == rate[index]) {
1036 /* We are lucky */ 1035 /* We are lucky */
1037 savesub = 0; 1036 savesub = 0;
1038 spdif_priv->txclk_div[index] = div; 1037 spdif_priv->txclk_df[index] = txclk_df;
1039 break; 1038 break;
1040 } else if (arate / rate[index] == 1) { 1039 } else if (arate / rate[index] == 1) {
1041 /* A little bigger than expect */ 1040 /* A little bigger than expect */
@@ -1043,7 +1042,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
1043 do_div(sub, rate[index]); 1042 do_div(sub, rate[index]);
1044 if (sub < savesub) { 1043 if (sub < savesub) {
1045 savesub = sub; 1044 savesub = sub;
1046 spdif_priv->txclk_div[index] = div; 1045 spdif_priv->txclk_df[index] = txclk_df;
1047 } 1046 }
1048 } else if (rate[index] / arate == 1) { 1047 } else if (rate[index] / arate == 1) {
1049 /* A little smaller than expect */ 1048 /* A little smaller than expect */
@@ -1051,7 +1050,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
1051 do_div(sub, rate[index]); 1050 do_div(sub, rate[index]);
1052 if (sub < savesub) { 1051 if (sub < savesub) {
1053 savesub = sub; 1052 savesub = sub;
1054 spdif_priv->txclk_div[index] = div; 1053 spdif_priv->txclk_df[index] = txclk_df;
1055 } 1054 }
1056 } 1055 }
1057 } 1056 }
@@ -1096,8 +1095,8 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv,
1096 1095
1097 dev_dbg(&pdev->dev, "use rxtx%d as tx clock source for %dHz sample rate\n", 1096 dev_dbg(&pdev->dev, "use rxtx%d as tx clock source for %dHz sample rate\n",
1098 spdif_priv->txclk_src[index], rate[index]); 1097 spdif_priv->txclk_src[index], rate[index]);
1099 dev_dbg(&pdev->dev, "use divisor %d for %dHz sample rate\n", 1098 dev_dbg(&pdev->dev, "use txclk df %d for %dHz sample rate\n",
1100 spdif_priv->txclk_div[index], rate[index]); 1099 spdif_priv->txclk_df[index], rate[index]);
1101 1100
1102 return 0; 1101 return 0;
1103} 1102}
diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h
index 4ec27fcebac7..16fde4b927d3 100644
--- a/sound/soc/fsl/fsl_spdif.h
+++ b/sound/soc/fsl/fsl_spdif.h
@@ -143,18 +143,18 @@ enum spdif_gainsel {
143#define INT_RXFIFO_FUL (1 << 0) 143#define INT_RXFIFO_FUL (1 << 0)
144 144
145/* SPDIF Clock register */ 145/* SPDIF Clock register */
146#define STC_SYSCLK_DIV_OFFSET 11 146#define STC_SYSCLK_DF_OFFSET 11
147#define STC_SYSCLK_DIV_MASK (0x1ff << STC_SYSCLK_DIV_OFFSET) 147#define STC_SYSCLK_DF_MASK (0x1ff << STC_SYSCLK_DF_OFFSET)
148#define STC_SYSCLK_DIV(x) ((((x) - 1) << STC_SYSCLK_DIV_OFFSET) & STC_SYSCLK_DIV_MASK) 148#define STC_SYSCLK_DF(x) ((((x) - 1) << STC_SYSCLK_DF_OFFSET) & STC_SYSCLK_DF_MASK)
149#define STC_TXCLK_SRC_OFFSET 8 149#define STC_TXCLK_SRC_OFFSET 8
150#define STC_TXCLK_SRC_MASK (0x7 << STC_TXCLK_SRC_OFFSET) 150#define STC_TXCLK_SRC_MASK (0x7 << STC_TXCLK_SRC_OFFSET)
151#define STC_TXCLK_SRC_SET(x) ((x << STC_TXCLK_SRC_OFFSET) & STC_TXCLK_SRC_MASK) 151#define STC_TXCLK_SRC_SET(x) ((x << STC_TXCLK_SRC_OFFSET) & STC_TXCLK_SRC_MASK)
152#define STC_TXCLK_ALL_EN_OFFSET 7 152#define STC_TXCLK_ALL_EN_OFFSET 7
153#define STC_TXCLK_ALL_EN_MASK (1 << STC_TXCLK_ALL_EN_OFFSET) 153#define STC_TXCLK_ALL_EN_MASK (1 << STC_TXCLK_ALL_EN_OFFSET)
154#define STC_TXCLK_ALL_EN (1 << STC_TXCLK_ALL_EN_OFFSET) 154#define STC_TXCLK_ALL_EN (1 << STC_TXCLK_ALL_EN_OFFSET)
155#define STC_TXCLK_DIV_OFFSET 0 155#define STC_TXCLK_DF_OFFSET 0
156#define STC_TXCLK_DIV_MASK (0x7ff << STC_TXCLK_DIV_OFFSET) 156#define STC_TXCLK_DF_MASK (0x7ff << STC_TXCLK_DF_OFFSET)
157#define STC_TXCLK_DIV(x) ((((x) - 1) << STC_TXCLK_DIV_OFFSET) & STC_TXCLK_DIV_MASK) 157#define STC_TXCLK_DF(x) ((((x) - 1) << STC_TXCLK_DF_OFFSET) & STC_TXCLK_DF_MASK)
158#define STC_TXCLK_SRC_MAX 8 158#define STC_TXCLK_SRC_MAX 8
159 159
160#define STC_TXCLK_SPDIF_ROOT 1 160#define STC_TXCLK_SPDIF_ROOT 1