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()
75 hda_dsp_stream_put(sdev, direction, hstream->stream_tag); in cl_stream_prepare()
85 static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag) in cl_dsp_init() argument
87 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in cl_dsp_init()
94 ret = hda_dsp_core_power_up(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
97 dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n"); in cl_dsp_init()
103 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in cl_dsp_init()
112 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, in cl_dsp_init()
117 ret = hda_dsp_core_run(sdev, BIT(0)); in cl_dsp_init()
120 dev_err(sdev->dev, in cl_dsp_init()
127 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_dsp_init()
136 dev_err(sdev->dev, in cl_dsp_init()
143 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, in cl_dsp_init()
149 ret = hda_dsp_core_power_down(sdev, chip->host_managed_cores_mask & ~(BIT(0))); in cl_dsp_init()
152 dev_err(sdev->dev, in cl_dsp_init()
158 hda_dsp_ipc_int_enable(sdev); in cl_dsp_init()
161 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_dsp_init()
172 dev_err(sdev->dev, in cl_dsp_init()
177 hda_dsp_dump(sdev, SOF_DBG_REGS | SOF_DBG_PCI | SOF_DBG_MBOX); in cl_dsp_init()
178 hda_dsp_core_reset_power_down(sdev, chip->host_managed_cores_mask); in cl_dsp_init()
183 static int cl_trigger(struct snd_sof_dev *sdev, in cl_trigger() argument
192 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL, in cl_trigger()
196 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in cl_trigger()
206 return hda_dsp_stream_trigger(sdev, stream, cmd); in cl_trigger()
210 static int cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, in cl_cleanup() argument
218 ret = hda_dsp_stream_spib_config(sdev, stream, HDA_DSP_SPIB_DISABLE, 0); in cl_cleanup()
220 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, sd_offset, in cl_cleanup()
223 hda_dsp_stream_put(sdev, hstream->direction, hstream->stream_tag); in cl_cleanup()
228 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, in cl_cleanup()
230 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, in cl_cleanup()
233 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, sd_offset, 0); in cl_cleanup()
242 static int cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *stream) in cl_copy_fw() argument
247 ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_START); in cl_copy_fw()
249 dev_err(sdev->dev, "error: DMA trigger start failed\n"); in cl_copy_fw()
253 status = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_copy_fw()
266 dev_err(sdev->dev, in cl_copy_fw()
271 ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_STOP); in cl_copy_fw()
273 dev_err(sdev->dev, "error: DMA trigger stop failed\n"); in cl_copy_fw()
281 int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev) in hda_dsp_cl_boot_firmware_iccmax() argument
283 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware_iccmax()
285 struct hdac_bus *bus = sof_to_bus(sdev); in hda_dsp_cl_boot_firmware_iccmax()
294 dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); in hda_dsp_cl_boot_firmware_iccmax()
301 iccmax_stream = cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size, in hda_dsp_cl_boot_firmware_iccmax()
302 &sdev->dmab_bdl, SNDRV_PCM_STREAM_CAPTURE); in hda_dsp_cl_boot_firmware_iccmax()
304 dev_err(sdev->dev, "error: dma prepare for ICCMAX stream failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
308 ret = hda_dsp_cl_boot_firmware(sdev); in hda_dsp_cl_boot_firmware_iccmax()
314 ret1 = cl_cleanup(sdev, &sdev->dmab_bdl, iccmax_stream); in hda_dsp_cl_boot_firmware_iccmax()
316 dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n"); in hda_dsp_cl_boot_firmware_iccmax()
329 int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) in hda_dsp_cl_boot_firmware() argument
331 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in hda_dsp_cl_boot_firmware()
332 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware()
342 dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); in hda_dsp_cl_boot_firmware()
350 init_waitqueue_head(&sdev->boot_wait); in hda_dsp_cl_boot_firmware()
353 stream = cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size, in hda_dsp_cl_boot_firmware()
354 &sdev->dmab, SNDRV_PCM_STREAM_PLAYBACK); in hda_dsp_cl_boot_firmware()
356 dev_err(sdev->dev, "error: dma prepare for fw loading failed\n"); in hda_dsp_cl_boot_firmware()
360 memcpy(sdev->dmab.area, stripped_firmware.data, in hda_dsp_cl_boot_firmware()
365 dev_dbg(sdev->dev, in hda_dsp_cl_boot_firmware()
369 ret = cl_dsp_init(sdev, stream->hstream.stream_tag); in hda_dsp_cl_boot_firmware()
377 dev_err(sdev->dev, "error: dsp init failed after %d attempts with err: %d\n", in hda_dsp_cl_boot_firmware()
379 dev_err(sdev->dev, "ROM error=0x%x: FW status=0x%x\n", in hda_dsp_cl_boot_firmware()
380 snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_cl_boot_firmware()
382 snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_cl_boot_firmware()
402 if (!sdev->first_boot) in hda_dsp_cl_boot_firmware()
403 hda_sdw_process_wakeen(sdev); in hda_dsp_cl_boot_firmware()
409 ret = cl_copy_fw(sdev, stream); in hda_dsp_cl_boot_firmware()
411 dev_dbg(sdev->dev, "Firmware download successful, booting...\n"); in hda_dsp_cl_boot_firmware()
413 dev_err(sdev->dev, "error: load fw failed ret: %d\n", ret); in hda_dsp_cl_boot_firmware()
421 ret1 = cl_cleanup(sdev, &sdev->dmab, stream); in hda_dsp_cl_boot_firmware()
423 dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n"); in hda_dsp_cl_boot_firmware()
438 hda_dsp_dump(sdev, SOF_DBG_REGS | SOF_DBG_PCI | SOF_DBG_MBOX); in hda_dsp_cl_boot_firmware()
441 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, in hda_dsp_cl_boot_firmware()
448 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev) in hda_dsp_pre_fw_run() argument
451 return hda_dsp_ctrl_clock_power_gating(sdev, false); in hda_dsp_pre_fw_run()
455 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev) in hda_dsp_post_fw_run() argument
459 if (sdev->first_boot) { in hda_dsp_post_fw_run()
460 ret = hda_sdw_startup(sdev); in hda_dsp_post_fw_run()
462 dev_err(sdev->dev, in hda_dsp_post_fw_run()
468 hda_sdw_int_enable(sdev, true); in hda_dsp_post_fw_run()
471 return hda_dsp_ctrl_clock_power_gating(sdev, true); in hda_dsp_post_fw_run()