ops.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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. int ret = 0;
  230. mutex_lock(&sdev->power_state_access);
  231. if (sof_ops(sdev)->set_power_state)
  232. ret = sof_ops(sdev)->set_power_state(sdev, target_state);
  233. mutex_unlock(&sdev->power_state_access);
  234. return ret;
  235. }
  236. /* debug */
  237. void snd_sof_dsp_dbg_dump(struct snd_sof_dev *sdev, const char *msg, u32 flags);
  238. static inline int snd_sof_debugfs_add_region_item(struct snd_sof_dev *sdev,
  239. enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
  240. const char *name, enum sof_debugfs_access_type access_type)
  241. {
  242. if (sof_ops(sdev) && sof_ops(sdev)->debugfs_add_region_item)
  243. return sof_ops(sdev)->debugfs_add_region_item(sdev, blk_type, offset,
  244. size, name, access_type);
  245. return 0;
  246. }
  247. /* register IO */
  248. static inline void snd_sof_dsp_write8(struct snd_sof_dev *sdev, u32 bar,
  249. u32 offset, u8 value)
  250. {
  251. if (sof_ops(sdev)->write8)
  252. sof_ops(sdev)->write8(sdev, sdev->bar[bar] + offset, value);
  253. else
  254. writeb(value, sdev->bar[bar] + offset);
  255. }
  256. static inline void snd_sof_dsp_write(struct snd_sof_dev *sdev, u32 bar,
  257. u32 offset, u32 value)
  258. {
  259. if (sof_ops(sdev)->write)
  260. sof_ops(sdev)->write(sdev, sdev->bar[bar] + offset, value);
  261. else
  262. writel(value, sdev->bar[bar] + offset);
  263. }
  264. static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar,
  265. u32 offset, u64 value)
  266. {
  267. if (sof_ops(sdev)->write64)
  268. sof_ops(sdev)->write64(sdev, sdev->bar[bar] + offset, value);
  269. else
  270. writeq(value, sdev->bar[bar] + offset);
  271. }
  272. static inline u8 snd_sof_dsp_read8(struct snd_sof_dev *sdev, u32 bar,
  273. u32 offset)
  274. {
  275. if (sof_ops(sdev)->read8)
  276. return sof_ops(sdev)->read8(sdev, sdev->bar[bar] + offset);
  277. else
  278. return readb(sdev->bar[bar] + offset);
  279. }
  280. static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar,
  281. u32 offset)
  282. {
  283. if (sof_ops(sdev)->read)
  284. return sof_ops(sdev)->read(sdev, sdev->bar[bar] + offset);
  285. else
  286. return readl(sdev->bar[bar] + offset);
  287. }
  288. static inline u64 snd_sof_dsp_read64(struct snd_sof_dev *sdev, u32 bar,
  289. u32 offset)
  290. {
  291. if (sof_ops(sdev)->read64)
  292. return sof_ops(sdev)->read64(sdev, sdev->bar[bar] + offset);
  293. else
  294. return readq(sdev->bar[bar] + offset);
  295. }
  296. static inline void snd_sof_dsp_update8(struct snd_sof_dev *sdev, u32 bar,
  297. u32 offset, u8 mask, u8 value)
  298. {
  299. u8 reg;
  300. reg = snd_sof_dsp_read8(sdev, bar, offset);
  301. reg &= ~mask;
  302. reg |= value;
  303. snd_sof_dsp_write8(sdev, bar, offset, reg);
  304. }
  305. /* block IO */
  306. static inline int snd_sof_dsp_block_read(struct snd_sof_dev *sdev,
  307. enum snd_sof_fw_blk_type blk_type,
  308. u32 offset, void *dest, size_t bytes)
  309. {
  310. return sof_ops(sdev)->block_read(sdev, blk_type, offset, dest, bytes);
  311. }
  312. static inline int snd_sof_dsp_block_write(struct snd_sof_dev *sdev,
  313. enum snd_sof_fw_blk_type blk_type,
  314. u32 offset, void *src, size_t bytes)
  315. {
  316. return sof_ops(sdev)->block_write(sdev, blk_type, offset, src, bytes);
  317. }
  318. /* mailbox IO */
  319. static inline void snd_sof_dsp_mailbox_read(struct snd_sof_dev *sdev,
  320. u32 offset, void *dest, size_t bytes)
  321. {
  322. if (sof_ops(sdev)->mailbox_read)
  323. sof_ops(sdev)->mailbox_read(sdev, offset, dest, bytes);
  324. }
  325. static inline void snd_sof_dsp_mailbox_write(struct snd_sof_dev *sdev,
  326. u32 offset, void *src, size_t bytes)
  327. {
  328. if (sof_ops(sdev)->mailbox_write)
  329. sof_ops(sdev)->mailbox_write(sdev, offset, src, bytes);
  330. }
  331. /* ipc */
  332. static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev,
  333. struct snd_sof_ipc_msg *msg)
  334. {
  335. return sof_ops(sdev)->send_msg(sdev, msg);
  336. }
  337. /* host PCM ops */
  338. static inline int
  339. snd_sof_pcm_platform_open(struct snd_sof_dev *sdev,
  340. struct snd_pcm_substream *substream)
  341. {
  342. if (sof_ops(sdev) && sof_ops(sdev)->pcm_open)
  343. return sof_ops(sdev)->pcm_open(sdev, substream);
  344. return 0;
  345. }
  346. /* disconnect pcm substream to a host stream */
  347. static inline int
  348. snd_sof_pcm_platform_close(struct snd_sof_dev *sdev,
  349. struct snd_pcm_substream *substream)
  350. {
  351. if (sof_ops(sdev) && sof_ops(sdev)->pcm_close)
  352. return sof_ops(sdev)->pcm_close(sdev, substream);
  353. return 0;
  354. }
  355. /* host stream hw params */
  356. static inline int
  357. snd_sof_pcm_platform_hw_params(struct snd_sof_dev *sdev,
  358. struct snd_pcm_substream *substream,
  359. struct snd_pcm_hw_params *params,
  360. struct snd_sof_platform_stream_params *platform_params)
  361. {
  362. if (sof_ops(sdev) && sof_ops(sdev)->pcm_hw_params)
  363. return sof_ops(sdev)->pcm_hw_params(sdev, substream, params,
  364. platform_params);
  365. return 0;
  366. }
  367. /* host stream hw free */
  368. static inline int
  369. snd_sof_pcm_platform_hw_free(struct snd_sof_dev *sdev,
  370. struct snd_pcm_substream *substream)
  371. {
  372. if (sof_ops(sdev) && sof_ops(sdev)->pcm_hw_free)
  373. return sof_ops(sdev)->pcm_hw_free(sdev, substream);
  374. return 0;
  375. }
  376. /* host stream trigger */
  377. static inline int
  378. snd_sof_pcm_platform_trigger(struct snd_sof_dev *sdev,
  379. struct snd_pcm_substream *substream, int cmd)
  380. {
  381. if (sof_ops(sdev) && sof_ops(sdev)->pcm_trigger)
  382. return sof_ops(sdev)->pcm_trigger(sdev, substream, cmd);
  383. return 0;
  384. }
  385. /* Firmware loading */
  386. static inline int snd_sof_load_firmware(struct snd_sof_dev *sdev)
  387. {
  388. dev_dbg(sdev->dev, "loading firmware\n");
  389. return sof_ops(sdev)->load_firmware(sdev);
  390. }
  391. /* host DSP message data */
  392. static inline int snd_sof_ipc_msg_data(struct snd_sof_dev *sdev,
  393. struct snd_sof_pcm_stream *sps,
  394. void *p, size_t sz)
  395. {
  396. return sof_ops(sdev)->ipc_msg_data(sdev, sps, p, sz);
  397. }
  398. /* host side configuration of the stream's data offset in stream mailbox area */
  399. static inline int
  400. snd_sof_set_stream_data_offset(struct snd_sof_dev *sdev,
  401. struct snd_sof_pcm_stream *sps,
  402. size_t posn_offset)
  403. {
  404. if (sof_ops(sdev) && sof_ops(sdev)->set_stream_data_offset)
  405. return sof_ops(sdev)->set_stream_data_offset(sdev, sps,
  406. posn_offset);
  407. return 0;
  408. }
  409. /* host stream pointer */
  410. static inline snd_pcm_uframes_t
  411. snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev,
  412. struct snd_pcm_substream *substream)
  413. {
  414. if (sof_ops(sdev) && sof_ops(sdev)->pcm_pointer)
  415. return sof_ops(sdev)->pcm_pointer(sdev, substream);
  416. return 0;
  417. }
  418. /* pcm ack */
  419. static inline int snd_sof_pcm_platform_ack(struct snd_sof_dev *sdev,
  420. struct snd_pcm_substream *substream)
  421. {
  422. if (sof_ops(sdev) && sof_ops(sdev)->pcm_ack)
  423. return sof_ops(sdev)->pcm_ack(sdev, substream);
  424. return 0;
  425. }
  426. static inline u64
  427. snd_sof_pcm_get_dai_frame_counter(struct snd_sof_dev *sdev,
  428. struct snd_soc_component *component,
  429. struct snd_pcm_substream *substream)
  430. {
  431. if (sof_ops(sdev) && sof_ops(sdev)->get_dai_frame_counter)
  432. return sof_ops(sdev)->get_dai_frame_counter(sdev, component,
  433. substream);
  434. return 0;
  435. }
  436. static inline u64
  437. snd_sof_pcm_get_host_byte_counter(struct snd_sof_dev *sdev,
  438. struct snd_soc_component *component,
  439. struct snd_pcm_substream *substream)
  440. {
  441. if (sof_ops(sdev) && sof_ops(sdev)->get_host_byte_counter)
  442. return sof_ops(sdev)->get_host_byte_counter(sdev, component,
  443. substream);
  444. return 0;
  445. }
  446. /* machine driver */
  447. static inline int
  448. snd_sof_machine_register(struct snd_sof_dev *sdev, void *pdata)
  449. {
  450. if (sof_ops(sdev) && sof_ops(sdev)->machine_register)
  451. return sof_ops(sdev)->machine_register(sdev, pdata);
  452. return 0;
  453. }
  454. static inline void
  455. snd_sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata)
  456. {
  457. if (sof_ops(sdev) && sof_ops(sdev)->machine_unregister)
  458. sof_ops(sdev)->machine_unregister(sdev, pdata);
  459. }
  460. static inline struct snd_soc_acpi_mach *
  461. snd_sof_machine_select(struct snd_sof_dev *sdev)
  462. {
  463. if (sof_ops(sdev) && sof_ops(sdev)->machine_select)
  464. return sof_ops(sdev)->machine_select(sdev);
  465. return NULL;
  466. }
  467. static inline void
  468. snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach,
  469. struct snd_sof_dev *sdev)
  470. {
  471. if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params)
  472. sof_ops(sdev)->set_mach_params(mach, sdev);
  473. }
  474. static inline bool
  475. snd_sof_is_chain_dma_supported(struct snd_sof_dev *sdev, u32 dai_type)
  476. {
  477. if (sof_ops(sdev) && sof_ops(sdev)->is_chain_dma_supported)
  478. return sof_ops(sdev)->is_chain_dma_supported(sdev, dai_type);
  479. return false;
  480. }
  481. /**
  482. * snd_sof_dsp_register_poll_timeout - Periodically poll an address
  483. * until a condition is met or a timeout occurs
  484. * @op: accessor function (takes @addr as its only argument)
  485. * @addr: Address to poll
  486. * @val: Variable to read the value into
  487. * @cond: Break condition (usually involving @val)
  488. * @sleep_us: Maximum time to sleep between reads in us (0
  489. * tight-loops). Should be less than ~20ms since usleep_range
  490. * is used (see Documentation/timers/timers-howto.rst).
  491. * @timeout_us: Timeout in us, 0 means never timeout
  492. *
  493. * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
  494. * case, the last read value at @addr is stored in @val. Must not
  495. * be called from atomic context if sleep_us or timeout_us are used.
  496. *
  497. * This is modelled after the readx_poll_timeout macros in linux/iopoll.h.
  498. */
  499. #define snd_sof_dsp_read_poll_timeout(sdev, bar, offset, val, cond, sleep_us, timeout_us) \
  500. ({ \
  501. u64 __timeout_us = (timeout_us); \
  502. unsigned long __sleep_us = (sleep_us); \
  503. ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
  504. might_sleep_if((__sleep_us) != 0); \
  505. for (;;) { \
  506. (val) = snd_sof_dsp_read(sdev, bar, offset); \
  507. if (cond) { \
  508. dev_dbg(sdev->dev, \
  509. "FW Poll Status: reg[%#x]=%#x successful\n", \
  510. (offset), (val)); \
  511. break; \
  512. } \
  513. if (__timeout_us && \
  514. ktime_compare(ktime_get(), __timeout) > 0) { \
  515. (val) = snd_sof_dsp_read(sdev, bar, offset); \
  516. dev_dbg(sdev->dev, \
  517. "FW Poll Status: reg[%#x]=%#x timedout\n", \
  518. (offset), (val)); \
  519. break; \
  520. } \
  521. if (__sleep_us) \
  522. usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
  523. } \
  524. (cond) ? 0 : -ETIMEDOUT; \
  525. })
  526. /* This is for registers bits with attribute RWC */
  527. bool snd_sof_pci_update_bits(struct snd_sof_dev *sdev, u32 offset,
  528. u32 mask, u32 value);
  529. bool snd_sof_dsp_update_bits_unlocked(struct snd_sof_dev *sdev, u32 bar,
  530. u32 offset, u32 mask, u32 value);
  531. bool snd_sof_dsp_update_bits64_unlocked(struct snd_sof_dev *sdev, u32 bar,
  532. u32 offset, u64 mask, u64 value);
  533. bool snd_sof_dsp_update_bits(struct snd_sof_dev *sdev, u32 bar, u32 offset,
  534. u32 mask, u32 value);
  535. bool snd_sof_dsp_update_bits64(struct snd_sof_dev *sdev, u32 bar,
  536. u32 offset, u64 mask, u64 value);
  537. void snd_sof_dsp_update_bits_forced(struct snd_sof_dev *sdev, u32 bar,
  538. u32 offset, u32 mask, u32 value);
  539. int snd_sof_dsp_register_poll(struct snd_sof_dev *sdev, u32 bar, u32 offset,
  540. u32 mask, u32 target, u32 timeout_ms,
  541. u32 interval_us);
  542. void snd_sof_dsp_panic(struct snd_sof_dev *sdev, u32 offset, bool non_recoverable);
  543. #endif