summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2015-06-04 09:04:22 -0400
committerMark Brown <broonie@kernel.org>2015-06-05 13:53:33 -0400
commit9d87a8888c0b2a3b2ec1204e0488935f021d6968 (patch)
treed6ec04f81a0cbd36125220d96a5aa4e145ea234b /sound
parent3715eda766a290fb8682bc2aabb2f23386f534de (diff)
ASoC: tas2552: Add support for pll and pdm source clock selection
Instead of hard wiring the PLL_CLKIN and PDM_CLK to be sourced from BCLK add proper clock configuration via the set_dai_sysclk callback. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/tas2552.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index e29b29b279d9..34495241c674 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -34,6 +34,7 @@
34#include <sound/soc-dapm.h> 34#include <sound/soc-dapm.h>
35#include <sound/tlv.h> 35#include <sound/tlv.h>
36#include <sound/tas2552-plat.h> 36#include <sound/tas2552-plat.h>
37#include <dt-bindings/sound/tas2552.h>
37 38
38#include "tas2552.h" 39#include "tas2552.h"
39 40
@@ -76,6 +77,7 @@ struct tas2552_data {
76 struct gpio_desc *enable_gpio; 77 struct gpio_desc *enable_gpio;
77 unsigned char regs[TAS2552_VBAT_DATA]; 78 unsigned char regs[TAS2552_VBAT_DATA];
78 unsigned int pll_clkin; 79 unsigned int pll_clkin;
80 unsigned int pdm_clk;
79}; 81};
80 82
81/* Input mux controls */ 83/* Input mux controls */
@@ -244,8 +246,33 @@ static int tas2552_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
244{ 246{
245 struct snd_soc_codec *codec = dai->codec; 247 struct snd_soc_codec *codec = dai->codec;
246 struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); 248 struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev);
249 u8 reg, mask, val;
250
251 switch (clk_id) {
252 case TAS2552_PLL_CLKIN_MCLK:
253 case TAS2552_PLL_CLKIN_BCLK:
254 case TAS2552_PLL_CLKIN_IVCLKIN:
255 case TAS2552_PLL_CLKIN_1_8_FIXED:
256 mask = TAS2552_PLL_SRC_MASK;
257 val = (clk_id << 3) & mask; /* bit 4:5 in the register */
258 reg = TAS2552_CFG_1;
259 tas2552->pll_clkin = freq;
260 break;
261 case TAS2552_PDM_CLK_PLL:
262 case TAS2552_PDM_CLK_IVCLKIN:
263 case TAS2552_PDM_CLK_BCLK:
264 case TAS2552_PDM_CLK_MCLK:
265 mask = TAS2552_PDM_CLK_SEL_MASK;
266 val = (clk_id >> 1) & mask; /* bit 0:1 in the register */
267 reg = TAS2552_PDM_CFG;
268 tas2552->pdm_clk = freq;
269 break;
270 default:
271 dev_err(codec->dev, "Invalid clk id: %d\n", clk_id);
272 return -EINVAL;
273 }
247 274
248 tas2552->pll_clkin = freq; 275 snd_soc_update_bits(codec, reg, mask, val);
249 276
250 return 0; 277 return 0;
251} 278}
@@ -366,13 +393,11 @@ static int tas2552_codec_probe(struct snd_soc_codec *codec)
366 goto probe_fail; 393 goto probe_fail;
367 } 394 }
368 395
369 snd_soc_write(codec, TAS2552_CFG_1, TAS2552_MUTE | 396 snd_soc_write(codec, TAS2552_CFG_1, TAS2552_MUTE);
370 TAS2552_PLL_SRC_BCLK);
371 snd_soc_write(codec, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL | 397 snd_soc_write(codec, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL |
372 TAS2552_DIN_SRC_SEL_AVG_L_R | TAS2552_88_96KHZ); 398 TAS2552_DIN_SRC_SEL_AVG_L_R | TAS2552_88_96KHZ);
373 snd_soc_write(codec, TAS2552_DOUT, TAS2552_PDM_DATA_I); 399 snd_soc_write(codec, TAS2552_DOUT, TAS2552_PDM_DATA_I);
374 snd_soc_write(codec, TAS2552_OUTPUT_DATA, TAS2552_PDM_DATA_V_I | 0x8); 400 snd_soc_write(codec, TAS2552_OUTPUT_DATA, TAS2552_PDM_DATA_V_I | 0x8);
375 snd_soc_write(codec, TAS2552_PDM_CFG, TAS2552_PDM_CLK_SEL_PLL);
376 snd_soc_write(codec, TAS2552_BOOST_PT_CTRL, TAS2552_APT_DELAY_200 | 401 snd_soc_write(codec, TAS2552_BOOST_PT_CTRL, TAS2552_APT_DELAY_200 |
377 TAS2552_APT_THRESH_2_1_7); 402 TAS2552_APT_THRESH_2_1_7);
378 403