aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2014-09-28 07:22:30 -0400
committerMark Brown <broonie@kernel.org>2014-09-28 07:22:30 -0400
commite172b9e6a1449f92e0ed834e7113a43e31ee7ced (patch)
treed13cd9d83ec50628d3216d4f5e6c990f745af875
parent0121327c1a68bc8c80f240c2794e682722b69051 (diff)
parentf69e3caa9e1855737bf1e99e1fe4488e33d74bfe (diff)
Merge branch 'fix/max98090' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-intel
-rw-r--r--sound/soc/codecs/max98090.c115
-rw-r--r--sound/soc/codecs/max98090.h3
2 files changed, 114 insertions, 4 deletions
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 4a063fa88526..7e111865946a 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -1311,8 +1311,6 @@ static const struct snd_soc_dapm_route max98090_dapm_routes[] = {
1311 {"MIC1 Input", NULL, "MIC1"}, 1311 {"MIC1 Input", NULL, "MIC1"},
1312 {"MIC2 Input", NULL, "MIC2"}, 1312 {"MIC2 Input", NULL, "MIC2"},
1313 1313
1314 {"DMICL", NULL, "DMICL_ENA"},
1315 {"DMICR", NULL, "DMICR_ENA"},
1316 {"DMICL", NULL, "AHPF"}, 1314 {"DMICL", NULL, "AHPF"},
1317 {"DMICR", NULL, "AHPF"}, 1315 {"DMICR", NULL, "AHPF"},
1318 1316
@@ -1370,6 +1368,8 @@ static const struct snd_soc_dapm_route max98090_dapm_routes[] = {
1370 {"DMIC Mux", "ADC", "ADCR"}, 1368 {"DMIC Mux", "ADC", "ADCR"},
1371 {"DMIC Mux", "DMIC", "DMICL"}, 1369 {"DMIC Mux", "DMIC", "DMICL"},
1372 {"DMIC Mux", "DMIC", "DMICR"}, 1370 {"DMIC Mux", "DMIC", "DMICR"},
1371 {"DMIC Mux", "DMIC", "DMICL_ENA"},
1372 {"DMIC Mux", "DMIC", "DMICR_ENA"},
1373 1373
1374 {"LBENL Mux", "Normal", "DMIC Mux"}, 1374 {"LBENL Mux", "Normal", "DMIC Mux"},
1375 {"LBENL Mux", "Loopback", "LTENL Mux"}, 1375 {"LBENL Mux", "Loopback", "LTENL Mux"},
@@ -1972,6 +1972,102 @@ static int max98090_dai_digital_mute(struct snd_soc_dai *codec_dai, int mute)
1972 return 0; 1972 return 0;
1973} 1973}
1974 1974
1975static int max98090_dai_trigger(struct snd_pcm_substream *substream, int cmd,
1976 struct snd_soc_dai *dai)
1977{
1978 struct snd_soc_codec *codec = dai->codec;
1979 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
1980
1981 switch (cmd) {
1982 case SNDRV_PCM_TRIGGER_START:
1983 case SNDRV_PCM_TRIGGER_RESUME:
1984 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1985 if (!max98090->master && dai->active == 1)
1986 queue_delayed_work(system_power_efficient_wq,
1987 &max98090->pll_det_enable_work,
1988 msecs_to_jiffies(10));
1989 break;
1990 case SNDRV_PCM_TRIGGER_STOP:
1991 case SNDRV_PCM_TRIGGER_SUSPEND:
1992 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1993 if (!max98090->master && dai->active == 1)
1994 schedule_work(&max98090->pll_det_disable_work);
1995 break;
1996 default:
1997 break;
1998 }
1999
2000 return 0;
2001}
2002
2003static void max98090_pll_det_enable_work(struct work_struct *work)
2004{
2005 struct max98090_priv *max98090 =
2006 container_of(work, struct max98090_priv,
2007 pll_det_enable_work.work);
2008 struct snd_soc_codec *codec = max98090->codec;
2009 unsigned int status, mask;
2010
2011 /*
2012 * Clear status register in order to clear possibly already occurred
2013 * PLL unlock. If PLL hasn't still locked, the status will be set
2014 * again and PLL unlock interrupt will occur.
2015 * Note this will clear all status bits
2016 */
2017 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status);
2018
2019 /*
2020 * Queue jack work in case jack state has just changed but handler
2021 * hasn't run yet
2022 */
2023 regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask);
2024 status &= mask;
2025 if (status & M98090_JDET_MASK)
2026 queue_delayed_work(system_power_efficient_wq,
2027 &max98090->jack_work,
2028 msecs_to_jiffies(100));
2029
2030 /* Enable PLL unlock interrupt */
2031 snd_soc_update_bits(codec, M98090_REG_INTERRUPT_S,
2032 M98090_IULK_MASK,
2033 1 << M98090_IULK_SHIFT);
2034}
2035
2036static void max98090_pll_det_disable_work(struct work_struct *work)
2037{
2038 struct max98090_priv *max98090 =
2039 container_of(work, struct max98090_priv, pll_det_disable_work);
2040 struct snd_soc_codec *codec = max98090->codec;
2041
2042 cancel_delayed_work_sync(&max98090->pll_det_enable_work);
2043
2044 /* Disable PLL unlock interrupt */
2045 snd_soc_update_bits(codec, M98090_REG_INTERRUPT_S,
2046 M98090_IULK_MASK, 0);
2047}
2048
2049static void max98090_pll_work(struct work_struct *work)
2050{
2051 struct max98090_priv *max98090 =
2052 container_of(work, struct max98090_priv, pll_work);
2053 struct snd_soc_codec *codec = max98090->codec;
2054
2055 if (!snd_soc_codec_is_active(codec))
2056 return;
2057
2058 dev_info(codec->dev, "PLL unlocked\n");
2059
2060 /* Toggle shutdown OFF then ON */
2061 snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN,
2062 M98090_SHDNN_MASK, 0);
2063 msleep(10);
2064 snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN,
2065 M98090_SHDNN_MASK, M98090_SHDNN_MASK);
2066
2067 /* Give PLL time to lock */
2068 msleep(10);
2069}
2070
1975static void max98090_jack_work(struct work_struct *work) 2071static void max98090_jack_work(struct work_struct *work)
1976{ 2072{
1977 struct max98090_priv *max98090 = container_of(work, 2073 struct max98090_priv *max98090 = container_of(work,
@@ -2103,8 +2199,10 @@ static irqreturn_t max98090_interrupt(int irq, void *data)
2103 if (active & M98090_SLD_MASK) 2199 if (active & M98090_SLD_MASK)
2104 dev_dbg(codec->dev, "M98090_SLD_MASK\n"); 2200 dev_dbg(codec->dev, "M98090_SLD_MASK\n");
2105 2201
2106 if (active & M98090_ULK_MASK) 2202 if (active & M98090_ULK_MASK) {
2107 dev_err(codec->dev, "M98090_ULK_MASK\n"); 2203 dev_dbg(codec->dev, "M98090_ULK_MASK\n");
2204 schedule_work(&max98090->pll_work);
2205 }
2108 2206
2109 if (active & M98090_JDET_MASK) { 2207 if (active & M98090_JDET_MASK) {
2110 dev_dbg(codec->dev, "M98090_JDET_MASK\n"); 2208 dev_dbg(codec->dev, "M98090_JDET_MASK\n");
@@ -2177,6 +2275,7 @@ static struct snd_soc_dai_ops max98090_dai_ops = {
2177 .set_tdm_slot = max98090_set_tdm_slot, 2275 .set_tdm_slot = max98090_set_tdm_slot,
2178 .hw_params = max98090_dai_hw_params, 2276 .hw_params = max98090_dai_hw_params,
2179 .digital_mute = max98090_dai_digital_mute, 2277 .digital_mute = max98090_dai_digital_mute,
2278 .trigger = max98090_dai_trigger,
2180}; 2279};
2181 2280
2182static struct snd_soc_dai_driver max98090_dai[] = { 2281static struct snd_soc_dai_driver max98090_dai[] = {
@@ -2258,6 +2357,11 @@ static int max98090_probe(struct snd_soc_codec *codec)
2258 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; 2357 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET;
2259 2358
2260 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); 2359 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work);
2360 INIT_DELAYED_WORK(&max98090->pll_det_enable_work,
2361 max98090_pll_det_enable_work);
2362 INIT_WORK(&max98090->pll_det_disable_work,
2363 max98090_pll_det_disable_work);
2364 INIT_WORK(&max98090->pll_work, max98090_pll_work);
2261 2365
2262 /* Enable jack detection */ 2366 /* Enable jack detection */
2263 snd_soc_write(codec, M98090_REG_JACK_DETECT, 2367 snd_soc_write(codec, M98090_REG_JACK_DETECT,
@@ -2310,6 +2414,9 @@ static int max98090_remove(struct snd_soc_codec *codec)
2310 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); 2414 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
2311 2415
2312 cancel_delayed_work_sync(&max98090->jack_work); 2416 cancel_delayed_work_sync(&max98090->jack_work);
2417 cancel_delayed_work_sync(&max98090->pll_det_enable_work);
2418 cancel_work_sync(&max98090->pll_det_disable_work);
2419 cancel_work_sync(&max98090->pll_work);
2313 2420
2314 return 0; 2421 return 0;
2315} 2422}
diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h
index cf1b6062ba8c..14427a566f41 100644
--- a/sound/soc/codecs/max98090.h
+++ b/sound/soc/codecs/max98090.h
@@ -1532,6 +1532,9 @@ struct max98090_priv {
1532 int irq; 1532 int irq;
1533 int jack_state; 1533 int jack_state;
1534 struct delayed_work jack_work; 1534 struct delayed_work jack_work;
1535 struct delayed_work pll_det_enable_work;
1536 struct work_struct pll_det_disable_work;
1537 struct work_struct pll_work;
1535 struct snd_soc_jack *jack; 1538 struct snd_soc_jack *jack;
1536 unsigned int dai_fmt; 1539 unsigned int dai_fmt;
1537 int tdm_slots; 1540 int tdm_slots;