Lines Matching +full:dsp +full:- +full:gpio2

1 // SPDX-License-Identifier: GPL-2.0
36 #define CS35L41_UUID "50d90cdc-3de4-4f18-b528-c7fe3b71f40d"
85 [CS35L41_HDA_FW_SPK_PROT] = "spk-prot",
86 [CS35L41_HDA_FW_SPK_CALI] = "spk-cali",
87 [CS35L41_HDA_FW_SPK_DIAG] = "spk-diag",
100 { CS35L41_DSP_CLK_CTRL, 0x00000003 }, // DSP CLK EN
113 { CS35L41_SP_HIZ_CTRL, 0x00000002 }, // Hi-Z unused
122 { CS35L41_SP_HIZ_CTRL, 0x00000003 }, // Hi-Z unused/disabled
152 return -ENOMEM; in cs35l41_request_tuning_param_file()
154 ret = firmware_request_nowarn(firmware, *filename, cs35l41->dev); in cs35l41_request_tuning_param_file()
156 dev_dbg(cs35l41->dev, "Failed to request '%s'\n", *filename); in cs35l41_request_tuning_param_file()
169 const char * const dsp_name = cs35l41->cs_dsp.name; in cs35l41_request_firmware_file()
173 if (spkid > -1 && ssid && amp_name) in cs35l41_request_firmware_file()
174 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-spkid%d-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
175 dsp_name, cs35l41_hda_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
177 else if (spkid > -1 && ssid) in cs35l41_request_firmware_file()
178 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-spkid%d.%s", CS35L41_PART, in cs35l41_request_firmware_file()
179 dsp_name, cs35l41_hda_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
182 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
183 dsp_name, cs35l41_hda_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
186 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
187 dsp_name, cs35l41_hda_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
190 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
191 dsp_name, cs35l41_hda_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
195 return -ENOMEM; in cs35l41_request_firmware_file()
198 * Make sure that filename is lower-case and any non alpha-numeric in cs35l41_request_firmware_file()
207 *s = '-'; in cs35l41_request_firmware_file()
211 ret = firmware_request_nowarn(firmware, *filename, cs35l41->dev); in cs35l41_request_firmware_file()
213 dev_dbg(cs35l41->dev, "Failed to request '%s'\n", *filename); in cs35l41_request_firmware_file()
229 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.wmfw */ in cs35l41_request_firmware_files_spkid()
231 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
232 cs35l41->speaker_id, "wmfw"); in cs35l41_request_firmware_files_spkid()
234 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
236 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
237 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
244 /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ in cs35l41_request_firmware_files_spkid()
246 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
247 cs35l41->amp_name, -1, "wmfw"); in cs35l41_request_firmware_files_spkid()
249 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
251 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
252 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
259 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.wmfw */ in cs35l41_request_firmware_files_spkid()
261 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
262 NULL, cs35l41->speaker_id, "wmfw"); in cs35l41_request_firmware_files_spkid()
264 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
266 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
267 cs35l41->amp_name, cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
269 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ in cs35l41_request_firmware_files_spkid()
272 cs35l41->acpi_subsystem_id, NULL, in cs35l41_request_firmware_files_spkid()
273 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
280 /* try cirrus/part-dspN-fwtype-sub.wmfw */ in cs35l41_request_firmware_files_spkid()
282 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
283 NULL, -1, "wmfw"); in cs35l41_request_firmware_files_spkid()
285 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
287 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
288 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
290 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ in cs35l41_request_firmware_files_spkid()
293 cs35l41->acpi_subsystem_id, NULL, in cs35l41_request_firmware_files_spkid()
294 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
315 dev_warn(cs35l41->dev, "Falling back to default firmware.\n"); in cs35l41_fallback_firmware_file()
317 /* fallback try cirrus/part-dspN-fwtype.wmfw */ in cs35l41_fallback_firmware_file()
319 NULL, NULL, -1, "wmfw"); in cs35l41_fallback_firmware_file()
323 /* fallback try cirrus/part-dspN-fwtype.bin */ in cs35l41_fallback_firmware_file()
325 NULL, NULL, -1, "bin"); in cs35l41_fallback_firmware_file()
334 dev_warn(cs35l41->dev, "Unable to find firmware and tuning\n"); in cs35l41_fallback_firmware_file()
346 if (cs35l41->speaker_id > -1) { in cs35l41_request_firmware_files()
352 /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ in cs35l41_request_firmware_files()
354 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
355 cs35l41->amp_name, -1, "wmfw"); in cs35l41_request_firmware_files()
357 /* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ in cs35l41_request_firmware_files()
359 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files()
360 -1, "bin"); in cs35l41_request_firmware_files()
367 /* try cirrus/part-dspN-fwtype-sub.wmfw */ in cs35l41_request_firmware_files()
369 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
370 NULL, -1, "wmfw"); in cs35l41_request_firmware_files()
372 /* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ in cs35l41_request_firmware_files()
374 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
375 cs35l41->amp_name, -1, "bin"); in cs35l41_request_firmware_files()
377 /* try cirrus/part-dspN-fwtype-sub.bin */ in cs35l41_request_firmware_files()
379 cs35l41->acpi_subsystem_id, NULL, -1, in cs35l41_request_firmware_files()
405 if (!cs35l41->cal_data_valid) in cs35l41_hda_apply_calibration()
408 ret = cs_amp_write_cal_coeffs(&cs35l41->cs_dsp, &cs35l41_calibration_controls, in cs35l41_hda_apply_calibration()
409 &cs35l41->cal_data); in cs35l41_hda_apply_calibration()
411 dev_warn(cs35l41->dev, "Failed to apply calibration: %d\n", ret); in cs35l41_hda_apply_calibration()
413 dev_info(cs35l41->dev, "Calibration applied: R0=%d\n", cs35l41->cal_data.calR); in cs35l41_hda_apply_calibration()
421 ret = regmap_read(cs35l41->regmap, CS35L41_DIE_STS2, &tmp); in cs35l41_read_silicon_uid()
423 dev_err(cs35l41->dev, "Cannot obtain CS35L41_DIE_STS2: %d\n", ret); in cs35l41_read_silicon_uid()
430 ret = regmap_read(cs35l41->regmap, CS35L41_DIE_STS1, &tmp); in cs35l41_read_silicon_uid()
432 dev_err(cs35l41->dev, "Cannot obtain CS35L41_DIE_STS1: %d\n", ret); in cs35l41_read_silicon_uid()
438 dev_dbg(cs35l41->dev, "UniqueID = %#llx\n", *uid); in cs35l41_read_silicon_uid()
452 ret = cs_amp_get_efi_calibration_data(cs35l41->dev, silicon_uid, in cs35l41_get_calibration()
453 cs35l41->index, in cs35l41_get_calibration()
454 &cs35l41->cal_data); in cs35l41_get_calibration()
457 if ((ret == -ENOENT) || (ret == -EOVERFLOW)) in cs35l41_get_calibration()
463 cs35l41->cal_data_valid = true; in cs35l41_get_calibration()
471 cs35l41->tuning_gain = DEFAULT_AMP_GAIN_PCM; in cs35l41_set_default_tuning_params()
481 params = (void *)&firmware->data[0]; in cs35l41_read_tuning_params()
483 if (le32_to_cpu(params->size) != firmware->size) { in cs35l41_read_tuning_params()
484 dev_err(cs35l41->dev, "Wrong Size for Tuning Param file. Expected %d got %zu\n", in cs35l41_read_tuning_params()
485 le32_to_cpu(params->size), firmware->size); in cs35l41_read_tuning_params()
486 return -EINVAL; in cs35l41_read_tuning_params()
489 if (le32_to_cpu(params->version) != 1) { in cs35l41_read_tuning_params()
490 dev_err(cs35l41->dev, "Unsupported Tuning Param Version: %d\n", in cs35l41_read_tuning_params()
491 le32_to_cpu(params->version)); in cs35l41_read_tuning_params()
492 return -EINVAL; in cs35l41_read_tuning_params()
495 if (le32_to_cpu(params->signature) != CS35L41_TUNING_SIG) { in cs35l41_read_tuning_params()
496 dev_err(cs35l41->dev, in cs35l41_read_tuning_params()
498 CS35L41_TUNING_SIG, le32_to_cpu(params->signature)); in cs35l41_read_tuning_params()
499 return -EINVAL; in cs35l41_read_tuning_params()
502 end = firmware->size - sizeof(struct cs35l41_tuning_params); in cs35l41_read_tuning_params()
504 for (i = 0; i < le32_to_cpu(params->num_entries); i++) { in cs35l41_read_tuning_params()
508 return -EFAULT; in cs35l41_read_tuning_params()
510 param = (void *)&params->data[offset]; in cs35l41_read_tuning_params()
511 offset += le32_to_cpu(param->hdr.size); in cs35l41_read_tuning_params()
514 return -EFAULT; in cs35l41_read_tuning_params()
516 switch (le32_to_cpu(param->hdr.type)) { in cs35l41_read_tuning_params()
518 cs35l41->tuning_gain = le32_to_cpu(param->gain); in cs35l41_read_tuning_params()
519 dev_dbg(cs35l41->dev, "Applying Gain: %d\n", cs35l41->tuning_gain); in cs35l41_read_tuning_params()
536 &tuning_param_filename, cs35l41->acpi_subsystem_id); in cs35l41_load_tuning_params()
538 dev_dbg(cs35l41->dev, "Missing Tuning Param for file: %s: %d\n", tuning_filename, in cs35l41_load_tuning_params()
545 dev_err(cs35l41->dev, "Error reading Tuning Params from file: %s: %d\n", in cs35l41_load_tuning_params()
561 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_init_dsp() local
566 if (!cs35l41->halo_initialized) { in cs35l41_init_dsp()
567 cs35l41_configure_cs_dsp(cs35l41->dev, cs35l41->regmap, dsp); in cs35l41_init_dsp()
568 dsp->client_ops = &client_ops; in cs35l41_init_dsp()
570 ret = cs_dsp_halo_init(&cs35l41->cs_dsp); in cs35l41_init_dsp()
573 cs35l41->halo_initialized = true; in cs35l41_init_dsp()
583 dev_dbg(cs35l41->dev, "Loading WMFW Firmware: %s\n", wmfw_filename); in cs35l41_init_dsp()
585 dev_dbg(cs35l41->dev, "Loading Coefficient File: %s\n", coeff_filename); in cs35l41_init_dsp()
588 dev_warn(cs35l41->dev, "Unable to load Tuning Parameters: %d\n", ret); in cs35l41_init_dsp()
590 dev_warn(cs35l41->dev, "No Coefficient File available.\n"); in cs35l41_init_dsp()
593 ret = cs_dsp_power_up(dsp, wmfw_firmware, wmfw_filename, coeff_firmware, coeff_filename, in cs35l41_init_dsp()
594 cs35l41_hda_fw_ids[cs35l41->firmware_type]); in cs35l41_init_dsp()
613 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_shutdown_dsp() local
616 cs_dsp_stop(dsp); in cs35l41_shutdown_dsp()
617 cs_dsp_power_down(dsp); in cs35l41_shutdown_dsp()
618 dev_dbg(cs35l41->dev, "Unloaded Firmware\n"); in cs35l41_shutdown_dsp()
623 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_remove_dsp() local
625 cancel_work_sync(&cs35l41->fw_load_work); in cs35l41_remove_dsp()
627 mutex_lock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
629 cs_dsp_remove(dsp); in cs35l41_remove_dsp()
630 cs35l41->halo_initialized = false; in cs35l41_remove_dsp()
631 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
634 /* Protection release cycle to get the speaker out of Safe-Mode */
645 cs35l41_error_release(cs35l41->dev, cs35l41->regmap, cs35l41->irq_errors); in cs35l41_irq_release()
646 cs35l41->irq_errors = 0; in cs35l41_irq_release()
651 struct regmap *reg = cs35l41->regmap; in cs35l41_update_mixer()
657 if (cs35l41->cs_dsp.running) { in cs35l41_update_mixer()
661 if (cs35l41->hw_cfg.bst_type == CS35L41_INT_BOOST) in cs35l41_update_mixer()
670 if (cs35l41->hw_cfg.spk_pos == CS35L41_CENTER) { in cs35l41_update_mixer()
687 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_play_start()
691 if (cs35l41->playback_started) { in cs35l41_hda_play_start()
696 cs35l41->playback_started = true; in cs35l41_hda_play_start()
700 if (cs35l41->cs_dsp.running) { in cs35l41_hda_play_start()
704 cs35l41_set_cspl_mbox_cmd(cs35l41->dev, reg, CSPL_MBOX_CMD_RESUME); in cs35l41_hda_play_start()
707 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_hda_play_start()
715 struct regmap *reg = cs35l41->regmap; in cs35l41_mute()
718 dev_dbg(dev, "Mute(%d:%d) Playback Started: %d\n", mute, cs35l41->mute_override, in cs35l41_mute()
719 cs35l41->playback_started); in cs35l41_mute()
721 if (cs35l41->playback_started) { in cs35l41_mute()
722 if (mute || cs35l41->mute_override) { in cs35l41_mute()
727 if (cs35l41->cs_dsp.running) { in cs35l41_mute()
728 dev_dbg(dev, "Using Tuned Gain: %d\n", cs35l41->tuning_gain); in cs35l41_mute()
729 amp_gain = (cs35l41->tuning_gain << CS35L41_AMP_GAIN_PCM_SHIFT) | in cs35l41_mute()
746 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_play_done()
750 cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, in cs35l41_hda_play_done()
751 &cs35l41->cs_dsp); in cs35l41_hda_play_done()
758 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_pause_start()
763 cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, in cs35l41_hda_pause_start()
764 &cs35l41->cs_dsp); in cs35l41_hda_pause_start()
770 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_pause_done()
775 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_hda_pause_done()
777 if (cs35l41->cs_dsp.running) { in cs35l41_hda_pause_done()
784 cs35l41->playback_started = false; in cs35l41_hda_pause_done()
793 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
795 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
816 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
818 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
821 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
823 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
826 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
827 if (!cs35l41->cs_dsp.running && cs35l41->request_fw_load && in cs35l41_hda_playback_hook()
828 !cs35l41->fw_request_ongoing) { in cs35l41_hda_playback_hook()
830 cs35l41->fw_request_ongoing = true; in cs35l41_hda_playback_hook()
831 schedule_work(&cs35l41->fw_load_work); in cs35l41_hda_playback_hook()
833 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
852 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
854 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
869 if (!cs35l41->amp_name) { in cs35l41_hda_channel_map()
870 if (cs35l41->hw_cfg.spk_pos >= ARRAY_SIZE(channel_name)) in cs35l41_hda_channel_map()
871 return -EINVAL; in cs35l41_hda_channel_map()
873 cs35l41->amp_name = devm_kasprintf(cs35l41->dev, GFP_KERNEL, "%c%d", in cs35l41_hda_channel_map()
874 channel_name[cs35l41->hw_cfg.spk_pos], in cs35l41_hda_channel_map()
875 cs35l41->channel_index); in cs35l41_hda_channel_map()
876 if (!cs35l41->amp_name) in cs35l41_hda_channel_map()
877 return -ENOMEM; in cs35l41_hda_channel_map()
881 if (cs35l41->hw_cfg.spk_pos == CS35L41_CENTER) in cs35l41_hda_channel_map()
884 rx_slot = &cs35l41->hw_cfg.spk_pos; in cs35l41_hda_channel_map()
886 return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num, in cs35l41_hda_channel_map()
895 ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, regid); in cs35l41_verify_id()
897 dev_err_probe(cs35l41->dev, ret, "Get Device ID failed\n"); in cs35l41_verify_id()
901 ret = regmap_read(cs35l41->regmap, CS35L41_REVID, reg_revid); in cs35l41_verify_id()
903 dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); in cs35l41_verify_id()
911 dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", *regid, chipid); in cs35l41_verify_id()
912 return -ENODEV; in cs35l41_verify_id()
920 mutex_lock(&cs35l41->fw_mutex); in cs35l41_ready_for_reset()
921 if (cs35l41->cs_dsp.running) { in cs35l41_ready_for_reset()
922 cs35l41->cs_dsp.running = false; in cs35l41_ready_for_reset()
923 cs35l41->cs_dsp.booted = false; in cs35l41_ready_for_reset()
925 regcache_mark_dirty(cs35l41->regmap); in cs35l41_ready_for_reset()
926 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_ready_for_reset()
935 dev_dbg(cs35l41->dev, "System Suspend Prepare\n"); in cs35l41_system_suspend_prep()
937 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_suspend_prep()
938 dev_err_once(cs35l41->dev, "System Suspend not supported\n"); in cs35l41_system_suspend_prep()
942 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_suspend_prep()
943 if (cs35l41->playback_started) in cs35l41_system_suspend_prep()
945 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_suspend_prep()
955 dev_dbg(cs35l41->dev, "System Suspend\n"); in cs35l41_system_suspend()
957 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_suspend()
958 dev_err_once(cs35l41->dev, "System Suspend not supported\n"); in cs35l41_system_suspend()
962 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_suspend()
963 if (cs35l41->playback_started) in cs35l41_system_suspend()
965 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_suspend()
973 /* Shutdown DSP before system suspend */ in cs35l41_system_suspend()
978 if (cs35l41->reset_gpio) { in cs35l41_system_suspend()
979 dev_info(cs35l41->dev, "Asserting Reset\n"); in cs35l41_system_suspend()
980 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_system_suspend()
984 dev_dbg(cs35l41->dev, "System Suspended\n"); in cs35l41_system_suspend()
994 ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, int_status, in cs35l41_wait_boot_done()
997 dev_err(cs35l41->dev, "Failed waiting for OTP_BOOT_DONE\n"); in cs35l41_wait_boot_done()
1001 ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status); in cs35l41_wait_boot_done()
1003 dev_err(cs35l41->dev, "OTP Boot status %x error\n", in cs35l41_wait_boot_done()
1006 ret = -EIO; in cs35l41_wait_boot_done()
1018 dev_dbg(cs35l41->dev, "System Resume\n"); in cs35l41_system_resume()
1020 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_resume()
1021 dev_err_once(cs35l41->dev, "System Resume not supported\n"); in cs35l41_system_resume()
1025 if (cs35l41->reset_gpio) { in cs35l41_system_resume()
1026 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_system_resume()
1028 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_system_resume()
1033 regcache_cache_only(cs35l41->regmap, false); in cs35l41_system_resume()
1035 regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); in cs35l41_system_resume()
1042 regcache_cache_only(cs35l41->regmap, true); in cs35l41_system_resume()
1050 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_resume()
1052 if (cs35l41->request_fw_load && !cs35l41->fw_request_ongoing) { in cs35l41_system_resume()
1053 cs35l41->fw_request_ongoing = true; in cs35l41_system_resume()
1054 schedule_work(&cs35l41->fw_load_work); in cs35l41_system_resume()
1056 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_resume()
1065 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) in cs35l41_runtime_idle()
1066 return -EBUSY; /* suspend not supported yet on this model */ in cs35l41_runtime_idle()
1075 dev_dbg(cs35l41->dev, "Runtime Suspend\n"); in cs35l41_runtime_suspend()
1077 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_runtime_suspend()
1078 dev_dbg(cs35l41->dev, "Runtime Suspend not supported\n"); in cs35l41_runtime_suspend()
1082 mutex_lock(&cs35l41->fw_mutex); in cs35l41_runtime_suspend()
1084 if (cs35l41->cs_dsp.running) { in cs35l41_runtime_suspend()
1085 ret = cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, in cs35l41_runtime_suspend()
1086 cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
1090 cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
1093 regcache_cache_only(cs35l41->regmap, true); in cs35l41_runtime_suspend()
1094 regcache_mark_dirty(cs35l41->regmap); in cs35l41_runtime_suspend()
1097 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_runtime_suspend()
1108 dev_dbg(cs35l41->dev, "Runtime Resume\n"); in cs35l41_runtime_resume()
1110 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_runtime_resume()
1111 dev_dbg(cs35l41->dev, "Runtime Resume not supported\n"); in cs35l41_runtime_resume()
1115 mutex_lock(&cs35l41->fw_mutex); in cs35l41_runtime_resume()
1117 regcache_cache_only(cs35l41->regmap, false); in cs35l41_runtime_resume()
1119 if (cs35l41->cs_dsp.running) { in cs35l41_runtime_resume()
1120 ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1122 dev_warn(cs35l41->dev, "Unable to exit Hibernate."); in cs35l41_runtime_resume()
1131 /* Test key needs to be unlocked to allow the OTP settings to re-apply */ in cs35l41_runtime_resume()
1132 cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1133 ret = regcache_sync(cs35l41->regmap); in cs35l41_runtime_resume()
1134 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1136 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); in cs35l41_runtime_resume()
1140 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_runtime_resume()
1141 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); in cs35l41_runtime_resume()
1143 dev_dbg(cs35l41->dev, "CS35L41 Resumed (%x), Revision: %02X\n", regid, reg_revid); in cs35l41_runtime_resume()
1146 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_runtime_resume()
1151 static int cs35l41_hda_read_ctl(struct cs_dsp *dsp, const char *name, int type, in cs35l41_hda_read_ctl() argument
1156 mutex_lock(&dsp->pwr_lock); in cs35l41_hda_read_ctl()
1157 ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, name, type, alg), 0, buf, len); in cs35l41_hda_read_ctl()
1158 mutex_unlock(&dsp->pwr_lock); in cs35l41_hda_read_ctl()
1169 if (cs35l41->bypass_fw) { in cs35l41_smart_amp()
1170 dev_warn(cs35l41->dev, "Bypassing Firmware.\n"); in cs35l41_smart_amp()
1176 dev_warn(cs35l41->dev, "Cannot Initialize Firmware. Error: %d\n", ret); in cs35l41_smart_amp()
1180 ret = cs35l41_write_fs_errata(cs35l41->dev, cs35l41->regmap); in cs35l41_smart_amp()
1182 dev_err(cs35l41->dev, "Cannot Write FS Errata: %d\n", ret); in cs35l41_smart_amp()
1186 ret = cs_dsp_run(&cs35l41->cs_dsp); in cs35l41_smart_amp()
1188 dev_err(cs35l41->dev, "Fail to start dsp: %d\n", ret); in cs35l41_smart_amp()
1194 1000, 15000, false, &cs35l41->cs_dsp, HALO_STATE_DSP_CTL_NAME, in cs35l41_smart_amp()
1199 dev_err(cs35l41->dev, "Timeout waiting for HALO Core to start. State: %u\n", in cs35l41_smart_amp()
1204 ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status); in cs35l41_smart_amp()
1206 dev_err(cs35l41->dev, in cs35l41_smart_amp()
1216 dev_err(cs35l41->dev, "Firmware status is invalid: %u\n", in cs35l41_smart_amp()
1218 ret = -EINVAL; in cs35l41_smart_amp()
1222 ret = cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, CSPL_MBOX_CMD_PAUSE); in cs35l41_smart_amp()
1224 dev_err(cs35l41->dev, "Error waiting for DSP to pause: %u\n", ret); in cs35l41_smart_amp()
1228 dev_info(cs35l41->dev, "Firmware Loaded - Type: %s, Gain: %d\n", in cs35l41_smart_amp()
1229 cs35l41_hda_fw_ids[cs35l41->firmware_type], cs35l41->tuning_gain); in cs35l41_smart_amp()
1240 if (cs35l41->cs_dsp.running && !load) { in cs35l41_load_firmware()
1241 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); in cs35l41_load_firmware()
1243 } else if (!cs35l41->cs_dsp.running && load) { in cs35l41_load_firmware()
1244 dev_dbg(cs35l41->dev, "Loading Firmware\n"); in cs35l41_load_firmware()
1247 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); in cs35l41_load_firmware()
1256 ucontrol->value.integer.value[0] = cs35l41->request_fw_load; in cs35l41_fw_load_ctl_get()
1265 ucontrol->value.integer.value[0] = cs35l41->mute_override; in cs35l41_mute_override_ctl_get()
1273 pm_runtime_get_sync(cs35l41->dev); in cs35l41_fw_load_work()
1275 mutex_lock(&cs35l41->fw_mutex); in cs35l41_fw_load_work()
1278 if (cs35l41->playback_started) in cs35l41_fw_load_work()
1279 dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); in cs35l41_fw_load_work()
1281 cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); in cs35l41_fw_load_work()
1283 cs35l41->fw_request_ongoing = false; in cs35l41_fw_load_work()
1284 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_fw_load_work()
1286 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_fw_load_work()
1294 if (cs35l41->request_fw_load == ucontrol->value.integer.value[0]) in cs35l41_fw_load_ctl_put()
1297 if (cs35l41->fw_request_ongoing) { in cs35l41_fw_load_ctl_put()
1298 dev_dbg(cs35l41->dev, "Existing request not complete\n"); in cs35l41_fw_load_ctl_put()
1299 return -EBUSY; in cs35l41_fw_load_ctl_put()
1303 if (cs35l41->playback_started) { in cs35l41_fw_load_ctl_put()
1304 dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); in cs35l41_fw_load_ctl_put()
1305 return -EBUSY; in cs35l41_fw_load_ctl_put()
1308 cs35l41->fw_request_ongoing = true; in cs35l41_fw_load_ctl_put()
1309 cs35l41->request_fw_load = ucontrol->value.integer.value[0]; in cs35l41_fw_load_ctl_put()
1310 schedule_work(&cs35l41->fw_load_work); in cs35l41_fw_load_ctl_put()
1320 ucontrol->value.enumerated.item[0] = cs35l41->firmware_type; in cs35l41_fw_type_ctl_get()
1330 if (ucontrol->value.enumerated.item[0] < CS35L41_HDA_NUM_FW) { in cs35l41_fw_type_ctl_put()
1331 if (cs35l41->firmware_type != ucontrol->value.enumerated.item[0]) { in cs35l41_fw_type_ctl_put()
1332 cs35l41->firmware_type = ucontrol->value.enumerated.item[0]; in cs35l41_fw_type_ctl_put()
1339 return -EINVAL; in cs35l41_fw_type_ctl_put()
1376 cs35l41->amp_name); in cs35l41_create_controls()
1378 cs35l41->amp_name); in cs35l41_create_controls()
1380 cs35l41->amp_name); in cs35l41_create_controls()
1382 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_type_ctl, cs35l41)); in cs35l41_create_controls()
1384 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", fw_type_ctl.name, ret); in cs35l41_create_controls()
1388 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_type_ctl.name); in cs35l41_create_controls()
1390 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_load_ctl, cs35l41)); in cs35l41_create_controls()
1392 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", fw_load_ctl.name, ret); in cs35l41_create_controls()
1396 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_load_ctl.name); in cs35l41_create_controls()
1398 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&mute_override_ctl, cs35l41)); in cs35l41_create_controls()
1400 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", mute_override_ctl.name, in cs35l41_create_controls()
1405 dev_dbg(cs35l41->dev, "Added Control %s\n", mute_override_ctl.name); in cs35l41_create_controls()
1423 int mute = -ENODEV; in cs35l41_get_acpi_mute_state()
1429 mute = *ret->buffer.pointer; in cs35l41_get_acpi_mute_state()
1430 dev_dbg(cs35l41->dev, "CS35L41_DSM_GET_MUTE: %d\n", mute); in cs35l41_get_acpi_mute_state()
1433 dev_dbg(cs35l41->dev, "%s: %d\n", __func__, mute); in cs35l41_get_acpi_mute_state()
1448 dev_warn(cs35l41->dev, "Unable to retrieve mute state: %d\n", mute); in cs35l41_acpi_device_notify()
1452 dev_dbg(cs35l41->dev, "Requesting mute value: %d\n", mute); in cs35l41_acpi_device_notify()
1453 cs35l41->mute_override = (mute > 0); in cs35l41_acpi_device_notify()
1454 cs35l41_mute(cs35l41->dev, cs35l41->mute_override); in cs35l41_acpi_device_notify()
1465 comp = hda_component_from_index(parent, cs35l41->index); in cs35l41_hda_bind()
1467 return -EINVAL; in cs35l41_hda_bind()
1469 if (comp->dev) in cs35l41_hda_bind()
1470 return -EBUSY; in cs35l41_hda_bind()
1474 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_bind()
1476 comp->dev = dev; in cs35l41_hda_bind()
1477 cs35l41->codec = parent->codec; in cs35l41_hda_bind()
1478 if (!cs35l41->acpi_subsystem_id) in cs35l41_hda_bind()
1479 cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", in cs35l41_hda_bind()
1480 cs35l41->codec->core.subsystem_id); in cs35l41_hda_bind()
1482 strscpy(comp->name, dev_name(dev), sizeof(comp->name)); in cs35l41_hda_bind()
1484 cs35l41->firmware_type = CS35L41_HDA_FW_SPK_PROT; in cs35l41_hda_bind()
1487 dev_dbg(cs35l41->dev, "Firmware Autostart.\n"); in cs35l41_hda_bind()
1488 cs35l41->request_fw_load = true; in cs35l41_hda_bind()
1490 dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n"); in cs35l41_hda_bind()
1492 dev_dbg(cs35l41->dev, "Firmware Autostart is disabled.\n"); in cs35l41_hda_bind()
1497 comp->playback_hook = cs35l41_hda_playback_hook; in cs35l41_hda_bind()
1498 comp->pre_playback_hook = cs35l41_hda_pre_playback_hook; in cs35l41_hda_bind()
1499 comp->post_playback_hook = cs35l41_hda_post_playback_hook; in cs35l41_hda_bind()
1500 comp->acpi_notify = cs35l41_acpi_device_notify; in cs35l41_hda_bind()
1501 comp->adev = cs35l41->dacpi; in cs35l41_hda_bind()
1503 comp->acpi_notifications_supported = cs35l41_dsm_supported(acpi_device_handle(comp->adev), in cs35l41_hda_bind()
1506 cs35l41->mute_override = cs35l41_get_acpi_mute_state(cs35l41, in cs35l41_hda_bind()
1507 acpi_device_handle(cs35l41->dacpi)) > 0; in cs35l41_hda_bind()
1509 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_bind()
1512 if (!device_link_add(&cs35l41->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) in cs35l41_hda_bind()
1518 dev_info(cs35l41->dev, in cs35l41_hda_bind()
1519 "CS35L41 Bound - SSID: %s, BST: %d, VSPK: %d, CH: %c, FW EN: %d, SPKID: %d\n", in cs35l41_hda_bind()
1520 cs35l41->acpi_subsystem_id, cs35l41->hw_cfg.bst_type, in cs35l41_hda_bind()
1521 cs35l41->hw_cfg.gpio1.func == CS35l41_VSPK_SWITCH, in cs35l41_hda_bind()
1522 channel_name[cs35l41->hw_cfg.spk_pos], in cs35l41_hda_bind()
1523 cs35l41->cs_dsp.running, cs35l41->speaker_id); in cs35l41_hda_bind()
1535 comp = hda_component_from_index(parent, cs35l41->index); in cs35l41_hda_unbind()
1539 if (comp->dev == dev) { in cs35l41_hda_unbind()
1541 device_link_remove(&cs35l41->codec->core.dev, cs35l41->dev); in cs35l41_hda_unbind()
1556 dev_crit_ratelimited(cs35l41->dev, "LBST Error\n"); in cs35l41_bst_short_err()
1557 set_bit(CS35L41_BST_SHORT_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_short_err()
1566 dev_crit_ratelimited(cs35l41->dev, "DCM VBST Under Voltage Error\n"); in cs35l41_bst_dcm_uvp_err()
1567 set_bit(CS35L41_BST_UVP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_dcm_uvp_err()
1576 dev_crit_ratelimited(cs35l41->dev, "VBST Over Voltage error\n"); in cs35l41_bst_ovp_err()
1577 set_bit(CS35L41_BST_OVP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_ovp_err()
1586 dev_crit_ratelimited(cs35l41->dev, "Over temperature error\n"); in cs35l41_temp_err()
1587 set_bit(CS35L41_TEMP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_temp_err()
1596 dev_crit_ratelimited(cs35l41->dev, "Over temperature warning\n"); in cs35l41_temp_warn()
1597 set_bit(CS35L41_TEMP_WARN_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_temp_warn()
1606 dev_crit_ratelimited(cs35l41->dev, "Amp short error\n"); in cs35l41_amp_short()
1607 set_bit(CS35L41_AMP_SHORT_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_amp_short()
1647 if (!cs35l41->irq) { in cs35l41_configure_interrupt()
1648 dev_warn(cs35l41->dev, "No Interrupt Found"); in cs35l41_configure_interrupt()
1652 ret = devm_regmap_add_irq_chip(cs35l41->dev, cs35l41->regmap, cs35l41->irq, in cs35l41_configure_interrupt()
1654 0, &cs35l41_regmap_irq_chip, &cs35l41->irq_data); in cs35l41_configure_interrupt()
1656 dev_dbg(cs35l41->dev, "Unable to add IRQ Chip: %d.", ret); in cs35l41_configure_interrupt()
1661 irq = regmap_irq_get_virq(cs35l41->irq_data, cs35l41_irqs[i].irq); in cs35l41_configure_interrupt()
1664 dev_dbg(cs35l41->dev, "Unable to map IRQ %s: %d.", cs35l41_irqs[i].name, in cs35l41_configure_interrupt()
1669 ret = devm_request_threaded_irq(cs35l41->dev, irq, NULL, in cs35l41_configure_interrupt()
1674 dev_dbg(cs35l41->dev, "Unable to allocate IRQ %s:: %d.", in cs35l41_configure_interrupt()
1681 dev_warn(cs35l41->dev, in cs35l41_configure_interrupt()
1687 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_hda_apply_properties()
1692 if (!cs35l41->hw_cfg.valid) in cs35l41_hda_apply_properties()
1693 return -EINVAL; in cs35l41_hda_apply_properties()
1695 ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1699 if (hw_cfg->gpio1.valid) { in cs35l41_hda_apply_properties()
1700 switch (hw_cfg->gpio1.func) { in cs35l41_hda_apply_properties()
1704 hw_cfg->gpio1.func = CS35L41_GPIO1_GPIO; in cs35l41_hda_apply_properties()
1705 hw_cfg->gpio1.out_en = true; in cs35l41_hda_apply_properties()
1708 hw_cfg->gpio1.func = CS35L41_GPIO1_MDSYNC; in cs35l41_hda_apply_properties()
1711 dev_err(cs35l41->dev, "Invalid function %d for GPIO1\n", in cs35l41_hda_apply_properties()
1712 hw_cfg->gpio1.func); in cs35l41_hda_apply_properties()
1713 return -EINVAL; in cs35l41_hda_apply_properties()
1717 if (hw_cfg->gpio2.valid) { in cs35l41_hda_apply_properties()
1718 switch (hw_cfg->gpio2.func) { in cs35l41_hda_apply_properties()
1723 hw_cfg->gpio2.func = CS35L41_GPIO2_INT_OPEN_DRAIN; in cs35l41_hda_apply_properties()
1726 dev_err(cs35l41->dev, "Invalid GPIO2 function %d\n", hw_cfg->gpio2.func); in cs35l41_hda_apply_properties()
1727 return -EINVAL; in cs35l41_hda_apply_properties()
1731 irq_pol = cs35l41_gpio_config(cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1742 int speaker_id = -ENODEV; in cs35l41_get_speaker_id()
1761 count = gpiod_count(dev, "spk-id"); in cs35l41_get_speaker_id()
1768 return -EINVAL; in cs35l41_get_speaker_id()
1773 speaker_id_desc = gpiod_get_index(dev, "spk-id", i + base_index, in cs35l41_get_speaker_id()
1795 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_hda_parse_acpi()
1801 property = "cirrus,dev-index"; in cs35l41_hda_parse_acpi()
1807 ret = -EINVAL; in cs35l41_hda_parse_acpi()
1816 cs35l41->index = -1; in cs35l41_hda_parse_acpi()
1819 cs35l41->index = i; in cs35l41_hda_parse_acpi()
1823 if (cs35l41->index == -1) { in cs35l41_hda_parse_acpi()
1824 dev_err(cs35l41->dev, "No index found in %s\n", property); in cs35l41_hda_parse_acpi()
1825 ret = -ENODEV; in cs35l41_hda_parse_acpi()
1832 cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(cs35l41->dacpi), "reset", in cs35l41_hda_parse_acpi()
1833 cs35l41->index, GPIOD_OUT_LOW, in cs35l41_hda_parse_acpi()
1834 "cs35l41-reset"); in cs35l41_hda_parse_acpi()
1836 property = "cirrus,speaker-position"; in cs35l41_hda_parse_acpi()
1840 hw_cfg->spk_pos = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1842 cs35l41->channel_index = 0; in cs35l41_hda_parse_acpi()
1843 for (i = 0; i < cs35l41->index; i++) in cs35l41_hda_parse_acpi()
1844 if (values[i] == hw_cfg->spk_pos) in cs35l41_hda_parse_acpi()
1845 cs35l41->channel_index++; in cs35l41_hda_parse_acpi()
1847 property = "cirrus,gpio1-func"; in cs35l41_hda_parse_acpi()
1851 hw_cfg->gpio1.func = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1852 hw_cfg->gpio1.valid = true; in cs35l41_hda_parse_acpi()
1854 property = "cirrus,gpio2-func"; in cs35l41_hda_parse_acpi()
1858 hw_cfg->gpio2.func = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1859 hw_cfg->gpio2.valid = true; in cs35l41_hda_parse_acpi()
1861 property = "cirrus,boost-peak-milliamp"; in cs35l41_hda_parse_acpi()
1864 hw_cfg->bst_ipk = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1866 hw_cfg->bst_ipk = -1; in cs35l41_hda_parse_acpi()
1868 property = "cirrus,boost-ind-nanohenry"; in cs35l41_hda_parse_acpi()
1871 hw_cfg->bst_ind = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1873 hw_cfg->bst_ind = -1; in cs35l41_hda_parse_acpi()
1875 property = "cirrus,boost-cap-microfarad"; in cs35l41_hda_parse_acpi()
1878 hw_cfg->bst_cap = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1880 hw_cfg->bst_cap = -1; in cs35l41_hda_parse_acpi()
1882 cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, cs35l41->index, nval, -1); in cs35l41_hda_parse_acpi()
1884 if (hw_cfg->bst_ind > 0 || hw_cfg->bst_cap > 0 || hw_cfg->bst_ipk > 0) in cs35l41_hda_parse_acpi()
1885 hw_cfg->bst_type = CS35L41_INT_BOOST; in cs35l41_hda_parse_acpi()
1887 hw_cfg->bst_type = CS35L41_EXT_BOOST; in cs35l41_hda_parse_acpi()
1889 hw_cfg->valid = true; in cs35l41_hda_parse_acpi()
1893 dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); in cs35l41_hda_parse_acpi()
1894 hw_cfg->valid = false; in cs35l41_hda_parse_acpi()
1895 hw_cfg->gpio1.valid = false; in cs35l41_hda_parse_acpi()
1896 hw_cfg->gpio2.valid = false; in cs35l41_hda_parse_acpi()
1897 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_parse_acpi()
1910 adev = acpi_dev_get_first_match_dev(hid, NULL, -1); in cs35l41_hda_read_acpi()
1912 dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid); in cs35l41_hda_read_acpi()
1913 return -ENODEV; in cs35l41_hda_read_acpi()
1916 cs35l41->dacpi = adev; in cs35l41_hda_read_acpi()
1922 cs35l41->acpi_subsystem_id = sub; in cs35l41_hda_read_acpi()
1926 dev_info(cs35l41->dev, "Using extra _DSD properties, bypassing _DSD in ACPI\n"); in cs35l41_hda_read_acpi()
1938 cs35l41->bypass_fw = false; in cs35l41_hda_read_acpi()
1939 if (cs35l41->control_bus == SPI) { in cs35l41_hda_read_acpi()
1940 spi = to_spi_device(cs35l41->dev); in cs35l41_hda_read_acpi()
1941 if (spi->max_speed_hz < CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ) { in cs35l41_hda_read_acpi()
1942 dev_warn(cs35l41->dev, in cs35l41_hda_read_acpi()
1944 spi->max_speed_hz); in cs35l41_hda_read_acpi()
1945 cs35l41->bypass_fw = true; in cs35l41_hda_read_acpi()
1967 return -ENOMEM; in cs35l41_hda_probe()
1969 cs35l41->dev = dev; in cs35l41_hda_probe()
1970 cs35l41->irq = irq; in cs35l41_hda_probe()
1971 cs35l41->regmap = regmap; in cs35l41_hda_probe()
1972 cs35l41->control_bus = control_bus; in cs35l41_hda_probe()
1977 return dev_err_probe(cs35l41->dev, ret, "Platform not supported\n"); in cs35l41_hda_probe()
1979 if (IS_ERR(cs35l41->reset_gpio)) { in cs35l41_hda_probe()
1980 ret = PTR_ERR(cs35l41->reset_gpio); in cs35l41_hda_probe()
1981 cs35l41->reset_gpio = NULL; in cs35l41_hda_probe()
1982 if (ret == -EBUSY) { in cs35l41_hda_probe()
1983 dev_info(cs35l41->dev, "Reset line busy, assuming shared reset\n"); in cs35l41_hda_probe()
1985 dev_err_probe(cs35l41->dev, ret, "Failed to get reset GPIO\n"); in cs35l41_hda_probe()
1989 if (cs35l41->reset_gpio) { in cs35l41_hda_probe()
1990 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_probe()
1992 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_hda_probe()
1996 regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); in cs35l41_hda_probe()
2007 ret = cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
2011 ret = cs35l41_register_errata_patch(cs35l41->dev, cs35l41->regmap, reg_revid); in cs35l41_hda_probe()
2015 ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
2017 dev_err_probe(cs35l41->dev, ret, "OTP Unpack failed\n"); in cs35l41_hda_probe()
2021 ret = cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
2026 if (ret && ret != -ENOENT) in cs35l41_hda_probe()
2029 cs35l41_mute(cs35l41->dev, true); in cs35l41_hda_probe()
2031 INIT_WORK(&cs35l41->fw_load_work, cs35l41_fw_load_work); in cs35l41_hda_probe()
2032 mutex_init(&cs35l41->fw_mutex); in cs35l41_hda_probe()
2034 pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); in cs35l41_hda_probe()
2035 pm_runtime_use_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
2036 pm_runtime_set_active(cs35l41->dev); in cs35l41_hda_probe()
2037 pm_runtime_get_noresume(cs35l41->dev); in cs35l41_hda_probe()
2038 pm_runtime_enable(cs35l41->dev); in cs35l41_hda_probe()
2044 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
2046 ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops); in cs35l41_hda_probe()
2048 dev_err_probe(cs35l41->dev, ret, "Register component failed\n"); in cs35l41_hda_probe()
2052 dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", regid, reg_revid); in cs35l41_hda_probe()
2057 pm_runtime_dont_use_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
2058 pm_runtime_disable(cs35l41->dev); in cs35l41_hda_probe()
2059 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_hda_probe()
2062 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) in cs35l41_hda_probe()
2063 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_probe()
2064 gpiod_put(cs35l41->reset_gpio); in cs35l41_hda_probe()
2065 gpiod_put(cs35l41->cs_gpio); in cs35l41_hda_probe()
2066 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_probe()
2067 kfree(cs35l41->acpi_subsystem_id); in cs35l41_hda_probe()
2077 component_del(cs35l41->dev, &cs35l41_hda_comp_ops); in cs35l41_hda_remove()
2079 pm_runtime_get_sync(cs35l41->dev); in cs35l41_hda_remove()
2080 pm_runtime_dont_use_autosuspend(cs35l41->dev); in cs35l41_hda_remove()
2081 pm_runtime_disable(cs35l41->dev); in cs35l41_hda_remove()
2083 if (cs35l41->halo_initialized) in cs35l41_hda_remove()
2086 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_remove()
2088 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_hda_remove()
2090 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) in cs35l41_hda_remove()
2091 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_remove()
2092 gpiod_put(cs35l41->reset_gpio); in cs35l41_hda_remove()
2093 gpiod_put(cs35l41->cs_gpio); in cs35l41_hda_remove()
2094 kfree(cs35l41->acpi_subsystem_id); in cs35l41_hda_remove()
2111 MODULE_FIRMWARE("cirrus/cs35l41-*.wmfw");
2112 MODULE_FIRMWARE("cirrus/cs35l41-*.bin");