Lines Matching +full:skip +full:- +full:power +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()
58 dev_err(sdev->dev, "error: no stream available\n"); in hda_cl_prepare()
59 return ERR_PTR(-ENODEV); in hda_cl_prepare()
61 hstream = &hext_stream->hstream; in hda_cl_prepare()
62 hstream->substream = NULL; in hda_cl_prepare()
67 dev_err(sdev->dev, "error: memory alloc failed: %d\n", ret); in hda_cl_prepare()
71 hstream->period_bytes = 0;/* initialize period_bytes */ in hda_cl_prepare()
72 hstream->format_val = format; in hda_cl_prepare()
73 hstream->bufsize = size; in hda_cl_prepare()
78 dev_err(sdev->dev, "error: iccmax stream prepare failed: %d\n", ret); in hda_cl_prepare()
84 dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); in hda_cl_prepare()
95 hda_dsp_stream_put(sdev, direction, hstream->stream_tag); in hda_cl_prepare()
102 * power on all host managed cores and only unstall/run the boot core to boot the
107 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in cl_dsp_init()
108 const struct sof_intel_dsp_desc *chip = hda->desc; in cl_dsp_init()
115 /* step 1: power up corex */ in cl_dsp_init()
116 ret = hda_dsp_core_power_up(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
118 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
119 dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n"); in cl_dsp_init()
126 ipc_hdr = chip->ipc_req_mask | HDA_DSP_ROM_IPC_CONTROL; in cl_dsp_init()
128 ipc_hdr |= HDA_DSP_ROM_IPC_PURGE_FW | ((stream_tag - 1) << 9); in cl_dsp_init()
130 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, ipc_hdr); in cl_dsp_init()
133 ret = hda_dsp_core_run(sdev, chip->init_core_mask); in cl_dsp_init()
135 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
136 dev_err(sdev->dev, in cl_dsp_init()
138 ret = -EIO; in cl_dsp_init()
144 chip->ipc_ack, status, in cl_dsp_init()
145 ((status & chip->ipc_ack_mask) in cl_dsp_init()
146 == chip->ipc_ack_mask), in cl_dsp_init()
151 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
152 dev_err(sdev->dev, in cl_dsp_init()
160 chip->ipc_ack, in cl_dsp_init()
161 chip->ipc_ack_mask, in cl_dsp_init()
162 chip->ipc_ack_mask); in cl_dsp_init()
164 /* step 5: power down cores that are no longer needed */ in cl_dsp_init()
165 ret = hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask & in cl_dsp_init()
166 ~(chip->init_core_mask)); in cl_dsp_init()
168 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
169 dev_err(sdev->dev, in cl_dsp_init()
170 "error: dsp core x power down failed\n"); in cl_dsp_init()
179 * - Cold/Full boot: wait for ROM init to proceed to download the firmware in cl_dsp_init()
180 * - IMR boot: wait for ROM firmware entered (firmware booted up from IMR) in cl_dsp_init()
188 chip->rom_status_reg, status, in cl_dsp_init()
191 chip->rom_init_timeout * in cl_dsp_init()
195 sdev->enabled_cores_mask |= chip->init_core_mask; in cl_dsp_init()
196 mask = sdev->enabled_cores_mask; in cl_dsp_init()
198 sdev->dsp_core_ref_count[j]++; in cl_dsp_init()
202 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
203 dev_err(sdev->dev, in cl_dsp_init()
205 __func__, chip->rom_status_reg); in cl_dsp_init()
211 if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) in cl_dsp_init()
215 hda->boot_iteration, HDA_FW_BOOT_ATTEMPTS); in cl_dsp_init()
217 hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
227 struct hdac_stream *hstream = &hext_stream->hstream; in hda_cl_trigger()
236 reinit_completion(&hda_stream->ioc); in hda_cl_trigger()
239 1 << hstream->index, in hda_cl_trigger()
240 1 << hstream->index); in hda_cl_trigger()
249 hstream->running = true; in hda_cl_trigger()
261 struct hdac_stream *hstream = &hext_stream->hstream; in hda_cl_cleanup()
265 if (hstream->direction == SNDRV_PCM_STREAM_PLAYBACK) in hda_cl_cleanup()
271 hda_dsp_stream_put(sdev, hstream->direction, hstream->stream_tag); in hda_cl_cleanup()
272 hstream->running = 0; in hda_cl_cleanup()
273 hstream->substream = NULL; in hda_cl_cleanup()
283 dmab->area = NULL; in hda_cl_cleanup()
284 hstream->bufsize = 0; in hda_cl_cleanup()
285 hstream->format_val = 0; in hda_cl_cleanup()
295 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_cl_copy_fw()
296 const struct sof_intel_dsp_desc *chip = hda->desc; in hda_cl_copy_fw()
300 dev_dbg(sdev->dev, "Code loader DMA starting\n"); in hda_cl_copy_fw()
302 ret = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_START); in hda_cl_copy_fw()
304 dev_err(sdev->dev, "error: DMA trigger start failed\n"); in hda_cl_copy_fw()
308 dev_dbg(sdev->dev, "waiting for FW_ENTERED status\n"); in hda_cl_copy_fw()
311 chip->rom_status_reg, reg, in hda_cl_copy_fw()
322 dev_err(sdev->dev, in hda_cl_copy_fw()
324 __func__, chip->rom_status_reg); in hda_cl_copy_fw()
326 dev_dbg(sdev->dev, "Code loader FW_ENTERED status\n"); in hda_cl_copy_fw()
329 ret = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_STOP); in hda_cl_copy_fw()
331 dev_err(sdev->dev, "error: DMA trigger stop failed\n"); in hda_cl_copy_fw()
335 dev_dbg(sdev->dev, "Code loader DMA stopped\n"); in hda_cl_copy_fw()
356 iccmax_stream = hda_cl_prepare(sdev->dev, HDA_CL_STREAM_FORMAT, PAGE_SIZE, in hda_dsp_cl_boot_firmware_iccmax()
359 dev_err(sdev->dev, "error: dma prepare for ICCMAX stream failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
369 ret1 = hda_cl_cleanup(sdev->dev, &dmab_bdl, iccmax_stream); in hda_dsp_cl_boot_firmware_iccmax()
371 dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
391 chip_info = get_chip_info(sdev->pdata); in hda_dsp_boot_imr()
392 if (chip_info->cl_init) in hda_dsp_boot_imr()
393 ret = chip_info->cl_init(sdev, 0, true); in hda_dsp_boot_imr()
395 ret = -EINVAL; in hda_dsp_boot_imr()
405 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_cl_boot_firmware()
406 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware()
407 const struct sof_dev_desc *desc = plat_data->desc; in hda_dsp_cl_boot_firmware()
414 if (hda->imrboot_supported && !sdev->first_boot && !hda->skip_imr_boot) { in hda_dsp_cl_boot_firmware()
415 dev_dbg(sdev->dev, "IMR restore supported, booting from IMR directly\n"); in hda_dsp_cl_boot_firmware()
416 hda->boot_iteration = 0; in hda_dsp_cl_boot_firmware()
419 hda->booted_from_imr = true; in hda_dsp_cl_boot_firmware()
423 dev_warn(sdev->dev, "IMR restore failed, trying to cold boot\n"); in hda_dsp_cl_boot_firmware()
426 hda->booted_from_imr = false; in hda_dsp_cl_boot_firmware()
428 chip_info = desc->chip_info; in hda_dsp_cl_boot_firmware()
430 if (sdev->basefw.fw->size <= sdev->basefw.payload_offset) { in hda_dsp_cl_boot_firmware()
431 dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); in hda_dsp_cl_boot_firmware()
432 return -EINVAL; in hda_dsp_cl_boot_firmware()
435 stripped_firmware.data = sdev->basefw.fw->data + sdev->basefw.payload_offset; in hda_dsp_cl_boot_firmware()
436 stripped_firmware.size = sdev->basefw.fw->size - sdev->basefw.payload_offset; in hda_dsp_cl_boot_firmware()
439 init_waitqueue_head(&sdev->boot_wait); in hda_dsp_cl_boot_firmware()
442 hext_stream = hda_cl_prepare(sdev->dev, HDA_CL_STREAM_FORMAT, in hda_dsp_cl_boot_firmware()
446 dev_err(sdev->dev, "error: dma prepare for fw loading failed\n"); in hda_dsp_cl_boot_firmware()
453 /* try ROM init a few times before giving up */ in hda_dsp_cl_boot_firmware()
455 dev_dbg(sdev->dev, in hda_dsp_cl_boot_firmware()
458 hda->boot_iteration = i + 1; in hda_dsp_cl_boot_firmware()
459 if (chip_info->cl_init) in hda_dsp_cl_boot_firmware()
460 ret = chip_info->cl_init(sdev, hext_stream->hstream.stream_tag, false); in hda_dsp_cl_boot_firmware()
462 ret = -EINVAL; in hda_dsp_cl_boot_firmware()
470 dev_err(sdev->dev, "error: dsp init failed after %d attempts with err: %d\n", in hda_dsp_cl_boot_firmware()
477 * device may trigger in-band wakes for events such as jack in hda_dsp_cl_boot_firmware()
487 * is initialized successfully, which ensures power rails are in hda_dsp_cl_boot_firmware()
490 if (!sdev->first_boot) in hda_dsp_cl_boot_firmware()
500 hda->boot_iteration = HDA_FW_BOOT_ATTEMPTS; in hda_dsp_cl_boot_firmware()
503 dev_dbg(sdev->dev, "Firmware download successful, booting...\n"); in hda_dsp_cl_boot_firmware()
504 hda->skip_imr_boot = false; in hda_dsp_cl_boot_firmware()
508 hda->skip_imr_boot = true; in hda_dsp_cl_boot_firmware()
517 ret1 = hda_cl_cleanup(sdev->dev, &dmab, hext_stream); in hda_dsp_cl_boot_firmware()
519 dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n"); in hda_dsp_cl_boot_firmware()
528 * and stream clean up are successful in hda_dsp_cl_boot_firmware()
531 return chip_info->init_core_mask; in hda_dsp_cl_boot_firmware()
543 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ipc4_load_library()
544 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in hda_dsp_ipc4_load_library()
551 /* if IMR booting is enabled and fw context is saved for D3 state, skip the loading */ in hda_dsp_ipc4_load_library()
552 if (reload && hda->booted_from_imr && ipc4_data->fw_context_save) in hda_dsp_ipc4_load_library()
556 stripped_firmware.data = fw_lib->sof_fw.fw->data + fw_lib->sof_fw.payload_offset; in hda_dsp_ipc4_load_library()
557 stripped_firmware.size = fw_lib->sof_fw.fw->size - fw_lib->sof_fw.payload_offset; in hda_dsp_ipc4_load_library()
560 hext_stream = hda_cl_prepare(sdev->dev, HDA_CL_STREAM_FORMAT, in hda_dsp_ipc4_load_library()
564 dev_err(sdev->dev, "%s: DMA prepare failed\n", __func__); in hda_dsp_ipc4_load_library()
574 * receive -EOPNOTSUPP. In this case we will use single step library in hda_dsp_ipc4_load_library()
577 msg.primary = hext_stream->hstream.stream_tag - 1; in hda_dsp_ipc4_load_library()
581 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); in hda_dsp_ipc4_load_library()
583 int sd_offset = SOF_STREAM_SD_OFFSET(&hext_stream->hstream); in hda_dsp_ipc4_load_library()
599 dev_warn(sdev->dev, in hda_dsp_ipc4_load_library()
601 } else if (ret != -EOPNOTSUPP) { in hda_dsp_ipc4_load_library()
605 ret = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_START); in hda_dsp_ipc4_load_library()
607 dev_err(sdev->dev, "%s: DMA trigger start failed\n", __func__); in hda_dsp_ipc4_load_library()
618 msg.primary |= SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(fw_lib->id); in hda_dsp_ipc4_load_library()
619 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); in hda_dsp_ipc4_load_library()
622 ret1 = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_STOP); in hda_dsp_ipc4_load_library()
624 dev_err(sdev->dev, "%s: DMA trigger stop failed\n", __func__); in hda_dsp_ipc4_load_library()
630 /* clean up even in case of error and return the first error */ in hda_dsp_ipc4_load_library()
631 ret1 = hda_cl_cleanup(sdev->dev, &dmab, hext_stream); in hda_dsp_ipc4_load_library()
633 dev_err(sdev->dev, "%s: Code loader DSP cleanup failed\n", __func__); in hda_dsp_ipc4_load_library()
649 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_ext_man_get_cavs_config_data()
653 elem_num = (hdr->size - sizeof(struct sof_ext_man_elem_header)) in hda_dsp_ext_man_get_cavs_config_data()
656 dev_err(sdev->dev, "cavs config data is inconsistent: %d\n", elem_num); in hda_dsp_ext_man_get_cavs_config_data()
657 return -EINVAL; in hda_dsp_ext_man_get_cavs_config_data()
661 switch (config_data->elems[i].token) { in hda_dsp_ext_man_get_cavs_config_data()
663 /* skip empty token */ in hda_dsp_ext_man_get_cavs_config_data()
666 hda->clk_config_lpro = config_data->elems[i].value; in hda_dsp_ext_man_get_cavs_config_data()
667 dev_dbg(sdev->dev, "FW clock config: %s\n", in hda_dsp_ext_man_get_cavs_config_data()
668 hda->clk_config_lpro ? "LPRO" : "HPRO"); in hda_dsp_ext_man_get_cavs_config_data()
675 dev_info(sdev->dev, "unsupported token type: %d\n", in hda_dsp_ext_man_get_cavs_config_data()
676 config_data->elems[i].token); in hda_dsp_ext_man_get_cavs_config_data()