Lines Matching defs:wm8996
3 * wm8996.c - WM8996 audio codec interface
32 #include <sound/wm8996.h>
33 #include "wm8996.h"
105 struct wm8996_priv *wm8996 = container_of(nb, struct wm8996_priv, \
108 regcache_mark_dirty(wm8996->regmap); \
336 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
337 struct wm8996_pdata *pdata = &wm8996->pdata;
340 if (!wm8996->num_retune_mobile_texts)
366 cfg = wm8996->retune_mobile_cfg[block];
371 wm8996->retune_mobile_texts[cfg]) == 0 &&
373 - wm8996->rx_rate[iface]) < best_val) {
376 - wm8996->rx_rate[iface]);
384 wm8996->rx_rate[iface]);
413 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
414 struct wm8996_pdata *pdata = &wm8996->pdata;
424 wm8996->retune_mobile_cfg[block] = value;
435 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
440 ucontrol->value.enumerated.item[0] = wm8996->retune_mobile_cfg[block];
576 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
578 wm8996->bg_ena++;
579 if (wm8996->bg_ena == 1) {
588 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
590 wm8996->bg_ena--;
591 if (!wm8996->bg_ena)
635 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
640 wm8996->hpout_pending &= ~w->shift;
643 wm8996->hpout_pending |= w->shift;
656 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
665 timeout = wait_for_completion_timeout(&wm8996->dcs_done,
688 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
692 if (wm8996->dcs_pending) {
694 wm8996->dcs_pending);
697 wait_for_dc_servo(component, wm8996->dcs_pending
700 wm8996->dcs_pending = 0;
703 if (wm8996->hpout_pending != wm8996->hpout_ena) {
705 wm8996->hpout_ena, wm8996->hpout_pending);
709 if (wm8996->hpout_pending & HPOUT1L) {
718 if (wm8996->hpout_pending & HPOUT1R) {
731 if (wm8996->hpout_pending & HPOUT2L) {
740 if (wm8996->hpout_pending & HPOUT2R) {
751 wm8996->hpout_ena = wm8996->hpout_pending;
759 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
763 wm8996->dcs_pending |= 1 << w->shift;
1533 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
1539 if (wm8996->sysclk < 64000)
1552 bclk_rate = wm8996->bclk_rate[aif];
1557 cur_val = (wm8996->sysclk / bclk_divs[i]) - bclk_rate;
1562 bclk_rate = wm8996->sysclk / bclk_divs[best];
1574 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
1590 ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies),
1591 wm8996->supplies);
1599 if (wm8996->pdata.ldo_ena >= 0) {
1600 gpio_set_value_cansleep(wm8996->pdata.ldo_ena,
1605 regcache_cache_only(wm8996->regmap, false);
1606 regcache_sync(wm8996->regmap);
1617 regcache_cache_only(wm8996->regmap, true);
1618 if (wm8996->pdata.ldo_ena >= 0) {
1619 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
1620 regcache_cache_only(wm8996->regmap, true);
1622 regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies),
1623 wm8996->supplies);
1734 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
1775 wm8996->bclk_rate[dai->id] = bclk_rate;
1776 wm8996->rx_rate[dai->id] = params_rate(params);
1814 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
1821 if (freq == wm8996->sysclk && clk_id == wm8996->sysclk_src)
1831 wm8996->sysclk = freq;
1835 wm8996->sysclk = freq;
1839 wm8996->sysclk = freq;
1847 switch (wm8996->sysclk) {
1856 wm8996->sysclk /= 2;
1870 wm8996->sysclk);
1885 wm8996->sysclk_src = clk_id;
2004 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2011 if (source == wm8996->fll_src && Fref == wm8996->fll_fref &&
2012 Fout == wm8996->fll_fout)
2018 wm8996->fll_fref = 0;
2019 wm8996->fll_fout = 0;
2086 try_wait_for_completion(&wm8996->fll_lock);
2112 time_left = wait_for_completion_timeout(&wm8996->fll_lock,
2131 wm8996->fll_fref = Fref;
2132 wm8996->fll_fout = Fout;
2133 wm8996->fll_src = source;
2141 struct wm8996_priv *wm8996 = gpiochip_get_data(chip);
2143 regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset,
2150 struct wm8996_priv *wm8996 = gpiochip_get_data(chip);
2155 return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset,
2162 struct wm8996_priv *wm8996 = gpiochip_get_data(chip);
2166 ret = regmap_read(wm8996->regmap, WM8996_GPIO_1 + offset, ®);
2175 struct wm8996_priv *wm8996 = gpiochip_get_data(chip);
2177 return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset,
2184 .label = "wm8996",
2193 static void wm8996_init_gpio(struct wm8996_priv *wm8996)
2197 wm8996->gpio_chip = wm8996_template_chip;
2198 wm8996->gpio_chip.ngpio = 5;
2199 wm8996->gpio_chip.parent = wm8996->dev;
2201 if (wm8996->pdata.gpio_base)
2202 wm8996->gpio_chip.base = wm8996->pdata.gpio_base;
2204 wm8996->gpio_chip.base = -1;
2206 ret = gpiochip_add_data(&wm8996->gpio_chip, wm8996);
2208 dev_err(wm8996->dev, "Failed to add GPIOs: %d\n", ret);
2211 static void wm8996_free_gpio(struct wm8996_priv *wm8996)
2213 gpiochip_remove(&wm8996->gpio_chip);
2216 static void wm8996_init_gpio(struct wm8996_priv *wm8996)
2220 static void wm8996_free_gpio(struct wm8996_priv *wm8996)
2242 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2245 wm8996->jack = jack;
2246 wm8996->detecting = true;
2247 wm8996->polarity_cb = polarity_cb;
2248 wm8996->jack_flips = 0;
2250 if (wm8996->polarity_cb)
2251 wm8996->polarity_cb(component, 0);
2289 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2321 if (wm8996->jack_mic)
2324 snd_soc_jack_report(wm8996->jack, report,
2327 wm8996->detecting = false;
2386 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2401 wm8996->jack_mic = false;
2402 wm8996->detecting = true;
2403 wm8996->jack_flips = 0;
2404 snd_soc_jack_report(wm8996->jack, 0,
2421 if (wm8996->detecting) {
2423 wm8996->jack_mic = true;
2435 snd_soc_jack_report(wm8996->jack, 0, SND_JACK_BTN_0);
2447 if (wm8996->detecting && (val & 0x3f0)) {
2448 wm8996->jack_flips++;
2450 if (wm8996->jack_flips > 1) {
2462 if (wm8996->polarity_cb)
2463 wm8996->polarity_cb(component,
2476 if (wm8996->jack_mic) {
2478 snd_soc_jack_report(wm8996->jack, SND_JACK_BTN_0,
2480 } else if (wm8996->detecting) {
2489 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2507 complete(&wm8996->dcs_done);
2515 complete(&wm8996->fll_lock);
2543 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2544 struct wm8996_pdata *pdata = &wm8996->pdata;
2548 wm8996->retune_mobile_enum,
2552 wm8996->retune_mobile_enum,
2563 wm8996->num_retune_mobile_texts = 0;
2564 wm8996->retune_mobile_texts = NULL;
2566 for (j = 0; j < wm8996->num_retune_mobile_texts; j++) {
2568 wm8996->retune_mobile_texts[j]) == 0)
2572 if (j != wm8996->num_retune_mobile_texts)
2576 t = krealloc(wm8996->retune_mobile_texts,
2578 (wm8996->num_retune_mobile_texts + 1),
2584 t[wm8996->num_retune_mobile_texts] =
2588 wm8996->num_retune_mobile_texts++;
2589 wm8996->retune_mobile_texts = t;
2593 wm8996->num_retune_mobile_texts);
2595 wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts;
2596 wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts;
2619 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
2623 wm8996->component = component;
2625 init_completion(&wm8996->dcs_done);
2626 init_completion(&wm8996->fll_lock);
2628 if (wm8996->pdata.num_retune_mobile_cfgs)
2635 if (wm8996->pdata.irq_flags)
2636 irq_flags = wm8996->pdata.irq_flags;
2645 irq_flags, "wm8996", component);
2648 irq_flags, "wm8996", component);
2715 .name = "wm8996-aif1",
2735 .name = "wm8996-aif2",
2758 struct wm8996_priv *wm8996;
2762 wm8996 = devm_kzalloc(&i2c->dev, sizeof(struct wm8996_priv),
2764 if (wm8996 == NULL)
2767 i2c_set_clientdata(i2c, wm8996);
2768 wm8996->dev = &i2c->dev;
2771 memcpy(&wm8996->pdata, dev_get_platdata(&i2c->dev),
2772 sizeof(wm8996->pdata));
2774 if (wm8996->pdata.ldo_ena > 0) {
2775 ret = gpio_request_one(wm8996->pdata.ldo_ena,
2779 wm8996->pdata.ldo_ena, ret);
2784 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++)
2785 wm8996->supplies[i].supply = wm8996_supply_names[i];
2787 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8996->supplies),
2788 wm8996->supplies);
2794 wm8996->disable_nb[0].notifier_call = wm8996_regulator_event_0;
2795 wm8996->disable_nb[1].notifier_call = wm8996_regulator_event_1;
2796 wm8996->disable_nb[2].notifier_call = wm8996_regulator_event_2;
2799 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) {
2801 wm8996->supplies[i].consumer,
2802 &wm8996->disable_nb[i]);
2810 ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies),
2811 wm8996->supplies);
2817 if (wm8996->pdata.ldo_ena > 0) {
2818 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 1);
2822 wm8996->regmap = devm_regmap_init_i2c(i2c, &wm8996_regmap);
2823 if (IS_ERR(wm8996->regmap)) {
2824 ret = PTR_ERR(wm8996->regmap);
2829 ret = regmap_read(wm8996->regmap, WM8996_SOFTWARE_RESET, ®);
2840 ret = regmap_read(wm8996->regmap, WM8996_CHIP_REVISION, ®);
2850 if (wm8996->pdata.ldo_ena > 0) {
2851 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
2852 regcache_cache_only(wm8996->regmap, true);
2854 ret = regmap_write(wm8996->regmap, WM8996_SOFTWARE_RESET,
2862 regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies);
2865 regmap_update_bits(wm8996->regmap, WM8996_LINE_INPUT_CONTROL,
2867 wm8996->pdata.inl_mode << WM8996_INL_MODE_SHIFT |
2868 wm8996->pdata.inr_mode);
2870 for (i = 0; i < ARRAY_SIZE(wm8996->pdata.gpio_default); i++) {
2871 if (!wm8996->pdata.gpio_default[i])
2874 regmap_write(wm8996->regmap, WM8996_GPIO_1 + i,
2875 wm8996->pdata.gpio_default[i] & 0xffff);
2878 if (wm8996->pdata.spkmute_seq)
2879 regmap_update_bits(wm8996->regmap,
2883 wm8996->pdata.spkmute_seq);
2885 regmap_update_bits(wm8996->regmap, WM8996_ACCESSORY_DETECT_MODE_2,
2887 WM8996_MICD_SRC, wm8996->pdata.micdet_def);
2890 regmap_update_bits(wm8996->regmap, WM8996_LEFT_LINE_INPUT_VOLUME,
2892 regmap_update_bits(wm8996->regmap, WM8996_RIGHT_LINE_INPUT_VOLUME,
2895 regmap_update_bits(wm8996->regmap, WM8996_DAC1_LEFT_VOLUME,
2897 regmap_update_bits(wm8996->regmap, WM8996_DAC1_RIGHT_VOLUME,
2899 regmap_update_bits(wm8996->regmap, WM8996_DAC2_LEFT_VOLUME,
2901 regmap_update_bits(wm8996->regmap, WM8996_DAC2_RIGHT_VOLUME,
2904 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT1_LEFT_VOLUME,
2906 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT1_RIGHT_VOLUME,
2908 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT2_LEFT_VOLUME,
2910 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT2_RIGHT_VOLUME,
2913 regmap_update_bits(wm8996->regmap, WM8996_DSP1_TX_LEFT_VOLUME,
2915 regmap_update_bits(wm8996->regmap, WM8996_DSP1_TX_RIGHT_VOLUME,
2917 regmap_update_bits(wm8996->regmap, WM8996_DSP2_TX_LEFT_VOLUME,
2919 regmap_update_bits(wm8996->regmap, WM8996_DSP2_TX_RIGHT_VOLUME,
2922 regmap_update_bits(wm8996->regmap, WM8996_DSP1_RX_LEFT_VOLUME,
2924 regmap_update_bits(wm8996->regmap, WM8996_DSP1_RX_RIGHT_VOLUME,
2926 regmap_update_bits(wm8996->regmap, WM8996_DSP2_RX_LEFT_VOLUME,
2928 regmap_update_bits(wm8996->regmap, WM8996_DSP2_RX_RIGHT_VOLUME,
2934 regmap_update_bits(wm8996->regmap,
2939 regmap_update_bits(wm8996->regmap,
2944 regmap_update_bits(wm8996->regmap,
2949 regmap_update_bits(wm8996->regmap,
2954 regmap_update_bits(wm8996->regmap,
2959 regmap_update_bits(wm8996->regmap,
2965 regmap_update_bits(wm8996->regmap,
2970 regmap_update_bits(wm8996->regmap,
2976 regmap_update_bits(wm8996->regmap,
2981 regmap_update_bits(wm8996->regmap,
2986 regmap_update_bits(wm8996->regmap,
2991 regmap_update_bits(wm8996->regmap,
2996 regmap_update_bits(wm8996->regmap,
3001 regmap_update_bits(wm8996->regmap,
3007 regmap_update_bits(wm8996->regmap,
3012 regmap_update_bits(wm8996->regmap,
3021 ret = regmap_read(wm8996->regmap, WM8996_GPIO_1, ®);
3028 regmap_update_bits(wm8996->regmap, WM8996_AIF1_TX_LRCLK_2,
3032 ret = regmap_read(wm8996->regmap, WM8996_GPIO_2, ®);
3039 regmap_update_bits(wm8996->regmap, WM8996_AIF2_TX_LRCLK_2,
3043 wm8996_init_gpio(wm8996);
3054 wm8996_free_gpio(wm8996);
3057 if (wm8996->pdata.ldo_ena > 0)
3058 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
3059 regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies);
3061 if (wm8996->pdata.ldo_ena > 0)
3062 gpio_free(wm8996->pdata.ldo_ena);
3070 struct wm8996_priv *wm8996 = i2c_get_clientdata(client);
3072 wm8996_free_gpio(wm8996);
3073 if (wm8996->pdata.ldo_ena > 0) {
3074 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
3075 gpio_free(wm8996->pdata.ldo_ena);
3080 { "wm8996", 0 },
3087 .name = "wm8996",