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