Lines Matching refs:sdev
123 void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level, in sof_print_oops_and_stack() argument
133 dev_printk(level, sdev->dev, "unexpected fault %#010x trace %#010x\n", in sof_print_oops_and_stack()
142 dev_printk(level, sdev->dev, "reason: %s (%#x)\n", in sof_print_oops_and_stack()
144 dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code); in sof_print_oops_and_stack()
150 dev_printk(level, sdev->dev, "unknown panic code: %#x\n", in sof_print_oops_and_stack()
152 dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code); in sof_print_oops_and_stack()
155 dev_printk(level, sdev->dev, "panic at %s:%d\n", panic_info->filename, in sof_print_oops_and_stack()
157 sof_oops(sdev, level, oops); in sof_print_oops_and_stack()
158 sof_stack(sdev, level, oops, stack, stack_words); in sof_print_oops_and_stack()
163 void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state) in sof_set_fw_state() argument
165 if (sdev->fw_state == new_state) in sof_set_fw_state()
168 dev_dbg(sdev->dev, "fw_state change: %d -> %d\n", sdev->fw_state, new_state); in sof_set_fw_state()
169 sdev->fw_state = new_state; in sof_set_fw_state()
175 sof_client_fw_state_dispatcher(sdev); in sof_set_fw_state()
183 static struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) in sof_of_machine_select() argument
185 struct snd_sof_pdata *sof_pdata = sdev->pdata; in sof_of_machine_select()
206 static int sof_machine_check(struct snd_sof_dev *sdev) in sof_machine_check() argument
208 struct snd_sof_pdata *sof_pdata = sdev->pdata; in sof_machine_check()
220 mach = snd_sof_machine_select(sdev); in sof_machine_check()
230 snd_sof_set_mach_params(mach, sdev); in sof_machine_check()
234 of_mach = sof_of_machine_select(sdev); in sof_machine_check()
241 dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); in sof_machine_check()
245 dev_warn(sdev->dev, "Force to use nocodec mode\n"); in sof_machine_check()
250 dev_warn(sdev->dev, "Using nocodec machine driver\n"); in sof_machine_check()
251 mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); in sof_machine_check()
260 snd_sof_set_mach_params(mach, sdev); in sof_machine_check()
265 static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev) in sof_select_ipc_and_paths() argument
267 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_select_ipc_and_paths()
270 struct device *dev = sdev->dev; in sof_select_ipc_and_paths()
304 ret = sof_create_ipc_file_profile(sdev, base_profile, &out_profile); in sof_select_ipc_and_paths()
317 static int validate_sof_ops(struct snd_sof_dev *sdev) in validate_sof_ops() argument
322 ret = sof_ops_init(sdev); in validate_sof_ops()
327 if (!sof_ops(sdev) || !sof_ops(sdev)->probe) { in validate_sof_ops()
328 dev_err(sdev->dev, "missing mandatory ops\n"); in validate_sof_ops()
329 sof_ops_free(sdev); in validate_sof_ops()
333 if (!sdev->dspless_mode_selected && in validate_sof_ops()
334 (!sof_ops(sdev)->run || !sof_ops(sdev)->block_read || in validate_sof_ops()
335 !sof_ops(sdev)->block_write || !sof_ops(sdev)->send_msg || in validate_sof_ops()
336 !sof_ops(sdev)->load_firmware || !sof_ops(sdev)->ipc_msg_data)) { in validate_sof_ops()
337 dev_err(sdev->dev, "missing mandatory DSP ops\n"); in validate_sof_ops()
338 sof_ops_free(sdev); in validate_sof_ops()
345 static int sof_init_sof_ops(struct snd_sof_dev *sdev) in sof_init_sof_ops() argument
347 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_init_sof_ops()
352 dev_err(sdev->dev, in sof_init_sof_ops()
365 return validate_sof_ops(sdev); in sof_init_sof_ops()
368 static int sof_init_environment(struct snd_sof_dev *sdev) in sof_init_environment() argument
370 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_init_environment()
375 ret = snd_sof_probe(sdev); in sof_init_environment()
377 dev_err(sdev->dev, "failed to probe DSP %d\n", ret); in sof_init_environment()
382 ret = sof_machine_check(sdev); in sof_init_environment()
384 dev_err(sdev->dev, "failed to get machine info %d\n", ret); in sof_init_environment()
388 ret = sof_select_ipc_and_paths(sdev); in sof_init_environment()
393 sof_ops_free(sdev); in sof_init_environment()
395 ret = validate_sof_ops(sdev); in sof_init_environment()
397 snd_sof_remove(sdev); in sof_init_environment()
398 snd_sof_remove_late(sdev); in sof_init_environment()
406 snd_sof_remove(sdev); in sof_init_environment()
408 snd_sof_remove_late(sdev); in sof_init_environment()
409 sof_ops_free(sdev); in sof_init_environment()
454 static int sof_probe_continue(struct snd_sof_dev *sdev) in sof_probe_continue() argument
456 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_probe_continue()
460 ret = sof_init_environment(sdev); in sof_probe_continue()
464 sof_set_fw_state(sdev, SOF_FW_BOOT_PREPARE); in sof_probe_continue()
467 snd_sof_new_platform_drv(sdev); in sof_probe_continue()
469 if (sdev->dspless_mode_selected) { in sof_probe_continue()
470 sof_set_fw_state(sdev, SOF_DSPLESS_MODE); in sof_probe_continue()
475 ret = snd_sof_dbg_init(sdev); in sof_probe_continue()
482 dev_err(sdev->dev, "error: failed to init DSP trace/debug %d\n", in sof_probe_continue()
488 sdev->ipc = snd_sof_ipc_init(sdev); in sof_probe_continue()
489 if (!sdev->ipc) { in sof_probe_continue()
491 dev_err(sdev->dev, "error: failed to init DSP IPC %d\n", ret); in sof_probe_continue()
496 ret = snd_sof_load_firmware(sdev); in sof_probe_continue()
498 dev_err(sdev->dev, "error: failed to load DSP firmware %d\n", in sof_probe_continue()
500 sof_set_fw_state(sdev, SOF_FW_BOOT_FAILED); in sof_probe_continue()
504 sof_set_fw_state(sdev, SOF_FW_BOOT_IN_PROGRESS); in sof_probe_continue()
510 ret = snd_sof_run_firmware(sdev); in sof_probe_continue()
512 dev_err(sdev->dev, "error: failed to boot DSP firmware %d\n", in sof_probe_continue()
514 sof_set_fw_state(sdev, SOF_FW_BOOT_FAILED); in sof_probe_continue()
519 sdev->fw_trace_is_supported = true; in sof_probe_continue()
522 ret = sof_fw_trace_init(sdev); in sof_probe_continue()
525 dev_warn(sdev->dev, "failed to initialize firmware tracing %d\n", in sof_probe_continue()
529 dev_dbg(sdev->dev, "SOF firmware trace disabled\n"); in sof_probe_continue()
534 sdev->first_boot = false; in sof_probe_continue()
537 ret = devm_snd_soc_register_component(sdev->dev, &sdev->plat_drv, in sof_probe_continue()
538 sof_ops(sdev)->drv, in sof_probe_continue()
539 sof_ops(sdev)->num_drv); in sof_probe_continue()
541 dev_err(sdev->dev, in sof_probe_continue()
546 ret = snd_sof_machine_register(sdev, plat_data); in sof_probe_continue()
548 dev_err(sdev->dev, in sof_probe_continue()
553 ret = sof_register_clients(sdev); in sof_probe_continue()
555 dev_err(sdev->dev, "failed to register clients %d\n", ret); in sof_probe_continue()
564 if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume) in sof_probe_continue()
565 pm_runtime_get_noresume(sdev->dev); in sof_probe_continue()
568 plat_data->sof_probe_complete(sdev->dev); in sof_probe_continue()
570 sdev->probe_completed = true; in sof_probe_continue()
575 snd_sof_machine_unregister(sdev, plat_data); in sof_probe_continue()
577 sof_fw_trace_free(sdev); in sof_probe_continue()
579 snd_sof_fw_unload(sdev); in sof_probe_continue()
581 snd_sof_ipc_free(sdev); in sof_probe_continue()
584 snd_sof_free_debug(sdev); in sof_probe_continue()
585 snd_sof_remove(sdev); in sof_probe_continue()
586 snd_sof_remove_late(sdev); in sof_probe_continue()
587 sof_ops_free(sdev); in sof_probe_continue()
590 sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); in sof_probe_continue()
591 sdev->first_boot = true; in sof_probe_continue()
598 struct snd_sof_dev *sdev = in sof_probe_work() local
602 ret = sof_probe_continue(sdev); in sof_probe_work()
605 dev_err(sdev->dev, "error: %s failed err: %d\n", __func__, ret); in sof_probe_work()
632 struct snd_sof_dev *sdev; in snd_sof_device_probe() local
635 sdev = devm_kzalloc(dev, sizeof(*sdev), GFP_KERNEL); in snd_sof_device_probe()
636 if (!sdev) in snd_sof_device_probe()
640 sdev->dev = dev; in snd_sof_device_probe()
643 sdev->dsp_power_state.state = SOF_DSP_PM_D0; in snd_sof_device_probe()
645 sdev->pdata = plat_data; in snd_sof_device_probe()
646 sdev->first_boot = true; in snd_sof_device_probe()
647 dev_set_drvdata(dev, sdev); in snd_sof_device_probe()
655 sdev->dspless_mode_selected = true; in snd_sof_device_probe()
664 ret = sof_init_sof_ops(sdev); in snd_sof_device_probe()
668 INIT_LIST_HEAD(&sdev->pcm_list); in snd_sof_device_probe()
669 INIT_LIST_HEAD(&sdev->kcontrol_list); in snd_sof_device_probe()
670 INIT_LIST_HEAD(&sdev->widget_list); in snd_sof_device_probe()
671 INIT_LIST_HEAD(&sdev->pipeline_list); in snd_sof_device_probe()
672 INIT_LIST_HEAD(&sdev->dai_list); in snd_sof_device_probe()
673 INIT_LIST_HEAD(&sdev->dai_link_list); in snd_sof_device_probe()
674 INIT_LIST_HEAD(&sdev->route_list); in snd_sof_device_probe()
675 INIT_LIST_HEAD(&sdev->ipc_client_list); in snd_sof_device_probe()
676 INIT_LIST_HEAD(&sdev->ipc_rx_handler_list); in snd_sof_device_probe()
677 INIT_LIST_HEAD(&sdev->fw_state_handler_list); in snd_sof_device_probe()
678 spin_lock_init(&sdev->ipc_lock); in snd_sof_device_probe()
679 spin_lock_init(&sdev->hw_lock); in snd_sof_device_probe()
680 mutex_init(&sdev->power_state_access); in snd_sof_device_probe()
681 mutex_init(&sdev->ipc_client_mutex); in snd_sof_device_probe()
682 mutex_init(&sdev->client_event_handler_mutex); in snd_sof_device_probe()
686 sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC_MS; in snd_sof_device_probe()
688 sdev->ipc_timeout = plat_data->desc->ipc_timeout; in snd_sof_device_probe()
690 sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT_MS; in snd_sof_device_probe()
692 sdev->boot_timeout = plat_data->desc->boot_timeout; in snd_sof_device_probe()
697 sdev->ipc_timeout = sof_ipc_timeout_ms; in snd_sof_device_probe()
700 sdev->boot_timeout = sof_boot_timeout_ms; in snd_sof_device_probe()
703 sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); in snd_sof_device_probe()
709 ret = snd_sof_probe_early(sdev); in snd_sof_device_probe()
714 INIT_WORK(&sdev->probe_work, sof_probe_work); in snd_sof_device_probe()
715 schedule_work(&sdev->probe_work); in snd_sof_device_probe()
719 return sof_probe_continue(sdev); in snd_sof_device_probe()
725 struct snd_sof_dev *sdev = dev_get_drvdata(dev); in snd_sof_device_probe_completed() local
727 return sdev->probe_completed; in snd_sof_device_probe_completed()
733 struct snd_sof_dev *sdev = dev_get_drvdata(dev); in snd_sof_device_remove() local
734 struct snd_sof_pdata *pdata = sdev->pdata; in snd_sof_device_remove()
739 aborted = cancel_work_sync(&sdev->probe_work); in snd_sof_device_remove()
745 sof_unregister_clients(sdev); in snd_sof_device_remove()
752 snd_sof_machine_unregister(sdev, pdata); in snd_sof_device_remove()
759 if (sdev->d3_prevented) { in snd_sof_device_remove()
760 sdev->d3_prevented = false; in snd_sof_device_remove()
761 pm_runtime_put_noidle(sdev->dev); in snd_sof_device_remove()
764 if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { in snd_sof_device_remove()
765 sof_fw_trace_free(sdev); in snd_sof_device_remove()
766 ret = snd_sof_dsp_power_down_notify(sdev); in snd_sof_device_remove()
771 snd_sof_ipc_free(sdev); in snd_sof_device_remove()
772 snd_sof_free_debug(sdev); in snd_sof_device_remove()
773 snd_sof_remove(sdev); in snd_sof_device_remove()
774 snd_sof_remove_late(sdev); in snd_sof_device_remove()
775 sof_ops_free(sdev); in snd_sof_device_remove()
778 snd_sof_remove_late(sdev); in snd_sof_device_remove()
779 sof_ops_free(sdev); in snd_sof_device_remove()
783 snd_sof_fw_unload(sdev); in snd_sof_device_remove()
791 struct snd_sof_dev *sdev = dev_get_drvdata(dev); in snd_sof_device_shutdown() local
794 cancel_work_sync(&sdev->probe_work); in snd_sof_device_shutdown()
796 if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { in snd_sof_device_shutdown()
797 sof_fw_trace_free(sdev); in snd_sof_device_shutdown()
798 return snd_sof_shutdown(sdev); in snd_sof_device_shutdown()
806 int sof_machine_register(struct snd_sof_dev *sdev, void *pdata) in sof_machine_register() argument
819 platform_device_register_data(sdev->dev, drv_name, in sof_machine_register()
824 dev_dbg(sdev->dev, "created machine %s\n", in sof_machine_register()
831 void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) in sof_machine_unregister() argument