ASoC: tlv320aic3x: add input clock selection
PATCH 1/1 ASoC: tlv320aic3x: add input clock selection
This patch adds input selection of main codec clock - from what pin. Tested with TLV320AIC3106 on BCLK and MCLK.
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c renamed from home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c.orig +4 -0
@@ -972,6 +972,10 @@struct snd_soc_codec *codec = codec_dai->codec;struct aic3x_priv *aic3x =snd_soc_codec_get_drvdata (codec); +/* set clock on MCLK or GPIO2 or BCLK */ +snd_soc_update_bits (codec,AIC3X_CLKGEN_CTRL_REG ,PLLCLK_IN_MASK , clk_id); +snd_soc_update_bits (codec,AIC3X_CLKGEN_CTRL_REG ,CLKDIV_IN_MASK , clk_id); + aic3x->sysclk = freq;return 0 ; }
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h renamed from home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h.orig +7 -0
@@ -178,6 +178,13 @@#define PLL_CLKIN_SHIFT 4#define MCLK_SOURCE 0x0#define PLL_CLKDIV_SHIFT 0 +#define PLLCLK_IN_MASK 0x30 +#define CLKDIV_IN_MASK 0xc0 +/* clock in source */ +#define CLKIN_MCLK 0 +#define CLKIN_GPIO2 1 +#define CLKIN_BCLK 2 +/* Software reset register bits */ #define SOFT_RESET 0x80
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c line 977
Quoted 3 lines · Prchal Jiří
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c renamed from home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c.orig +3
-0+/* set clock on MCLK or GPIO2 or BCLK */ +snd_soc_update_bits (codec,AIC3X_CLKGEN_CTRL_REG ,PLLCLK_IN_MASK , clk_id); +snd_soc_update_bits (codec,AIC3X_CLKGEN_CTRL_REG ,CLKDIV_IN_MASK , clk_id);
Normally it's possible to set these separately. Is there a reason why they have to be the same (and if so why has the chip got separate registers)?
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h line 186
Quoted 6 lines
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h renamed from home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h.orig +6
-0+#define PLLCLK_IN_MASK 0x30 +#define CLKDIV_IN_MASK 0xc0 +/* clock in source */ +#define CLKIN_MCLK 0 +#define CLKIN_GPIO2 1 +#define CLKIN_BCLK 2
This doesn't look right - you use the clock source values directly above but they need shifting to be used as if they're used directly they'll always come out as zero. It'd also be better to have some bounds checking on the values.
Hi Mark,
Dne 26.6.2012 12:26, Mark Brown napsal(a):
Quoted 9 lines · Prchal Jiří
Review
Quoted 4 lines
(quoted diff) +3
-0+ /* set clock on MCLK or GPIO2 or BCLK */ + snd_soc_update_bits(codec, AIC3X_CLKGEN_CTRL_REG, PLLCLK_IN_MASK, clk_id); + snd_soc_update_bits(codec, AIC3X_CLKGEN_CTRL_REG, CLKDIV_IN_MASK, clk_id);Normally it's possible to set these separately. Is there a reason why they have to be the same (and if so why has the chip got separate registers)?
It could be set separately but in my opinion that doesn't make sense. Codec has one inner clock which is from divider or pll. In one time is used only one clock source so it doesn't matter how is set the other. And the other must be set to someone, cannot be switched off.
Normally board design contain one clock connected to one of tree input pins. This is to select pin. Selection of input divider or pll is done somewhere else depended on frequency and sampling rate. Can someone from TI approve or disapprove this?
Quoted 12 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+#define PLLCLK_IN_MASK 0x30 +#define CLKDIV_IN_MASK 0xc0 +/* clock in source */ +#define CLKIN_MCLK 0 +#define CLKIN_GPIO2 1 +#define CLKIN_BCLK 2This doesn't look right - you use the clock source values directly above but they need shifting to be used as if they're used directly they'll always come out as zero. It'd also be better to have some bounds checking on the values.
You are right, my mistake. Below is corrected patch. Thanks.
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c renamed from home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.c.orig +6 -0
@@ -972,6 +972,12 @@struct snd_soc_codec *codec = codec_dai->codec;struct aic3x_priv *aic3x =snd_soc_codec_get_drvdata (codec); +/* set clock on MCLK or GPIO2 or BCLK */ +snd_soc_update_bits (codec,AIC3X_CLKGEN_CTRL_REG ,PLLCLK_IN_MASK , + clk_id <<PLLCLK_IN_SHIFT ); +snd_soc_update_bits (codec,AIC3X_CLKGEN_CTRL_REG ,CLKDIV_IN_MASK , + clk_id <<CLKDIV_IN_SHIFT ); + aic3x->sysclk = freq;return 0 ; }
home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h renamed from home/prchal/arm/fw-cdu/linux/linux-3.5-rc3/sound/soc/codecs/tlv320aic3x.h.orig +9 -0
@@ -178,6 +178,15 @@#define PLL_CLKIN_SHIFT 4#define MCLK_SOURCE 0x0#define PLL_CLKDIV_SHIFT 0 +#define PLLCLK_IN_MASK 0x30 +#define PLLCLK_IN_SHIFT 4 +#define CLKDIV_IN_MASK 0xc0 +#define CLKDIV_IN_SHIFT 6 +/* clock in source */ +#define CLKIN_MCLK 0 +#define CLKIN_GPIO2 1 +#define CLKIN_BCLK 2 +/* Software reset register bits */ #define SOFT_RESET 0x80
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel