Lines Matching refs:wm5100

120 	struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component);  in wm5100_alloc_sr()  local
132 if ((wm5100->sysclk % rate) == 0) { 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()
148 rate, i, wm5100->sr_ref[i]); in wm5100_alloc_sr()
159 wm5100->sr_ref[sr_free]++; in wm5100_alloc_sr()
169 rate, wm5100->sysclk, wm5100->asyncclk); in wm5100_alloc_sr()
176 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_free_sr() local
189 if (!wm5100->sr_ref[i]) in wm5100_free_sr()
197 wm5100->sr_ref[i]--; in wm5100_free_sr()
199 rate, wm5100->sr_ref[i]); in wm5100_free_sr()
206 static int wm5100_reset(struct wm5100_priv *wm5100) in wm5100_reset() argument
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()
736 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_seq_notifier() local
740 if (wm5100->out_ena[0]) { in wm5100_seq_notifier()
745 wm5100->out_ena[0] = false; in wm5100_seq_notifier()
755 if (wm5100->out_ena[1]) { in wm5100_seq_notifier()
760 wm5100->out_ena[1] = false; in wm5100_seq_notifier()
776 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_out_ev() local
780 wm5100->out_ena[0] = true; in wm5100_out_ev()
783 wm5100->out_ena[0] = true; in wm5100_out_ev()
792 static void wm5100_log_status3(struct wm5100_priv *wm5100, int val) in wm5100_log_status3() argument
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()
804 static void wm5100_log_status4(struct wm5100_priv *wm5100, int val) in wm5100_log_status4() argument
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()
841 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_post_ev() local
848 wm5100_log_status3(wm5100, ret); in wm5100_post_ev()
851 wm5100_log_status4(wm5100, ret); in wm5100_post_ev()
1400 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_hw_params() local
1401 bool async = wm5100->aif_async[dai->id]; in wm5100_hw_params()
1425 aif_rate = wm5100->sysclk; in wm5100_hw_params()
1431 aif_rate = wm5100->asyncclk; in wm5100_hw_params()
1479 wm5100->aif_symmetric[dai->id]) in wm5100_hw_params()
1509 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_set_sysclk() local
1516 rate_store = &wm5100->sysclk; in wm5100_set_sysclk()
1520 rate_store = &wm5100->asyncclk; 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()
1758 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_set_fll() local
1766 fll = &wm5100->fll[0]; in wm5100_set_fll()
1771 fll = &wm5100->fll[1]; in wm5100_set_fll()
1970 static void wm5100_set_detect_mode(struct wm5100_priv *wm5100, int the_mode) in wm5100_set_detect_mode() argument
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()
1983 regmap_update_bits(wm5100->regmap, WM5100_MISC_CONTROL, 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()
1993 static void wm5100_report_headphone(struct wm5100_priv *wm5100) in wm5100_report_headphone() argument
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()
2006 static void wm5100_micd_irq(struct wm5100_priv *wm5100) in wm5100_micd_irq() argument
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()
2077 wm5100_report_headphone(wm5100); 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()
2093 wm5100_report_headphone(wm5100); in wm5100_micd_irq()
2100 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_detect() local
2104 wm5100->jack = jack; in wm5100_detect()
2105 wm5100->jack_detecting = true; in wm5100_detect()
2106 wm5100->jack_flips = 0; in wm5100_detect()
2108 wm5100_set_detect_mode(wm5100, 0); in wm5100_detect()
2144 wm5100->jack = NULL; in wm5100_detect()
2153 struct wm5100_priv *wm5100 = data; in wm5100_irq() local
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()
2180 wm5100_log_status3(wm5100, 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()
2192 wm5100_micd_irq(wm5100); 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()
2216 wm5100_log_status4(wm5100, irq_val); in wm5100_irq()
2238 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_set() local
2240 regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_set()
2247 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_direction_out() local
2252 ret = regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_direction_out()
2263 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_get() local
2267 ret = regmap_read(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, &reg); in wm5100_gpio_get()
2276 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); in wm5100_gpio_direction_in() local
2278 return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, in wm5100_gpio_direction_in()
2296 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); in wm5100_init_gpio() local
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()
2315 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); in wm5100_free_gpio() local
2317 gpiochip_remove(&wm5100->gpio_chip); in wm5100_free_gpio()
2333 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_probe() local
2336 wm5100->component = component; in wm5100_probe()
2352 if (wm5100->pdata.hp_pol) { in wm5100_probe()
2353 ret = gpio_request_one(wm5100->pdata.hp_pol, in wm5100_probe()
2357 wm5100->pdata.hp_pol, ret); in wm5100_probe()
2371 struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); in wm5100_remove() local
2373 if (wm5100->pdata.hp_pol) { in wm5100_remove()
2374 gpio_free(wm5100->pdata.hp_pol); in wm5100_remove()
2416 struct wm5100_priv *wm5100; in wm5100_i2c_probe() local
2420 wm5100 = devm_kzalloc(&i2c->dev, sizeof(struct wm5100_priv), in wm5100_i2c_probe()
2422 if (wm5100 == NULL) in wm5100_i2c_probe()
2425 wm5100->dev = &i2c->dev; in wm5100_i2c_probe()
2427 wm5100->regmap = devm_regmap_init_i2c(i2c, &wm5100_regmap); in wm5100_i2c_probe()
2428 if (IS_ERR(wm5100->regmap)) { in wm5100_i2c_probe()
2429 ret = PTR_ERR(wm5100->regmap); in wm5100_i2c_probe()
2435 for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++) in wm5100_i2c_probe()
2436 init_completion(&wm5100->fll[i].lock); in wm5100_i2c_probe()
2439 wm5100->pdata = *pdata; in wm5100_i2c_probe()
2441 i2c_set_clientdata(i2c, wm5100); in wm5100_i2c_probe()
2443 for (i = 0; i < ARRAY_SIZE(wm5100->core_supplies); i++) in wm5100_i2c_probe()
2444 wm5100->core_supplies[i].supply = wm5100_core_supply_names[i]; in wm5100_i2c_probe()
2447 ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2448 wm5100->core_supplies); in wm5100_i2c_probe()
2455 ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2456 wm5100->core_supplies); in wm5100_i2c_probe()
2463 if (wm5100->pdata.ldo_ena) { in wm5100_i2c_probe()
2464 ret = gpio_request_one(wm5100->pdata.ldo_ena, in wm5100_i2c_probe()
2468 wm5100->pdata.ldo_ena, ret); in wm5100_i2c_probe()
2474 if (wm5100->pdata.reset) { in wm5100_i2c_probe()
2475 ret = gpio_request_one(wm5100->pdata.reset, in wm5100_i2c_probe()
2479 wm5100->pdata.reset, ret); in wm5100_i2c_probe()
2484 ret = regmap_read(wm5100->regmap, WM5100_SOFTWARE_RESET, &reg); in wm5100_i2c_probe()
2500 ret = regmap_read(wm5100->regmap, WM5100_DEVICE_REVISION, &reg); in wm5100_i2c_probe()
2505 wm5100->rev = reg & WM5100_DEVICE_REVISION_MASK; in wm5100_i2c_probe()
2507 dev_info(&i2c->dev, "revision %c\n", wm5100->rev + 'A'); in wm5100_i2c_probe()
2509 ret = wm5100_reset(wm5100); in wm5100_i2c_probe()
2515 switch (wm5100->rev) { in wm5100_i2c_probe()
2517 ret = regmap_register_patch(wm5100->regmap, in wm5100_i2c_probe()
2533 for (i = 0; i < ARRAY_SIZE(wm5100->pdata.gpio_defaults); i++) { in wm5100_i2c_probe()
2534 if (!wm5100->pdata.gpio_defaults[i]) in wm5100_i2c_probe()
2537 regmap_write(wm5100->regmap, WM5100_GPIO_CTRL_1 + i, in wm5100_i2c_probe()
2538 wm5100->pdata.gpio_defaults[i]); in wm5100_i2c_probe()
2541 for (i = 0; i < ARRAY_SIZE(wm5100->pdata.in_mode); i++) { in wm5100_i2c_probe()
2542 regmap_update_bits(wm5100->regmap, wm5100_mic_ctrl_reg[i], in wm5100_i2c_probe()
2545 (wm5100->pdata.in_mode[i] << in wm5100_i2c_probe()
2547 (wm5100->pdata.dmic_sup[i] << in wm5100_i2c_probe()
2552 if (wm5100->pdata.irq_flags) in wm5100_i2c_probe()
2553 irq_flags = wm5100->pdata.irq_flags; in wm5100_i2c_probe()
2562 "wm5100", wm5100); in wm5100_i2c_probe()
2566 wm5100); in wm5100_i2c_probe()
2573 regmap_update_bits(wm5100->regmap, in wm5100_i2c_probe()
2584 regmap_update_bits(wm5100->regmap, in wm5100_i2c_probe()
2620 free_irq(i2c->irq, wm5100); in wm5100_i2c_probe()
2622 if (wm5100->pdata.reset) { in wm5100_i2c_probe()
2623 gpio_set_value_cansleep(wm5100->pdata.reset, 0); in wm5100_i2c_probe()
2624 gpio_free(wm5100->pdata.reset); in wm5100_i2c_probe()
2627 if (wm5100->pdata.ldo_ena) { in wm5100_i2c_probe()
2628 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); in wm5100_i2c_probe()
2629 gpio_free(wm5100->pdata.ldo_ena); in wm5100_i2c_probe()
2632 regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_i2c_probe()
2633 wm5100->core_supplies); in wm5100_i2c_probe()
2640 struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); in wm5100_i2c_remove() local
2644 free_irq(i2c->irq, wm5100); in wm5100_i2c_remove()
2646 if (wm5100->pdata.reset) { in wm5100_i2c_remove()
2647 gpio_set_value_cansleep(wm5100->pdata.reset, 0); in wm5100_i2c_remove()
2648 gpio_free(wm5100->pdata.reset); in wm5100_i2c_remove()
2650 if (wm5100->pdata.ldo_ena) { in wm5100_i2c_remove()
2651 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); in wm5100_i2c_remove()
2652 gpio_free(wm5100->pdata.ldo_ena); in wm5100_i2c_remove()
2659 struct wm5100_priv *wm5100 = dev_get_drvdata(dev); in wm5100_runtime_suspend() local
2661 regcache_cache_only(wm5100->regmap, true); in wm5100_runtime_suspend()
2662 regcache_mark_dirty(wm5100->regmap); in wm5100_runtime_suspend()
2663 if (wm5100->pdata.ldo_ena) in wm5100_runtime_suspend()
2664 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); in wm5100_runtime_suspend()
2665 regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_runtime_suspend()
2666 wm5100->core_supplies); in wm5100_runtime_suspend()
2673 struct wm5100_priv *wm5100 = dev_get_drvdata(dev); in wm5100_runtime_resume() local
2676 ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), in wm5100_runtime_resume()
2677 wm5100->core_supplies); in wm5100_runtime_resume()
2684 if (wm5100->pdata.ldo_ena) { in wm5100_runtime_resume()
2685 gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 1); in wm5100_runtime_resume()
2689 regcache_cache_only(wm5100->regmap, false); in wm5100_runtime_resume()
2690 regcache_sync(wm5100->regmap); in wm5100_runtime_resume()