Lines Matching +full:imon +full:- +full:slot +full:- +full:no
1 // SPDX-License-Identifier: GPL-2.0
37 #define CS35L41_UUID "50d90cdc-3de4-4f18-b528-c7fe3b71f40d"
53 { CS35L41_SP_HIZ_CTRL, 0x00000002 }, // Hi-Z unused
54 { CS35L41_SP_TX_WL, 0x00000018 }, // 24 cycles/slot
55 { CS35L41_SP_RX_WL, 0x00000018 }, // 24 cycles/slot
58 { CS35L41_ASP_TX2_SRC, 0x00000019 }, // ASPTX2 SRC = IMON
64 { CS35L41_DSP1_RX4_SRC, 0x00000019 }, // DSP1RX4 SRC = IMON
75 { CS35L41_SP_HIZ_CTRL, 0x00000003 }, // Hi-Z unused/disabled
76 { CS35L41_SP_TX_WL, 0x00000018 }, // 24 cycles/slot
77 { CS35L41_SP_RX_WL, 0x00000018 }, // 24 cycles/slot
80 { CS35L41_ASP_TX2_SRC, 0x00000019 }, // ASPTX2 SRC = IMON
86 { CS35L41_DSP1_RX4_SRC, 0x00000019 }, // DSP1RX4 SRC = IMON
109 info.device_name = cs35l41->amp_name; in cs35l41_add_controls()
110 info.fw_type = cs35l41->firmware_type; in cs35l41_add_controls()
111 info.card = cs35l41->codec->card; in cs35l41_add_controls()
113 hda_cs_dsp_add_controls(&cs35l41->cs_dsp, &info); in cs35l41_add_controls()
125 const char * const dsp_name = cs35l41->cs_dsp.name; in cs35l41_request_firmware_file()
129 if (spkid > -1 && ssid && amp_name) in cs35l41_request_firmware_file()
130 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-spkid%d-%s.%s", dir, CS35L41_PART, in cs35l41_request_firmware_file()
131 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
133 else if (spkid > -1 && ssid) in cs35l41_request_firmware_file()
134 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-spkid%d.%s", dir, CS35L41_PART, in cs35l41_request_firmware_file()
135 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
138 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s-%s.%s", dir, CS35L41_PART, in cs35l41_request_firmware_file()
139 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
142 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, CS35L41_PART, in cs35l41_request_firmware_file()
143 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
146 *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, CS35L41_PART, in cs35l41_request_firmware_file()
147 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
151 return -ENOMEM; in cs35l41_request_firmware_file()
154 * Make sure that filename is lower-case and any non alpha-numeric in cs35l41_request_firmware_file()
163 *s = '-'; in cs35l41_request_firmware_file()
167 ret = firmware_request_nowarn(firmware, *filename, cs35l41->dev); in cs35l41_request_firmware_file()
169 dev_dbg(cs35l41->dev, "Failed to request '%s'\n", *filename); in cs35l41_request_firmware_file()
185 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.wmfw */ in cs35l41_request_firmware_files_spkid()
188 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
189 cs35l41->speaker_id, "wmfw"); in cs35l41_request_firmware_files_spkid()
191 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
194 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
195 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
202 /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ in cs35l41_request_firmware_files_spkid()
204 CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
205 cs35l41->amp_name, -1, "wmfw"); in cs35l41_request_firmware_files_spkid()
207 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
210 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files_spkid()
211 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
218 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.wmfw */ in cs35l41_request_firmware_files_spkid()
220 CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
221 NULL, cs35l41->speaker_id, "wmfw"); in cs35l41_request_firmware_files_spkid()
223 /* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ in cs35l41_request_firmware_files_spkid()
226 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
227 cs35l41->amp_name, cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
229 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ in cs35l41_request_firmware_files_spkid()
232 cs35l41->acpi_subsystem_id, NULL, in cs35l41_request_firmware_files_spkid()
233 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
240 /* try cirrus/part-dspN-fwtype-sub.wmfw */ in cs35l41_request_firmware_files_spkid()
242 CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
243 NULL, -1, "wmfw"); in cs35l41_request_firmware_files_spkid()
245 /* 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()
251 /* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ in cs35l41_request_firmware_files_spkid()
254 cs35l41->acpi_subsystem_id, NULL, in cs35l41_request_firmware_files_spkid()
255 cs35l41->speaker_id, "bin"); in cs35l41_request_firmware_files_spkid()
276 dev_warn(cs35l41->dev, "Falling back to default firmware.\n"); in cs35l41_fallback_firmware_file()
278 /* fallback try cirrus/part-dspN-fwtype.wmfw */ in cs35l41_fallback_firmware_file()
280 CS35L41_FIRMWARE_ROOT, NULL, NULL, -1, "wmfw"); in cs35l41_fallback_firmware_file()
284 /* fallback try cirrus/part-dspN-fwtype.bin */ in cs35l41_fallback_firmware_file()
286 CS35L41_FIRMWARE_ROOT, NULL, NULL, -1, "bin"); in cs35l41_fallback_firmware_file()
295 dev_warn(cs35l41->dev, "Unable to find firmware and tuning\n"); in cs35l41_fallback_firmware_file()
307 if (cs35l41->speaker_id > -1) { in cs35l41_request_firmware_files()
313 /* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ in cs35l41_request_firmware_files()
315 CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
316 cs35l41->amp_name, -1, "wmfw"); in cs35l41_request_firmware_files()
318 /* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ in cs35l41_request_firmware_files()
321 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files()
322 -1, "bin"); in cs35l41_request_firmware_files()
329 /* try cirrus/part-dspN-fwtype-sub.wmfw */ in cs35l41_request_firmware_files()
331 CS35L41_FIRMWARE_ROOT, cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
332 NULL, -1, "wmfw"); in cs35l41_request_firmware_files()
334 /* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ in cs35l41_request_firmware_files()
337 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
338 cs35l41->amp_name, -1, "bin"); in cs35l41_request_firmware_files()
340 /* try cirrus/part-dspN-fwtype-sub.bin */ in cs35l41_request_firmware_files()
343 cs35l41->acpi_subsystem_id, NULL, -1, in cs35l41_request_firmware_files()
370 ret = hda_cs_dsp_write_ctl(&cs35l41->cs_dsp, CAL_AMBIENT_DSP_CTL_NAME, CAL_DSP_CTL_TYPE, in cs35l41_apply_calibration()
373 dev_err(cs35l41->dev, "Cannot Write Control: %s - %d\n", CAL_AMBIENT_DSP_CTL_NAME, in cs35l41_apply_calibration()
377 ret = hda_cs_dsp_write_ctl(&cs35l41->cs_dsp, CAL_R_DSP_CTL_NAME, CAL_DSP_CTL_TYPE, in cs35l41_apply_calibration()
380 dev_err(cs35l41->dev, "Cannot Write Control: %s - %d\n", CAL_R_DSP_CTL_NAME, ret); in cs35l41_apply_calibration()
383 ret = hda_cs_dsp_write_ctl(&cs35l41->cs_dsp, CAL_STATUS_DSP_CTL_NAME, CAL_DSP_CTL_TYPE, in cs35l41_apply_calibration()
386 dev_err(cs35l41->dev, "Cannot Write Control: %s - %d\n", CAL_STATUS_DSP_CTL_NAME, in cs35l41_apply_calibration()
390 ret = hda_cs_dsp_write_ctl(&cs35l41->cs_dsp, CAL_CHECKSUM_DSP_CTL_NAME, CAL_DSP_CTL_TYPE, in cs35l41_apply_calibration()
393 dev_err(cs35l41->dev, "Cannot Write Control: %s - %d\n", CAL_CHECKSUM_DSP_CTL_NAME, in cs35l41_apply_calibration()
417 ret = -ENODEV; in cs35l41_save_calibration()
421 return -ENOMEM; in cs35l41_save_calibration()
426 dev_dbg(cs35l41->dev, "Calibration: Size=%d, Amp Count=%d\n", in cs35l41_save_calibration()
427 efi_data->size, efi_data->count); in cs35l41_save_calibration()
428 if (efi_data->count > cs35l41->index) { in cs35l41_save_calibration()
429 cl = &efi_data->data[cs35l41->index]; in cs35l41_save_calibration()
430 dev_dbg(cs35l41->dev, in cs35l41_save_calibration()
432 cl->calAmbient, cl->calStatus, cl->calR); in cs35l41_save_calibration()
436 cpu_to_be32(cl->calAmbient), in cs35l41_save_calibration()
437 cpu_to_be32(cl->calR), in cs35l41_save_calibration()
438 cpu_to_be32(cl->calStatus), in cs35l41_save_calibration()
439 cpu_to_be32(cl->calR + 1)); in cs35l41_save_calibration()
449 dev_warn(cs35l41->dev, "Calibration not supported without EFI support.\n"); in cs35l41_save_calibration()
458 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_init_dsp()
463 if (!cs35l41->halo_initialized) { in cs35l41_init_dsp()
464 cs35l41_configure_cs_dsp(cs35l41->dev, cs35l41->regmap, dsp); in cs35l41_init_dsp()
465 dsp->client_ops = &client_ops; in cs35l41_init_dsp()
467 ret = cs_dsp_halo_init(&cs35l41->cs_dsp); in cs35l41_init_dsp()
470 cs35l41->halo_initialized = true; in cs35l41_init_dsp()
478 dev_dbg(cs35l41->dev, "Loading WMFW Firmware: %s\n", wmfw_filename); in cs35l41_init_dsp()
480 dev_dbg(cs35l41->dev, "Loading Coefficient File: %s\n", coeff_filename); in cs35l41_init_dsp()
482 dev_warn(cs35l41->dev, "No Coefficient File available.\n"); in cs35l41_init_dsp()
485 hda_cs_dsp_fw_ids[cs35l41->firmware_type]); in cs35l41_init_dsp()
504 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_shutdown_dsp()
508 dev_dbg(cs35l41->dev, "Unloaded Firmware\n"); in cs35l41_shutdown_dsp()
513 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_remove_dsp()
515 cancel_work_sync(&cs35l41->fw_load_work); in cs35l41_remove_dsp()
517 mutex_lock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
520 cs35l41->halo_initialized = false; in cs35l41_remove_dsp()
521 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
524 /* Protection release cycle to get the speaker out of Safe-Mode */
535 cs35l41_error_release(cs35l41->dev, cs35l41->regmap, cs35l41->irq_errors); in cs35l41_irq_release()
536 cs35l41->irq_errors = 0; in cs35l41_irq_release()
542 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_play_start()
546 if (cs35l41->playback_started) { in cs35l41_hda_play_start()
551 cs35l41->playback_started = true; in cs35l41_hda_play_start()
553 if (cs35l41->cs_dsp.running) { in cs35l41_hda_play_start()
559 cs35l41_set_cspl_mbox_cmd(cs35l41->dev, reg, CSPL_MBOX_CMD_RESUME); in cs35l41_hda_play_start()
564 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_hda_play_start()
572 struct regmap *reg = cs35l41->regmap; in cs35l41_mute()
574 dev_dbg(dev, "Mute(%d:%d) Playback Started: %d\n", mute, cs35l41->mute_override, in cs35l41_mute()
575 cs35l41->playback_started); in cs35l41_mute()
577 if (cs35l41->playback_started) { in cs35l41_mute()
578 if (mute || cs35l41->mute_override) { in cs35l41_mute()
583 if (cs35l41->cs_dsp.running) { in cs35l41_mute()
597 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_play_done()
601 cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 1, in cs35l41_hda_play_done()
602 &cs35l41->cs_dsp); in cs35l41_hda_play_done()
609 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_pause_start()
614 cs35l41_global_enable(dev, reg, cs35l41->hw_cfg.bst_type, 0, in cs35l41_hda_pause_start()
615 &cs35l41->cs_dsp); in cs35l41_hda_pause_start()
621 struct regmap *reg = cs35l41->regmap; in cs35l41_hda_pause_done()
626 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_hda_pause_done()
628 if (cs35l41->cs_dsp.running) { in cs35l41_hda_pause_done()
635 cs35l41->playback_started = false; in cs35l41_hda_pause_done()
644 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
646 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
667 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
669 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
672 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
674 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
677 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
678 if (!cs35l41->cs_dsp.running && cs35l41->request_fw_load && in cs35l41_hda_playback_hook()
679 !cs35l41->fw_request_ongoing) { in cs35l41_hda_playback_hook()
681 cs35l41->fw_request_ongoing = true; in cs35l41_hda_playback_hook()
682 schedule_work(&cs35l41->fw_load_work); in cs35l41_hda_playback_hook()
684 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_playback_hook()
688 * This ensures no amps are playing back when we start putting them to sleep. in cs35l41_hda_playback_hook()
704 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
706 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
719 if (!cs35l41->amp_name) { in cs35l41_hda_channel_map()
721 return -EINVAL; in cs35l41_hda_channel_map()
723 cs35l41->amp_name = devm_kasprintf(cs35l41->dev, GFP_KERNEL, "%s%d", in cs35l41_hda_channel_map()
724 channel_name[*rx_slot], cs35l41->channel_index); in cs35l41_hda_channel_map()
725 if (!cs35l41->amp_name) in cs35l41_hda_channel_map()
726 return -ENOMEM; in cs35l41_hda_channel_map()
729 return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num, in cs35l41_hda_channel_map()
738 ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, regid); in cs35l41_verify_id()
740 dev_err_probe(cs35l41->dev, ret, "Get Device ID failed\n"); in cs35l41_verify_id()
744 ret = regmap_read(cs35l41->regmap, CS35L41_REVID, reg_revid); in cs35l41_verify_id()
746 dev_err_probe(cs35l41->dev, ret, "Get Revision ID failed\n"); in cs35l41_verify_id()
754 dev_err(cs35l41->dev, "CS35L41 Device ID (%X). Expected ID %X\n", *regid, chipid); in cs35l41_verify_id()
755 return -ENODEV; in cs35l41_verify_id()
763 mutex_lock(&cs35l41->fw_mutex); in cs35l41_ready_for_reset()
764 if (cs35l41->cs_dsp.running) { in cs35l41_ready_for_reset()
765 cs35l41->cs_dsp.running = false; in cs35l41_ready_for_reset()
766 cs35l41->cs_dsp.booted = false; in cs35l41_ready_for_reset()
768 regcache_mark_dirty(cs35l41->regmap); in cs35l41_ready_for_reset()
769 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_ready_for_reset()
778 dev_dbg(cs35l41->dev, "System Suspend Prepare\n"); in cs35l41_system_suspend_prep()
780 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_suspend_prep()
781 dev_err_once(cs35l41->dev, "System Suspend not supported\n"); in cs35l41_system_suspend_prep()
785 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_suspend_prep()
786 if (cs35l41->playback_started) in cs35l41_system_suspend_prep()
788 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_suspend_prep()
798 dev_dbg(cs35l41->dev, "System Suspend\n"); in cs35l41_system_suspend()
800 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_suspend()
801 dev_err_once(cs35l41->dev, "System Suspend not supported\n"); in cs35l41_system_suspend()
805 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_suspend()
806 if (cs35l41->playback_started) in cs35l41_system_suspend()
808 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_suspend()
821 if (cs35l41->reset_gpio) { in cs35l41_system_suspend()
822 dev_info(cs35l41->dev, "Asserting Reset\n"); in cs35l41_system_suspend()
823 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_system_suspend()
827 dev_dbg(cs35l41->dev, "System Suspended\n"); in cs35l41_system_suspend()
837 ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4, int_status, in cs35l41_wait_boot_done()
840 dev_err(cs35l41->dev, "Failed waiting for OTP_BOOT_DONE\n"); in cs35l41_wait_boot_done()
844 ret = regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status); in cs35l41_wait_boot_done()
846 dev_err(cs35l41->dev, "OTP Boot status %x error\n", in cs35l41_wait_boot_done()
849 ret = -EIO; in cs35l41_wait_boot_done()
861 dev_dbg(cs35l41->dev, "System Resume\n"); in cs35l41_system_resume()
863 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_system_resume()
864 dev_err_once(cs35l41->dev, "System Resume not supported\n"); in cs35l41_system_resume()
868 if (cs35l41->reset_gpio) { in cs35l41_system_resume()
869 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_system_resume()
871 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_system_resume()
876 regcache_cache_only(cs35l41->regmap, false); in cs35l41_system_resume()
878 regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); in cs35l41_system_resume()
885 regcache_cache_only(cs35l41->regmap, true); in cs35l41_system_resume()
893 mutex_lock(&cs35l41->fw_mutex); in cs35l41_system_resume()
895 if (cs35l41->request_fw_load && !cs35l41->fw_request_ongoing) { in cs35l41_system_resume()
896 cs35l41->fw_request_ongoing = true; in cs35l41_system_resume()
897 schedule_work(&cs35l41->fw_load_work); in cs35l41_system_resume()
899 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_system_resume()
908 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) in cs35l41_runtime_idle()
909 return -EBUSY; /* suspend not supported yet on this model */ in cs35l41_runtime_idle()
918 dev_dbg(cs35l41->dev, "Runtime Suspend\n"); in cs35l41_runtime_suspend()
920 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_runtime_suspend()
921 dev_dbg(cs35l41->dev, "Runtime Suspend not supported\n"); in cs35l41_runtime_suspend()
925 mutex_lock(&cs35l41->fw_mutex); in cs35l41_runtime_suspend()
927 if (cs35l41->cs_dsp.running) { in cs35l41_runtime_suspend()
928 ret = cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, in cs35l41_runtime_suspend()
929 cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
933 cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); in cs35l41_runtime_suspend()
936 regcache_cache_only(cs35l41->regmap, true); in cs35l41_runtime_suspend()
937 regcache_mark_dirty(cs35l41->regmap); in cs35l41_runtime_suspend()
940 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_runtime_suspend()
951 dev_dbg(cs35l41->dev, "Runtime Resume\n"); in cs35l41_runtime_resume()
953 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { in cs35l41_runtime_resume()
954 dev_dbg(cs35l41->dev, "Runtime Resume not supported\n"); in cs35l41_runtime_resume()
958 mutex_lock(&cs35l41->fw_mutex); in cs35l41_runtime_resume()
960 regcache_cache_only(cs35l41->regmap, false); in cs35l41_runtime_resume()
962 if (cs35l41->cs_dsp.running) { in cs35l41_runtime_resume()
963 ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
965 dev_warn(cs35l41->dev, "Unable to exit Hibernate."); in cs35l41_runtime_resume()
974 /* Test key needs to be unlocked to allow the OTP settings to re-apply */ in cs35l41_runtime_resume()
975 cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
976 ret = regcache_sync(cs35l41->regmap); in cs35l41_runtime_resume()
977 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_runtime_resume()
979 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); in cs35l41_runtime_resume()
983 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) in cs35l41_runtime_resume()
984 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); in cs35l41_runtime_resume()
986 dev_dbg(cs35l41->dev, "CS35L41 Resumed (%x), Revision: %02X\n", regid, reg_revid); in cs35l41_runtime_resume()
989 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_runtime_resume()
1000 if (cs35l41->bypass_fw) { in cs35l41_smart_amp()
1001 dev_warn(cs35l41->dev, "Bypassing Firmware.\n"); in cs35l41_smart_amp()
1007 dev_warn(cs35l41->dev, "Cannot Initialize Firmware. Error: %d\n", ret); in cs35l41_smart_amp()
1011 ret = cs35l41_write_fs_errata(cs35l41->dev, cs35l41->regmap); in cs35l41_smart_amp()
1013 dev_err(cs35l41->dev, "Cannot Write FS Errata: %d\n", ret); in cs35l41_smart_amp()
1017 ret = cs_dsp_run(&cs35l41->cs_dsp); in cs35l41_smart_amp()
1019 dev_err(cs35l41->dev, "Fail to start dsp: %d\n", ret); in cs35l41_smart_amp()
1025 1000, 15000, false, &cs35l41->cs_dsp, HALO_STATE_DSP_CTL_NAME, in cs35l41_smart_amp()
1030 dev_err(cs35l41->dev, "Timeout waiting for HALO Core to start. State: %u\n", in cs35l41_smart_amp()
1035 ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status); in cs35l41_smart_amp()
1037 dev_err(cs35l41->dev, in cs35l41_smart_amp()
1047 dev_err(cs35l41->dev, "Firmware status is invalid: %u\n", in cs35l41_smart_amp()
1049 ret = -EINVAL; in cs35l41_smart_amp()
1053 ret = cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, CSPL_MBOX_CMD_PAUSE); in cs35l41_smart_amp()
1055 dev_err(cs35l41->dev, "Error waiting for DSP to pause: %u\n", ret); in cs35l41_smart_amp()
1068 if (cs35l41->cs_dsp.running && !load) { in cs35l41_load_firmware()
1069 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); in cs35l41_load_firmware()
1071 } else if (!cs35l41->cs_dsp.running && load) { in cs35l41_load_firmware()
1072 dev_dbg(cs35l41->dev, "Loading Firmware\n"); in cs35l41_load_firmware()
1075 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); in cs35l41_load_firmware()
1084 ucontrol->value.integer.value[0] = cs35l41->request_fw_load; in cs35l41_fw_load_ctl_get()
1093 ucontrol->value.integer.value[0] = cs35l41->mute_override; in cs35l41_mute_override_ctl_get()
1101 pm_runtime_get_sync(cs35l41->dev); in cs35l41_fw_load_work()
1103 mutex_lock(&cs35l41->fw_mutex); in cs35l41_fw_load_work()
1106 if (cs35l41->playback_started) in cs35l41_fw_load_work()
1107 dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); in cs35l41_fw_load_work()
1109 cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); in cs35l41_fw_load_work()
1111 cs35l41->fw_request_ongoing = false; in cs35l41_fw_load_work()
1112 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_fw_load_work()
1114 pm_runtime_mark_last_busy(cs35l41->dev); in cs35l41_fw_load_work()
1115 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_fw_load_work()
1123 if (cs35l41->request_fw_load == ucontrol->value.integer.value[0]) in cs35l41_fw_load_ctl_put()
1126 if (cs35l41->fw_request_ongoing) { in cs35l41_fw_load_ctl_put()
1127 dev_dbg(cs35l41->dev, "Existing request not complete\n"); in cs35l41_fw_load_ctl_put()
1128 return -EBUSY; in cs35l41_fw_load_ctl_put()
1132 if (cs35l41->playback_started) { in cs35l41_fw_load_ctl_put()
1133 dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); in cs35l41_fw_load_ctl_put()
1134 return -EBUSY; in cs35l41_fw_load_ctl_put()
1137 cs35l41->fw_request_ongoing = true; in cs35l41_fw_load_ctl_put()
1138 cs35l41->request_fw_load = ucontrol->value.integer.value[0]; in cs35l41_fw_load_ctl_put()
1139 schedule_work(&cs35l41->fw_load_work); in cs35l41_fw_load_ctl_put()
1149 ucontrol->value.enumerated.item[0] = cs35l41->firmware_type; in cs35l41_fw_type_ctl_get()
1159 if (ucontrol->value.enumerated.item[0] < HDA_CS_DSP_NUM_FW) { in cs35l41_fw_type_ctl_put()
1160 if (cs35l41->firmware_type != ucontrol->value.enumerated.item[0]) { in cs35l41_fw_type_ctl_put()
1161 cs35l41->firmware_type = ucontrol->value.enumerated.item[0]; in cs35l41_fw_type_ctl_put()
1168 return -EINVAL; in cs35l41_fw_type_ctl_put()
1205 cs35l41->amp_name); in cs35l41_create_controls()
1207 cs35l41->amp_name); in cs35l41_create_controls()
1209 cs35l41->amp_name); in cs35l41_create_controls()
1211 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_type_ctl, cs35l41)); in cs35l41_create_controls()
1213 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", fw_type_ctl.name, ret); in cs35l41_create_controls()
1217 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_type_ctl.name); in cs35l41_create_controls()
1219 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&fw_load_ctl, cs35l41)); in cs35l41_create_controls()
1221 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", fw_load_ctl.name, ret); in cs35l41_create_controls()
1225 dev_dbg(cs35l41->dev, "Added Control %s\n", fw_load_ctl.name); in cs35l41_create_controls()
1227 ret = snd_ctl_add(cs35l41->codec->card, snd_ctl_new1(&mute_override_ctl, cs35l41)); in cs35l41_create_controls()
1229 dev_err(cs35l41->dev, "Failed to add KControl %s = %d\n", mute_override_ctl.name, in cs35l41_create_controls()
1234 dev_dbg(cs35l41->dev, "Added Control %s\n", mute_override_ctl.name); in cs35l41_create_controls()
1252 int mute = -ENODEV; in cs35l41_get_acpi_mute_state()
1258 mute = *ret->buffer.pointer; in cs35l41_get_acpi_mute_state()
1259 dev_dbg(cs35l41->dev, "CS35L41_DSM_GET_MUTE: %d\n", mute); in cs35l41_get_acpi_mute_state()
1262 dev_dbg(cs35l41->dev, "%s: %d\n", __func__, mute); in cs35l41_get_acpi_mute_state()
1277 dev_warn(cs35l41->dev, "Unable to retrieve mute state: %d\n", mute); in cs35l41_acpi_device_notify()
1281 dev_dbg(cs35l41->dev, "Requesting mute value: %d\n", mute); in cs35l41_acpi_device_notify()
1282 cs35l41->mute_override = (mute > 0); in cs35l41_acpi_device_notify()
1283 cs35l41_mute(cs35l41->dev, cs35l41->mute_override); in cs35l41_acpi_device_notify()
1293 if (!comps || cs35l41->index < 0 || cs35l41->index >= HDA_MAX_COMPONENTS) in cs35l41_hda_bind()
1294 return -EINVAL; in cs35l41_hda_bind()
1296 comps = &comps[cs35l41->index]; in cs35l41_hda_bind()
1297 if (comps->dev) in cs35l41_hda_bind()
1298 return -EBUSY; in cs35l41_hda_bind()
1302 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_bind()
1304 comps->dev = dev; in cs35l41_hda_bind()
1305 if (!cs35l41->acpi_subsystem_id) in cs35l41_hda_bind()
1306 cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", in cs35l41_hda_bind()
1307 comps->codec->core.subsystem_id); in cs35l41_hda_bind()
1308 cs35l41->codec = comps->codec; in cs35l41_hda_bind()
1309 strscpy(comps->name, dev_name(dev), sizeof(comps->name)); in cs35l41_hda_bind()
1311 cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT; in cs35l41_hda_bind()
1314 dev_dbg(cs35l41->dev, "Firmware Autostart.\n"); in cs35l41_hda_bind()
1315 cs35l41->request_fw_load = true; in cs35l41_hda_bind()
1317 dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n"); in cs35l41_hda_bind()
1319 dev_dbg(cs35l41->dev, "Firmware Autostart is disabled.\n"); in cs35l41_hda_bind()
1324 comps->playback_hook = cs35l41_hda_playback_hook; in cs35l41_hda_bind()
1325 comps->pre_playback_hook = cs35l41_hda_pre_playback_hook; in cs35l41_hda_bind()
1326 comps->post_playback_hook = cs35l41_hda_post_playback_hook; in cs35l41_hda_bind()
1327 comps->acpi_notify = cs35l41_acpi_device_notify; in cs35l41_hda_bind()
1328 comps->adev = cs35l41->dacpi; in cs35l41_hda_bind()
1330 comps->acpi_notifications_supported = cs35l41_dsm_supported(acpi_device_handle(comps->adev), in cs35l41_hda_bind()
1333 cs35l41->mute_override = cs35l41_get_acpi_mute_state(cs35l41, in cs35l41_hda_bind()
1334 acpi_device_handle(cs35l41->dacpi)) > 0; in cs35l41_hda_bind()
1336 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_bind()
1339 if (!device_link_add(&comps->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) in cs35l41_hda_bind()
1346 dev_info(cs35l41->dev, in cs35l41_hda_bind()
1347 "CS35L41 Bound - SSID: %s, BST: %d, VSPK: %d, CH: %c, FW EN: %d, SPKID: %d\n", in cs35l41_hda_bind()
1348 cs35l41->acpi_subsystem_id, cs35l41->hw_cfg.bst_type, in cs35l41_hda_bind()
1349 cs35l41->hw_cfg.gpio1.func == CS35l41_VSPK_SWITCH, in cs35l41_hda_bind()
1350 cs35l41->hw_cfg.spk_pos ? 'R' : 'L', in cs35l41_hda_bind()
1351 cs35l41->cs_dsp.running, cs35l41->speaker_id); in cs35l41_hda_bind()
1362 if (comps[cs35l41->index].dev == dev) { in cs35l41_hda_unbind()
1363 memset(&comps[cs35l41->index], 0, sizeof(*comps)); in cs35l41_hda_unbind()
1365 device_link_remove(&comps->codec->core.dev, cs35l41->dev); in cs35l41_hda_unbind()
1379 dev_crit_ratelimited(cs35l41->dev, "LBST Error\n"); in cs35l41_bst_short_err()
1380 set_bit(CS35L41_BST_SHORT_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_short_err()
1389 dev_crit_ratelimited(cs35l41->dev, "DCM VBST Under Voltage Error\n"); in cs35l41_bst_dcm_uvp_err()
1390 set_bit(CS35L41_BST_UVP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_dcm_uvp_err()
1399 dev_crit_ratelimited(cs35l41->dev, "VBST Over Voltage error\n"); in cs35l41_bst_ovp_err()
1400 set_bit(CS35L41_BST_OVP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_bst_ovp_err()
1409 dev_crit_ratelimited(cs35l41->dev, "Over temperature error\n"); in cs35l41_temp_err()
1410 set_bit(CS35L41_TEMP_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_temp_err()
1419 dev_crit_ratelimited(cs35l41->dev, "Over temperature warning\n"); in cs35l41_temp_warn()
1420 set_bit(CS35L41_TEMP_WARN_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_temp_warn()
1429 dev_crit_ratelimited(cs35l41->dev, "Amp short error\n"); in cs35l41_amp_short()
1430 set_bit(CS35L41_AMP_SHORT_ERR_RLS_SHIFT, &cs35l41->irq_errors); in cs35l41_amp_short()
1466 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_hda_apply_properties()
1472 if (!cs35l41->hw_cfg.valid) in cs35l41_hda_apply_properties()
1473 return -EINVAL; in cs35l41_hda_apply_properties()
1475 ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1479 if (hw_cfg->gpio1.valid) { in cs35l41_hda_apply_properties()
1480 switch (hw_cfg->gpio1.func) { in cs35l41_hda_apply_properties()
1484 hw_cfg->gpio1.func = CS35L41_GPIO1_GPIO; in cs35l41_hda_apply_properties()
1485 hw_cfg->gpio1.out_en = true; in cs35l41_hda_apply_properties()
1488 hw_cfg->gpio1.func = CS35L41_GPIO1_MDSYNC; in cs35l41_hda_apply_properties()
1491 dev_err(cs35l41->dev, "Invalid function %d for GPIO1\n", in cs35l41_hda_apply_properties()
1492 hw_cfg->gpio1.func); in cs35l41_hda_apply_properties()
1493 return -EINVAL; in cs35l41_hda_apply_properties()
1497 if (hw_cfg->gpio2.valid) { in cs35l41_hda_apply_properties()
1498 switch (hw_cfg->gpio2.func) { in cs35l41_hda_apply_properties()
1503 hw_cfg->gpio2.func = CS35L41_GPIO2_INT_OPEN_DRAIN; in cs35l41_hda_apply_properties()
1506 dev_err(cs35l41->dev, "Invalid GPIO2 function %d\n", hw_cfg->gpio2.func); in cs35l41_hda_apply_properties()
1507 return -EINVAL; in cs35l41_hda_apply_properties()
1511 irq_pol = cs35l41_gpio_config(cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1513 if (cs35l41->irq && using_irq) { in cs35l41_hda_apply_properties()
1514 ret = devm_regmap_add_irq_chip(cs35l41->dev, cs35l41->regmap, cs35l41->irq, in cs35l41_hda_apply_properties()
1516 0, &cs35l41_regmap_irq_chip, &cs35l41->irq_data); in cs35l41_hda_apply_properties()
1521 irq = regmap_irq_get_virq(cs35l41->irq_data, cs35l41_irqs[i].irq); in cs35l41_hda_apply_properties()
1525 ret = devm_request_threaded_irq(cs35l41->dev, irq, NULL, in cs35l41_hda_apply_properties()
1534 return cs35l41_hda_channel_map(cs35l41->dev, 0, NULL, 1, &hw_cfg->spk_pos); in cs35l41_hda_apply_properties()
1540 int speaker_id = -ENODEV; in cs35l41_get_speaker_id()
1559 count = gpiod_count(dev, "spk-id"); in cs35l41_get_speaker_id()
1566 return -EINVAL; in cs35l41_get_speaker_id()
1571 speaker_id_desc = gpiod_get_index(dev, "spk-id", i + base_index, in cs35l41_get_speaker_id()
1593 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; in cs35l41_hda_read_acpi()
1603 adev = acpi_dev_get_first_match_dev(hid, NULL, -1); in cs35l41_hda_read_acpi()
1605 dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid); in cs35l41_hda_read_acpi()
1606 return -ENODEV; in cs35l41_hda_read_acpi()
1609 cs35l41->dacpi = adev; in cs35l41_hda_read_acpi()
1615 cs35l41->acpi_subsystem_id = sub; in cs35l41_hda_read_acpi()
1619 dev_info(cs35l41->dev, "Using extra _DSD properties, bypassing _DSD in ACPI\n"); in cs35l41_hda_read_acpi()
1623 property = "cirrus,dev-index"; in cs35l41_hda_read_acpi()
1629 ret = -EINVAL; in cs35l41_hda_read_acpi()
1638 cs35l41->index = -1; in cs35l41_hda_read_acpi()
1641 cs35l41->index = i; in cs35l41_hda_read_acpi()
1645 if (cs35l41->index == -1) { in cs35l41_hda_read_acpi()
1646 dev_err(cs35l41->dev, "No index found in %s\n", property); in cs35l41_hda_read_acpi()
1647 ret = -ENODEV; in cs35l41_hda_read_acpi()
1654 cs35l41->reset_gpio = fwnode_gpiod_get_index(acpi_fwnode_handle(adev), "reset", cs35l41->index, in cs35l41_hda_read_acpi()
1655 GPIOD_OUT_LOW, "cs35l41-reset"); in cs35l41_hda_read_acpi()
1657 property = "cirrus,speaker-position"; in cs35l41_hda_read_acpi()
1661 hw_cfg->spk_pos = values[cs35l41->index]; in cs35l41_hda_read_acpi()
1663 cs35l41->channel_index = 0; in cs35l41_hda_read_acpi()
1664 for (i = 0; i < cs35l41->index; i++) in cs35l41_hda_read_acpi()
1665 if (values[i] == hw_cfg->spk_pos) in cs35l41_hda_read_acpi()
1666 cs35l41->channel_index++; in cs35l41_hda_read_acpi()
1668 property = "cirrus,gpio1-func"; in cs35l41_hda_read_acpi()
1672 hw_cfg->gpio1.func = values[cs35l41->index]; in cs35l41_hda_read_acpi()
1673 hw_cfg->gpio1.valid = true; in cs35l41_hda_read_acpi()
1675 property = "cirrus,gpio2-func"; in cs35l41_hda_read_acpi()
1679 hw_cfg->gpio2.func = values[cs35l41->index]; in cs35l41_hda_read_acpi()
1680 hw_cfg->gpio2.valid = true; in cs35l41_hda_read_acpi()
1682 property = "cirrus,boost-peak-milliamp"; in cs35l41_hda_read_acpi()
1685 hw_cfg->bst_ipk = values[cs35l41->index]; in cs35l41_hda_read_acpi()
1687 hw_cfg->bst_ipk = -1; in cs35l41_hda_read_acpi()
1689 property = "cirrus,boost-ind-nanohenry"; in cs35l41_hda_read_acpi()
1692 hw_cfg->bst_ind = values[cs35l41->index]; in cs35l41_hda_read_acpi()
1694 hw_cfg->bst_ind = -1; in cs35l41_hda_read_acpi()
1696 property = "cirrus,boost-cap-microfarad"; in cs35l41_hda_read_acpi()
1699 hw_cfg->bst_cap = values[cs35l41->index]; in cs35l41_hda_read_acpi()
1701 hw_cfg->bst_cap = -1; in cs35l41_hda_read_acpi()
1703 cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, cs35l41->index, nval, -1); in cs35l41_hda_read_acpi()
1705 if (hw_cfg->bst_ind > 0 || hw_cfg->bst_cap > 0 || hw_cfg->bst_ipk > 0) in cs35l41_hda_read_acpi()
1706 hw_cfg->bst_type = CS35L41_INT_BOOST; in cs35l41_hda_read_acpi()
1708 hw_cfg->bst_type = CS35L41_EXT_BOOST; in cs35l41_hda_read_acpi()
1710 hw_cfg->valid = true; in cs35l41_hda_read_acpi()
1714 cs35l41->bypass_fw = false; in cs35l41_hda_read_acpi()
1715 if (cs35l41->control_bus == SPI) { in cs35l41_hda_read_acpi()
1716 spi = to_spi_device(cs35l41->dev); in cs35l41_hda_read_acpi()
1717 if (spi->max_speed_hz < CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ) { in cs35l41_hda_read_acpi()
1718 dev_warn(cs35l41->dev, in cs35l41_hda_read_acpi()
1720 spi->max_speed_hz); in cs35l41_hda_read_acpi()
1721 cs35l41->bypass_fw = true; in cs35l41_hda_read_acpi()
1728 dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); in cs35l41_hda_read_acpi()
1729 hw_cfg->valid = false; in cs35l41_hda_read_acpi()
1730 hw_cfg->gpio1.valid = false; in cs35l41_hda_read_acpi()
1731 hw_cfg->gpio2.valid = false; in cs35l41_hda_read_acpi()
1732 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_read_acpi()
1753 return -ENOMEM; in cs35l41_hda_probe()
1755 cs35l41->dev = dev; in cs35l41_hda_probe()
1756 cs35l41->irq = irq; in cs35l41_hda_probe()
1757 cs35l41->regmap = regmap; in cs35l41_hda_probe()
1758 cs35l41->control_bus = control_bus; in cs35l41_hda_probe()
1763 return dev_err_probe(cs35l41->dev, ret, "Platform not supported\n"); in cs35l41_hda_probe()
1765 if (IS_ERR(cs35l41->reset_gpio)) { in cs35l41_hda_probe()
1766 ret = PTR_ERR(cs35l41->reset_gpio); in cs35l41_hda_probe()
1767 cs35l41->reset_gpio = NULL; in cs35l41_hda_probe()
1768 if (ret == -EBUSY) { in cs35l41_hda_probe()
1769 dev_info(cs35l41->dev, "Reset line busy, assuming shared reset\n"); in cs35l41_hda_probe()
1771 dev_err_probe(cs35l41->dev, ret, "Failed to get reset GPIO\n"); in cs35l41_hda_probe()
1775 if (cs35l41->reset_gpio) { in cs35l41_hda_probe()
1776 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_probe()
1778 gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); in cs35l41_hda_probe()
1782 regmap_write(cs35l41->regmap, CS35L41_SFT_RESET, CS35L41_SOFTWARE_RESET); in cs35l41_hda_probe()
1793 ret = cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
1797 ret = cs35l41_register_errata_patch(cs35l41->dev, cs35l41->regmap, reg_revid); in cs35l41_hda_probe()
1801 ret = cs35l41_otp_unpack(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
1803 dev_err_probe(cs35l41->dev, ret, "OTP Unpack failed\n"); in cs35l41_hda_probe()
1807 ret = cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); in cs35l41_hda_probe()
1811 cs35l41_mute(cs35l41->dev, true); in cs35l41_hda_probe()
1813 INIT_WORK(&cs35l41->fw_load_work, cs35l41_fw_load_work); in cs35l41_hda_probe()
1814 mutex_init(&cs35l41->fw_mutex); in cs35l41_hda_probe()
1816 pm_runtime_set_autosuspend_delay(cs35l41->dev, 3000); in cs35l41_hda_probe()
1817 pm_runtime_use_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
1818 pm_runtime_mark_last_busy(cs35l41->dev); in cs35l41_hda_probe()
1819 pm_runtime_set_active(cs35l41->dev); in cs35l41_hda_probe()
1820 pm_runtime_get_noresume(cs35l41->dev); in cs35l41_hda_probe()
1821 pm_runtime_enable(cs35l41->dev); in cs35l41_hda_probe()
1827 pm_runtime_put_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
1829 ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops); in cs35l41_hda_probe()
1831 dev_err_probe(cs35l41->dev, ret, "Register component failed\n"); in cs35l41_hda_probe()
1835 dev_info(cs35l41->dev, "Cirrus Logic CS35L41 (%x), Revision: %02X\n", regid, reg_revid); in cs35l41_hda_probe()
1840 pm_runtime_dont_use_autosuspend(cs35l41->dev); in cs35l41_hda_probe()
1841 pm_runtime_disable(cs35l41->dev); in cs35l41_hda_probe()
1842 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_hda_probe()
1845 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) in cs35l41_hda_probe()
1846 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_probe()
1847 gpiod_put(cs35l41->reset_gpio); in cs35l41_hda_probe()
1848 gpiod_put(cs35l41->cs_gpio); in cs35l41_hda_probe()
1849 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_probe()
1850 kfree(cs35l41->acpi_subsystem_id); in cs35l41_hda_probe()
1860 pm_runtime_get_sync(cs35l41->dev); in cs35l41_hda_remove()
1861 pm_runtime_dont_use_autosuspend(cs35l41->dev); in cs35l41_hda_remove()
1862 pm_runtime_disable(cs35l41->dev); in cs35l41_hda_remove()
1864 if (cs35l41->halo_initialized) in cs35l41_hda_remove()
1867 component_del(cs35l41->dev, &cs35l41_hda_comp_ops); in cs35l41_hda_remove()
1869 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_remove()
1871 pm_runtime_put_noidle(cs35l41->dev); in cs35l41_hda_remove()
1873 if (cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type)) in cs35l41_hda_remove()
1874 gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); in cs35l41_hda_remove()
1875 gpiod_put(cs35l41->reset_gpio); in cs35l41_hda_remove()
1876 gpiod_put(cs35l41->cs_gpio); in cs35l41_hda_remove()
1877 kfree(cs35l41->acpi_subsystem_id); in cs35l41_hda_remove()