Lines Matching +full:boot +full:- +full:up

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
24 #include "../ipc4-priv.h"
26 #include "../sof-priv.h"
31 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_ssp_set_cbp_cfp()
32 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_ssp_set_cbp_cfp()
35 /* DSP is powered up, set all SSPs to clock consumer/codec provider mode */ in hda_ssp_set_cbp_cfp()
36 for (i = 0; i < chip->ssp_count; i++) { in hda_ssp_set_cbp_cfp()
38 chip->ssp_base_offset in hda_ssp_set_cbp_cfp()
52 struct pci_dev *pci = to_pci_dev(sdev->dev); in hda_cl_stream_prepare()
58 dev_err(sdev->dev, "error: no stream available\n"); in hda_cl_stream_prepare()
59 return ERR_PTR(-ENODEV); in hda_cl_stream_prepare()
61 hstream = &hext_stream->hstream; in hda_cl_stream_prepare()
62 hstream->substream = NULL; in hda_cl_stream_prepare()
65 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, &pci->dev, size, dmab); in hda_cl_stream_prepare()
67 dev_err(sdev->dev, "error: memory alloc failed: %d\n", ret); in hda_cl_stream_prepare()
71 hstream->period_bytes = 0;/* initialize period_bytes */ in hda_cl_stream_prepare()
72 hstream->format_val = format; in hda_cl_stream_prepare()
73 hstream->bufsize = size; in hda_cl_stream_prepare()
78 dev_err(sdev->dev, "error: iccmax stream prepare failed: %d\n", ret); in hda_cl_stream_prepare()
84 dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); in hda_cl_stream_prepare()
95 hda_dsp_stream_put(sdev, direction, hstream->stream_tag); in hda_cl_stream_prepare()
100 * first boot sequence has some extra steps.
101 * power on all host managed cores and only unstall/run the boot core to boot the
102 * DSP then turn off all non boot cores (if any) is powered on.
106 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in cl_dsp_init()
107 const struct sof_intel_dsp_desc *chip = hda->desc; in cl_dsp_init()
114 /* step 1: power up corex */ in cl_dsp_init()
115 ret = hda_dsp_core_power_up(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
117 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
118 dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n"); in cl_dsp_init()
124 /* step 2: Send ROM_CONTROL command (stream_tag is ignored for IMR boot) */ in cl_dsp_init()
125 ipc_hdr = chip->ipc_req_mask | HDA_DSP_ROM_IPC_CONTROL; in cl_dsp_init()
127 ipc_hdr |= HDA_DSP_ROM_IPC_PURGE_FW | ((stream_tag - 1) << 9); in cl_dsp_init()
129 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, ipc_hdr); in cl_dsp_init()
132 ret = hda_dsp_core_run(sdev, chip->init_core_mask); in cl_dsp_init()
134 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
135 dev_err(sdev->dev, in cl_dsp_init()
137 ret = -EIO; in cl_dsp_init()
143 chip->ipc_ack, status, in cl_dsp_init()
144 ((status & chip->ipc_ack_mask) in cl_dsp_init()
145 == chip->ipc_ack_mask), in cl_dsp_init()
150 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
151 dev_err(sdev->dev, in cl_dsp_init()
159 chip->ipc_ack, in cl_dsp_init()
160 chip->ipc_ack_mask, in cl_dsp_init()
161 chip->ipc_ack_mask); in cl_dsp_init()
164 ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask & in cl_dsp_init()
165 ~(chip->init_core_mask)); in cl_dsp_init()
167 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
168 dev_err(sdev->dev, in cl_dsp_init()
178 * - Cold/Full boot: wait for ROM init to proceed to download the firmware in cl_dsp_init()
179 * - IMR boot: wait for ROM firmware entered (firmware booted up from IMR) in cl_dsp_init()
187 chip->rom_status_reg, status, in cl_dsp_init()
190 chip->rom_init_timeout * in cl_dsp_init()
194 sdev->enabled_cores_mask |= chip->init_core_mask; in cl_dsp_init()
195 mask = sdev->enabled_cores_mask; in cl_dsp_init()
197 sdev->dsp_core_ref_count[j]++; in cl_dsp_init()
201 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
202 dev_err(sdev->dev, in cl_dsp_init()
204 __func__, chip->rom_status_reg); in cl_dsp_init()
209 /* after max boot attempts make sure that the dump is printed */ in cl_dsp_init()
210 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
213 dump_msg = kasprintf(GFP_KERNEL, "Boot iteration failed: %d/%d", in cl_dsp_init()
214 hda->boot_iteration, HDA_FW_BOOT_ATTEMPTS); in cl_dsp_init()
216 hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
225 struct hdac_stream *hstream = &hext_stream->hstream; in cl_trigger()
232 1 << hstream->index, in cl_trigger()
233 1 << hstream->index); in cl_trigger()
242 hstream->running = true; in cl_trigger()
252 struct hdac_stream *hstream = &hext_stream->hstream; in hda_cl_cleanup()
256 if (hstream->direction == SNDRV_PCM_STREAM_PLAYBACK) in hda_cl_cleanup()
262 hda_dsp_stream_put(sdev, hstream->direction, hstream->stream_tag); in hda_cl_cleanup()
263 hstream->running = 0; in hda_cl_cleanup()
264 hstream->substream = NULL; in hda_cl_cleanup()
274 dmab->area = NULL; in hda_cl_cleanup()
275 hstream->bufsize = 0; in hda_cl_cleanup()
276 hstream->format_val = 0; in hda_cl_cleanup()
283 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_cl_copy_fw()
284 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_cl_copy_fw()
290 dev_err(sdev->dev, "error: DMA trigger start failed\n"); in hda_cl_copy_fw()
295 chip->rom_status_reg, reg, in hda_cl_copy_fw()
306 dev_err(sdev->dev, in hda_cl_copy_fw()
308 __func__, chip->rom_status_reg); in hda_cl_copy_fw()
313 dev_err(sdev->dev, "error: DMA trigger stop failed\n"); in hda_cl_copy_fw()
339 dev_err(sdev->dev, "error: dma prepare for ICCMAX stream failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
351 dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
358 /* restore the original guardband value after FW boot */ in hda_dsp_cl_boot_firmware_iccmax()
370 chip_info = get_chip_info(sdev->pdata); in hda_dsp_boot_imr()
371 if (chip_info->cl_init) in hda_dsp_boot_imr()
372 ret = chip_info->cl_init(sdev, 0, true); in hda_dsp_boot_imr()
374 ret = -EINVAL; in hda_dsp_boot_imr()
384 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_cl_boot_firmware()
385 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware()
386 const struct sof_dev_desc *desc = plat_data->desc; in hda_dsp_cl_boot_firmware()
393 if (hda->imrboot_supported && !sdev->first_boot && !hda->skip_imr_boot) { in hda_dsp_cl_boot_firmware()
394 dev_dbg(sdev->dev, "IMR restore supported, booting from IMR directly\n"); in hda_dsp_cl_boot_firmware()
395 hda->boot_iteration = 0; in hda_dsp_cl_boot_firmware()
398 hda->booted_from_imr = true; in hda_dsp_cl_boot_firmware()
402 dev_warn(sdev->dev, "IMR restore failed, trying to cold boot\n"); in hda_dsp_cl_boot_firmware()
405 hda->booted_from_imr = false; in hda_dsp_cl_boot_firmware()
407 chip_info = desc->chip_info; in hda_dsp_cl_boot_firmware()
409 if (sdev->basefw.fw->size <= sdev->basefw.payload_offset) { in hda_dsp_cl_boot_firmware()
410 dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); in hda_dsp_cl_boot_firmware()
411 return -EINVAL; in hda_dsp_cl_boot_firmware()
414 stripped_firmware.data = sdev->basefw.fw->data + sdev->basefw.payload_offset; in hda_dsp_cl_boot_firmware()
415 stripped_firmware.size = sdev->basefw.fw->size - sdev->basefw.payload_offset; in hda_dsp_cl_boot_firmware()
418 init_waitqueue_head(&sdev->boot_wait); in hda_dsp_cl_boot_firmware()
425 dev_err(sdev->dev, "error: dma prepare for fw loading failed\n"); in hda_dsp_cl_boot_firmware()
432 /* try ROM init a few times before giving up */ in hda_dsp_cl_boot_firmware()
434 dev_dbg(sdev->dev, in hda_dsp_cl_boot_firmware()
437 hda->boot_iteration = i + 1; in hda_dsp_cl_boot_firmware()
438 if (chip_info->cl_init) in hda_dsp_cl_boot_firmware()
439 ret = chip_info->cl_init(sdev, hext_stream->hstream.stream_tag, false); in hda_dsp_cl_boot_firmware()
441 ret = -EINVAL; in hda_dsp_cl_boot_firmware()
449 dev_err(sdev->dev, "error: dsp init failed after %d attempts with err: %d\n", in hda_dsp_cl_boot_firmware()
456 * device may trigger in-band wakes for events such as jack in hda_dsp_cl_boot_firmware()
469 if (!sdev->first_boot) in hda_dsp_cl_boot_firmware()
475 * retry done to boot. in hda_dsp_cl_boot_firmware()
477 * Continue with code loading and firmware boot in hda_dsp_cl_boot_firmware()
479 hda->boot_iteration = HDA_FW_BOOT_ATTEMPTS; in hda_dsp_cl_boot_firmware()
482 dev_dbg(sdev->dev, "Firmware download successful, booting...\n"); in hda_dsp_cl_boot_firmware()
483 hda->skip_imr_boot = false; in hda_dsp_cl_boot_firmware()
487 hda->skip_imr_boot = true; in hda_dsp_cl_boot_firmware()
498 dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n"); in hda_dsp_cl_boot_firmware()
507 * and stream clean up are successful in hda_dsp_cl_boot_firmware()
510 return chip_info->init_core_mask; in hda_dsp_cl_boot_firmware()
522 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc4_load_library()
530 if (reload && hda->booted_from_imr) in hda_dsp_ipc4_load_library()
534 stripped_firmware.data = fw_lib->sof_fw.fw->data + fw_lib->sof_fw.payload_offset; in hda_dsp_ipc4_load_library()
535 stripped_firmware.size = fw_lib->sof_fw.fw->size - fw_lib->sof_fw.payload_offset; in hda_dsp_ipc4_load_library()
542 dev_err(sdev->dev, "%s: DMA prepare failed\n", __func__); in hda_dsp_ipc4_load_library()
548 msg.primary = hext_stream->hstream.stream_tag - 1; in hda_dsp_ipc4_load_library()
552 msg.primary |= SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(fw_lib->id); in hda_dsp_ipc4_load_library()
556 dev_err(sdev->dev, "%s: DMA trigger start failed\n", __func__); in hda_dsp_ipc4_load_library()
560 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); in hda_dsp_ipc4_load_library()
564 dev_err(sdev->dev, "%s: DMA trigger stop failed\n", __func__); in hda_dsp_ipc4_load_library()
570 /* clean up even in case of error and return the first error */ in hda_dsp_ipc4_load_library()
573 dev_err(sdev->dev, "%s: Code loader DSP cleanup failed\n", __func__); in hda_dsp_ipc4_load_library()
595 if (sdev->first_boot) { in hda_dsp_post_fw_run()
596 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in hda_dsp_post_fw_run()
600 dev_err(sdev->dev, in hda_dsp_post_fw_run()
605 /* Check if IMR boot is usable */ in hda_dsp_post_fw_run()
607 (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT || in hda_dsp_post_fw_run()
608 sdev->pdata->ipc_type == SOF_INTEL_IPC4)) in hda_dsp_post_fw_run()
609 hdev->imrboot_supported = true; in hda_dsp_post_fw_run()
614 /* re-enable clock gating and power gating */ in hda_dsp_post_fw_run()
623 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ext_man_get_cavs_config_data()
627 elem_num = (hdr->size - sizeof(struct sof_ext_man_elem_header)) in hda_dsp_ext_man_get_cavs_config_data()
630 dev_err(sdev->dev, "cavs config data is inconsistent: %d\n", elem_num); in hda_dsp_ext_man_get_cavs_config_data()
631 return -EINVAL; in hda_dsp_ext_man_get_cavs_config_data()
635 switch (config_data->elems[i].token) { in hda_dsp_ext_man_get_cavs_config_data()
640 hda->clk_config_lpro = config_data->elems[i].value; in hda_dsp_ext_man_get_cavs_config_data()
641 dev_dbg(sdev->dev, "FW clock config: %s\n", in hda_dsp_ext_man_get_cavs_config_data()
642 hda->clk_config_lpro ? "LPRO" : "HPRO"); in hda_dsp_ext_man_get_cavs_config_data()
649 dev_info(sdev->dev, "unsupported token type: %d\n", in hda_dsp_ext_man_get_cavs_config_data()
650 config_data->elems[i].token); in hda_dsp_ext_man_get_cavs_config_data()