uniperif.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414
  1. /*
  2. * Copyright (C) STMicroelectronics SA 2015
  3. * Authors: Arnaud Pouliquen <arnaud.pouliquen@st.com>
  4. * for STMicroelectronics.
  5. * License terms: GNU General Public License (GPL), version 2
  6. */
  7. #ifndef __SND_ST_AUD_UNIPERIF_H
  8. #define __SND_ST_AUD_UNIPERIF_H
  9. #include <linux/regmap.h>
  10. #include <sound/dmaengine_pcm.h>
  11. /*
  12. * Register access macros
  13. */
  14. #define GET_UNIPERIF_REG(ip, offset, shift, mask) \
  15. ((readl_relaxed(ip->base + offset) >> shift) & mask)
  16. #define SET_UNIPERIF_REG(ip, offset, shift, mask, value) \
  17. writel_relaxed(((readl_relaxed(ip->base + offset) & \
  18. ~(mask << shift)) | (((value) & mask) << shift)), ip->base + offset)
  19. #define SET_UNIPERIF_BIT_REG(ip, offset, shift, mask, value) \
  20. writel_relaxed((((value) & mask) << shift), ip->base + offset)
  21. /*
  22. * UNIPERIF_SOFT_RST reg
  23. */
  24. #define UNIPERIF_SOFT_RST_OFFSET(ip) 0x0000
  25. #define GET_UNIPERIF_SOFT_RST(ip) \
  26. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  27. readl_relaxed(ip->base + UNIPERIF_SOFT_RST_OFFSET(ip)) : 0)
  28. #define SET_UNIPERIF_SOFT_RST(ip, value) \
  29. writel_relaxed(value, ip->base + UNIPERIF_SOFT_RST_OFFSET(ip))
  30. /* SOFT_RST */
  31. #define UNIPERIF_SOFT_RST_SOFT_RST_SHIFT(ip) 0x0
  32. #define UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip) 0x1
  33. #define SET_UNIPERIF_SOFT_RST_SOFT_RST(ip) \
  34. SET_UNIPERIF_BIT_REG(ip, \
  35. UNIPERIF_SOFT_RST_OFFSET(ip), \
  36. UNIPERIF_SOFT_RST_SOFT_RST_SHIFT(ip), \
  37. UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip), 1)
  38. #define GET_UNIPERIF_SOFT_RST_SOFT_RST(ip) \
  39. GET_UNIPERIF_REG(ip, \
  40. UNIPERIF_SOFT_RST_OFFSET(ip), \
  41. UNIPERIF_SOFT_RST_SOFT_RST_SHIFT(ip), \
  42. UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip))
  43. /*
  44. * UNIPERIF_FIFO_DATA reg
  45. */
  46. #define UNIPERIF_FIFO_DATA_OFFSET(ip) 0x0004
  47. #define SET_UNIPERIF_DATA(ip, value) \
  48. writel_relaxed(value, ip->base + UNIPERIF_FIFO_DATA_OFFSET(ip))
  49. /*
  50. * UNIPERIF_CHANNEL_STA_REGN reg
  51. */
  52. #define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n))
  53. #define GET_UNIPERIF_CHANNEL_STA_REGN(ip) \
  54. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REGN(ip, n))
  55. #define SET_UNIPERIF_CHANNEL_STA_REGN(ip, n, value) \
  56. writel_relaxed(value, ip->base + \
  57. UNIPERIF_CHANNEL_STA_REGN(ip, n))
  58. #define UNIPERIF_CHANNEL_STA_REG0_OFFSET(ip) 0x0060
  59. #define GET_UNIPERIF_CHANNEL_STA_REG0(ip) \
  60. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG0_OFFSET(ip))
  61. #define SET_UNIPERIF_CHANNEL_STA_REG0(ip, value) \
  62. writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG0_OFFSET(ip))
  63. #define UNIPERIF_CHANNEL_STA_REG1_OFFSET(ip) 0x0064
  64. #define GET_UNIPERIF_CHANNEL_STA_REG1(ip) \
  65. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG1_OFFSET(ip))
  66. #define SET_UNIPERIF_CHANNEL_STA_REG1(ip, value) \
  67. writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG1_OFFSET(ip))
  68. #define UNIPERIF_CHANNEL_STA_REG2_OFFSET(ip) 0x0068
  69. #define GET_UNIPERIF_CHANNEL_STA_REG2(ip) \
  70. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG2_OFFSET(ip))
  71. #define SET_UNIPERIF_CHANNEL_STA_REG2(ip, value) \
  72. writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG2_OFFSET(ip))
  73. #define UNIPERIF_CHANNEL_STA_REG3_OFFSET(ip) 0x006C
  74. #define GET_UNIPERIF_CHANNEL_STA_REG3(ip) \
  75. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG3_OFFSET(ip))
  76. #define SET_UNIPERIF_CHANNEL_STA_REG3(ip, value) \
  77. writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG3_OFFSET(ip))
  78. #define UNIPERIF_CHANNEL_STA_REG4_OFFSET(ip) 0x0070
  79. #define GET_UNIPERIF_CHANNEL_STA_REG4(ip) \
  80. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG4_OFFSET(ip))
  81. #define SET_UNIPERIF_CHANNEL_STA_REG4(ip, value) \
  82. writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG4_OFFSET(ip))
  83. #define UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip) 0x0074
  84. #define GET_UNIPERIF_CHANNEL_STA_REG5(ip) \
  85. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip))
  86. #define SET_UNIPERIF_CHANNEL_STA_REG5(ip, value) \
  87. writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip))
  88. /*
  89. * UNIPERIF_ITS reg
  90. */
  91. #define UNIPERIF_ITS_OFFSET(ip) 0x000C
  92. #define GET_UNIPERIF_ITS(ip) \
  93. readl_relaxed(ip->base + UNIPERIF_ITS_OFFSET(ip))
  94. /* MEM_BLK_READ */
  95. #define UNIPERIF_ITS_MEM_BLK_READ_SHIFT(ip) 5
  96. #define UNIPERIF_ITS_MEM_BLK_READ_MASK(ip) \
  97. (BIT(UNIPERIF_ITS_MEM_BLK_READ_SHIFT(ip)))
  98. /* FIFO_ERROR */
  99. #define UNIPERIF_ITS_FIFO_ERROR_SHIFT(ip) \
  100. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
  101. #define UNIPERIF_ITS_FIFO_ERROR_MASK(ip) \
  102. (BIT(UNIPERIF_ITS_FIFO_ERROR_SHIFT(ip)))
  103. /* DMA_ERROR */
  104. #define UNIPERIF_ITS_DMA_ERROR_SHIFT(ip) 9
  105. #define UNIPERIF_ITS_DMA_ERROR_MASK(ip) \
  106. (BIT(UNIPERIF_ITS_DMA_ERROR_SHIFT(ip)))
  107. /* UNDERFLOW_REC_DONE */
  108. #define UNIPERIF_ITS_UNDERFLOW_REC_DONE_SHIFT(ip) \
  109. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 12)
  110. #define UNIPERIF_ITS_UNDERFLOW_REC_DONE_MASK(ip) \
  111. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  112. 0 : (BIT(UNIPERIF_ITS_UNDERFLOW_REC_DONE_SHIFT(ip))))
  113. /* UNDERFLOW_REC_FAILED */
  114. #define UNIPERIF_ITS_UNDERFLOW_REC_FAILED_SHIFT(ip) \
  115. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 13)
  116. #define UNIPERIF_ITS_UNDERFLOW_REC_FAILED_MASK(ip) \
  117. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  118. 0 : (BIT(UNIPERIF_ITS_UNDERFLOW_REC_FAILED_SHIFT(ip))))
  119. /*
  120. * UNIPERIF_ITS_BCLR reg
  121. */
  122. /* FIFO_ERROR */
  123. #define UNIPERIF_ITS_BCLR_FIFO_ERROR_SHIFT(ip) \
  124. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
  125. #define UNIPERIF_ITS_BCLR_FIFO_ERROR_MASK(ip) \
  126. (BIT(UNIPERIF_ITS_BCLR_FIFO_ERROR_SHIFT(ip)))
  127. #define SET_UNIPERIF_ITS_BCLR_FIFO_ERROR(ip) \
  128. SET_UNIPERIF_ITS_BCLR(ip, \
  129. UNIPERIF_ITS_BCLR_FIFO_ERROR_MASK(ip))
  130. #define UNIPERIF_ITS_BCLR_OFFSET(ip) 0x0010
  131. #define SET_UNIPERIF_ITS_BCLR(ip, value) \
  132. writel_relaxed(value, ip->base + UNIPERIF_ITS_BCLR_OFFSET(ip))
  133. /*
  134. * UNIPERIF_ITM reg
  135. */
  136. #define UNIPERIF_ITM_OFFSET(ip) 0x0018
  137. #define GET_UNIPERIF_ITM(ip) \
  138. readl_relaxed(ip->base + UNIPERIF_ITM_OFFSET(ip))
  139. /* FIFO_ERROR */
  140. #define UNIPERIF_ITM_FIFO_ERROR_SHIFT(ip) \
  141. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
  142. #define UNIPERIF_ITM_FIFO_ERROR_MASK(ip) \
  143. (BIT(UNIPERIF_ITM_FIFO_ERROR_SHIFT(ip)))
  144. /* UNDERFLOW_REC_DONE */
  145. #define UNIPERIF_ITM_UNDERFLOW_REC_DONE_SHIFT(ip) \
  146. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 12)
  147. #define UNIPERIF_ITM_UNDERFLOW_REC_DONE_MASK(ip) \
  148. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  149. 0 : (BIT(UNIPERIF_ITM_UNDERFLOW_REC_DONE_SHIFT(ip))))
  150. /* UNDERFLOW_REC_FAILED */
  151. #define UNIPERIF_ITM_UNDERFLOW_REC_FAILED_SHIFT(ip) \
  152. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 13)
  153. #define UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASK(ip) \
  154. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  155. 0 : (BIT(UNIPERIF_ITM_UNDERFLOW_REC_FAILED_SHIFT(ip))))
  156. /*
  157. * UNIPERIF_ITM_BCLR reg
  158. */
  159. #define UNIPERIF_ITM_BCLR_OFFSET(ip) 0x001c
  160. #define SET_UNIPERIF_ITM_BCLR(ip, value) \
  161. writel_relaxed(value, ip->base + UNIPERIF_ITM_BCLR_OFFSET(ip))
  162. /* FIFO_ERROR */
  163. #define UNIPERIF_ITM_BCLR_FIFO_ERROR_SHIFT(ip) \
  164. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
  165. #define UNIPERIF_ITM_BCLR_FIFO_ERROR_MASK(ip) \
  166. (BIT(UNIPERIF_ITM_BCLR_FIFO_ERROR_SHIFT(ip)))
  167. #define SET_UNIPERIF_ITM_BCLR_FIFO_ERROR(ip) \
  168. SET_UNIPERIF_ITM_BCLR(ip, \
  169. UNIPERIF_ITM_BCLR_FIFO_ERROR_MASK(ip))
  170. /* DMA_ERROR */
  171. #define UNIPERIF_ITM_BCLR_DMA_ERROR_SHIFT(ip) 9
  172. #define UNIPERIF_ITM_BCLR_DMA_ERROR_MASK(ip) \
  173. (BIT(UNIPERIF_ITM_BCLR_DMA_ERROR_SHIFT(ip)))
  174. #define SET_UNIPERIF_ITM_BCLR_DMA_ERROR(ip) \
  175. SET_UNIPERIF_ITM_BCLR(ip, \
  176. UNIPERIF_ITM_BCLR_DMA_ERROR_MASK(ip))
  177. /*
  178. * UNIPERIF_ITM_BSET reg
  179. */
  180. #define UNIPERIF_ITM_BSET_OFFSET(ip) 0x0020
  181. #define SET_UNIPERIF_ITM_BSET(ip, value) \
  182. writel_relaxed(value, ip->base + UNIPERIF_ITM_BSET_OFFSET(ip))
  183. /* FIFO_ERROR */
  184. #define UNIPERIF_ITM_BSET_FIFO_ERROR_SHIFT(ip) \
  185. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
  186. #define UNIPERIF_ITM_BSET_FIFO_ERROR_MASK(ip) \
  187. (BIT(UNIPERIF_ITM_BSET_FIFO_ERROR_SHIFT(ip)))
  188. #define SET_UNIPERIF_ITM_BSET_FIFO_ERROR(ip) \
  189. SET_UNIPERIF_ITM_BSET(ip, \
  190. UNIPERIF_ITM_BSET_FIFO_ERROR_MASK(ip))
  191. /* MEM_BLK_READ */
  192. #define UNIPERIF_ITM_BSET_MEM_BLK_READ_SHIFT(ip) 5
  193. #define UNIPERIF_ITM_BSET_MEM_BLK_READ_MASK(ip) \
  194. (BIT(UNIPERIF_ITM_BSET_MEM_BLK_READ_SHIFT(ip)))
  195. #define SET_UNIPERIF_ITM_BSET_MEM_BLK_READ(ip) \
  196. SET_UNIPERIF_ITM_BSET(ip, \
  197. UNIPERIF_ITM_BSET_MEM_BLK_READ_MASK(ip))
  198. /* DMA_ERROR */
  199. #define UNIPERIF_ITM_BSET_DMA_ERROR_SHIFT(ip) 9
  200. #define UNIPERIF_ITM_BSET_DMA_ERROR_MASK(ip) \
  201. (BIT(UNIPERIF_ITM_BSET_DMA_ERROR_SHIFT(ip)))
  202. #define SET_UNIPERIF_ITM_BSET_DMA_ERROR(ip) \
  203. SET_UNIPERIF_ITM_BSET(ip, \
  204. UNIPERIF_ITM_BSET_DMA_ERROR_MASK(ip))
  205. /* UNDERFLOW_REC_DONE */
  206. #define UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_SHIFT(ip) \
  207. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 12)
  208. #define UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_MASK(ip) \
  209. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  210. 0 : (BIT(UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_SHIFT(ip))))
  211. #define SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE(ip) \
  212. SET_UNIPERIF_ITM_BSET(ip, \
  213. UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_MASK(ip))
  214. /* UNDERFLOW_REC_FAILED */
  215. #define UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_SHIFT(ip) \
  216. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 13)
  217. #define UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_MASK(ip) \
  218. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
  219. 0 : (BIT(UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_SHIFT(ip))))
  220. #define SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(ip) \
  221. SET_UNIPERIF_ITM_BSET(ip, \
  222. UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_MASK(ip))
  223. /*
  224. * UNIPERIF_CONFIG reg
  225. */
  226. #define UNIPERIF_CONFIG_OFFSET(ip) 0x0040
  227. #define GET_UNIPERIF_CONFIG(ip) \
  228. readl_relaxed(ip->base + UNIPERIF_CONFIG_OFFSET(ip))
  229. #define SET_UNIPERIF_CONFIG(ip, value) \
  230. writel_relaxed(value, ip->base + UNIPERIF_CONFIG_OFFSET(ip))
  231. /* PARITY_CNTR */
  232. #define UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip) 0
  233. #define UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip) 0x1
  234. #define GET_UNIPERIF_CONFIG_PARITY_CNTR(ip) \
  235. GET_UNIPERIF_REG(ip, \
  236. UNIPERIF_CONFIG_OFFSET(ip), \
  237. UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip), \
  238. UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip))
  239. #define SET_UNIPERIF_CONFIG_PARITY_CNTR_BY_HW(ip) \
  240. SET_UNIPERIF_REG(ip, \
  241. UNIPERIF_CONFIG_OFFSET(ip), \
  242. UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip), \
  243. UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip), 0)
  244. #define SET_UNIPERIF_CONFIG_PARITY_CNTR_BY_SW(ip) \
  245. SET_UNIPERIF_REG(ip, \
  246. UNIPERIF_CONFIG_OFFSET(ip), \
  247. UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip), \
  248. UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip), 1)
  249. /* CHANNEL_STA_CNTR */
  250. #define UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip) 1
  251. #define UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip) 0x1
  252. #define GET_UNIPERIF_CONFIG_CHANNEL_STA_CNTR(ip) \
  253. GET_UNIPERIF_REG(ip, \
  254. UNIPERIF_CONFIG_OFFSET(ip), \
  255. UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip), \
  256. UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip))
  257. #define SET_UNIPERIF_CONFIG_CHANNEL_STA_CNTR_BY_SW(ip) \
  258. SET_UNIPERIF_REG(ip, \
  259. UNIPERIF_CONFIG_OFFSET(ip), \
  260. UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip), \
  261. UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip), 0)
  262. #define SET_UNIPERIF_CONFIG_CHANNEL_STA_CNTR_BY_HW(ip) \
  263. SET_UNIPERIF_REG(ip, \
  264. UNIPERIF_CONFIG_OFFSET(ip), \
  265. UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip), \
  266. UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip), 1)
  267. /* USER_DAT_CNTR */
  268. #define UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip) 2
  269. #define UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip) 0x1
  270. #define GET_UNIPERIF_CONFIG_USER_DAT_CNTR(ip) \
  271. GET_UNIPERIF_REG(ip, \
  272. UNIPERIF_CONFIG_OFFSET(ip), \
  273. UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip), \
  274. UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip))
  275. #define SET_UNIPERIF_CONFIG_USER_DAT_CNTR_BY_HW(ip) \
  276. SET_UNIPERIF_REG(ip, \
  277. UNIPERIF_CONFIG_OFFSET(ip), \
  278. UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip), \
  279. UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip), 1)
  280. #define SET_UNIPERIF_CONFIG_USER_DAT_CNTR_BY_SW(ip) \
  281. SET_UNIPERIF_REG(ip, \
  282. UNIPERIF_CONFIG_OFFSET(ip), \
  283. UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip), \
  284. UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip), 0)
  285. /* VALIDITY_DAT_CNTR */
  286. #define UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip) 3
  287. #define UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip) 0x1
  288. #define GET_UNIPERIF_CONFIG_VALIDITY_DAT_CNTR(ip) \
  289. GET_UNIPERIF_REG(ip, \
  290. UNIPERIF_CONFIG_OFFSET(ip), \
  291. UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip), \
  292. UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip))
  293. #define SET_UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_BY_SW(ip) \
  294. SET_UNIPERIF_REG(ip, \
  295. UNIPERIF_CONFIG_OFFSET(ip), \
  296. UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip), \
  297. UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip), 0)
  298. #define SET_UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_BY_HW(ip) \
  299. SET_UNIPERIF_REG(ip, \
  300. UNIPERIF_CONFIG_OFFSET(ip), \
  301. UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip), \
  302. UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip), 1)
  303. /* ONE_BIT_AUD_SUPPORT */
  304. #define UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip) 4
  305. #define UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip) 0x1
  306. #define GET_UNIPERIF_CONFIG_ONE_BIT_AUD(ip) \
  307. GET_UNIPERIF_REG(ip, \
  308. UNIPERIF_CONFIG_OFFSET(ip), \
  309. UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip), \
  310. UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip))
  311. #define SET_UNIPERIF_CONFIG_ONE_BIT_AUD_DISABLE(ip) \
  312. SET_UNIPERIF_REG(ip, \
  313. UNIPERIF_CONFIG_OFFSET(ip), \
  314. UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip), \
  315. UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip), 0)
  316. #define SET_UNIPERIF_CONFIG_ONE_BIT_AUD_ENABLE(ip) \
  317. SET_UNIPERIF_REG(ip, \
  318. UNIPERIF_CONFIG_OFFSET(ip), \
  319. UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip), \
  320. UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip), 1)
  321. /* MEMORY_FMT */
  322. #define UNIPERIF_CONFIG_MEM_FMT_SHIFT(ip) 5
  323. #define UNIPERIF_CONFIG_MEM_FMT_MASK(ip) 0x1
  324. #define VALUE_UNIPERIF_CONFIG_MEM_FMT_16_0(ip) 0
  325. #define VALUE_UNIPERIF_CONFIG_MEM_FMT_16_16(ip) 1
  326. #define GET_UNIPERIF_CONFIG_MEM_FMT(ip) \
  327. GET_UNIPERIF_REG(ip, \
  328. UNIPERIF_CONFIG_OFFSET(ip), \
  329. UNIPERIF_CONFIG_MEM_FMT_SHIFT(ip), \
  330. UNIPERIF_CONFIG_MEM_FMT_MASK(ip))
  331. #define SET_UNIPERIF_CONFIG_MEM_FMT(ip, value) \
  332. SET_UNIPERIF_REG(ip, \
  333. UNIPERIF_CONFIG_OFFSET(ip), \
  334. UNIPERIF_CONFIG_MEM_FMT_SHIFT(ip), \
  335. UNIPERIF_CONFIG_MEM_FMT_MASK(ip), value)
  336. #define SET_UNIPERIF_CONFIG_MEM_FMT_16_0(ip) \
  337. SET_UNIPERIF_CONFIG_MEM_FMT(ip, \
  338. VALUE_UNIPERIF_CONFIG_MEM_FMT_16_0(ip))
  339. #define SET_UNIPERIF_CONFIG_MEM_FMT_16_16(ip) \
  340. SET_UNIPERIF_CONFIG_MEM_FMT(ip, \
  341. VALUE_UNIPERIF_CONFIG_MEM_FMT_16_16(ip))
  342. /* REPEAT_CHL_STS */
  343. #define UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip) 6
  344. #define UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip) 0x1
  345. #define GET_UNIPERIF_CONFIG_REPEAT_CHL_STS(ip) \
  346. GET_UNIPERIF_REG(ip, \
  347. UNIPERIF_CONFIG_OFFSET(ip), \
  348. UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip), \
  349. UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip))
  350. #define SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_ENABLE(ip) \
  351. SET_UNIPERIF_REG(ip, \
  352. UNIPERIF_CONFIG_OFFSET(ip), \
  353. UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip), \
  354. UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip), 0)
  355. #define SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_DISABLE(ip) \
  356. SET_UNIPERIF_REG(ip, \
  357. UNIPERIF_CONFIG_OFFSET(ip), \
  358. UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip), \
  359. UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip), 1)
  360. /* BACK_STALL_REQ */
  361. #define UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip) \
  362. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 7 : -1)
  363. #define UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip) 0x1
  364. #define GET_UNIPERIF_CONFIG_BACK_STALL_REQ(ip) \
  365. GET_UNIPERIF_REG(ip, \
  366. UNIPERIF_CONFIG_OFFSET(ip), \
  367. UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip), \
  368. UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip))
  369. #define SET_UNIPERIF_CONFIG_BACK_STALL_REQ_DISABLE(ip) \
  370. SET_UNIPERIF_REG(ip, \
  371. UNIPERIF_CONFIG_OFFSET(ip), \
  372. UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip), \
  373. UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip), 0)
  374. #define SET_UNIPERIF_CONFIG_BACK_STALL_REQ_ENABLE(ip) \
  375. SET_UNIPERIF_REG(ip, \
  376. UNIPERIF_CONFIG_OFFSET(ip), \
  377. UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip), \
  378. UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip), 1)
  379. /* FDMA_TRIGGER_LIMIT */
  380. #define UNIPERIF_CONFIG_DMA_TRIG_LIMIT_SHIFT(ip) 8
  381. #define UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(ip) 0x7F
  382. #define GET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(ip) \
  383. GET_UNIPERIF_REG(ip, \
  384. UNIPERIF_CONFIG_OFFSET(ip), \
  385. UNIPERIF_CONFIG_DMA_TRIG_LIMIT_SHIFT(ip), \
  386. UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(ip))
  387. #define SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(ip, value) \
  388. SET_UNIPERIF_REG(ip, \
  389. UNIPERIF_CONFIG_OFFSET(ip), \
  390. UNIPERIF_CONFIG_DMA_TRIG_LIMIT_SHIFT(ip), \
  391. UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(ip), value)
  392. /* CHL_STS_UPDATE */
  393. #define UNIPERIF_CONFIG_CHL_STS_UPDATE_SHIFT(ip) \
  394. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 16 : -1)
  395. #define UNIPERIF_CONFIG_CHL_STS_UPDATE_MASK(ip) 0x1
  396. #define GET_UNIPERIF_CONFIG_CHL_STS_UPDATE(ip) \
  397. GET_UNIPERIF_REG(ip, \
  398. UNIPERIF_CONFIG_OFFSET(ip), \
  399. UNIPERIF_CONFIG_CHL_STS_UPDATE_SHIFT(ip), \
  400. UNIPERIF_CONFIG_CHL_STS_UPDATE_MASK(ip))
  401. #define SET_UNIPERIF_CONFIG_CHL_STS_UPDATE(ip) \
  402. SET_UNIPERIF_REG(ip, \
  403. UNIPERIF_CONFIG_OFFSET(ip), \
  404. UNIPERIF_CONFIG_CHL_STS_UPDATE_SHIFT(ip), \
  405. UNIPERIF_CONFIG_CHL_STS_UPDATE_MASK(ip), 1)
  406. /* IDLE_MOD */
  407. #define UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip) 18
  408. #define UNIPERIF_CONFIG_IDLE_MOD_MASK(ip) 0x1
  409. #define GET_UNIPERIF_CONFIG_IDLE_MOD(ip) \
  410. GET_UNIPERIF_REG(ip, \
  411. UNIPERIF_CONFIG_OFFSET(ip), \
  412. UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip), \
  413. UNIPERIF_CONFIG_IDLE_MOD_MASK(ip))
  414. #define SET_UNIPERIF_CONFIG_IDLE_MOD_DISABLE(ip) \
  415. SET_UNIPERIF_REG(ip, \
  416. UNIPERIF_CONFIG_OFFSET(ip), \
  417. UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip), \
  418. UNIPERIF_CONFIG_IDLE_MOD_MASK(ip), 0)
  419. #define SET_UNIPERIF_CONFIG_IDLE_MOD_ENABLE(ip) \
  420. SET_UNIPERIF_REG(ip, \
  421. UNIPERIF_CONFIG_OFFSET(ip), \
  422. UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip), \
  423. UNIPERIF_CONFIG_IDLE_MOD_MASK(ip), 1)
  424. /* SUBFRAME_SELECTION */
  425. #define UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip) 19
  426. #define UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip) 0x1
  427. #define GET_UNIPERIF_CONFIG_SUBFRAME_SEL(ip) \
  428. GET_UNIPERIF_REG(ip, \
  429. UNIPERIF_CONFIG_OFFSET(ip), \
  430. UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip), \
  431. UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip))
  432. #define SET_UNIPERIF_CONFIG_SUBFRAME_SEL_SUBF1_SUBF0(ip) \
  433. SET_UNIPERIF_REG(ip, \
  434. UNIPERIF_CONFIG_OFFSET(ip), \
  435. UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip), \
  436. UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip), 1)
  437. #define SET_UNIPERIF_CONFIG_SUBFRAME_SEL_SUBF0_SUBF1(ip) \
  438. SET_UNIPERIF_REG(ip, \
  439. UNIPERIF_CONFIG_OFFSET(ip), \
  440. UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip), \
  441. UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip), 0)
  442. /* FULL_SW_CONTROL */
  443. #define UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip) 20
  444. #define UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip) 0x1
  445. #define GET_UNIPERIF_CONFIG_SPDIF_SW_CTRL(ip) \
  446. GET_UNIPERIF_REG(ip, \
  447. UNIPERIF_CONFIG_OFFSET(ip), \
  448. UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip), \
  449. UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip))
  450. #define SET_UNIPERIF_CONFIG_SPDIF_SW_CTRL_ENABLE(ip) \
  451. SET_UNIPERIF_REG(ip, \
  452. UNIPERIF_CONFIG_OFFSET(ip), \
  453. UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip), \
  454. UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip), 1)
  455. #define SET_UNIPERIF_CONFIG_SPDIF_SW_CTRL_DISABLE(ip) \
  456. SET_UNIPERIF_REG(ip, \
  457. UNIPERIF_CONFIG_OFFSET(ip), \
  458. UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip), \
  459. UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip), 0)
  460. /* MASTER_CLKEDGE */
  461. #define UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip) \
  462. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 24 : -1)
  463. #define UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip) 0x1
  464. #define GET_UNIPERIF_CONFIG_MSTR_CLKEDGE(ip) \
  465. GET_UNIPERIF_REG(ip, \
  466. UNIPERIF_CONFIG_OFFSET(ip), \
  467. UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip), \
  468. UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip))
  469. #define SET_UNIPERIF_CONFIG_MSTR_CLKEDGE_FALLING(ip) \
  470. SET_UNIPERIF_REG(ip, \
  471. UNIPERIF_CONFIG_OFFSET(ip), \
  472. UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip), \
  473. UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip), 1)
  474. #define SET_UNIPERIF_CONFIG_MSTR_CLKEDGE_RISING(ip) \
  475. SET_UNIPERIF_REG(ip, \
  476. UNIPERIF_CONFIG_OFFSET(ip), \
  477. UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip), \
  478. UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip), 0)
  479. /*
  480. * UNIPERIF_CTRL reg
  481. */
  482. #define UNIPERIF_CTRL_OFFSET(ip) 0x0044
  483. #define GET_UNIPERIF_CTRL(ip) \
  484. readl_relaxed(ip->base + UNIPERIF_CTRL_OFFSET(ip))
  485. #define SET_UNIPERIF_CTRL(ip, value) \
  486. writel_relaxed(value, ip->base + UNIPERIF_CTRL_OFFSET(ip))
  487. /* OPERATION */
  488. #define UNIPERIF_CTRL_OPERATION_SHIFT(ip) 0
  489. #define UNIPERIF_CTRL_OPERATION_MASK(ip) 0x7
  490. #define GET_UNIPERIF_CTRL_OPERATION(ip) \
  491. GET_UNIPERIF_REG(ip, \
  492. UNIPERIF_CTRL_OFFSET(ip), \
  493. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  494. UNIPERIF_CTRL_OPERATION_MASK(ip))
  495. #define VALUE_UNIPERIF_CTRL_OPERATION_OFF(ip) 0
  496. #define SET_UNIPERIF_CTRL_OPERATION_OFF(ip) \
  497. SET_UNIPERIF_REG(ip, \
  498. UNIPERIF_CTRL_OFFSET(ip), \
  499. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  500. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  501. VALUE_UNIPERIF_CTRL_OPERATION_OFF(ip))
  502. #define VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PCM_NULL(ip) \
  503. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 1 : -1)
  504. #define SET_UNIPERIF_CTRL_OPERATION_MUTE_PCM_NULL(ip) \
  505. SET_UNIPERIF_REG(ip, \
  506. UNIPERIF_CTRL_OFFSET(ip), \
  507. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  508. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  509. VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PCM_NULL(ip))
  510. #define VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PAUSE_BURST(ip) \
  511. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 2 : -1)
  512. #define SET_UNIPERIF_CTRL_OPERATION_MUTE_PAUSE_BURST(ip) \
  513. SET_UNIPERIF_REG(ip, \
  514. UNIPERIF_CTRL_OFFSET(ip), \
  515. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  516. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  517. VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PAUSE_BURST(ip))
  518. #define VALUE_UNIPERIF_CTRL_OPERATION_PCM_DATA(ip) 3
  519. #define SET_UNIPERIF_CTRL_OPERATION_PCM_DATA(ip) \
  520. SET_UNIPERIF_REG(ip, \
  521. UNIPERIF_CTRL_OFFSET(ip), \
  522. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  523. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  524. VALUE_UNIPERIF_CTRL_OPERATION_PCM_DATA(ip))
  525. /* This is the same as above! */
  526. #define VALUE_UNIPERIF_CTRL_OPERATION_AUDIO_DATA(ip) 3
  527. #define SET_UNIPERIF_CTRL_OPERATION_AUDIO_DATA(ip) \
  528. SET_UNIPERIF_REG(ip, \
  529. UNIPERIF_CTRL_OFFSET(ip), \
  530. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  531. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  532. VALUE_UNIPERIF_CTRL_OPERATION_AUDIO_DATA(ip))
  533. #define VALUE_UNIPERIF_CTRL_OPERATION_ENC_DATA(ip) 4
  534. #define SET_UNIPERIF_CTRL_OPERATION_ENC_DATA(ip) \
  535. SET_UNIPERIF_REG(ip, \
  536. UNIPERIF_CTRL_OFFSET(ip), \
  537. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  538. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  539. VALUE_UNIPERIF_CTRL_OPERATION_ENC_DATA(ip))
  540. #define VALUE_UNIPERIF_CTRL_OPERATION_CD_DATA(ip) \
  541. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 5 : -1)
  542. #define SET_UNIPERIF_CTRL_OPERATION_CD_DATA(ip) \
  543. SET_UNIPERIF_REG(ip, \
  544. UNIPERIF_CTRL_OFFSET(ip), \
  545. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  546. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  547. VALUE_UNIPERIF_CTRL_OPERATION_CD_DATA(ip))
  548. #define VALUE_UNIPERIF_CTRL_OPERATION_STANDBY(ip) \
  549. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 7)
  550. #define SET_UNIPERIF_CTRL_OPERATION_STANDBY(ip) \
  551. SET_UNIPERIF_REG(ip, \
  552. UNIPERIF_CTRL_OFFSET(ip), \
  553. UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
  554. UNIPERIF_CTRL_OPERATION_MASK(ip), \
  555. VALUE_UNIPERIF_CTRL_OPERATION_STANDBY(ip))
  556. /* EXIT_STBY_ON_EOBLOCK */
  557. #define UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip) \
  558. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 3)
  559. #define UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip) 0x1
  560. #define GET_UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK(ip) \
  561. GET_UNIPERIF_REG(ip, \
  562. UNIPERIF_CTRL_OFFSET(ip), \
  563. UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip), \
  564. UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip))
  565. #define SET_UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_OFF(ip) \
  566. SET_UNIPERIF_REG(ip, \
  567. UNIPERIF_CTRL_OFFSET(ip), \
  568. UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip), \
  569. UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip), 0)
  570. #define SET_UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_ON(ip) \
  571. SET_UNIPERIF_REG(ip, \
  572. UNIPERIF_CTRL_OFFSET(ip), \
  573. UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip), \
  574. UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip), 1)
  575. /* ROUNDING */
  576. #define UNIPERIF_CTRL_ROUNDING_SHIFT(ip) 4
  577. #define UNIPERIF_CTRL_ROUNDING_MASK(ip) 0x1
  578. #define GET_UNIPERIF_CTRL_ROUNDING(ip) \
  579. GET_UNIPERIF_REG(ip, \
  580. UNIPERIF_CTRL_OFFSET(ip), \
  581. UNIPERIF_CTRL_ROUNDING_SHIFT(ip), \
  582. UNIPERIF_CTRL_ROUNDING_MASK(ip))
  583. #define SET_UNIPERIF_CTRL_ROUNDING_OFF(ip) \
  584. SET_UNIPERIF_REG(ip, \
  585. UNIPERIF_CTRL_OFFSET(ip), \
  586. UNIPERIF_CTRL_ROUNDING_SHIFT(ip), \
  587. UNIPERIF_CTRL_ROUNDING_MASK(ip), 0)
  588. #define SET_UNIPERIF_CTRL_ROUNDING_ON(ip) \
  589. SET_UNIPERIF_REG(ip, \
  590. UNIPERIF_CTRL_OFFSET(ip), \
  591. UNIPERIF_CTRL_ROUNDING_SHIFT(ip), \
  592. UNIPERIF_CTRL_ROUNDING_MASK(ip), 1)
  593. /* DIVIDER */
  594. #define UNIPERIF_CTRL_DIVIDER_SHIFT(ip) 5
  595. #define UNIPERIF_CTRL_DIVIDER_MASK(ip) 0xff
  596. #define GET_UNIPERIF_CTRL_DIVIDER(ip) \
  597. GET_UNIPERIF_REG(ip, \
  598. UNIPERIF_CTRL_OFFSET(ip), \
  599. UNIPERIF_CTRL_DIVIDER_SHIFT(ip), \
  600. UNIPERIF_CTRL_DIVIDER_MASK(ip))
  601. #define SET_UNIPERIF_CTRL_DIVIDER(ip, value) \
  602. SET_UNIPERIF_REG(ip, \
  603. UNIPERIF_CTRL_OFFSET(ip), \
  604. UNIPERIF_CTRL_DIVIDER_SHIFT(ip), \
  605. UNIPERIF_CTRL_DIVIDER_MASK(ip), value)
  606. /* BYTE_SWAP */
  607. #define UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip) \
  608. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 13 : -1)
  609. #define UNIPERIF_CTRL_BYTE_SWP_MASK(ip) 0x1
  610. #define GET_UNIPERIF_CTRL_BYTE_SWP(ip) \
  611. GET_UNIPERIF_REG(ip, \
  612. UNIPERIF_CTRL_OFFSET(ip), \
  613. UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip), \
  614. UNIPERIF_CTRL_BYTE_SWP_MASK(ip))
  615. #define SET_UNIPERIF_CTRL_BYTE_SWP_OFF(ip) \
  616. SET_UNIPERIF_REG(ip, \
  617. UNIPERIF_CTRL_OFFSET(ip), \
  618. UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip), \
  619. UNIPERIF_CTRL_BYTE_SWP_MASK(ip), 0)
  620. #define SET_UNIPERIF_CTRL_BYTE_SWP_ON(ip) \
  621. SET_UNIPERIF_REG(ip, \
  622. UNIPERIF_CTRL_OFFSET(ip), \
  623. UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip), \
  624. UNIPERIF_CTRL_BYTE_SWP_MASK(ip), 1)
  625. /* ZERO_STUFFING_HW_SW */
  626. #define UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip) \
  627. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 14 : -1)
  628. #define UNIPERIF_CTRL_ZERO_STUFF_MASK(ip) 0x1
  629. #define GET_UNIPERIF_CTRL_ZERO_STUFF(ip) \
  630. GET_UNIPERIF_REG(ip, \
  631. UNIPERIF_CTRL_OFFSET(ip), \
  632. UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip), \
  633. UNIPERIF_CTRL_ZERO_STUFF_MASK(ip))
  634. #define SET_UNIPERIF_CTRL_ZERO_STUFF_HW(ip) \
  635. SET_UNIPERIF_REG(ip, \
  636. UNIPERIF_CTRL_OFFSET(ip), \
  637. UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip), \
  638. UNIPERIF_CTRL_ZERO_STUFF_MASK(ip), 1)
  639. #define SET_UNIPERIF_CTRL_ZERO_STUFF_SW(ip) \
  640. SET_UNIPERIF_REG(ip, \
  641. UNIPERIF_CTRL_OFFSET(ip), \
  642. UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip), \
  643. UNIPERIF_CTRL_ZERO_STUFF_MASK(ip), 0)
  644. /* SPDIF_LAT */
  645. #define UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip) \
  646. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 16 : -1)
  647. #define UNIPERIF_CTRL_SPDIF_LAT_MASK(ip) 0x1
  648. #define GET_UNIPERIF_CTRL_SPDIF_LAT(ip) \
  649. GET_UNIPERIF_REG(ip, \
  650. UNIPERIF_CTRL_OFFSET(ip), \
  651. UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip), \
  652. UNIPERIF_CTRL_SPDIF_LAT_MASK(ip))
  653. #define SET_UNIPERIF_CTRL_SPDIF_LAT_ON(ip) \
  654. SET_UNIPERIF_REG(ip, \
  655. UNIPERIF_CTRL_OFFSET(ip), \
  656. UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip), \
  657. UNIPERIF_CTRL_SPDIF_LAT_MASK(ip), 1)
  658. #define SET_UNIPERIF_CTRL_SPDIF_LAT_OFF(ip) \
  659. SET_UNIPERIF_REG(ip, \
  660. UNIPERIF_CTRL_OFFSET(ip), \
  661. UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip), \
  662. UNIPERIF_CTRL_SPDIF_LAT_MASK(ip), 0)
  663. /* EN_SPDIF_FORMATTING */
  664. #define UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip) 17
  665. #define UNIPERIF_CTRL_SPDIF_FMT_MASK(ip) 0x1
  666. #define GET_UNIPERIF_CTRL_SPDIF_FMT(ip) \
  667. GET_UNIPERIF_REG(ip, \
  668. UNIPERIF_CTRL_OFFSET(ip), \
  669. UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip), \
  670. UNIPERIF_CTRL_SPDIF_FMT_MASK(ip))
  671. #define SET_UNIPERIF_CTRL_SPDIF_FMT_ON(ip) \
  672. SET_UNIPERIF_REG(ip, \
  673. UNIPERIF_CTRL_OFFSET(ip), \
  674. UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip), \
  675. UNIPERIF_CTRL_SPDIF_FMT_MASK(ip), 1)
  676. #define SET_UNIPERIF_CTRL_SPDIF_FMT_OFF(ip) \
  677. SET_UNIPERIF_REG(ip, \
  678. UNIPERIF_CTRL_OFFSET(ip), \
  679. UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip), \
  680. UNIPERIF_CTRL_SPDIF_FMT_MASK(ip), 0)
  681. /* READER_OUT_SELECT */
  682. #define UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip) \
  683. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 18 : -1)
  684. #define UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip) 0x1
  685. #define GET_UNIPERIF_CTRL_READER_OUT_SEL(ip) \
  686. GET_UNIPERIF_REG(ip, \
  687. UNIPERIF_CTRL_OFFSET(ip), \
  688. UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
  689. UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip))
  690. #define SET_UNIPERIF_CTRL_READER_OUT_SEL_IN_MEM(ip) \
  691. SET_UNIPERIF_REG(ip, \
  692. UNIPERIF_CTRL_OFFSET(ip), \
  693. UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
  694. UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip), 0)
  695. #define SET_UNIPERIF_CTRL_READER_OUT_SEL_ON_I2S_LINE(ip) \
  696. SET_UNIPERIF_REG(ip, \
  697. UNIPERIF_CTRL_OFFSET(ip), \
  698. UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
  699. UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip), 1)
  700. /* UNDERFLOW_REC_WINDOW */
  701. #define UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip) 20
  702. #define UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_MASK(ip) 0xff
  703. #define GET_UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW(ip) \
  704. GET_UNIPERIF_REG(ip, \
  705. UNIPERIF_CTRL_OFFSET(ip), \
  706. UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip), \
  707. UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_MASK(ip))
  708. #define SET_UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW(ip, value) \
  709. SET_UNIPERIF_REG(ip, \
  710. UNIPERIF_CTRL_OFFSET(ip), \
  711. UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip), \
  712. UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_MASK(ip), value)
  713. /*
  714. * UNIPERIF_I2S_FMT a.k.a UNIPERIF_FORMAT reg
  715. */
  716. #define UNIPERIF_I2S_FMT_OFFSET(ip) 0x0048
  717. #define GET_UNIPERIF_I2S_FMT(ip) \
  718. readl_relaxed(ip->base + UNIPERIF_I2S_FMT_OFFSET(ip))
  719. #define SET_UNIPERIF_I2S_FMT(ip, value) \
  720. writel_relaxed(value, ip->base + UNIPERIF_I2S_FMT_OFFSET(ip))
  721. /* NBIT */
  722. #define UNIPERIF_I2S_FMT_NBIT_SHIFT(ip) 0
  723. #define UNIPERIF_I2S_FMT_NBIT_MASK(ip) 0x1
  724. #define GET_UNIPERIF_I2S_FMT_NBIT(ip) \
  725. GET_UNIPERIF_REG(ip, \
  726. UNIPERIF_I2S_FMT_OFFSET(ip), \
  727. UNIPERIF_I2S_FMT_NBIT_SHIFT(ip), \
  728. UNIPERIF_I2S_FMT_NBIT_MASK(ip))
  729. #define SET_UNIPERIF_I2S_FMT_NBIT_32(ip) \
  730. SET_UNIPERIF_REG(ip, \
  731. UNIPERIF_I2S_FMT_OFFSET(ip), \
  732. UNIPERIF_I2S_FMT_NBIT_SHIFT(ip), \
  733. UNIPERIF_I2S_FMT_NBIT_MASK(ip), 0)
  734. #define SET_UNIPERIF_I2S_FMT_NBIT_16(ip) \
  735. SET_UNIPERIF_REG(ip, \
  736. UNIPERIF_I2S_FMT_OFFSET(ip), \
  737. UNIPERIF_I2S_FMT_NBIT_SHIFT(ip), \
  738. UNIPERIF_I2S_FMT_NBIT_MASK(ip), 1)
  739. /* DATA_SIZE */
  740. #define UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip) 1
  741. #define UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip) 0x7
  742. #define GET_UNIPERIF_I2S_FMT_DATA_SIZE(ip) \
  743. GET_UNIPERIF_REG(ip, \
  744. UNIPERIF_I2S_FMT_OFFSET(ip), \
  745. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  746. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip))
  747. #define SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(ip) \
  748. SET_UNIPERIF_REG(ip, \
  749. UNIPERIF_I2S_FMT_OFFSET(ip), \
  750. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  751. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 0)
  752. #define SET_UNIPERIF_I2S_FMT_DATA_SIZE_18(ip) \
  753. SET_UNIPERIF_REG(ip, \
  754. UNIPERIF_I2S_FMT_OFFSET(ip), \
  755. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  756. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 1)
  757. #define SET_UNIPERIF_I2S_FMT_DATA_SIZE_20(ip) \
  758. SET_UNIPERIF_REG(ip, \
  759. UNIPERIF_I2S_FMT_OFFSET(ip), \
  760. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  761. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 2)
  762. #define SET_UNIPERIF_I2S_FMT_DATA_SIZE_24(ip) \
  763. SET_UNIPERIF_REG(ip, \
  764. UNIPERIF_I2S_FMT_OFFSET(ip), \
  765. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  766. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 3)
  767. #define SET_UNIPERIF_I2S_FMTL_DATA_SIZE_28(ip) \
  768. SET_UNIPERIF_REG(ip, \
  769. UNIPERIF_I2S_FMT_OFFSET(ip), \
  770. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  771. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 4)
  772. #define SET_UNIPERIF_I2S_FMT_DATA_SIZE_32(ip) \
  773. SET_UNIPERIF_REG(ip, \
  774. UNIPERIF_I2S_FMT_OFFSET(ip), \
  775. UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
  776. UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 5)
  777. /* LR_POL */
  778. #define UNIPERIF_I2S_FMT_LR_POL_SHIFT(ip) 4
  779. #define UNIPERIF_I2S_FMT_LR_POL_MASK(ip) 0x1
  780. #define VALUE_UNIPERIF_I2S_FMT_LR_POL_LOW(ip) 0x0
  781. #define VALUE_UNIPERIF_I2S_FMT_LR_POL_HIG(ip) 0x1
  782. #define GET_UNIPERIF_I2S_FMT_LR_POL(ip) \
  783. GET_UNIPERIF_REG(ip, \
  784. UNIPERIF_I2S_FMT_OFFSET(ip), \
  785. UNIPERIF_I2S_FMT_LR_POL_SHIFT(ip), \
  786. UNIPERIF_I2S_FMT_LR_POL_MASK(ip))
  787. #define SET_UNIPERIF_I2S_FMT_LR_POL(ip, value) \
  788. SET_UNIPERIF_REG(ip, \
  789. UNIPERIF_I2S_FMT_OFFSET(ip), \
  790. UNIPERIF_I2S_FMT_LR_POL_SHIFT(ip), \
  791. UNIPERIF_I2S_FMT_LR_POL_MASK(ip), value)
  792. #define SET_UNIPERIF_I2S_FMT_LR_POL_LOW(ip) \
  793. SET_UNIPERIF_I2S_FMT_LR_POL(ip, \
  794. VALUE_UNIPERIF_I2S_FMT_LR_POL_LOW(ip))
  795. #define SET_UNIPERIF_I2S_FMT_LR_POL_HIG(ip) \
  796. SET_UNIPERIF_I2S_FMT_LR_POL(ip, \
  797. VALUE_UNIPERIF_I2S_FMT_LR_POL_HIG(ip))
  798. /* SCLK_EDGE */
  799. #define UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip) 5
  800. #define UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip) 0x1
  801. #define GET_UNIPERIF_I2S_FMT_SCLK_EDGE(ip) \
  802. GET_UNIPERIF_REG(ip, \
  803. UNIPERIF_I2S_FMT_OFFSET(ip), \
  804. UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip), \
  805. UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip))
  806. #define SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(ip) \
  807. SET_UNIPERIF_REG(ip, \
  808. UNIPERIF_I2S_FMT_OFFSET(ip), \
  809. UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip), \
  810. UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip), 0)
  811. #define SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(ip) \
  812. SET_UNIPERIF_REG(ip, \
  813. UNIPERIF_I2S_FMT_OFFSET(ip), \
  814. UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip), \
  815. UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip), 1)
  816. /* PADDING */
  817. #define UNIPERIF_I2S_FMT_PADDING_SHIFT(ip) 6
  818. #define UNIPERIF_I2S_FMT_PADDING_MASK(ip) 0x1
  819. #define UNIPERIF_I2S_FMT_PADDING_MASK(ip) 0x1
  820. #define VALUE_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(ip) 0x0
  821. #define VALUE_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(ip) 0x1
  822. #define GET_UNIPERIF_I2S_FMT_PADDING(ip) \
  823. GET_UNIPERIF_REG(ip, \
  824. UNIPERIF_I2S_FMT_OFFSET(ip), \
  825. UNIPERIF_I2S_FMT_PADDING_SHIFT(ip), \
  826. UNIPERIF_I2S_FMT_PADDING_MASK(ip))
  827. #define SET_UNIPERIF_I2S_FMT_PADDING(ip, value) \
  828. SET_UNIPERIF_REG(ip, \
  829. UNIPERIF_I2S_FMT_OFFSET(ip), \
  830. UNIPERIF_I2S_FMT_PADDING_SHIFT(ip), \
  831. UNIPERIF_I2S_FMT_PADDING_MASK(ip), value)
  832. #define SET_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(ip) \
  833. SET_UNIPERIF_I2S_FMT_PADDING(ip, \
  834. VALUE_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(ip))
  835. #define SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(ip) \
  836. SET_UNIPERIF_I2S_FMT_PADDING(ip, \
  837. VALUE_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(ip))
  838. /* ALIGN */
  839. #define UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip) 7
  840. #define UNIPERIF_I2S_FMT_ALIGN_MASK(ip) 0x1
  841. #define GET_UNIPERIF_I2S_FMT_ALIGN(ip) \
  842. GET_UNIPERIF_REG(ip, \
  843. UNIPERIF_I2S_FMT_OFFSET(ip), \
  844. UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip), \
  845. UNIPERIF_I2S_FMT_ALIGN_MASK(ip))
  846. #define SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(ip) \
  847. SET_UNIPERIF_REG(ip, \
  848. UNIPERIF_I2S_FMT_OFFSET(ip), \
  849. UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip), \
  850. UNIPERIF_I2S_FMT_ALIGN_MASK(ip), 0)
  851. #define SET_UNIPERIF_I2S_FMT_ALIGN_RIGHT(ip) \
  852. SET_UNIPERIF_REG(ip, \
  853. UNIPERIF_I2S_FMT_OFFSET(ip), \
  854. UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip), \
  855. UNIPERIF_I2S_FMT_ALIGN_MASK(ip), 1)
  856. /* ORDER */
  857. #define UNIPERIF_I2S_FMT_ORDER_SHIFT(ip) 8
  858. #define UNIPERIF_I2S_FMT_ORDER_MASK(ip) 0x1
  859. #define GET_UNIPERIF_I2S_FMT_ORDER(ip) \
  860. GET_UNIPERIF_REG(ip, \
  861. UNIPERIF_I2S_FMT_OFFSET(ip), \
  862. UNIPERIF_I2S_FMT_ORDER_SHIFT(ip), \
  863. UNIPERIF_I2S_FMT_ORDER_MASK(ip))
  864. #define SET_UNIPERIF_I2S_FMT_ORDER_LSB(ip) \
  865. SET_UNIPERIF_REG(ip, \
  866. UNIPERIF_I2S_FMT_OFFSET(ip), \
  867. UNIPERIF_I2S_FMT_ORDER_SHIFT(ip), \
  868. UNIPERIF_I2S_FMT_ORDER_MASK(ip), 0)
  869. #define SET_UNIPERIF_I2S_FMT_ORDER_MSB(ip) \
  870. SET_UNIPERIF_REG(ip, \
  871. UNIPERIF_I2S_FMT_OFFSET(ip), \
  872. UNIPERIF_I2S_FMT_ORDER_SHIFT(ip), \
  873. UNIPERIF_I2S_FMT_ORDER_MASK(ip), 1)
  874. /* NUM_CH */
  875. #define UNIPERIF_I2S_FMT_NUM_CH_SHIFT(ip) 9
  876. #define UNIPERIF_I2S_FMT_NUM_CH_MASK(ip) 0x7
  877. #define GET_UNIPERIF_I2S_FMT_NUM_CH(ip) \
  878. GET_UNIPERIF_REG(ip, \
  879. UNIPERIF_I2S_FMT_OFFSET(ip), \
  880. UNIPERIF_I2S_FMT_NUM_CH_SHIFT(ip), \
  881. UNIPERIF_I2S_FMT_NUM_CH_MASK(ip))
  882. #define SET_UNIPERIF_I2S_FMT_NUM_CH(ip, value) \
  883. SET_UNIPERIF_REG(ip, \
  884. UNIPERIF_I2S_FMT_OFFSET(ip), \
  885. UNIPERIF_I2S_FMT_NUM_CH_SHIFT(ip), \
  886. UNIPERIF_I2S_FMT_NUM_CH_MASK(ip), value)
  887. /* NO_OF_SAMPLES_TO_READ */
  888. #define UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_SHIFT(ip) 12
  889. #define UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_MASK(ip) 0xfffff
  890. #define GET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(ip) \
  891. GET_UNIPERIF_REG(ip, \
  892. UNIPERIF_I2S_FMT_OFFSET(ip), \
  893. UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_SHIFT(ip), \
  894. UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_MASK(ip))
  895. #define SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(ip, value) \
  896. SET_UNIPERIF_REG(ip, \
  897. UNIPERIF_I2S_FMT_OFFSET(ip), \
  898. UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_SHIFT(ip), \
  899. UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_MASK(ip), value)
  900. /*
  901. * UNIPERIF_BIT_CONTROL reg
  902. */
  903. #define UNIPERIF_BIT_CONTROL_OFFSET(ip) \
  904. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 0x004c)
  905. #define GET_UNIPERIF_BIT_CONTROL(ip) \
  906. readl_relaxed(ip->base + UNIPERIF_BIT_CONTROL_OFFSET(ip))
  907. #define SET_UNIPERIF_BIT_CONTROL(ip, value) \
  908. writel_relaxed(value, ip->base + UNIPERIF_BIT_CONTROL_OFFSET(ip))
  909. /* CLR_UNDERFLOW_DURATION */
  910. #define UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_SHIFT(ip) 0
  911. #define UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_MASK(ip) 0x1
  912. #define GET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(ip) \
  913. GET_UNIPERIF_REG(ip, \
  914. UNIPERIF_BIT_CONTROL_OFFSET(ip), \
  915. UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_SHIFT(ip), \
  916. UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_MASK(ip))
  917. #define SET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(ip) \
  918. SET_UNIPERIF_REG(ip, \
  919. UNIPERIF_BIT_CONTROL_OFFSET(ip), \
  920. UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_SHIFT(ip), \
  921. UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_MASK(ip), 1)
  922. /* CHL_STS_UPDATE */
  923. #define UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_SHIFT(ip) 1
  924. #define UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_MASK(ip) 0x1
  925. #define GET_UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE(ip) \
  926. GET_UNIPERIF_REG(ip, \
  927. UNIPERIF_BIT_CONTROL_OFFSET(ip), \
  928. UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_SHIFT(ip), \
  929. UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_MASK(ip))
  930. #define SET_UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE(ip) \
  931. SET_UNIPERIF_BIT_REG(ip, \
  932. UNIPERIF_BIT_CONTROL_OFFSET(ip), \
  933. UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_SHIFT(ip), \
  934. UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_MASK(ip), 1)
  935. /*
  936. * UNIPERIF_STATUS_1 reg
  937. */
  938. #define UNIPERIF_STATUS_1_OFFSET(ip) 0x0050
  939. #define GET_UNIPERIF_STATUS_1(ip) \
  940. readl_relaxed(ip->base + UNIPERIF_STATUS_1_OFFSET(ip))
  941. #define SET_UNIPERIF_STATUS_1(ip, value) \
  942. writel_relaxed(value, ip->base + UNIPERIF_STATUS_1_OFFSET(ip))
  943. /* UNDERFLOW_DURATION */
  944. #define UNIPERIF_STATUS_1_UNDERFLOW_DURATION_SHIFT(ip) \
  945. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 0)
  946. #define UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip) 0xff
  947. #define GET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(ip) \
  948. GET_UNIPERIF_REG(ip, \
  949. UNIPERIF_STATUS_1_OFFSET(ip), \
  950. UNIPERIF_STATUS_1_UNDERFLOW_DURATION_SHIFT(ip), \
  951. UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip))
  952. #define SET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(ip, value) \
  953. SET_UNIPERIF_REG(ip, \
  954. UNIPERIF_STATUS_1_OFFSET(ip), \
  955. UNIPERIF_STATUS_1_UNDERFLOW_DURATION_SHIFT(ip), \
  956. UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip), value)
  957. /*
  958. * UNIPERIF_CHANNEL_STA_REGN reg
  959. */
  960. #define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n))
  961. #define GET_UNIPERIF_CHANNEL_STA_REGN(ip) \
  962. readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REGN(ip, n))
  963. #define SET_UNIPERIF_CHANNEL_STA_REGN(ip, n, value) \
  964. writel_relaxed(value, ip->base + \
  965. UNIPERIF_CHANNEL_STA_REGN(ip, n))
  966. /*
  967. * UNIPERIF_USER_VALIDITY reg
  968. */
  969. #define UNIPERIF_USER_VALIDITY_OFFSET(ip) 0x0090
  970. #define GET_UNIPERIF_USER_VALIDITY(ip) \
  971. readl_relaxed(ip->base + UNIPERIF_USER_VALIDITY_OFFSET(ip))
  972. #define SET_UNIPERIF_USER_VALIDITY(ip, value) \
  973. writel_relaxed(value, ip->base + UNIPERIF_USER_VALIDITY_OFFSET(ip))
  974. /* VALIDITY_LEFT_AND_RIGHT */
  975. #define UNIPERIF_USER_VALIDITY_VALIDITY_LR_SHIFT(ip) 0
  976. #define UNIPERIF_USER_VALIDITY_VALIDITY_LR_MASK(ip) 0x3
  977. #define GET_UNIPERIF_USER_VALIDITY_VALIDITY_LR(ip) \
  978. GET_UNIPERIF_REG(ip, \
  979. UNIPERIF_USER_VALIDITY_OFFSET(ip), \
  980. UNIPERIF_USER_VALIDITY_VALIDITY_LR_SHIFT(ip), \
  981. UNIPERIF_USER_VALIDITY_VALIDITY_LR_MASK(ip))
  982. #define SET_UNIPERIF_USER_VALIDITY_VALIDITY_LR(ip, value) \
  983. SET_UNIPERIF_REG(ip, \
  984. UNIPERIF_USER_VALIDITY_OFFSET(ip), \
  985. UNIPERIF_USER_VALIDITY_VALIDITY_LR_SHIFT(ip), \
  986. UNIPERIF_USER_VALIDITY_VALIDITY_LR_MASK(ip), \
  987. value ? 0x3 : 0)
  988. /*
  989. * UNIPERIF_DBG_STANDBY_LEFT_SP reg
  990. */
  991. #define UNIPERIF_DBG_STANDBY_LEFT_SP_OFFSET(ip) 0x0150
  992. #define UNIPERIF_DBG_STANDBY_LEFT_SP_SHIFT(ip) \
  993. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 0)
  994. #define UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip) \
  995. ((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 0xFFFFFF)
  996. #define GET_UNIPERIF_DBG_STANDBY_LEFT_SP(ip) \
  997. GET_UNIPERIF_REG(ip, \
  998. UNIPERIF_DBG_STANDBY_LEFT_SP_OFFSET(ip), \
  999. UNIPERIF_DBG_STANDBY_LEFT_SP_SHIFT(ip), \
  1000. UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip))
  1001. #define SET_UNIPERIF_DBG_STANDBY_LEFT_SP(ip, value) \
  1002. SET_UNIPERIF_REG(ip, \
  1003. UNIPERIF_DBG_STANDBY_LEFT_SP_OFFSET(ip), \
  1004. UNIPERIF_DBG_STANDBY_LEFT_SP_SHIFT(ip), \
  1005. UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip), value)
  1006. /*
  1007. * UNIPERIF_TDM_ENABLE
  1008. */
  1009. #define UNIPERIF_TDM_ENABLE_OFFSET(ip) 0x0118
  1010. #define GET_UNIPERIF_TDM_ENABLE(ip) \
  1011. readl_relaxed(ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip))
  1012. #define SET_UNIPERIF_TDM_ENABLE(ip, value) \
  1013. writel_relaxed(value, ip->base + UNIPERIF_TDM_ENABLE_OFFSET(ip))
  1014. /* TDM_ENABLE */
  1015. #define UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip) 0x0
  1016. #define UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip) 0x1
  1017. #define GET_UNIPERIF_TDM_ENABLE_EN_TDM(ip) \
  1018. GET_UNIPERIF_REG(ip, \
  1019. UNIPERIF_TDM_ENABLE_OFFSET(ip), \
  1020. UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \
  1021. UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip))
  1022. #define SET_UNIPERIF_TDM_ENABLE_TDM_ENABLE(ip) \
  1023. SET_UNIPERIF_REG(ip, \
  1024. UNIPERIF_TDM_ENABLE_OFFSET(ip), \
  1025. UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \
  1026. UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 1)
  1027. #define SET_UNIPERIF_TDM_ENABLE_TDM_DISABLE(ip) \
  1028. SET_UNIPERIF_REG(ip, \
  1029. UNIPERIF_TDM_ENABLE_OFFSET(ip), \
  1030. UNIPERIF_TDM_ENABLE_EN_TDM_SHIFT(ip), \
  1031. UNIPERIF_TDM_ENABLE_EN_TDM_MASK(ip), 0)
  1032. /*
  1033. * UNIPERIF_TDM_FS_REF_FREQ
  1034. */
  1035. #define UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip) 0x011c
  1036. #define GET_UNIPERIF_TDM_FS_REF_FREQ(ip) \
  1037. readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip))
  1038. #define SET_UNIPERIF_TDM_FS_REF_FREQ(ip, value) \
  1039. writel_relaxed(value, ip->base + \
  1040. UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip))
  1041. /* REF_FREQ */
  1042. #define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip) 0x0
  1043. #define VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip) 0
  1044. #define VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip) 1
  1045. #define VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip) 2
  1046. #define VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip) 3
  1047. #define UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip) 0x3
  1048. #define GET_UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ(ip) \
  1049. GET_UNIPERIF_REG(ip, \
  1050. UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
  1051. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
  1052. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip))
  1053. #define SET_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip) \
  1054. SET_UNIPERIF_REG(ip, \
  1055. UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
  1056. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
  1057. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
  1058. VALUE_UNIPERIF_TDM_FS_REF_FREQ_8KHZ(ip))
  1059. #define SET_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip) \
  1060. SET_UNIPERIF_REG(ip, \
  1061. UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
  1062. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
  1063. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
  1064. VALUE_UNIPERIF_TDM_FS_REF_FREQ_16KHZ(ip))
  1065. #define SET_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip) \
  1066. SET_UNIPERIF_REG(ip, \
  1067. UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
  1068. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
  1069. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
  1070. VALUE_UNIPERIF_TDM_FS_REF_FREQ_32KHZ(ip))
  1071. #define SET_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip) \
  1072. SET_UNIPERIF_REG(ip, \
  1073. UNIPERIF_TDM_FS_REF_FREQ_OFFSET(ip), \
  1074. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_SHIFT(ip), \
  1075. UNIPERIF_TDM_FS_REF_FREQ_REF_FREQ_MASK(ip), \
  1076. VALUE_UNIPERIF_TDM_FS_REF_FREQ_48KHZ(ip))
  1077. /*
  1078. * UNIPERIF_TDM_FS_REF_DIV
  1079. */
  1080. #define UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip) 0x0120
  1081. #define GET_UNIPERIF_TDM_FS_REF_DIV(ip) \
  1082. readl_relaxed(ip->base + UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip))
  1083. #define SET_UNIPERIF_TDM_FS_REF_DIV(ip, value) \
  1084. writel_relaxed(value, ip->base + \
  1085. UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip))
  1086. /* NUM_TIMESLOT */
  1087. #define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip) 0x0
  1088. #define UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip) 0xff
  1089. #define GET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT(ip) \
  1090. GET_UNIPERIF_REG(ip, \
  1091. UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \
  1092. UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \
  1093. UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip))
  1094. #define SET_UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT(ip, value) \
  1095. SET_UNIPERIF_REG(ip, \
  1096. UNIPERIF_TDM_FS_REF_DIV_OFFSET(ip), \
  1097. UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_SHIFT(ip), \
  1098. UNIPERIF_TDM_FS_REF_DIV_NUM_TIMESLOT_MASK(ip), value)
  1099. /*
  1100. * UNIPERIF_TDM_WORD_POS_X_Y
  1101. * 32 bits of UNIPERIF_TDM_WORD_POS_X_Y register shall be set in 1 shot
  1102. */
  1103. #define UNIPERIF_TDM_WORD_POS_1_2_OFFSET(ip) 0x013c
  1104. #define UNIPERIF_TDM_WORD_POS_3_4_OFFSET(ip) 0x0140
  1105. #define UNIPERIF_TDM_WORD_POS_5_6_OFFSET(ip) 0x0144
  1106. #define UNIPERIF_TDM_WORD_POS_7_8_OFFSET(ip) 0x0148
  1107. #define GET_UNIPERIF_TDM_WORD_POS(ip, words) \
  1108. readl_relaxed(ip->base + UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip))
  1109. #define SET_UNIPERIF_TDM_WORD_POS(ip, words, value) \
  1110. writel_relaxed(value, ip->base + \
  1111. UNIPERIF_TDM_WORD_POS_##words##_OFFSET(ip))
  1112. /*
  1113. * uniperipheral IP capabilities
  1114. */
  1115. #define UNIPERIF_FIFO_SIZE 70 /* FIFO is 70 cells deep */
  1116. #define UNIPERIF_FIFO_FRAMES 4 /* FDMA trigger limit in frames */
  1117. #define UNIPERIF_TYPE_IS_HDMI(p) \
  1118. ((p)->type == SND_ST_UNIPERIF_TYPE_HDMI)
  1119. #define UNIPERIF_TYPE_IS_PCM(p) \
  1120. ((p)->type == SND_ST_UNIPERIF_TYPE_PCM)
  1121. #define UNIPERIF_TYPE_IS_SPDIF(p) \
  1122. ((p)->type == SND_ST_UNIPERIF_TYPE_SPDIF)
  1123. #define UNIPERIF_TYPE_IS_IEC958(p) \
  1124. (UNIPERIF_TYPE_IS_HDMI(p) || \
  1125. UNIPERIF_TYPE_IS_SPDIF(p))
  1126. #define UNIPERIF_TYPE_IS_TDM(p) \
  1127. ((p)->type == SND_ST_UNIPERIF_TYPE_TDM)
  1128. /*
  1129. * Uniperipheral IP revisions
  1130. */
  1131. enum uniperif_version {
  1132. SND_ST_UNIPERIF_VERSION_UNKNOWN,
  1133. /* SASG1 (Orly), Newman */
  1134. SND_ST_UNIPERIF_VERSION_C6AUD0_UNI_1_0,
  1135. /* SASC1, SASG2 (Orly2) */
  1136. SND_ST_UNIPERIF_VERSION_UNI_PLR_1_0,
  1137. /* SASC1, SASG2 (Orly2), TELSS, Cannes */
  1138. SND_ST_UNIPERIF_VERSION_UNI_RDR_1_0,
  1139. /* TELSS (SASC1) */
  1140. SND_ST_UNIPERIF_VERSION_TDM_PLR_1_0,
  1141. /* Cannes/Monaco */
  1142. SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0
  1143. };
  1144. enum uniperif_type {
  1145. SND_ST_UNIPERIF_TYPE_NONE = 0x00,
  1146. SND_ST_UNIPERIF_TYPE_HDMI = 0x01,
  1147. SND_ST_UNIPERIF_TYPE_PCM = 0x02,
  1148. SND_ST_UNIPERIF_TYPE_SPDIF = 0x04,
  1149. SND_ST_UNIPERIF_TYPE_TDM = 0x08
  1150. };
  1151. enum uniperif_state {
  1152. UNIPERIF_STATE_STOPPED,
  1153. UNIPERIF_STATE_STARTED,
  1154. UNIPERIF_STATE_STANDBY,
  1155. UNIPERIF_STATE_UNDERFLOW,
  1156. UNIPERIF_STATE_OVERFLOW = UNIPERIF_STATE_UNDERFLOW,
  1157. UNIPERIF_STATE_XRUN
  1158. };
  1159. enum uniperif_iec958_encoding_mode {
  1160. UNIPERIF_IEC958_ENCODING_MODE_PCM,
  1161. UNIPERIF_IEC958_ENCODING_MODE_ENCODED
  1162. };
  1163. enum uniperif_word_pos {
  1164. WORD_1_2,
  1165. WORD_3_4,
  1166. WORD_5_6,
  1167. WORD_7_8,
  1168. WORD_MAX
  1169. };
  1170. struct uniperif_iec958_settings {
  1171. enum uniperif_iec958_encoding_mode encoding_mode;
  1172. struct snd_aes_iec958 iec958;
  1173. };
  1174. struct dai_tdm_slot {
  1175. unsigned int mask;
  1176. int slots;
  1177. int slot_width;
  1178. unsigned int avail_slots;
  1179. };
  1180. struct uniperif {
  1181. /* System information */
  1182. enum uniperif_type type;
  1183. int underflow_enabled; /* Underflow recovery mode */
  1184. struct device *dev;
  1185. int id; /* instance value of the uniperipheral IP */
  1186. int ver; /* IP version, used by register access macros */
  1187. struct regmap_field *clk_sel;
  1188. struct regmap_field *valid_sel;
  1189. /* capabilities */
  1190. const struct snd_pcm_hardware *hw;
  1191. /* Resources */
  1192. struct resource *mem_region;
  1193. void __iomem *base;
  1194. unsigned long fifo_phys_address;
  1195. int irq;
  1196. /* Clocks */
  1197. struct clk *clk;
  1198. int mclk;
  1199. int clk_adj;
  1200. /* Runtime data */
  1201. enum uniperif_state state;
  1202. struct snd_pcm_substream *substream;
  1203. /* Specific to IEC958 player */
  1204. struct uniperif_iec958_settings stream_settings;
  1205. struct mutex ctrl_lock; /* For resource updated by stream and controls*/
  1206. /*alsa ctrl*/
  1207. struct snd_kcontrol_new *snd_ctrls;
  1208. int num_ctrls;
  1209. /* dai properties */
  1210. unsigned int daifmt;
  1211. struct dai_tdm_slot tdm_slot;
  1212. /* DAI callbacks */
  1213. const struct snd_soc_dai_ops *dai_ops;
  1214. };
  1215. struct sti_uniperiph_dai {
  1216. int stream;
  1217. struct uniperif *uni;
  1218. struct snd_dmaengine_dai_dma_data dma_data;
  1219. };
  1220. struct sti_uniperiph_data {
  1221. struct platform_device *pdev;
  1222. struct snd_soc_dai_driver *dai;
  1223. struct sti_uniperiph_dai dai_data;
  1224. };
  1225. static const struct snd_pcm_hardware uni_tdm_hw = {
  1226. .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
  1227. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP |
  1228. SNDRV_PCM_INFO_MMAP_VALID,
  1229. .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE,
  1230. .rates = SNDRV_PCM_RATE_CONTINUOUS,
  1231. .rate_min = 8000,
  1232. .rate_max = 48000,
  1233. .channels_min = 1,
  1234. .channels_max = 32,
  1235. .periods_min = 2,
  1236. .periods_max = 10,
  1237. .period_bytes_min = 128,
  1238. .period_bytes_max = 64 * PAGE_SIZE,
  1239. .buffer_bytes_max = 256 * PAGE_SIZE
  1240. };
  1241. /* uniperiph player*/
  1242. int uni_player_init(struct platform_device *pdev,
  1243. struct uniperif *uni_player);
  1244. int uni_player_resume(struct uniperif *player);
  1245. /* uniperiph reader */
  1246. int uni_reader_init(struct platform_device *pdev,
  1247. struct uniperif *uni_reader);
  1248. /* common */
  1249. int sti_uniperiph_dai_set_fmt(struct snd_soc_dai *dai,
  1250. unsigned int fmt);
  1251. int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,
  1252. struct snd_pcm_hw_params *params,
  1253. struct snd_soc_dai *dai);
  1254. static inline int sti_uniperiph_get_user_frame_size(
  1255. struct snd_pcm_runtime *runtime)
  1256. {
  1257. return (runtime->channels * snd_pcm_format_width(runtime->format) / 8);
  1258. }
  1259. static inline int sti_uniperiph_get_unip_tdm_frame_size(struct uniperif *uni)
  1260. {
  1261. return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8);
  1262. }
  1263. int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
  1264. unsigned int rx_mask, int slots,
  1265. int slot_width);
  1266. int sti_uniperiph_get_tdm_word_pos(struct uniperif *uni,
  1267. unsigned int *word_pos);
  1268. int sti_uniperiph_fix_tdm_chan(struct snd_pcm_hw_params *params,
  1269. struct snd_pcm_hw_rule *rule);
  1270. int sti_uniperiph_fix_tdm_format(struct snd_pcm_hw_params *params,
  1271. struct snd_pcm_hw_rule *rule);
  1272. #endif