uniperif.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  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. * AUD_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. * AUD_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. * AUD_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. * AUD_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. * AUD_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. * AUD_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. * AUD_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. * AUD_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. CORAUD_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. * AUD_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. * AUD_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. * uniperipheral IP capabilities
  1008. */
  1009. #define UNIPERIF_FIFO_SIZE 70 /* FIFO is 70 cells deep */
  1010. #define UNIPERIF_FIFO_FRAMES 4 /* FDMA trigger limit in frames */
  1011. /*
  1012. * Uniperipheral IP revisions
  1013. */
  1014. enum uniperif_version {
  1015. SND_ST_UNIPERIF_VERSION_UNKNOWN,
  1016. /* SASG1 (Orly), Newman */
  1017. SND_ST_UNIPERIF_VERSION_C6AUD0_UNI_1_0,
  1018. /* SASC1, SASG2 (Orly2) */
  1019. SND_ST_UNIPERIF_VERSION_UNI_PLR_1_0,
  1020. /* SASC1, SASG2 (Orly2), TELSS, Cannes */
  1021. SND_ST_UNIPERIF_VERSION_UNI_RDR_1_0,
  1022. /* TELSS (SASC1) */
  1023. SND_ST_UNIPERIF_VERSION_TDM_PLR_1_0,
  1024. /* Cannes/Monaco */
  1025. SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0
  1026. };
  1027. enum uniperif_type {
  1028. SND_ST_UNIPERIF_PLAYER_TYPE_NONE,
  1029. SND_ST_UNIPERIF_PLAYER_TYPE_HDMI,
  1030. SND_ST_UNIPERIF_PLAYER_TYPE_PCM,
  1031. SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF
  1032. };
  1033. enum uniperif_state {
  1034. UNIPERIF_STATE_STOPPED,
  1035. UNIPERIF_STATE_STARTED,
  1036. UNIPERIF_STATE_STANDBY,
  1037. UNIPERIF_STATE_UNDERFLOW,
  1038. UNIPERIF_STATE_OVERFLOW = UNIPERIF_STATE_UNDERFLOW,
  1039. UNIPERIF_STATE_XRUN
  1040. };
  1041. enum uniperif_iec958_encoding_mode {
  1042. UNIPERIF_IEC958_ENCODING_MODE_PCM,
  1043. UNIPERIF_IEC958_ENCODING_MODE_ENCODED
  1044. };
  1045. struct uniperif_info {
  1046. int id; /* instance value of the uniperipheral IP */
  1047. enum uniperif_type player_type;
  1048. int underflow_enabled; /* Underflow recovery mode */
  1049. };
  1050. struct uniperif_iec958_settings {
  1051. enum uniperif_iec958_encoding_mode encoding_mode;
  1052. struct snd_aes_iec958 iec958;
  1053. };
  1054. struct uniperif {
  1055. /* System information */
  1056. struct uniperif_info *info;
  1057. struct device *dev;
  1058. int ver; /* IP version, used by register access macros */
  1059. struct regmap_field *clk_sel;
  1060. /* capabilities */
  1061. const struct snd_pcm_hardware *hw;
  1062. /* Resources */
  1063. struct resource *mem_region;
  1064. void __iomem *base;
  1065. unsigned long fifo_phys_address;
  1066. int irq;
  1067. /* Clocks */
  1068. struct clk *clk;
  1069. int mclk;
  1070. int clk_adj;
  1071. /* Runtime data */
  1072. enum uniperif_state state;
  1073. struct snd_pcm_substream *substream;
  1074. /* Specific to IEC958 player */
  1075. struct uniperif_iec958_settings stream_settings;
  1076. struct mutex ctrl_lock; /* For resource updated by stream and controls*/
  1077. /*alsa ctrl*/
  1078. struct snd_kcontrol_new *snd_ctrls;
  1079. int num_ctrls;
  1080. /* dai properties */
  1081. unsigned int daifmt;
  1082. /* DAI callbacks */
  1083. const struct snd_soc_dai_ops *dai_ops;
  1084. };
  1085. struct sti_uniperiph_dai {
  1086. int stream;
  1087. struct uniperif *uni;
  1088. struct snd_dmaengine_dai_dma_data dma_data;
  1089. };
  1090. struct sti_uniperiph_data {
  1091. struct platform_device *pdev;
  1092. struct snd_soc_dai_driver *dai;
  1093. struct sti_uniperiph_dai dai_data;
  1094. };
  1095. /* uniperiph player*/
  1096. int uni_player_init(struct platform_device *pdev,
  1097. struct uniperif *uni_player);
  1098. int uni_player_resume(struct uniperif *player);
  1099. /* uniperiph reader */
  1100. int uni_reader_init(struct platform_device *pdev,
  1101. struct uniperif *uni_reader);
  1102. /* common */
  1103. int sti_uniperiph_dai_set_fmt(struct snd_soc_dai *dai,
  1104. unsigned int fmt);
  1105. int sti_uniperiph_dai_hw_params(struct snd_pcm_substream *substream,
  1106. struct snd_pcm_hw_params *params,
  1107. struct snd_soc_dai *dai);
  1108. #endif