ops.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
  9. */
  10. #ifndef __SOUND_SOC_SOF_IO_H
  11. #define __SOUND_SOC_SOF_IO_H
  12. #include <linux/device.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/kernel.h>
  15. #include <linux/types.h>
  16. #include <sound/pcm.h>
  17. #include "sof-priv.h"
  18. #define sof_ops(sdev) \
  19. ((sdev)->pdata->desc->ops)
  20. static inline int sof_ops_init(struct snd_sof_dev *sdev)
  21. {
  22. if (sdev->pdata->desc->ops_init)
  23. return sdev->pdata->desc->ops_init(sdev);
  24. return 0;
  25. }
  26. static inline void sof_ops_free(struct snd_sof_dev *sdev)
  27. {
  28. if (sdev->pdata->desc->ops_free)
  29. sdev->pdata->desc->ops_free(sdev);
  30. }
  31. /* Mandatory operations are verified during probing */
  32. /* init */
  33. static inline int snd_sof_probe_early(struct snd_sof_dev *sdev)
  34. {
  35. if (sof_ops(sdev)->probe_early)
  36. return sof_ops(sdev)->probe_early(sdev);
  37. return 0;
  38. }
  39. static inline int snd_sof_probe(struct snd_sof_dev *sdev)
  40. {
  41. return sof_ops(sdev)->probe(sdev);
  42. }
  43. static inline void snd_sof_remove(struct snd_sof_dev *sdev)
  44. {
  45. if (sof_ops(sdev)->remove)
  46. sof_ops(sdev)->remove(sdev);
  47. }
  48. static inline void snd_sof_remove_late(struct snd_sof_dev *sdev)
  49. {
  50. if (sof_ops(sdev)->remove_late)
  51. sof_ops(sdev)->remove_late(sdev);
  52. }
  53. static inline int snd_sof_shutdown(struct snd_sof_dev *sdev)
  54. {
  55. if (sof_ops(sdev)->shutdown)
  56. return sof_ops(sdev)->shutdown(sdev);
  57. return 0;
  58. }
  59. /* control */
  60. /*
  61. * snd_sof_dsp_run returns the core mask of the cores that are available
  62. * after successful fw boot
  63. */
  64. static inline int snd_sof_dsp_run(struct snd_sof_dev *sdev)
  65. {
  66. return sof_ops(sdev)->run(sdev);
  67. }
  68. static inline int snd_sof_dsp_stall(struct snd_sof_dev *sdev, unsigned int core_mask)
  69. {
  70. if (sof_ops(sdev)->stall)
  71. return sof_ops(sdev)->stall(sdev, core_mask);
  72. return 0;
  73. }
  74. static inline int snd_sof_dsp_reset(struct snd_sof_dev *sdev)
  75. {
  76. if (sof_ops(sdev)->reset)
  77. return sof_ops(sdev)->reset(sdev);
  78. return 0;
  79. }
  80. /* dsp core get/put */
  81. static inline int snd_sof_dsp_core_get(struct snd_sof_dev *sdev, int core)
  82. {
  83. if (core > sdev->num_cores - 1) {
  84. dev_err(sdev->dev, "invalid core id: %d for num_cores: %d\n", core,
  85. sdev->num_cores);
  86. return -EINVAL;
  87. }
  88. if (sof_ops(sdev)->core_get) {
  89. int ret;
  90. /* if current ref_count is > 0, increment it and return */
  91. if (sdev->dsp_core_ref_count[core] > 0) {
  92. sdev->dsp_core_ref_count[core]++;
  93. return 0;
  94. }
  95. /* power up the core */
  96. ret = sof_ops(sdev)->core_get(sdev, core);
  97. if (ret < 0)
  98. return ret;
  99. /* increment ref_count */
  100. sdev->dsp_core_ref_count[core]++;
  101. /* and update enabled_cores_mask */
  102. sdev->enabled_cores_mask |= BIT(core);
  103. dev_dbg(sdev->dev, "Core %d powered up\n", core);
  104. }
  105. return 0;
  106. }
  107. static inline int snd_sof_dsp_core_put(struct snd_sof_dev *sdev, int core)
  108. {
  109. if (core > sdev->num_cores - 1) {
  110. dev_err(sdev->dev, "invalid core id: %d for num_cores: %d\n", core,
  111. sdev->num_cores);
  112. return -EINVAL;
  113. }
  114. if (sof_ops(sdev)->core_put) {
  115. int ret;
  116. /* decrement ref_count and return if it is > 0 */
  117. if (--(sdev->dsp_core_ref_count[core]) > 0)
  118. return 0;
  119. /* power down the core */
  120. ret = sof_ops(sdev)->core_put(sdev, core);
  121. if (ret < 0)
  122. return ret;
  123. /* and update enabled_cores_mask */
  124. sdev->enabled_cores_mask &= ~BIT(core);
  125. dev_dbg(sdev->dev, "Core %d powered down\n", core);
  126. }
  127. return 0;
  128. }
  129. /* pre/post fw load */
  130. static inline int snd_sof_dsp_pre_fw_run(struct snd_sof_dev *sdev)
  131. {
  132. if (sof_ops(sdev)->pre_fw_run)
  133. return sof_ops(sdev)->pre_fw_run(sdev);
  134. return 0;
  135. }
  136. static inline int snd_sof_dsp_post_fw_run(struct snd_sof_dev *sdev)
  137. {
  138. if (sof_ops(sdev)->post_fw_run)
  139. return sof_ops(sdev)->post_fw_run(sdev);
  140. return 0;
  141. }
  142. /* parse platform specific extended manifest */
  143. static inline int snd_sof_dsp_parse_platform_ext_manifest(struct snd_sof_dev *sdev,
  144. const struct sof_ext_man_elem_header *hdr)
  145. {
  146. if (sof_ops(sdev)->parse_platform_ext_manifest)
  147. return sof_ops(sdev)->parse_platform_ext_manifest(sdev, hdr);
  148. return 0;
  149. }
  150. /* misc */
  151. /**
  152. * snd_sof_dsp_get_bar_index - Maps a section type with a BAR index
  153. *
  154. * @sdev: sof device
  155. * @type: section type as described by snd_sof_fw_blk_type
  156. *
  157. * Returns the corresponding BAR index (a positive integer) or -EINVAL
  158. * in case there is no mapping
  159. */
  160. static inline int snd_sof_dsp_get_bar_index(struct snd_sof_dev *sdev, u32 type)
  161. {
  162. if (sof_ops(sdev)->get_bar_index)
  163. return sof_ops(sdev)->get_bar_index(sdev, type);
  164. return sdev->mmio_bar;
  165. }
  166. static inline int snd_sof_dsp_get_mailbox_offset(struct snd_sof_dev *sdev)
  167. {
  168. if (sof_ops(sdev)->get_mailbox_offset)
  169. return sof_ops(sdev)->get_mailbox_offset(sdev);
  170. dev_err(sdev->dev, "error: %s not defined\n", __func__);
  171. return -EOPNOTSUPP;
  172. }
  173. static inline int snd_sof_dsp_get_window_offset(struct snd_sof_dev *sdev,
  174. u32 id)
  175. {
  176. if (sof_ops(sdev)->get_window_offset)
  177. return sof_ops(sdev)->get_window_offset(sdev, id);
  178. dev_err(sdev->dev, "error: %s not defined\n", __func__);
  179. return -EOPNOTSUPP;
  180. }
  181. /* power management */
  182. static inline int snd_sof_dsp_resume(struct snd_sof_dev *sdev)
  183. {
  184. if (sof_ops(sdev)->resume)
  185. return sof_ops(sdev)->resume(sdev);
  186. return 0;
  187. }
  188. static inline int snd_sof_dsp_suspend(struct snd_sof_dev *sdev,
  189. u32 target_state)
  190. {
  191. if (sof_ops(sdev)->suspend)
  192. return sof_ops(sdev)->suspend(sdev, target_state);
  193. return 0;
  194. }
  195. static inline int snd_sof_dsp_runtime_resume(struct snd_sof_dev *sdev)
  196. {
  197. if (sof_ops(sdev)->runtime_resume)
  198. return sof_ops(sdev)->runtime_resume(sdev);
  199. return 0;
  200. }
  201. static inline int snd_sof_dsp_runtime_suspend(struct snd_sof_dev *sdev)
  202. {
  203. if (sof_ops(sdev)->runtime_suspend)
  204. return sof_ops(sdev)->runtime_suspend(sdev);
  205. return 0;
  206. }
  207. static inline int snd_sof_dsp_runtime_idle(struct snd_sof_dev *sdev)
  208. {
  209. if (sof_ops(sdev)->runtime_idle)
  210. return sof_ops(sdev)->runtime_idle(sdev);
  211. return 0;
  212. }
  213. static inline int snd_sof_dsp_hw_params_upon_resume(struct snd_sof_dev *sdev)
  214. {
  215. if (sof_ops(sdev)->set_hw_params_upon_resume)
  216. return sof_ops(sdev)->set_hw_params_upon_resume(sdev);
  217. return 0;
  218. }
  219. static inline int snd_sof_dsp_set_clk(struct snd_sof_dev *sdev, u32 freq)
  220. {
  221. if (sof_ops(sdev)->set_clk)
  222. return sof_ops(sdev)->set_clk(sdev, freq);
  223. return 0;
  224. }
  225. static inline int
  226. snd_sof_dsp_set_power_state(struct snd_sof_dev *sdev,
  227. const struct sof_dsp_power_state *target_state)
  228. {
  229. guard(mutex)(&sdev->power_state_access);
  230. if (sof_ops(sdev)->set_power_state)
  231. return sof_ops(sdev)->set_power_state(sdev, target_state);
  232. return 0;
  233. }
  234. /* debug */
  235. void snd_sof_dsp_dbg_dump(struct snd_sof_dev *sdev, const char *msg, u32 flags);
  236. static inline int snd_sof_debugfs_add_region_item(struct snd_sof_dev *sdev,
  237. enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
  238. const char *name, enum sof_debugfs_access_type access_type)
  239. {
  240. if (sof_ops(sdev) && sof_ops(sdev)->debugfs_add_region_item)
  241. return sof_ops(sdev)->debugfs_add_region_item(sdev, blk_type, offset,
  242. size, name, access_type);
  243. return 0;
  244. }
  245. /* register IO */
  246. static inline void snd_sof_dsp_write8(struct snd_sof_dev *sdev, u32 bar,
  247. u32 offset, u8 value)
  248. {
  249. if (sof_ops(sdev)->write8)
  250. sof_ops(sdev)->write8(sdev, sdev->bar[bar] + offset, value);
  251. else
  252. writeb(value, sdev->bar[bar] + offset);
  253. }
  254. static inline void snd_sof_dsp_write(struct snd_sof_dev *sdev, u32 bar,
  255. u32 offset, u32 value)
  256. {
  257. if (sof_ops(sdev)->write)
  258. sof_ops(sdev)->write(sdev, sdev->bar[bar] + offset, value);
  259. else
  260. writel(value, sdev->bar[bar] + offset);
  261. }
  262. static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar,
  263. u32 offset, u64 value)
  264. {
  265. if (sof_ops(sdev)->write64)
  266. sof_ops(sdev)->write64(sdev, sdev->bar[bar] + offset, value);
  267. else
  268. writeq(value, sdev->bar[bar] + offset);
  269. }
  270. static inline u8 snd_sof_dsp_read8(struct snd_sof_dev *sdev, u32 bar,
  271. u32 offset)
  272. {
  273. if (sof_ops(sdev)->read8)
  274. return sof_ops(sdev)->read8(sdev, sdev->bar[bar] + offset);
  275. else
  276. return readb(sdev->bar[bar] + offset);
  277. }
  278. static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar,
  279. u32 offset)
  280. {
  281. if (sof_ops(sdev)->read)
  282. return sof_ops(sdev)->read(sdev, sdev->bar[bar] + offset);
  283. else
  284. return readl(sdev->bar[bar] + offset);
  285. }
  286. static inline u64 snd_sof_dsp_read64(struct snd_sof_dev *sdev, u32 bar,
  287. u32 offset)
  288. {
  289. if (sof_ops(sdev)->read64)
  290. return sof_ops(sdev)->read64(sdev, sdev->bar[bar] + offset);
  291. else
  292. return readq(sdev->bar[bar] + offset);
  293. }
  294. static inline void snd_sof_dsp_update8(struct snd_sof_dev *sdev, u32 bar,
  295. u32 offset, u8 mask, u8 value)
  296. {
  297. u8 reg;
  298. reg = snd_sof_dsp_read8(sdev, bar, offset);
  299. reg &= ~mask;
  300. reg |= value;
  301. snd_sof_dsp_write8(sdev, bar, offset, reg);
  302. }
  303. /* block IO */
  304. static inline int snd_sof_dsp_block_read(struct snd_sof_dev *sdev,
  305. enum snd_sof_fw_blk_type blk_type,
  306. u32 offset, void *dest, size_t bytes)
  307. {
  308. return sof_ops(sdev)->block_read(sdev, blk_type, offset, dest, bytes);
  309. }
  310. static inline int snd_sof_dsp_block_write(struct snd_sof_dev *sdev,
  311. enum snd_sof_fw_blk_type blk_type,
  312. u32 offset, void *src, size_t bytes)
  313. {
  314. return sof_ops(sdev)->block_write(sdev, blk_type, offset, src, bytes);
  315. }
  316. /* mailbox IO */
  317. static inline void snd_sof_dsp_mailbox_read(struct snd_sof_dev *sdev,
  318. u32 offset, void *dest, size_t bytes)
  319. {
  320. if (sof_ops(sdev)->mailbox_read)
  321. sof_ops(sdev)->mailbox_read(sdev, offset, dest, bytes);
  322. }
  323. static inline void snd_sof_dsp_mailbox_write(struct snd_sof_dev *sdev,
  324. u32 offset, void *src, size_t bytes)
  325. {
  326. if (sof_ops(sdev)->mailbox_write)
  327. sof_ops(sdev)->mailbox_write(sdev, offset, src, bytes);
  328. }
  329. /* ipc */
  330. static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev,
  331. struct snd_sof_ipc_msg *msg)
  332. {
  333. return sof_ops(sdev)->send_msg(sdev, msg);
  334. }
  335. /* host PCM ops */
  336. static inline int
  337. snd_sof_pcm_platform_open(struct snd_sof_dev *sdev,
  338. struct snd_pcm_substream *substream)
  339. {
  340. if (sof_ops(sdev) && sof_ops(sdev)->pcm_open)
  341. return sof_ops(sdev)->pcm_open(sdev, substream);
  342. return 0;
  343. }
  344. /* disconnect pcm substream to a host stream */
  345. static inline int
  346. snd_sof_pcm_platform_close(struct snd_sof_dev *sdev,
  347. struct snd_pcm_substream *substream)
  348. {
  349. if (sof_ops(sdev) && sof_ops(sdev)->pcm_close)
  350. return sof_ops(sdev)->pcm_close(sdev, substream);
  351. return 0;
  352. }
  353. /* host stream hw params */
  354. static inline int
  355. snd_sof_pcm_platform_hw_params(struct snd_sof_dev *sdev,
  356. struct snd_pcm_substream *substream,
  357. struct snd_pcm_hw_params *params,
  358. struct snd_sof_platform_stream_params *platform_params)
  359. {
  360. if (sof_ops(sdev) && sof_ops(sdev)->pcm_hw_params)
  361. return sof_ops(sdev)->pcm_hw_params(sdev, substream, params,
  362. platform_params);
  363. return 0;
  364. }
  365. /* host stream hw free */
  366. static inline int
  367. snd_sof_pcm_platform_hw_free(struct snd_sof_dev *sdev,
  368. struct snd_pcm_substream *substream)
  369. {
  370. if (sof_ops(sdev) && sof_ops(sdev)->pcm_hw_free)
  371. return sof_ops(sdev)->pcm_hw_free(sdev, substream);
  372. return 0;
  373. }
  374. /* host stream trigger */
  375. static inline int
  376. snd_sof_pcm_platform_trigger(struct snd_sof_dev *sdev,
  377. struct snd_pcm_substream *substream, int cmd)
  378. {
  379. if (sof_ops(sdev) && sof_ops(sdev)->pcm_trigger)
  380. return sof_ops(sdev)->pcm_trigger(sdev, substream, cmd);
  381. return 0;
  382. }
  383. /* Firmware loading */
  384. static inline int snd_sof_load_firmware(struct snd_sof_dev *sdev)
  385. {
  386. dev_dbg(sdev->dev, "loading firmware\n");
  387. return sof_ops(sdev)->load_firmware(sdev);
  388. }
  389. /* host DSP message data */
  390. static inline int snd_sof_ipc_msg_data(struct snd_sof_dev *sdev,
  391. struct snd_sof_pcm_stream *sps,
  392. void *p, size_t sz)
  393. {
  394. return sof_ops(sdev)->ipc_msg_data(sdev, sps, p, sz);
  395. }
  396. /* host side configuration of the stream's data offset in stream mailbox area */
  397. static inline int
  398. snd_sof_set_stream_data_offset(struct snd_sof_dev *sdev,
  399. struct snd_sof_pcm_stream *sps,
  400. size_t posn_offset)
  401. {
  402. if (sof_ops(sdev) && sof_ops(sdev)->set_stream_data_offset)
  403. return sof_ops(sdev)->set_stream_data_offset(sdev, sps,
  404. posn_offset);
  405. return 0;
  406. }
  407. /* host stream pointer */
  408. static inline snd_pcm_uframes_t
  409. snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev,
  410. struct snd_pcm_substream *substream)
  411. {
  412. if (sof_ops(sdev) && sof_ops(sdev)->pcm_pointer)
  413. return sof_ops(sdev)->pcm_pointer(sdev, substream);
  414. return 0;
  415. }
  416. /* pcm ack */
  417. static inline int snd_sof_pcm_platform_ack(struct snd_sof_dev *sdev,
  418. struct snd_pcm_substream *substream)
  419. {
  420. if (sof_ops(sdev) && sof_ops(sdev)->pcm_ack)
  421. return sof_ops(sdev)->pcm_ack(sdev, substream);
  422. return 0;
  423. }
  424. static inline u64
  425. snd_sof_pcm_get_dai_frame_counter(struct snd_sof_dev *sdev,
  426. struct snd_soc_component *component,
  427. struct snd_pcm_substream *substream)
  428. {
  429. if (sof_ops(sdev) && sof_ops(sdev)->get_dai_frame_counter)
  430. return sof_ops(sdev)->get_dai_frame_counter(sdev, component,
  431. substream);
  432. return 0;
  433. }
  434. static inline u64
  435. snd_sof_pcm_get_host_byte_counter(struct snd_sof_dev *sdev,
  436. struct snd_soc_component *component,
  437. struct snd_pcm_substream *substream)
  438. {
  439. if (sof_ops(sdev) && sof_ops(sdev)->get_host_byte_counter)
  440. return sof_ops(sdev)->get_host_byte_counter(sdev, component,
  441. substream);
  442. return 0;
  443. }
  444. /* machine driver */
  445. static inline int
  446. snd_sof_machine_register(struct snd_sof_dev *sdev, void *pdata)
  447. {
  448. if (sof_ops(sdev) && sof_ops(sdev)->machine_register)
  449. return sof_ops(sdev)->machine_register(sdev, pdata);
  450. return 0;
  451. }
  452. static inline void
  453. snd_sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata)
  454. {
  455. if (sof_ops(sdev) && sof_ops(sdev)->machine_unregister)
  456. sof_ops(sdev)->machine_unregister(sdev, pdata);
  457. }
  458. static inline struct snd_soc_acpi_mach *
  459. snd_sof_machine_select(struct snd_sof_dev *sdev)
  460. {
  461. if (sof_ops(sdev) && sof_ops(sdev)->machine_select)
  462. return sof_ops(sdev)->machine_select(sdev);
  463. return NULL;
  464. }
  465. static inline void
  466. snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach,
  467. struct snd_sof_dev *sdev)
  468. {
  469. if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params)
  470. sof_ops(sdev)->set_mach_params(mach, sdev);
  471. }
  472. static inline bool
  473. snd_sof_is_chain_dma_supported(struct snd_sof_dev *sdev, u32 dai_type)
  474. {
  475. if (sof_ops(sdev) && sof_ops(sdev)->is_chain_dma_supported)
  476. return sof_ops(sdev)->is_chain_dma_supported(sdev, dai_type);
  477. return false;
  478. }
  479. /**
  480. * snd_sof_dsp_register_poll_timeout - Periodically poll an address
  481. * until a condition is met or a timeout occurs
  482. * @op: accessor function (takes @addr as its only argument)
  483. * @addr: Address to poll
  484. * @val: Variable to read the value into
  485. * @cond: Break condition (usually involving @val)
  486. * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops). Please
  487. * read usleep_range() function description for details and
  488. * limitations.
  489. * @timeout_us: Timeout in us, 0 means never timeout
  490. *
  491. * Returns: 0 on success and -ETIMEDOUT upon a timeout. In either
  492. * case, the last read value at @addr is stored in @val. Must not
  493. * be called from atomic context if sleep_us or timeout_us are used.
  494. *
  495. * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
  496. */
  497. #define snd_sof_dsp_read_poll_timeout(sdev, bar, offset, val, cond, sleep_us, timeout_us) \
  498. ({ \
  499. u64 __timeout_us = (timeout_us); \
  500. unsigned long __sleep_us = (sleep_us); \
  501. ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
  502. might_sleep_if((__sleep_us) != 0); \
  503. for (;;) { \
  504. (val) = snd_sof_dsp_read(sdev, bar, offset); \
  505. if (cond) { \
  506. dev_dbg(sdev->dev, \
  507. "FW Poll Status: reg[%#x]=%#x successful\n", \
  508. (offset), (val)); \
  509. break; \
  510. } \
  511. if (__timeout_us && \
  512. ktime_compare(ktime_get(), __timeout) > 0) { \
  513. (val) = snd_sof_dsp_read(sdev, bar, offset); \
  514. dev_dbg(sdev->dev, \
  515. "FW Poll Status: reg[%#x]=%#x timedout\n", \
  516. (offset), (val)); \
  517. break; \
  518. } \
  519. if (__sleep_us) \
  520. usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
  521. } \
  522. (cond) ? 0 : -ETIMEDOUT; \
  523. })
  524. /* This is for registers bits with attribute RWC */
  525. bool snd_sof_pci_update_bits(struct snd_sof_dev *sdev, u32 offset,
  526. u32 mask, u32 value);
  527. bool snd_sof_dsp_update_bits_unlocked(struct snd_sof_dev *sdev, u32 bar,
  528. u32 offset, u32 mask, u32 value);
  529. bool snd_sof_dsp_update_bits64_unlocked(struct snd_sof_dev *sdev, u32 bar,
  530. u32 offset, u64 mask, u64 value);
  531. bool snd_sof_dsp_update_bits(struct snd_sof_dev *sdev, u32 bar, u32 offset,
  532. u32 mask, u32 value);
  533. bool snd_sof_dsp_update_bits64(struct snd_sof_dev *sdev, u32 bar,
  534. u32 offset, u64 mask, u64 value);
  535. void snd_sof_dsp_update_bits_forced(struct snd_sof_dev *sdev, u32 bar,
  536. u32 offset, u32 mask, u32 value);
  537. int snd_sof_dsp_register_poll(struct snd_sof_dev *sdev, u32 bar, u32 offset,
  538. u32 mask, u32 target, u32 timeout_ms,
  539. u32 interval_us);
  540. void snd_sof_dsp_panic(struct snd_sof_dev *sdev, u32 offset, bool non_recoverable);
  541. #endif