Lines Matching refs:sdev
87 void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level, in sof_print_oops_and_stack() argument
97 dev_printk(level, sdev->dev, "unexpected fault %#010x trace %#010x\n", in sof_print_oops_and_stack()
106 dev_printk(level, sdev->dev, "reason: %s (%#x)\n", in sof_print_oops_and_stack()
108 dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code); in sof_print_oops_and_stack()
114 dev_printk(level, sdev->dev, "unknown panic code: %#x\n", in sof_print_oops_and_stack()
116 dev_printk(level, sdev->dev, "trace point: %#010x\n", tracep_code); in sof_print_oops_and_stack()
119 dev_printk(level, sdev->dev, "panic at %s:%d\n", panic_info->filename, in sof_print_oops_and_stack()
121 sof_oops(sdev, level, oops); in sof_print_oops_and_stack()
122 sof_stack(sdev, level, oops, stack, stack_words); in sof_print_oops_and_stack()
127 void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state) in sof_set_fw_state() argument
129 if (sdev->fw_state == new_state) in sof_set_fw_state()
132 dev_dbg(sdev->dev, "fw_state change: %d -> %d\n", sdev->fw_state, new_state); in sof_set_fw_state()
133 sdev->fw_state = new_state; in sof_set_fw_state()
139 sof_client_fw_state_dispatcher(sdev); in sof_set_fw_state()
147 static struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) in sof_of_machine_select() argument
149 struct snd_sof_pdata *sof_pdata = sdev->pdata; in sof_of_machine_select()
170 static int sof_machine_check(struct snd_sof_dev *sdev) in sof_machine_check() argument
172 struct snd_sof_pdata *sof_pdata = sdev->pdata; in sof_machine_check()
184 mach = snd_sof_machine_select(sdev); in sof_machine_check()
194 snd_sof_set_mach_params(mach, sdev); in sof_machine_check()
198 of_mach = sof_of_machine_select(sdev); in sof_machine_check()
205 dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); in sof_machine_check()
209 dev_warn(sdev->dev, "Force to use nocodec mode\n"); in sof_machine_check()
214 dev_warn(sdev->dev, "Using nocodec machine driver\n"); in sof_machine_check()
215 mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); in sof_machine_check()
224 snd_sof_set_mach_params(mach, sdev); in sof_machine_check()
229 static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev) in sof_select_ipc_and_paths() argument
231 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_select_ipc_and_paths()
234 struct device *dev = sdev->dev; in sof_select_ipc_and_paths()
268 ret = sof_create_ipc_file_profile(sdev, base_profile, &out_profile); in sof_select_ipc_and_paths()
281 static int validate_sof_ops(struct snd_sof_dev *sdev) in validate_sof_ops() argument
286 ret = sof_ops_init(sdev); in validate_sof_ops()
291 if (!sof_ops(sdev) || !sof_ops(sdev)->probe) { in validate_sof_ops()
292 dev_err(sdev->dev, "missing mandatory ops\n"); in validate_sof_ops()
293 sof_ops_free(sdev); in validate_sof_ops()
297 if (!sdev->dspless_mode_selected && in validate_sof_ops()
298 (!sof_ops(sdev)->run || !sof_ops(sdev)->block_read || in validate_sof_ops()
299 !sof_ops(sdev)->block_write || !sof_ops(sdev)->send_msg || in validate_sof_ops()
300 !sof_ops(sdev)->load_firmware || !sof_ops(sdev)->ipc_msg_data)) { in validate_sof_ops()
301 dev_err(sdev->dev, "missing mandatory DSP ops\n"); in validate_sof_ops()
302 sof_ops_free(sdev); in validate_sof_ops()
309 static int sof_init_sof_ops(struct snd_sof_dev *sdev) in sof_init_sof_ops() argument
311 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_init_sof_ops()
316 dev_err(sdev->dev, in sof_init_sof_ops()
329 return validate_sof_ops(sdev); in sof_init_sof_ops()
332 static int sof_init_environment(struct snd_sof_dev *sdev) in sof_init_environment() argument
334 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_init_environment()
339 ret = snd_sof_probe(sdev); in sof_init_environment()
341 dev_err(sdev->dev, "failed to probe DSP %d\n", ret); in sof_init_environment()
346 ret = sof_machine_check(sdev); in sof_init_environment()
348 dev_err(sdev->dev, "failed to get machine info %d\n", ret); in sof_init_environment()
352 ret = sof_select_ipc_and_paths(sdev); in sof_init_environment()
357 sof_ops_free(sdev); in sof_init_environment()
359 ret = validate_sof_ops(sdev); in sof_init_environment()
361 snd_sof_remove(sdev); in sof_init_environment()
362 snd_sof_remove_late(sdev); in sof_init_environment()
370 snd_sof_remove(sdev); in sof_init_environment()
372 snd_sof_remove_late(sdev); in sof_init_environment()
373 sof_ops_free(sdev); in sof_init_environment()
418 static int sof_probe_continue(struct snd_sof_dev *sdev) in sof_probe_continue() argument
420 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_probe_continue()
424 ret = sof_init_environment(sdev); in sof_probe_continue()
428 sof_set_fw_state(sdev, SOF_FW_BOOT_PREPARE); in sof_probe_continue()
431 snd_sof_new_platform_drv(sdev); in sof_probe_continue()
433 if (sdev->dspless_mode_selected) { in sof_probe_continue()
434 sof_set_fw_state(sdev, SOF_DSPLESS_MODE); in sof_probe_continue()
439 ret = snd_sof_dbg_init(sdev); in sof_probe_continue()
446 dev_err(sdev->dev, "error: failed to init DSP trace/debug %d\n", in sof_probe_continue()
452 sdev->ipc = snd_sof_ipc_init(sdev); in sof_probe_continue()
453 if (!sdev->ipc) { in sof_probe_continue()
455 dev_err(sdev->dev, "error: failed to init DSP IPC %d\n", ret); in sof_probe_continue()
460 ret = snd_sof_load_firmware(sdev); in sof_probe_continue()
462 dev_err(sdev->dev, "error: failed to load DSP firmware %d\n", in sof_probe_continue()
464 sof_set_fw_state(sdev, SOF_FW_BOOT_FAILED); in sof_probe_continue()
468 sof_set_fw_state(sdev, SOF_FW_BOOT_IN_PROGRESS); in sof_probe_continue()
474 ret = snd_sof_run_firmware(sdev); in sof_probe_continue()
476 dev_err(sdev->dev, "error: failed to boot DSP firmware %d\n", in sof_probe_continue()
478 sof_set_fw_state(sdev, SOF_FW_BOOT_FAILED); in sof_probe_continue()
483 sdev->fw_trace_is_supported = true; in sof_probe_continue()
486 ret = sof_fw_trace_init(sdev); in sof_probe_continue()
489 dev_warn(sdev->dev, "failed to initialize firmware tracing %d\n", in sof_probe_continue()
493 dev_dbg(sdev->dev, "SOF firmware trace disabled\n"); in sof_probe_continue()
498 sdev->first_boot = false; in sof_probe_continue()
501 ret = devm_snd_soc_register_component(sdev->dev, &sdev->plat_drv, in sof_probe_continue()
502 sof_ops(sdev)->drv, in sof_probe_continue()
503 sof_ops(sdev)->num_drv); in sof_probe_continue()
505 dev_err(sdev->dev, in sof_probe_continue()
510 ret = snd_sof_machine_register(sdev, plat_data); in sof_probe_continue()
512 dev_err(sdev->dev, in sof_probe_continue()
517 ret = sof_register_clients(sdev); in sof_probe_continue()
519 dev_err(sdev->dev, "failed to register clients %d\n", ret); in sof_probe_continue()
528 if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume) in sof_probe_continue()
529 pm_runtime_get_noresume(sdev->dev); in sof_probe_continue()
532 plat_data->sof_probe_complete(sdev->dev); in sof_probe_continue()
534 sdev->probe_completed = true; in sof_probe_continue()
539 snd_sof_machine_unregister(sdev, plat_data); in sof_probe_continue()
541 sof_fw_trace_free(sdev); in sof_probe_continue()
543 snd_sof_fw_unload(sdev); in sof_probe_continue()
545 snd_sof_ipc_free(sdev); in sof_probe_continue()
548 snd_sof_free_debug(sdev); in sof_probe_continue()
549 snd_sof_remove(sdev); in sof_probe_continue()
550 snd_sof_remove_late(sdev); in sof_probe_continue()
551 sof_ops_free(sdev); in sof_probe_continue()
554 sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); in sof_probe_continue()
555 sdev->first_boot = true; in sof_probe_continue()
562 struct snd_sof_dev *sdev = in sof_probe_work() local
566 ret = sof_probe_continue(sdev); in sof_probe_work()
569 dev_err(sdev->dev, "error: %s failed err: %d\n", __func__, ret); in sof_probe_work()
575 struct snd_sof_dev *sdev; in snd_sof_device_probe() local
578 sdev = devm_kzalloc(dev, sizeof(*sdev), GFP_KERNEL); in snd_sof_device_probe()
579 if (!sdev) in snd_sof_device_probe()
583 sdev->dev = dev; in snd_sof_device_probe()
586 sdev->dsp_power_state.state = SOF_DSP_PM_D0; in snd_sof_device_probe()
588 sdev->pdata = plat_data; in snd_sof_device_probe()
589 sdev->first_boot = true; in snd_sof_device_probe()
590 dev_set_drvdata(dev, sdev); in snd_sof_device_probe()
598 sdev->dspless_mode_selected = true; in snd_sof_device_probe()
605 ret = sof_init_sof_ops(sdev); in snd_sof_device_probe()
609 INIT_LIST_HEAD(&sdev->pcm_list); in snd_sof_device_probe()
610 INIT_LIST_HEAD(&sdev->kcontrol_list); in snd_sof_device_probe()
611 INIT_LIST_HEAD(&sdev->widget_list); in snd_sof_device_probe()
612 INIT_LIST_HEAD(&sdev->pipeline_list); in snd_sof_device_probe()
613 INIT_LIST_HEAD(&sdev->dai_list); in snd_sof_device_probe()
614 INIT_LIST_HEAD(&sdev->dai_link_list); in snd_sof_device_probe()
615 INIT_LIST_HEAD(&sdev->route_list); in snd_sof_device_probe()
616 INIT_LIST_HEAD(&sdev->ipc_client_list); in snd_sof_device_probe()
617 INIT_LIST_HEAD(&sdev->ipc_rx_handler_list); in snd_sof_device_probe()
618 INIT_LIST_HEAD(&sdev->fw_state_handler_list); in snd_sof_device_probe()
619 spin_lock_init(&sdev->ipc_lock); in snd_sof_device_probe()
620 spin_lock_init(&sdev->hw_lock); in snd_sof_device_probe()
621 mutex_init(&sdev->power_state_access); in snd_sof_device_probe()
622 mutex_init(&sdev->ipc_client_mutex); in snd_sof_device_probe()
623 mutex_init(&sdev->client_event_handler_mutex); in snd_sof_device_probe()
627 sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC_MS; in snd_sof_device_probe()
629 sdev->ipc_timeout = plat_data->desc->ipc_timeout; in snd_sof_device_probe()
631 sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT_MS; in snd_sof_device_probe()
633 sdev->boot_timeout = plat_data->desc->boot_timeout; in snd_sof_device_probe()
635 sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); in snd_sof_device_probe()
641 ret = snd_sof_probe_early(sdev); in snd_sof_device_probe()
646 INIT_WORK(&sdev->probe_work, sof_probe_work); in snd_sof_device_probe()
647 schedule_work(&sdev->probe_work); in snd_sof_device_probe()
651 return sof_probe_continue(sdev); in snd_sof_device_probe()
657 struct snd_sof_dev *sdev = dev_get_drvdata(dev); in snd_sof_device_probe_completed() local
659 return sdev->probe_completed; in snd_sof_device_probe_completed()
665 struct snd_sof_dev *sdev = dev_get_drvdata(dev); in snd_sof_device_remove() local
666 struct snd_sof_pdata *pdata = sdev->pdata; in snd_sof_device_remove()
671 aborted = cancel_work_sync(&sdev->probe_work); in snd_sof_device_remove()
677 sof_unregister_clients(sdev); in snd_sof_device_remove()
684 snd_sof_machine_unregister(sdev, pdata); in snd_sof_device_remove()
691 if (sdev->d3_prevented) { in snd_sof_device_remove()
692 sdev->d3_prevented = false; in snd_sof_device_remove()
693 pm_runtime_put_noidle(sdev->dev); in snd_sof_device_remove()
696 if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { in snd_sof_device_remove()
697 sof_fw_trace_free(sdev); in snd_sof_device_remove()
698 ret = snd_sof_dsp_power_down_notify(sdev); in snd_sof_device_remove()
703 snd_sof_ipc_free(sdev); in snd_sof_device_remove()
704 snd_sof_free_debug(sdev); in snd_sof_device_remove()
705 snd_sof_remove(sdev); in snd_sof_device_remove()
706 snd_sof_remove_late(sdev); in snd_sof_device_remove()
707 sof_ops_free(sdev); in snd_sof_device_remove()
710 snd_sof_remove_late(sdev); in snd_sof_device_remove()
711 sof_ops_free(sdev); in snd_sof_device_remove()
715 snd_sof_fw_unload(sdev); in snd_sof_device_remove()
723 struct snd_sof_dev *sdev = dev_get_drvdata(dev); in snd_sof_device_shutdown() local
726 cancel_work_sync(&sdev->probe_work); in snd_sof_device_shutdown()
728 if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { in snd_sof_device_shutdown()
729 sof_fw_trace_free(sdev); in snd_sof_device_shutdown()
730 return snd_sof_shutdown(sdev); in snd_sof_device_shutdown()
738 int sof_machine_register(struct snd_sof_dev *sdev, void *pdata) in sof_machine_register() argument
751 platform_device_register_data(sdev->dev, drv_name, in sof_machine_register()
756 dev_dbg(sdev->dev, "created machine %s\n", in sof_machine_register()
763 void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) in sof_machine_unregister() argument