aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2015-06-04 09:04:30 -0400
committerMark Brown <broonie@kernel.org>2015-06-05 13:53:36 -0400
commita571cb17acb6156e6ea8d5fe2ff824e713416bae (patch)
treee9d897170ae7df34cba502f70c9ca4f4e0c53b4f
parentd20b098dd98ec9e0a205ad59e32d93a636a783b3 (diff)
ASoC: tas2552: Configure the WCLK frequency based on the stream
Instead of hard wiring the WCLK frequency at probe time do it runtime. The hard wired 88_96KHz was not even setting the correct bits since it was defined as (1 << 6) which will change the I2S_OUT_SEL bit and will leave the amplifier configured for 8KHz. At the same time clean up and fix the CFG3 register bits. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/tas2552.c43
-rw-r--r--sound/soc/codecs/tas2552.h37
2 files changed, 59 insertions, 21 deletions
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index 13b435f9a9b1..891e2c529df3 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -168,7 +168,7 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream,
168 int d; 168 int d;
169 int cpf; 169 int cpf;
170 u8 p, j; 170 u8 p, j;
171 u8 ser_ctrl1_reg; 171 u8 ser_ctrl1_reg, wclk_rate;
172 172
173 switch (params_width(params)) { 173 switch (params_width(params)) {
174 case 16: 174 case 16:
@@ -206,6 +206,45 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream,
206 TAS2552_WORDLENGTH_MASK | TAS2552_CLKSPERFRAME_MASK, 206 TAS2552_WORDLENGTH_MASK | TAS2552_CLKSPERFRAME_MASK,
207 ser_ctrl1_reg); 207 ser_ctrl1_reg);
208 208
209 switch (params_rate(params)) {
210 case 8000:
211 wclk_rate = TAS2552_WCLK_FREQ_8KHZ;
212 break;
213 case 11025:
214 case 12000:
215 wclk_rate = TAS2552_WCLK_FREQ_11_12KHZ;
216 break;
217 case 16000:
218 wclk_rate = TAS2552_WCLK_FREQ_16KHZ;
219 break;
220 case 22050:
221 case 24000:
222 wclk_rate = TAS2552_WCLK_FREQ_22_24KHZ;
223 break;
224 case 32000:
225 wclk_rate = TAS2552_WCLK_FREQ_32KHZ;
226 break;
227 case 44100:
228 case 48000:
229 wclk_rate = TAS2552_WCLK_FREQ_44_48KHZ;
230 break;
231 case 88200:
232 case 96000:
233 wclk_rate = TAS2552_WCLK_FREQ_88_96KHZ;
234 break;
235 case 176400:
236 case 192000:
237 wclk_rate = TAS2552_WCLK_FREQ_176_192KHZ;
238 break;
239 default:
240 dev_err(codec->dev, "Not supported sample rate: %d\n",
241 params_rate(params));
242 return -EINVAL;
243 }
244
245 snd_soc_update_bits(codec, TAS2552_CFG_3, TAS2552_WCLK_FREQ_MASK,
246 wclk_rate);
247
209 if (!tas2552->pll_clkin) 248 if (!tas2552->pll_clkin)
210 return -EINVAL; 249 return -EINVAL;
211 250
@@ -503,7 +542,7 @@ static int tas2552_codec_probe(struct snd_soc_codec *codec)
503 542
504 snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_MUTE, TAS2552_MUTE); 543 snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_MUTE, TAS2552_MUTE);
505 snd_soc_write(codec, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL | 544 snd_soc_write(codec, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL |
506 TAS2552_DIN_SRC_SEL_AVG_L_R | TAS2552_88_96KHZ); 545 TAS2552_DIN_SRC_SEL_AVG_L_R);
507 snd_soc_write(codec, TAS2552_DOUT, TAS2552_PDM_DATA_I); 546 snd_soc_write(codec, TAS2552_DOUT, TAS2552_PDM_DATA_I);
508 snd_soc_write(codec, TAS2552_OUTPUT_DATA, TAS2552_PDM_DATA_V_I | 0x8); 547 snd_soc_write(codec, TAS2552_OUTPUT_DATA, TAS2552_PDM_DATA_V_I | 0x8);
509 snd_soc_write(codec, TAS2552_BOOST_PT_CTRL, TAS2552_APT_DELAY_200 | 548 snd_soc_write(codec, TAS2552_BOOST_PT_CTRL, TAS2552_APT_DELAY_200 |
diff --git a/sound/soc/codecs/tas2552.h b/sound/soc/codecs/tas2552.h
index de0ab0d27520..bbb820495516 100644
--- a/sound/soc/codecs/tas2552.h
+++ b/sound/soc/codecs/tas2552.h
@@ -62,6 +62,24 @@
62#define TAS2552_LIM_EN (1 << 2) 62#define TAS2552_LIM_EN (1 << 2)
63#define TAS2552_IVSENSE_EN (1 << 1) 63#define TAS2552_IVSENSE_EN (1 << 1)
64 64
65/* CFG3 Register Masks */
66#define TAS2552_WCLK_FREQ_8KHZ (0x0 << 0)
67#define TAS2552_WCLK_FREQ_11_12KHZ (0x1 << 0)
68#define TAS2552_WCLK_FREQ_16KHZ (0x2 << 0)
69#define TAS2552_WCLK_FREQ_22_24KHZ (0x3 << 0)
70#define TAS2552_WCLK_FREQ_32KHZ (0x4 << 0)
71#define TAS2552_WCLK_FREQ_44_48KHZ (0x5 << 0)
72#define TAS2552_WCLK_FREQ_88_96KHZ (0x6 << 0)
73#define TAS2552_WCLK_FREQ_176_192KHZ (0x7 << 0)
74#define TAS2552_WCLK_FREQ_MASK TAS2552_WCLK_FREQ_176_192KHZ
75#define TAS2552_DIN_SRC_SEL_MUTED (0x0 << 3)
76#define TAS2552_DIN_SRC_SEL_LEFT (0x1 << 3)
77#define TAS2552_DIN_SRC_SEL_RIGHT (0x2 << 3)
78#define TAS2552_DIN_SRC_SEL_AVG_L_R (0x3 << 3)
79#define TAS2552_PDM_IN_SEL (1 << 5)
80#define TAS2552_I2S_OUT_SEL (1 << 6)
81#define TAS2552_ANALOG_IN_SEL (1 << 7)
82
65/* DOUT Register Masks */ 83/* DOUT Register Masks */
66#define TAS2552_SDOUT_TRISTATE (1 << 2) 84#define TAS2552_SDOUT_TRISTATE (1 << 2)
67 85
@@ -84,25 +102,6 @@
84#define TAS2552_BCLKDIR (1 << 6) 102#define TAS2552_BCLKDIR (1 << 6)
85#define TAS2552_WCLKDIR (1 << 7) 103#define TAS2552_WCLKDIR (1 << 7)
86 104
87#define TAS2552_DIN_SRC_SEL_MUTED 0x00
88#define TAS2552_DIN_SRC_SEL_LEFT (1 << 4)
89#define TAS2552_DIN_SRC_SEL_RIGHT (1 << 5)
90#define TAS2552_DIN_SRC_SEL_AVG_L_R (0x11 << 4)
91
92#define TAS2552_PDM_IN_SEL (1 << 5)
93#define TAS2552_I2S_OUT_SEL (1 << 6)
94#define TAS2552_ANALOG_IN_SEL (1 << 7)
95
96/* CFG3 WCLK Dividers */
97#define TAS2552_8KHZ 0x00
98#define TAS2552_11_12KHZ (1 << 1)
99#define TAS2552_16KHZ (1 << 2)
100#define TAS2552_22_24KHZ (1 << 3)
101#define TAS2552_32KHZ (1 << 4)
102#define TAS2552_44_48KHZ (1 << 5)
103#define TAS2552_88_96KHZ (1 << 6)
104#define TAS2552_176_192KHZ (1 << 7)
105
106/* OUTPUT_DATA register */ 105/* OUTPUT_DATA register */
107#define TAS2552_PDM_DATA_I 0x00 106#define TAS2552_PDM_DATA_I 0x00
108#define TAS2552_PDM_DATA_V (1 << 6) 107#define TAS2552_PDM_DATA_V (1 << 6)