hda-ipc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2. //
  3. // This file is provided under a dual BSD/GPLv2 license. When using or
  4. // redistributing this file, you may do so under either license.
  5. //
  6. // Copyright(c) 2018 Intel Corporation
  7. //
  8. // Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com>
  9. // Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  10. // Rander Wang <rander.wang@intel.com>
  11. // Keyon Jie <yang.jie@linux.intel.com>
  12. //
  13. /*
  14. * Hardware interface for generic Intel audio DSP HDA IP
  15. */
  16. #include <sound/hda_register.h>
  17. #include <sound/sof/ipc4/header.h>
  18. #include <trace/events/sof_intel.h>
  19. #include "../ops.h"
  20. #include "hda.h"
  21. #include "telemetry.h"
  22. EXPORT_TRACEPOINT_SYMBOL(sof_intel_ipc_firmware_initiated);
  23. EXPORT_TRACEPOINT_SYMBOL(sof_intel_ipc_firmware_response);
  24. EXPORT_TRACEPOINT_SYMBOL(sof_intel_hda_irq_ipc_check);
  25. static void hda_dsp_ipc_host_done(struct snd_sof_dev *sdev)
  26. {
  27. /*
  28. * tell DSP cmd is done - clear busy
  29. * interrupt and send reply msg to dsp
  30. */
  31. snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR,
  32. HDA_DSP_REG_HIPCT,
  33. HDA_DSP_REG_HIPCT_BUSY,
  34. HDA_DSP_REG_HIPCT_BUSY);
  35. /* unmask BUSY interrupt */
  36. snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR,
  37. HDA_DSP_REG_HIPCCTL,
  38. HDA_DSP_REG_HIPCCTL_BUSY,
  39. HDA_DSP_REG_HIPCCTL_BUSY);
  40. }
  41. static void hda_dsp_ipc_dsp_done(struct snd_sof_dev *sdev)
  42. {
  43. /*
  44. * set DONE bit - tell DSP we have received the reply msg
  45. * from DSP, and processed it, don't send more reply to host
  46. */
  47. snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR,
  48. HDA_DSP_REG_HIPCIE,
  49. HDA_DSP_REG_HIPCIE_DONE,
  50. HDA_DSP_REG_HIPCIE_DONE);
  51. /* unmask Done interrupt */
  52. snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR,
  53. HDA_DSP_REG_HIPCCTL,
  54. HDA_DSP_REG_HIPCCTL_DONE,
  55. HDA_DSP_REG_HIPCCTL_DONE);
  56. }
  57. int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
  58. {
  59. /* send IPC message to DSP */
  60. sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
  61. msg->msg_size);
  62. snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI,
  63. HDA_DSP_REG_HIPCI_BUSY);
  64. return 0;
  65. }
  66. EXPORT_SYMBOL_NS(hda_dsp_ipc_send_msg, SND_SOC_SOF_INTEL_HDA_COMMON);
  67. static inline bool hda_dsp_ipc4_pm_msg(u32 primary)
  68. {
  69. /* pm setting is only supported by module msg */
  70. if (SOF_IPC4_MSG_IS_MODULE_MSG(primary) != SOF_IPC4_MODULE_MSG)
  71. return false;
  72. if (SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_DX ||
  73. SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_D0IX)
  74. return true;
  75. return false;
  76. }
  77. void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
  78. struct snd_sof_ipc_msg *msg)
  79. {
  80. struct sof_ipc4_msg *msg_data = msg->msg_data;
  81. /* Schedule a delayed work for d0i3 entry after sending non-pm ipc msg */
  82. if (hda_dsp_ipc4_pm_msg(msg_data->primary))
  83. return;
  84. mod_delayed_work(system_wq, &hdev->d0i3_work,
  85. msecs_to_jiffies(SOF_HDA_D0I3_WORK_DELAY_MS));
  86. }
  87. EXPORT_SYMBOL_NS(hda_dsp_ipc4_schedule_d0i3_work, SND_SOC_SOF_INTEL_HDA_COMMON);
  88. int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
  89. {
  90. struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
  91. struct sof_ipc4_msg *msg_data = msg->msg_data;
  92. if (hda_ipc4_tx_is_busy(sdev)) {
  93. hdev->delayed_ipc_tx_msg = msg;
  94. return 0;
  95. }
  96. hdev->delayed_ipc_tx_msg = NULL;
  97. /* send the message via mailbox */
  98. if (msg_data->data_size)
  99. sof_mailbox_write(sdev, sdev->host_box.offset, msg_data->data_ptr,
  100. msg_data->data_size);
  101. snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCIE, msg_data->extension);
  102. snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI,
  103. msg_data->primary | HDA_DSP_REG_HIPCI_BUSY);
  104. hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
  105. return 0;
  106. }
  107. EXPORT_SYMBOL_NS(hda_dsp_ipc4_send_msg, SND_SOC_SOF_INTEL_HDA_COMMON);
  108. void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
  109. {
  110. struct snd_sof_ipc_msg *msg = sdev->msg;
  111. struct sof_ipc_reply reply;
  112. struct sof_ipc_cmd_hdr *hdr;
  113. /*
  114. * Sometimes, there is unexpected reply ipc arriving. The reply
  115. * ipc belongs to none of the ipcs sent from driver.
  116. * In this case, the driver must ignore the ipc.
  117. */
  118. if (!msg) {
  119. dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n");
  120. return;
  121. }
  122. hdr = msg->msg_data;
  123. if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE) ||
  124. hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE)) {
  125. /*
  126. * memory windows are powered off before sending IPC reply,
  127. * so we can't read the mailbox for CTX_SAVE and PM_GATE
  128. * replies.
  129. */
  130. reply.error = 0;
  131. reply.hdr.cmd = SOF_IPC_GLB_REPLY;
  132. reply.hdr.size = sizeof(reply);
  133. memcpy(msg->reply_data, &reply, sizeof(reply));
  134. msg->reply_error = 0;
  135. } else {
  136. snd_sof_ipc_get_reply(sdev);
  137. }
  138. }
  139. EXPORT_SYMBOL_NS(hda_dsp_ipc_get_reply, SND_SOC_SOF_INTEL_HDA_COMMON);
  140. irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context)
  141. {
  142. struct sof_ipc4_msg notification_data = {{ 0 }};
  143. struct snd_sof_dev *sdev = context;
  144. bool ack_received = false;
  145. bool ipc_irq = false;
  146. u32 hipcie, hipct;
  147. hipcie = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCIE);
  148. hipct = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCT);
  149. if (hipcie & HDA_DSP_REG_HIPCIE_DONE) {
  150. /* DSP received the message */
  151. snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCCTL,
  152. HDA_DSP_REG_HIPCCTL_DONE, 0);
  153. hda_dsp_ipc_dsp_done(sdev);
  154. ipc_irq = true;
  155. ack_received = true;
  156. }
  157. if (hipct & HDA_DSP_REG_HIPCT_BUSY) {
  158. /* Message from DSP (reply or notification) */
  159. u32 hipcte = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
  160. HDA_DSP_REG_HIPCTE);
  161. u32 primary = hipct & HDA_DSP_REG_HIPCT_MSG_MASK;
  162. u32 extension = hipcte & HDA_DSP_REG_HIPCTE_MSG_MASK;
  163. /* mask BUSY interrupt */
  164. snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCCTL,
  165. HDA_DSP_REG_HIPCCTL_BUSY, 0);
  166. if (primary & SOF_IPC4_MSG_DIR_MASK) {
  167. /* Reply received */
  168. if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
  169. struct sof_ipc4_msg *data = sdev->ipc->msg.reply_data;
  170. data->primary = primary;
  171. data->extension = extension;
  172. spin_lock_irq(&sdev->ipc_lock);
  173. snd_sof_ipc_get_reply(sdev);
  174. hda_dsp_ipc_host_done(sdev);
  175. snd_sof_ipc_reply(sdev, data->primary);
  176. spin_unlock_irq(&sdev->ipc_lock);
  177. } else {
  178. dev_dbg_ratelimited(sdev->dev,
  179. "IPC reply before FW_READY: %#x|%#x\n",
  180. primary, extension);
  181. }
  182. } else {
  183. /* Notification received */
  184. notification_data.primary = primary;
  185. notification_data.extension = extension;
  186. sdev->ipc->msg.rx_data = &notification_data;
  187. snd_sof_ipc_msgs_rx(sdev);
  188. sdev->ipc->msg.rx_data = NULL;
  189. /* Let DSP know that we have finished processing the message */
  190. hda_dsp_ipc_host_done(sdev);
  191. }
  192. ipc_irq = true;
  193. }
  194. if (!ipc_irq)
  195. /* This interrupt is not shared so no need to return IRQ_NONE. */
  196. dev_dbg_ratelimited(sdev->dev, "nothing to do in IPC IRQ thread\n");
  197. if (ack_received) {
  198. struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
  199. if (hdev->delayed_ipc_tx_msg)
  200. hda_dsp_ipc4_send_msg(sdev, hdev->delayed_ipc_tx_msg);
  201. }
  202. return IRQ_HANDLED;
  203. }
  204. EXPORT_SYMBOL_NS(hda_dsp_ipc4_irq_thread, SND_SOC_SOF_INTEL_HDA_COMMON);
  205. /* IPC handler thread */
  206. irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context)
  207. {
  208. struct snd_sof_dev *sdev = context;
  209. u32 hipci;
  210. u32 hipcie;
  211. u32 hipct;
  212. u32 hipcte;
  213. u32 msg;
  214. u32 msg_ext;
  215. bool ipc_irq = false;
  216. /* read IPC status */
  217. hipcie = snd_sof_dsp_read(sdev, HDA_DSP_BAR,
  218. HDA_DSP_REG_HIPCIE);
  219. hipct = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCT);
  220. hipci = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI);
  221. hipcte = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCTE);
  222. /* is this a reply message from the DSP */
  223. if (hipcie & HDA_DSP_REG_HIPCIE_DONE) {
  224. msg = hipci & HDA_DSP_REG_HIPCI_MSG_MASK;
  225. msg_ext = hipcie & HDA_DSP_REG_HIPCIE_MSG_MASK;
  226. trace_sof_intel_ipc_firmware_response(sdev, msg, msg_ext);
  227. /* mask Done interrupt */
  228. snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR,
  229. HDA_DSP_REG_HIPCCTL,
  230. HDA_DSP_REG_HIPCCTL_DONE, 0);
  231. /*
  232. * Make sure the interrupt thread cannot be preempted between
  233. * waking up the sender and re-enabling the interrupt. Also
  234. * protect against a theoretical race with sof_ipc_tx_message():
  235. * if the DSP is fast enough to receive an IPC message, reply to
  236. * it, and the host interrupt processing calls this function on
  237. * a different core from the one, where the sending is taking
  238. * place, the message might not yet be marked as expecting a
  239. * reply.
  240. */
  241. if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
  242. spin_lock_irq(&sdev->ipc_lock);
  243. /* handle immediate reply from DSP core */
  244. hda_dsp_ipc_get_reply(sdev);
  245. snd_sof_ipc_reply(sdev, msg);
  246. /* set the done bit */
  247. hda_dsp_ipc_dsp_done(sdev);
  248. spin_unlock_irq(&sdev->ipc_lock);
  249. } else {
  250. dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_READY: %#x\n",
  251. msg);
  252. }
  253. ipc_irq = true;
  254. }
  255. /* is this a new message from DSP */
  256. if (hipct & HDA_DSP_REG_HIPCT_BUSY) {
  257. msg = hipct & HDA_DSP_REG_HIPCT_MSG_MASK;
  258. msg_ext = hipcte & HDA_DSP_REG_HIPCTE_MSG_MASK;
  259. trace_sof_intel_ipc_firmware_initiated(sdev, msg, msg_ext);
  260. /* mask BUSY interrupt */
  261. snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR,
  262. HDA_DSP_REG_HIPCCTL,
  263. HDA_DSP_REG_HIPCCTL_BUSY, 0);
  264. /* handle messages from DSP */
  265. if ((hipct & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
  266. struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
  267. bool non_recoverable = true;
  268. /*
  269. * This is a PANIC message!
  270. *
  271. * If it is arriving during firmware boot and it is not
  272. * the last boot attempt then change the non_recoverable
  273. * to false as the DSP might be able to boot in the next
  274. * iteration(s)
  275. */
  276. if (sdev->fw_state == SOF_FW_BOOT_IN_PROGRESS &&
  277. hda->boot_iteration < HDA_FW_BOOT_ATTEMPTS)
  278. non_recoverable = false;
  279. snd_sof_dsp_panic(sdev, HDA_DSP_PANIC_OFFSET(msg_ext),
  280. non_recoverable);
  281. } else {
  282. /* normal message - process normally */
  283. snd_sof_ipc_msgs_rx(sdev);
  284. }
  285. hda_dsp_ipc_host_done(sdev);
  286. ipc_irq = true;
  287. }
  288. if (!ipc_irq) {
  289. /*
  290. * This interrupt is not shared so no need to return IRQ_NONE.
  291. */
  292. dev_dbg_ratelimited(sdev->dev,
  293. "nothing to do in IPC IRQ thread\n");
  294. }
  295. return IRQ_HANDLED;
  296. }
  297. EXPORT_SYMBOL_NS(hda_dsp_ipc_irq_thread, SND_SOC_SOF_INTEL_HDA_COMMON);
  298. /* Check if an IPC IRQ occurred */
  299. bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev)
  300. {
  301. struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
  302. bool ret = false;
  303. u32 irq_status;
  304. if (sdev->dspless_mode_selected)
  305. return false;
  306. /* store status */
  307. irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS);
  308. trace_sof_intel_hda_irq_ipc_check(sdev, irq_status);
  309. /* invalid message ? */
  310. if (irq_status == 0xffffffff)
  311. goto out;
  312. /* IPC message ? */
  313. if (irq_status & HDA_DSP_ADSPIS_IPC)
  314. ret = true;
  315. /* CLDMA message ? */
  316. if (irq_status & HDA_DSP_ADSPIS_CL_DMA) {
  317. hda->code_loading = 0;
  318. wake_up(&hda->waitq);
  319. ret = false;
  320. }
  321. out:
  322. return ret;
  323. }
  324. EXPORT_SYMBOL_NS(hda_dsp_check_ipc_irq, SND_SOC_SOF_INTEL_HDA_COMMON);
  325. int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev)
  326. {
  327. return HDA_DSP_MBOX_UPLINK_OFFSET;
  328. }
  329. EXPORT_SYMBOL_NS(hda_dsp_ipc_get_mailbox_offset, SND_SOC_SOF_INTEL_HDA_COMMON);
  330. int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id)
  331. {
  332. return SRAM_WINDOW_OFFSET(id);
  333. }
  334. EXPORT_SYMBOL_NS(hda_dsp_ipc_get_window_offset, SND_SOC_SOF_INTEL_HDA_COMMON);
  335. int hda_ipc_msg_data(struct snd_sof_dev *sdev,
  336. struct snd_sof_pcm_stream *sps,
  337. void *p, size_t sz)
  338. {
  339. if (!sps || !sdev->stream_box.size) {
  340. sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
  341. } else {
  342. struct snd_pcm_substream *substream = sps->substream;
  343. struct hdac_stream *hstream = substream->runtime->private_data;
  344. struct sof_intel_hda_stream *hda_stream;
  345. hda_stream = container_of(hstream,
  346. struct sof_intel_hda_stream,
  347. hext_stream.hstream);
  348. /* The stream might already be closed */
  349. if (!hstream)
  350. return -ESTRPIPE;
  351. sof_mailbox_read(sdev, hda_stream->sof_intel_stream.posn_offset, p, sz);
  352. }
  353. return 0;
  354. }
  355. EXPORT_SYMBOL_NS(hda_ipc_msg_data, SND_SOC_SOF_INTEL_HDA_COMMON);
  356. int hda_set_stream_data_offset(struct snd_sof_dev *sdev,
  357. struct snd_sof_pcm_stream *sps,
  358. size_t posn_offset)
  359. {
  360. struct snd_pcm_substream *substream = sps->substream;
  361. struct hdac_stream *hstream = substream->runtime->private_data;
  362. struct sof_intel_hda_stream *hda_stream;
  363. hda_stream = container_of(hstream, struct sof_intel_hda_stream,
  364. hext_stream.hstream);
  365. /* check for unaligned offset or overflow */
  366. if (posn_offset > sdev->stream_box.size ||
  367. posn_offset % sizeof(struct sof_ipc_stream_posn) != 0)
  368. return -EINVAL;
  369. hda_stream->sof_intel_stream.posn_offset = sdev->stream_box.offset + posn_offset;
  370. dev_dbg(sdev->dev, "pcm: stream dir %d, posn mailbox offset is %zu",
  371. substream->stream, hda_stream->sof_intel_stream.posn_offset);
  372. return 0;
  373. }
  374. EXPORT_SYMBOL_NS(hda_set_stream_data_offset, SND_SOC_SOF_INTEL_HDA_COMMON);
  375. void hda_ipc4_dsp_dump(struct snd_sof_dev *sdev, u32 flags)
  376. {
  377. char *level = (flags & SOF_DBG_DUMP_OPTIONAL) ? KERN_DEBUG : KERN_ERR;
  378. /* print ROM/FW status */
  379. hda_dsp_get_state(sdev, level);
  380. if (flags & SOF_DBG_DUMP_REGS)
  381. sof_ipc4_intel_dump_telemetry_state(sdev, flags);
  382. else
  383. hda_dsp_dump_ext_rom_status(sdev, level, flags);
  384. }
  385. EXPORT_SYMBOL_NS(hda_ipc4_dsp_dump, SND_SOC_SOF_INTEL_HDA_COMMON);
  386. bool hda_check_ipc_irq(struct snd_sof_dev *sdev)
  387. {
  388. const struct sof_intel_dsp_desc *chip;
  389. chip = get_chip_info(sdev->pdata);
  390. if (chip && chip->check_ipc_irq)
  391. return chip->check_ipc_irq(sdev);
  392. return false;
  393. }
  394. EXPORT_SYMBOL_NS(hda_check_ipc_irq, SND_SOC_SOF_INTEL_HDA_COMMON);
  395. void hda_ipc_irq_dump(struct snd_sof_dev *sdev)
  396. {
  397. u32 adspis;
  398. u32 intsts;
  399. u32 intctl;
  400. u32 ppsts;
  401. u8 rirbsts;
  402. /* read key IRQ stats and config registers */
  403. adspis = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS);
  404. intsts = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);
  405. intctl = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL);
  406. ppsts = snd_sof_dsp_read(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPSTS);
  407. rirbsts = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, AZX_REG_RIRBSTS);
  408. dev_err(sdev->dev, "hda irq intsts 0x%8.8x intlctl 0x%8.8x rirb %2.2x\n",
  409. intsts, intctl, rirbsts);
  410. dev_err(sdev->dev, "dsp irq ppsts 0x%8.8x adspis 0x%8.8x\n", ppsts, adspis);
  411. }
  412. EXPORT_SYMBOL_NS(hda_ipc_irq_dump, SND_SOC_SOF_INTEL_HDA_COMMON);
  413. void hda_ipc_dump(struct snd_sof_dev *sdev)
  414. {
  415. u32 hipcie;
  416. u32 hipct;
  417. u32 hipcctl;
  418. hda_ipc_irq_dump(sdev);
  419. /* read IPC status */
  420. hipcie = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCIE);
  421. hipct = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCT);
  422. hipcctl = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCCTL);
  423. /* dump the IPC regs */
  424. /* TODO: parse the raw msg */
  425. dev_err(sdev->dev, "host status 0x%8.8x dsp status 0x%8.8x mask 0x%8.8x\n",
  426. hipcie, hipct, hipcctl);
  427. }
  428. EXPORT_SYMBOL_NS(hda_ipc_dump, SND_SOC_SOF_INTEL_HDA_COMMON);
  429. void hda_ipc4_dump(struct snd_sof_dev *sdev)
  430. {
  431. u32 hipci, hipcie, hipct, hipcte, hipcctl;
  432. hda_ipc_irq_dump(sdev);
  433. hipci = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI);
  434. hipcie = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCIE);
  435. hipct = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCT);
  436. hipcte = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCTE);
  437. hipcctl = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCCTL);
  438. /* dump the IPC regs */
  439. /* TODO: parse the raw msg */
  440. dev_err(sdev->dev, "Host IPC initiator: %#x|%#x, target: %#x|%#x, ctl: %#x\n",
  441. hipci, hipcie, hipct, hipcte, hipcctl);
  442. }
  443. EXPORT_SYMBOL_NS(hda_ipc4_dump, SND_SOC_SOF_INTEL_HDA_COMMON);
  444. bool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev)
  445. {
  446. struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
  447. const struct sof_intel_dsp_desc *chip = hda->desc;
  448. u32 val;
  449. val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->ipc_req);
  450. return !!(val & chip->ipc_req_mask);
  451. }
  452. EXPORT_SYMBOL_NS(hda_ipc4_tx_is_busy, SND_SOC_SOF_INTEL_HDA_COMMON);