max98090.c (83bc90e11576f9c100f8ef4ba2bcd0b89212e3fb) | max98090.c (b8a3ee820f7b0802c9b90a9f3426dbda54e93d09) |
---|---|
1/* 2 * max98090.c -- MAX98090 ALSA SoC Audio driver 3 * 4 * Copyright 2011-2012 Maxim Integrated Products 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. --- 1958 unchanged lines hidden (view full) --- 1967 1968 regval = mute ? M98090_DVM_MASK : 0; 1969 snd_soc_update_bits(codec, M98090_REG_DAI_PLAYBACK_LEVEL, 1970 M98090_DVM_MASK, regval); 1971 1972 return 0; 1973} 1974 | 1/* 2 * max98090.c -- MAX98090 ALSA SoC Audio driver 3 * 4 * Copyright 2011-2012 Maxim Integrated Products 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. --- 1958 unchanged lines hidden (view full) --- 1967 1968 regval = mute ? M98090_DVM_MASK : 0; 1969 snd_soc_update_bits(codec, M98090_REG_DAI_PLAYBACK_LEVEL, 1970 M98090_DVM_MASK, regval); 1971 1972 return 0; 1973} 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) 1976{ 1977 struct max98090_priv *max98090 = container_of(work, 1978 struct max98090_priv, 1979 jack_work.work); 1980 struct snd_soc_codec *codec = max98090->codec; 1981 struct snd_soc_dapm_context *dapm = &codec->dapm; 1982 int status = 0; --- 115 unchanged lines hidden (view full) --- 2098 return IRQ_NONE; 2099 2100 if (active & M98090_CLD_MASK) 2101 dev_err(codec->dev, "M98090_CLD_MASK\n"); 2102 2103 if (active & M98090_SLD_MASK) 2104 dev_dbg(codec->dev, "M98090_SLD_MASK\n"); 2105 | 2071static void max98090_jack_work(struct work_struct *work) 2072{ 2073 struct max98090_priv *max98090 = container_of(work, 2074 struct max98090_priv, 2075 jack_work.work); 2076 struct snd_soc_codec *codec = max98090->codec; 2077 struct snd_soc_dapm_context *dapm = &codec->dapm; 2078 int status = 0; --- 115 unchanged lines hidden (view full) --- 2194 return IRQ_NONE; 2195 2196 if (active & M98090_CLD_MASK) 2197 dev_err(codec->dev, "M98090_CLD_MASK\n"); 2198 2199 if (active & M98090_SLD_MASK) 2200 dev_dbg(codec->dev, "M98090_SLD_MASK\n"); 2201 |
2106 if (active & M98090_ULK_MASK) 2107 dev_err(codec->dev, "M98090_ULK_MASK\n"); | 2202 if (active & M98090_ULK_MASK) { 2203 dev_dbg(codec->dev, "M98090_ULK_MASK\n"); 2204 schedule_work(&max98090->pll_work); 2205 } |
2108 2109 if (active & M98090_JDET_MASK) { 2110 dev_dbg(codec->dev, "M98090_JDET_MASK\n"); 2111 2112 pm_wakeup_event(codec->dev, 100); 2113 2114 queue_delayed_work(system_power_efficient_wq, 2115 &max98090->jack_work, --- 56 unchanged lines hidden (view full) --- 2172#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) 2173 2174static struct snd_soc_dai_ops max98090_dai_ops = { 2175 .set_sysclk = max98090_dai_set_sysclk, 2176 .set_fmt = max98090_dai_set_fmt, 2177 .set_tdm_slot = max98090_set_tdm_slot, 2178 .hw_params = max98090_dai_hw_params, 2179 .digital_mute = max98090_dai_digital_mute, | 2206 2207 if (active & M98090_JDET_MASK) { 2208 dev_dbg(codec->dev, "M98090_JDET_MASK\n"); 2209 2210 pm_wakeup_event(codec->dev, 100); 2211 2212 queue_delayed_work(system_power_efficient_wq, 2213 &max98090->jack_work, --- 56 unchanged lines hidden (view full) --- 2270#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) 2271 2272static struct snd_soc_dai_ops max98090_dai_ops = { 2273 .set_sysclk = max98090_dai_set_sysclk, 2274 .set_fmt = max98090_dai_set_fmt, 2275 .set_tdm_slot = max98090_set_tdm_slot, 2276 .hw_params = max98090_dai_hw_params, 2277 .digital_mute = max98090_dai_digital_mute, |
2278 .trigger = max98090_dai_trigger, |
|
2180}; 2181 2182static struct snd_soc_dai_driver max98090_dai[] = { 2183{ 2184 .name = "HiFi", 2185 .playback = { 2186 .stream_name = "HiFi Playback", 2187 .channels_min = 2, --- 65 unchanged lines hidden (view full) --- 2253 if (max98090->devtype != devtype) { 2254 dev_warn(codec->dev, "Mismatch in DT specified CODEC type.\n"); 2255 max98090->devtype = devtype; 2256 } 2257 2258 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; 2259 2260 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); | 2279}; 2280 2281static struct snd_soc_dai_driver max98090_dai[] = { 2282{ 2283 .name = "HiFi", 2284 .playback = { 2285 .stream_name = "HiFi Playback", 2286 .channels_min = 2, --- 65 unchanged lines hidden (view full) --- 2352 if (max98090->devtype != devtype) { 2353 dev_warn(codec->dev, "Mismatch in DT specified CODEC type.\n"); 2354 max98090->devtype = devtype; 2355 } 2356 2357 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; 2358 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 2262 /* Enable jack detection */ 2263 snd_soc_write(codec, M98090_REG_JACK_DETECT, 2264 M98090_JDETEN_MASK | M98090_JDEB_25MS); 2265 2266 /* Register for interrupts */ 2267 dev_dbg(codec->dev, "irq = %d\n", max98090->irq); 2268 --- 36 unchanged lines hidden (view full) --- 2305 return ret; 2306} 2307 2308static int max98090_remove(struct snd_soc_codec *codec) 2309{ 2310 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); 2311 2312 cancel_delayed_work_sync(&max98090->jack_work); | 2365 2366 /* Enable jack detection */ 2367 snd_soc_write(codec, M98090_REG_JACK_DETECT, 2368 M98090_JDETEN_MASK | M98090_JDEB_25MS); 2369 2370 /* Register for interrupts */ 2371 dev_dbg(codec->dev, "irq = %d\n", max98090->irq); 2372 --- 36 unchanged lines hidden (view full) --- 2409 return ret; 2410} 2411 2412static int max98090_remove(struct snd_soc_codec *codec) 2413{ 2414 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); 2415 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 2314 return 0; 2315} 2316 2317static struct snd_soc_codec_driver soc_codec_dev_max98090 = { 2318 .probe = max98090_probe, 2319 .remove = max98090_remove, 2320 .set_bias_level = max98090_set_bias_level, --- 160 unchanged lines hidden --- | 2420 2421 return 0; 2422} 2423 2424static struct snd_soc_codec_driver soc_codec_dev_max98090 = { 2425 .probe = max98090_probe, 2426 .remove = max98090_remove, 2427 .set_bias_level = max98090_set_bias_level, --- 160 unchanged lines hidden --- |