Lines Matching +full:micbias2 +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm5100.c -- WM5100 ALSA SoC Audio driver
5 * Copyright 2011-2 Wolfson Microelectronics plc
127 dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate); in wm5100_alloc_sr()
128 return -EINVAL; in wm5100_alloc_sr()
132 if ((wm5100->sysclk % rate) == 0) { in wm5100_alloc_sr()
134 sr_free = -1; in wm5100_alloc_sr()
136 if (!wm5100->sr_ref[i] && sr_free == -1) { in wm5100_alloc_sr()
146 wm5100->sr_ref[i]++; in wm5100_alloc_sr()
147 dev_dbg(component->dev, "SR %dHz, slot %d, ref %d\n", in wm5100_alloc_sr()
148 rate, i, wm5100->sr_ref[i]); in wm5100_alloc_sr()
152 if (sr_free == -1) { in wm5100_alloc_sr()
153 dev_err(component->dev, "All SR slots already in use\n"); in wm5100_alloc_sr()
154 return -EBUSY; in wm5100_alloc_sr()
157 dev_dbg(component->dev, "Allocating SR slot %d for %dHz\n", in wm5100_alloc_sr()
159 wm5100->sr_ref[sr_free]++; in wm5100_alloc_sr()
167 dev_err(component->dev, in wm5100_alloc_sr()
169 rate, wm5100->sysclk, wm5100->asyncclk); in wm5100_alloc_sr()
170 return -EINVAL; in wm5100_alloc_sr()
183 dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate); in wm5100_free_sr()
189 if (!wm5100->sr_ref[i]) in wm5100_free_sr()
197 wm5100->sr_ref[i]--; in wm5100_free_sr()
198 dev_dbg(component->dev, "Dereference SR %dHz, count now %d\n", in wm5100_free_sr()
199 rate, wm5100->sr_ref[i]); in wm5100_free_sr()
201 dev_warn(component->dev, "Freeing unreferenced sample rate %dHz\n", in wm5100_free_sr()
208 if (wm5100->pdata.reset) { in wm5100_reset()
209 gpio_set_value_cansleep(wm5100->pdata.reset, 0); in wm5100_reset()
210 gpio_set_value_cansleep(wm5100->pdata.reset, 1); in wm5100_reset()
214 return regmap_write(wm5100->regmap, WM5100_SOFTWARE_RESET, 0); in wm5100_reset()
218 static DECLARE_TLV_DB_SCALE(in_tlv, -6300, 100, 0);
219 static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
220 static DECLARE_TLV_DB_SCALE(mixer_tlv, -3200, 100, 0);
221 static DECLARE_TLV_DB_SCALE(out_tlv, -6400, 100, 0);
222 static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
322 0x30, /* AIF3 - check */
504 "Low-pass", "High-pass"
623 /* FIXME: Only valid from -12dB to 0dB (52-64) */
740 if (wm5100->out_ena[0]) { in wm5100_seq_notifier()
745 wm5100->out_ena[0] = false; in wm5100_seq_notifier()
750 dev_err(component->dev, "Timeout waiting for OUTPUT1 %x\n", in wm5100_seq_notifier()
755 if (wm5100->out_ena[1]) { in wm5100_seq_notifier()
760 wm5100->out_ena[1] = false; in wm5100_seq_notifier()
765 dev_err(component->dev, "Timeout waiting for OUTPUT2 %x\n", in wm5100_seq_notifier()
775 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5100_out_ev()
778 switch (w->reg) { in wm5100_out_ev()
780 wm5100->out_ena[0] = true; in wm5100_out_ev()
783 wm5100->out_ena[0] = true; in wm5100_out_ev()
795 dev_crit(wm5100->dev, "Speaker shutdown warning\n"); in wm5100_log_status3()
797 dev_crit(wm5100->dev, "Speaker shutdown\n"); in wm5100_log_status3()
799 dev_crit(wm5100->dev, "SYSCLK underclocked\n"); in wm5100_log_status3()
801 dev_crit(wm5100->dev, "ASYNCCLK underclocked\n"); in wm5100_log_status3()
807 dev_err(wm5100->dev, "AIF3 configuration error\n"); in wm5100_log_status4()
809 dev_err(wm5100->dev, "AIF2 configuration error\n"); in wm5100_log_status4()
811 dev_err(wm5100->dev, "AIF1 configuration error\n"); in wm5100_log_status4()
813 dev_err(wm5100->dev, "Control interface error\n"); in wm5100_log_status4()
815 dev_err(wm5100->dev, "ISRC2 underclocked\n"); in wm5100_log_status4()
817 dev_err(wm5100->dev, "ISRC1 underclocked\n"); in wm5100_log_status4()
819 dev_err(wm5100->dev, "FX underclocked\n"); in wm5100_log_status4()
821 dev_err(wm5100->dev, "AIF3 underclocked\n"); in wm5100_log_status4()
823 dev_err(wm5100->dev, "AIF2 underclocked\n"); in wm5100_log_status4()
825 dev_err(wm5100->dev, "AIF1 underclocked\n"); in wm5100_log_status4()
827 dev_err(wm5100->dev, "ASRC underclocked\n"); in wm5100_log_status4()
829 dev_err(wm5100->dev, "DAC underclocked\n"); in wm5100_log_status4()
831 dev_err(wm5100->dev, "ADC underclocked\n"); in wm5100_log_status4()
833 dev_err(wm5100->dev, "Mixer underclocked\n"); in wm5100_log_status4()
840 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5100_post_ev()
875 SND_SOC_DAPM_SUPPLY("MICBIAS2", WM5100_MIC_BIAS_CTRL_2, WM5100_MICB2_ENA_SHIFT,
1074 * look at the error status from the CODEC - if we've got the IRQ
1146 { "MICBIAS2", NULL, "CP2" },
1281 struct snd_soc_component *component = dai->component; in wm5100_set_fmt()
1284 base = dai->driver->base; in wm5100_set_fmt()
1297 dev_err(component->dev, "Unsupported DAI format %d\n", in wm5100_set_fmt()
1299 return -EINVAL; in wm5100_set_fmt()
1316 dev_err(component->dev, "Unsupported master mode %d\n", in wm5100_set_fmt()
1318 return -EINVAL; in wm5100_set_fmt()
1335 return -EINVAL; in wm5100_set_fmt()
1399 struct snd_soc_component *component = dai->component; in wm5100_hw_params()
1401 bool async = wm5100->aif_async[dai->id]; in wm5100_hw_params()
1405 base = dai->driver->base; in wm5100_hw_params()
1415 dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n", in wm5100_hw_params()
1425 aif_rate = wm5100->sysclk; in wm5100_hw_params()
1431 aif_rate = wm5100->asyncclk; in wm5100_hw_params()
1438 dev_err(component->dev, "Invalid rate %dHzn", in wm5100_hw_params()
1440 return -EINVAL; in wm5100_hw_params()
1449 dev_err(component->dev, "%s has no rate set\n", in wm5100_hw_params()
1451 return -EINVAL; in wm5100_hw_params()
1454 dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz %s\n", in wm5100_hw_params()
1466 dev_err(component->dev, in wm5100_hw_params()
1469 return -EINVAL; in wm5100_hw_params()
1473 dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); in wm5100_hw_params()
1477 dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); in wm5100_hw_params()
1478 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || in wm5100_hw_params()
1479 wm5100->aif_symmetric[dai->id]) in wm5100_hw_params()
1487 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in wm5100_hw_params()
1516 rate_store = &wm5100->sysclk; in wm5100_set_sysclk()
1520 rate_store = &wm5100->asyncclk; in wm5100_set_sysclk()
1533 return -EINVAL; in wm5100_set_sysclk()
1543 wm5100->aif_async[clk_id - 1] = false; in wm5100_set_sysclk()
1546 wm5100->aif_async[clk_id - 1] = true; in wm5100_set_sysclk()
1549 dev_err(component->dev, "Invalid source %d\n", source); in wm5100_set_sysclk()
1550 return -EINVAL; in wm5100_set_sysclk()
1572 dev_err(component->dev, "Unsupported OPCLK %dHz\n", in wm5100_set_sysclk()
1574 return -EINVAL; in wm5100_set_sysclk()
1579 dev_err(component->dev, "Unknown clock %d\n", clk_id); in wm5100_set_sysclk()
1580 return -EINVAL; in wm5100_set_sysclk()
1586 dev_err(component->dev, "Invalid source %d\n", source); in wm5100_set_sysclk()
1587 return -EINVAL; in wm5100_set_sysclk()
1604 dev_err(component->dev, "Invalid clock rate: %d\n", freq); in wm5100_set_sysclk()
1605 return -EINVAL; in wm5100_set_sysclk()
1640 dev_dbg(component->dev, "Setting primary audio rate to %dHz", in wm5100_set_sysclk()
1646 dev_warn(component->dev, "Primary audio slot is %d\n", in wm5100_set_sysclk()
1687 fll_div->fll_refclk_div = 0; in fll_factors()
1690 fll_div->fll_refclk_div++; in fll_factors()
1695 return -EINVAL; in fll_factors()
1704 /* Fvco should be 90-100MHz; don't check the upper bound */ in fll_factors()
1711 return -EINVAL; in fll_factors()
1715 fll_div->fll_outdiv = div - 1; in fll_factors()
1722 fll_div->fll_fratio = fll_fratios[i].fll_fratio; in fll_factors()
1729 return -EINVAL; in fll_factors()
1732 fll_div->n = target / (fratio * Fref); in fll_factors()
1735 fll_div->theta = 0; in fll_factors()
1736 fll_div->lambda = 0; in fll_factors()
1740 fll_div->theta = (target - (fll_div->n * fratio * Fref)) in fll_factors()
1742 fll_div->lambda = (fratio * Fref) / gcd_fll; in fll_factors()
1746 fll_div->n, fll_div->theta, fll_div->lambda); in fll_factors()
1748 fll_div->fll_fratio, fratio, fll_div->fll_outdiv, in fll_factors()
1749 fll_div->fll_refclk_div); in fll_factors()
1757 struct i2c_client *i2c = to_i2c_client(component->dev); in wm5100_set_fll()
1766 fll = &wm5100->fll[0]; in wm5100_set_fll()
1767 base = WM5100_FLL1_CONTROL_1 - 1; in wm5100_set_fll()
1771 fll = &wm5100->fll[1]; in wm5100_set_fll()
1772 base = WM5100_FLL2_CONTROL_2 - 1; in wm5100_set_fll()
1776 dev_err(component->dev, "Unknown FLL %d\n",fll_id); in wm5100_set_fll()
1777 return -EINVAL; in wm5100_set_fll()
1781 dev_dbg(component->dev, "FLL%d disabled", fll_id); in wm5100_set_fll()
1782 if (fll->fout) in wm5100_set_fll()
1783 pm_runtime_put(component->dev); in wm5100_set_fll()
1784 fll->fout = 0; in wm5100_set_fll()
1799 dev_err(component->dev, "Invalid FLL source %d\n", source); in wm5100_set_fll()
1800 return -EINVAL; in wm5100_set_fll()
1826 try_wait_for_completion(&fll->lock); in wm5100_set_fll()
1828 pm_runtime_get_sync(component->dev); in wm5100_set_fll()
1832 if (i2c->irq) in wm5100_set_fll()
1842 if (i2c->irq) { in wm5100_set_fll()
1843 time_left = wait_for_completion_timeout(&fll->lock, in wm5100_set_fll()
1854 dev_err(component->dev, in wm5100_set_fll()
1863 dev_err(component->dev, "FLL%d lock timed out\n", fll_id); in wm5100_set_fll()
1864 pm_runtime_put(component->dev); in wm5100_set_fll()
1865 return -ETIMEDOUT; in wm5100_set_fll()
1868 fll->src = source; in wm5100_set_fll()
1869 fll->fref = Fref; in wm5100_set_fll()
1870 fll->fout = Fout; in wm5100_set_fll()
1872 dev_dbg(component->dev, "FLL%d running %dHz->%dHz\n", fll_id, in wm5100_set_fll()
1886 .name = "wm5100-aif1",
1887 .base = WM5100_AUDIO_IF_1_1 - 1,
1905 .name = "wm5100-aif2",
1907 .base = WM5100_AUDIO_IF_2_1 - 1,
1925 .name = "wm5100-aif3",
1927 .base = WM5100_AUDIO_IF_3_1 - 1,
1972 struct wm5100_jack_mode *mode = &wm5100->pdata.jack_modes[the_mode]; in wm5100_set_detect_mode()
1974 if (WARN_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes))) in wm5100_set_detect_mode()
1977 gpio_set_value_cansleep(wm5100->pdata.hp_pol, mode->hp_pol); in wm5100_set_detect_mode()
1978 regmap_update_bits(wm5100->regmap, WM5100_ACCESSORY_DETECT_MODE_1, in wm5100_set_detect_mode()
1981 (mode->bias << WM5100_ACCDET_BIAS_SRC_SHIFT) | in wm5100_set_detect_mode()
1982 mode->micd_src << WM5100_ACCDET_SRC_SHIFT); in wm5100_set_detect_mode()
1983 regmap_update_bits(wm5100->regmap, WM5100_MISC_CONTROL, in wm5100_set_detect_mode()
1985 mode->micd_src << WM5100_HPCOM_SRC_SHIFT); in wm5100_set_detect_mode()
1987 wm5100->jack_mode = the_mode; in wm5100_set_detect_mode()
1989 dev_dbg(wm5100->dev, "Set microphone polarity to %d\n", in wm5100_set_detect_mode()
1990 wm5100->jack_mode); in wm5100_set_detect_mode()
1995 dev_dbg(wm5100->dev, "Headphone detected\n"); in wm5100_report_headphone()
1996 wm5100->jack_detecting = false; in wm5100_report_headphone()
1997 snd_soc_jack_report(wm5100->jack, SND_JACK_HEADPHONE, in wm5100_report_headphone()
2001 regmap_update_bits(wm5100->regmap, WM5100_MIC_DETECT_1, in wm5100_report_headphone()
2011 ret = regmap_read(wm5100->regmap, WM5100_MIC_DETECT_3, &val); in wm5100_micd_irq()
2013 dev_err(wm5100->dev, "Failed to read microphone status: %d\n", in wm5100_micd_irq()
2018 dev_dbg(wm5100->dev, "Microphone event: %x\n", val); in wm5100_micd_irq()
2021 dev_warn(wm5100->dev, "Microphone detection state invalid\n"); in wm5100_micd_irq()
2027 dev_dbg(wm5100->dev, "Jack removal detected\n"); in wm5100_micd_irq()
2028 wm5100->jack_mic = false; in wm5100_micd_irq()
2029 wm5100->jack_detecting = true; in wm5100_micd_irq()
2030 wm5100->jack_flips = 0; in wm5100_micd_irq()
2031 snd_soc_jack_report(wm5100->jack, 0, in wm5100_micd_irq()
2035 regmap_update_bits(wm5100->regmap, WM5100_MIC_DETECT_1, in wm5100_micd_irq()
2046 if (wm5100->jack_detecting) { in wm5100_micd_irq()
2047 dev_dbg(wm5100->dev, "Microphone detected\n"); in wm5100_micd_irq()
2048 wm5100->jack_mic = true; in wm5100_micd_irq()
2049 wm5100->jack_detecting = false; in wm5100_micd_irq()
2050 snd_soc_jack_report(wm5100->jack, in wm5100_micd_irq()
2056 regmap_update_bits(wm5100->regmap, WM5100_MIC_DETECT_1, in wm5100_micd_irq()
2060 dev_dbg(wm5100->dev, "Mic button up\n"); in wm5100_micd_irq()
2061 snd_soc_jack_report(wm5100->jack, 0, SND_JACK_BTN_0); in wm5100_micd_irq()
2073 if (wm5100->jack_detecting && (val & 0x3f8)) { in wm5100_micd_irq()
2074 wm5100->jack_flips++; in wm5100_micd_irq()
2076 if (wm5100->jack_flips > 1) in wm5100_micd_irq()
2079 wm5100_set_detect_mode(wm5100, !wm5100->jack_mode); in wm5100_micd_irq()
2088 if (wm5100->jack_mic) { in wm5100_micd_irq()
2089 dev_dbg(wm5100->dev, "Mic button detected\n"); in wm5100_micd_irq()
2090 snd_soc_jack_report(wm5100->jack, SND_JACK_BTN_0, in wm5100_micd_irq()
2092 } else if (wm5100->jack_detecting) { in wm5100_micd_irq()
2104 wm5100->jack = jack; in wm5100_detect()
2105 wm5100->jack_detecting = true; in wm5100_detect()
2106 wm5100->jack_flips = 0; in wm5100_detect()
2128 /* We start off just enabling microphone detection - even a in wm5100_detect()
2144 wm5100->jack = NULL; in wm5100_detect()
2158 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_3, &irq_val); in wm5100_irq()
2160 dev_err(wm5100->dev, "Failed to read IRQ status 3: %d\n", in wm5100_irq()
2165 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_3_MASK, in wm5100_irq()
2168 dev_err(wm5100->dev, "Failed to read IRQ mask 3: %d\n", in wm5100_irq()
2175 regmap_write(wm5100->regmap, WM5100_INTERRUPT_STATUS_3, irq_val); in wm5100_irq()
2183 dev_dbg(wm5100->dev, "FLL1 locked\n"); in wm5100_irq()
2184 complete(&wm5100->fll[0].lock); in wm5100_irq()
2187 dev_dbg(wm5100->dev, "FLL2 locked\n"); in wm5100_irq()
2188 complete(&wm5100->fll[1].lock); in wm5100_irq()
2194 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_4, &irq_val); in wm5100_irq()
2196 dev_err(wm5100->dev, "Failed to read IRQ status 4: %d\n", in wm5100_irq()
2201 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_4_MASK, in wm5100_irq()
2204 dev_err(wm5100->dev, "Failed to read IRQ mask 4: %d\n", in wm5100_irq()
2214 regmap_write(wm5100->regmap, WM5100_INTERRUPT_STATUS_4, irq_val); in wm5100_irq()
2240 regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_set()
2252 ret = regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_direction_out()
2267 ret = regmap_read(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, &reg); in wm5100_gpio_get()
2278 return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_direction_in()
2299 wm5100->gpio_chip = wm5100_template_chip; in wm5100_init_gpio()
2300 wm5100->gpio_chip.ngpio = 6; in wm5100_init_gpio()
2301 wm5100->gpio_chip.parent = &i2c->dev; in wm5100_init_gpio()
2303 if (wm5100->pdata.gpio_base) in wm5100_init_gpio()
2304 wm5100->gpio_chip.base = wm5100->pdata.gpio_base; in wm5100_init_gpio()
2306 wm5100->gpio_chip.base = -1; in wm5100_init_gpio()
2308 ret = gpiochip_add_data(&wm5100->gpio_chip, wm5100); in wm5100_init_gpio()
2310 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret); in wm5100_init_gpio()
2317 gpiochip_remove(&wm5100->gpio_chip); in wm5100_free_gpio()
2332 struct i2c_client *i2c = to_i2c_client(component->dev); in wm5100_probe()
2336 wm5100->component = component; in wm5100_probe()
2348 if (i2c->irq) in wm5100_probe()
2352 if (wm5100->pdata.hp_pol) { in wm5100_probe()
2353 ret = gpio_request_one(wm5100->pdata.hp_pol, in wm5100_probe()
2356 dev_err(&i2c->dev, "Failed to request HP_POL %d: %d\n", in wm5100_probe()
2357 wm5100->pdata.hp_pol, ret); in wm5100_probe()
2373 if (wm5100->pdata.hp_pol) { in wm5100_remove()
2374 gpio_free(wm5100->pdata.hp_pol); in wm5100_remove()
2417 struct wm5100_pdata *pdata = dev_get_platdata(&i2c->dev); in wm5100_i2c_probe()
2422 wm5100 = devm_kzalloc(&i2c->dev, sizeof(struct wm5100_priv), in wm5100_i2c_probe()
2425 return -ENOMEM; in wm5100_i2c_probe()
2427 wm5100->dev = &i2c->dev; in wm5100_i2c_probe()
2429 wm5100->regmap = devm_regmap_init_i2c(i2c, &wm5100_regmap); in wm5100_i2c_probe()
2430 if (IS_ERR(wm5100->regmap)) { in wm5100_i2c_probe()
2431 ret = PTR_ERR(wm5100->regmap); in wm5100_i2c_probe()
2432 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in wm5100_i2c_probe()
2437 for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++) in wm5100_i2c_probe()
2438 init_completion(&wm5100->fll[i].lock); in wm5100_i2c_probe()
2441 wm5100->pdata = *pdata; in wm5100_i2c_probe()
2445 for (i = 0; i < ARRAY_SIZE(wm5100->core_supplies); i++) in wm5100_i2c_probe()
2446 wm5100->core_supplies[i].supply = wm5100_core_supply_names[i]; in wm5100_i2c_probe()
2448 ret = devm_regulator_bulk_get(&i2c->dev, in wm5100_i2c_probe()
2449 ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2450 wm5100->core_supplies); in wm5100_i2c_probe()
2452 dev_err(&i2c->dev, "Failed to request core supplies: %d\n", in wm5100_i2c_probe()
2457 ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2458 wm5100->core_supplies); in wm5100_i2c_probe()
2460 dev_err(&i2c->dev, "Failed to enable core supplies: %d\n", in wm5100_i2c_probe()
2465 if (wm5100->pdata.ldo_ena) { in wm5100_i2c_probe()
2466 ret = gpio_request_one(wm5100->pdata.ldo_ena, in wm5100_i2c_probe()
2469 dev_err(&i2c->dev, "Failed to request LDOENA %d: %d\n", in wm5100_i2c_probe()
2470 wm5100->pdata.ldo_ena, ret); in wm5100_i2c_probe()
2476 if (wm5100->pdata.reset) { in wm5100_i2c_probe()
2477 ret = gpio_request_one(wm5100->pdata.reset, in wm5100_i2c_probe()
2480 dev_err(&i2c->dev, "Failed to request /RESET %d: %d\n", in wm5100_i2c_probe()
2481 wm5100->pdata.reset, ret); in wm5100_i2c_probe()
2486 ret = regmap_read(wm5100->regmap, WM5100_SOFTWARE_RESET, &reg); in wm5100_i2c_probe()
2488 dev_err(&i2c->dev, "Failed to read ID register: %d\n", ret); in wm5100_i2c_probe()
2497 dev_err(&i2c->dev, "Device is not a WM5100, ID is %x\n", reg); in wm5100_i2c_probe()
2498 ret = -EINVAL; in wm5100_i2c_probe()
2502 ret = regmap_read(wm5100->regmap, WM5100_DEVICE_REVISION, &reg); in wm5100_i2c_probe()
2504 dev_err(&i2c->dev, "Failed to read revision register\n"); in wm5100_i2c_probe()
2507 wm5100->rev = reg & WM5100_DEVICE_REVISION_MASK; in wm5100_i2c_probe()
2509 dev_info(&i2c->dev, "revision %c\n", wm5100->rev + 'A'); in wm5100_i2c_probe()
2513 dev_err(&i2c->dev, "Failed to issue reset\n"); in wm5100_i2c_probe()
2517 switch (wm5100->rev) { in wm5100_i2c_probe()
2519 ret = regmap_register_patch(wm5100->regmap, in wm5100_i2c_probe()
2523 dev_err(&i2c->dev, "Failed to register patches: %d\n", in wm5100_i2c_probe()
2535 for (i = 0; i < ARRAY_SIZE(wm5100->pdata.gpio_defaults); i++) { in wm5100_i2c_probe()
2536 if (!wm5100->pdata.gpio_defaults[i]) in wm5100_i2c_probe()
2539 regmap_write(wm5100->regmap, WM5100_GPIO_CTRL_1 + i, in wm5100_i2c_probe()
2540 wm5100->pdata.gpio_defaults[i]); in wm5100_i2c_probe()
2543 for (i = 0; i < ARRAY_SIZE(wm5100->pdata.in_mode); i++) { in wm5100_i2c_probe()
2544 regmap_update_bits(wm5100->regmap, wm5100_mic_ctrl_reg[i], in wm5100_i2c_probe()
2547 (wm5100->pdata.in_mode[i] << in wm5100_i2c_probe()
2549 (wm5100->pdata.dmic_sup[i] << in wm5100_i2c_probe()
2553 if (i2c->irq) { in wm5100_i2c_probe()
2554 if (wm5100->pdata.irq_flags) in wm5100_i2c_probe()
2555 irq_flags = wm5100->pdata.irq_flags; in wm5100_i2c_probe()
2562 ret = request_threaded_irq(i2c->irq, NULL, in wm5100_i2c_probe()
2566 ret = request_threaded_irq(i2c->irq, NULL, wm5100_irq, in wm5100_i2c_probe()
2571 dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n", in wm5100_i2c_probe()
2572 i2c->irq, ret); in wm5100_i2c_probe()
2575 regmap_update_bits(wm5100->regmap, in wm5100_i2c_probe()
2586 regmap_update_bits(wm5100->regmap, in wm5100_i2c_probe()
2605 pm_runtime_set_active(&i2c->dev); in wm5100_i2c_probe()
2606 pm_runtime_enable(&i2c->dev); in wm5100_i2c_probe()
2607 pm_request_idle(&i2c->dev); in wm5100_i2c_probe()
2609 ret = devm_snd_soc_register_component(&i2c->dev, in wm5100_i2c_probe()
2613 dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret); in wm5100_i2c_probe()
2620 pm_runtime_disable(&i2c->dev); in wm5100_i2c_probe()
2621 if (i2c->irq) in wm5100_i2c_probe()
2622 free_irq(i2c->irq, wm5100); in wm5100_i2c_probe()
2624 if (wm5100->pdata.reset) { in wm5100_i2c_probe()
2625 gpio_set_value_cansleep(wm5100->pdata.reset, 0); in wm5100_i2c_probe()
2626 gpio_free(wm5100->pdata.reset); in wm5100_i2c_probe()
2629 if (wm5100->pdata.ldo_ena) { in wm5100_i2c_probe()
2630 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); in wm5100_i2c_probe()
2631 gpio_free(wm5100->pdata.ldo_ena); in wm5100_i2c_probe()
2634 regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2635 wm5100->core_supplies); in wm5100_i2c_probe()
2644 pm_runtime_disable(&i2c->dev); in wm5100_i2c_remove()
2645 if (i2c->irq) in wm5100_i2c_remove()
2646 free_irq(i2c->irq, wm5100); in wm5100_i2c_remove()
2648 if (wm5100->pdata.reset) { in wm5100_i2c_remove()
2649 gpio_set_value_cansleep(wm5100->pdata.reset, 0); in wm5100_i2c_remove()
2650 gpio_free(wm5100->pdata.reset); in wm5100_i2c_remove()
2652 if (wm5100->pdata.ldo_ena) { in wm5100_i2c_remove()
2653 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); in wm5100_i2c_remove()
2654 gpio_free(wm5100->pdata.ldo_ena); in wm5100_i2c_remove()
2665 regcache_cache_only(wm5100->regmap, true); in wm5100_runtime_suspend()
2666 regcache_mark_dirty(wm5100->regmap); in wm5100_runtime_suspend()
2667 if (wm5100->pdata.ldo_ena) in wm5100_runtime_suspend()
2668 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); in wm5100_runtime_suspend()
2669 regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_runtime_suspend()
2670 wm5100->core_supplies); in wm5100_runtime_suspend()
2680 ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_runtime_resume()
2681 wm5100->core_supplies); in wm5100_runtime_resume()
2688 if (wm5100->pdata.ldo_ena) { in wm5100_runtime_resume()
2689 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 1); in wm5100_runtime_resume()
2693 regcache_cache_only(wm5100->regmap, false); in wm5100_runtime_resume()
2694 regcache_sync(wm5100->regmap); in wm5100_runtime_resume()