Lines Matching refs:wm5100

123 	struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component);  in wm5100_alloc_sr()  local
135 if ((wm5100->sysclk % rate) == 0) { in wm5100_alloc_sr()
139 if (!wm5100->sr_ref[i] && sr_free == -1) { in wm5100_alloc_sr()
149 wm5100->sr_ref[i]++; in wm5100_alloc_sr()
151 rate, i, wm5100->sr_ref[i]); in wm5100_alloc_sr()
162 wm5100->sr_ref[sr_free]++; in wm5100_alloc_sr()
172 rate, wm5100->sysclk, wm5100->asyncclk); in wm5100_alloc_sr()
179 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_free_sr() local
192 if (!wm5100->sr_ref[i]) in wm5100_free_sr()
200 wm5100->sr_ref[i]--; in wm5100_free_sr()
202 rate, wm5100->sr_ref[i]); in wm5100_free_sr()
209 static int wm5100_reset(struct wm5100_priv *wm5100) in wm5100_reset() argument
211 if (wm5100->reset) { in wm5100_reset()
212 gpiod_set_value_cansleep(wm5100->reset, 1); in wm5100_reset()
213 gpiod_set_value_cansleep(wm5100->reset, 0); in wm5100_reset()
217 return regmap_write(wm5100->regmap, WM5100_SOFTWARE_RESET, 0); in wm5100_reset()
739 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_seq_notifier() local
743 if (wm5100->out_ena[0]) { in wm5100_seq_notifier()
748 wm5100->out_ena[0] = false; in wm5100_seq_notifier()
758 if (wm5100->out_ena[1]) { in wm5100_seq_notifier()
763 wm5100->out_ena[1] = false; in wm5100_seq_notifier()
779 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_out_ev() local
783 wm5100->out_ena[0] = true; in wm5100_out_ev()
786 wm5100->out_ena[0] = true; in wm5100_out_ev()
795 static void wm5100_log_status3(struct wm5100_priv *wm5100, int val) in wm5100_log_status3() argument
798 dev_crit(wm5100->dev, "Speaker shutdown warning\n"); in wm5100_log_status3()
800 dev_crit(wm5100->dev, "Speaker shutdown\n"); in wm5100_log_status3()
802 dev_crit(wm5100->dev, "SYSCLK underclocked\n"); in wm5100_log_status3()
804 dev_crit(wm5100->dev, "ASYNCCLK underclocked\n"); in wm5100_log_status3()
807 static void wm5100_log_status4(struct wm5100_priv *wm5100, int val) in wm5100_log_status4() argument
810 dev_err(wm5100->dev, "AIF3 configuration error\n"); in wm5100_log_status4()
812 dev_err(wm5100->dev, "AIF2 configuration error\n"); in wm5100_log_status4()
814 dev_err(wm5100->dev, "AIF1 configuration error\n"); in wm5100_log_status4()
816 dev_err(wm5100->dev, "Control interface error\n"); in wm5100_log_status4()
818 dev_err(wm5100->dev, "ISRC2 underclocked\n"); in wm5100_log_status4()
820 dev_err(wm5100->dev, "ISRC1 underclocked\n"); in wm5100_log_status4()
822 dev_err(wm5100->dev, "FX underclocked\n"); in wm5100_log_status4()
824 dev_err(wm5100->dev, "AIF3 underclocked\n"); in wm5100_log_status4()
826 dev_err(wm5100->dev, "AIF2 underclocked\n"); in wm5100_log_status4()
828 dev_err(wm5100->dev, "AIF1 underclocked\n"); in wm5100_log_status4()
830 dev_err(wm5100->dev, "ASRC underclocked\n"); in wm5100_log_status4()
832 dev_err(wm5100->dev, "DAC underclocked\n"); in wm5100_log_status4()
834 dev_err(wm5100->dev, "ADC underclocked\n"); in wm5100_log_status4()
836 dev_err(wm5100->dev, "Mixer underclocked\n"); in wm5100_log_status4()
844 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_post_ev() local
851 wm5100_log_status3(wm5100, ret); in wm5100_post_ev()
854 wm5100_log_status4(wm5100, ret); in wm5100_post_ev()
1403 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_hw_params() local
1404 bool async = wm5100->aif_async[dai->id]; in wm5100_hw_params()
1428 aif_rate = wm5100->sysclk; in wm5100_hw_params()
1434 aif_rate = wm5100->asyncclk; in wm5100_hw_params()
1482 wm5100->aif_symmetric[dai->id]) in wm5100_hw_params()
1512 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_set_sysclk() local
1519 rate_store = &wm5100->sysclk; in wm5100_set_sysclk()
1523 rate_store = &wm5100->asyncclk; in wm5100_set_sysclk()
1546 wm5100->aif_async[clk_id - 1] = false; in wm5100_set_sysclk()
1549 wm5100->aif_async[clk_id - 1] = true; in wm5100_set_sysclk()
1761 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_set_fll() local
1769 fll = &wm5100->fll[0]; in wm5100_set_fll()
1774 fll = &wm5100->fll[1]; in wm5100_set_fll()
1973 static void wm5100_set_detect_mode(struct wm5100_priv *wm5100, int the_mode) in wm5100_set_detect_mode() argument
1975 struct wm5100_jack_mode *mode = &wm5100->pdata.jack_modes[the_mode]; in wm5100_set_detect_mode()
1977 if (WARN_ON(the_mode >= ARRAY_SIZE(wm5100->pdata.jack_modes))) in wm5100_set_detect_mode()
1980 gpiod_set_value_cansleep(wm5100->hp_pol, mode->hp_pol); in wm5100_set_detect_mode()
1981 regmap_update_bits(wm5100->regmap, WM5100_ACCESSORY_DETECT_MODE_1, in wm5100_set_detect_mode()
1986 regmap_update_bits(wm5100->regmap, WM5100_MISC_CONTROL, in wm5100_set_detect_mode()
1990 wm5100->jack_mode = the_mode; in wm5100_set_detect_mode()
1992 dev_dbg(wm5100->dev, "Set microphone polarity to %d\n", in wm5100_set_detect_mode()
1993 wm5100->jack_mode); in wm5100_set_detect_mode()
1996 static void wm5100_report_headphone(struct wm5100_priv *wm5100) in wm5100_report_headphone() argument
1998 dev_dbg(wm5100->dev, "Headphone detected\n"); in wm5100_report_headphone()
1999 wm5100->jack_detecting = false; in wm5100_report_headphone()
2000 snd_soc_jack_report(wm5100->jack, SND_JACK_HEADPHONE, in wm5100_report_headphone()
2004 regmap_update_bits(wm5100->regmap, WM5100_MIC_DETECT_1, in wm5100_report_headphone()
2009 static void wm5100_micd_irq(struct wm5100_priv *wm5100) in wm5100_micd_irq() argument
2014 ret = regmap_read(wm5100->regmap, WM5100_MIC_DETECT_3, &val); in wm5100_micd_irq()
2016 dev_err(wm5100->dev, "Failed to read microphone status: %d\n", in wm5100_micd_irq()
2021 dev_dbg(wm5100->dev, "Microphone event: %x\n", val); in wm5100_micd_irq()
2024 dev_warn(wm5100->dev, "Microphone detection state invalid\n"); in wm5100_micd_irq()
2030 dev_dbg(wm5100->dev, "Jack removal detected\n"); in wm5100_micd_irq()
2031 wm5100->jack_mic = false; in wm5100_micd_irq()
2032 wm5100->jack_detecting = true; in wm5100_micd_irq()
2033 wm5100->jack_flips = 0; in wm5100_micd_irq()
2034 snd_soc_jack_report(wm5100->jack, 0, in wm5100_micd_irq()
2038 regmap_update_bits(wm5100->regmap, WM5100_MIC_DETECT_1, in wm5100_micd_irq()
2049 if (wm5100->jack_detecting) { in wm5100_micd_irq()
2050 dev_dbg(wm5100->dev, "Microphone detected\n"); in wm5100_micd_irq()
2051 wm5100->jack_mic = true; in wm5100_micd_irq()
2052 wm5100->jack_detecting = false; in wm5100_micd_irq()
2053 snd_soc_jack_report(wm5100->jack, in wm5100_micd_irq()
2059 regmap_update_bits(wm5100->regmap, WM5100_MIC_DETECT_1, in wm5100_micd_irq()
2063 dev_dbg(wm5100->dev, "Mic button up\n"); in wm5100_micd_irq()
2064 snd_soc_jack_report(wm5100->jack, 0, SND_JACK_BTN_0); in wm5100_micd_irq()
2076 if (wm5100->jack_detecting && (val & 0x3f8)) { in wm5100_micd_irq()
2077 wm5100->jack_flips++; in wm5100_micd_irq()
2079 if (wm5100->jack_flips > 1) in wm5100_micd_irq()
2080 wm5100_report_headphone(wm5100); in wm5100_micd_irq()
2082 wm5100_set_detect_mode(wm5100, !wm5100->jack_mode); in wm5100_micd_irq()
2091 if (wm5100->jack_mic) { in wm5100_micd_irq()
2092 dev_dbg(wm5100->dev, "Mic button detected\n"); in wm5100_micd_irq()
2093 snd_soc_jack_report(wm5100->jack, SND_JACK_BTN_0, in wm5100_micd_irq()
2095 } else if (wm5100->jack_detecting) { in wm5100_micd_irq()
2096 wm5100_report_headphone(wm5100); in wm5100_micd_irq()
2103 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_detect() local
2107 wm5100->jack = jack; in wm5100_detect()
2108 wm5100->jack_detecting = true; in wm5100_detect()
2109 wm5100->jack_flips = 0; in wm5100_detect()
2111 wm5100_set_detect_mode(wm5100, 0); in wm5100_detect()
2147 wm5100->jack = NULL; in wm5100_detect()
2156 struct wm5100_priv *wm5100 = data; in wm5100_irq() local
2161 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_3, &irq_val); in wm5100_irq()
2163 dev_err(wm5100->dev, "Failed to read IRQ status 3: %d\n", in wm5100_irq()
2168 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_3_MASK, in wm5100_irq()
2171 dev_err(wm5100->dev, "Failed to read IRQ mask 3: %d\n", in wm5100_irq()
2178 regmap_write(wm5100->regmap, WM5100_INTERRUPT_STATUS_3, irq_val); in wm5100_irq()
2183 wm5100_log_status3(wm5100, irq_val); in wm5100_irq()
2186 dev_dbg(wm5100->dev, "FLL1 locked\n"); in wm5100_irq()
2187 complete(&wm5100->fll[0].lock); in wm5100_irq()
2190 dev_dbg(wm5100->dev, "FLL2 locked\n"); in wm5100_irq()
2191 complete(&wm5100->fll[1].lock); in wm5100_irq()
2195 wm5100_micd_irq(wm5100); in wm5100_irq()
2197 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_4, &irq_val); in wm5100_irq()
2199 dev_err(wm5100->dev, "Failed to read IRQ status 4: %d\n", in wm5100_irq()
2204 ret = regmap_read(wm5100->regmap, WM5100_INTERRUPT_STATUS_4_MASK, in wm5100_irq()
2207 dev_err(wm5100->dev, "Failed to read IRQ mask 4: %d\n", in wm5100_irq()
2217 regmap_write(wm5100->regmap, WM5100_INTERRUPT_STATUS_4, irq_val); in wm5100_irq()
2219 wm5100_log_status4(wm5100, irq_val); in wm5100_irq()
2241 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_set() local
2243 regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_set()
2250 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_direction_out() local
2255 ret = regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_direction_out()
2266 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_get() local
2270 ret = regmap_read(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, &reg); in wm5100_gpio_get()
2279 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_direction_in() local
2281 return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_direction_in()
2299 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); in wm5100_init_gpio() local
2302 wm5100->gpio_chip = wm5100_template_chip; in wm5100_init_gpio()
2303 wm5100->gpio_chip.ngpio = 6; in wm5100_init_gpio()
2304 wm5100->gpio_chip.parent = &i2c->dev; in wm5100_init_gpio()
2305 wm5100->gpio_chip.base = -1; in wm5100_init_gpio()
2307 ret = gpiochip_add_data(&wm5100->gpio_chip, wm5100); in wm5100_init_gpio()
2314 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); in wm5100_free_gpio() local
2316 gpiochip_remove(&wm5100->gpio_chip); in wm5100_free_gpio()
2332 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_probe() local
2335 wm5100->component = component; in wm5100_probe()
2351 wm5100->hp_pol = devm_gpiod_get_optional(&i2c->dev, "hp-pol", in wm5100_probe()
2353 if (IS_ERR(wm5100->hp_pol)) { in wm5100_probe()
2354 ret = PTR_ERR(wm5100->hp_pol); in wm5100_probe()
2400 struct wm5100_priv *wm5100; in wm5100_i2c_probe() local
2404 wm5100 = devm_kzalloc(&i2c->dev, sizeof(struct wm5100_priv), in wm5100_i2c_probe()
2406 if (wm5100 == NULL) in wm5100_i2c_probe()
2409 wm5100->dev = &i2c->dev; in wm5100_i2c_probe()
2411 wm5100->regmap = devm_regmap_init_i2c(i2c, &wm5100_regmap); in wm5100_i2c_probe()
2412 if (IS_ERR(wm5100->regmap)) { in wm5100_i2c_probe()
2413 ret = PTR_ERR(wm5100->regmap); in wm5100_i2c_probe()
2419 for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++) in wm5100_i2c_probe()
2420 init_completion(&wm5100->fll[i].lock); in wm5100_i2c_probe()
2423 wm5100->pdata = *pdata; in wm5100_i2c_probe()
2425 i2c_set_clientdata(i2c, wm5100); in wm5100_i2c_probe()
2427 for (i = 0; i < ARRAY_SIZE(wm5100->core_supplies); i++) in wm5100_i2c_probe()
2428 wm5100->core_supplies[i].supply = wm5100_core_supply_names[i]; in wm5100_i2c_probe()
2431 ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2432 wm5100->core_supplies); in wm5100_i2c_probe()
2439 ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2440 wm5100->core_supplies); in wm5100_i2c_probe()
2447 wm5100->ldo_ena = devm_gpiod_get_optional(&i2c->dev, "wlf,ldo1ena", in wm5100_i2c_probe()
2449 if (IS_ERR(wm5100->ldo_ena)) { in wm5100_i2c_probe()
2450 ret = PTR_ERR(wm5100->ldo_ena); in wm5100_i2c_probe()
2454 if (wm5100->ldo_ena) { in wm5100_i2c_probe()
2455 gpiod_set_consumer_name(wm5100->ldo_ena, "WM5100 LDOENA"); in wm5100_i2c_probe()
2459 wm5100->reset = devm_gpiod_get_optional(&i2c->dev, "reset", in wm5100_i2c_probe()
2461 if (IS_ERR(wm5100->reset)) { in wm5100_i2c_probe()
2462 ret = PTR_ERR(wm5100->reset); in wm5100_i2c_probe()
2466 gpiod_set_consumer_name(wm5100->reset, "WM5100 /RESET"); in wm5100_i2c_probe()
2468 ret = regmap_read(wm5100->regmap, WM5100_SOFTWARE_RESET, &reg); in wm5100_i2c_probe()
2484 ret = regmap_read(wm5100->regmap, WM5100_DEVICE_REVISION, &reg); in wm5100_i2c_probe()
2489 wm5100->rev = reg & WM5100_DEVICE_REVISION_MASK; in wm5100_i2c_probe()
2491 dev_info(&i2c->dev, "revision %c\n", wm5100->rev + 'A'); in wm5100_i2c_probe()
2493 ret = wm5100_reset(wm5100); in wm5100_i2c_probe()
2499 switch (wm5100->rev) { in wm5100_i2c_probe()
2501 ret = regmap_register_patch(wm5100->regmap, in wm5100_i2c_probe()
2517 for (i = 0; i < ARRAY_SIZE(wm5100->pdata.gpio_defaults); i++) { in wm5100_i2c_probe()
2518 if (!wm5100->pdata.gpio_defaults[i]) in wm5100_i2c_probe()
2521 regmap_write(wm5100->regmap, WM5100_GPIO_CTRL_1 + i, in wm5100_i2c_probe()
2522 wm5100->pdata.gpio_defaults[i]); in wm5100_i2c_probe()
2525 for (i = 0; i < ARRAY_SIZE(wm5100->pdata.in_mode); i++) { in wm5100_i2c_probe()
2526 regmap_update_bits(wm5100->regmap, wm5100_mic_ctrl_reg[i], in wm5100_i2c_probe()
2529 (wm5100->pdata.in_mode[i] << in wm5100_i2c_probe()
2531 (wm5100->pdata.dmic_sup[i] << in wm5100_i2c_probe()
2536 if (wm5100->pdata.irq_flags) in wm5100_i2c_probe()
2537 irq_flags = wm5100->pdata.irq_flags; in wm5100_i2c_probe()
2546 "wm5100", wm5100); in wm5100_i2c_probe()
2550 wm5100); in wm5100_i2c_probe()
2557 regmap_update_bits(wm5100->regmap, in wm5100_i2c_probe()
2568 regmap_update_bits(wm5100->regmap, in wm5100_i2c_probe()
2604 free_irq(i2c->irq, wm5100); in wm5100_i2c_probe()
2606 gpiod_set_value_cansleep(wm5100->reset, 1); in wm5100_i2c_probe()
2608 gpiod_set_value_cansleep(wm5100->ldo_ena, 0); in wm5100_i2c_probe()
2610 regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2611 wm5100->core_supplies); in wm5100_i2c_probe()
2618 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); in wm5100_i2c_remove() local
2622 free_irq(i2c->irq, wm5100); in wm5100_i2c_remove()
2624 gpiod_set_value_cansleep(wm5100->reset, 1); in wm5100_i2c_remove()
2625 gpiod_set_value_cansleep(wm5100->ldo_ena, 0); in wm5100_i2c_remove()
2631 struct wm5100_priv *wm5100 = dev_get_drvdata(dev); in wm5100_runtime_suspend() local
2633 regcache_cache_only(wm5100->regmap, true); in wm5100_runtime_suspend()
2634 regcache_mark_dirty(wm5100->regmap); in wm5100_runtime_suspend()
2635 gpiod_set_value_cansleep(wm5100->ldo_ena, 0); in wm5100_runtime_suspend()
2636 regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_runtime_suspend()
2637 wm5100->core_supplies); in wm5100_runtime_suspend()
2644 struct wm5100_priv *wm5100 = dev_get_drvdata(dev); in wm5100_runtime_resume() local
2647 ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_runtime_resume()
2648 wm5100->core_supplies); in wm5100_runtime_resume()
2655 if (wm5100->ldo_ena) { in wm5100_runtime_resume()
2656 gpiod_set_value_cansleep(wm5100->ldo_ena, 1); in wm5100_runtime_resume()
2660 regcache_cache_only(wm5100->regmap, false); in wm5100_runtime_resume()
2661 regcache_sync(wm5100->regmap); in wm5100_runtime_resume()