aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Thomson <Adam.Thomson.Opensource@diasemi.com>2016-09-12 11:46:50 -0400
committerMark Brown <broonie@kernel.org>2016-09-14 11:32:42 -0400
commit6a0b87c6e7f664aff8957e0889f9f82e5ee27f65 (patch)
treebc5942962052e8e039c5cd0bbab410e56c970303
parent40585391fc88d6d66dc479efccba973426c004ab (diff)
ASoC: da7219: Support HP detect procedure when MCLK not present
Currently the driver code assumes that MCLK will be present during the procedure, or if it has control of MCLK then it can make sure it's enabled. Some platforms however do not provide MCLK to the driver in this way, and will not leave MCLK enabled when Codec is in STANDBY state. This patch adds support for the HP detect procedure when running from the device's internal oscillator, to ensure all platforms can make use of this feature correctly. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/da7219-aad.c34
-rw-r--r--sound/soc/codecs/da7219-aad.h6
-rw-r--r--sound/soc/codecs/da7219.h2
3 files changed, 38 insertions, 4 deletions
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
index 4e369a1c5d88..fc27dab3d6ba 100644
--- a/sound/soc/codecs/da7219-aad.c
+++ b/sound/soc/codecs/da7219-aad.c
@@ -115,7 +115,7 @@ static void da7219_aad_hptest_work(struct work_struct *work)
115 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); 115 struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
116 116
117 u16 tonegen_freq_hptest; 117 u16 tonegen_freq_hptest;
118 u8 accdet_cfg8; 118 u8 pll_srm_sts, gain_ramp_ctrl, accdet_cfg8;
119 int report = 0, ret = 0; 119 int report = 0, ret = 0;
120 120
121 /* Lock DAPM and any Kcontrols that are affected by this test */ 121 /* Lock DAPM and any Kcontrols that are affected by this test */
@@ -133,6 +133,20 @@ static void da7219_aad_hptest_work(struct work_struct *work)
133 } 133 }
134 } 134 }
135 135
136 /*
137 * If MCLK not present, then we're using the internal oscillator and
138 * require different frequency settings to achieve the same result.
139 */
140 pll_srm_sts = snd_soc_read(codec, DA7219_PLL_SRM_STS);
141 if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK)
142 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ);
143 else
144 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC);
145
146 /* Ensure gain ramping at fastest rate */
147 gain_ramp_ctrl = snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL);
148 snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8);
149
136 /* Bypass cache so it saves current settings */ 150 /* Bypass cache so it saves current settings */
137 regcache_cache_bypass(da7219->regmap, true); 151 regcache_cache_bypass(da7219->regmap, true);
138 152
@@ -195,9 +209,15 @@ static void da7219_aad_hptest_work(struct work_struct *work)
195 snd_soc_write(codec, DA7219_HP_R_CTRL, 209 snd_soc_write(codec, DA7219_HP_R_CTRL,
196 DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK); 210 DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK);
197 211
212 /*
213 * If we're running from the internal oscillator then give audio paths
214 * time to settle before running test.
215 */
216 if (!(pll_srm_sts & DA7219_PLL_SRM_STS_MCLK))
217 msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY);
218
198 /* Configure & start Tone Generator */ 219 /* Configure & start Tone Generator */
199 snd_soc_write(codec, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); 220 snd_soc_write(codec, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK);
200 tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ);
201 regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L, 221 regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L,
202 &tonegen_freq_hptest, sizeof(tonegen_freq_hptest)); 222 &tonegen_freq_hptest, sizeof(tonegen_freq_hptest));
203 snd_soc_update_bits(codec, DA7219_TONE_GEN_CFG2, 223 snd_soc_update_bits(codec, DA7219_TONE_GEN_CFG2,
@@ -256,6 +276,16 @@ static void da7219_aad_hptest_work(struct work_struct *work)
256 snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, 276 snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8,
257 DA7219_HPTEST_EN_MASK, 0); 277 DA7219_HPTEST_EN_MASK, 0);
258 278
279 /*
280 * If we're running from the internal oscillator then give audio paths
281 * time to settle before allowing headphones to be driven as required.
282 */
283 if (!(pll_srm_sts & DA7219_PLL_SRM_STS_MCLK))
284 msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY);
285
286 /* Restore gain ramping rate */
287 snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl);
288
259 /* Drive Headphones/lineout */ 289 /* Drive Headphones/lineout */
260 snd_soc_update_bits(codec, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, 290 snd_soc_update_bits(codec, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK,
261 DA7219_HP_L_AMP_OE_MASK); 291 DA7219_HP_L_AMP_OE_MASK);
diff --git a/sound/soc/codecs/da7219-aad.h b/sound/soc/codecs/da7219-aad.h
index 4fccf677cd06..a34be4828f97 100644
--- a/sound/soc/codecs/da7219-aad.h
+++ b/sound/soc/codecs/da7219-aad.h
@@ -176,8 +176,10 @@
176#define DA7219_AAD_MICBIAS_CHK_DELAY 10 176#define DA7219_AAD_MICBIAS_CHK_DELAY 10
177#define DA7219_AAD_MICBIAS_CHK_RETRIES 5 177#define DA7219_AAD_MICBIAS_CHK_RETRIES 5
178 178
179#define DA7219_AAD_HPTEST_RAMP_FREQ 0x28 179#define DA7219_AAD_HPTEST_RAMP_FREQ 0x28
180#define DA7219_AAD_HPTEST_PERIOD 65 180#define DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC 0x4D
181#define DA7219_AAD_HPTEST_PERIOD 65
182#define DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY 20
181 183
182enum da7219_aad_event_regs { 184enum da7219_aad_event_regs {
183 DA7219_AAD_IRQ_REG_A = 0, 185 DA7219_AAD_IRQ_REG_A = 0,
diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h
index ff2a2f02ce40..545576ddf50c 100644
--- a/sound/soc/codecs/da7219.h
+++ b/sound/soc/codecs/da7219.h
@@ -224,6 +224,7 @@
224#define DA7219_PLL_SRM_STATE_MASK (0xF << 0) 224#define DA7219_PLL_SRM_STATE_MASK (0xF << 0)
225#define DA7219_PLL_SRM_STATUS_SHIFT 4 225#define DA7219_PLL_SRM_STATUS_SHIFT 4
226#define DA7219_PLL_SRM_STATUS_MASK (0xF << 4) 226#define DA7219_PLL_SRM_STATUS_MASK (0xF << 4)
227#define DA7219_PLL_SRM_STS_MCLK (0x1 << 4)
227#define DA7219_PLL_SRM_STS_SRM_LOCK (0x1 << 7) 228#define DA7219_PLL_SRM_STS_SRM_LOCK (0x1 << 7)
228 229
229/* DA7219_DIG_ROUTING_DAI = 0x2A */ 230/* DA7219_DIG_ROUTING_DAI = 0x2A */
@@ -576,6 +577,7 @@
576/* DA7219_GAIN_RAMP_CTRL = 0x92 */ 577/* DA7219_GAIN_RAMP_CTRL = 0x92 */
577#define DA7219_GAIN_RAMP_RATE_SHIFT 0 578#define DA7219_GAIN_RAMP_RATE_SHIFT 0
578#define DA7219_GAIN_RAMP_RATE_MASK (0x3 << 0) 579#define DA7219_GAIN_RAMP_RATE_MASK (0x3 << 0)
580#define DA7219_GAIN_RAMP_RATE_X8 (0x0 << 0)
579#define DA7219_GAIN_RAMP_RATE_MAX 4 581#define DA7219_GAIN_RAMP_RATE_MAX 4
580 582
581/* DA7219_PC_COUNT = 0x94 */ 583/* DA7219_PC_COUNT = 0x94 */