Lines Matching refs:sdev

26 static int cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,  in cl_stream_prepare()  argument
32 struct pci_dev *pci = to_pci_dev(sdev->dev); in cl_stream_prepare()
36 dev_err(sdev->dev, "error: code loading DMA is playback only\n"); in cl_stream_prepare()
40 dsp_stream = hda_dsp_stream_get(sdev, direction); in cl_stream_prepare()
43 dev_err(sdev->dev, "error: no stream available\n"); in cl_stream_prepare()
52 dev_err(sdev->dev, "error: memory alloc failed: %x\n", ret); in cl_stream_prepare()
60 ret = hda_dsp_stream_hw_params(sdev, dsp_stream, dmab, NULL); in cl_stream_prepare()
62 dev_err(sdev->dev, "error: hdac prepare failed: %x\n", ret); in cl_stream_prepare()
66 hda_dsp_stream_spib_config(sdev, dsp_stream, HDA_DSP_SPIB_ENABLE, size); in cl_stream_prepare()
71 hda_dsp_stream_put(sdev, direction, hstream->stream_tag); in cl_stream_prepare()
81 static int cl_dsp_init(struct snd_sof_dev *sdev, const void *fwdata, in cl_dsp_init() argument
84 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in cl_dsp_init()
91 ret = hda_dsp_core_power_up(sdev, chip->cores_mask); in cl_dsp_init()
93 dev_err(sdev->dev, "error: dsp core 0/1 power up failed\n"); in cl_dsp_init()
99 snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, in cl_dsp_init()
108 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, in cl_dsp_init()
113 ret = hda_dsp_core_run(sdev, HDA_DSP_CORE_MASK(0)); in cl_dsp_init()
115 dev_err(sdev->dev, "error: dsp core start failed %d\n", ret); in cl_dsp_init()
121 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_dsp_init()
129 dev_err(sdev->dev, "error: waiting for HIPCIE done\n"); in cl_dsp_init()
134 ret = hda_dsp_core_power_down(sdev, in cl_dsp_init()
137 dev_err(sdev->dev, "error: dsp core x power down failed\n"); in cl_dsp_init()
142 hda_dsp_ipc_int_enable(sdev); in cl_dsp_init()
145 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_dsp_init()
156 hda_dsp_dump(sdev, SOF_DBG_REGS | SOF_DBG_PCI | SOF_DBG_MBOX); in cl_dsp_init()
157 hda_dsp_core_reset_power_down(sdev, chip->cores_mask); in cl_dsp_init()
162 static int cl_trigger(struct snd_sof_dev *sdev, in cl_trigger() argument
171 wait_event_timeout(sdev->waitq, !sdev->code_loading, in cl_trigger()
174 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL, in cl_trigger()
178 snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, in cl_trigger()
188 return hda_dsp_stream_trigger(sdev, stream, cmd); in cl_trigger()
192 static struct hdac_ext_stream *get_stream_with_tag(struct snd_sof_dev *sdev, in get_stream_with_tag() argument
195 struct hdac_bus *bus = sof_to_bus(sdev); in get_stream_with_tag()
209 static int cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, in cl_cleanup() argument
216 ret = hda_dsp_stream_spib_config(sdev, stream, HDA_DSP_SPIB_DISABLE, 0); in cl_cleanup()
218 hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_PLAYBACK, in cl_cleanup()
224 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, in cl_cleanup()
226 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, in cl_cleanup()
229 snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, sd_offset, 0); in cl_cleanup()
238 static int cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *stream) in cl_copy_fw() argument
243 ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_START); in cl_copy_fw()
245 dev_err(sdev->dev, "error: DMA trigger start failed\n"); in cl_copy_fw()
249 status = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in cl_copy_fw()
256 ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_STOP); in cl_copy_fw()
258 dev_err(sdev->dev, "error: DMA trigger stop failed\n"); in cl_copy_fw()
265 int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) in hda_dsp_cl_boot_firmware() argument
267 struct snd_sof_pdata *plat_data = sdev->pdata; in hda_dsp_cl_boot_firmware()
280 init_waitqueue_head(&sdev->boot_wait); in hda_dsp_cl_boot_firmware()
281 sdev->boot_complete = false; in hda_dsp_cl_boot_firmware()
284 tag = cl_stream_prepare(sdev, 0x40, stripped_firmware.size, in hda_dsp_cl_boot_firmware()
285 &sdev->dmab, SNDRV_PCM_STREAM_PLAYBACK); in hda_dsp_cl_boot_firmware()
288 dev_err(sdev->dev, "error: dma prepare for fw loading err: %x\n", in hda_dsp_cl_boot_firmware()
294 stream = get_stream_with_tag(sdev, tag); in hda_dsp_cl_boot_firmware()
296 dev_err(sdev->dev, in hda_dsp_cl_boot_firmware()
303 memcpy(sdev->dmab.area, stripped_firmware.data, in hda_dsp_cl_boot_firmware()
308 ret = cl_dsp_init(sdev, stripped_firmware.data, in hda_dsp_cl_boot_firmware()
315 dev_err(sdev->dev, "error: Error code=0x%x: FW status=0x%x\n", in hda_dsp_cl_boot_firmware()
316 snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_cl_boot_firmware()
318 snd_sof_dsp_read(sdev, HDA_DSP_BAR, in hda_dsp_cl_boot_firmware()
320 dev_err(sdev->dev, "error: iteration %d of Core En/ROM load failed: %d\n", in hda_dsp_cl_boot_firmware()
325 dev_err(sdev->dev, "error: dsp init failed after %d attempts with err: %d\n", in hda_dsp_cl_boot_firmware()
334 ret = cl_copy_fw(sdev, stream); in hda_dsp_cl_boot_firmware()
336 dev_dbg(sdev->dev, "Firmware download successful, booting...\n"); in hda_dsp_cl_boot_firmware()
338 dev_err(sdev->dev, "error: load fw failed ret: %d\n", ret); in hda_dsp_cl_boot_firmware()
345 ret1 = cl_cleanup(sdev, &sdev->dmab, stream); in hda_dsp_cl_boot_firmware()
347 dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n"); in hda_dsp_cl_boot_firmware()
362 hda_dsp_dump(sdev, SOF_DBG_REGS | SOF_DBG_PCI | SOF_DBG_MBOX); in hda_dsp_cl_boot_firmware()
365 snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, in hda_dsp_cl_boot_firmware()
372 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev) in hda_dsp_pre_fw_run() argument
375 return hda_dsp_ctrl_clock_power_gating(sdev, false); in hda_dsp_pre_fw_run()
379 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev) in hda_dsp_post_fw_run() argument
382 return hda_dsp_ctrl_clock_power_gating(sdev, true); in hda_dsp_post_fw_run()