Skip to contentSkip to conversation

ASoC: max98090: Correct pclk divisor settings

PATCH Applied Dylan Reid 2 participants 3 messages Nov 3, 2014 – Nov 4, 2014

Subsystems (3)
lore
Share & tools
lore

Dylan Reid

author
#0 lore raw

PATCH 1/2 ASoC: max98090: Correct pclk divisor settings

The Baytrail-based chromebooks have a 20MHz mclk, the code was setting the divisor incorrectly in this case. According to the 98090 datasheet, the divisor should be set to DIV1 for 10 <= mclk <= 20. Correct this and the surrounding clock ranges as well to match the datasheet.

---
 sound/soc/codecs/max98090.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/max98090.c +3 -3
index d519294..1229554 100644
@@ -1941,13 +1941,13 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
 	 *		 0x02 (when master clk is 20MHz to 40MHz)..
 	 *		 0x03 (when master clk is 40MHz to 60MHz)..
 	 */
-	if ((freq >= 10000000) && (freq < 20000000)) {
+	if ((freq >= 10000000) && (freq <= 20000000)) {
 		snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
 			M98090_PSCLK_DIV1);
-	} else if ((freq >= 20000000) && (freq < 40000000)) {
+	} else if ((freq > 20000000) && (freq <= 40000000)) {
 		snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
 			M98090_PSCLK_DIV2);
-	} else if ((freq >= 40000000) && (freq < 60000000)) {
+	} else if ((freq > 40000000) && (freq <= 60000000)) {
 		snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
 			M98090_PSCLK_DIV4);
 	} else {
Signature · 1 line
2.1.2.330.g565301e
author
#1 lore raw

PATCH 2/2 ASoC: max98090: Different comp tables for different pclks

In addtion expand the table to handle other values of sysclk. Instead of making the table 3D, expand it to a more descriptive struct. The divisors are specified in Table 19 of the 98090 data sheet version 0p94.

The dmic frequency was previously assumed. Instead make it explicit and configurable through device tree. This now handles independently set pclk and dmic frequency.

Based on downstream work by Ralph Birt.

---
 .../devicetree/bindings/sound/max98090.txt         |   2 +
 sound/soc/codecs/max98090.c                        | 189 +++++++++++++++++----
 sound/soc/codecs/max98090.h                        |   8 +
 3 files changed, 163 insertions(+), 36 deletions(-)
Documentation/devicetree/bindings/sound/max98090.txt +2 -0
index c454e67..aa802a2 100644
@@ -16,6 +16,8 @@ Optional properties:
 
 - clock-names: Should be "mclk"
 
+- maxim,dmic-freq: Frequency at which to clock DMIC
+
 Pins on the device (for linking into audio routes):
 
   * MIC1
sound/soc/codecs/max98090.c +153 -36

238 lines not on this page · raw message

sound/soc/codecs/max98090.h +8 -0
index a5f6bad..21ff743 100644
@@ -12,6 +12,12 @@
 #define _MAX98090_H
 
 /*
+ * The default operating frequency for a DMIC attached to the codec.
+ * This can be overridden by a device tree property.
+ */
+#define MAX98090_DEFAULT_DMIC_FREQ		2500000
+
+/*
  * MAX98090 Register Definitions
  */
 
@@ -1518,8 +1524,10 @@ struct max98090_priv {
 	struct max98090_pdata *pdata;
 	struct clk *mclk;
 	unsigned int sysclk;
+	unsigned int pclk;
 	unsigned int bclk;
 	unsigned int lrclk;
+	u32 dmic_freq;
 	struct max98090_cdata dai[1];
 	int jack_state;
 	struct delayed_work jack_work;
Signature · 1 line
2.1.2.330.g565301e
maintainer Applied
#2 lore raw
In reply to Dylan Reid
Quoted 5 lines · Dylan Reid

The Baytrail-based chromebooks have a 20MHz mclk, the code was setting the divisor incorrectly in this case. According to the 98090 datasheet, the divisor should be set to DIV1 for 10 <= mclk <= 20. Correct this and the surrounding clock ranges as well to match the datasheet.

Applied both, thanks.