Lines Matching +full:spkvdd +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm_hubs.c -- WM8993/4 common code
5 * Copyright 2009-12 Wolfson Microelectronics plc
27 const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv, -300, 300, 0);
30 static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0);
32 static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1);
33 static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0);
34 static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0);
35 static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1);
36 static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0);
41 static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0);
44 "SPKVDD/2",
72 dev_dbg(component->dev, "Waiting for DC servo...\n"); in wait_for_dc_servo()
74 if (hubs->dcs_done_irq) in wait_for_dc_servo()
82 if (hubs->dcs_done_irq) in wait_for_dc_servo()
83 wait_for_completion_timeout(&hubs->dcs_done, in wait_for_dc_servo()
89 dev_dbg(component->dev, "DC servo: %x\n", reg); in wait_for_dc_servo()
93 dev_err(component->dev, "Timed out waiting for DC Servo %x\n", in wait_for_dc_servo()
101 complete(&hubs->dcs_done); in wm_hubs_dcs_done()
115 dev_vdbg(component->dev, "Analogue paths connected: %x\n", in wm_hubs_dac_hp_direct()
119 dev_vdbg(component->dev, "HPL connected to mixer\n"); in wm_hubs_dac_hp_direct()
122 dev_vdbg(component->dev, "HPL connected to DAC\n"); in wm_hubs_dac_hp_direct()
128 dev_vdbg(component->dev, "Analogue paths connected: %x\n", in wm_hubs_dac_hp_direct()
132 dev_vdbg(component->dev, "HPR connected to mixer\n"); in wm_hubs_dac_hp_direct()
135 dev_vdbg(component->dev, "HPR connected to DAC\n"); in wm_hubs_dac_hp_direct()
161 list_for_each_entry(cache, &hubs->dcs_cache, list) { in wm_hubs_dcs_cache_get()
162 if (cache->left != left || cache->right != right) in wm_hubs_dcs_cache_get()
177 if (hubs->no_cache_dac_hp_direct) in wm_hubs_dcs_cache_set()
180 cache = devm_kzalloc(component->dev, sizeof(*cache), GFP_KERNEL); in wm_hubs_dcs_cache_set()
184 cache->left = snd_soc_component_read(component, WM8993_LEFT_OUTPUT_VOLUME); in wm_hubs_dcs_cache_set()
185 cache->left &= WM8993_HPOUT1L_VOL_MASK; in wm_hubs_dcs_cache_set()
187 cache->right = snd_soc_component_read(component, WM8993_RIGHT_OUTPUT_VOLUME); in wm_hubs_dcs_cache_set()
188 cache->right &= WM8993_HPOUT1R_VOL_MASK; in wm_hubs_dcs_cache_set()
190 cache->dcs_cfg = dcs_cfg; in wm_hubs_dcs_cache_set()
192 list_add_tail(&cache->list, &hubs->dcs_cache); in wm_hubs_dcs_cache_set()
202 switch (hubs->dcs_readback_mode) { in wm_hubs_read_dc_servo()
217 switch (hubs->dcs_readback_mode) { in wm_hubs_read_dc_servo()
233 ret = -1; in wm_hubs_read_dc_servo()
248 switch (hubs->dcs_readback_mode) { in enable_dc_servo()
261 dev_dbg(component->dev, "Using cached DCS offset %x for %d,%d\n", in enable_dc_servo()
262 cache->dcs_cfg, cache->left, cache->right); in enable_dc_servo()
263 snd_soc_component_write(component, dcs_reg, cache->dcs_cfg); in enable_dc_servo()
270 if (hubs->series_startup) { in enable_dc_servo()
287 dev_dbg(component->dev, "DCS input: %x %x\n", reg_l, reg_r); in enable_dc_servo()
290 if (hubs->dcs_codes_l || hubs->dcs_codes_r) { in enable_dc_servo()
291 dev_dbg(component->dev, in enable_dc_servo()
293 hubs->dcs_codes_l, hubs->dcs_codes_r); in enable_dc_servo()
297 dev_dbg(component->dev, "DCS right %d->%d\n", offset, in enable_dc_servo()
298 offset + hubs->dcs_codes_r); in enable_dc_servo()
299 offset += hubs->dcs_codes_r; in enable_dc_servo()
304 dev_dbg(component->dev, "DCS left %d->%d\n", offset, in enable_dc_servo()
305 offset + hubs->dcs_codes_l); in enable_dc_servo()
306 offset += hubs->dcs_codes_l; in enable_dc_servo()
309 dev_dbg(component->dev, "DCS result: %x\n", dcs_cfg); in enable_dc_servo()
341 if (hubs->dcs_codes_l || hubs->dcs_codes_r || hubs->no_series_update) in wm8993_put_dc_servo()
498 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in hp_supply_event()
503 switch (hubs->hp_startup_mode) { in hp_supply_event()
522 dev_err(component->dev, "Unknown HP startup mode %d\n", in hp_supply_event()
523 hubs->hp_startup_mode); in hp_supply_event()
540 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in hp_event()
592 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in earpiece_event()
617 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in lineout_event()
621 switch (w->shift) { in lineout_event()
623 flag = &hubs->lineout1n_ena; in lineout_event()
626 flag = &hubs->lineout1p_ena; in lineout_event()
629 flag = &hubs->lineout2n_ena; in lineout_event()
632 flag = &hubs->lineout2p_ena; in lineout_event()
636 return -EINVAL; in lineout_event()
647 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in micbias_event()
650 switch (w->shift) { in micbias_event()
652 if (hubs->micb1_delay) in micbias_event()
653 msleep(hubs->micb1_delay); in micbias_event()
656 if (hubs->micb2_delay) in micbias_event()
657 msleep(hubs->micb2_delay); in micbias_event()
660 return -EINVAL; in micbias_event()
674 if (hubs->check_class_w_digital && !hubs->check_class_w_digital(component)) in wm_hubs_update_class_w()
677 dev_vdbg(component->dev, "Class W %s\n", enable ? "enabled" : "disabled"); in wm_hubs_update_class_w()
883 SND_SOC_DAPM_SUPPLY("Headphone Supply", SND_SOC_NOPM, 0, 0, hp_supply_event,
1058 { "Headphone PGA", NULL, "Headphone Supply" },
1160 hubs->component = component; in wm_hubs_add_analogue_routes()
1162 INIT_LIST_HEAD(&hubs->dcs_cache); in wm_hubs_add_analogue_routes()
1163 init_completion(&hubs->dcs_done); in wm_hubs_add_analogue_routes()
1199 hubs->lineout1_se = !lineout1_diff; in wm_hubs_handle_analogue_pdata()
1200 hubs->lineout2_se = !lineout2_diff; in wm_hubs_handle_analogue_pdata()
1201 hubs->micb1_delay = micbias1_delay; in wm_hubs_handle_analogue_pdata()
1202 hubs->micb2_delay = micbias2_delay; in wm_hubs_handle_analogue_pdata()
1226 if (!hubs->micd_scthr) in wm_hubs_handle_analogue_pdata()
1246 if (hubs->lineout1_se) in wm_hubs_vmid_ena()
1249 if (hubs->lineout2_se) in wm_hubs_vmid_ena()
1275 if (hubs->lineout1_se) in wm_hubs_set_bias_level()
1278 if (hubs->lineout2_se) in wm_hubs_set_bias_level()
1281 if (hubs->lineout1_se && hubs->lineout1n_ena) in wm_hubs_set_bias_level()
1284 if (hubs->lineout1_se && hubs->lineout1p_ena) in wm_hubs_set_bias_level()
1287 if (hubs->lineout2_se && hubs->lineout2n_ena) in wm_hubs_set_bias_level()
1290 if (hubs->lineout2_se && hubs->lineout2p_ena) in wm_hubs_set_bias_level()