Lines Matching +full:tempmon +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-only
27 #include <sound/soc-dapm.h>
39 flush_work(&cs35l56->dsp_work); in cs35l56_wait_dsp_ready()
73 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cs35l56->component); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
74 const char *prefix = cs35l56->component->name_prefix; in cs35l56_sync_asp1_mixer_widgets_with_firmware()
82 if (cs35l56->asp1_mixer_widgets_initialized) in cs35l56_sync_asp1_mixer_widgets_with_firmware()
89 ret = pm_runtime_resume_and_get(cs35l56->base.dev); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
96 ret = regmap_bulk_read(cs35l56->base.regmap, CS35L56_ASP1TX1_INPUT, in cs35l56_sync_asp1_mixer_widgets_with_firmware()
99 pm_runtime_mark_last_busy(cs35l56->base.dev); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
100 pm_runtime_put_autosuspend(cs35l56->base.dev); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
103 dev_err(cs35l56->base.dev, "Failed to read ASP1 mixer regs: %d\n", ret); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
115 kcontrol = snd_soc_card_get_kcontrol_locked(dapm->card, name); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
117 dev_warn(cs35l56->base.dev, "Could not find control %s\n", name); in cs35l56_sync_asp1_mixer_widgets_with_firmware()
121 e = (struct soc_enum *)kcontrol->private_value; in cs35l56_sync_asp1_mixer_widgets_with_firmware()
126 cs35l56->asp1_mixer_widgets_initialized = true; in cs35l56_sync_asp1_mixer_widgets_with_firmware()
136 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in cs35l56_dspwait_asp1tx_get()
137 int index = e->shift_l; in cs35l56_dspwait_asp1tx_get()
146 ret = regmap_read(cs35l56->base.regmap, addr, &val); in cs35l56_dspwait_asp1tx_get()
151 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); in cs35l56_dspwait_asp1tx_get()
162 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in cs35l56_dspwait_asp1tx_put()
163 int item = ucontrol->value.enumerated.item[0]; in cs35l56_dspwait_asp1tx_put()
164 int index = e->shift_l; in cs35l56_dspwait_asp1tx_put()
176 ret = regmap_update_bits_check(cs35l56->base.regmap, addr, in cs35l56_dspwait_asp1tx_put()
187 static DECLARE_TLV_DB_SCALE(vol_tlv, -10000, 25, 0);
195 6, -400, 400, 9, 0,
283 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l56_asp1_cfg_event()
289 return cs35l56_force_sync_asp1_registers_from_cache(&cs35l56->base); in cs35l56_asp1_cfg_event()
298 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l56_play_event()
303 dev_dbg(cs35l56->base.dev, "play: %d\n", event); in cs35l56_play_event()
308 return regmap_write(cs35l56->base.regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, in cs35l56_play_event()
312 ret = regmap_read_poll_timeout(cs35l56->base.regmap, in cs35l56_play_event()
318 dev_err(cs35l56->base.dev, "PS0 wait failed: %d\n", ret); in cs35l56_play_event()
321 return cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_PAUSE); in cs35l56_play_event()
372 SND_SOC_DAPM_SIGGEN("TEMPMON ADC"),
392 { name" Source", "TEMPMON", "TEMPMON ADC" }, \
442 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l56_dsp_event()
445 dev_dbg(cs35l56->base.dev, "%s: %d\n", __func__, event); in cs35l56_dsp_event()
452 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(codec_dai->component); in cs35l56_asp_dai_set_fmt()
455 dev_dbg(cs35l56->base.dev, "%s: %#x\n", __func__, fmt); in cs35l56_asp_dai_set_fmt()
461 dev_err(cs35l56->base.dev, "Unsupported clock source mode\n"); in cs35l56_asp_dai_set_fmt()
462 return -EINVAL; in cs35l56_asp_dai_set_fmt()
468 cs35l56->tdm_mode = true; in cs35l56_asp_dai_set_fmt()
472 cs35l56->tdm_mode = false; in cs35l56_asp_dai_set_fmt()
475 dev_err(cs35l56->base.dev, "Unsupported DAI format\n"); in cs35l56_asp_dai_set_fmt()
476 return -EINVAL; in cs35l56_asp_dai_set_fmt()
492 dev_err(cs35l56->base.dev, "Invalid clock invert\n"); in cs35l56_asp_dai_set_fmt()
493 return -EINVAL; in cs35l56_asp_dai_set_fmt()
496 regmap_update_bits(cs35l56->base.regmap, in cs35l56_asp_dai_set_fmt()
502 /* Hi-Z DOUT in unused slots and when all TX are disabled */ in cs35l56_asp_dai_set_fmt()
503 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_CONTROL3, in cs35l56_asp_dai_set_fmt()
529 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); in cs35l56_asp_dai_set_tdm_slot()
532 dev_dbg(cs35l56->base.dev, "tdm config cleared\n"); in cs35l56_asp_dai_set_tdm_slot()
533 cs35l56->asp_slot_width = 0; in cs35l56_asp_dai_set_tdm_slot()
534 cs35l56->asp_slot_count = 0; in cs35l56_asp_dai_set_tdm_slot()
539 dev_err(cs35l56->base.dev, "tdm invalid slot width %d\n", slot_width); in cs35l56_asp_dai_set_tdm_slot()
540 return -EINVAL; in cs35l56_asp_dai_set_tdm_slot()
545 dev_err(cs35l56->base.dev, "tdm invalid slot count %d\n", slots); in cs35l56_asp_dai_set_tdm_slot()
546 return -EINVAL; in cs35l56_asp_dai_set_tdm_slot()
549 cs35l56->asp_slot_width = (u8)slot_width; in cs35l56_asp_dai_set_tdm_slot()
550 cs35l56->asp_slot_count = (u8)slots; in cs35l56_asp_dai_set_tdm_slot()
560 regmap_write(cs35l56->base.regmap, CS35L56_ASP1_FRAME_CONTROL1, in cs35l56_asp_dai_set_tdm_slot()
562 regmap_write(cs35l56->base.regmap, CS35L56_ASP1_FRAME_CONTROL5, in cs35l56_asp_dai_set_tdm_slot()
565 dev_dbg(cs35l56->base.dev, "tdm slot width: %u count: %u tx_mask: %#x rx_mask: %#x\n", in cs35l56_asp_dai_set_tdm_slot()
566 cs35l56->asp_slot_width, cs35l56->asp_slot_count, tx_mask, rx_mask); in cs35l56_asp_dai_set_tdm_slot()
575 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); in cs35l56_asp_dai_hw_params()
580 if (cs35l56->asp_slot_width) in cs35l56_asp_dai_hw_params()
581 asp_width = cs35l56->asp_slot_width; in cs35l56_asp_dai_hw_params()
585 dev_dbg(cs35l56->base.dev, "%s: wl=%d, width=%d, rate=%d", in cs35l56_asp_dai_hw_params()
588 if (!cs35l56->sysclk_set) { in cs35l56_asp_dai_hw_params()
589 unsigned int slots = cs35l56->asp_slot_count; in cs35l56_asp_dai_hw_params()
597 if (!cs35l56->tdm_mode) in cs35l56_asp_dai_hw_params()
604 dev_err(cs35l56->base.dev, "%s: Invalid BCLK %u\n", __func__, bclk_freq); in cs35l56_asp_dai_hw_params()
605 return -EINVAL; in cs35l56_asp_dai_hw_params()
608 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_CONTROL1, in cs35l56_asp_dai_hw_params()
613 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l56_asp_dai_hw_params()
614 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_CONTROL2, in cs35l56_asp_dai_hw_params()
617 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_DATA_CONTROL5, in cs35l56_asp_dai_hw_params()
620 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_CONTROL2, in cs35l56_asp_dai_hw_params()
623 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_DATA_CONTROL1, in cs35l56_asp_dai_hw_params()
633 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); in cs35l56_asp_dai_set_sysclk()
637 cs35l56->sysclk_set = false; in cs35l56_asp_dai_set_sysclk()
645 regmap_update_bits(cs35l56->base.regmap, CS35L56_ASP1_CONTROL1, in cs35l56_asp_dai_set_sysclk()
648 cs35l56->sysclk_set = true; in cs35l56_asp_dai_set_sysclk()
669 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); in cs35l56_sdw_dai_set_tdm_slot()
672 cs35l56->rx_mask = tx_mask; in cs35l56_sdw_dai_set_tdm_slot()
673 cs35l56->tx_mask = rx_mask; in cs35l56_sdw_dai_set_tdm_slot()
682 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); in cs35l56_sdw_dai_hw_params()
688 dev_dbg(cs35l56->base.dev, "%s: rate %d\n", __func__, params_rate(params)); in cs35l56_sdw_dai_hw_params()
690 if (!cs35l56->base.init_done) in cs35l56_sdw_dai_hw_params()
691 return -ENODEV; in cs35l56_sdw_dai_hw_params()
694 return -EINVAL; in cs35l56_sdw_dai_hw_params()
702 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l56_sdw_dai_hw_params()
705 pconfig.ch_mask = cs35l56->rx_mask; in cs35l56_sdw_dai_hw_params()
709 pconfig.ch_mask = cs35l56->tx_mask; in cs35l56_sdw_dai_hw_params()
714 pconfig.ch_mask = GENMASK(sconfig.ch_count - 1, 0); in cs35l56_sdw_dai_hw_params()
719 ret = sdw_stream_add_slave(cs35l56->sdw_peripheral, &sconfig, &pconfig, in cs35l56_sdw_dai_hw_params()
722 dev_err(dai->dev, "Failed to add sdw stream: %d\n", ret); in cs35l56_sdw_dai_hw_params()
732 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); in cs35l56_sdw_dai_hw_free()
735 if (!cs35l56->sdw_peripheral) in cs35l56_sdw_dai_hw_free()
736 return -EINVAL; in cs35l56_sdw_dai_hw_free()
738 sdw_stream_remove_slave(cs35l56->sdw_peripheral, sdw_stream); in cs35l56_sdw_dai_hw_free()
761 .name = "cs35l56-asp1",
782 .name = "cs35l56-sdw1",
808 ret = wm_adsp_power_up(&cs35l56->dsp, true); in cs35l56_secure_patch()
810 dev_dbg(cs35l56->base.dev, "%s: wm_adsp_power_up ret %d\n", __func__, ret); in cs35l56_secure_patch()
812 cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT); in cs35l56_secure_patch()
820 ret = regmap_read(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, &firmware_missing); in cs35l56_patch()
822 dev_err(cs35l56->base.dev, "Failed to read PROTECTION_STATUS: %d\n", ret); in cs35l56_patch()
830 * Setting sdw_irq_no_unmask prevents the handler re-enabling in cs35l56_patch()
833 if (cs35l56->sdw_peripheral) { in cs35l56_patch()
834 cs35l56->sdw_irq_no_unmask = true; in cs35l56_patch()
835 flush_work(&cs35l56->sdw_irq_work); in cs35l56_patch()
836 sdw_write_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_MASK_1, 0); in cs35l56_patch()
837 sdw_read_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_STAT_1); in cs35l56_patch()
838 sdw_write_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_STAT_1, 0xFF); in cs35l56_patch()
839 flush_work(&cs35l56->sdw_irq_work); in cs35l56_patch()
842 ret = cs35l56_firmware_shutdown(&cs35l56->base); in cs35l56_patch()
849 * power-up wm_adsp without downloading firmware. in cs35l56_patch()
851 ret = wm_adsp_power_up(&cs35l56->dsp, !!firmware_missing); in cs35l56_patch()
853 dev_dbg(cs35l56->base.dev, "%s: wm_adsp_power_up ret %d\n", __func__, ret); in cs35l56_patch()
857 mutex_lock(&cs35l56->base.irq_lock); in cs35l56_patch()
859 reinit_completion(&cs35l56->init_completion); in cs35l56_patch()
861 cs35l56->soft_resetting = true; in cs35l56_patch()
862 cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral); in cs35l56_patch()
864 if (cs35l56->sdw_peripheral) { in cs35l56_patch()
866 * The system-reset causes the CS35L56 to detach from the bus. in cs35l56_patch()
867 * Wait for the manager to re-enumerate the CS35L56 and in cs35l56_patch()
870 if (!wait_for_completion_timeout(&cs35l56->init_completion, in cs35l56_patch()
872 dev_err(cs35l56->base.dev, "%s: init_completion timed out (SDW)\n", in cs35l56_patch()
880 regmap_clear_bits(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, in cs35l56_patch()
882 cs35l56->base.fw_patched = true; in cs35l56_patch()
885 mutex_unlock(&cs35l56->base.irq_lock); in cs35l56_patch()
887 /* Re-enable SoundWire interrupts */ in cs35l56_patch()
888 if (cs35l56->sdw_peripheral) { in cs35l56_patch()
889 cs35l56->sdw_irq_no_unmask = false; in cs35l56_patch()
890 sdw_write_no_pm(cs35l56->sdw_peripheral, CS35L56_SDW_GEN_INT_MASK_1, in cs35l56_patch()
901 if (!cs35l56->base.init_done) in cs35l56_dsp_work()
904 pm_runtime_get_sync(cs35l56->base.dev); in cs35l56_dsp_work()
907 if (!cs35l56->dsp.fwf_name) { in cs35l56_dsp_work()
908 cs35l56->dsp.fwf_name = kasprintf(GFP_KERNEL, "%02x%s-dsp1", in cs35l56_dsp_work()
909 cs35l56->base.rev, in cs35l56_dsp_work()
910 cs35l56->base.secured ? "-s" : ""); in cs35l56_dsp_work()
911 if (!cs35l56->dsp.fwf_name) in cs35l56_dsp_work()
915 dev_dbg(cs35l56->base.dev, "DSP fwf name: '%s' system name: '%s'\n", in cs35l56_dsp_work()
916 cs35l56->dsp.fwf_name, cs35l56->dsp.system_name); in cs35l56_dsp_work()
924 if (cs35l56->base.secured) in cs35l56_dsp_work()
930 pm_runtime_mark_last_busy(cs35l56->base.dev); in cs35l56_dsp_work()
931 pm_runtime_put_autosuspend(cs35l56->base.dev); in cs35l56_dsp_work()
937 struct dentry *debugfs_root = component->debugfs_root; in cs35l56_component_probe()
942 if (!cs35l56->dsp.system_name && in cs35l56_component_probe()
943 (snd_soc_card_get_pci_ssid(component->card, &vendor, &device) == 0)) { in cs35l56_component_probe()
945 if (cs35l56->speaker_id >= 0) { in cs35l56_component_probe()
946 cs35l56->dsp.system_name = devm_kasprintf(cs35l56->base.dev, in cs35l56_component_probe()
948 "%04x%04x-spkid%d", in cs35l56_component_probe()
950 cs35l56->speaker_id); in cs35l56_component_probe()
952 cs35l56->dsp.system_name = devm_kasprintf(cs35l56->base.dev, in cs35l56_component_probe()
957 if (!cs35l56->dsp.system_name) in cs35l56_component_probe()
958 return -ENOMEM; in cs35l56_component_probe()
961 if (!wait_for_completion_timeout(&cs35l56->init_completion, in cs35l56_component_probe()
963 dev_err(cs35l56->base.dev, "%s: init_completion timed out\n", __func__); in cs35l56_component_probe()
964 return -ENODEV; in cs35l56_component_probe()
967 cs35l56->component = component; in cs35l56_component_probe()
968 wm_adsp2_component_probe(&cs35l56->dsp, component); in cs35l56_component_probe()
970 debugfs_create_bool("init_done", 0444, debugfs_root, &cs35l56->base.init_done); in cs35l56_component_probe()
971 debugfs_create_bool("can_hibernate", 0444, debugfs_root, &cs35l56->base.can_hibernate); in cs35l56_component_probe()
972 debugfs_create_bool("fw_patched", 0444, debugfs_root, &cs35l56->base.fw_patched); in cs35l56_component_probe()
978 regcache_drop_region(cs35l56->base.regmap, CS35L56_ASP1TX1_INPUT, CS35L56_ASP1TX4_INPUT); in cs35l56_component_probe()
979 cs35l56->asp1_mixer_widgets_initialized = false; in cs35l56_component_probe()
981 queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work); in cs35l56_component_probe()
990 cancel_work_sync(&cs35l56->dsp_work); in cs35l56_component_remove()
992 if (cs35l56->dsp.cs_dsp.booted) in cs35l56_component_remove()
993 wm_adsp_power_down(&cs35l56->dsp); in cs35l56_component_remove()
995 wm_adsp2_component_remove(&cs35l56->dsp, component); in cs35l56_component_remove()
997 kfree(cs35l56->dsp.fwf_name); in cs35l56_component_remove()
998 cs35l56->dsp.fwf_name = NULL; in cs35l56_component_remove()
1000 cs35l56->component = NULL; in cs35l56_component_remove()
1045 return cs35l56_runtime_suspend_common(&cs35l56->base); in cs35l56_runtime_suspend_i2c_spi()
1052 return cs35l56_runtime_resume_common(&cs35l56->base, false); in cs35l56_runtime_resume_i2c_spi()
1061 if (cs35l56->component) in cs35l56_system_suspend()
1062 flush_work(&cs35l56->dsp_work); in cs35l56_system_suspend()
1070 if (cs35l56->base.irq) in cs35l56_system_suspend()
1071 disable_irq(cs35l56->base.irq); in cs35l56_system_suspend()
1088 if (cs35l56->base.reset_gpio) { in cs35l56_system_suspend_late()
1089 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0); in cs35l56_system_suspend_late()
1093 regulator_bulk_disable(ARRAY_SIZE(cs35l56->supplies), cs35l56->supplies); in cs35l56_system_suspend_late()
1105 /* Handlers are now disabled so the parent IRQ can safely be re-enabled. */ in cs35l56_system_suspend_no_irq()
1106 if (cs35l56->base.irq) in cs35l56_system_suspend_no_irq()
1107 enable_irq(cs35l56->base.irq); in cs35l56_system_suspend_no_irq()
1126 if (cs35l56->base.irq) in cs35l56_system_resume_no_irq()
1127 disable_irq(cs35l56->base.irq); in cs35l56_system_resume_no_irq()
1140 /* Ensure a spec-compliant RESET pulse. */ in cs35l56_system_resume_early()
1141 if (cs35l56->base.reset_gpio) { in cs35l56_system_resume_early()
1142 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0); in cs35l56_system_resume_early()
1147 ret = regulator_bulk_enable(ARRAY_SIZE(cs35l56->supplies), cs35l56->supplies); in cs35l56_system_resume_early()
1154 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 1); in cs35l56_system_resume_early()
1168 * We might have done a hard reset or the CS35L56 was power-cycled in cs35l56_system_resume()
1173 /* Undo pm_runtime_force_suspend() before re-enabling the irq */ in cs35l56_system_resume()
1175 if (cs35l56->base.irq) in cs35l56_system_resume()
1176 enable_irq(cs35l56->base.irq); in cs35l56_system_resume()
1182 if (!cs35l56->component) in cs35l56_system_resume()
1185 ret = cs35l56_is_fw_reload_needed(&cs35l56->base); in cs35l56_system_resume()
1186 dev_dbg(cs35l56->base.dev, "fw_reload_needed: %d\n", ret); in cs35l56_system_resume()
1190 cs35l56->base.fw_patched = false; in cs35l56_system_resume()
1191 wm_adsp_power_down(&cs35l56->dsp); in cs35l56_system_resume()
1192 queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work); in cs35l56_system_resume()
1196 * a BIAS_OFF->BIAS_STANDBY transition to complete dsp patching. in cs35l56_system_resume()
1208 cs35l56->dsp_wq = create_singlethread_workqueue("cs35l56-dsp"); in cs35l56_dsp_init()
1209 if (!cs35l56->dsp_wq) in cs35l56_dsp_init()
1210 return -ENOMEM; in cs35l56_dsp_init()
1212 INIT_WORK(&cs35l56->dsp_work, cs35l56_dsp_work); in cs35l56_dsp_init()
1214 dsp = &cs35l56->dsp; in cs35l56_dsp_init()
1215 cs35l56_init_cs_dsp(&cs35l56->base, &dsp->cs_dsp); in cs35l56_dsp_init()
1216 dsp->part = "cs35l56"; in cs35l56_dsp_init()
1217 dsp->fw = 12; in cs35l56_dsp_init()
1218 dsp->wmfw_optional = true; in cs35l56_dsp_init()
1220 dev_dbg(cs35l56->base.dev, "DSP system name: '%s'\n", dsp->system_name); in cs35l56_dsp_init()
1224 dev_err(cs35l56->base.dev, "wm_halo_init failed\n"); in cs35l56_dsp_init()
1233 struct device *dev = cs35l56->base.dev; in cs35l56_get_firmware_uid()
1237 ret = device_property_read_string(dev, "cirrus,firmware-uid", &prop); in cs35l56_get_firmware_uid()
1243 if (cs35l56->speaker_id >= 0) in cs35l56_get_firmware_uid()
1244 cs35l56->dsp.system_name = devm_kasprintf(dev, GFP_KERNEL, "%s-spkid%d", in cs35l56_get_firmware_uid()
1245 prop, cs35l56->speaker_id); in cs35l56_get_firmware_uid()
1247 cs35l56->dsp.system_name = devm_kstrdup(dev, prop, GFP_KERNEL); in cs35l56_get_firmware_uid()
1249 if (cs35l56->dsp.system_name == NULL) in cs35l56_get_firmware_uid()
1250 return -ENOMEM; in cs35l56_get_firmware_uid()
1252 dev_dbg(dev, "Firmware UID: %s\n", cs35l56->dsp.system_name); in cs35l56_get_firmware_uid()
1261 init_completion(&cs35l56->init_completion); in cs35l56_common_probe()
1262 mutex_init(&cs35l56->base.irq_lock); in cs35l56_common_probe()
1263 cs35l56->speaker_id = -ENOENT; in cs35l56_common_probe()
1265 dev_set_drvdata(cs35l56->base.dev, cs35l56); in cs35l56_common_probe()
1267 cs35l56_fill_supply_names(cs35l56->supplies); in cs35l56_common_probe()
1268 ret = devm_regulator_bulk_get(cs35l56->base.dev, ARRAY_SIZE(cs35l56->supplies), in cs35l56_common_probe()
1269 cs35l56->supplies); in cs35l56_common_probe()
1271 return dev_err_probe(cs35l56->base.dev, ret, "Failed to request supplies\n"); in cs35l56_common_probe()
1274 cs35l56->base.reset_gpio = devm_gpiod_get_optional(cs35l56->base.dev, "reset", in cs35l56_common_probe()
1276 if (IS_ERR(cs35l56->base.reset_gpio)) { in cs35l56_common_probe()
1277 ret = PTR_ERR(cs35l56->base.reset_gpio); in cs35l56_common_probe()
1282 if (ret != -EBUSY) in cs35l56_common_probe()
1283 return dev_err_probe(cs35l56->base.dev, ret, "Failed to get reset GPIO\n"); in cs35l56_common_probe()
1285 dev_info(cs35l56->base.dev, "Reset GPIO busy, assume shared reset\n"); in cs35l56_common_probe()
1286 cs35l56->base.reset_gpio = NULL; in cs35l56_common_probe()
1289 ret = regulator_bulk_enable(ARRAY_SIZE(cs35l56->supplies), cs35l56->supplies); in cs35l56_common_probe()
1291 return dev_err_probe(cs35l56->base.dev, ret, "Failed to enable supplies\n"); in cs35l56_common_probe()
1293 if (cs35l56->base.reset_gpio) { in cs35l56_common_probe()
1295 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0); in cs35l56_common_probe()
1297 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 1); in cs35l56_common_probe()
1300 ret = cs35l56_get_speaker_id(&cs35l56->base); in cs35l56_common_probe()
1301 if ((ret < 0) && (ret != -ENOENT)) in cs35l56_common_probe()
1304 cs35l56->speaker_id = ret; in cs35l56_common_probe()
1312 dev_err_probe(cs35l56->base.dev, ret, "DSP init failed\n"); in cs35l56_common_probe()
1316 ret = devm_snd_soc_register_component(cs35l56->base.dev, in cs35l56_common_probe()
1320 dev_err_probe(cs35l56->base.dev, ret, "Register codec failed\n"); in cs35l56_common_probe()
1327 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0); in cs35l56_common_probe()
1328 regulator_bulk_disable(ARRAY_SIZE(cs35l56->supplies), cs35l56->supplies); in cs35l56_common_probe()
1342 if (cs35l56->soft_resetting) in cs35l56_init()
1345 if (cs35l56->base.init_done) in cs35l56_init()
1348 pm_runtime_set_autosuspend_delay(cs35l56->base.dev, 100); in cs35l56_init()
1349 pm_runtime_use_autosuspend(cs35l56->base.dev); in cs35l56_init()
1350 pm_runtime_set_active(cs35l56->base.dev); in cs35l56_init()
1351 pm_runtime_enable(cs35l56->base.dev); in cs35l56_init()
1353 ret = cs35l56_hw_init(&cs35l56->base); in cs35l56_init()
1357 ret = cs35l56_set_patch(&cs35l56->base); in cs35l56_init()
1361 if (!cs35l56->base.reset_gpio) { in cs35l56_init()
1362 dev_dbg(cs35l56->base.dev, "No reset gpio: using soft reset\n"); in cs35l56_init()
1363 cs35l56->soft_resetting = true; in cs35l56_init()
1364 cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral); in cs35l56_init()
1365 if (cs35l56->sdw_peripheral) { in cs35l56_init()
1366 /* Keep alive while we wait for re-enumeration */ in cs35l56_init()
1367 pm_runtime_get_noresume(cs35l56->base.dev); in cs35l56_init()
1373 if (cs35l56->soft_resetting) { in cs35l56_init()
1374 cs35l56->soft_resetting = false; in cs35l56_init()
1376 /* Done re-enumerating after one-time init so release the keep-alive */ in cs35l56_init()
1377 if (cs35l56->sdw_peripheral && !cs35l56->base.init_done) in cs35l56_init()
1378 pm_runtime_put_noidle(cs35l56->base.dev); in cs35l56_init()
1380 regcache_mark_dirty(cs35l56->base.regmap); in cs35l56_init()
1381 ret = cs35l56_wait_for_firmware_boot(&cs35l56->base); in cs35l56_init()
1385 dev_dbg(cs35l56->base.dev, "Firmware rebooted after soft reset\n"); in cs35l56_init()
1388 /* Disable auto-hibernate so that runtime_pm has control */ in cs35l56_init()
1389 ret = cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE); in cs35l56_init()
1394 regcache_sync(cs35l56->base.regmap); in cs35l56_init()
1396 /* Set ASP1 DOUT to high-impedance when it is not transmitting audio data. */ in cs35l56_init()
1397 ret = regmap_set_bits(cs35l56->base.regmap, CS35L56_ASP1_CONTROL3, in cs35l56_init()
1400 return dev_err_probe(cs35l56->base.dev, ret, "Failed to write ASP1_CONTROL3\n"); in cs35l56_init()
1402 cs35l56->base.init_done = true; in cs35l56_init()
1403 complete(&cs35l56->init_completion); in cs35l56_init()
1411 cs35l56->base.init_done = false; in cs35l56_remove()
1417 if (cs35l56->base.irq) in cs35l56_remove()
1418 devm_free_irq(cs35l56->base.dev, cs35l56->base.irq, &cs35l56->base); in cs35l56_remove()
1420 flush_workqueue(cs35l56->dsp_wq); in cs35l56_remove()
1421 destroy_workqueue(cs35l56->dsp_wq); in cs35l56_remove()
1423 pm_runtime_dont_use_autosuspend(cs35l56->base.dev); in cs35l56_remove()
1424 pm_runtime_suspend(cs35l56->base.dev); in cs35l56_remove()
1425 pm_runtime_disable(cs35l56->base.dev); in cs35l56_remove()
1427 regcache_cache_only(cs35l56->base.regmap, true); in cs35l56_remove()
1429 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0); in cs35l56_remove()
1430 regulator_bulk_disable(ARRAY_SIZE(cs35l56->supplies), cs35l56->supplies); in cs35l56_remove()