Lines Matching +full:tdm +full:- +full:data +full:- +full:pair
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8996.c - WM8996 audio codec interface
5 * Copyright 2011-2 Wolfson Microelectronics PLC.
103 unsigned long event, void *data) \
108 regcache_mark_dirty(wm8996->regmap); \
299 static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 150, 0);
300 static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
301 static const DECLARE_TLV_DB_SCALE(out_digital_tlv, -1200, 150, 0);
302 static const DECLARE_TLV_DB_SCALE(out_tlv, -900, 75, 0);
303 static const DECLARE_TLV_DB_SCALE(spk_tlv, -900, 150, 0);
304 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
305 static const DECLARE_TLV_DB_SCALE(threedstereo_tlv, -1600, 183, 1);
337 struct wm8996_pdata *pdata = &wm8996->pdata; in wm8996_set_retune_mobile()
340 if (!wm8996->num_retune_mobile_texts) in wm8996_set_retune_mobile()
366 cfg = wm8996->retune_mobile_cfg[block]; in wm8996_set_retune_mobile()
369 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8996_set_retune_mobile()
370 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8996_set_retune_mobile()
371 wm8996->retune_mobile_texts[cfg]) == 0 && in wm8996_set_retune_mobile()
372 abs(pdata->retune_mobile_cfgs[i].rate in wm8996_set_retune_mobile()
373 - wm8996->rx_rate[iface]) < best_val) { in wm8996_set_retune_mobile()
375 best_val = abs(pdata->retune_mobile_cfgs[i].rate in wm8996_set_retune_mobile()
376 - wm8996->rx_rate[iface]); in wm8996_set_retune_mobile()
380 dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", in wm8996_set_retune_mobile()
382 pdata->retune_mobile_cfgs[best].name, in wm8996_set_retune_mobile()
383 pdata->retune_mobile_cfgs[best].rate, in wm8996_set_retune_mobile()
384 wm8996->rx_rate[iface]); in wm8996_set_retune_mobile()
392 for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++) in wm8996_set_retune_mobile()
394 pdata->retune_mobile_cfgs[best].regs[i]); in wm8996_set_retune_mobile()
406 return -EINVAL; in wm8996_get_retune_mobile_block()
414 struct wm8996_pdata *pdata = &wm8996->pdata; in wm8996_put_retune_mobile_enum()
415 int block = wm8996_get_retune_mobile_block(kcontrol->id.name); in wm8996_put_retune_mobile_enum()
416 int value = ucontrol->value.enumerated.item[0]; in wm8996_put_retune_mobile_enum()
421 if (value >= pdata->num_retune_mobile_cfgs) in wm8996_put_retune_mobile_enum()
422 return -EINVAL; in wm8996_put_retune_mobile_enum()
424 wm8996->retune_mobile_cfg[block] = value; in wm8996_put_retune_mobile_enum()
436 int block = wm8996_get_retune_mobile_block(kcontrol->id.name); in wm8996_get_retune_mobile_enum()
440 ucontrol->value.enumerated.item[0] = wm8996->retune_mobile_cfg[block]; in wm8996_get_retune_mobile_enum()
456 SOC_ENUM("Sidetone HPF Cut-off", sidetone_hpf),
578 wm8996->bg_ena++; in wm8996_bg_enable()
579 if (wm8996->bg_ena == 1) { in wm8996_bg_enable()
590 wm8996->bg_ena--; in wm8996_bg_disable()
591 if (!wm8996->bg_ena) in wm8996_bg_disable()
599 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in bg_event()
611 ret = -EINVAL; in bg_event()
634 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rmv_short_event()
640 wm8996->hpout_pending &= ~w->shift; in rmv_short_event()
643 wm8996->hpout_pending |= w->shift; in rmv_short_event()
647 return -EINVAL; in rmv_short_event()
655 struct i2c_client *i2c = to_i2c_client(component->dev); in wait_for_dc_servo()
664 if (i2c->irq) { in wait_for_dc_servo()
665 time_left = wait_for_completion_timeout(&wm8996->dcs_done, in wait_for_dc_servo()
668 dev_err(component->dev, "DC servo timed out\n"); in wait_for_dc_servo()
672 time_left--; in wait_for_dc_servo()
676 dev_dbg(component->dev, "DC servo state: %x\n", ret); in wait_for_dc_servo()
680 dev_err(component->dev, "DC servo timed out for %x\n", mask); in wait_for_dc_servo()
682 dev_dbg(component->dev, "DC servo complete for %x\n", mask); in wait_for_dc_servo()
692 if (wm8996->dcs_pending) { in wm8996_seq_notifier()
693 dev_dbg(component->dev, "Starting DC servo for %x\n", in wm8996_seq_notifier()
694 wm8996->dcs_pending); in wm8996_seq_notifier()
697 wait_for_dc_servo(component, wm8996->dcs_pending in wm8996_seq_notifier()
700 wm8996->dcs_pending = 0; in wm8996_seq_notifier()
703 if (wm8996->hpout_pending != wm8996->hpout_ena) { in wm8996_seq_notifier()
704 dev_dbg(component->dev, "Applying RMV_SHORTs %x->%x\n", in wm8996_seq_notifier()
705 wm8996->hpout_ena, wm8996->hpout_pending); in wm8996_seq_notifier()
709 if (wm8996->hpout_pending & HPOUT1L) { in wm8996_seq_notifier()
718 if (wm8996->hpout_pending & HPOUT1R) { in wm8996_seq_notifier()
731 if (wm8996->hpout_pending & HPOUT2L) { in wm8996_seq_notifier()
740 if (wm8996->hpout_pending & HPOUT2R) { in wm8996_seq_notifier()
751 wm8996->hpout_ena = wm8996->hpout_pending; in wm8996_seq_notifier()
758 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in dcs_start()
763 wm8996->dcs_pending |= 1 << w->shift; in dcs_start()
767 return -EINVAL; in dcs_start()
1539 if (wm8996->sysclk < 64000) in wm8996_update_bclk()
1552 bclk_rate = wm8996->bclk_rate[aif]; in wm8996_update_bclk()
1557 cur_val = (wm8996->sysclk / bclk_divs[i]) - bclk_rate; in wm8996_update_bclk()
1562 bclk_rate = wm8996->sysclk / bclk_divs[best]; in wm8996_update_bclk()
1563 dev_dbg(component->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", in wm8996_update_bclk()
1590 ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), in wm8996_set_bias_level()
1591 wm8996->supplies); in wm8996_set_bias_level()
1593 dev_err(component->dev, in wm8996_set_bias_level()
1599 if (wm8996->ldo_ena) { in wm8996_set_bias_level()
1600 gpiod_set_value_cansleep(wm8996->ldo_ena, in wm8996_set_bias_level()
1605 regcache_cache_only(wm8996->regmap, false); in wm8996_set_bias_level()
1606 regcache_sync(wm8996->regmap); in wm8996_set_bias_level()
1617 regcache_cache_only(wm8996->regmap, true); in wm8996_set_bias_level()
1618 if (wm8996->ldo_ena) { in wm8996_set_bias_level()
1619 gpiod_set_value_cansleep(wm8996->ldo_ena, 0); in wm8996_set_bias_level()
1620 regcache_cache_only(wm8996->regmap, true); in wm8996_set_bias_level()
1622 regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), in wm8996_set_bias_level()
1623 wm8996->supplies); in wm8996_set_bias_level()
1632 struct snd_soc_component *component = dai->component; in wm8996_set_fmt()
1639 switch (dai->id) { in wm8996_set_fmt()
1653 WARN(1, "Invalid dai id %d\n", dai->id); in wm8996_set_fmt()
1654 return -EINVAL; in wm8996_set_fmt()
1690 return -EINVAL; in wm8996_set_fmt()
1706 return -EINVAL; in wm8996_set_fmt()
1733 struct snd_soc_component *component = dai->component; in wm8996_hw_params()
1741 switch (dai->id) { in wm8996_hw_params()
1743 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || in wm8996_hw_params()
1754 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || in wm8996_hw_params()
1765 WARN(1, "Invalid dai id %d\n", dai->id); in wm8996_hw_params()
1766 return -EINVAL; in wm8996_hw_params()
1771 dev_err(component->dev, "Unsupported BCLK rate: %d\n", bclk_rate); in wm8996_hw_params()
1775 wm8996->bclk_rate[dai->id] = bclk_rate; in wm8996_hw_params()
1776 wm8996->rx_rate[dai->id] = params_rate(params); in wm8996_hw_params()
1778 /* Needs looking at for TDM */ in wm8996_hw_params()
1786 if (abs(dsp_divs[i] - params_rate(params)) < in wm8996_hw_params()
1787 abs(dsp_divs[best] - params_rate(params))) in wm8996_hw_params()
1795 dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", in wm8996_hw_params()
1813 struct snd_soc_component *component = dai->component; in wm8996_set_sysclk()
1821 if (freq == wm8996->sysclk && clk_id == wm8996->sysclk_src) in wm8996_set_sysclk()
1831 wm8996->sysclk = freq; in wm8996_set_sysclk()
1835 wm8996->sysclk = freq; in wm8996_set_sysclk()
1839 wm8996->sysclk = freq; in wm8996_set_sysclk()
1843 dev_err(component->dev, "Unsupported clock source %d\n", clk_id); in wm8996_set_sysclk()
1844 return -EINVAL; in wm8996_set_sysclk()
1847 switch (wm8996->sysclk) { in wm8996_set_sysclk()
1856 wm8996->sysclk /= 2; in wm8996_set_sysclk()
1869 dev_warn(component->dev, "Unsupported clock rate %dHz\n", in wm8996_set_sysclk()
1870 wm8996->sysclk); in wm8996_set_sysclk()
1871 return -EINVAL; in wm8996_set_sysclk()
1885 wm8996->sysclk_src = clk_id; in wm8996_set_sysclk()
1924 fll_div->fll_refclk_div = 0; in fll_factors()
1927 fll_div->fll_refclk_div++; in fll_factors()
1932 return -EINVAL; in fll_factors()
1942 fll_div->fll_loop_gain = 5; in fll_factors()
1944 fll_div->fll_loop_gain = 0; in fll_factors()
1947 fll_div->fll_ref_freq = 0; in fll_factors()
1949 fll_div->fll_ref_freq = 1; in fll_factors()
1951 /* Fvco should be 90-100MHz; don't check the upper bound */ in fll_factors()
1958 return -EINVAL; in fll_factors()
1962 fll_div->fll_outdiv = div - 1; in fll_factors()
1969 fll_div->fll_fratio = fll_fratios[i].fll_fratio; in fll_factors()
1976 return -EINVAL; in fll_factors()
1979 fll_div->n = target / (fratio * Fref); in fll_factors()
1982 fll_div->theta = 0; in fll_factors()
1983 fll_div->lambda = 0; in fll_factors()
1987 fll_div->theta = (target - (fll_div->n * fratio * Fref)) in fll_factors()
1989 fll_div->lambda = (fratio * Fref) / gcd_fll; in fll_factors()
1993 fll_div->n, fll_div->theta, fll_div->lambda); in fll_factors()
1995 fll_div->fll_fratio, fll_div->fll_outdiv, in fll_factors()
1996 fll_div->fll_refclk_div); in fll_factors()
2005 struct i2c_client *i2c = to_i2c_client(component->dev); in wm8996_set_fll()
2011 if (source == wm8996->fll_src && Fref == wm8996->fll_fref && in wm8996_set_fll()
2012 Fout == wm8996->fll_fout) in wm8996_set_fll()
2016 dev_dbg(component->dev, "FLL disabled\n"); in wm8996_set_fll()
2018 wm8996->fll_fref = 0; in wm8996_set_fll()
2019 wm8996->fll_fout = 0; in wm8996_set_fll()
2047 dev_err(component->dev, "Unknown FLL source %d\n", ret); in wm8996_set_fll()
2048 return -EINVAL; in wm8996_set_fll()
2086 try_wait_for_completion(&wm8996->fll_lock); in wm8996_set_fll()
2091 /* The FLL supports live reconfiguration - kick that in case we were in wm8996_set_fll()
2105 if (i2c->irq) in wm8996_set_fll()
2112 time_left = wait_for_completion_timeout(&wm8996->fll_lock, in wm8996_set_fll()
2115 WARN_ON(!i2c->irq); in wm8996_set_fll()
2125 dev_err(component->dev, "Timed out waiting for FLL\n"); in wm8996_set_fll()
2126 ret = -ETIMEDOUT; in wm8996_set_fll()
2129 dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); in wm8996_set_fll()
2131 wm8996->fll_fref = Fref; in wm8996_set_fll()
2132 wm8996->fll_fout = Fout; in wm8996_set_fll()
2133 wm8996->fll_src = source; in wm8996_set_fll()
2143 regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, in wm8996_gpio_set()
2155 return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, in wm8996_gpio_direction_out()
2166 ret = regmap_read(wm8996->regmap, WM8996_GPIO_1 + offset, ®); in wm8996_gpio_get()
2177 return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, in wm8996_gpio_direction_in()
2192 .base = -1,
2199 wm8996->gpio_chip = wm8996_template_chip; in wm8996_init_gpio()
2200 wm8996->gpio_chip.parent = wm8996->dev; in wm8996_init_gpio()
2202 ret = gpiochip_add_data(&wm8996->gpio_chip, wm8996); in wm8996_init_gpio()
2204 dev_err(wm8996->dev, "Failed to add GPIOs: %d\n", ret); in wm8996_init_gpio()
2209 gpiochip_remove(&wm8996->gpio_chip); in wm8996_free_gpio()
2222 * wm8996_detect - Enable default WM8996 jack detection
2241 wm8996->jack = jack; in wm8996_detect()
2242 wm8996->detecting = true; in wm8996_detect()
2243 wm8996->polarity_cb = polarity_cb; in wm8996_detect()
2244 wm8996->jack_flips = 0; in wm8996_detect()
2246 if (wm8996->polarity_cb) in wm8996_detect()
2247 wm8996->polarity_cb(component, 0); in wm8996_detect()
2263 /* We start off just enabling microphone detection - even a in wm8996_detect()
2295 dev_err(component->dev, "Failed to read HPDET status\n"); in wm8996_hpdet_irq()
2300 dev_err(component->dev, "Got HPDET IRQ but HPDET is busy\n"); in wm8996_hpdet_irq()
2306 dev_dbg(component->dev, "HPDET measured %d ohms\n", val); in wm8996_hpdet_irq()
2317 if (wm8996->jack_mic) in wm8996_hpdet_irq()
2320 snd_soc_jack_report(wm8996->jack, report, in wm8996_hpdet_irq()
2323 wm8996->detecting = false; in wm8996_hpdet_irq()
2325 /* If the output isn't running re-clamp it */ in wm8996_hpdet_irq()
2369 dev_dbg(component->dev, "Headphone detected\n"); in wm8996_report_headphone()
2387 dev_dbg(component->dev, "Microphone event: %x\n", val); in wm8996_micd()
2390 dev_warn(component->dev, "Microphone detection state invalid\n"); in wm8996_micd()
2396 dev_dbg(component->dev, "Jack removal detected\n"); in wm8996_micd()
2397 wm8996->jack_mic = false; in wm8996_micd()
2398 wm8996->detecting = true; in wm8996_micd()
2399 wm8996->jack_flips = 0; in wm8996_micd()
2400 snd_soc_jack_report(wm8996->jack, 0, in wm8996_micd()
2417 if (wm8996->detecting) { in wm8996_micd()
2418 dev_dbg(component->dev, "Microphone detected\n"); in wm8996_micd()
2419 wm8996->jack_mic = true; in wm8996_micd()
2430 dev_dbg(component->dev, "Mic button up\n"); in wm8996_micd()
2431 snd_soc_jack_report(wm8996->jack, 0, SND_JACK_BTN_0); in wm8996_micd()
2443 if (wm8996->detecting && (val & 0x3f0)) { in wm8996_micd()
2444 wm8996->jack_flips++; in wm8996_micd()
2446 if (wm8996->jack_flips > 1) { in wm8996_micd()
2458 if (wm8996->polarity_cb) in wm8996_micd()
2459 wm8996->polarity_cb(component, in wm8996_micd()
2462 dev_dbg(component->dev, "Set microphone polarity to %d\n", in wm8996_micd()
2472 if (wm8996->jack_mic) { in wm8996_micd()
2473 dev_dbg(component->dev, "Mic button detected\n"); in wm8996_micd()
2474 snd_soc_jack_report(wm8996->jack, SND_JACK_BTN_0, in wm8996_micd()
2476 } else if (wm8996->detecting) { in wm8996_micd()
2482 static irqreturn_t wm8996_irq(int irq, void *data) in wm8996_irq() argument
2484 struct snd_soc_component *component = data; in wm8996_irq()
2490 dev_err(component->dev, "Failed to read IRQ status: %d\n", in wm8996_irq()
2502 dev_dbg(component->dev, "DC servo IRQ\n"); in wm8996_irq()
2503 complete(&wm8996->dcs_done); in wm8996_irq()
2507 dev_err(component->dev, "Digital core FIFO error\n"); in wm8996_irq()
2510 dev_dbg(component->dev, "FLL locked\n"); in wm8996_irq()
2511 complete(&wm8996->fll_lock); in wm8996_irq()
2523 static irqreturn_t wm8996_edge_irq(int irq, void *data) in wm8996_edge_irq() argument
2529 val = wm8996_irq(irq, data); in wm8996_edge_irq()
2540 struct wm8996_pdata *pdata = &wm8996->pdata; in wm8996_retune_mobile_pdata()
2544 wm8996->retune_mobile_enum, in wm8996_retune_mobile_pdata()
2548 wm8996->retune_mobile_enum, in wm8996_retune_mobile_pdata()
2559 wm8996->num_retune_mobile_texts = 0; in wm8996_retune_mobile_pdata()
2560 wm8996->retune_mobile_texts = NULL; in wm8996_retune_mobile_pdata()
2561 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8996_retune_mobile_pdata()
2562 for (j = 0; j < wm8996->num_retune_mobile_texts; j++) { in wm8996_retune_mobile_pdata()
2563 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8996_retune_mobile_pdata()
2564 wm8996->retune_mobile_texts[j]) == 0) in wm8996_retune_mobile_pdata()
2568 if (j != wm8996->num_retune_mobile_texts) in wm8996_retune_mobile_pdata()
2572 t = krealloc(wm8996->retune_mobile_texts, in wm8996_retune_mobile_pdata()
2574 (wm8996->num_retune_mobile_texts + 1), in wm8996_retune_mobile_pdata()
2580 t[wm8996->num_retune_mobile_texts] = in wm8996_retune_mobile_pdata()
2581 pdata->retune_mobile_cfgs[i].name; in wm8996_retune_mobile_pdata()
2584 wm8996->num_retune_mobile_texts++; in wm8996_retune_mobile_pdata()
2585 wm8996->retune_mobile_texts = t; in wm8996_retune_mobile_pdata()
2588 dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", in wm8996_retune_mobile_pdata()
2589 wm8996->num_retune_mobile_texts); in wm8996_retune_mobile_pdata()
2591 wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts; in wm8996_retune_mobile_pdata()
2592 wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts; in wm8996_retune_mobile_pdata()
2596 dev_err(component->dev, in wm8996_retune_mobile_pdata()
2616 struct i2c_client *i2c = to_i2c_client(component->dev); in wm8996_probe()
2619 wm8996->component = component; in wm8996_probe()
2621 init_completion(&wm8996->dcs_done); in wm8996_probe()
2622 init_completion(&wm8996->fll_lock); in wm8996_probe()
2624 if (wm8996->pdata.num_retune_mobile_cfgs) in wm8996_probe()
2630 if (i2c->irq) { in wm8996_probe()
2631 if (wm8996->pdata.irq_flags) in wm8996_probe()
2632 irq_flags = wm8996->pdata.irq_flags; in wm8996_probe()
2639 ret = request_threaded_irq(i2c->irq, NULL, in wm8996_probe()
2643 ret = request_threaded_irq(i2c->irq, NULL, wm8996_irq, in wm8996_probe()
2660 dev_err(component->dev, "Failed to request IRQ: %d\n", in wm8996_probe()
2671 struct i2c_client *i2c = to_i2c_client(component->dev); in wm8996_remove()
2676 if (i2c->irq) in wm8996_remove()
2677 free_irq(i2c->irq, component); in wm8996_remove()
2711 .name = "wm8996-aif1",
2731 .name = "wm8996-aif2",
2758 wm8996 = devm_kzalloc(&i2c->dev, sizeof(struct wm8996_priv), in wm8996_i2c_probe()
2761 return -ENOMEM; in wm8996_i2c_probe()
2764 wm8996->dev = &i2c->dev; in wm8996_i2c_probe()
2766 if (dev_get_platdata(&i2c->dev)) in wm8996_i2c_probe()
2767 memcpy(&wm8996->pdata, dev_get_platdata(&i2c->dev), in wm8996_i2c_probe()
2768 sizeof(wm8996->pdata)); in wm8996_i2c_probe()
2770 wm8996->ldo_ena = devm_gpiod_get_optional(&i2c->dev, "wlf,ldo1ena", in wm8996_i2c_probe()
2772 if (IS_ERR(wm8996->ldo_ena)) { in wm8996_i2c_probe()
2773 ret = PTR_ERR(wm8996->ldo_ena); in wm8996_i2c_probe()
2774 dev_err(&i2c->dev, "Failed to request LDO ENA GPIO: %d\n", in wm8996_i2c_probe()
2778 gpiod_set_consumer_name(wm8996->ldo_ena, "WM8996 ENA"); in wm8996_i2c_probe()
2780 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) in wm8996_i2c_probe()
2781 wm8996->supplies[i].supply = wm8996_supply_names[i]; in wm8996_i2c_probe()
2783 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8996->supplies), in wm8996_i2c_probe()
2784 wm8996->supplies); in wm8996_i2c_probe()
2786 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in wm8996_i2c_probe()
2790 wm8996->disable_nb[0].notifier_call = wm8996_regulator_event_0; in wm8996_i2c_probe()
2791 wm8996->disable_nb[1].notifier_call = wm8996_regulator_event_1; in wm8996_i2c_probe()
2792 wm8996->disable_nb[2].notifier_call = wm8996_regulator_event_2; in wm8996_i2c_probe()
2795 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) { in wm8996_i2c_probe()
2797 wm8996->supplies[i].consumer, in wm8996_i2c_probe()
2798 &wm8996->disable_nb[i]); in wm8996_i2c_probe()
2800 dev_err(&i2c->dev, in wm8996_i2c_probe()
2806 ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), in wm8996_i2c_probe()
2807 wm8996->supplies); in wm8996_i2c_probe()
2809 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in wm8996_i2c_probe()
2813 if (wm8996->ldo_ena) { in wm8996_i2c_probe()
2814 gpiod_set_value_cansleep(wm8996->ldo_ena, 1); in wm8996_i2c_probe()
2818 wm8996->regmap = devm_regmap_init_i2c(i2c, &wm8996_regmap); in wm8996_i2c_probe()
2819 if (IS_ERR(wm8996->regmap)) { in wm8996_i2c_probe()
2820 ret = PTR_ERR(wm8996->regmap); in wm8996_i2c_probe()
2821 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); in wm8996_i2c_probe()
2825 ret = regmap_read(wm8996->regmap, WM8996_SOFTWARE_RESET, ®); in wm8996_i2c_probe()
2827 dev_err(&i2c->dev, "Failed to read ID register: %d\n", ret); in wm8996_i2c_probe()
2831 dev_err(&i2c->dev, "Device is not a WM8996, ID %x\n", reg); in wm8996_i2c_probe()
2832 ret = -EINVAL; in wm8996_i2c_probe()
2836 ret = regmap_read(wm8996->regmap, WM8996_CHIP_REVISION, ®); in wm8996_i2c_probe()
2838 dev_err(&i2c->dev, "Failed to read device revision: %d\n", in wm8996_i2c_probe()
2843 dev_info(&i2c->dev, "revision %c\n", in wm8996_i2c_probe()
2846 if (wm8996->ldo_ena) { in wm8996_i2c_probe()
2847 gpiod_set_value_cansleep(wm8996->ldo_ena, 0); in wm8996_i2c_probe()
2848 regcache_cache_only(wm8996->regmap, true); in wm8996_i2c_probe()
2850 ret = regmap_write(wm8996->regmap, WM8996_SOFTWARE_RESET, in wm8996_i2c_probe()
2853 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); in wm8996_i2c_probe()
2858 regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); in wm8996_i2c_probe()
2860 /* Apply platform data settings */ in wm8996_i2c_probe()
2861 regmap_update_bits(wm8996->regmap, WM8996_LINE_INPUT_CONTROL, in wm8996_i2c_probe()
2863 wm8996->pdata.inl_mode << WM8996_INL_MODE_SHIFT | in wm8996_i2c_probe()
2864 wm8996->pdata.inr_mode); in wm8996_i2c_probe()
2866 for (i = 0; i < ARRAY_SIZE(wm8996->pdata.gpio_default); i++) { in wm8996_i2c_probe()
2867 if (!wm8996->pdata.gpio_default[i]) in wm8996_i2c_probe()
2870 regmap_write(wm8996->regmap, WM8996_GPIO_1 + i, in wm8996_i2c_probe()
2871 wm8996->pdata.gpio_default[i] & 0xffff); in wm8996_i2c_probe()
2874 if (wm8996->pdata.spkmute_seq) in wm8996_i2c_probe()
2875 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2879 wm8996->pdata.spkmute_seq); in wm8996_i2c_probe()
2881 regmap_update_bits(wm8996->regmap, WM8996_ACCESSORY_DETECT_MODE_2, in wm8996_i2c_probe()
2883 WM8996_MICD_SRC, wm8996->pdata.micdet_def); in wm8996_i2c_probe()
2886 regmap_update_bits(wm8996->regmap, WM8996_LEFT_LINE_INPUT_VOLUME, in wm8996_i2c_probe()
2888 regmap_update_bits(wm8996->regmap, WM8996_RIGHT_LINE_INPUT_VOLUME, in wm8996_i2c_probe()
2891 regmap_update_bits(wm8996->regmap, WM8996_DAC1_LEFT_VOLUME, in wm8996_i2c_probe()
2893 regmap_update_bits(wm8996->regmap, WM8996_DAC1_RIGHT_VOLUME, in wm8996_i2c_probe()
2895 regmap_update_bits(wm8996->regmap, WM8996_DAC2_LEFT_VOLUME, in wm8996_i2c_probe()
2897 regmap_update_bits(wm8996->regmap, WM8996_DAC2_RIGHT_VOLUME, in wm8996_i2c_probe()
2900 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT1_LEFT_VOLUME, in wm8996_i2c_probe()
2902 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT1_RIGHT_VOLUME, in wm8996_i2c_probe()
2904 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT2_LEFT_VOLUME, in wm8996_i2c_probe()
2906 regmap_update_bits(wm8996->regmap, WM8996_OUTPUT2_RIGHT_VOLUME, in wm8996_i2c_probe()
2909 regmap_update_bits(wm8996->regmap, WM8996_DSP1_TX_LEFT_VOLUME, in wm8996_i2c_probe()
2911 regmap_update_bits(wm8996->regmap, WM8996_DSP1_TX_RIGHT_VOLUME, in wm8996_i2c_probe()
2913 regmap_update_bits(wm8996->regmap, WM8996_DSP2_TX_LEFT_VOLUME, in wm8996_i2c_probe()
2915 regmap_update_bits(wm8996->regmap, WM8996_DSP2_TX_RIGHT_VOLUME, in wm8996_i2c_probe()
2918 regmap_update_bits(wm8996->regmap, WM8996_DSP1_RX_LEFT_VOLUME, in wm8996_i2c_probe()
2920 regmap_update_bits(wm8996->regmap, WM8996_DSP1_RX_RIGHT_VOLUME, in wm8996_i2c_probe()
2922 regmap_update_bits(wm8996->regmap, WM8996_DSP2_RX_LEFT_VOLUME, in wm8996_i2c_probe()
2924 regmap_update_bits(wm8996->regmap, WM8996_DSP2_RX_RIGHT_VOLUME, in wm8996_i2c_probe()
2927 /* No support currently for the underclocked TDM modes and in wm8996_i2c_probe()
2928 * pick a default TDM layout with each channel pair working with in wm8996_i2c_probe()
2930 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2935 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2940 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2945 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2950 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2955 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2961 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2966 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2972 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2977 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2982 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2987 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2992 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
2997 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
3003 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
3008 regmap_update_bits(wm8996->regmap, in wm8996_i2c_probe()
3017 ret = regmap_read(wm8996->regmap, WM8996_GPIO_1, ®); in wm8996_i2c_probe()
3019 dev_err(&i2c->dev, "Failed to read GPIO1: %d\n", ret); in wm8996_i2c_probe()
3024 regmap_update_bits(wm8996->regmap, WM8996_AIF1_TX_LRCLK_2, in wm8996_i2c_probe()
3028 ret = regmap_read(wm8996->regmap, WM8996_GPIO_2, ®); in wm8996_i2c_probe()
3030 dev_err(&i2c->dev, "Failed to read GPIO2: %d\n", ret); in wm8996_i2c_probe()
3035 regmap_update_bits(wm8996->regmap, WM8996_AIF2_TX_LRCLK_2, in wm8996_i2c_probe()
3041 ret = devm_snd_soc_register_component(&i2c->dev, in wm8996_i2c_probe()
3053 if (wm8996->ldo_ena) in wm8996_i2c_probe()
3054 gpiod_set_value_cansleep(wm8996->ldo_ena, 0); in wm8996_i2c_probe()
3055 regulator_bulk_disable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); in wm8996_i2c_probe()
3067 if (wm8996->ldo_ena) in wm8996_i2c_remove()
3068 gpiod_set_value_cansleep(wm8996->ldo_ena, 0); in wm8996_i2c_remove()