Lines Matching full:max98090
3 * max98090.c -- MAX98090 ALSA SoC Audio driver
23 #include <sound/max98090.h>
24 #include "max98090.h"
276 static int max98090_reset(struct max98090_priv *max98090) in max98090_reset() argument
281 ret = regmap_write(max98090->regmap, M98090_REG_SOFTWARE_RESET, in max98090_reset()
284 dev_err(max98090->component->dev, in max98090_reset()
352 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_get_enab_tlv() local
361 select = &(max98090->pa1en); in max98090_get_enab_tlv()
364 select = &(max98090->pa2en); in max98090_get_enab_tlv()
367 select = &(max98090->sidetone); in max98090_get_enab_tlv()
392 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_put_enab_tlv() local
402 select = &(max98090->pa1en); in max98090_put_enab_tlv()
405 select = &(max98090->pa2en); in max98090_put_enab_tlv()
408 select = &(max98090->sidetone); in max98090_put_enab_tlv()
731 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_micinput_event() local
742 max98090->pa1en = val - 1; /* Update for volatile */ in max98090_micinput_event()
744 max98090->pa2en = val - 1; /* Update for volatile */ in max98090_micinput_event()
752 val = max98090->pa1en + 1; in max98090_micinput_event()
754 val = max98090->pa2en + 1; in max98090_micinput_event()
778 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_shdn_event() local
781 max98090->shdn_pending = true; in max98090_shdn_event()
1428 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_add_widgets() local
1434 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1445 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1484 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_configure_bclk() local
1488 if (!max98090->sysclk) { in max98090_configure_bclk()
1493 if (!max98090->bclk || !max98090->lrclk) { in max98090_configure_bclk()
1506 if ((pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1507 (lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1523 if ((user_pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1524 (user_lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1562 ni = 65536ULL * (max98090->lrclk < 50000 ? 96ULL : 48ULL) in max98090_configure_bclk()
1563 * (unsigned long long int)max98090->lrclk; in max98090_configure_bclk()
1564 do_div(ni, (unsigned long long int)max98090->sysclk); in max98090_configure_bclk()
1576 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_set_fmt() local
1580 max98090->dai_fmt = fmt; in max98090_dai_set_fmt()
1581 cdata = &max98090->dai[0]; in max98090_dai_set_fmt()
1596 max98090->master = false; in max98090_dai_set_fmt()
1600 if (max98090->tdm_slots == 4) { in max98090_dai_set_fmt()
1604 } else if (max98090->tdm_slots == 3) { in max98090_dai_set_fmt()
1613 max98090->master = true; in max98090_dai_set_fmt()
1658 * This accommodates an inverted logic in the MAX98090 chip in max98090_dai_set_fmt()
1663 if (max98090->tdm_slots > 1) in max98090_dai_set_fmt()
1677 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_set_tdm_slot() local
1679 cdata = &max98090->dai[0]; in max98090_set_tdm_slot()
1684 max98090->tdm_slots = slots; in max98090_set_tdm_slot()
1685 max98090->tdm_width = slot_width; in max98090_set_tdm_slot()
1687 if (max98090->tdm_slots > 1) { in max98090_set_tdm_slot()
1704 max98090_dai_set_fmt(codec_dai, max98090->dai_fmt); in max98090_set_tdm_slot()
1712 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_set_bias_level() local
1727 if (IS_ERR(max98090->mclk)) in max98090_set_bias_level()
1731 clk_disable_unprepare(max98090->mclk); in max98090_set_bias_level()
1733 ret = clk_prepare_enable(max98090->mclk); in max98090_set_bias_level()
1741 ret = regcache_sync(max98090->regmap); in max98090_set_bias_level()
1754 regcache_mark_dirty(max98090->regmap); in max98090_set_bias_level()
1874 static int max98090_configure_dmic(struct max98090_priv *max98090, in max98090_configure_dmic() argument
1897 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_ENABLE, in max98090_configure_dmic()
1901 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_CONFIG, in max98090_configure_dmic()
1913 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_startup() local
1914 unsigned int fmt = max98090->dai_fmt; in max98090_dai_startup()
1929 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_hw_params() local
1932 cdata = &max98090->dai[0]; in max98090_dai_hw_params()
1933 max98090->bclk = snd_soc_params_to_bclk(params); in max98090_dai_hw_params()
1935 max98090->bclk *= 2; in max98090_dai_hw_params()
1937 max98090->lrclk = params_rate(params); in max98090_dai_hw_params()
1948 if (max98090->master) in max98090_dai_hw_params()
1951 cdata->rate = max98090->lrclk; in max98090_dai_hw_params()
1954 if (max98090->lrclk < 24000) in max98090_dai_hw_params()
1962 if (max98090->lrclk < 50000) in max98090_dai_hw_params()
1969 max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk, in max98090_dai_hw_params()
1970 max98090->lrclk); in max98090_dai_hw_params()
1982 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_set_sysclk() local
1985 if (freq == max98090->sysclk) in max98090_dai_set_sysclk()
1988 if (!IS_ERR(max98090->mclk)) { in max98090_dai_set_sysclk()
1989 freq = clk_round_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
1990 clk_set_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
2001 max98090->pclk = freq; in max98090_dai_set_sysclk()
2005 max98090->pclk = freq >> 1; in max98090_dai_set_sysclk()
2009 max98090->pclk = freq >> 2; in max98090_dai_set_sysclk()
2015 max98090->sysclk = freq; in max98090_dai_set_sysclk()
2037 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_trigger() local
2043 if (!max98090->master && snd_soc_dai_active(dai) == 1) in max98090_dai_trigger()
2045 &max98090->pll_det_enable_work, in max98090_dai_trigger()
2051 if (!max98090->master && snd_soc_dai_active(dai) == 1) in max98090_dai_trigger()
2052 schedule_work(&max98090->pll_det_disable_work); in max98090_dai_trigger()
2063 struct max98090_priv *max98090 = in max98090_pll_det_enable_work() local
2066 struct snd_soc_component *component = max98090->component; in max98090_pll_det_enable_work()
2075 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_pll_det_enable_work()
2081 regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_pll_det_enable_work()
2085 &max98090->jack_work, in max98090_pll_det_enable_work()
2096 struct max98090_priv *max98090 = in max98090_pll_det_disable_work() local
2098 struct snd_soc_component *component = max98090->component; in max98090_pll_det_disable_work()
2100 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_pll_det_disable_work()
2107 static void max98090_pll_work(struct max98090_priv *max98090) in max98090_pll_work() argument
2109 struct snd_soc_component *component = max98090->component; in max98090_pll_work()
2145 struct max98090_priv *max98090 = container_of(work, in max98090_jack_work() local
2148 struct snd_soc_component *component = max98090->component; in max98090_jack_work()
2153 if (max98090->jack_state == M98090_JACK_STATE_NO_HEADSET) { in max98090_jack_work()
2176 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_jack_work()
2183 if (max98090->jack_state == in max98090_jack_work()
2205 max98090->jack_state = M98090_JACK_STATE_HEADPHONE; in max98090_jack_work()
2214 max98090->jack_state = M98090_JACK_STATE_HEADSET; in max98090_jack_work()
2225 snd_soc_jack_report(max98090->jack, status, in max98090_jack_work()
2231 struct max98090_priv *max98090 = data; in max98090_interrupt() local
2232 struct snd_soc_component *component = max98090->component; in max98090_interrupt()
2243 ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_interrupt()
2252 ret = regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &active); in max98090_interrupt()
2277 max98090_pll_work(max98090); in max98090_interrupt()
2286 &max98090->jack_work, in max98090_interrupt()
2300 * max98090_mic_detect - Enable microphone detection via the MAX98090 IRQ
2302 * @component: MAX98090 component
2305 * Enable microphone detection via IRQ on the MAX98090. If GPIOs are
2307 * data configuration is needed for MAX98090 and processor GPIOs should
2315 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_mic_detect() local
2319 max98090->jack = jack; in max98090_mic_detect()
2331 snd_soc_jack_report(max98090->jack, 0, in max98090_mic_detect()
2335 &max98090->jack_work, in max98090_mic_detect()
2379 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_probe() local
2388 max98090->mclk = devm_clk_get(component->dev, "mclk"); in max98090_probe()
2389 if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) in max98090_probe()
2392 max98090->component = component; in max98090_probe()
2395 max98090_reset(max98090); in max98090_probe()
2399 max98090->sysclk = (unsigned)-1; in max98090_probe()
2400 max98090->pclk = (unsigned)-1; in max98090_probe()
2401 max98090->master = false; in max98090_probe()
2403 cdata = &max98090->dai[0]; in max98090_probe()
2407 max98090->lin_state = 0; in max98090_probe()
2408 max98090->pa1en = 0; in max98090_probe()
2409 max98090->pa2en = 0; in max98090_probe()
2419 devtype = MAX98090; in max98090_probe()
2420 dev_info(component->dev, "MAX98090 REVID=0x%02x\n", ret); in max98090_probe()
2425 devtype = MAX98090; in max98090_probe()
2429 if (max98090->devtype != devtype) { in max98090_probe()
2431 max98090->devtype = devtype; in max98090_probe()
2434 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_probe()
2436 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); in max98090_probe()
2437 INIT_DELAYED_WORK(&max98090->pll_det_enable_work, in max98090_probe()
2439 INIT_WORK(&max98090->pll_det_disable_work, in max98090_probe()
2488 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_remove() local
2490 cancel_delayed_work_sync(&max98090->jack_work); in max98090_remove()
2491 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_remove()
2492 cancel_work_sync(&max98090->pll_det_disable_work); in max98090_remove()
2493 max98090->component = NULL; in max98090_remove()
2499 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_seq_notifier() local
2501 if (max98090->shdn_pending) { in max98090_seq_notifier()
2507 max98090->shdn_pending = false; in max98090_seq_notifier()
2537 struct max98090_priv *max98090; in max98090_i2c_probe() local
2544 max98090 = devm_kzalloc(&i2c->dev, sizeof(struct max98090_priv), in max98090_i2c_probe()
2546 if (max98090 == NULL) in max98090_i2c_probe()
2561 max98090->devtype = driver_data; in max98090_i2c_probe()
2562 i2c_set_clientdata(i2c, max98090); in max98090_i2c_probe()
2563 max98090->pdata = i2c->dev.platform_data; in max98090_i2c_probe()
2566 &max98090->dmic_freq); in max98090_i2c_probe()
2568 max98090->dmic_freq = MAX98090_DEFAULT_DMIC_FREQ; in max98090_i2c_probe()
2570 max98090->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap); in max98090_i2c_probe()
2571 if (IS_ERR(max98090->regmap)) { in max98090_i2c_probe()
2572 ret = PTR_ERR(max98090->regmap); in max98090_i2c_probe()
2579 "max98090_interrupt", max98090); in max98090_i2c_probe()
2595 struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev); in max98090_i2c_shutdown() local
2601 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2603 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2618 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_runtime_resume() local
2620 regcache_cache_only(max98090->regmap, false); in max98090_runtime_resume()
2622 max98090_reset(max98090); in max98090_runtime_resume()
2624 regcache_sync(max98090->regmap); in max98090_runtime_resume()
2631 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_runtime_suspend() local
2633 regcache_cache_only(max98090->regmap, true); in max98090_runtime_suspend()
2642 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_resume() local
2645 regcache_mark_dirty(max98090->regmap); in max98090_resume()
2647 max98090_reset(max98090); in max98090_resume()
2650 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_resume()
2652 regcache_sync(max98090->regmap); in max98090_resume()
2665 { "max98090", MAX98090 },
2672 { .compatible = "maxim,max98090", },
2680 { "193C9890", MAX98090 },
2688 .name = "max98090",
2701 MODULE_DESCRIPTION("ALSA SoC MAX98090 driver");