Lines Matching full:max98090
3 * max98090.c -- MAX98090 ALSA SoC Audio driver
22 #include <sound/max98090.h>
23 #include "max98090.h"
275 static int max98090_reset(struct max98090_priv *max98090) in max98090_reset() argument
280 ret = regmap_write(max98090->regmap, M98090_REG_SOFTWARE_RESET, in max98090_reset()
283 dev_err(max98090->component->dev, in max98090_reset()
351 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_get_enab_tlv() local
360 select = &(max98090->pa1en); in max98090_get_enab_tlv()
363 select = &(max98090->pa2en); in max98090_get_enab_tlv()
366 select = &(max98090->sidetone); in max98090_get_enab_tlv()
391 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()
737 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_micinput_event() local
748 max98090->pa1en = val - 1; /* Update for volatile */ in max98090_micinput_event()
750 max98090->pa2en = val - 1; /* Update for volatile */ in max98090_micinput_event()
758 val = max98090->pa1en + 1; in max98090_micinput_event()
760 val = max98090->pa2en + 1; in max98090_micinput_event()
784 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_shdn_event() local
787 max98090->shdn_pending = true; in max98090_shdn_event()
1434 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_add_widgets() local
1440 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1451 if (max98090->devtype == MAX98091) { in max98090_add_widgets()
1490 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_configure_bclk() local
1494 if (!max98090->sysclk) { in max98090_configure_bclk()
1499 if (!max98090->bclk || !max98090->lrclk) { in max98090_configure_bclk()
1512 if ((pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1513 (lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1529 if ((user_pclk_rates[i] == max98090->sysclk) && in max98090_configure_bclk()
1530 (user_lrclk_rates[i] == max98090->lrclk)) { in max98090_configure_bclk()
1568 ni = 65536ULL * (max98090->lrclk < 50000 ? 96ULL : 48ULL) in max98090_configure_bclk()
1569 * (unsigned long long int)max98090->lrclk; in max98090_configure_bclk()
1570 do_div(ni, (unsigned long long int)max98090->sysclk); in max98090_configure_bclk()
1582 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_set_fmt() local
1586 max98090->dai_fmt = fmt; in max98090_dai_set_fmt()
1587 cdata = &max98090->dai[0]; in max98090_dai_set_fmt()
1603 max98090->master = false; in max98090_dai_set_fmt()
1607 if (max98090->tdm_slots == 4) { in max98090_dai_set_fmt()
1611 } else if (max98090->tdm_slots == 3) { in max98090_dai_set_fmt()
1620 max98090->master = true; in max98090_dai_set_fmt()
1664 * This accommodates an inverted logic in the MAX98090 chip in max98090_dai_set_fmt()
1677 regval = max98090->tdm_lslot << M98090_TDM_SLOTL_SHIFT | in max98090_dai_set_fmt()
1678 max98090->tdm_rslot << M98090_TDM_SLOTR_SHIFT | in max98090_dai_set_fmt()
1692 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_set_tdm_slot() local
1706 max98090->tdm_slots = slots; in max98090_set_tdm_slot()
1707 max98090->tdm_lslot = ffs(rx_mask) - 1; in max98090_set_tdm_slot()
1708 max98090->tdm_rslot = fls(rx_mask) - 1; in max98090_set_tdm_slot()
1716 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_set_bias_level() local
1731 if (IS_ERR(max98090->mclk)) in max98090_set_bias_level()
1735 clk_disable_unprepare(max98090->mclk); in max98090_set_bias_level()
1737 ret = clk_prepare_enable(max98090->mclk); in max98090_set_bias_level()
1745 ret = regcache_sync(max98090->regmap); in max98090_set_bias_level()
1758 regcache_mark_dirty(max98090->regmap); in max98090_set_bias_level()
1878 static int max98090_configure_dmic(struct max98090_priv *max98090, in max98090_configure_dmic() argument
1901 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_ENABLE, in max98090_configure_dmic()
1905 regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_CONFIG, in max98090_configure_dmic()
1917 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_startup() local
1918 unsigned int fmt = max98090->dai_fmt; in max98090_dai_startup()
1933 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_hw_params() local
1936 cdata = &max98090->dai[0]; in max98090_dai_hw_params()
1937 max98090->bclk = snd_soc_params_to_bclk(params); in max98090_dai_hw_params()
1939 max98090->bclk *= 2; in max98090_dai_hw_params()
1941 max98090->lrclk = params_rate(params); in max98090_dai_hw_params()
1952 if (max98090->master) in max98090_dai_hw_params()
1955 cdata->rate = max98090->lrclk; in max98090_dai_hw_params()
1958 if (max98090->lrclk < 24000) in max98090_dai_hw_params()
1966 if (max98090->lrclk < 50000) in max98090_dai_hw_params()
1973 max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk, in max98090_dai_hw_params()
1974 max98090->lrclk); in max98090_dai_hw_params()
1986 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_set_sysclk() local
1989 if (freq == max98090->sysclk) in max98090_dai_set_sysclk()
1992 if (!IS_ERR(max98090->mclk)) { in max98090_dai_set_sysclk()
1993 freq = clk_round_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
1994 clk_set_rate(max98090->mclk, freq); in max98090_dai_set_sysclk()
2005 max98090->pclk = freq; in max98090_dai_set_sysclk()
2009 max98090->pclk = freq >> 1; in max98090_dai_set_sysclk()
2013 max98090->pclk = freq >> 2; in max98090_dai_set_sysclk()
2019 max98090->sysclk = freq; in max98090_dai_set_sysclk()
2041 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_dai_trigger() local
2047 if (!max98090->master && snd_soc_dai_active(dai) == 1) in max98090_dai_trigger()
2049 &max98090->pll_det_enable_work, in max98090_dai_trigger()
2055 if (!max98090->master && snd_soc_dai_active(dai) == 1) in max98090_dai_trigger()
2056 schedule_work(&max98090->pll_det_disable_work); in max98090_dai_trigger()
2067 struct max98090_priv *max98090 = in max98090_pll_det_enable_work() local
2070 struct snd_soc_component *component = max98090->component; in max98090_pll_det_enable_work()
2079 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_pll_det_enable_work()
2085 regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_pll_det_enable_work()
2089 &max98090->jack_work, in max98090_pll_det_enable_work()
2100 struct max98090_priv *max98090 = in max98090_pll_det_disable_work() local
2102 struct snd_soc_component *component = max98090->component; in max98090_pll_det_disable_work()
2104 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_pll_det_disable_work()
2111 static void max98090_pll_work(struct max98090_priv *max98090) in max98090_pll_work() argument
2113 struct snd_soc_component *component = max98090->component; in max98090_pll_work()
2149 struct max98090_priv *max98090 = container_of(work, in max98090_jack_work() local
2152 struct snd_soc_component *component = max98090->component; in max98090_jack_work()
2157 if (max98090->jack_state == M98090_JACK_STATE_NO_HEADSET) { in max98090_jack_work()
2178 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_jack_work()
2185 if (max98090->jack_state == in max98090_jack_work()
2207 max98090->jack_state = M98090_JACK_STATE_HEADPHONE; in max98090_jack_work()
2216 max98090->jack_state = M98090_JACK_STATE_HEADSET; in max98090_jack_work()
2227 snd_soc_jack_report(max98090->jack, status, in max98090_jack_work()
2233 struct max98090_priv *max98090 = data; in max98090_interrupt() local
2234 struct snd_soc_component *component = max98090->component; in max98090_interrupt()
2245 ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); in max98090_interrupt()
2254 ret = regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &active); in max98090_interrupt()
2279 max98090_pll_work(max98090); in max98090_interrupt()
2288 &max98090->jack_work, in max98090_interrupt()
2302 * max98090_mic_detect - Enable microphone detection via the MAX98090 IRQ
2304 * @component: MAX98090 component
2307 * Enable microphone detection via IRQ on the MAX98090. If GPIOs are
2309 * data configuration is needed for MAX98090 and processor GPIOs should
2317 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_mic_detect() local
2321 max98090->jack = jack; in max98090_mic_detect()
2333 snd_soc_jack_report(max98090->jack, 0, in max98090_mic_detect()
2337 &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()
2411 max98090->tdm_lslot = 0; in max98090_probe()
2412 max98090->tdm_rslot = 1; in max98090_probe()
2422 devtype = MAX98090; in max98090_probe()
2423 dev_info(component->dev, "MAX98090 REVID=0x%02x\n", ret); in max98090_probe()
2428 devtype = MAX98090; in max98090_probe()
2432 if (max98090->devtype != devtype) { in max98090_probe()
2434 max98090->devtype = devtype; in max98090_probe()
2437 max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; in max98090_probe()
2439 INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); in max98090_probe()
2440 INIT_DELAYED_WORK(&max98090->pll_det_enable_work, in max98090_probe()
2442 INIT_WORK(&max98090->pll_det_disable_work, in max98090_probe()
2491 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_remove() local
2493 cancel_delayed_work_sync(&max98090->jack_work); in max98090_remove()
2494 cancel_delayed_work_sync(&max98090->pll_det_enable_work); in max98090_remove()
2495 cancel_work_sync(&max98090->pll_det_disable_work); in max98090_remove()
2496 max98090->component = NULL; in max98090_remove()
2502 struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); in max98090_seq_notifier() local
2504 if (max98090->shdn_pending) { in max98090_seq_notifier()
2510 max98090->shdn_pending = false; in max98090_seq_notifier()
2537 { "max98090", MAX98090 },
2545 struct max98090_priv *max98090; in max98090_i2c_probe() local
2552 max98090 = devm_kzalloc(&i2c->dev, sizeof(struct max98090_priv), in max98090_i2c_probe()
2554 if (max98090 == NULL) in max98090_i2c_probe()
2571 max98090->devtype = driver_data; in max98090_i2c_probe()
2572 i2c_set_clientdata(i2c, max98090); in max98090_i2c_probe()
2573 max98090->pdata = i2c->dev.platform_data; in max98090_i2c_probe()
2576 &max98090->dmic_freq); in max98090_i2c_probe()
2578 max98090->dmic_freq = MAX98090_DEFAULT_DMIC_FREQ; in max98090_i2c_probe()
2580 max98090->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap); in max98090_i2c_probe()
2581 if (IS_ERR(max98090->regmap)) { in max98090_i2c_probe()
2582 ret = PTR_ERR(max98090->regmap); in max98090_i2c_probe()
2589 "max98090_interrupt", max98090); in max98090_i2c_probe()
2605 struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev); in max98090_i2c_shutdown() local
2611 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2613 regmap_write(max98090->regmap, in max98090_i2c_shutdown()
2626 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_runtime_resume() local
2628 regcache_cache_only(max98090->regmap, false); in max98090_runtime_resume()
2630 max98090_reset(max98090); in max98090_runtime_resume()
2632 regcache_sync(max98090->regmap); in max98090_runtime_resume()
2639 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_runtime_suspend() local
2641 regcache_cache_only(max98090->regmap, true); in max98090_runtime_suspend()
2650 struct max98090_priv *max98090 = dev_get_drvdata(dev); in max98090_resume() local
2653 regcache_mark_dirty(max98090->regmap); in max98090_resume()
2655 max98090_reset(max98090); in max98090_resume()
2658 regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status); in max98090_resume()
2660 regcache_sync(max98090->regmap); in max98090_resume()
2674 { .compatible = "maxim,max98090", },
2683 { "193C9890", MAX98090 },
2691 .name = "max98090",
2704 MODULE_DESCRIPTION("ALSA SoC MAX98090 driver");