Lines Matching +full:sense +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright (C) 2022-2023 Cirrus Logic, Inc. and
21 #include <linux/mfd/cs42l43-regs.h>
33 #include <sound/soc-component.h>
34 #include <sound/soc-dapm.h>
35 #include <sound/soc-dai.h>
137 dev_err(priv->dev, "Error " #name " IRQ\n"); \
157 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(priv->component); in CS42L43_IRQ_ERROR()
161 priv->hp_ilimit_count--; in CS42L43_IRQ_ERROR()
163 if (priv->hp_ilimit_count) in CS42L43_IRQ_ERROR()
164 queue_delayed_work(system_wq, &priv->hp_ilimit_clear_work, in CS42L43_IRQ_ERROR()
174 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(priv->component); in cs42l43_hp_ilimit_work()
175 struct cs42l43 *cs42l43 = priv->core; in cs42l43_hp_ilimit_work()
179 if (priv->hp_ilimit_count < CS42L43_HP_ILIMIT_MAX_COUNT) { in cs42l43_hp_ilimit_work()
180 if (!priv->hp_ilimit_count) in cs42l43_hp_ilimit_work()
181 queue_delayed_work(system_wq, &priv->hp_ilimit_clear_work, in cs42l43_hp_ilimit_work()
184 priv->hp_ilimit_count++; in cs42l43_hp_ilimit_work()
189 dev_err(priv->dev, "Disabling headphone for %dmS, due to frequent current limit\n", in cs42l43_hp_ilimit_work()
192 priv->hp_ilimited = true; in cs42l43_hp_ilimit_work()
195 regmap_update_bits(cs42l43->regmap, CS42L43_BLOCK_EN8, in cs42l43_hp_ilimit_work()
204 if (priv->hp_ena && !priv->load_detect_running) { in cs42l43_hp_ilimit_work()
207 reinit_completion(&priv->hp_startup); in cs42l43_hp_ilimit_work()
209 regmap_update_bits(cs42l43->regmap, CS42L43_BLOCK_EN8, in cs42l43_hp_ilimit_work()
210 CS42L43_HP_EN_MASK, priv->hp_ena); in cs42l43_hp_ilimit_work()
212 time_left = wait_for_completion_timeout(&priv->hp_startup, in cs42l43_hp_ilimit_work()
215 dev_err(priv->dev, "ilimit HP restore timed out\n"); in cs42l43_hp_ilimit_work()
218 priv->hp_ilimited = false; in cs42l43_hp_ilimit_work()
227 dev_dbg(priv->dev, "headphone ilimit IRQ\n"); in cs42l43_hp_ilimit()
229 queue_work(system_long_wq, &priv->hp_ilimit_work); in cs42l43_hp_ilimit()
238 dev_dbg(priv->dev, #name " completed\n"); \
239 complete(&priv->name); \
256 struct snd_soc_component *component = priv->component; in CS42L43_IRQ_COMPLETE()
259 dev_dbg(priv->dev, "Microphone shutter changed\n"); in CS42L43_IRQ_COMPLETE()
264 for (i = 1; i < ARRAY_SIZE(priv->kctl); i++) { in CS42L43_IRQ_COMPLETE()
265 if (!priv->kctl[i]) in CS42L43_IRQ_COMPLETE()
268 snd_ctl_notify(component->card->snd_card, in CS42L43_IRQ_COMPLETE()
269 SNDRV_CTL_EVENT_MASK_VALUE, &priv->kctl[i]->id); in CS42L43_IRQ_COMPLETE()
278 struct snd_soc_component *component = priv->component; in cs42l43_spk_shutter()
280 dev_dbg(priv->dev, "Speaker shutter changed\n"); in cs42l43_spk_shutter()
285 if (!priv->kctl[0]) in cs42l43_spk_shutter()
288 snd_ctl_notify(component->card->snd_card, in cs42l43_spk_shutter()
289 SNDRV_CTL_EVENT_MASK_VALUE, &priv->kctl[0]->id); in cs42l43_spk_shutter()
308 struct snd_soc_component *component = dai->component; in cs42l43_startup()
310 struct cs42l43 *cs42l43 = priv->core; in cs42l43_startup()
311 int provider = !dai->id || !!regmap_test_bits(cs42l43->regmap, in cs42l43_startup()
316 priv->constraint.mask = CS42L43_PROVIDER_RATE_MASK; in cs42l43_startup()
318 priv->constraint.mask = CS42L43_CONSUMER_RATE_MASK; in cs42l43_startup()
320 return snd_pcm_hw_constraint_list(substream->runtime, 0, in cs42l43_startup()
322 &priv->constraint); in cs42l43_startup()
345 return -EINVAL; in cs42l43_convert_sample_rate()
353 struct cs42l43_codec *priv = snd_soc_component_get_drvdata(dai->component); in cs42l43_set_sample_rate()
354 struct cs42l43 *cs42l43 = priv->core; in cs42l43_set_sample_rate()
359 dev_err(priv->dev, "Failed to convert sample rate: %d\n", ret); in cs42l43_set_sample_rate()
364 regmap_update_bits(cs42l43->regmap, CS42L43_SAMPLE_RATE1, in cs42l43_set_sample_rate()
374 struct cs42l43_codec *priv = snd_soc_component_get_drvdata(dai->component); in cs42l43_asp_hw_params()
375 struct cs42l43 *cs42l43 = priv->core; in cs42l43_asp_hw_params()
376 int dsp_mode = !!regmap_test_bits(cs42l43->regmap, CS42L43_ASP_CTRL, in cs42l43_asp_hw_params()
378 int provider = !!regmap_test_bits(cs42l43->regmap, CS42L43_ASP_CLK_CONFIG2, in cs42l43_asp_hw_params()
388 if (priv->n_slots) { in cs42l43_asp_hw_params()
389 n_slots = priv->n_slots; in cs42l43_asp_hw_params()
390 slot_width = priv->slot_width; in cs42l43_asp_hw_params()
394 dev_dbg(priv->dev, "Forcing balanced channels on ASP\n"); in cs42l43_asp_hw_params()
408 dev_err(priv->dev, "Can't produce %dHz bclk\n", bclk_target); in cs42l43_asp_hw_params()
409 return -EINVAL; in cs42l43_asp_hw_params()
412 dev_dbg(priv->dev, "bclk %d/%d = %dHz, with %dx%d frame\n", in cs42l43_asp_hw_params()
415 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_CLK_CONFIG1, in cs42l43_asp_hw_params()
419 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_FSYNC_CTRL1, in cs42l43_asp_hw_params()
423 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_FSYNC_CTRL4, in cs42l43_asp_hw_params()
427 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in cs42l43_asp_hw_params()
429 slots = priv->tx_slots; in cs42l43_asp_hw_params()
432 slots = priv->rx_slots; in cs42l43_asp_hw_params()
444 dev_dbg(priv->dev, "Configure channel %d at slot %d (%d,%d)\n", in cs42l43_asp_hw_params()
447 regmap_update_bits(cs42l43->regmap, reg, in cs42l43_asp_hw_params()
451 ((data_width - 1) << CS42L43_ASP_CH_WIDTH_SHIFT) | in cs42l43_asp_hw_params()
461 struct snd_soc_component *component = dai->component; in cs42l43_asp_set_fmt()
464 struct cs42l43 *cs42l43 = priv->core; in cs42l43_asp_set_fmt()
465 int provider = regmap_test_bits(cs42l43->regmap, CS42L43_ASP_CLK_CONFIG2, in cs42l43_asp_set_fmt()
490 dev_err(priv->dev, "Unsupported DAI format 0x%x\n", in cs42l43_asp_set_fmt()
492 return -EINVAL; in cs42l43_asp_set_fmt()
506 dev_err(priv->dev, "Unsupported ASP mode 0x%x\n", in cs42l43_asp_set_fmt()
508 return -EINVAL; in cs42l43_asp_set_fmt()
527 dev_err(priv->dev, "Unsupported invert mode 0x%x\n", in cs42l43_asp_set_fmt()
529 return -EINVAL; in cs42l43_asp_set_fmt()
532 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_CTRL, in cs42l43_asp_set_fmt()
535 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_DATA_CTRL, in cs42l43_asp_set_fmt()
539 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_CLK_CONFIG2, in cs42l43_asp_set_fmt()
543 regmap_update_bits(cs42l43->regmap, CS42L43_ASP_FSYNC_CTRL3, in cs42l43_asp_set_fmt()
559 dev_warn(priv->dev, "Too many channels in TDM mask: %lx\n", in cs42l43_mask_to_slots()
572 struct snd_soc_component *component = dai->component; in cs42l43_asp_set_tdm_slot()
575 priv->n_slots = slots; in cs42l43_asp_set_tdm_slot()
576 priv->slot_width = slot_width; in cs42l43_asp_set_tdm_slot()
583 cs42l43_mask_to_slots(priv, tx_mask, priv->tx_slots, in cs42l43_asp_set_tdm_slot()
584 ARRAY_SIZE(priv->tx_slots)); in cs42l43_asp_set_tdm_slot()
585 cs42l43_mask_to_slots(priv, rx_mask, priv->rx_slots, in cs42l43_asp_set_tdm_slot()
586 ARRAY_SIZE(priv->rx_slots)); in cs42l43_asp_set_tdm_slot()
593 struct snd_soc_component *component = dai->component; in cs42l43_dai_probe()
604 static_assert(ARRAY_SIZE(controls) == ARRAY_SIZE(priv->kctl)); in cs42l43_dai_probe()
607 if (priv->kctl[i]) in cs42l43_dai_probe()
610 priv->kctl[i] = snd_soc_component_get_kcontrol(component, controls[i]); in cs42l43_dai_probe()
618 struct snd_soc_component *component = dai->component; in cs42l43_dai_remove()
622 for (i = 0; i < ARRAY_SIZE(priv->kctl); i++) in cs42l43_dai_remove()
623 priv->kctl[i] = NULL; in cs42l43_dai_remove()
665 .name = "cs42l43-asp",
684 .name = "cs42l43-dp1",
696 .name = "cs42l43-dp2",
708 .name = "cs42l43-dp3",
720 .name = "cs42l43-dp4",
732 .name = "cs42l43-dp5",
744 .name = "cs42l43-dp6",
756 .name = "cs42l43-dp7",
769 static const DECLARE_TLV_DB_SCALE(cs42l43_mixer_tlv, -3200, 100, 0);
804 static DECLARE_TLV_DB_SCALE(cs42l43_adc_tlv, -600, 600, 0);
805 static DECLARE_TLV_DB_SCALE(cs42l43_dec_tlv, -6400, 50, 0);
850 static DECLARE_TLV_DB_SCALE(cs42l43_speaker_tlv, -6400, 50, 0);
858 static DECLARE_TLV_DB_SCALE(cs42l43_headphone_tlv, -11450, 50, 1);
1019 memcpy(ucontrol->value.integer.value, priv->eq_coeffs, sizeof(priv->eq_coeffs)); in cs42l43_eq_get()
1033 memcpy(priv->eq_coeffs, ucontrol->value.integer.value, sizeof(priv->eq_coeffs)); in cs42l43_eq_put()
1042 struct cs42l43 *cs42l43 = priv->core; in cs42l43_spk_vu_sync()
1044 mutex_lock(&priv->spk_vu_lock); in cs42l43_spk_vu_sync()
1046 regmap_update_bits(cs42l43->regmap, CS42L43_INTP_VOLUME_CTRL1, in cs42l43_spk_vu_sync()
1048 regmap_update_bits(cs42l43->regmap, CS42L43_INTP_VOLUME_CTRL1, in cs42l43_spk_vu_sync()
1051 mutex_unlock(&priv->spk_vu_lock); in cs42l43_spk_vu_sync()
1056 struct cs42l43 *cs42l43 = priv->core; in cs42l43_shutter_get()
1060 ret = pm_runtime_resume_and_get(priv->dev); in cs42l43_shutter_get()
1062 dev_err(priv->dev, "Failed to resume for shutters: %d\n", ret); in cs42l43_shutter_get()
1067 * SHUTTER_CONTROL is a mix of volatile and non-volatile bits, so must in cs42l43_shutter_get()
1068 * be cached for the non-volatiles, so drop it from the cache here so in cs42l43_shutter_get()
1071 ret = regcache_drop_region(cs42l43->regmap, CS42L43_SHUTTER_CONTROL, in cs42l43_shutter_get()
1074 dev_err(priv->dev, "Failed to drop shutter from cache: %d\n", ret); in cs42l43_shutter_get()
1078 ret = regmap_read(cs42l43->regmap, CS42L43_SHUTTER_CONTROL, &val); in cs42l43_shutter_get()
1080 dev_err(priv->dev, "Failed to check shutter status: %d\n", ret); in cs42l43_shutter_get()
1086 dev_dbg(priv->dev, "%s shutter is %s\n", in cs42l43_shutter_get()
1091 pm_runtime_mark_last_busy(priv->dev); in cs42l43_shutter_get()
1092 pm_runtime_put_autosuspend(priv->dev); in cs42l43_shutter_get()
1108 ucontrol->value.integer.value[0] = ret; in cs42l43_decim_get()
1124 ucontrol->value.integer.value[0] = ret; in cs42l43_spk_get()
1275 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_eq_ev()
1277 struct cs42l43 *cs42l43 = priv->core; in cs42l43_eq_ev()
1283 regmap_update_bits(cs42l43->regmap, CS42L43_MUTE_EQ_IN0, in cs42l43_eq_ev()
1287 regmap_update_bits(cs42l43->regmap, CS42L43_COEFF_RD_WR0, in cs42l43_eq_ev()
1291 regmap_write(cs42l43->regmap, CS42L43_COEFF_DATA_IN0, in cs42l43_eq_ev()
1292 priv->eq_coeffs[i]); in cs42l43_eq_ev()
1294 regmap_update_bits(cs42l43->regmap, CS42L43_COEFF_RD_WR0, in cs42l43_eq_ev()
1299 ret = regmap_read_poll_timeout(cs42l43->regmap, CS42L43_INIT_DONE0, in cs42l43_eq_ev()
1303 dev_err(priv->dev, "Failed to start EQs: %d\n", ret); in cs42l43_eq_ev()
1305 regmap_update_bits(cs42l43->regmap, CS42L43_MUTE_EQ_IN0, in cs42l43_eq_ev()
1314 unsigned int freq; member
1328 unsigned int freq) in cs42l43_set_pll() argument
1330 struct cs42l43 *cs42l43 = priv->core; in cs42l43_set_pll()
1332 lockdep_assert_held(&cs42l43->pll_lock); in cs42l43_set_pll()
1334 if (priv->refclk_src == src && priv->refclk_freq == freq) in cs42l43_set_pll()
1337 if (regmap_test_bits(cs42l43->regmap, CS42L43_CTRL_REG, CS42L43_PLL_EN_MASK)) { in cs42l43_set_pll()
1338 dev_err(priv->dev, "PLL active, can't change configuration\n"); in cs42l43_set_pll()
1339 return -EBUSY; in cs42l43_set_pll()
1345 dev_dbg(priv->dev, "Source PLL from %s at %uHz\n", in cs42l43_set_pll()
1346 src ? "SoundWire" : "MCLK", freq); in cs42l43_set_pll()
1348 priv->refclk_src = src; in cs42l43_set_pll()
1349 priv->refclk_freq = freq; in cs42l43_set_pll()
1353 dev_err(priv->dev, "Invalid PLL source: 0x%x\n", src); in cs42l43_set_pll()
1354 return -EINVAL; in cs42l43_set_pll()
1364 struct cs42l43 *cs42l43 = priv->core; in cs42l43_enable_pll()
1367 unsigned int freq = priv->refclk_freq; in cs42l43_enable_pll() local
1370 lockdep_assert_held(&cs42l43->pll_lock); in cs42l43_enable_pll()
1372 if (priv->refclk_src == CS42L43_SYSCLK_SDW) { in cs42l43_enable_pll()
1373 if (!freq) in cs42l43_enable_pll()
1374 freq = cs42l43->sdw_freq; in cs42l43_enable_pll()
1375 else if (!cs42l43->sdw_freq) in cs42l43_enable_pll()
1376 cs42l43->sdw_freq = freq; in cs42l43_enable_pll()
1379 dev_dbg(priv->dev, "Enabling PLL at %uHz\n", freq); in cs42l43_enable_pll()
1381 div = fls(freq) - in cs42l43_enable_pll()
1382 fls(cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq); in cs42l43_enable_pll()
1383 freq >>= div; in cs42l43_enable_pll()
1389 if (freq == cs42l43_pll_configs[i].freq) { in cs42l43_enable_pll()
1397 dev_err(priv->dev, "No suitable PLL config: 0x%x, %uHz\n", div, freq); in cs42l43_enable_pll()
1398 return -EINVAL; in cs42l43_enable_pll()
1401 regmap_update_bits(cs42l43->regmap, CS42L43_PLL_CONTROL, in cs42l43_enable_pll()
1404 priv->refclk_src << CS42L43_PLL_REFCLK_SRC_SHIFT); in cs42l43_enable_pll()
1405 regmap_write(cs42l43->regmap, CS42L43_FDIV_FRAC, config->div); in cs42l43_enable_pll()
1406 regmap_update_bits(cs42l43->regmap, CS42L43_CTRL_REG, in cs42l43_enable_pll()
1409 config->mode << CS42L43_PLL_MODE_BYPASS_1029_SHIFT); in cs42l43_enable_pll()
1410 regmap_update_bits(cs42l43->regmap, CS42L43_CAL_RATIO, in cs42l43_enable_pll()
1411 CS42L43_PLL_CAL_RATIO_MASK, config->cal); in cs42l43_enable_pll()
1412 regmap_update_bits(cs42l43->regmap, CS42L43_PLL_CONTROL, in cs42l43_enable_pll()
1415 reinit_completion(&priv->pll_ready); in cs42l43_enable_pll()
1417 regmap_update_bits(cs42l43->regmap, CS42L43_CTRL_REG, in cs42l43_enable_pll()
1420 time_left = wait_for_completion_timeout(&priv->pll_ready, in cs42l43_enable_pll()
1423 regmap_update_bits(cs42l43->regmap, CS42L43_CTRL_REG, in cs42l43_enable_pll()
1425 regmap_update_bits(cs42l43->regmap, CS42L43_PLL_CONTROL, in cs42l43_enable_pll()
1428 dev_err(priv->dev, "Timeout out waiting for PLL\n"); in cs42l43_enable_pll()
1429 return -ETIMEDOUT; in cs42l43_enable_pll()
1432 if (priv->refclk_src == CS42L43_SYSCLK_SDW) in cs42l43_enable_pll()
1433 cs42l43->sdw_pll_active = true; in cs42l43_enable_pll()
1435 dev_dbg(priv->dev, "PLL locked in %ums\n", 200 - jiffies_to_msecs(time_left)); in cs42l43_enable_pll()
1442 regmap_multi_reg_write(cs42l43->regmap, enable_seq, ARRAY_SIZE(enable_seq)); in cs42l43_enable_pll()
1453 struct cs42l43 *cs42l43 = priv->core; in cs42l43_disable_pll()
1455 dev_dbg(priv->dev, "Disabling PLL\n"); in cs42l43_disable_pll()
1457 lockdep_assert_held(&cs42l43->pll_lock); in cs42l43_disable_pll()
1459 regmap_multi_reg_write(cs42l43->regmap, disable_seq, ARRAY_SIZE(disable_seq)); in cs42l43_disable_pll()
1460 regmap_update_bits(cs42l43->regmap, CS42L43_CTRL_REG, CS42L43_PLL_EN_MASK, 0); in cs42l43_disable_pll()
1461 regmap_update_bits(cs42l43->regmap, CS42L43_PLL_CONTROL, in cs42l43_disable_pll()
1464 cs42l43->sdw_pll_active = false; in cs42l43_disable_pll()
1472 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_pll_ev()
1474 struct cs42l43 *cs42l43 = priv->core; in cs42l43_pll_ev()
1477 mutex_lock(&cs42l43->pll_lock); in cs42l43_pll_ev()
1481 if (priv->refclk_src == CS42L43_SYSCLK_MCLK) { in cs42l43_pll_ev()
1482 ret = clk_prepare_enable(priv->mclk); in cs42l43_pll_ev()
1484 dev_err(priv->dev, "Failed to enable MCLK: %d\n", ret); in cs42l43_pll_ev()
1494 if (priv->refclk_src == CS42L43_SYSCLK_MCLK) in cs42l43_pll_ev()
1495 clk_disable_unprepare(priv->mclk); in cs42l43_pll_ev()
1502 mutex_unlock(&cs42l43->pll_lock); in cs42l43_pll_ev()
1530 return -ETIMEDOUT; in cs42l43_dapm_wait_completion()
1538 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_spkr_ev()
1541 return cs42l43_dapm_wait_completion(&priv->spkr_startup, in cs42l43_spkr_ev()
1542 &priv->spkr_shutdown, event, in cs42l43_spkr_ev()
1549 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_spkl_ev()
1552 return cs42l43_dapm_wait_completion(&priv->spkl_startup, in cs42l43_spkl_ev()
1553 &priv->spkl_shutdown, event, in cs42l43_spkl_ev()
1560 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_hp_ev()
1562 struct cs42l43 *cs42l43 = priv->core; in cs42l43_hp_ev()
1563 unsigned int mask = 1 << w->shift; in cs42l43_hp_ev()
1572 priv->hp_ena &= ~mask; in cs42l43_hp_ev()
1573 priv->hp_ena |= val; in cs42l43_hp_ev()
1575 ret = cs42l43_dapm_wait_completion(&priv->hp_startup, in cs42l43_hp_ev()
1576 &priv->hp_shutdown, event, in cs42l43_hp_ev()
1581 if (!priv->load_detect_running && !priv->hp_ilimited) in cs42l43_hp_ev()
1582 regmap_update_bits(cs42l43->regmap, CS42L43_BLOCK_EN8, in cs42l43_hp_ev()
1587 if (priv->load_detect_running || priv->hp_ilimited) in cs42l43_hp_ev()
1590 ret = cs42l43_dapm_wait_completion(&priv->hp_startup, in cs42l43_hp_ev()
1591 &priv->hp_shutdown, event, in cs42l43_hp_ev()
1606 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_mic_ev()
1608 struct cs42l43 *cs42l43 = priv->core; in cs42l43_mic_ev()
1613 switch (w->shift) { in cs42l43_mic_ev()
1619 val = &priv->decim_cache[0]; in cs42l43_mic_ev()
1626 val = &priv->decim_cache[1]; in cs42l43_mic_ev()
1632 val = &priv->decim_cache[2]; in cs42l43_mic_ev()
1638 val = &priv->decim_cache[3]; in cs42l43_mic_ev()
1641 dev_err(priv->dev, "Invalid microphone shift: %d\n", w->shift); in cs42l43_mic_ev()
1642 return -EINVAL; in cs42l43_mic_ev()
1647 ret = regmap_read(cs42l43->regmap, reg, val); in cs42l43_mic_ev()
1649 dev_err(priv->dev, in cs42l43_mic_ev()
1655 regmap_update_bits(cs42l43->regmap, reg, mute | ramp, mute); in cs42l43_mic_ev()
1658 regmap_update_bits(cs42l43->regmap, reg, mute | ramp, *val); in cs42l43_mic_ev()
1670 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l43_adc_ev()
1672 struct cs42l43 *cs42l43 = priv->core; in cs42l43_adc_ev()
1673 unsigned int mask = 1 << w->shift; in cs42l43_adc_ev()
1686 priv->adc_ena &= ~mask; in cs42l43_adc_ev()
1687 priv->adc_ena |= val; in cs42l43_adc_ev()
1689 if (!priv->load_detect_running) in cs42l43_adc_ev()
1690 regmap_update_bits(cs42l43->regmap, CS42L43_BLOCK_EN3, in cs42l43_adc_ev()
1798 SND_SOC_DAPM_REGULATOR_SUPPLY("vdd-amp", 0, 0),
2034 { "AMP1", NULL, "vdd-amp" },
2035 { "AMP2", NULL, "vdd-amp" },
2123 int src, unsigned int freq, int dir) in cs42l43_set_sysclk() argument
2126 struct cs42l43 *cs42l43 = priv->core; in cs42l43_set_sysclk()
2129 mutex_lock(&cs42l43->pll_lock); in cs42l43_set_sysclk()
2130 ret = cs42l43_set_pll(priv, src, freq); in cs42l43_set_sysclk()
2131 mutex_unlock(&cs42l43->pll_lock); in cs42l43_set_sysclk()
2139 struct cs42l43 *cs42l43 = priv->core; in cs42l43_component_probe()
2141 snd_soc_component_init_regmap(component, cs42l43->regmap); in cs42l43_component_probe()
2143 cs42l43_mask_to_slots(priv, CS42L43_DEFAULT_SLOTS, priv->tx_slots, in cs42l43_component_probe()
2144 ARRAY_SIZE(priv->tx_slots)); in cs42l43_component_probe()
2145 cs42l43_mask_to_slots(priv, CS42L43_DEFAULT_SLOTS, priv->rx_slots, in cs42l43_component_probe()
2146 ARRAY_SIZE(priv->rx_slots)); in cs42l43_component_probe()
2148 priv->component = component; in cs42l43_component_probe()
2149 priv->constraint = cs42l43_constraint; in cs42l43_component_probe()
2158 cs42l43_set_jack(priv->component, NULL, NULL); in cs42l43_component_remove()
2160 cancel_delayed_work_sync(&priv->bias_sense_timeout); in cs42l43_component_remove()
2161 cancel_delayed_work_sync(&priv->tip_sense_work); in cs42l43_component_remove()
2162 cancel_delayed_work_sync(&priv->button_press_work); in cs42l43_component_remove()
2163 cancel_work_sync(&priv->button_release_work); in cs42l43_component_remove()
2165 cancel_work_sync(&priv->hp_ilimit_work); in cs42l43_component_remove()
2166 cancel_delayed_work_sync(&priv->hp_ilimit_clear_work); in cs42l43_component_remove()
2168 priv->component = NULL; in cs42l43_component_remove()
2172 .name = "cs42l43-codec",
2201 { CS42L43_TIPSENSE_UNPLUG_PDET, "tip sense unplug", cs42l43_tip_sense },
2202 { CS42L43_TIPSENSE_PLUG_PDET, "tip sense plug", cs42l43_tip_sense },
2233 return dev_err_probe(priv->dev, ret, "Failed to map IRQ %s\n", name); in cs42l43_request_irq()
2235 dev_dbg(priv->dev, "Request IRQ %d for %s\n", ret, name); in cs42l43_request_irq()
2237 ret = devm_request_threaded_irq(priv->dev, ret, NULL, handler, in cs42l43_request_irq()
2240 return dev_err_probe(priv->dev, ret, "Failed to request IRQ %s\n", name); in cs42l43_request_irq()
2256 dev_warn(priv->dev, "Manual shutters, notifications not available\n"); in cs42l43_shutter_irq()
2283 struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent); in cs42l43_codec_probe()
2289 dom = irq_find_matching_fwnode(dev_fwnode(cs42l43->dev), DOMAIN_BUS_ANY); in cs42l43_codec_probe()
2291 return -EPROBE_DEFER; in cs42l43_codec_probe()
2293 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in cs42l43_codec_probe()
2295 return -ENOMEM; in cs42l43_codec_probe()
2297 priv->dev = &pdev->dev; in cs42l43_codec_probe()
2298 priv->core = cs42l43; in cs42l43_codec_probe()
2302 mutex_init(&priv->jack_lock); in cs42l43_codec_probe()
2303 mutex_init(&priv->spk_vu_lock); in cs42l43_codec_probe()
2305 init_completion(&priv->hp_startup); in cs42l43_codec_probe()
2306 init_completion(&priv->hp_shutdown); in cs42l43_codec_probe()
2307 init_completion(&priv->spkr_shutdown); in cs42l43_codec_probe()
2308 init_completion(&priv->spkl_shutdown); in cs42l43_codec_probe()
2309 init_completion(&priv->spkr_startup); in cs42l43_codec_probe()
2310 init_completion(&priv->spkl_startup); in cs42l43_codec_probe()
2311 init_completion(&priv->pll_ready); in cs42l43_codec_probe()
2312 init_completion(&priv->type_detect); in cs42l43_codec_probe()
2313 init_completion(&priv->load_detect); in cs42l43_codec_probe()
2315 INIT_DELAYED_WORK(&priv->tip_sense_work, cs42l43_tip_sense_work); in cs42l43_codec_probe()
2316 INIT_DELAYED_WORK(&priv->bias_sense_timeout, cs42l43_bias_sense_timeout); in cs42l43_codec_probe()
2317 INIT_DELAYED_WORK(&priv->button_press_work, cs42l43_button_press_work); in cs42l43_codec_probe()
2318 INIT_DELAYED_WORK(&priv->hp_ilimit_clear_work, cs42l43_hp_ilimit_clear_work); in cs42l43_codec_probe()
2319 INIT_WORK(&priv->button_release_work, cs42l43_button_release_work); in cs42l43_codec_probe()
2320 INIT_WORK(&priv->hp_ilimit_work, cs42l43_hp_ilimit_work); in cs42l43_codec_probe()
2322 pm_runtime_set_autosuspend_delay(priv->dev, 100); in cs42l43_codec_probe()
2323 pm_runtime_use_autosuspend(priv->dev); in cs42l43_codec_probe()
2324 pm_runtime_set_active(priv->dev); in cs42l43_codec_probe()
2325 pm_runtime_get_noresume(priv->dev); in cs42l43_codec_probe()
2327 ret = devm_pm_runtime_enable(priv->dev); in cs42l43_codec_probe()
2339 ret = regmap_read(cs42l43->regmap, CS42L43_SHUTTER_CONTROL, &val); in cs42l43_codec_probe()
2341 dev_err(priv->dev, "Failed to check shutter source: %d\n", ret); in cs42l43_codec_probe()
2359 priv->mclk = clk_get_optional(cs42l43->dev, "mclk"); in cs42l43_codec_probe()
2360 if (IS_ERR(priv->mclk)) { in cs42l43_codec_probe()
2361 ret = PTR_ERR(priv->mclk); in cs42l43_codec_probe()
2362 dev_err_probe(priv->dev, ret, "Failed to get mclk\n"); in cs42l43_codec_probe()
2366 ret = devm_snd_soc_register_component(priv->dev, &cs42l43_component_drv, in cs42l43_codec_probe()
2369 dev_err_probe(priv->dev, ret, "Failed to register component\n"); in cs42l43_codec_probe()
2373 pm_runtime_mark_last_busy(priv->dev); in cs42l43_codec_probe()
2374 pm_runtime_put_autosuspend(priv->dev); in cs42l43_codec_probe()
2379 clk_put(priv->mclk); in cs42l43_codec_probe()
2381 pm_runtime_put_sync(priv->dev); in cs42l43_codec_probe()
2390 clk_put(priv->mclk); in cs42l43_codec_remove()
2397 dev_dbg(priv->dev, "Runtime resume\n"); in cs42l43_codec_runtime_resume()
2408 struct cs42l43 *cs42l43 = priv->core; in cs42l43_codec_suspend()
2410 disable_irq(cs42l43->irq); in cs42l43_codec_suspend()
2418 struct cs42l43 *cs42l43 = priv->core; in cs42l43_codec_suspend_noirq()
2420 enable_irq(cs42l43->irq); in cs42l43_codec_suspend_noirq()
2428 struct cs42l43 *cs42l43 = priv->core; in cs42l43_codec_resume()
2430 enable_irq(cs42l43->irq); in cs42l43_codec_resume()
2438 struct cs42l43 *cs42l43 = priv->core; in cs42l43_codec_resume_noirq()
2440 disable_irq(cs42l43->irq); in cs42l43_codec_resume_noirq()
2452 { "cs42l43-codec", },
2459 .name = "cs42l43-codec",