Lines Matching +full:boost +full:- +full:ind +full:- +full:nanohenry
1 // SPDX-License-Identifier: GPL-2.0
37 #define CS35L41_UUID "50d90cdc-3de4-4f18-b528-c7fe3b71f40d"
89 { CS35L41_SP_HIZ_CTRL, 0x00000002 }, // Hi-Z unused
111 { CS35L41_SP_HIZ_CTRL, 0x00000003 }, // Hi-Z unused/disabled
149 return -ENOMEM; in cs35l41_request_tuning_param_file()
151 ret = firmware_request_nowarn(firmware, *filename, cs35l41->dev); in cs35l41_request_tuning_param_file()
153 dev_dbg(cs35l41->dev, "Failed to request '%s'\n", *filename); in cs35l41_request_tuning_param_file()
166 const char * const dsp_name = cs35l41->cs_dsp.name; in cs35l41_request_firmware_file()
170 if (spkid > -1 && ssid && amp_name) in cs35l41_request_firmware_file()
171 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-spkid%d-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
172 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
174 else if (spkid > -1 && ssid) in cs35l41_request_firmware_file()
175 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-spkid%d.%s", CS35L41_PART, in cs35l41_request_firmware_file()
176 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
179 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
180 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
183 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
184 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
187 *filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s.%s", CS35L41_PART, in cs35l41_request_firmware_file()
188 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
192 return -ENOMEM; in cs35l41_request_firmware_file()
195 * Make sure that filename is lower-case and any non alpha-numeric in cs35l41_request_firmware_file()
204 *s = '-'; in cs35l41_request_firmware_file()
208 ret = firmware_request_nowarn(firmware, *filename, cs35l41->dev); in cs35l41_request_firmware_file()
210 dev_dbg(cs35l41->dev, "Failed to request '%s'\n", *filename); in cs35l41_request_firmware_file()
226 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.wmfw */ in cs35l41_request_firmware_files_spkid()
228 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
229 cs35l41->speaker_id, "wmfw"); in cs35l41_request_firmware_files_spkid()
231 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
233 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
234 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
241 /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ in cs35l41_request_firmware_files_spkid()
243 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
244 cs35l41->amp_name, -1, "wmfw"); in cs35l41_request_firmware_files_spkid()
246 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
248 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
249 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
256 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.wmfw */ in cs35l41_request_firmware_files_spkid()
258 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
259 NULL, cs35l41->speaker_id, "wmfw"); in cs35l41_request_firmware_files_spkid()
261 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
263 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
264 cs35l41->amp_name, cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
266 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ in cs35l41_request_firmware_files_spkid()
269 cs35l41->acpi_subsystem_id, NULL, in cs35l41_request_firmware_files_spkid()
270 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
277 /* try cirrus/part-dspN-fwtype-sub.wmfw */ in cs35l41_request_firmware_files_spkid()
279 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
280 NULL, -1, "wmfw"); in cs35l41_request_firmware_files_spkid()
282 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
284 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
285 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
287 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ in cs35l41_request_firmware_files_spkid()
290 cs35l41->acpi_subsystem_id, NULL, in cs35l41_request_firmware_files_spkid()
291 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
312 dev_warn(cs35l41->dev, "Falling back to default firmware.\n"); in cs35l41_fallback_firmware_file()
314 /* fallback try cirrus/part-dspN-fwtype.wmfw */ in cs35l41_fallback_firmware_file()
316 NULL, NULL, -1, "wmfw"); in cs35l41_fallback_firmware_file()
320 /* fallback try cirrus/part-dspN-fwtype.bin */ in cs35l41_fallback_firmware_file()
322 NULL, NULL, -1, "bin"); in cs35l41_fallback_firmware_file()
331 dev_warn(cs35l41->dev, "Unable to find firmware and tuning\n"); in cs35l41_fallback_firmware_file()
343 if (cs35l41->speaker_id > -1) { in cs35l41_request_firmware_files()
349 /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ in cs35l41_request_firmware_files()
351 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
352 cs35l41->amp_name, -1, "wmfw"); in cs35l41_request_firmware_files()
354 /* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ in cs35l41_request_firmware_files()
356 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files()
357 -1, "bin"); in cs35l41_request_firmware_files()
364 /* try cirrus/part-dspN-fwtype-sub.wmfw */ in cs35l41_request_firmware_files()
366 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
367 NULL, -1, "wmfw"); in cs35l41_request_firmware_files()
369 /* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ in cs35l41_request_firmware_files()
371 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
372 cs35l41->amp_name, -1, "bin"); in cs35l41_request_firmware_files()
374 /* try cirrus/part-dspN-fwtype-sub.bin */ in cs35l41_request_firmware_files()
376 cs35l41->acpi_subsystem_id, NULL, -1, in cs35l41_request_firmware_files()
402 if (!cs35l41->cal_data_valid) in cs35l41_hda_apply_calibration()
405 ret = cs_amp_write_cal_coeffs(&cs35l41->cs_dsp, &cs35l41_calibration_controls, in cs35l41_hda_apply_calibration()
406 &cs35l41->cal_data); in cs35l41_hda_apply_calibration()
408 dev_warn(cs35l41->dev, "Failed to apply calibration: %d\n", ret); in cs35l41_hda_apply_calibration()
410 dev_info(cs35l41->dev, "Calibration applied: R0=%d\n", cs35l41->cal_data.calR); in cs35l41_hda_apply_calibration()
418 ret = regmap_read(cs35l41->regmap, CS35L41_DIE_STS2, &tmp); in cs35l41_read_silicon_uid()
420 dev_err(cs35l41->dev, "Cannot obtain CS35L41_DIE_STS2: %d\n", ret); in cs35l41_read_silicon_uid()
427 ret = regmap_read(cs35l41->regmap, CS35L41_DIE_STS1, &tmp); in cs35l41_read_silicon_uid()
429 dev_err(cs35l41->dev, "Cannot obtain CS35L41_DIE_STS1: %d\n", ret); in cs35l41_read_silicon_uid()
435 dev_dbg(cs35l41->dev, "UniqueID = %#llx\n", *uid); in cs35l41_read_silicon_uid()
449 ret = cs_amp_get_efi_calibration_data(cs35l41->dev, silicon_uid, in cs35l41_get_calibration()
450 cs35l41->index, in cs35l41_get_calibration()
451 &cs35l41->cal_data); in cs35l41_get_calibration()
454 if ((ret == -ENOENT) || (ret == -EOVERFLOW)) in cs35l41_get_calibration()
460 cs35l41->cal_data_valid = true; in cs35l41_get_calibration()
468 cs35l41->tuning_gain = DEFAULT_AMP_GAIN_PCM; in cs35l41_set_default_tuning_params()
478 params = (void *)&firmware->data[0]; in cs35l41_read_tuning_params()
480 if (le32_to_cpu(params->size) != firmware->size) { in cs35l41_read_tuning_params()
481 dev_err(cs35l41->dev, "Wrong Size for Tuning Param file. Expected %d got %zu\n", in cs35l41_read_tuning_params()
482 le32_to_cpu(params->size), firmware->size); in cs35l41_read_tuning_params()
483 return -EINVAL; in cs35l41_read_tuning_params()
486 if (le32_to_cpu(params->version) != 1) { in cs35l41_read_tuning_params()
487 dev_err(cs35l41->dev, "Unsupported Tuning Param Version: %d\n", in cs35l41_read_tuning_params()
488 le32_to_cpu(params->version)); in cs35l41_read_tuning_params()
489 return -EINVAL; in cs35l41_read_tuning_params()
492 if (le32_to_cpu(params->signature) != CS35L41_TUNING_SIG) { in cs35l41_read_tuning_params()
493 dev_err(cs35l41->dev, in cs35l41_read_tuning_params()
495 CS35L41_TUNING_SIG, le32_to_cpu(params->signature)); in cs35l41_read_tuning_params()
496 return -EINVAL; in cs35l41_read_tuning_params()
499 end = firmware->size - sizeof(struct cs35l41_tuning_params); in cs35l41_read_tuning_params()
501 for (i = 0; i < le32_to_cpu(params->num_entries); i++) { in cs35l41_read_tuning_params()
505 return -EFAULT; in cs35l41_read_tuning_params()
507 param = (void *)¶ms->data[offset]; in cs35l41_read_tuning_params()
508 offset += le32_to_cpu(param->hdr.size); in cs35l41_read_tuning_params()
511 return -EFAULT; in cs35l41_read_tuning_params()
513 switch (le32_to_cpu(param->hdr.type)) { in cs35l41_read_tuning_params()
515 cs35l41->tuning_gain = le32_to_cpu(param->gain); in cs35l41_read_tuning_params()
516 dev_dbg(cs35l41->dev, "Applying Gain: %d\n", cs35l41->tuning_gain); in cs35l41_read_tuning_params()
533 &tuning_param_filename, cs35l41->acpi_subsystem_id); in cs35l41_load_tuning_params()
535 dev_dbg(cs35l41->dev, "Missing Tuning Param for file: %s: %d\n", tuning_filename, in cs35l41_load_tuning_params()
542 dev_err(cs35l41->dev, "Error reading Tuning Params from file: %s: %d\n", in cs35l41_load_tuning_params()
558 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_init_dsp()
563 if (!cs35l41->halo_initialized) { in cs35l41_init_dsp()
564 cs35l41_configure_cs_dsp(cs35l41->dev, cs35l41->regmap, dsp); in cs35l41_init_dsp()
565 dsp->client_ops = &client_ops; in cs35l41_init_dsp()
567 ret = cs_dsp_halo_init(&cs35l41->cs_dsp); in cs35l41_init_dsp()
570 cs35l41->halo_initialized = true; in cs35l41_init_dsp()
580 dev_dbg(cs35l41->dev, "Loading WMFW Firmware: %s\n", wmfw_filename); in cs35l41_init_dsp()
582 dev_dbg(cs35l41->dev, "Loading Coefficient File: %s\n", coeff_filename); in cs35l41_init_dsp()
585 dev_warn(cs35l41->dev, "Unable to load Tuning Parameters: %d\n", ret); in cs35l41_init_dsp()
587 dev_warn(cs35l41->dev, "No Coefficient File available.\n"); in cs35l41_init_dsp()
591 hda_cs_dsp_fw_ids[cs35l41->firmware_type]); in cs35l41_init_dsp()
610 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_shutdown_dsp()
615 dev_dbg(cs35l41->dev, "Unloaded Firmware\n"); in cs35l41_shutdown_dsp()
620 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_remove_dsp()
622 cancel_work_sync(&cs35l41->fw_load_work); in cs35l41_remove_dsp()
624 mutex_lock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
627 cs35l41->halo_initialized = false; in cs35l41_remove_dsp()
628 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
631 /* Protection release cycle to get the speaker out of Safe-Mode */
642 cs35l41_error_release(cs35l41->dev, cs35l41->regmap, cs35l41->irq_errors); in cs35l41_irq_release()
643 cs35l41->irq_errors = 0; in cs35l41_irq_release()
649 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_play_start()
653 if (cs35l41->playback_started) { in cs35l41_hda_play_start()
658 cs35l41->playback_started = true; in cs35l41_hda_play_start()
660 if (cs35l41->cs_dsp.running) { in cs35l41_hda_play_start()
663 if (cs35l41->hw_cfg.bst_type == CS35L41_INT_BOOST) in cs35l41_hda_play_start()
670 cs35l41_set_cspl_mbox_cmd(cs35l41->dev, reg, CSPL_MBOX_CMD_RESUME); in cs35l41_hda_play_start()
675 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_hda_play_start()
683 struct regmap *reg = cs35l41->regmap; in cs35l41_mute()
686 dev_dbg(dev, "Mute(%d:%d) Playback Started: %d\n", mute, cs35l41->mute_override, in cs35l41_mute()
687 cs35l41->playback_started); in cs35l41_mute()
689 if (cs35l41->playback_started) { in cs35l41_mute()
690 if (mute || cs35l41->mute_override) { in cs35l41_mute()
695 if (cs35l41->cs_dsp.running) { in cs35l41_mute()
696 dev_dbg(dev, "Using Tuned Gain: %d\n", cs35l41->tuning_gain); in cs35l41_mute()
697 amp_gain = (cs35l41->tuning_gain << CS35L41_AMP_GAIN_PCM_SHIFT) | in cs35l41_mute()
714 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_play_done()
718 cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, in cs35l41_hda_play_done()
719 &cs35l41->cs_dsp); in cs35l41_hda_play_done()
726 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_pause_start()
731 cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, in cs35l41_hda_pause_start()
732 &cs35l41->cs_dsp); in cs35l41_hda_pause_start()
738 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_pause_done()
743 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_hda_pause_done()
745 if (cs35l41->cs_dsp.running) { in cs35l41_hda_pause_done()
752 cs35l41->playback_started = false; in cs35l41_hda_pause_done()
761 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
763 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
777 * This ensures, for external boost, that all amps are in AMP_SAFE mode. in cs35l41_hda_playback_hook()
784 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
786 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
789 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
791 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
794 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
795 if (!cs35l41->cs_dsp.running && cs35l41->request_fw_load && in cs35l41_hda_playback_hook()
796 !cs35l41->fw_request_ongoing) { in cs35l41_hda_playback_hook()
798 cs35l41->fw_request_ongoing = true; in cs35l41_hda_playback_hook()
799 schedule_work(&cs35l41->fw_load_work); in cs35l41_hda_playback_hook()
801 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
821 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
823 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
836 if (!cs35l41->amp_name) { in cs35l41_hda_channel_map()
838 return -EINVAL; in cs35l41_hda_channel_map()
840 cs35l41->amp_name = devm_kasprintf(cs35l41->dev, GFP_KERNEL, "%s%d", in cs35l41_hda_channel_map()
841 channel_name[*rx_slot], cs35l41->channel_index); in cs35l41_hda_channel_map()
842 if (!cs35l41->amp_name) in cs35l41_hda_channel_map()
843 return -ENOMEM; in cs35l41_hda_channel_map()
846 return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num, in cs35l41_hda_channel_map()
855 ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, regid); in cs35l41_verify_id()
857 dev_err_probe(cs35l41->dev, ret, "Get Device ID failed\n"); in cs35l41_verify_id()
861 ret = regmap_read(cs35l41->regmap, CS35L41_REVID, reg_revid); in cs35l41_verify_id()
863 dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); in cs35l41_verify_id()
871 dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", *regid, chipid); in cs35l41_verify_id()
872 return -ENODEV; in cs35l41_verify_id()
880 mutex_lock(&cs35l41->fw_mutex); in cs35l41_ready_for_reset()
881 if (cs35l41->cs_dsp.running) { in cs35l41_ready_for_reset()
882 cs35l41->cs_dsp.running = false; in cs35l41_ready_for_reset()
883 cs35l41->cs_dsp.booted = false; in cs35l41_ready_for_reset()
885 regcache_mark_dirty(cs35l41->regmap); in cs35l41_ready_for_reset()
886 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_ready_for_reset()
895 dev_dbg(cs35l41->dev, "System Suspend Prepare\n"); in cs35l41_system_suspend_prep()
897 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_suspend_prep()
898 dev_err_once(cs35l41->dev, "System Suspend not supported\n"); in cs35l41_system_suspend_prep()
902 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_suspend_prep()
903 if (cs35l41->playback_started) in cs35l41_system_suspend_prep()
905 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_suspend_prep()
915 dev_dbg(cs35l41->dev, "System Suspend\n"); in cs35l41_system_suspend()
917 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_suspend()
918 dev_err_once(cs35l41->dev, "System Suspend not supported\n"); in cs35l41_system_suspend()
922 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_suspend()
923 if (cs35l41->playback_started) in cs35l41_system_suspend()
925 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_suspend()
938 if (cs35l41->reset_gpio) { in cs35l41_system_suspend()
939 dev_info(cs35l41->dev, "Asserting Reset\n"); in cs35l41_system_suspend()
940 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_system_suspend()
944 dev_dbg(cs35l41->dev, "System Suspended\n"); in cs35l41_system_suspend()
954 ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, int_status, in cs35l41_wait_boot_done()
957 dev_err(cs35l41->dev, "Failed waiting for OTP_BOOT_DONE\n"); in cs35l41_wait_boot_done()
961 ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status); in cs35l41_wait_boot_done()
963 dev_err(cs35l41->dev, "OTP Boot status %x error\n", in cs35l41_wait_boot_done()
966 ret = -EIO; in cs35l41_wait_boot_done()
978 dev_dbg(cs35l41->dev, "System Resume\n"); in cs35l41_system_resume()
980 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_resume()
981 dev_err_once(cs35l41->dev, "System Resume not supported\n"); in cs35l41_system_resume()
985 if (cs35l41->reset_gpio) { in cs35l41_system_resume()
986 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_system_resume()
988 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_system_resume()
993 regcache_cache_only(cs35l41->regmap, false); in cs35l41_system_resume()
995 regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); in cs35l41_system_resume()
1002 regcache_cache_only(cs35l41->regmap, true); in cs35l41_system_resume()
1010 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_resume()
1012 if (cs35l41->request_fw_load && !cs35l41->fw_request_ongoing) { in cs35l41_system_resume()
1013 cs35l41->fw_request_ongoing = true; in cs35l41_system_resume()
1014 schedule_work(&cs35l41->fw_load_work); in cs35l41_system_resume()
1016 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_resume()
1025 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) in cs35l41_runtime_idle()
1026 return -EBUSY; /* suspend not supported yet on this model */ in cs35l41_runtime_idle()
1035 dev_dbg(cs35l41->dev, "Runtime Suspend\n"); in cs35l41_runtime_suspend()
1037 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_runtime_suspend()
1038 dev_dbg(cs35l41->dev, "Runtime Suspend not supported\n"); in cs35l41_runtime_suspend()
1042 mutex_lock(&cs35l41->fw_mutex); in cs35l41_runtime_suspend()
1044 if (cs35l41->cs_dsp.running) { in cs35l41_runtime_suspend()
1045 ret = cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, in cs35l41_runtime_suspend()
1046 cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
1050 cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
1053 regcache_cache_only(cs35l41->regmap, true); in cs35l41_runtime_suspend()
1054 regcache_mark_dirty(cs35l41->regmap); in cs35l41_runtime_suspend()
1057 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_runtime_suspend()
1068 dev_dbg(cs35l41->dev, "Runtime Resume\n"); in cs35l41_runtime_resume()
1070 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_runtime_resume()
1071 dev_dbg(cs35l41->dev, "Runtime Resume not supported\n"); in cs35l41_runtime_resume()
1075 mutex_lock(&cs35l41->fw_mutex); in cs35l41_runtime_resume()
1077 regcache_cache_only(cs35l41->regmap, false); in cs35l41_runtime_resume()
1079 if (cs35l41->cs_dsp.running) { in cs35l41_runtime_resume()
1080 ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1082 dev_warn(cs35l41->dev, "Unable to exit Hibernate."); in cs35l41_runtime_resume()
1091 /* Test key needs to be unlocked to allow the OTP settings to re-apply */ in cs35l41_runtime_resume()
1092 cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1093 ret = regcache_sync(cs35l41->regmap); in cs35l41_runtime_resume()
1094 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
1096 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); in cs35l41_runtime_resume()
1100 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_runtime_resume()
1101 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); in cs35l41_runtime_resume()
1103 dev_dbg(cs35l41->dev, "CS35L41 Resumed (%x), Revision: %02X\n", regid, reg_revid); in cs35l41_runtime_resume()
1106 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_runtime_resume()
1117 if (cs35l41->bypass_fw) { in cs35l41_smart_amp()
1118 dev_warn(cs35l41->dev, "Bypassing Firmware.\n"); in cs35l41_smart_amp()
1124 dev_warn(cs35l41->dev, "Cannot Initialize Firmware. Error: %d\n", ret); in cs35l41_smart_amp()
1128 ret = cs35l41_write_fs_errata(cs35l41->dev, cs35l41->regmap); in cs35l41_smart_amp()
1130 dev_err(cs35l41->dev, "Cannot Write FS Errata: %d\n", ret); in cs35l41_smart_amp()
1134 ret = cs_dsp_run(&cs35l41->cs_dsp); in cs35l41_smart_amp()
1136 dev_err(cs35l41->dev, "Fail to start dsp: %d\n", ret); in cs35l41_smart_amp()
1142 1000, 15000, false, &cs35l41->cs_dsp, HALO_STATE_DSP_CTL_NAME, in cs35l41_smart_amp()
1147 dev_err(cs35l41->dev, "Timeout waiting for HALO Core to start. State: %u\n", in cs35l41_smart_amp()
1152 ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status); in cs35l41_smart_amp()
1154 dev_err(cs35l41->dev, in cs35l41_smart_amp()
1164 dev_err(cs35l41->dev, "Firmware status is invalid: %u\n", in cs35l41_smart_amp()
1166 ret = -EINVAL; in cs35l41_smart_amp()
1170 ret = cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, CSPL_MBOX_CMD_PAUSE); in cs35l41_smart_amp()
1172 dev_err(cs35l41->dev, "Error waiting for DSP to pause: %u\n", ret); in cs35l41_smart_amp()
1176 dev_info(cs35l41->dev, "Firmware Loaded - Type: %s, Gain: %d\n", in cs35l41_smart_amp()
1177 hda_cs_dsp_fw_ids[cs35l41->firmware_type], cs35l41->tuning_gain); in cs35l41_smart_amp()
1188 if (cs35l41->cs_dsp.running && !load) { in cs35l41_load_firmware()
1189 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); in cs35l41_load_firmware()
1191 } else if (!cs35l41->cs_dsp.running && load) { in cs35l41_load_firmware()
1192 dev_dbg(cs35l41->dev, "Loading Firmware\n"); in cs35l41_load_firmware()
1195 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); in cs35l41_load_firmware()
1204 ucontrol->value.integer.value[0] = cs35l41->request_fw_load; in cs35l41_fw_load_ctl_get()
1213 ucontrol->value.integer.value[0] = cs35l41->mute_override; in cs35l41_mute_override_ctl_get()
1221 pm_runtime_get_sync(cs35l41->dev); in cs35l41_fw_load_work()
1223 mutex_lock(&cs35l41->fw_mutex); in cs35l41_fw_load_work()
1226 if (cs35l41->playback_started) in cs35l41_fw_load_work()
1227 dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); in cs35l41_fw_load_work()
1229 cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); in cs35l41_fw_load_work()
1231 cs35l41->fw_request_ongoing = false; in cs35l41_fw_load_work()
1232 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_fw_load_work()
1234 pm_runtime_mark_last_busy(cs35l41->dev); in cs35l41_fw_load_work()
1235 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_fw_load_work()
1243 if (cs35l41->request_fw_load == ucontrol->value.integer.value[0]) in cs35l41_fw_load_ctl_put()
1246 if (cs35l41->fw_request_ongoing) { in cs35l41_fw_load_ctl_put()
1247 dev_dbg(cs35l41->dev, "Existing request not complete\n"); in cs35l41_fw_load_ctl_put()
1248 return -EBUSY; in cs35l41_fw_load_ctl_put()
1252 if (cs35l41->playback_started) { in cs35l41_fw_load_ctl_put()
1253 dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); in cs35l41_fw_load_ctl_put()
1254 return -EBUSY; in cs35l41_fw_load_ctl_put()
1257 cs35l41->fw_request_ongoing = true; in cs35l41_fw_load_ctl_put()
1258 cs35l41->request_fw_load = ucontrol->value.integer.value[0]; in cs35l41_fw_load_ctl_put()
1259 schedule_work(&cs35l41->fw_load_work); in cs35l41_fw_load_ctl_put()
1269 ucontrol->value.enumerated.item[0] = cs35l41->firmware_type; in cs35l41_fw_type_ctl_get()
1279 if (ucontrol->value.enumerated.item[0] < HDA_CS_DSP_NUM_FW) { in cs35l41_fw_type_ctl_put()
1280 if (cs35l41->firmware_type != ucontrol->value.enumerated.item[0]) { in cs35l41_fw_type_ctl_put()
1281 cs35l41->firmware_type = ucontrol->value.enumerated.item[0]; in cs35l41_fw_type_ctl_put()
1288 return -EINVAL; in cs35l41_fw_type_ctl_put()
1325 cs35l41->amp_name); in cs35l41_create_controls()
1327 cs35l41->amp_name); in cs35l41_create_controls()
1329 cs35l41->amp_name); in cs35l41_create_controls()
1331 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_type_ctl, cs35l41)); in cs35l41_create_controls()
1333 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", fw_type_ctl.name, ret); in cs35l41_create_controls()
1337 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_type_ctl.name); in cs35l41_create_controls()
1339 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_load_ctl, cs35l41)); in cs35l41_create_controls()
1341 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", fw_load_ctl.name, ret); in cs35l41_create_controls()
1345 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_load_ctl.name); in cs35l41_create_controls()
1347 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&mute_override_ctl, cs35l41)); in cs35l41_create_controls()
1349 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", mute_override_ctl.name, in cs35l41_create_controls()
1354 dev_dbg(cs35l41->dev, "Added Control %s\n", mute_override_ctl.name); in cs35l41_create_controls()
1372 int mute = -ENODEV; in cs35l41_get_acpi_mute_state()
1378 mute = *ret->buffer.pointer; in cs35l41_get_acpi_mute_state()
1379 dev_dbg(cs35l41->dev, "CS35L41_DSM_GET_MUTE: %d\n", mute); in cs35l41_get_acpi_mute_state()
1382 dev_dbg(cs35l41->dev, "%s: %d\n", __func__, mute); in cs35l41_get_acpi_mute_state()
1397 dev_warn(cs35l41->dev, "Unable to retrieve mute state: %d\n", mute); in cs35l41_acpi_device_notify()
1401 dev_dbg(cs35l41->dev, "Requesting mute value: %d\n", mute); in cs35l41_acpi_device_notify()
1402 cs35l41->mute_override = (mute > 0); in cs35l41_acpi_device_notify()
1403 cs35l41_mute(cs35l41->dev, cs35l41->mute_override); in cs35l41_acpi_device_notify()
1414 comp = hda_component_from_index(parent, cs35l41->index); in cs35l41_hda_bind()
1416 return -EINVAL; in cs35l41_hda_bind()
1418 if (comp->dev) in cs35l41_hda_bind()
1419 return -EBUSY; in cs35l41_hda_bind()
1423 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_bind()
1425 comp->dev = dev; in cs35l41_hda_bind()
1426 cs35l41->codec = parent->codec; in cs35l41_hda_bind()
1427 if (!cs35l41->acpi_subsystem_id) in cs35l41_hda_bind()
1428 cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", in cs35l41_hda_bind()
1429 cs35l41->codec->core.subsystem_id); in cs35l41_hda_bind()
1431 strscpy(comp->name, dev_name(dev), sizeof(comp->name)); in cs35l41_hda_bind()
1433 cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT; in cs35l41_hda_bind()
1436 dev_dbg(cs35l41->dev, "Firmware Autostart.\n"); in cs35l41_hda_bind()
1437 cs35l41->request_fw_load = true; in cs35l41_hda_bind()
1439 dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n"); in cs35l41_hda_bind()
1441 dev_dbg(cs35l41->dev, "Firmware Autostart is disabled.\n"); in cs35l41_hda_bind()
1446 comp->playback_hook = cs35l41_hda_playback_hook; in cs35l41_hda_bind()
1447 comp->pre_playback_hook = cs35l41_hda_pre_playback_hook; in cs35l41_hda_bind()
1448 comp->post_playback_hook = cs35l41_hda_post_playback_hook; in cs35l41_hda_bind()
1449 comp->acpi_notify = cs35l41_acpi_device_notify; in cs35l41_hda_bind()
1450 comp->adev = cs35l41->dacpi; in cs35l41_hda_bind()
1452 comp->acpi_notifications_supported = cs35l41_dsm_supported(acpi_device_handle(comp->adev), in cs35l41_hda_bind()
1455 cs35l41->mute_override = cs35l41_get_acpi_mute_state(cs35l41, in cs35l41_hda_bind()
1456 acpi_device_handle(cs35l41->dacpi)) > 0; in cs35l41_hda_bind()
1458 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_bind()
1461 if (!device_link_add(&cs35l41->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) in cs35l41_hda_bind()
1468 dev_info(cs35l41->dev, in cs35l41_hda_bind()
1469 "CS35L41 Bound - SSID: %s, BST: %d, VSPK: %d, CH: %c, FW EN: %d, SPKID: %d\n", in cs35l41_hda_bind()
1470 cs35l41->acpi_subsystem_id, cs35l41->hw_cfg.bst_type, in cs35l41_hda_bind()
1471 cs35l41->hw_cfg.gpio1.func == CS35l41_VSPK_SWITCH, in cs35l41_hda_bind()
1472 cs35l41->hw_cfg.spk_pos ? 'R' : 'L', in cs35l41_hda_bind()
1473 cs35l41->cs_dsp.running, cs35l41->speaker_id); in cs35l41_hda_bind()
1485 comp = hda_component_from_index(parent, cs35l41->index); in cs35l41_hda_unbind()
1489 if (comp->dev == dev) { in cs35l41_hda_unbind()
1491 device_link_remove(&cs35l41->codec->core.dev, cs35l41->dev); in cs35l41_hda_unbind()
1506 dev_crit_ratelimited(cs35l41->dev, "LBST Error\n"); in cs35l41_bst_short_err()
1507 set_bit(CS35L41_BST_SHORT_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_short_err()
1516 dev_crit_ratelimited(cs35l41->dev, "DCM VBST Under Voltage Error\n"); in cs35l41_bst_dcm_uvp_err()
1517 set_bit(CS35L41_BST_UVP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_dcm_uvp_err()
1526 dev_crit_ratelimited(cs35l41->dev, "VBST Over Voltage error\n"); in cs35l41_bst_ovp_err()
1527 set_bit(CS35L41_BST_OVP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_ovp_err()
1536 dev_crit_ratelimited(cs35l41->dev, "Over temperature error\n"); in cs35l41_temp_err()
1537 set_bit(CS35L41_TEMP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_temp_err()
1546 dev_crit_ratelimited(cs35l41->dev, "Over temperature warning\n"); in cs35l41_temp_warn()
1547 set_bit(CS35L41_TEMP_WARN_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_temp_warn()
1556 dev_crit_ratelimited(cs35l41->dev, "Amp short error\n"); in cs35l41_amp_short()
1557 set_bit(CS35L41_AMP_SHORT_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_amp_short()
1563 CS35L41_IRQ(BST_OVP_ERR, "Boost Overvoltage Error", cs35l41_bst_ovp_err),
1564 CS35L41_IRQ(BST_DCM_UVP_ERR, "Boost Undervoltage Error", cs35l41_bst_dcm_uvp_err),
1565 CS35L41_IRQ(BST_SHORT_ERR, "Boost Inductor Short Error", cs35l41_bst_short_err),
1597 if (!cs35l41->irq) { in cs35l41_configure_interrupt()
1598 dev_warn(cs35l41->dev, "No Interrupt Found"); in cs35l41_configure_interrupt()
1602 ret = devm_regmap_add_irq_chip(cs35l41->dev, cs35l41->regmap, cs35l41->irq, in cs35l41_configure_interrupt()
1604 0, &cs35l41_regmap_irq_chip, &cs35l41->irq_data); in cs35l41_configure_interrupt()
1606 dev_dbg(cs35l41->dev, "Unable to add IRQ Chip: %d.", ret); in cs35l41_configure_interrupt()
1611 irq = regmap_irq_get_virq(cs35l41->irq_data, cs35l41_irqs[i].irq); in cs35l41_configure_interrupt()
1614 dev_dbg(cs35l41->dev, "Unable to map IRQ %s: %d.", cs35l41_irqs[i].name, in cs35l41_configure_interrupt()
1619 ret = devm_request_threaded_irq(cs35l41->dev, irq, NULL, in cs35l41_configure_interrupt()
1624 dev_dbg(cs35l41->dev, "Unable to allocate IRQ %s:: %d.", in cs35l41_configure_interrupt()
1631 dev_warn(cs35l41->dev, in cs35l41_configure_interrupt()
1637 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_hda_apply_properties()
1642 if (!cs35l41->hw_cfg.valid) in cs35l41_hda_apply_properties()
1643 return -EINVAL; in cs35l41_hda_apply_properties()
1645 ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1649 if (hw_cfg->gpio1.valid) { in cs35l41_hda_apply_properties()
1650 switch (hw_cfg->gpio1.func) { in cs35l41_hda_apply_properties()
1654 hw_cfg->gpio1.func = CS35L41_GPIO1_GPIO; in cs35l41_hda_apply_properties()
1655 hw_cfg->gpio1.out_en = true; in cs35l41_hda_apply_properties()
1658 hw_cfg->gpio1.func = CS35L41_GPIO1_MDSYNC; in cs35l41_hda_apply_properties()
1661 dev_err(cs35l41->dev, "Invalid function %d for GPIO1\n", in cs35l41_hda_apply_properties()
1662 hw_cfg->gpio1.func); in cs35l41_hda_apply_properties()
1663 return -EINVAL; in cs35l41_hda_apply_properties()
1667 if (hw_cfg->gpio2.valid) { in cs35l41_hda_apply_properties()
1668 switch (hw_cfg->gpio2.func) { in cs35l41_hda_apply_properties()
1673 hw_cfg->gpio2.func = CS35L41_GPIO2_INT_OPEN_DRAIN; in cs35l41_hda_apply_properties()
1676 dev_err(cs35l41->dev, "Invalid GPIO2 function %d\n", hw_cfg->gpio2.func); in cs35l41_hda_apply_properties()
1677 return -EINVAL; in cs35l41_hda_apply_properties()
1681 irq_pol = cs35l41_gpio_config(cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1686 return cs35l41_hda_channel_map(cs35l41->dev, 0, NULL, 1, &hw_cfg->spk_pos); in cs35l41_hda_apply_properties()
1692 int speaker_id = -ENODEV; in cs35l41_get_speaker_id()
1711 count = gpiod_count(dev, "spk-id"); in cs35l41_get_speaker_id()
1718 return -EINVAL; in cs35l41_get_speaker_id()
1723 speaker_id_desc = gpiod_get_index(dev, "spk-id", i + base_index, in cs35l41_get_speaker_id()
1745 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_hda_parse_acpi()
1751 property = "cirrus,dev-index"; in cs35l41_hda_parse_acpi()
1757 ret = -EINVAL; in cs35l41_hda_parse_acpi()
1766 cs35l41->index = -1; in cs35l41_hda_parse_acpi()
1769 cs35l41->index = i; in cs35l41_hda_parse_acpi()
1773 if (cs35l41->index == -1) { in cs35l41_hda_parse_acpi()
1774 dev_err(cs35l41->dev, "No index found in %s\n", property); in cs35l41_hda_parse_acpi()
1775 ret = -ENODEV; in cs35l41_hda_parse_acpi()
1782 cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(cs35l41->dacpi), "reset", in cs35l41_hda_parse_acpi()
1783 cs35l41->index, GPIOD_OUT_LOW, in cs35l41_hda_parse_acpi()
1784 "cs35l41-reset"); in cs35l41_hda_parse_acpi()
1786 property = "cirrus,speaker-position"; in cs35l41_hda_parse_acpi()
1790 hw_cfg->spk_pos = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1792 cs35l41->channel_index = 0; in cs35l41_hda_parse_acpi()
1793 for (i = 0; i < cs35l41->index; i++) in cs35l41_hda_parse_acpi()
1794 if (values[i] == hw_cfg->spk_pos) in cs35l41_hda_parse_acpi()
1795 cs35l41->channel_index++; in cs35l41_hda_parse_acpi()
1797 property = "cirrus,gpio1-func"; in cs35l41_hda_parse_acpi()
1801 hw_cfg->gpio1.func = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1802 hw_cfg->gpio1.valid = true; in cs35l41_hda_parse_acpi()
1804 property = "cirrus,gpio2-func"; in cs35l41_hda_parse_acpi()
1808 hw_cfg->gpio2.func = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1809 hw_cfg->gpio2.valid = true; in cs35l41_hda_parse_acpi()
1811 property = "cirrus,boost-peak-milliamp"; in cs35l41_hda_parse_acpi()
1814 hw_cfg->bst_ipk = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1816 hw_cfg->bst_ipk = -1; in cs35l41_hda_parse_acpi()
1818 property = "cirrus,boost-ind-nanohenry"; in cs35l41_hda_parse_acpi()
1821 hw_cfg->bst_ind = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1823 hw_cfg->bst_ind = -1; in cs35l41_hda_parse_acpi()
1825 property = "cirrus,boost-cap-microfarad"; in cs35l41_hda_parse_acpi()
1828 hw_cfg->bst_cap = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1830 hw_cfg->bst_cap = -1; in cs35l41_hda_parse_acpi()
1832 cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, cs35l41->index, nval, -1); in cs35l41_hda_parse_acpi()
1834 if (hw_cfg->bst_ind > 0 || hw_cfg->bst_cap > 0 || hw_cfg->bst_ipk > 0) in cs35l41_hda_parse_acpi()
1835 hw_cfg->bst_type = CS35L41_INT_BOOST; in cs35l41_hda_parse_acpi()
1837 hw_cfg->bst_type = CS35L41_EXT_BOOST; in cs35l41_hda_parse_acpi()
1839 hw_cfg->valid = true; in cs35l41_hda_parse_acpi()
1843 dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); in cs35l41_hda_parse_acpi()
1844 hw_cfg->valid = false; in cs35l41_hda_parse_acpi()
1845 hw_cfg->gpio1.valid = false; in cs35l41_hda_parse_acpi()
1846 hw_cfg->gpio2.valid = false; in cs35l41_hda_parse_acpi()
1847 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_parse_acpi()
1860 adev = acpi_dev_get_first_match_dev(hid, NULL, -1); in cs35l41_hda_read_acpi()
1862 dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid); in cs35l41_hda_read_acpi()
1863 return -ENODEV; in cs35l41_hda_read_acpi()
1866 cs35l41->dacpi = adev; in cs35l41_hda_read_acpi()
1872 cs35l41->acpi_subsystem_id = sub; in cs35l41_hda_read_acpi()
1876 dev_info(cs35l41->dev, "Using extra _DSD properties, bypassing _DSD in ACPI\n"); in cs35l41_hda_read_acpi()
1888 cs35l41->bypass_fw = false; in cs35l41_hda_read_acpi()
1889 if (cs35l41->control_bus == SPI) { in cs35l41_hda_read_acpi()
1890 spi = to_spi_device(cs35l41->dev); in cs35l41_hda_read_acpi()
1891 if (spi->max_speed_hz < CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ) { in cs35l41_hda_read_acpi()
1892 dev_warn(cs35l41->dev, in cs35l41_hda_read_acpi()
1894 spi->max_speed_hz); in cs35l41_hda_read_acpi()
1895 cs35l41->bypass_fw = true; in cs35l41_hda_read_acpi()
1917 return -ENOMEM; in cs35l41_hda_probe()
1919 cs35l41->dev = dev; in cs35l41_hda_probe()
1920 cs35l41->irq = irq; in cs35l41_hda_probe()
1921 cs35l41->regmap = regmap; in cs35l41_hda_probe()
1922 cs35l41->control_bus = control_bus; in cs35l41_hda_probe()
1927 return dev_err_probe(cs35l41->dev, ret, "Platform not supported\n"); in cs35l41_hda_probe()
1929 if (IS_ERR(cs35l41->reset_gpio)) { in cs35l41_hda_probe()
1930 ret = PTR_ERR(cs35l41->reset_gpio); in cs35l41_hda_probe()
1931 cs35l41->reset_gpio = NULL; in cs35l41_hda_probe()
1932 if (ret == -EBUSY) { in cs35l41_hda_probe()
1933 dev_info(cs35l41->dev, "Reset line busy, assuming shared reset\n"); in cs35l41_hda_probe()
1935 dev_err_probe(cs35l41->dev, ret, "Failed to get reset GPIO\n"); in cs35l41_hda_probe()
1939 if (cs35l41->reset_gpio) { in cs35l41_hda_probe()
1940 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_probe()
1942 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_hda_probe()
1946 regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); in cs35l41_hda_probe()
1957 ret = cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
1961 ret = cs35l41_register_errata_patch(cs35l41->dev, cs35l41->regmap, reg_revid); in cs35l41_hda_probe()
1965 ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
1967 dev_err_probe(cs35l41->dev, ret, "OTP Unpack failed\n"); in cs35l41_hda_probe()
1971 ret = cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
1976 if (ret && ret != -ENOENT) in cs35l41_hda_probe()
1979 cs35l41_mute(cs35l41->dev, true); in cs35l41_hda_probe()
1981 INIT_WORK(&cs35l41->fw_load_work, cs35l41_fw_load_work); in cs35l41_hda_probe()
1982 mutex_init(&cs35l41->fw_mutex); in cs35l41_hda_probe()
1984 pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); in cs35l41_hda_probe()
1985 pm_runtime_use_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
1986 pm_runtime_mark_last_busy(cs35l41->dev); in cs35l41_hda_probe()
1987 pm_runtime_set_active(cs35l41->dev); in cs35l41_hda_probe()
1988 pm_runtime_get_noresume(cs35l41->dev); in cs35l41_hda_probe()
1989 pm_runtime_enable(cs35l41->dev); in cs35l41_hda_probe()
1995 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
1997 ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops); in cs35l41_hda_probe()
1999 dev_err_probe(cs35l41->dev, ret, "Register component failed\n"); in cs35l41_hda_probe()
2003 dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", regid, reg_revid); in cs35l41_hda_probe()
2008 pm_runtime_dont_use_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
2009 pm_runtime_disable(cs35l41->dev); in cs35l41_hda_probe()
2010 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_hda_probe()
2013 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) in cs35l41_hda_probe()
2014 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_probe()
2015 gpiod_put(cs35l41->reset_gpio); in cs35l41_hda_probe()
2016 gpiod_put(cs35l41->cs_gpio); in cs35l41_hda_probe()
2017 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_probe()
2018 kfree(cs35l41->acpi_subsystem_id); in cs35l41_hda_probe()
2028 component_del(cs35l41->dev, &cs35l41_hda_comp_ops); in cs35l41_hda_remove()
2030 pm_runtime_get_sync(cs35l41->dev); in cs35l41_hda_remove()
2031 pm_runtime_dont_use_autosuspend(cs35l41->dev); in cs35l41_hda_remove()
2032 pm_runtime_disable(cs35l41->dev); in cs35l41_hda_remove()
2034 if (cs35l41->halo_initialized) in cs35l41_hda_remove()
2037 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_remove()
2039 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_hda_remove()
2041 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) in cs35l41_hda_remove()
2042 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_remove()
2043 gpiod_put(cs35l41->reset_gpio); in cs35l41_hda_remove()
2044 gpiod_put(cs35l41->cs_gpio); in cs35l41_hda_remove()
2045 kfree(cs35l41->acpi_subsystem_id); in cs35l41_hda_remove()