Lines Matching +full:asp +full:- +full:sdout +full:- +full:hiz +full:- +full:ctrl

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 // cs35l45.c - CS35L45 ALSA SoC audio driver
5 // Copyright 2019-2022 Cirrus Logic, Inc.
25 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l45_global_en_ev()
28 dev_dbg(cs35l45->dev, "%s event : %x\n", __func__, event); in cs35l45_global_en_ev()
32 regmap_write(cs35l45->regmap, CS35L45_GLOBAL_ENABLES, in cs35l45_global_en_ev()
40 regmap_write(cs35l45->regmap, CS35L45_GLOBAL_ENABLES, 0); in cs35l45_global_en_ev()
212 static const DECLARE_TLV_DB_SCALE(cs35l45_dig_pcm_vol_tlv, -10225, 25, true);
219 -409, 48,
220 (CS35L45_AMP_VOL_PCM_WIDTH - 1) - 1,
231 dev_err(cs35l45->dev, "Invalid freq: %u\n", freq); in cs35l45_set_pll()
232 return -EINVAL; in cs35l45_set_pll()
235 regmap_read(cs35l45->regmap, CS35L45_REFCLK_INPUT, &val); in cs35l45_set_pll()
240 regmap_set_bits(cs35l45->regmap, CS35L45_REFCLK_INPUT, CS35L45_PLL_OPEN_LOOP_MASK); in cs35l45_set_pll()
241 regmap_update_bits(cs35l45->regmap, CS35L45_REFCLK_INPUT, in cs35l45_set_pll()
244 regmap_clear_bits(cs35l45->regmap, CS35L45_REFCLK_INPUT, CS35L45_PLL_REFCLK_EN_MASK); in cs35l45_set_pll()
245 regmap_clear_bits(cs35l45->regmap, CS35L45_REFCLK_INPUT, CS35L45_PLL_OPEN_LOOP_MASK); in cs35l45_set_pll()
246 regmap_set_bits(cs35l45->regmap, CS35L45_REFCLK_INPUT, CS35L45_PLL_REFCLK_EN_MASK); in cs35l45_set_pll()
253 struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(codec_dai->component); in cs35l45_asp_set_fmt()
260 dev_err(cs35l45->dev, "Invalid DAI clocking\n"); in cs35l45_asp_set_fmt()
261 return -EINVAL; in cs35l45_asp_set_fmt()
272 dev_err(cs35l45->dev, "Invalid DAI format\n"); in cs35l45_asp_set_fmt()
273 return -EINVAL; in cs35l45_asp_set_fmt()
294 dev_warn(cs35l45->dev, "Invalid DAI clock polarity\n"); in cs35l45_asp_set_fmt()
295 return -EINVAL; in cs35l45_asp_set_fmt()
298 regmap_update_bits(cs35l45->regmap, CS35L45_ASP_CONTROL2, in cs35l45_asp_set_fmt()
313 struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(dai->component); in cs35l45_asp_hw_params()
331 dev_warn(cs35l45->dev, "Unsupported sample rate (%d)\n", in cs35l45_asp_hw_params()
333 return -EINVAL; in cs35l45_asp_hw_params()
336 regmap_update_bits(cs35l45->regmap, CS35L45_GLOBAL_SAMPLE_RATE, in cs35l45_asp_hw_params()
342 if (cs35l45->slot_width) in cs35l45_asp_hw_params()
343 asp_width = cs35l45->slot_width; in cs35l45_asp_hw_params()
347 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l45_asp_hw_params()
348 regmap_update_bits(cs35l45->regmap, CS35L45_ASP_CONTROL2, in cs35l45_asp_hw_params()
352 regmap_update_bits(cs35l45->regmap, CS35L45_ASP_DATA_CONTROL5, in cs35l45_asp_hw_params()
356 regmap_update_bits(cs35l45->regmap, CS35L45_ASP_CONTROL2, in cs35l45_asp_hw_params()
360 regmap_update_bits(cs35l45->regmap, CS35L45_ASP_DATA_CONTROL1, in cs35l45_asp_hw_params()
365 if (cs35l45->sysclk_set) in cs35l45_asp_hw_params()
369 regmap_read(cs35l45->regmap, CS35L45_ASP_CONTROL2, &asp_fmt); in cs35l45_asp_hw_params()
377 cs35l45->slot_count, slot_multiple); in cs35l45_asp_hw_params()
386 struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(dai->component); in cs35l45_asp_set_tdm_slot()
389 return -EINVAL; in cs35l45_asp_set_tdm_slot()
391 cs35l45->slot_width = slot_width; in cs35l45_asp_set_tdm_slot()
392 cs35l45->slot_count = slots; in cs35l45_asp_set_tdm_slot()
400 struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(dai->component); in cs35l45_asp_set_sysclk()
404 dev_err(cs35l45->dev, "Invalid clk_id %d\n", clk_id); in cs35l45_asp_set_sysclk()
405 return -EINVAL; in cs35l45_asp_set_sysclk()
408 cs35l45->sysclk_set = false; in cs35l45_asp_set_sysclk()
414 return -EINVAL; in cs35l45_asp_set_sysclk()
416 cs35l45->sysclk_set = true; in cs35l45_asp_set_sysclk()
423 struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(dai->component); in cs35l45_mute_stream()
429 regmap_read(cs35l45->regmap, CS35L45_GLOBAL_SAMPLE_RATE, &global_fs); in cs35l45_mute_stream()
443 regmap_read(cs35l45->regmap, CS35L45_AMP_PCM_HPF_TST, &val); in cs35l45_mute_stream()
454 regmap_multi_reg_write(cs35l45->regmap, hpf_override_seq, in cs35l45_mute_stream()
511 regcache_cache_only(cs35l45->regmap, true); in cs35l45_runtime_suspend()
513 dev_dbg(cs35l45->dev, "Runtime suspended\n"); in cs35l45_runtime_suspend()
523 dev_dbg(cs35l45->dev, "Runtime resume\n"); in cs35l45_runtime_resume()
525 regcache_cache_only(cs35l45->regmap, false); in cs35l45_runtime_resume()
526 ret = regcache_sync(cs35l45->regmap); in cs35l45_runtime_resume()
528 dev_warn(cs35l45->dev, "regcache_sync failed: %d\n", ret); in cs35l45_runtime_resume()
531 regmap_clear_bits(cs35l45->regmap, CS35L45_ERROR_RELEASE, CS35L45_GLOBAL_ERR_RLS_MASK); in cs35l45_runtime_resume()
532 regmap_set_bits(cs35l45->regmap, CS35L45_ERROR_RELEASE, CS35L45_GLOBAL_ERR_RLS_MASK); in cs35l45_runtime_resume()
533 regmap_clear_bits(cs35l45->regmap, CS35L45_ERROR_RELEASE, CS35L45_GLOBAL_ERR_RLS_MASK); in cs35l45_runtime_resume()
541 if (device_property_read_u32(cs35l45->dev, in cs35l45_apply_property_config()
542 "cirrus,asp-sdout-hiz-ctrl", &val) == 0) { in cs35l45_apply_property_config()
543 regmap_update_bits(cs35l45->regmap, CS35L45_ASP_CONTROL3, in cs35l45_apply_property_config()
553 struct device *dev = cs35l45->dev; in cs35l45_initialize()
558 ret = regmap_read_poll_timeout(cs35l45->regmap, CS35L45_IRQ1_EINT_4, sts, in cs35l45_initialize()
562 dev_err(cs35l45->dev, "Timeout waiting for OTP boot\n"); in cs35l45_initialize()
566 ret = regmap_bulk_read(cs35l45->regmap, CS35L45_DEVID, dev_id, ARRAY_SIZE(dev_id)); in cs35l45_initialize()
568 dev_err(cs35l45->dev, "Get Device ID failed: %d\n", ret); in cs35l45_initialize()
576 dev_err(cs35l45->dev, "Bad DEVID 0x%x\n", dev_id[0]); in cs35l45_initialize()
577 return -ENODEV; in cs35l45_initialize()
580 dev_info(cs35l45->dev, "Cirrus Logic CS35L45: REVID %02X OTPID %02X\n", in cs35l45_initialize()
583 regmap_write(cs35l45->regmap, CS35L45_IRQ1_EINT_4, in cs35l45_initialize()
596 pm_runtime_set_autosuspend_delay(cs35l45->dev, 3000); in cs35l45_initialize()
597 pm_runtime_use_autosuspend(cs35l45->dev); in cs35l45_initialize()
598 pm_runtime_set_active(cs35l45->dev); in cs35l45_initialize()
599 pm_runtime_enable(cs35l45->dev); in cs35l45_initialize()
606 struct device *dev = cs35l45->dev; in cs35l45_probe()
609 cs35l45->vdd_batt = devm_regulator_get(dev, "vdd-batt"); in cs35l45_probe()
610 if (IS_ERR(cs35l45->vdd_batt)) in cs35l45_probe()
611 return dev_err_probe(dev, PTR_ERR(cs35l45->vdd_batt), in cs35l45_probe()
612 "Failed to request vdd-batt\n"); in cs35l45_probe()
614 cs35l45->vdd_a = devm_regulator_get(dev, "vdd-a"); in cs35l45_probe()
615 if (IS_ERR(cs35l45->vdd_a)) in cs35l45_probe()
616 return dev_err_probe(dev, PTR_ERR(cs35l45->vdd_a), in cs35l45_probe()
617 "Failed to request vdd-a\n"); in cs35l45_probe()
620 ret = regulator_enable(cs35l45->vdd_batt); in cs35l45_probe()
622 return dev_err_probe(dev, ret, "Failed to enable vdd-batt\n"); in cs35l45_probe()
624 ret = regulator_enable(cs35l45->vdd_a); in cs35l45_probe()
626 return dev_err_probe(dev, ret, "Failed to enable vdd-a\n"); in cs35l45_probe()
629 cs35l45->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in cs35l45_probe()
630 if (IS_ERR(cs35l45->reset_gpio)) { in cs35l45_probe()
631 ret = PTR_ERR(cs35l45->reset_gpio); in cs35l45_probe()
632 cs35l45->reset_gpio = NULL; in cs35l45_probe()
633 if (ret == -EBUSY) { in cs35l45_probe()
641 if (cs35l45->reset_gpio) { in cs35l45_probe()
643 gpiod_set_value_cansleep(cs35l45->reset_gpio, 1); in cs35l45_probe()
661 gpiod_set_value_cansleep(cs35l45->reset_gpio, 0); in cs35l45_probe()
663 regulator_disable(cs35l45->vdd_a); in cs35l45_probe()
664 regulator_disable(cs35l45->vdd_batt); in cs35l45_probe()
672 pm_runtime_disable(cs35l45->dev); in cs35l45_remove()
674 gpiod_set_value_cansleep(cs35l45->reset_gpio, 0); in cs35l45_remove()
675 regulator_disable(cs35l45->vdd_a); in cs35l45_remove()
676 /* VDD_BATT must be the last to power-off */ in cs35l45_remove()
677 regulator_disable(cs35l45->vdd_batt); in cs35l45_remove()