Lines Matching refs:cs35l41

188 	struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component);  in cs35l41_dsp_preload_ev()  local
193 if (cs35l41->dsp.cs_dsp.booted) in cs35l41_dsp_preload_ev()
198 if (cs35l41->dsp.preloaded) in cs35l41_dsp_preload_ev()
201 if (cs35l41->dsp.cs_dsp.running) { in cs35l41_dsp_preload_ev()
217 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); in cs35l41_dsp_audio_ev() local
223 if (!cs35l41->dsp.cs_dsp.running) in cs35l41_dsp_audio_ev()
226 ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status); in cs35l41_dsp_audio_ev()
228 dev_err(cs35l41->dev, in cs35l41_dsp_audio_ev()
238 dev_err(cs35l41->dev, "Firmware status is invalid: %u\n", in cs35l41_dsp_audio_ev()
243 return cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, in cs35l41_dsp_audio_ev()
246 return cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, in cs35l41_dsp_audio_ev()
360 static void cs35l41_boost_enable(struct cs35l41_private *cs35l41, unsigned int enable) in cs35l41_boost_enable() argument
362 switch (cs35l41->hw_cfg.bst_type) { in cs35l41_boost_enable()
366 regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, CS35L41_BST_EN_MASK, in cs35l41_boost_enable()
375 static void cs35l41_error_release(struct cs35l41_private *cs35l41, unsigned int irq_err_bit, in cs35l41_error_release() argument
378 regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS1, irq_err_bit); in cs35l41_error_release()
379 regmap_write(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN, 0); in cs35l41_error_release()
380 regmap_update_bits(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN, rel_err_bit, rel_err_bit); in cs35l41_error_release()
381 regmap_update_bits(cs35l41->regmap, CS35L41_PROTECT_REL_ERR_IGN, rel_err_bit, 0); in cs35l41_error_release()
386 struct cs35l41_private *cs35l41 = data; in cs35l41_irq() local
392 pm_runtime_get_sync(cs35l41->dev); in cs35l41_irq()
395 regmap_read(cs35l41->regmap, in cs35l41_irq()
398 regmap_read(cs35l41->regmap, in cs35l41_irq()
409 regmap_update_bits(cs35l41->regmap, CS35L41_IRQ1_MASK4, in cs35l41_irq()
419 dev_crit_ratelimited(cs35l41->dev, "Amp short error\n"); in cs35l41_irq()
420 cs35l41_error_release(cs35l41, CS35L41_AMP_SHORT_ERR, CS35L41_AMP_SHORT_ERR_RLS); in cs35l41_irq()
425 dev_crit_ratelimited(cs35l41->dev, "Over temperature warning\n"); in cs35l41_irq()
426 cs35l41_error_release(cs35l41, CS35L41_TEMP_WARN, CS35L41_TEMP_WARN_ERR_RLS); in cs35l41_irq()
431 dev_crit_ratelimited(cs35l41->dev, "Over temperature error\n"); in cs35l41_irq()
432 cs35l41_error_release(cs35l41, CS35L41_TEMP_ERR, CS35L41_TEMP_ERR_RLS); in cs35l41_irq()
437 dev_crit_ratelimited(cs35l41->dev, "VBST Over Voltage error\n"); in cs35l41_irq()
438 cs35l41_boost_enable(cs35l41, 0); in cs35l41_irq()
439 cs35l41_error_release(cs35l41, CS35L41_BST_OVP_ERR, CS35L41_BST_OVP_ERR_RLS); in cs35l41_irq()
440 cs35l41_boost_enable(cs35l41, 1); in cs35l41_irq()
445 dev_crit_ratelimited(cs35l41->dev, "DCM VBST Under Voltage Error\n"); in cs35l41_irq()
446 cs35l41_boost_enable(cs35l41, 0); in cs35l41_irq()
447 cs35l41_error_release(cs35l41, CS35L41_BST_DCM_UVP_ERR, CS35L41_BST_UVP_ERR_RLS); in cs35l41_irq()
448 cs35l41_boost_enable(cs35l41, 1); in cs35l41_irq()
453 dev_crit_ratelimited(cs35l41->dev, "LBST error: powering off!\n"); in cs35l41_irq()
454 cs35l41_boost_enable(cs35l41, 0); in cs35l41_irq()
455 cs35l41_error_release(cs35l41, CS35L41_BST_SHORT_ERR, CS35L41_BST_SHORT_ERR_RLS); in cs35l41_irq()
456 cs35l41_boost_enable(cs35l41, 1); in cs35l41_irq()
461 regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS3, CS35L41_PLL_LOCK); in cs35l41_irq()
462 complete(&cs35l41->pll_lock); in cs35l41_irq()
467 pm_runtime_mark_last_busy(cs35l41->dev); in cs35l41_irq()
468 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_irq()
493 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); in cs35l41_main_amp_event() local
498 regmap_multi_reg_write_bypassed(cs35l41->regmap, in cs35l41_main_amp_event()
502 ret = cs35l41_global_enable(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type, in cs35l41_main_amp_event()
503 1, &cs35l41->pll_lock, cs35l41->dsp.cs_dsp.running); in cs35l41_main_amp_event()
506 ret = cs35l41_global_enable(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type, in cs35l41_main_amp_event()
507 0, &cs35l41->pll_lock, cs35l41->dsp.cs_dsp.running); in cs35l41_main_amp_event()
509 regmap_multi_reg_write_bypassed(cs35l41->regmap, in cs35l41_main_amp_event()
514 dev_err(cs35l41->dev, "Invalid event = 0x%x\n", event); in cs35l41_main_amp_event()
659 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); in cs35l41_set_channel_map() local
661 return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_n, tx_slot, rx_n, rx_slot); in cs35l41_set_channel_map()
666 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); in cs35l41_set_dai_fmt() local
676 dev_warn(cs35l41->dev, "Mixed provider/consumer mode unsupported\n"); in cs35l41_set_dai_fmt()
687 dev_warn(cs35l41->dev, "Invalid or unsupported DAI format\n"); in cs35l41_set_dai_fmt()
704 dev_warn(cs35l41->dev, "Invalid DAI clock INV\n"); in cs35l41_set_dai_fmt()
708 return regmap_update_bits(cs35l41->regmap, CS35L41_SP_FORMAT, in cs35l41_set_dai_fmt()
739 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); in cs35l41_pcm_hw_params() local
750 dev_err(cs35l41->dev, "Unsupported rate: %u\n", rate); in cs35l41_pcm_hw_params()
757 regmap_update_bits(cs35l41->regmap, CS35L41_GLOBAL_CLK_CTRL, in cs35l41_pcm_hw_params()
762 regmap_update_bits(cs35l41->regmap, CS35L41_SP_FORMAT, in cs35l41_pcm_hw_params()
765 regmap_update_bits(cs35l41->regmap, CS35L41_SP_RX_WL, in cs35l41_pcm_hw_params()
769 regmap_update_bits(cs35l41->regmap, CS35L41_SP_FORMAT, in cs35l41_pcm_hw_params()
772 regmap_update_bits(cs35l41->regmap, CS35L41_SP_TX_WL, in cs35l41_pcm_hw_params()
805 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); in cs35l41_pcm_startup() local
807 reinit_completion(&cs35l41->pll_lock); in cs35l41_pcm_startup()
820 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); in cs35l41_component_set_sysclk() local
834 dev_err(cs35l41->dev, "Invalid CLK Config\n"); in cs35l41_component_set_sysclk()
841 dev_err(cs35l41->dev, "Invalid CLK Config: %d, freq: %u\n", in cs35l41_component_set_sysclk()
846 regmap_update_bits(cs35l41->regmap, CS35L41_PLL_CLK_CTRL, in cs35l41_component_set_sysclk()
849 regmap_update_bits(cs35l41->regmap, CS35L41_PLL_CLK_CTRL, in cs35l41_component_set_sysclk()
852 regmap_update_bits(cs35l41->regmap, CS35L41_PLL_CLK_CTRL, in cs35l41_component_set_sysclk()
855 regmap_update_bits(cs35l41->regmap, CS35L41_PLL_CLK_CTRL, in cs35l41_component_set_sysclk()
857 regmap_update_bits(cs35l41->regmap, CS35L41_PLL_CLK_CTRL, in cs35l41_component_set_sysclk()
860 regmap_update_bits(cs35l41->regmap, CS35L41_PLL_CLK_CTRL, in cs35l41_component_set_sysclk()
870 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); in cs35l41_dai_set_sysclk() local
878 dev_err(cs35l41->dev, "Invalid CLK Config freq: %u\n", freq); in cs35l41_dai_set_sysclk()
882 dev_dbg(cs35l41->dev, "Set DAI sysclk %d\n", freq); in cs35l41_dai_set_sysclk()
896 regmap_write(cs35l41->regmap, CS35L41_TST_FS_MON0, val); in cs35l41_dai_set_sysclk()
901 static int cs35l41_set_pdata(struct cs35l41_private *cs35l41) in cs35l41_set_pdata() argument
903 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_set_pdata()
913 ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, hw_cfg); in cs35l41_set_pdata()
919 regmap_update_bits(cs35l41->regmap, CS35L41_SP_HIZ_CTRL, CS35L41_ASP_DOUT_HIZ_MASK, in cs35l41_set_pdata()
935 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); in cs35l41_component_probe() local
939 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) { in cs35l41_component_probe()
951 return wm_adsp2_component_probe(&cs35l41->dsp, component); in cs35l41_component_probe()
956 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); in cs35l41_component_remove() local
958 wm_adsp2_component_remove(&cs35l41->dsp, component); in cs35l41_component_remove()
1079 static int cs35l41_dsp_init(struct cs35l41_private *cs35l41) in cs35l41_dsp_init() argument
1084 dsp = &cs35l41->dsp; in cs35l41_dsp_init()
1089 cs35l41_configure_cs_dsp(cs35l41->dev, cs35l41->regmap, &dsp->cs_dsp); in cs35l41_dsp_init()
1091 ret = cs35l41_write_fs_errata(cs35l41->dev, cs35l41->regmap); in cs35l41_dsp_init()
1097 dev_err(cs35l41->dev, "wm_halo_init failed: %d\n", ret); in cs35l41_dsp_init()
1101 ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX5_SRC, in cs35l41_dsp_init()
1104 dev_err(cs35l41->dev, "Write INPUT_SRC_VPMON failed: %d\n", ret); in cs35l41_dsp_init()
1107 ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX6_SRC, in cs35l41_dsp_init()
1110 dev_err(cs35l41->dev, "Write INPUT_SRC_CLASSH failed: %d\n", ret); in cs35l41_dsp_init()
1113 ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX7_SRC, in cs35l41_dsp_init()
1116 dev_err(cs35l41->dev, "Write INPUT_SRC_TEMPMON failed: %d\n", ret); in cs35l41_dsp_init()
1119 ret = regmap_write(cs35l41->regmap, CS35L41_DSP1_RX8_SRC, in cs35l41_dsp_init()
1122 dev_err(cs35l41->dev, "Write INPUT_SRC_RSVD failed: %d\n", ret); in cs35l41_dsp_init()
1134 static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41) in cs35l41_acpi_get_name() argument
1136 acpi_handle handle = ACPI_HANDLE(cs35l41->dev); in cs35l41_acpi_get_name()
1152 cs35l41->dsp.system_name = sub; in cs35l41_acpi_get_name()
1153 dev_dbg(cs35l41->dev, "Subsystem ID: %s\n", cs35l41->dsp.system_name); in cs35l41_acpi_get_name()
1158 int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg) in cs35l41_probe() argument
1165 cs35l41->hw_cfg = *hw_cfg; in cs35l41_probe()
1167 ret = cs35l41_handle_pdata(cs35l41->dev, &cs35l41->hw_cfg); in cs35l41_probe()
1173 cs35l41->supplies[i].supply = cs35l41_supplies[i]; in cs35l41_probe()
1175 ret = devm_regulator_bulk_get(cs35l41->dev, CS35L41_NUM_SUPPLIES, in cs35l41_probe()
1176 cs35l41->supplies); in cs35l41_probe()
1178 dev_err(cs35l41->dev, "Failed to request core supplies: %d\n", ret); in cs35l41_probe()
1182 ret = regulator_bulk_enable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); in cs35l41_probe()
1184 dev_err(cs35l41->dev, "Failed to enable core supplies: %d\n", ret); in cs35l41_probe()
1189 cs35l41->reset_gpio = devm_gpiod_get_optional(cs35l41->dev, "reset", in cs35l41_probe()
1191 if (IS_ERR(cs35l41->reset_gpio)) { in cs35l41_probe()
1192 ret = PTR_ERR(cs35l41->reset_gpio); in cs35l41_probe()
1193 cs35l41->reset_gpio = NULL; in cs35l41_probe()
1195 dev_info(cs35l41->dev, in cs35l41_probe()
1198 dev_err(cs35l41->dev, in cs35l41_probe()
1203 if (cs35l41->reset_gpio) { in cs35l41_probe()
1206 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_probe()
1211 ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, in cs35l41_probe()
1215 dev_err(cs35l41->dev, in cs35l41_probe()
1220 regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status); in cs35l41_probe()
1222 dev_err(cs35l41->dev, "OTP Boot error\n"); in cs35l41_probe()
1227 ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, &regid); in cs35l41_probe()
1229 dev_err(cs35l41->dev, "Get Device ID failed: %d\n", ret); in cs35l41_probe()
1233 ret = regmap_read(cs35l41->regmap, CS35L41_REVID, &reg_revid); in cs35l41_probe()
1235 dev_err(cs35l41->dev, "Get Revision ID failed: %d\n", ret); in cs35l41_probe()
1246 dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", in cs35l41_probe()
1252 cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_probe()
1254 ret = cs35l41_register_errata_patch(cs35l41->dev, cs35l41->regmap, reg_revid); in cs35l41_probe()
1258 ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); in cs35l41_probe()
1260 dev_err(cs35l41->dev, "OTP Unpack failed: %d\n", ret); in cs35l41_probe()
1264 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_probe()
1266 irq_pol = cs35l41_gpio_config(cs35l41->regmap, &cs35l41->hw_cfg); in cs35l41_probe()
1269 regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, in cs35l41_probe()
1271 if (cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_PASS || in cs35l41_probe()
1272 cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_ACTV) in cs35l41_probe()
1273 regmap_update_bits(cs35l41->regmap, CS35L41_IRQ1_MASK3, CS35L41_INT3_PLL_LOCK_MASK, in cs35l41_probe()
1276 ret = devm_request_threaded_irq(cs35l41->dev, cs35l41->irq, NULL, cs35l41_irq, in cs35l41_probe()
1278 "cs35l41", cs35l41); in cs35l41_probe()
1280 dev_err(cs35l41->dev, "Failed to request IRQ: %d\n", ret); in cs35l41_probe()
1284 ret = cs35l41_set_pdata(cs35l41); in cs35l41_probe()
1286 dev_err(cs35l41->dev, "Set pdata failed: %d\n", ret); in cs35l41_probe()
1290 ret = cs35l41_acpi_get_name(cs35l41); in cs35l41_probe()
1294 ret = cs35l41_dsp_init(cs35l41); in cs35l41_probe()
1298 init_completion(&cs35l41->pll_lock); in cs35l41_probe()
1300 pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); in cs35l41_probe()
1301 pm_runtime_use_autosuspend(cs35l41->dev); in cs35l41_probe()
1302 pm_runtime_mark_last_busy(cs35l41->dev); in cs35l41_probe()
1303 pm_runtime_set_active(cs35l41->dev); in cs35l41_probe()
1304 pm_runtime_get_noresume(cs35l41->dev); in cs35l41_probe()
1305 pm_runtime_enable(cs35l41->dev); in cs35l41_probe()
1307 ret = devm_snd_soc_register_component(cs35l41->dev, in cs35l41_probe()
1311 dev_err(cs35l41->dev, "Register codec failed: %d\n", ret); in cs35l41_probe()
1315 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_probe()
1317 dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", in cs35l41_probe()
1323 pm_runtime_disable(cs35l41->dev); in cs35l41_probe()
1324 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_probe()
1326 wm_adsp2_remove(&cs35l41->dsp); in cs35l41_probe()
1328 cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); in cs35l41_probe()
1329 regulator_bulk_disable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); in cs35l41_probe()
1330 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_probe()
1336 void cs35l41_remove(struct cs35l41_private *cs35l41) in cs35l41_remove() argument
1338 pm_runtime_get_sync(cs35l41->dev); in cs35l41_remove()
1339 pm_runtime_disable(cs35l41->dev); in cs35l41_remove()
1341 regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, 0xFFFFFFFF); in cs35l41_remove()
1342 if (cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_PASS || in cs35l41_remove()
1343 cs35l41->hw_cfg.bst_type == CS35L41_SHD_BOOST_ACTV) in cs35l41_remove()
1344 regmap_update_bits(cs35l41->regmap, CS35L41_IRQ1_MASK3, CS35L41_INT3_PLL_LOCK_MASK, in cs35l41_remove()
1346 kfree(cs35l41->dsp.system_name); in cs35l41_remove()
1347 wm_adsp2_remove(&cs35l41->dsp); in cs35l41_remove()
1348 cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); in cs35l41_remove()
1350 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_remove()
1352 regulator_bulk_disable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); in cs35l41_remove()
1353 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_remove()
1359 struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); in cs35l41_runtime_suspend() local
1361 dev_dbg(cs35l41->dev, "Runtime suspend\n"); in cs35l41_runtime_suspend()
1363 if (!cs35l41->dsp.preloaded || !cs35l41->dsp.cs_dsp.running) in cs35l41_runtime_suspend()
1366 cs35l41_enter_hibernate(dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
1368 regcache_cache_only(cs35l41->regmap, true); in cs35l41_runtime_suspend()
1369 regcache_mark_dirty(cs35l41->regmap); in cs35l41_runtime_suspend()
1376 struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); in cs35l41_runtime_resume() local
1379 dev_dbg(cs35l41->dev, "Runtime resume\n"); in cs35l41_runtime_resume()
1381 if (!cs35l41->dsp.preloaded || !cs35l41->dsp.cs_dsp.running) in cs35l41_runtime_resume()
1384 regcache_cache_only(cs35l41->regmap, false); in cs35l41_runtime_resume()
1386 ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1391 cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1392 ret = regcache_sync(cs35l41->regmap); in cs35l41_runtime_resume()
1393 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1395 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); in cs35l41_runtime_resume()
1398 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); in cs35l41_runtime_resume()
1405 struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); in cs35l41_sys_suspend() local
1407 dev_dbg(cs35l41->dev, "System suspend, disabling IRQ\n"); in cs35l41_sys_suspend()
1408 disable_irq(cs35l41->irq); in cs35l41_sys_suspend()
1415 struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); in cs35l41_sys_suspend_noirq() local
1417 dev_dbg(cs35l41->dev, "Late system suspend, reenabling IRQ\n"); in cs35l41_sys_suspend_noirq()
1418 enable_irq(cs35l41->irq); in cs35l41_sys_suspend_noirq()
1425 struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); in cs35l41_sys_resume_noirq() local
1427 dev_dbg(cs35l41->dev, "Early system resume, disabling IRQ\n"); in cs35l41_sys_resume_noirq()
1428 disable_irq(cs35l41->irq); in cs35l41_sys_resume_noirq()
1435 struct cs35l41_private *cs35l41 = dev_get_drvdata(dev); in cs35l41_sys_resume() local
1437 dev_dbg(cs35l41->dev, "System resume, reenabling IRQ\n"); in cs35l41_sys_resume()
1438 enable_irq(cs35l41->irq); in cs35l41_sys_resume()