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
403 select = &(max98090->pa1en); in max98090_put_enab_tlv()
406 select = &(max98090->pa2en); in max98090_put_enab_tlv()
409 select = &(max98090->sidetone); in max98090_put_enab_tlv()
736 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_micinput_event() local
747 max98090->pa1en = val - 1; /* Update for volatile */ in max98090_micinput_event()
749 max98090->pa2en = val - 1; /* Update for volatile */ in max98090_micinput_event()
757 val = max98090->pa1en + 1; in max98090_micinput_event()
759 val = max98090->pa2en + 1; in max98090_micinput_event()
783 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_shdn_event() local
786 max98090->shdn_pending = true; in max98090_shdn_event()
1433 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_add_widgets() local
1439 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1450 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1489 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_configure_bclk() local
1493 if (!max98090->sysclk) { in max98090_configure_bclk()
1498 if (!max98090->bclk || !max98090->lrclk) { in max98090_configure_bclk()
1511 if ((pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1512 (lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1528 if ((user_pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1529 (user_lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1567 ni = 65536ULL * (max98090->lrclk < 50000 ? 96ULL : 48ULL) in max98090_configure_bclk()
1568 * (unsigned long long int)max98090->lrclk; in max98090_configure_bclk()
1569 do_div(ni, (unsigned long long int)max98090->sysclk); in max98090_configure_bclk()
1581 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_set_fmt() local
1585 max98090->dai_fmt = fmt; in max98090_dai_set_fmt()
1586 cdata = &max98090->dai[0]; in max98090_dai_set_fmt()
1601 max98090->master = false; in max98090_dai_set_fmt()
1605 if (max98090->tdm_slots == 4) { in max98090_dai_set_fmt()
1609 } else if (max98090->tdm_slots == 3) { in max98090_dai_set_fmt()
1618 max98090->master = true; in max98090_dai_set_fmt()
1663 * This accommodates an inverted logic in the MAX98090 chip in max98090_dai_set_fmt()
1668 if (max98090->tdm_slots > 1) in max98090_dai_set_fmt()
1682 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_set_tdm_slot() local
1684 cdata = &max98090->dai[0]; in max98090_set_tdm_slot()
1689 max98090->tdm_slots = slots; in max98090_set_tdm_slot()
1690 max98090->tdm_width = slot_width; in max98090_set_tdm_slot()
1692 if (max98090->tdm_slots > 1) { in max98090_set_tdm_slot()
1709 max98090_dai_set_fmt(codec_dai, max98090->dai_fmt); in max98090_set_tdm_slot()
1717 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_set_bias_level() local
1732 if (IS_ERR(max98090->mclk)) in max98090_set_bias_level()
1736 clk_disable_unprepare(max98090->mclk); in max98090_set_bias_level()
1738 ret = clk_prepare_enable(max98090->mclk); in max98090_set_bias_level()
1746 ret = regcache_sync(max98090->regmap); in max98090_set_bias_level()
1759 regcache_mark_dirty(max98090->regmap); in max98090_set_bias_level()
1879 static int max98090_configure_dmic(struct max98090_priv *max98090, in max98090_configure_dmic() argument
1902 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_ENABLE, in max98090_configure_dmic()
1906 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_CONFIG, in max98090_configure_dmic()
1918 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_startup() local
1919 unsigned int fmt = max98090->dai_fmt; in max98090_dai_startup()
1934 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_hw_params() local
1937 cdata = &max98090->dai[0]; in max98090_dai_hw_params()
1938 max98090->bclk = snd_soc_params_to_bclk(params); in max98090_dai_hw_params()
1940 max98090->bclk *= 2; in max98090_dai_hw_params()
1942 max98090->lrclk = params_rate(params); in max98090_dai_hw_params()
1953 if (max98090->master) in max98090_dai_hw_params()
1956 cdata->rate = max98090->lrclk; in max98090_dai_hw_params()
1959 if (max98090->lrclk < 24000) in max98090_dai_hw_params()
1967 if (max98090->lrclk < 50000) in max98090_dai_hw_params()
1974 max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk, in max98090_dai_hw_params()
1975 max98090->lrclk); in max98090_dai_hw_params()
1987 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_set_sysclk() local
1990 if (freq == max98090->sysclk) in max98090_dai_set_sysclk()
1993 if (!IS_ERR(max98090->mclk)) { in max98090_dai_set_sysclk()
1994 freq = clk_round_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
1995 clk_set_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
2006 max98090->pclk = freq; in max98090_dai_set_sysclk()
2010 max98090->pclk = freq >> 1; in max98090_dai_set_sysclk()
2014 max98090->pclk = freq >> 2; in max98090_dai_set_sysclk()
2020 max98090->sysclk = freq; in max98090_dai_set_sysclk()
2042 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_trigger() local
2048 if (!max98090->master && snd_soc_dai_active(dai) == 1) in max98090_dai_trigger()
2050 &max98090->pll_det_enable_work, in max98090_dai_trigger()
2056 if (!max98090->master && snd_soc_dai_active(dai) == 1) in max98090_dai_trigger()
2057 schedule_work(&max98090->pll_det_disable_work); in max98090_dai_trigger()
2068 struct max98090_priv *max98090 = in max98090_pll_det_enable_work() local
2071 struct snd_soc_component *component = max98090->component; in max98090_pll_det_enable_work()
2080 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_pll_det_enable_work()
2086 regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_pll_det_enable_work()
2090 &max98090->jack_work, in max98090_pll_det_enable_work()
2101 struct max98090_priv *max98090 = in max98090_pll_det_disable_work() local
2103 struct snd_soc_component *component = max98090->component; in max98090_pll_det_disable_work()
2105 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_pll_det_disable_work()
2112 static void max98090_pll_work(struct max98090_priv *max98090) in max98090_pll_work() argument
2114 struct snd_soc_component *component = max98090->component; in max98090_pll_work()
2150 struct max98090_priv *max98090 = container_of(work, in max98090_jack_work() local
2153 struct snd_soc_component *component = max98090->component; in max98090_jack_work()
2158 if (max98090->jack_state == M98090_JACK_STATE_NO_HEADSET) { in max98090_jack_work()
2181 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_jack_work()
2188 if (max98090->jack_state == in max98090_jack_work()
2210 max98090->jack_state = M98090_JACK_STATE_HEADPHONE; in max98090_jack_work()
2219 max98090->jack_state = M98090_JACK_STATE_HEADSET; in max98090_jack_work()
2230 snd_soc_jack_report(max98090->jack, status, in max98090_jack_work()
2236 struct max98090_priv *max98090 = data; in max98090_interrupt() local
2237 struct snd_soc_component *component = max98090->component; in max98090_interrupt()
2248 ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_interrupt()
2257 ret = regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &active); in max98090_interrupt()
2282 max98090_pll_work(max98090); in max98090_interrupt()
2291 &max98090->jack_work, in max98090_interrupt()
2305 * max98090_mic_detect - Enable microphone detection via the MAX98090 IRQ
2307 * @component: MAX98090 component
2310 * Enable microphone detection via IRQ on the MAX98090. If GPIOs are
2312 * data configuration is needed for MAX98090 and processor GPIOs should
2320 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_mic_detect() local
2324 max98090->jack = jack; in max98090_mic_detect()
2336 snd_soc_jack_report(max98090->jack, 0, in max98090_mic_detect()
2340 &max98090->jack_work, in max98090_mic_detect()
2384 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_probe() local
2393 max98090->mclk = devm_clk_get(component->dev, "mclk"); in max98090_probe()
2394 if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) in max98090_probe()
2397 max98090->component = component; in max98090_probe()
2400 max98090_reset(max98090); in max98090_probe()
2404 max98090->sysclk = (unsigned)-1; in max98090_probe()
2405 max98090->pclk = (unsigned)-1; in max98090_probe()
2406 max98090->master = false; in max98090_probe()
2408 cdata = &max98090->dai[0]; in max98090_probe()
2412 max98090->lin_state = 0; in max98090_probe()
2413 max98090->pa1en = 0; in max98090_probe()
2414 max98090->pa2en = 0; in max98090_probe()
2424 devtype = MAX98090; in max98090_probe()
2425 dev_info(component->dev, "MAX98090 REVID=0x%02x\n", ret); in max98090_probe()
2430 devtype = MAX98090; in max98090_probe()
2434 if (max98090->devtype != devtype) { in max98090_probe()
2436 max98090->devtype = devtype; in max98090_probe()
2439 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_probe()
2441 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); in max98090_probe()
2442 INIT_DELAYED_WORK(&max98090->pll_det_enable_work, in max98090_probe()
2444 INIT_WORK(&max98090->pll_det_disable_work, in max98090_probe()
2493 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_remove() local
2495 cancel_delayed_work_sync(&max98090->jack_work); in max98090_remove()
2496 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_remove()
2497 cancel_work_sync(&max98090->pll_det_disable_work); in max98090_remove()
2498 max98090->component = NULL; in max98090_remove()
2504 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_seq_notifier() local
2506 if (max98090->shdn_pending) { in max98090_seq_notifier()
2512 max98090->shdn_pending = false; in max98090_seq_notifier()
2542 struct max98090_priv *max98090; in max98090_i2c_probe() local
2549 max98090 = devm_kzalloc(&i2c->dev, sizeof(struct max98090_priv), in max98090_i2c_probe()
2551 if (max98090 == NULL) in max98090_i2c_probe()
2566 max98090->devtype = driver_data; in max98090_i2c_probe()
2567 i2c_set_clientdata(i2c, max98090); in max98090_i2c_probe()
2568 max98090->pdata = i2c->dev.platform_data; in max98090_i2c_probe()
2571 &max98090->dmic_freq); in max98090_i2c_probe()
2573 max98090->dmic_freq = MAX98090_DEFAULT_DMIC_FREQ; in max98090_i2c_probe()
2575 max98090->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap); in max98090_i2c_probe()
2576 if (IS_ERR(max98090->regmap)) { in max98090_i2c_probe()
2577 ret = PTR_ERR(max98090->regmap); in max98090_i2c_probe()
2584 "max98090_interrupt", max98090); in max98090_i2c_probe()
2600 struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev); in max98090_i2c_shutdown() local
2606 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2608 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2623 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_runtime_resume() local
2625 regcache_cache_only(max98090->regmap, false); in max98090_runtime_resume()
2627 max98090_reset(max98090); in max98090_runtime_resume()
2629 regcache_sync(max98090->regmap); in max98090_runtime_resume()
2636 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_runtime_suspend() local
2638 regcache_cache_only(max98090->regmap, true); in max98090_runtime_suspend()
2647 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_resume() local
2650 regcache_mark_dirty(max98090->regmap); in max98090_resume()
2652 max98090_reset(max98090); in max98090_resume()
2655 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_resume()
2657 regcache_sync(max98090->regmap); in max98090_resume()
2670 { "max98090", MAX98090 },
2677 { .compatible = "maxim,max98090", },
2685 { "193C9890", MAX98090 },
2693 .name = "max98090",
2706 MODULE_DESCRIPTION("ALSA SoC MAX98090 driver");