Lines Matching refs:wm8962

95 	struct wm8962_priv *wm8962 = container_of(nb, struct wm8962_priv, \
98 regcache_mark_dirty(wm8962->regmap); \
1439 static int wm8962_reset(struct wm8962_priv *wm8962) in wm8962_reset() argument
1443 ret = regmap_write(wm8962->regmap, WM8962_SOFTWARE_RESET, 0x6243); in wm8962_reset()
1447 return regmap_write(wm8962->regmap, WM8962_PLL_SOFTWARE_RESET, 0); in wm8962_reset()
1474 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_dsp2_write_config() local
1476 return regcache_sync_region(wm8962->regmap, in wm8962_dsp2_write_config()
1505 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_dsp2_start() local
1511 wm8962_dsp2_set_enable(component, wm8962->dsp2_ena); in wm8962_dsp2_start()
1548 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_dsp2_ena_get() local
1550 ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); in wm8962_dsp2_ena_get()
1560 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_dsp2_ena_put() local
1561 int old = wm8962->dsp2_ena; in wm8962_dsp2_ena_put()
1566 mutex_lock(&wm8962->dsp2_ena_lock); in wm8962_dsp2_ena_put()
1569 wm8962->dsp2_ena |= 1 << shift; in wm8962_dsp2_ena_put()
1571 wm8962->dsp2_ena &= ~(1 << shift); in wm8962_dsp2_ena_put()
1573 if (wm8962->dsp2_ena == old) in wm8962_dsp2_ena_put()
1579 if (wm8962->dsp2_ena) in wm8962_dsp2_ena_put()
1580 wm8962_dsp2_set_enable(component, wm8962->dsp2_ena); in wm8962_dsp2_ena_put()
1586 mutex_unlock(&wm8962->dsp2_ena_lock); in wm8962_dsp2_ena_put()
2034 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in dsp2_event() local
2038 if (wm8962->dsp2_ena) in dsp2_event()
2043 if (wm8962->dsp2_ena) in dsp2_event()
2419 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_add_widgets() local
2420 struct wm8962_pdata *pdata = &wm8962->pdata; in wm8962_add_widgets()
2468 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_configure_bclk() local
2475 if (!wm8962->sysclk_rate) { in wm8962_configure_bclk()
2480 if (!wm8962->bclk || !wm8962->lrclk) { in wm8962_configure_bclk()
2486 if (sysclk_rates[i] == wm8962->sysclk_rate / wm8962->lrclk) { in wm8962_configure_bclk()
2494 wm8962->sysclk_rate / wm8962->lrclk); in wm8962_configure_bclk()
2533 dspclk = wm8962->sysclk_rate; in wm8962_configure_bclk()
2536 dspclk = wm8962->sysclk_rate / 2; in wm8962_configure_bclk()
2539 dspclk = wm8962->sysclk_rate / 4; in wm8962_configure_bclk()
2543 dspclk = wm8962->sysclk_rate; in wm8962_configure_bclk()
2546 dev_dbg(component->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); in wm8962_configure_bclk()
2555 diff = (dspclk / bclk_divs[i]) - wm8962->bclk; in wm8962_configure_bclk()
2563 wm8962->bclk = dspclk / bclk_divs[best]; in wm8962_configure_bclk()
2566 bclk_divs[best], wm8962->bclk); in wm8962_configure_bclk()
2568 aif2 |= wm8962->bclk / wm8962->lrclk; in wm8962_configure_bclk()
2570 wm8962->bclk / wm8962->lrclk, wm8962->lrclk); in wm8962_configure_bclk()
2631 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_hw_params() local
2636 wm8962->bclk = snd_soc_params_to_bclk(params); in wm8962_hw_params()
2638 wm8962->bclk *= 2; in wm8962_hw_params()
2640 wm8962->lrclk = params_rate(params); in wm8962_hw_params()
2643 if (sr_vals[i].rate == wm8962->lrclk) { in wm8962_hw_params()
2649 dev_err(component->dev, "Unsupported rate %dHz\n", wm8962->lrclk); in wm8962_hw_params()
2653 if (wm8962->lrclk % 8000 == 0) in wm8962_hw_params()
2679 wm8962->bclk, wm8962->lrclk); in wm8962_hw_params()
2691 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_set_dai_sysclk() local
2696 wm8962->sysclk = WM8962_SYSCLK_MCLK; in wm8962_set_dai_sysclk()
2700 wm8962->sysclk = WM8962_SYSCLK_FLL; in wm8962_set_dai_sysclk()
2710 wm8962->sysclk_rate = freq; in wm8962_set_dai_sysclk()
2887 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_set_fll() local
2894 if (source == wm8962->fll_src && Fref == wm8962->fll_fref && in wm8962_set_fll()
2895 Fout == wm8962->fll_fout) in wm8962_set_fll()
2901 wm8962->fll_fref = 0; in wm8962_set_fll()
2902 wm8962->fll_fout = 0; in wm8962_set_fll()
2959 reinit_completion(&wm8962->fll_lock); in wm8962_set_fll()
2976 if (wm8962->irq) in wm8962_set_fll()
2981 time_left = wait_for_completion_timeout(&wm8962->fll_lock, in wm8962_set_fll()
2984 if (time_left == 0 && wm8962->irq) { in wm8962_set_fll()
2992 wm8962->fll_fref = Fref; in wm8962_set_fll()
2993 wm8962->fll_fout = Fout; in wm8962_set_fll()
2994 wm8962->fll_src = source; in wm8962_set_fll()
3058 struct wm8962_priv *wm8962 = container_of(work, in wm8962_mic_work() local
3061 struct snd_soc_component *component = wm8962->component; in wm8962_mic_work()
3078 snd_soc_jack_report(wm8962->jack, status, in wm8962_mic_work()
3089 struct wm8962_priv *wm8962 = dev_get_drvdata(dev); in wm8962_irq() local
3100 ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2_MASK, in wm8962_irq()
3109 ret = regmap_read(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, &active); in wm8962_irq()
3124 ret = regmap_write(wm8962->regmap, WM8962_INTERRUPT_STATUS_2, active); in wm8962_irq()
3130 complete(&wm8962->fll_lock); in wm8962_irq()
3139 ret = regmap_read(wm8962->regmap, in wm8962_irq()
3167 &wm8962->mic_work, in wm8962_irq()
3191 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_mic_detect() local
3195 wm8962->jack = jack; in wm8962_mic_detect()
3210 snd_soc_jack_report(wm8962->jack, 0, in wm8962_mic_detect()
3235 struct wm8962_priv *wm8962 = in wm8962_beep_work() local
3237 struct snd_soc_component *component = wm8962->component; in wm8962_beep_work()
3243 if (wm8962->beep_rate) { in wm8962_beep_work()
3245 if (abs(wm8962->beep_rate - beep_rates[i]) < in wm8962_beep_work()
3246 abs(wm8962->beep_rate - beep_rates[best])) in wm8962_beep_work()
3251 beep_rates[best], wm8962->beep_rate); in wm8962_beep_work()
3274 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_beep_event() local
3290 wm8962->beep_rate = hz; in wm8962_beep_event()
3291 schedule_work(&wm8962->beep_work); in wm8962_beep_event()
3298 struct wm8962_priv *wm8962 = dev_get_drvdata(dev); in beep_store() local
3306 input_event(wm8962->beep, EV_SND, SND_TONE, time); in beep_store()
3315 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_init_beep() local
3318 wm8962->beep = devm_input_allocate_device(component->dev); in wm8962_init_beep()
3319 if (!wm8962->beep) { in wm8962_init_beep()
3324 INIT_WORK(&wm8962->beep_work, wm8962_beep_work); in wm8962_init_beep()
3325 wm8962->beep_rate = 0; in wm8962_init_beep()
3327 wm8962->beep->name = "WM8962 Beep Generator"; in wm8962_init_beep()
3328 wm8962->beep->phys = dev_name(component->dev); in wm8962_init_beep()
3329 wm8962->beep->id.bustype = BUS_I2C; in wm8962_init_beep()
3331 wm8962->beep->evbit[0] = BIT_MASK(EV_SND); in wm8962_init_beep()
3332 wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); in wm8962_init_beep()
3333 wm8962->beep->event = wm8962_beep_event; in wm8962_init_beep()
3334 wm8962->beep->dev.parent = component->dev; in wm8962_init_beep()
3335 input_set_drvdata(wm8962->beep, component); in wm8962_init_beep()
3337 ret = input_register_device(wm8962->beep); in wm8962_init_beep()
3339 wm8962->beep = NULL; in wm8962_init_beep()
3352 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_free_beep() local
3355 cancel_work_sync(&wm8962->beep_work); in wm8962_free_beep()
3356 wm8962->beep = NULL; in wm8962_free_beep()
3361 static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) in wm8962_set_gpio_mode() argument
3382 regmap_update_bits(wm8962->regmap, WM8962_ANALOGUE_CLOCKING1, in wm8962_set_gpio_mode()
3389 struct wm8962_priv *wm8962 = gpiochip_get_data(chip); in wm8962_gpio_request() local
3405 wm8962_set_gpio_mode(wm8962, offset + 1); in wm8962_gpio_request()
3412 struct wm8962_priv *wm8962 = gpiochip_get_data(chip); in wm8962_gpio_set() local
3413 struct snd_soc_component *component = wm8962->component; in wm8962_gpio_set()
3422 struct wm8962_priv *wm8962 = gpiochip_get_data(chip); in wm8962_gpio_direction_out() local
3423 struct snd_soc_component *component = wm8962->component; in wm8962_gpio_direction_out()
3448 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_init_gpio() local
3449 struct wm8962_pdata *pdata = &wm8962->pdata; in wm8962_init_gpio()
3452 wm8962->gpio_chip = wm8962_template_chip; in wm8962_init_gpio()
3453 wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO; in wm8962_init_gpio()
3454 wm8962->gpio_chip.parent = component->dev; in wm8962_init_gpio()
3457 wm8962->gpio_chip.base = pdata->gpio_base; in wm8962_init_gpio()
3459 wm8962->gpio_chip.base = -1; in wm8962_init_gpio()
3461 ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962); in wm8962_init_gpio()
3468 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_free_gpio() local
3470 gpiochip_remove(&wm8962->gpio_chip); in wm8962_free_gpio()
3486 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_probe() local
3490 wm8962->component = component; in wm8962_probe()
3492 wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0; in wm8962_probe()
3493 wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1; in wm8962_probe()
3494 wm8962->disable_nb[2].notifier_call = wm8962_regulator_event_2; in wm8962_probe()
3495 wm8962->disable_nb[3].notifier_call = wm8962_regulator_event_3; in wm8962_probe()
3496 wm8962->disable_nb[4].notifier_call = wm8962_regulator_event_4; in wm8962_probe()
3497 wm8962->disable_nb[5].notifier_call = wm8962_regulator_event_5; in wm8962_probe()
3498 wm8962->disable_nb[6].notifier_call = wm8962_regulator_event_6; in wm8962_probe()
3499 wm8962->disable_nb[7].notifier_call = wm8962_regulator_event_7; in wm8962_probe()
3502 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) { in wm8962_probe()
3504 wm8962->supplies[i].consumer, in wm8962_probe()
3505 &wm8962->disable_nb[i]); in wm8962_probe()
3552 struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); in wm8962_remove() local
3554 cancel_delayed_work_sync(&wm8962->mic_work); in wm8962_remove()
3620 struct wm8962_priv *wm8962; in wm8962_i2c_probe() local
3624 wm8962 = devm_kzalloc(&i2c->dev, sizeof(*wm8962), GFP_KERNEL); in wm8962_i2c_probe()
3625 if (wm8962 == NULL) in wm8962_i2c_probe()
3628 mutex_init(&wm8962->dsp2_ena_lock); in wm8962_i2c_probe()
3630 i2c_set_clientdata(i2c, wm8962); in wm8962_i2c_probe()
3632 INIT_DELAYED_WORK(&wm8962->mic_work, wm8962_mic_work); in wm8962_i2c_probe()
3633 init_completion(&wm8962->fll_lock); in wm8962_i2c_probe()
3634 wm8962->irq = i2c->irq; in wm8962_i2c_probe()
3638 memcpy(&wm8962->pdata, pdata, sizeof(struct wm8962_pdata)); in wm8962_i2c_probe()
3640 ret = wm8962_set_pdata_from_of(i2c, &wm8962->pdata); in wm8962_i2c_probe()
3645 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) in wm8962_i2c_probe()
3646 wm8962->supplies[i].supply = wm8962_supply_names[i]; in wm8962_i2c_probe()
3648 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies), in wm8962_i2c_probe()
3649 wm8962->supplies); in wm8962_i2c_probe()
3655 ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), in wm8962_i2c_probe()
3656 wm8962->supplies); in wm8962_i2c_probe()
3662 wm8962->regmap = devm_regmap_init_i2c(i2c, &wm8962_regmap); in wm8962_i2c_probe()
3663 if (IS_ERR(wm8962->regmap)) { in wm8962_i2c_probe()
3664 ret = PTR_ERR(wm8962->regmap); in wm8962_i2c_probe()
3674 regcache_cache_bypass(wm8962->regmap, true); in wm8962_i2c_probe()
3676 ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, &reg); in wm8962_i2c_probe()
3688 ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, &reg); in wm8962_i2c_probe()
3700 regcache_cache_bypass(wm8962->regmap, false); in wm8962_i2c_probe()
3702 ret = wm8962_reset(wm8962); in wm8962_i2c_probe()
3711 regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, in wm8962_i2c_probe()
3715 regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, in wm8962_i2c_probe()
3719 regmap_update_bits(wm8962->regmap, WM8962_PLL2, in wm8962_i2c_probe()
3724 for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++) in wm8962_i2c_probe()
3725 if (wm8962->pdata.gpio_init[i]) { in wm8962_i2c_probe()
3726 wm8962_set_gpio_mode(wm8962, i + 1); in wm8962_i2c_probe()
3727 regmap_write(wm8962->regmap, 0x200 + i, in wm8962_i2c_probe()
3728 wm8962->pdata.gpio_init[i] & 0xffff); in wm8962_i2c_probe()
3733 if (wm8962->pdata.spk_mono) in wm8962_i2c_probe()
3734 regmap_update_bits(wm8962->regmap, WM8962_CLASS_D_CONTROL_2, in wm8962_i2c_probe()
3739 if (wm8962->pdata.mic_cfg) in wm8962_i2c_probe()
3740 regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4, in wm8962_i2c_probe()
3745 wm8962->pdata.mic_cfg); in wm8962_i2c_probe()
3748 regmap_update_bits(wm8962->regmap, WM8962_LEFT_INPUT_VOLUME, in wm8962_i2c_probe()
3750 regmap_update_bits(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, in wm8962_i2c_probe()
3752 regmap_update_bits(wm8962->regmap, WM8962_LEFT_ADC_VOLUME, in wm8962_i2c_probe()
3754 regmap_update_bits(wm8962->regmap, WM8962_RIGHT_ADC_VOLUME, in wm8962_i2c_probe()
3756 regmap_update_bits(wm8962->regmap, WM8962_LEFT_DAC_VOLUME, in wm8962_i2c_probe()
3758 regmap_update_bits(wm8962->regmap, WM8962_RIGHT_DAC_VOLUME, in wm8962_i2c_probe()
3760 regmap_update_bits(wm8962->regmap, WM8962_SPKOUTL_VOLUME, in wm8962_i2c_probe()
3762 regmap_update_bits(wm8962->regmap, WM8962_SPKOUTR_VOLUME, in wm8962_i2c_probe()
3764 regmap_update_bits(wm8962->regmap, WM8962_HPOUTL_VOLUME, in wm8962_i2c_probe()
3766 regmap_update_bits(wm8962->regmap, WM8962_HPOUTR_VOLUME, in wm8962_i2c_probe()
3770 regmap_update_bits(wm8962->regmap, WM8962_EQ1, in wm8962_i2c_probe()
3774 regmap_update_bits(wm8962->regmap, WM8962_IRQ_DEBOUNCE, in wm8962_i2c_probe()
3779 if (wm8962->pdata.in4_dc_measure) { in wm8962_i2c_probe()
3780 ret = regmap_register_patch(wm8962->regmap, in wm8962_i2c_probe()
3789 if (wm8962->irq) { in wm8962_i2c_probe()
3790 if (wm8962->pdata.irq_active_low) { in wm8962_i2c_probe()
3798 regmap_update_bits(wm8962->regmap, WM8962_INTERRUPT_CONTROL, in wm8962_i2c_probe()
3801 ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL, in wm8962_i2c_probe()
3807 wm8962->irq, ret); in wm8962_i2c_probe()
3808 wm8962->irq = 0; in wm8962_i2c_probe()
3812 regmap_update_bits(wm8962->regmap, in wm8962_i2c_probe()
3828 regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4, in wm8962_i2c_probe()
3830 regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4, in wm8962_i2c_probe()
3833 regcache_cache_only(wm8962->regmap, true); in wm8962_i2c_probe()
3836 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); in wm8962_i2c_probe()
3843 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); in wm8962_i2c_probe()
3856 struct wm8962_priv *wm8962 = dev_get_drvdata(dev); in wm8962_runtime_resume() local
3859 ret = clk_prepare_enable(wm8962->pdata.mclk); in wm8962_runtime_resume()
3865 ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), in wm8962_runtime_resume()
3866 wm8962->supplies); in wm8962_runtime_resume()
3872 regcache_cache_only(wm8962->regmap, false); in wm8962_runtime_resume()
3874 wm8962_reset(wm8962); in wm8962_runtime_resume()
3876 regcache_mark_dirty(wm8962->regmap); in wm8962_runtime_resume()
3881 regmap_write_bits(wm8962->regmap, WM8962_CLOCKING2, in wm8962_runtime_resume()
3885 regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, in wm8962_runtime_resume()
3889 regmap_update_bits(wm8962->regmap, WM8962_PLL2, in wm8962_runtime_resume()
3893 regcache_sync(wm8962->regmap); in wm8962_runtime_resume()
3895 regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP, in wm8962_runtime_resume()
3900 regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1, in wm8962_runtime_resume()
3909 clk_disable_unprepare(wm8962->pdata.mclk); in wm8962_runtime_resume()
3915 struct wm8962_priv *wm8962 = dev_get_drvdata(dev); in wm8962_runtime_suspend() local
3917 regmap_update_bits(wm8962->regmap, WM8962_PWR_MGMT_1, in wm8962_runtime_suspend()
3920 regmap_update_bits(wm8962->regmap, WM8962_ANTI_POP, in wm8962_runtime_suspend()
3924 regcache_cache_only(wm8962->regmap, true); in wm8962_runtime_suspend()
3926 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), in wm8962_runtime_suspend()
3927 wm8962->supplies); in wm8962_runtime_suspend()
3929 clk_disable_unprepare(wm8962->pdata.mclk); in wm8962_runtime_suspend()