Lines Matching refs:cs35l41

140 static int cs35l41_request_tuning_param_file(struct cs35l41_hda *cs35l41, char *tuning_filename,  in cs35l41_request_tuning_param_file()  argument
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()
161 static int cs35l41_request_firmware_file(struct cs35l41_hda *cs35l41, in cs35l41_request_firmware_file() argument
166 const char * const dsp_name = cs35l41->cs_dsp.name; in cs35l41_request_firmware_file()
172 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
176 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
180 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
184 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], in cs35l41_request_firmware_file()
188 dsp_name, hda_cs_dsp_fw_ids[cs35l41->firmware_type], 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()
218 static int cs35l41_request_firmware_files_spkid(struct cs35l41_hda *cs35l41, in cs35l41_request_firmware_files_spkid() argument
227 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, 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()
232 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, 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()
242 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, 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()
247 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, 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()
257 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, 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()
262 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, 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()
267 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, 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()
278 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, in cs35l41_request_firmware_files_spkid()
279 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files_spkid()
283 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, 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()
288 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, 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()
303 static int cs35l41_fallback_firmware_file(struct cs35l41_hda *cs35l41, in cs35l41_fallback_firmware_file() argument
312 dev_warn(cs35l41->dev, "Falling back to default firmware.\n"); in cs35l41_fallback_firmware_file()
315 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, in cs35l41_fallback_firmware_file()
321 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, in cs35l41_fallback_firmware_file()
331 dev_warn(cs35l41->dev, "Unable to find firmware and tuning\n"); in cs35l41_fallback_firmware_file()
335 static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41, in cs35l41_request_firmware_files() argument
343 if (cs35l41->speaker_id > -1) { in cs35l41_request_firmware_files()
344 ret = cs35l41_request_firmware_files_spkid(cs35l41, wmfw_firmware, wmfw_filename, in cs35l41_request_firmware_files()
350 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, 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()
355 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, in cs35l41_request_firmware_files()
356 cs35l41->acpi_subsystem_id, cs35l41->amp_name, in cs35l41_request_firmware_files()
365 ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, in cs35l41_request_firmware_files()
366 cs35l41->acpi_subsystem_id, in cs35l41_request_firmware_files()
370 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, 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()
375 ret = cs35l41_request_firmware_file(cs35l41, coeff_firmware, coeff_filename, in cs35l41_request_firmware_files()
376 cs35l41->acpi_subsystem_id, NULL, -1, in cs35l41_request_firmware_files()
393 return cs35l41_fallback_firmware_file(cs35l41, wmfw_firmware, wmfw_filename, in cs35l41_request_firmware_files()
398 static void cs35l41_hda_apply_calibration(struct cs35l41_hda *cs35l41) in cs35l41_hda_apply_calibration() argument
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()
413 static int cs35l41_read_silicon_uid(struct cs35l41_hda *cs35l41, u64 *uid) in cs35l41_read_silicon_uid() argument
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()
440 static int cs35l41_get_calibration(struct cs35l41_hda *cs35l41) in cs35l41_get_calibration() argument
445 ret = cs35l41_read_silicon_uid(cs35l41, &silicon_uid); in cs35l41_get_calibration()
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()
460 cs35l41->cal_data_valid = true; in cs35l41_get_calibration()
466 static void cs35l41_set_default_tuning_params(struct cs35l41_hda *cs35l41) in cs35l41_set_default_tuning_params() argument
468 cs35l41->tuning_gain = DEFAULT_AMP_GAIN_PCM; in cs35l41_set_default_tuning_params()
471 static int cs35l41_read_tuning_params(struct cs35l41_hda *cs35l41, const struct firmware *firmware) in cs35l41_read_tuning_params() argument
481 dev_err(cs35l41->dev, "Wrong Size for Tuning Param file. Expected %d got %zu\n", in cs35l41_read_tuning_params()
487 dev_err(cs35l41->dev, "Unsupported Tuning Param Version: %d\n", in cs35l41_read_tuning_params()
493 dev_err(cs35l41->dev, 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()
526 static int cs35l41_load_tuning_params(struct cs35l41_hda *cs35l41, char *tuning_filename) in cs35l41_load_tuning_params() argument
532 ret = cs35l41_request_tuning_param_file(cs35l41, tuning_filename, &tuning_param_file, in cs35l41_load_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()
540 ret = cs35l41_read_tuning_params(cs35l41, tuning_param_file); in cs35l41_load_tuning_params()
542 dev_err(cs35l41->dev, "Error reading Tuning Params from file: %s: %d\n", in cs35l41_load_tuning_params()
545 cs35l41_set_default_tuning_params(cs35l41); in cs35l41_load_tuning_params()
554 static int cs35l41_init_dsp(struct cs35l41_hda *cs35l41) in cs35l41_init_dsp() argument
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()
567 ret = cs_dsp_halo_init(&cs35l41->cs_dsp); in cs35l41_init_dsp()
570 cs35l41->halo_initialized = true; in cs35l41_init_dsp()
573 cs35l41_set_default_tuning_params(cs35l41); in cs35l41_init_dsp()
575 ret = cs35l41_request_firmware_files(cs35l41, &wmfw_firmware, &wmfw_filename, 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()
583 ret = cs35l41_load_tuning_params(cs35l41, 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()
595 cs35l41_hda_apply_calibration(cs35l41); in cs35l41_init_dsp()
599 cs35l41_set_default_tuning_params(cs35l41); in cs35l41_init_dsp()
608 static void cs35l41_shutdown_dsp(struct cs35l41_hda *cs35l41) in cs35l41_shutdown_dsp() argument
610 struct cs_dsp *dsp = &cs35l41->cs_dsp; in cs35l41_shutdown_dsp()
612 cs35l41_set_default_tuning_params(cs35l41); in cs35l41_shutdown_dsp()
615 dev_dbg(cs35l41->dev, "Unloaded Firmware\n"); in cs35l41_shutdown_dsp()
618 static void cs35l41_remove_dsp(struct cs35l41_hda *cs35l41) in cs35l41_remove_dsp() argument
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()
625 cs35l41_shutdown_dsp(cs35l41); in cs35l41_remove_dsp()
627 cs35l41->halo_initialized = false; in cs35l41_remove_dsp()
628 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_remove_dsp()
640 static void cs35l41_irq_release(struct cs35l41_hda *cs35l41) in cs35l41_irq_release() argument
642 cs35l41_error_release(cs35l41->dev, cs35l41->regmap, cs35l41->irq_errors); in cs35l41_irq_release()
643 cs35l41->irq_errors = 0; in cs35l41_irq_release()
648 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_play_start() local
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()
682 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_mute() local
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()
713 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_play_done() local
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()
725 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_pause_start() local
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()
737 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_pause_done() local
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()
751 cs35l41_irq_release(cs35l41); in cs35l41_hda_pause_done()
752 cs35l41->playback_started = false; in cs35l41_hda_pause_done()
757 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_pre_playback_hook() local
761 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
763 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_pre_playback_hook()
771 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_playback_hook() local
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()
817 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_post_playback_hook() local
821 mutex_lock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
823 mutex_unlock(&cs35l41->fw_mutex); in cs35l41_hda_post_playback_hook()
833 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_channel_map() local
836 if (!cs35l41->amp_name) { 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()
846 return cs35l41_set_channels(cs35l41->dev, cs35l41->regmap, tx_num, tx_slot, rx_num, in cs35l41_hda_channel_map()
850 static int cs35l41_verify_id(struct cs35l41_hda *cs35l41, unsigned int *regid, unsigned int *reg_re… in cs35l41_verify_id() argument
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()
878 static int cs35l41_ready_for_reset(struct cs35l41_hda *cs35l41) in cs35l41_ready_for_reset() argument
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()
893 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_system_suspend_prep() local
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()
912 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_system_suspend() local
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()
934 ret = cs35l41_ready_for_reset(cs35l41); 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()
949 static int cs35l41_wait_boot_done(struct cs35l41_hda *cs35l41) in cs35l41_wait_boot_done() argument
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()
975 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_system_resume() local
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()
998 ret = cs35l41_wait_boot_done(cs35l41); 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()
1023 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_runtime_idle() local
1025 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) in cs35l41_runtime_idle()
1032 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_runtime_suspend() local
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()
1064 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_runtime_resume() local
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()
1087 ret = cs35l41_verify_id(cs35l41, &regid, &reg_revid); 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()
1111 static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) in cs35l41_smart_amp() argument
1117 if (cs35l41->bypass_fw) { in cs35l41_smart_amp()
1118 dev_warn(cs35l41->dev, "Bypassing Firmware.\n"); in cs35l41_smart_amp()
1122 ret = cs35l41_init_dsp(cs35l41); 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()
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()
1182 cs35l41_shutdown_dsp(cs35l41); in cs35l41_smart_amp()
1186 static void cs35l41_load_firmware(struct cs35l41_hda *cs35l41, bool load) in cs35l41_load_firmware() argument
1188 if (cs35l41->cs_dsp.running && !load) { in cs35l41_load_firmware()
1189 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); in cs35l41_load_firmware()
1190 cs35l41_shutdown_dsp(cs35l41); 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()
1193 cs35l41_smart_amp(cs35l41); in cs35l41_load_firmware()
1195 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); in cs35l41_load_firmware()
1202 struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); in cs35l41_fw_load_ctl_get() local
1204 ucontrol->value.integer.value[0] = cs35l41->request_fw_load; in cs35l41_fw_load_ctl_get()
1211 struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); in cs35l41_mute_override_ctl_get() local
1213 ucontrol->value.integer.value[0] = cs35l41->mute_override; in cs35l41_mute_override_ctl_get()
1219 struct cs35l41_hda *cs35l41 = container_of(work, struct cs35l41_hda, fw_load_work); in cs35l41_fw_load_work() local
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()
1241 struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); in cs35l41_fw_load_ctl_put() local
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()
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()
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()
1267 struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); in cs35l41_fw_type_ctl_get() local
1269 ucontrol->value.enumerated.item[0] = cs35l41->firmware_type; in cs35l41_fw_type_ctl_get()
1277 struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); in cs35l41_fw_type_ctl_put() local
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()
1296 static int cs35l41_create_controls(struct cs35l41_hda *cs35l41) in cs35l41_create_controls() argument
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()
1368 static int cs35l41_get_acpi_mute_state(struct cs35l41_hda *cs35l41, acpi_handle handle) in cs35l41_get_acpi_mute_state() argument
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()
1389 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_acpi_device_notify() local
1395 mute = cs35l41_get_acpi_mute_state(cs35l41, handle); in cs35l41_acpi_device_notify()
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()
1408 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_bind() local
1414 comp = hda_component_from_index(parent, cs35l41->index); in cs35l41_hda_bind()
1423 mutex_lock(&cs35l41->fw_mutex); 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()
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()
1438 if (cs35l41_smart_amp(cs35l41) < 0) 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()
1444 ret = cs35l41_create_controls(cs35l41); in cs35l41_hda_bind()
1450 comp->adev = cs35l41->dacpi; 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()
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()
1480 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_unbind() local
1485 comp = hda_component_from_index(parent, cs35l41->index); in cs35l41_hda_unbind()
1491 device_link_remove(&cs35l41->codec->core.dev, cs35l41->dev); in cs35l41_hda_unbind()
1504 struct cs35l41_hda *cs35l41 = data; in cs35l41_bst_short_err() local
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()
1514 struct cs35l41_hda *cs35l41 = data; in cs35l41_bst_dcm_uvp_err() local
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()
1524 struct cs35l41_hda *cs35l41 = data; in cs35l41_bst_ovp_err() local
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()
1534 struct cs35l41_hda *cs35l41 = data; in cs35l41_temp_err() local
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()
1544 struct cs35l41_hda *cs35l41 = data; in cs35l41_temp_warn() local
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()
1554 struct cs35l41_hda *cs35l41 = data; in cs35l41_amp_short() local
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()
1591 static void cs35l41_configure_interrupt(struct cs35l41_hda *cs35l41, int irq_pol) in cs35l41_configure_interrupt() argument
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()
1622 cs35l41_irqs[i].name, cs35l41); 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()
1635 static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41) in cs35l41_hda_apply_properties() argument
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()
1645 ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1661 dev_err(cs35l41->dev, "Invalid function %d for GPIO1\n", in cs35l41_hda_apply_properties()
1676 dev_err(cs35l41->dev, "Invalid GPIO2 function %d\n", hw_cfg->gpio2.func); in cs35l41_hda_apply_properties()
1681 irq_pol = cs35l41_gpio_config(cs35l41->regmap, hw_cfg); in cs35l41_hda_apply_properties()
1684 cs35l41_configure_interrupt(cs35l41, irq_pol); 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()
1743 int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, int id) in cs35l41_hda_parse_acpi() argument
1745 struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; 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()
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()
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()
1795 cs35l41->channel_index++; in cs35l41_hda_parse_acpi()
1801 hw_cfg->gpio1.func = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1808 hw_cfg->gpio2.func = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1814 hw_cfg->bst_ipk = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1821 hw_cfg->bst_ind = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1828 hw_cfg->bst_cap = values[cs35l41->index]; in cs35l41_hda_parse_acpi()
1832 cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, cs35l41->index, nval, -1); in cs35l41_hda_parse_acpi()
1843 dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); in cs35l41_hda_parse_acpi()
1847 acpi_dev_put(cs35l41->dacpi); in cs35l41_hda_parse_acpi()
1852 static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, int id) in cs35l41_hda_read_acpi() argument
1862 dev_err(cs35l41->dev, "Failed to find an ACPI device for %s\n", hid); 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()
1874 ret = cs35l41_add_dsd_properties(cs35l41, physdev, id, hid); in cs35l41_hda_read_acpi()
1876 dev_info(cs35l41->dev, "Using extra _DSD properties, bypassing _DSD in ACPI\n"); in cs35l41_hda_read_acpi()
1880 ret = cs35l41_hda_parse_acpi(cs35l41, physdev, id); 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()
1892 dev_warn(cs35l41->dev, in cs35l41_hda_read_acpi()
1895 cs35l41->bypass_fw = true; in cs35l41_hda_read_acpi()
1906 struct cs35l41_hda *cs35l41; in cs35l41_hda_probe() local
1915 cs35l41 = devm_kzalloc(dev, sizeof(*cs35l41), GFP_KERNEL); in cs35l41_hda_probe()
1916 if (!cs35l41) 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()
1923 dev_set_drvdata(dev, cs35l41); in cs35l41_hda_probe()
1925 ret = cs35l41_hda_read_acpi(cs35l41, device_name, id); 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()
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()
1949 ret = cs35l41_wait_boot_done(cs35l41); in cs35l41_hda_probe()
1953 ret = cs35l41_verify_id(cs35l41, &regid, &reg_revid); 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()
1975 ret = cs35l41_get_calibration(cs35l41); 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()
1991 ret = cs35l41_hda_apply_properties(cs35l41); 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()
2026 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); in cs35l41_hda_remove() local
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()
2035 cs35l41_remove_dsp(cs35l41); 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()