Lines Matching refs:sdev
28 static struct hdac_ext_stream *cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format, in cl_stream_prepare() argument
34 struct pci_dev *pci = to_pci_dev(sdev->dev); in cl_stream_prepare()
37 dsp_stream = hda_dsp_stream_get(sdev, direction); in cl_stream_prepare()
40 dev_err(sdev->dev, "error: no stream available\n"); in cl_stream_prepare()
49 dev_err(sdev->dev, "error: memory alloc failed: %x\n", ret); in cl_stream_prepare()
58 ret = hda_dsp_iccmax_stream_hw_params(sdev, dsp_stream, dmab, NULL); in cl_stream_prepare()
60 dev_err(sdev->dev, "error: iccmax stream prepare failed: %x\n", ret); in cl_stream_prepare()
64 ret = hda_dsp_stream_hw_params(sdev, dsp_stream, dmab, NULL); in cl_stream_prepare()
66 dev_err(sdev->dev, "error: hdac prepare failed: %x\n", ret); in cl_stream_prepare()
69 hda_dsp_stream_spib_config(sdev, dsp_stream, HDA_DSP_SPIB_ENABLE, size); in cl_stream_prepare()
77 hda_dsp_stream_put(sdev, direction, hstream->stream_tag); in cl_stream_prepare()
86 static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag) in cl_dsp_init() argument
88 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in cl_dsp_init()
95 ret = hda_dsp_core_power_up(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
98 dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n"); in cl_dsp_init()
104 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in cl_dsp_init()
113 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, in cl_dsp_init()
118 ret = hda_dsp_core_run(sdev, chip->init_core_mask); in cl_dsp_init()
121 dev_err(sdev->dev, in cl_dsp_init()
128 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_dsp_init()
137 dev_err(sdev->dev, in cl_dsp_init()
144 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, in cl_dsp_init()
150 ret = hda_dsp_core_power_down(sdev, chip->host_managed_cores_mask & ~(BIT(0))); in cl_dsp_init()
153 dev_err(sdev->dev, in cl_dsp_init()
159 hda_dsp_ipc_int_enable(sdev); in cl_dsp_init()
162 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_dsp_init()
173 dev_err(sdev->dev, in cl_dsp_init()
178 hda_dsp_dump(sdev, SOF_DBG_REGS | SOF_DBG_PCI | SOF_DBG_MBOX); in cl_dsp_init()
179 hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
184 static int cl_trigger(struct snd_sof_dev *sdev, in cl_trigger() argument
193 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL, in cl_trigger()
197 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in cl_trigger()
207 return hda_dsp_stream_trigger(sdev, stream, cmd); in cl_trigger()
211 static int cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, in cl_cleanup() argument
219 ret = hda_dsp_stream_spib_config(sdev, stream, HDA_DSP_SPIB_DISABLE, 0); in cl_cleanup()
221 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, sd_offset, in cl_cleanup()
224 hda_dsp_stream_put(sdev, hstream->direction, hstream->stream_tag); in cl_cleanup()
229 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, in cl_cleanup()
231 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, in cl_cleanup()
234 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, sd_offset, 0); in cl_cleanup()
243 static int cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *stream) in cl_copy_fw() argument
248 ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_START); in cl_copy_fw()
250 dev_err(sdev->dev, "error: DMA trigger start failed\n"); in cl_copy_fw()
254 status = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_copy_fw()
267 dev_err(sdev->dev, in cl_copy_fw()
272 ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_STOP); in cl_copy_fw()
274 dev_err(sdev->dev, "error: DMA trigger stop failed\n"); in cl_copy_fw()
282 int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev) in hda_dsp_cl_boot_firmware_iccmax() argument
284 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware_iccmax()
286 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_cl_boot_firmware_iccmax()
295 dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); in hda_dsp_cl_boot_firmware_iccmax()
302 iccmax_stream = cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size, in hda_dsp_cl_boot_firmware_iccmax()
303 &sdev->dmab_bdl, SNDRV_PCM_STREAM_CAPTURE); in hda_dsp_cl_boot_firmware_iccmax()
305 dev_err(sdev->dev, "error: dma prepare for ICCMAX stream failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
309 ret = hda_dsp_cl_boot_firmware(sdev); in hda_dsp_cl_boot_firmware_iccmax()
315 ret1 = cl_cleanup(sdev, &sdev->dmab_bdl, iccmax_stream); in hda_dsp_cl_boot_firmware_iccmax()
317 dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
330 int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) in hda_dsp_cl_boot_firmware() argument
332 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_cl_boot_firmware()
333 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware()
343 dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); in hda_dsp_cl_boot_firmware()
351 init_waitqueue_head(&sdev->boot_wait); in hda_dsp_cl_boot_firmware()
354 stream = cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size, in hda_dsp_cl_boot_firmware()
355 &sdev->dmab, SNDRV_PCM_STREAM_PLAYBACK); in hda_dsp_cl_boot_firmware()
357 dev_err(sdev->dev, "error: dma prepare for fw loading failed\n"); in hda_dsp_cl_boot_firmware()
361 memcpy(sdev->dmab.area, stripped_firmware.data, in hda_dsp_cl_boot_firmware()
366 dev_dbg(sdev->dev, in hda_dsp_cl_boot_firmware()
370 ret = cl_dsp_init(sdev, stream->hstream.stream_tag); in hda_dsp_cl_boot_firmware()
378 dev_err(sdev->dev, "error: dsp init failed after %d attempts with err: %d\n", in hda_dsp_cl_boot_firmware()
380 dev_err(sdev->dev, "ROM error=0x%x: FW status=0x%x\n", in hda_dsp_cl_boot_firmware()
381 snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_cl_boot_firmware()
383 snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_cl_boot_firmware()
403 if (!sdev->first_boot) in hda_dsp_cl_boot_firmware()
404 hda_sdw_process_wakeen(sdev); in hda_dsp_cl_boot_firmware()
410 ret = cl_copy_fw(sdev, stream); in hda_dsp_cl_boot_firmware()
412 dev_dbg(sdev->dev, "Firmware download successful, booting...\n"); in hda_dsp_cl_boot_firmware()
414 dev_err(sdev->dev, "error: load fw failed ret: %d\n", ret); in hda_dsp_cl_boot_firmware()
422 ret1 = cl_cleanup(sdev, &sdev->dmab, stream); in hda_dsp_cl_boot_firmware()
424 dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n"); in hda_dsp_cl_boot_firmware()
439 hda_dsp_dump(sdev, SOF_DBG_REGS | SOF_DBG_PCI | SOF_DBG_MBOX); in hda_dsp_cl_boot_firmware()
442 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, in hda_dsp_cl_boot_firmware()
449 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev) in hda_dsp_pre_fw_run() argument
452 return hda_dsp_ctrl_clock_power_gating(sdev, false); in hda_dsp_pre_fw_run()
456 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev) in hda_dsp_post_fw_run() argument
460 if (sdev->first_boot) { in hda_dsp_post_fw_run()
461 ret = hda_sdw_startup(sdev); in hda_dsp_post_fw_run()
463 dev_err(sdev->dev, in hda_dsp_post_fw_run()
469 hda_sdw_int_enable(sdev, true); in hda_dsp_post_fw_run()
472 return hda_dsp_ctrl_clock_power_gating(sdev, true); in hda_dsp_post_fw_run()