dmac.h 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  1. /* Copyright 2018 Canaan Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #ifndef _DRIVER_DMAC_H
  16. #define _DRIVER_DMAC_H
  17. #include <stddef.h>
  18. #include <stdint.h>
  19. #include "io.h"
  20. #include "platform.h"
  21. #include "plic.h"
  22. #include "stdbool.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* DMAC */
  27. #define DMAC_CHANNEL_COUNT (DMAC_CHANNEL_MAX)
  28. #define LAST_ROW (-1)
  29. typedef enum _dmac_channel_number
  30. {
  31. DMAC_CHANNEL0 = 0,
  32. DMAC_CHANNEL1 = 1,
  33. DMAC_CHANNEL2 = 2,
  34. DMAC_CHANNEL3 = 3,
  35. DMAC_CHANNEL4 = 4,
  36. DMAC_CHANNEL5 = 5,
  37. DMAC_CHANNEL_MAX
  38. } dmac_channel_number_t;
  39. typedef enum _dmac_src_dst_select
  40. {
  41. DMAC_SRC = 0x1,
  42. DMAC_DST = 0x2,
  43. DMAC_SRC_DST = 0x3
  44. } dmac_src_dst_select_t;
  45. typedef enum _state_value
  46. {
  47. clear = 0,
  48. set = 1
  49. } state_value_t;
  50. typedef enum _dmac_lock_bus_ch
  51. {
  52. DMAC_LOCK_BUS = 0x1,
  53. DMAC_LOCK_CHANNEL = 0x2,
  54. DMAC_LOCK_BUS_CH = 0x3
  55. } dmac_lock_bus_ch_t;
  56. typedef enum _dmac_sw_hw_hs_select
  57. {
  58. DMAC_HS_HARDWARE = 0x0,
  59. DMAC_HS_SOFTWARE = 0x1
  60. } dmac_sw_hw_hs_select_t;
  61. typedef enum _dmac_scatter_gather_param
  62. {
  63. DMAC_SG_COUNT = 0x0,
  64. DMAC_SG_INTERVAL = 0x1
  65. } dmac_scatter_gather_param_t;
  66. typedef enum _dmac_irq
  67. {
  68. /* no interrupts */
  69. DMAC_IRQ_NONE = 0x00,
  70. /* transfer complete */
  71. DMAC_IRQ_TFR = 0x01,
  72. /* block transfer complete */
  73. DMAC_IRQ_BLOCK = 0x02,
  74. /* source transaction complete */
  75. DMAC_IRQ_SRCTRAN = 0x04,
  76. /* destination transaction complete */
  77. DMAC_IRQ_DSTTRAN = 0x08,
  78. /* error */
  79. DMAC_IRQ_ERR = 0x10,
  80. /* all interrupts */
  81. DMAC_IRQ_ALL = 0x1f
  82. } dmac_irq_t;
  83. typedef enum _dmac_software_req
  84. {
  85. /* ReqSrcReq/ReqDstReq */
  86. DMAC_REQUEST = 0x1,
  87. /* SglReqSrcReq/SglReqDstReq */
  88. DMAC_SINGLE_REQUEST = 0x2,
  89. /* LstReqSrcReq/LstReqDstReq */
  90. DMAC_LAST_REQUEST = 0x4
  91. } dmac_software_req_t;
  92. typedef enum _dmac_master_number
  93. {
  94. DMAC_MASTER1 = 0x0,
  95. DMAC_MASTER2 = 0x1
  96. } dmac_master_number_t;
  97. typedef enum _dmac_transfer_flow
  98. {
  99. /* mem to mem - DMAC flow ctlr */
  100. DMAC_MEM2MEM_DMA = 0x0,
  101. /* mem to prf - DMAC flow ctlr */
  102. DMAC_MEM2PRF_DMA = 0x1,
  103. /* prf to mem - DMAC flow ctlr */
  104. DMAC_PRF2MEM_DMA = 0x2,
  105. /* prf to prf - DMAC flow ctlr */
  106. DMAC_PRF2PRF_DMA = 0x3,
  107. /* prf to mem - periph flow ctlr */
  108. DMAC_PRF2MEM_PRF = 0x4,
  109. /* prf to prf - source flow ctlr */
  110. DMAC_PRF2PRF_SRCPRF = 0x5,
  111. /* mem to prf - periph flow ctlr */
  112. DMAC_MEM2PRF_PRF = 0x6,
  113. /* prf to prf - dest flow ctlr */
  114. DMAC_PRF2PRF_DSTPRF = 0x7
  115. } dmac_transfer_flow_t;
  116. typedef enum _dmac_burst_trans_length
  117. {
  118. DMAC_MSIZE_1 = 0x0,
  119. DMAC_MSIZE_4 = 0x1,
  120. DMAC_MSIZE_8 = 0x2,
  121. DMAC_MSIZE_16 = 0x3,
  122. DMAC_MSIZE_32 = 0x4,
  123. DMAC_MSIZE_64 = 0x5,
  124. DMAC_MSIZE_128 = 0x6,
  125. DMAC_MSIZE_256 = 0x7
  126. } dmac_burst_trans_length_t;
  127. typedef enum _dmac_address_increment
  128. {
  129. DMAC_ADDR_INCREMENT = 0x0,
  130. DMAC_ADDR_NOCHANGE = 0x1
  131. } dmac_address_increment_t;
  132. typedef enum _dmac_transfer_width
  133. {
  134. DMAC_TRANS_WIDTH_8 = 0x0,
  135. DMAC_TRANS_WIDTH_16 = 0x1,
  136. DMAC_TRANS_WIDTH_32 = 0x2,
  137. DMAC_TRANS_WIDTH_64 = 0x3,
  138. DMAC_TRANS_WIDTH_128 = 0x4,
  139. DMAC_TRANS_WIDTH_256 = 0x5
  140. } dmac_transfer_width_t;
  141. typedef enum _dmac_hs_interface
  142. {
  143. DMAC_HS_IF0 = 0x0,
  144. DMAC_HS_IF1 = 0x1,
  145. DMAC_HS_IF2 = 0x2,
  146. DMAC_HS_IF3 = 0x3,
  147. DMAC_HS_IF4 = 0x4,
  148. DMAC_HS_IF5 = 0x5,
  149. DMAC_HS_IF6 = 0x6,
  150. DMAC_HS_IF7 = 0x7,
  151. DMAC_HS_IF8 = 0x8,
  152. DMAC_HS_IF9 = 0x9,
  153. DMAC_HS_IF10 = 0xa,
  154. DMAC_HS_IF11 = 0xb,
  155. DMAC_HS_IF12 = 0xc,
  156. DMAC_HS_IF13 = 0xd,
  157. DMAC_HS_IF14 = 0xe,
  158. DMAC_HS_IF15 = 0xf
  159. } dmac_hs_interface_t;
  160. typedef enum _dmac_multiblk_transfer_type
  161. {
  162. CONTIGUOUS = 0,
  163. RELOAD = 1,
  164. SHADOWREGISTER = 2,
  165. LINKEDLIST = 3
  166. } dmac_multiblk_transfer_type_t;
  167. typedef enum _dmac_multiblk_type
  168. {
  169. DMAC_SRC_DST_CONTINUE = 0,
  170. DMAC_SRC_CONTINUE_DST_RELAOD = 2,
  171. DMAC_SRC_CONTINUE_DST_LINKEDLIST = 3,
  172. DMAC_SRC_RELOAD_DST_CONTINUE = 4,
  173. DMAC_SRC_RELOAD_DST_RELOAD = 5,
  174. DMAC_SRC_RELOAD_DST_LINKEDLIST = 6,
  175. DMAC_SRC_LINKEDLIST_DST_CONTINUE = 7,
  176. DMAC_SRC_LINKEDLIST_DST_RELOAD = 8,
  177. DMAC_SRC_LINKEDLIST_DST_LINKEDLIST = 9,
  178. DMAC_SRC_SHADOWREG_DST_CONTINUE = 10
  179. } dmac_multiblk_type_t;
  180. typedef enum _dmac_transfer_type
  181. {
  182. DMAC_TRANSFER_ROW1 = 0x1,
  183. DMAC_TRANSFER_ROW2 = 0x2,
  184. DMAC_TRANSFER_ROW3 = 0x3,
  185. DMAC_TRANSFER_ROW4 = 0x4,
  186. DMAC_TRANSFER_ROW5 = 0x5,
  187. DMAC_TRANSFER_ROW6 = 0x6,
  188. DMAC_TRANSFER_ROW7 = 0x7,
  189. DMAC_TRANSFER_ROW8 = 0x8,
  190. DMAC_TRANSFER_ROW9 = 0x9,
  191. DMAC_TRANSFER_ROW10 = 0xa
  192. } dmac_transfer_type_t;
  193. typedef enum _dmac_prot_level
  194. {
  195. /* default prot level */
  196. DMAC_NONCACHE_NONBUFF_NONPRIV_OPCODE = 0x0,
  197. DMAC_NONCACHE_NONBUFF_NONPRIV_DATA = 0x1,
  198. DMAC_NONCACHE_NONBUFF_PRIV_OPCODE = 0x2,
  199. DMAC_NONCACHE_NONBUFF_PRIV_DATA = 0x3,
  200. DMAC_NONCACHE_BUFF_NONPRIV_OPCODE = 0x4,
  201. DMAC_NONCACHE_BUFF_NONPRIV_DATA = 0x5,
  202. DMAC_NONCACHE_BUFF_PRIV_OPCODE = 0x6,
  203. DMAC_NONCACHE_BUFF_PRIV_DATA = 0x7,
  204. DMAC_CACHE_NONBUFF_NONPRIV_OPCODE = 0x8,
  205. DMAC_CACHE_NONBUFF_NONPRIV_DATA = 0x9,
  206. DMAC_CACHE_NONBUFF_PRIV_OPCODE = 0xa,
  207. DMAC_CACHE_NONBUFF_PRIV_DATA = 0xb,
  208. DMAC_CACHE_BUFF_NONPRIV_OPCODE = 0xc,
  209. DMAC_CACHE_BUFF_NONPRIV_DATA = 0xd,
  210. DMAC_CACHE_BUFF_PRIV_OPCODE = 0xe,
  211. DMAC_CACHE_BUFF_PRIV_DATA = 0xf
  212. } dmac_prot_level_t;
  213. typedef enum _dmac_fifo_mode
  214. {
  215. DMAC_FIFO_MODE_SINGLE = 0x0,
  216. DMAC_FIFO_MODE_HALF = 0x1
  217. } dmac_fifo_mode_t;
  218. typedef enum _dw_dmac_flow_ctl_mode
  219. {
  220. DMAC_DATA_PREFETCH_ENABLED = 0x0,
  221. DMAC_DATA_PREFETCH_DISABLED = 0x1
  222. } dw_dmac_flow_ctl_mode_t;
  223. typedef enum _dmac_polarity_level
  224. {
  225. DMAC_ACTIVE_HIGH = 0x0,
  226. DMAC_ACTIVE_LOW = 0x1
  227. } dmac_polarity_level_t;
  228. typedef enum _dmac_lock_level
  229. {
  230. DMAC_LOCK_LEVEL_DMA_TRANSFER = 0x0,
  231. DMAC_LOCK_LEVEL_BLOCK_TRANSFER = 0x1,
  232. DMAC_LOCK_LEVEL_TRANSACTION = 0x2
  233. } dmac_lock_level_t;
  234. typedef enum _dmac_channel_priority
  235. {
  236. DMAC_PRIORITY_0 = 0x0,
  237. DMAC_PRIORITY_1 = 0x1,
  238. DMAC_PRIORITY_2 = 0x2,
  239. DMAC_PRIORITY_3 = 0x3,
  240. DMAC_PRIORITY_4 = 0x4,
  241. DMAC_PRIORITY_5 = 0x5,
  242. DMAC_PRIORITY_6 = 0x6,
  243. DMAC_PRIORITY_7 = 0x7
  244. } dmac_channel_priority_t;
  245. typedef enum _dmac_state
  246. {
  247. ZERO,
  248. ONE
  249. } dmac_state_t;
  250. typedef enum _dmac_common_int
  251. {
  252. SLVIF_COMMON_DEC_ERR = 0,
  253. SLVIF_COMMON_WR2RO_ERR = 1,
  254. SLVIF_COMMON_RD2WO_ERR = 2,
  255. SLVIF_COMMON__WRONHOLD_ERR = 3,
  256. SLVIF_UNDEFINED_DEC_ERR = 4,
  257. SLVIF_ALL_INT = 5
  258. } dmac_common_int_t;
  259. typedef struct _dmac_cfg
  260. {
  261. /**
  262. * Bit 0 is used to enable dmac
  263. * 0x1 for enable, 0x0 for disable
  264. */
  265. uint64_t dmac_en : 1;
  266. /**
  267. * Bit 1 is used to glabally enable interrupt generation
  268. * 0x1 for enable interrupt, 0x0 for disable interrupt
  269. */
  270. uint64_t int_en : 1;
  271. /* Bits [63:2] is reserved */
  272. uint64_t rsvd : 62;
  273. } __attribute__((packed, aligned(8))) dmac_cfg_t;
  274. typedef union _dmac_cfg_u
  275. {
  276. dmac_cfg_t cfg;
  277. uint64_t data;
  278. } dmac_cfg_u_t;
  279. typedef struct _damc_chen
  280. {
  281. /**
  282. * Bit 0 is used to enable channel 1
  283. * 0x1 for enable, 0x0 for disable
  284. */
  285. uint64_t ch1_en : 1;
  286. /**
  287. * Bit 1 is used to enable channel 2
  288. * 0x1 for enable, 0x0 for disable
  289. */
  290. uint64_t ch2_en : 1;
  291. /**
  292. * Bit 2 is used to enable channel 3
  293. * 0x1 for enable, 0x0 for disable
  294. */
  295. uint64_t ch3_en : 1;
  296. /**
  297. * Bit 3 is used to enable channel 4
  298. * 0x1 for enable, 0x0 for disable
  299. */
  300. uint64_t ch4_en : 1;
  301. /**
  302. * Bit 4 is used to enable channel 5
  303. * 0x1 for enable, 0x0 for disable
  304. */
  305. uint64_t ch5_en : 1;
  306. /**
  307. * Bit 5 is used to enable channel 6
  308. * 0x1 for enable, 0x0 for disable
  309. */
  310. uint64_t ch6_en : 1;
  311. /* Bits [7:6] is reserved */
  312. uint64_t rsvd1 : 2;
  313. /**
  314. * Bit 8 is write enable bit
  315. * 0x1 for enable, 0x0 for disable
  316. */
  317. uint64_t ch1_en_we : 1;
  318. /**
  319. * Bit 9 is write enable bit
  320. * 0x1 for enable, 0x0 for disable
  321. */
  322. uint64_t ch2_en_we : 1;
  323. /**
  324. * Bit 10 is write enable bit
  325. * 0x1 for enable, 0x0 for disable
  326. */
  327. uint64_t ch3_en_we : 1;
  328. /**
  329. * Bit 11 is write enable bit
  330. * 0x1 for enable, 0x0 for disable
  331. */
  332. uint64_t ch4_en_we : 1;
  333. /**
  334. * Bit 12 is write enable bit
  335. * 0x1 for enable, 0x0 for disable
  336. */
  337. uint64_t ch5_en_we : 1;
  338. /**
  339. * Bit 13 is write enable bit
  340. * 0x1 for enable, 0x0 for disable
  341. */
  342. uint64_t ch6_en_we : 1;
  343. /* Bits [15:14] is reserved */
  344. uint64_t rsvd2 : 2;
  345. /**
  346. * Bit 16 is susped reuest
  347. * 0x1 for request channel suspend
  348. * 0x0 for no channel suspend request
  349. */
  350. uint64_t ch1_susp : 1;
  351. /**
  352. * Bit 17 is susped reuest
  353. * 0x1 for request channel suspend
  354. * 0x0 for no channel suspend request
  355. */
  356. uint64_t ch2_susp : 1;
  357. /* Bit 18 is susped reuest
  358. * 0x1 for request channel suspend
  359. * 0x0 for no channel suspend request
  360. */
  361. uint64_t ch3_susp : 1;
  362. /**
  363. * Bit 19 is susped reuest
  364. * 0x1 for request channel suspend
  365. * 0x0 for no channel suspend request
  366. */
  367. uint64_t ch4_susp : 1;
  368. /**
  369. * Bit 20 is susped reuest
  370. * 0x1 for request channel suspend
  371. * 0x0 for no channel suspend request
  372. */
  373. uint64_t ch5_susp : 1;
  374. /**
  375. * Bit 21 is susped reuest
  376. * 0x1 for request channel suspend
  377. * 0x0 for no channel suspend request
  378. */
  379. uint64_t ch6_susp : 1;
  380. /* Bits [23:22] is reserved */
  381. uint64_t rsvd3 : 2;
  382. /**
  383. * Bit 24 is write enable to the channel suspend bit
  384. * 0x1 for enable write to CH1_SUSP bit
  385. * 0x0 for disable write to CH1_SUSP bit
  386. */
  387. uint64_t ch1_susp_we : 1;
  388. /**
  389. * Bit 25 is write enable to the channel suspend bit
  390. * 0x1 for enable write to CH2_SUSP bit
  391. * 0x0 for disable write to CH2_SUSP bit
  392. */
  393. uint64_t ch2_susp_we : 1;
  394. /**
  395. * Bit 26 is write enable to the channel suspend bit
  396. * 0x1 for enable write to CH3_SUSP bit
  397. * 0x0 for disable write to CH3_SUSP bit
  398. */
  399. uint64_t ch3_susp_we : 1;
  400. /**
  401. * Bit 27 is write enable to the channel suspend bit
  402. * 0x1 for enable write to CH4_SUSP bit
  403. * 0x0 for disable write to CH4_SUSP bit
  404. */
  405. uint64_t ch4_susp_we : 1;
  406. /**
  407. * Bit 28 is write enable to the channel suspend bit
  408. * 0x1 for enable write to CH5_SUSP bit
  409. * 0x0 for disable write to CH5_SUSP bit
  410. */
  411. uint64_t ch5_susp_we : 1;
  412. /**
  413. * Bit 29 is write enable to the channel suspend bit
  414. * 0x1 for enable write to CH6_SUSP bit
  415. * 0x0 for disable write to CH6_SUSP bit
  416. */
  417. uint64_t ch6_susp_we : 1;
  418. /* Bits [31:30] is reserved */
  419. uint64_t rsvd4 : 2;
  420. /**
  421. * Bit 32 is channel-1 abort requst bit
  422. * 0x1 for request for channnel abort
  423. * 0x0 for no channel abort request
  424. */
  425. uint64_t ch1_abort : 1;
  426. /**
  427. * Bit 33 is channel-2 abort requst bit
  428. * 0x1 for request for channnel abort
  429. * 0x0 for no channel abort request
  430. */
  431. uint64_t ch2_abort : 1;
  432. /**
  433. * Bit 34 is channel-3 abort requst bit
  434. * 0x1 for request for channnel abort
  435. * 0x0 for no channel abort request
  436. */
  437. uint64_t ch3_abort : 1;
  438. /**
  439. * Bit 35 is channel-4 abort requst bit
  440. * 0x1 for request for channnel abort
  441. * 0x0 for no channel abort request
  442. */
  443. uint64_t ch4_abort : 1;
  444. /**
  445. * Bit 36 is channel-5 abort requst bit
  446. * 0x1 for request for channnel abort
  447. * 0x0 for no channel abort request
  448. */
  449. uint64_t ch5_abort : 1;
  450. /**
  451. * Bit 37 is channel-6 abort requst bit
  452. * 0x1 for request for channnel abort
  453. * 0x0 for no channel abort request
  454. */
  455. uint64_t ch6_abort : 1;
  456. /* Bits [39:38] is reserved */
  457. uint64_t rsvd5 : 2;
  458. /**
  459. * Bit 40 is ued to write enable channel-1 abort bit
  460. * 0x1 for enable write to CH1_ABORT bit
  461. * 0x0 for disable write to CH1_ABORT bit
  462. */
  463. uint64_t ch1_abort_we : 1;
  464. /**
  465. * Bit 41 is ued to write enable channel-2 abort bit
  466. * 0x1 for enable write to CH2_ABORT bit
  467. * 0x0 for disable write to CH2_ABORT bit
  468. */
  469. uint64_t ch2_abort_we : 1;
  470. /**
  471. * Bit 42 is ued to write enable channel-3 abort bit
  472. * 0x1 for enable write to CH3_ABORT bit
  473. * 0x0 for disable write to CH3_ABORT bit
  474. */
  475. uint64_t ch3_abort_we : 1;
  476. /**
  477. * Bit 43 is ued to write enable channel-4 abort bit
  478. * 0x1 for enable write to CH4_ABORT bit
  479. * 0x0 for disable write to CH4_ABORT bit
  480. */
  481. uint64_t ch4_abort_we : 1;
  482. /**
  483. * Bit 44 is ued to write enable channel-5 abort bit
  484. * 0x1 for enable write to CH5_ABORT bit
  485. * 0x0 for disable write to CH5_ABORT bit
  486. */
  487. uint64_t ch5_abort_we : 1;
  488. /**
  489. * Bit 45 is ued to write enable channel-6 abort bit
  490. * 0x1 for enable write to CH6_ABORT bit
  491. * 0x0 for disable write to CH6_ABORT bit
  492. */
  493. uint64_t ch6_abort_we : 1;
  494. /* Bits [47:46] is reserved */
  495. uint64_t rsvd6 : 2;
  496. /* Bits [63:48] is reserved */
  497. uint64_t rsvd7 : 16;
  498. } __attribute__((packed, aligned(8))) damc_chen_t;
  499. typedef union _dmac_chen_u
  500. {
  501. damc_chen_t dmac_chen;
  502. uint64_t data;
  503. } dmac_chen_u_t;
  504. typedef struct _dmac_intstatus
  505. {
  506. /**
  507. * Bit 0 is channel 1 interrupt bit
  508. * 0x1 for channel 1 interrupt active
  509. * 0x0 for channel 1 interrupt inactive
  510. */
  511. uint64_t ch1_intstat : 1;
  512. /**
  513. * Bit 1 is channel 1 interrupt bit
  514. * 0x1 for channel 2 interrupt active
  515. * 0x0 for channel 2 interrupt inactive
  516. */
  517. uint64_t ch2_intstat : 1;
  518. /**
  519. * Bit 2 is channel 3 interrupt bit
  520. * 0x1 for channel 3 interrupt active
  521. * 0x0 for channel 3 interrupt inactive
  522. */
  523. uint64_t ch3_intstat : 1;
  524. /**
  525. * Bit 3 is channel 4 interrupt bit
  526. * 0x1 for channel 4 interrupt active
  527. * 0x0 for channel 4 interrupt inactive
  528. */
  529. uint64_t ch4_intstat : 1;
  530. /**
  531. * Bit 4 is channel 5 interrupt bit
  532. * 0x1 for channel 5 interrupt active
  533. * 0x0 for channel 5 interrupt inactive
  534. */
  535. uint64_t ch5_intstat : 1;
  536. /**
  537. * Bit 5 is channel 6 interrupt bit
  538. * 0x1 for channel 6 interrupt active
  539. * 0x0 for channel 6 interrupt inactive
  540. */
  541. uint64_t ch6_intstat : 1;
  542. /* Bits [15:6] is reserved */
  543. uint64_t rsvd1 : 10;
  544. /**
  545. * Bit 16 is commom register status bit
  546. * 0x1 for common register interrupt is active
  547. * 0x0 for common register interrupt inactive
  548. */
  549. uint64_t commonreg_intstat : 1;
  550. /* Bits [63:17] is reserved */
  551. uint64_t rsvd2 : 47;
  552. } __attribute__((packed, aligned(8))) dmac_intstatus_t;
  553. typedef union _dmac_intstatus_u
  554. {
  555. dmac_intstatus_t intstatus;
  556. uint64_t data;
  557. } dmac_intstatus_u_t;
  558. typedef struct _dmac_commonreg_intclear
  559. {
  560. /**
  561. * Bit 0 is slave nterface Common Register
  562. * Decode Error Interrupt clear Bit
  563. * x01 for clear SLVIF_CommonReg_DEC_ERR interrupt
  564. * in DMAC_COMMONREG_INTSTATUSREG
  565. * 0x0 for inactive signal
  566. */
  567. uint64_t cear_slvif_dec_err_intstat : 1;
  568. /**
  569. * Bit 1 is Slave Interface Common Register Write
  570. * to Read only Error Interrupt clear Bit
  571. * x01 for clear SLVIF_CommonReg_WR2RO_ERR interrupt
  572. * in DMAC_COMMONREG_INTSTATUSREG
  573. * 0x0 for inactive signal
  574. */
  575. uint64_t clear_slvif_wr2ro_err_intstat : 1;
  576. /**
  577. * Bit 2 is Slave Interface Common Register Read to
  578. * Write only Error Interrupt clear Bit
  579. * x01 for clear SLVIF_CommonReg_RD2WO_ERR interrupt
  580. * in DMAC_COMMONREG_INTSTATUSREG
  581. * 0x0 for inactive signal
  582. */
  583. uint64_t clear_slvif_rd2wo_err_intstat : 1;
  584. /**
  585. * Bit 3 is Slave Interface Common Register Write
  586. * On Hold Error Interrupt clear Bit
  587. * x01 for clear SSLVIF_CommonReg_WrOnHold_ERR interrupt
  588. * in DMAC_COMMONREG_INTSTATUSREG
  589. * 0x0 for inactive signal
  590. */
  591. uint64_t clear_slvif_wronhold_err_intstat : 1;
  592. /* Bits [7:4] is reserved */
  593. uint64_t rsvd1 : 4;
  594. /**
  595. * Bit 8 is Slave Interface Undefined register
  596. * Decode Error Interrupt clear Bit
  597. * x01 for clear SLVIF_UndefinedReg_DEC_ERRinterrupt
  598. * in DMAC_COMMONREG_INTSTATUSREG
  599. * 0x0 for inactive signal
  600. */
  601. uint64_t clear_slvif_undefinedreg_dec_err_intstat : 1;
  602. /* Bits [63:9] is reserved */
  603. uint64_t rsvd2 : 55;
  604. } __attribute__((packed, aligned(8))) dmac_commonreg_intclear_t;
  605. typedef union _dmac_commonreg_intclear_u
  606. {
  607. dmac_commonreg_intclear_t com_intclear;
  608. uint64_t data;
  609. } dmac_commonreg_intclear_u_t;
  610. typedef struct _dmac_commonreg_intstatus_enable
  611. {
  612. /**
  613. * Bit 0 is Slave Interface Common Register Decode Error
  614. * Interrupt Status Enable Bit
  615. * 0x1 for SLVIF_CommonReg_DEC_ERR_IntStat bit enable
  616. * 0x0 for SLVIF_CommonReg_DEC_ERR_IntStat bit disable
  617. */
  618. uint64_t enable_slvif_dec_err_intstat : 1;
  619. /**
  620. * Bit 1 is Slave Interface Common Register Write to Read
  621. * only Error Interrupt Status Enable Bit
  622. * 0x1 for SLVIF_CommonReg_WR2RO_ERR_IntStat bit enable
  623. * 0x0 for SLVIF_CommonReg_WR2RO_ERR_IntStat bit disable
  624. */
  625. uint64_t enable_slvif_wr2ro_err_intstat : 1;
  626. /*!<
  627. * Bit 2 is Slave Interface Common Register Read to Write
  628. * only Error Interrupt Status Enable Bit
  629. * 0x1 for SLVIF_CommonReg_RD2WO_ERR_IntStat bit enable
  630. * 0x0 for SLVIF_CommonReg_RD2WO_ERR_IntStat bit disable
  631. */
  632. uint64_t enable_slvif_rd2wo_err_intstat : 1;
  633. /**
  634. * Bit 3 is Slave Interface Common Register Write On Hold
  635. * Error Interrupt Status Enable Bit
  636. * 0x1 for SLVIF_CommonReg_WrOnHold_ERR_IntStat bit enable
  637. * 0x0 for SLVIF_CommonReg_WrOnHold_ERR_IntStat bit disable
  638. */
  639. uint64_t enable_slvif_wronhold_err_intstat : 1;
  640. /* Bits [7:4] is reserved */
  641. uint64_t rsvd1 : 4;
  642. /**
  643. * Bit 8 is Slave Interface Undefined register Decode
  644. * Error Interrupt Status enable Bit
  645. * 0x1 for SLVIF_UndefinedReg_DEC_ERR_IntStat bit enable
  646. * 0x0 for SLVIF_UndefinedReg_DEC_ERR_IntStat disable
  647. */
  648. uint64_t enable_slvif_undefinedreg_dec_err_intstat : 1;
  649. /* Bits [63:9] is reserved */
  650. uint64_t rsvd2 : 55;
  651. } __attribute__((packed, aligned(8))) dmac_commonreg_intstatus_enable_t;
  652. typedef union _dmac_commonreg_intstatus_enable_u
  653. {
  654. dmac_commonreg_intstatus_enable_t intstatus_enable;
  655. uint64_t data;
  656. } dmac_commonreg_intstatus_enable_u_t;
  657. typedef struct _dmac_commonreg_intsignal_enable
  658. {
  659. /**
  660. * Bit 0 is Slave Interface Common Register Decode Error
  661. * Interrupt Signal Enable Bit
  662. * 0x1 for SLVIF_CommonReg_DEC_ERR_IntStat signal enable
  663. * 0x0 for SLVIF_CommonReg_DEC_ERR_IntStat signal disable
  664. */
  665. uint64_t enable_slvif_dec_err_intsignal : 1;
  666. /**
  667. * Bit 1 is Slave Interface Common Register Write to Read only
  668. * Error Interrupt Signal Enable Bit
  669. * 0x1 for SLVIF_CommonReg_WR2RO_ERR_IntStat signal enable
  670. * 0x0 for SLVIF_CommonReg_WR2RO_ERR_IntStat signal disable
  671. */
  672. uint64_t enable_slvif_wr2ro_err_intsignal : 1;
  673. /**
  674. * Bit 2 is Slave Interface Common Register Read to
  675. * Write only Error Interrupt Status Enable Bit
  676. * 0x1 for SLVIF_CommonReg_RD2WO_ERR_IntStat bit enable
  677. * 0x0 for SLVIF_CommonReg_RD2WO_ERR_IntStat bit disable
  678. */
  679. uint64_t enable_slvif_rd2wo_err_intsignal : 1;
  680. /**
  681. * Bit 3 is Slave Interface Common Register Write On Hold Error
  682. * Interrupt Signal Enable Bit
  683. * 0x1 for SLVIF_CommonReg_WrOnHold_ERR_IntStat signal enable
  684. * 0x0 for SLVIF_CommonReg_WrOnHold_ERR_IntStat signal disable
  685. */
  686. uint64_t enable_slvif_wronhold_err_intsignal : 1;
  687. /* Bits [7:4] is reserved */
  688. uint64_t rsvd1 : 4;
  689. /**
  690. * Bit 8 is Slave Interface Undefined register Decode Error
  691. * Interrupt Signal Enable Bit
  692. * 0x1 for SLVIF_UndefinedReg_DEC_ERR_IntStat signal enable
  693. * 0x0 for SLVIF_UndefinedReg_DEC_ERR_IntStat signal disable
  694. */
  695. uint64_t enable_slvif_undefinedreg_dec_err_intsignal : 1;
  696. /* Bits [63:9] is reserved */
  697. uint64_t rsvd2 : 55;
  698. } __attribute__((packed, aligned(8))) dmac_commonreg_intsignal_enable_t;
  699. typedef union _dmac_commonreg_intsignal_enable_u
  700. {
  701. dmac_commonreg_intsignal_enable_t intsignal_enable;
  702. uint64_t data;
  703. } dmac_commonreg_intsignal_enable_u_t;
  704. typedef struct _dmac_commonreg_intstatus
  705. {
  706. /**
  707. * Bit 0 is Slave Interface Common Register Decode
  708. * Error Interrupt Status Bit
  709. * 0x1 for Slave Interface Decode Error detected
  710. * 0x0 for No Slave Interface Decode Errors
  711. */
  712. uint64_t slvif_dec_err_intstat : 1;
  713. /**
  714. * Bit 1 is Slave Interface Common Register Write to Read Only
  715. * Error Interrupt Status bit
  716. * 0x1 for Slave Interface Write to Read Only Error detected
  717. * 0x0 No Slave Interface Write to Read Only Errors
  718. */
  719. uint64_t slvif_wr2ro_err_intstat : 1;
  720. /**
  721. * Bit 2 is Slave Interface Common Register Read to Write
  722. * only Error Interrupt Status bit
  723. * 0x1 for Slave Interface Read to Write Only Error detected
  724. * 0x0 for No Slave Interface Read to Write Only Errors
  725. */
  726. uint64_t slvif_rd2wo_err_intstat : 1;
  727. /**
  728. * Bit 3 is Slave Interface Common Register Write On
  729. * Hold Error Interrupt Status Bit
  730. * 0x1 for Slave Interface Common Register Write On Hold Error detected
  731. * 0x0 for No Slave Interface Common Register Write On Hold Errors
  732. */
  733. uint64_t slvif_wronhold_err_intstat : 1;
  734. /*!< Bits [7:4] is reserved */
  735. uint64_t rsvd1 : 4;
  736. /**
  737. * Bit 8 is Slave Interface Undefined register Decode
  738. * Error Interrupt Signal Enable Bit
  739. * 0x1 for Slave Interface Decode Error detected
  740. * 0x0 for No Slave Interface Decode Errors
  741. */
  742. uint64_t slvif_undefinedreg_dec_err_intstat : 1;
  743. /* Bits [63:9] is reserved */
  744. uint64_t rsvd2 : 55;
  745. } __attribute__((packed, aligned(8))) dmac_commonreg_intstatus_t;
  746. typedef union _dmac_commonreg_intstatus_u
  747. {
  748. dmac_commonreg_intstatus_t commonreg_intstatus;
  749. uint64_t data;
  750. } dmac_commonreg_intstatus_u_t;
  751. typedef struct _dmac_reset
  752. {
  753. /* Bit 0 is DMAC reset request bit */
  754. uint64_t rst : 1;
  755. /* Bits [63:1] is reserved */
  756. uint64_t rsvd : 63;
  757. } __attribute__((packed, aligned(8))) dmac_reset_t;
  758. typedef union _dmac_reset_u
  759. {
  760. dmac_reset_t reset;
  761. uint64_t data;
  762. } dmac_reset_u_t;
  763. typedef struct _dmac_ch_block_ts
  764. {
  765. uint64_t block_ts : 22;
  766. /*!< Bit [21:0] is block transfer size*/
  767. uint64_t rsvd : 42;
  768. /*!< Bits [63:22] is reserved */
  769. } __attribute__((packed, aligned(8))) dmac_ch_block_ts_t;
  770. typedef union _dmac_ch_block_ts_u
  771. {
  772. dmac_ch_block_ts_t block_ts;
  773. uint64_t data;
  774. } dmac_ch_block_ts_u_t;
  775. typedef struct _dmac_ch_ctl
  776. {
  777. /**
  778. * Bit 0 is source master select
  779. * 1 for AXI master 2, 0 for AXI master 1
  780. */
  781. uint64_t sms : 1;
  782. /* Bit 1 is reserved */
  783. uint64_t rsvd1 : 1;
  784. /**
  785. * Bit 2 is destination master select
  786. * 0x1 for AXI master 2,0x0 for AXI master 1
  787. */
  788. uint64_t dms : 1;
  789. /* Bit 3 is reserved */
  790. uint64_t rsvd2 : 1;
  791. /**
  792. * Bit 4 is source address increment
  793. * 0x1 for no change, 0x0 for incremnet
  794. */
  795. uint64_t sinc : 1;
  796. /**
  797. * Bit 5 is reserved
  798. */
  799. uint64_t rsvd3 : 1;
  800. /**
  801. * Bit 6 is destination address incremnet
  802. * 0x1 for no change, 0x0 for increment
  803. */
  804. uint64_t dinc : 1;
  805. /* Bit 7 is reserved*/
  806. uint64_t rsvd4 : 1;
  807. /**
  808. * Bits [10:8] is source transfer width
  809. * 0x0 for source transfer width is 8 bits
  810. * 0x1 for source transfer width is 16 bits
  811. * 0x2 for source transfer width is 32 bits
  812. * 0x3 for source transfer width is 64 bits
  813. * 0x4 for source transfer width is 128 bits
  814. * 0x5 for source transfer width is 256 bits
  815. * 0x6 for source transfer width is 512 bits
  816. */
  817. uint64_t src_tr_width : 3;
  818. /**
  819. * Bits [13:11] is detination transfer width
  820. * 0x0 for detination transfer width is 8 bits
  821. * 0x1 for detination transfer width is 16 bits
  822. * 0x2 for detination transfer width is 32 bits
  823. * 0x3 for detination transfer width is 64 bits
  824. * 0x4 for detination transfer width is 128 bits
  825. * 0x5 for detination transfer width is 256 bits
  826. * 0x6 for detination transfer width is 512 bits
  827. */
  828. uint64_t dst_tr_width : 3;
  829. /**
  830. * Bits [17:14] is source burst transaction length
  831. * 0x0 for 1 data item read from rource in the burst transaction
  832. * 0x1 for 4 data item read from rource in the burst transaction
  833. * 0x2 for 8 data item read from rource in the burst transaction
  834. * 0x3 for 16 data item read from rource in the burst transaction
  835. * 0x4 for 32 data item read from rource in the burst transaction
  836. * 0x5 for 64 data item read from rource in the burst transaction
  837. * 0x6 for 128 data item read from rource in the burst transaction
  838. * 0x7 for 256 data item read from rource in the burst transaction
  839. * 0x8 for 512 data item read from rource in the burst transaction
  840. * 0x9 for 1024 data item read from rource in the burst transaction
  841. */
  842. uint64_t src_msize : 4;
  843. /**
  844. * Bits [17:14] is sdestination burst transaction length
  845. * 0x0 for 1 data item read from rource in the burst transaction
  846. * 0x1 for 4 data item read from rource in the burst transaction
  847. * 0x2 for 8 data item read from rource in the burst transaction
  848. * 0x3 for 16 data item read from rource in the burst transaction
  849. * 0x4 for 32 data item read from rource in the burst transaction
  850. * 0x5 for 64 data item read from rource in the burst transaction
  851. * 0x6 for 128 data item read from rource in the burst transaction
  852. * 0x7 for 256 data item read from rource in the burst transaction
  853. * 0x8 for 512 data item read from rource in the burst transaction
  854. * 0x9 for 1024 data item read from rource in the burst transaction
  855. */
  856. uint64_t dst_msize : 4;
  857. /**
  858. * Bits [25:22] is reserved
  859. */
  860. uint64_t rsvd5 : 4;
  861. /*!< Bits [29:26] is reserved */
  862. uint64_t rsvd6 : 4;
  863. /**
  864. * Bit 30 is Non Posted Last Write Enable
  865. * 0x1 for posted writes may be used till the end of the block
  866. * 0x 0 for posted writes may be used throughout the block transfer
  867. */
  868. uint64_t nonposted_lastwrite_en : 1;
  869. /* Bit 31 is resrved */
  870. uint64_t rsvd7 : 1;
  871. /* Bits [34:32] is reserved*/
  872. uint64_t rsvd8 : 3;
  873. /* Bits [37:35] is reserved*/
  874. uint64_t rsvd9 : 3;
  875. /**
  876. * Bit 38 is source burst length enable
  877. * 1 for enable, 0 for disable
  878. */
  879. uint64_t arlen_en : 1;
  880. /* Bits [46:39] is source burst length*/
  881. uint64_t arlen : 8;
  882. /**
  883. * Bit 47 is destination burst length enable
  884. * 1 for enable, 0 for disable
  885. */
  886. uint64_t awlen_en : 1;
  887. /* Bits [55:48] is destination burst length */
  888. uint64_t awlen : 8;
  889. /**
  890. * Bit 56 is source status enable
  891. * 0x1 for enable, 0x0 for disable
  892. */
  893. uint64_t src_stat_en : 1;
  894. /**
  895. * Bit 57 is destination status enable
  896. * 0x1 for enable, 0x0 for disable
  897. */
  898. uint64_t dst_stat_en : 1;
  899. /**
  900. * Bit 58 is interrupt completion of block transfer
  901. * 0x1 for enable CHx_IntStatusReg.BLOCK_TFR_DONE_IntStat field
  902. * 0x0 for dsiable CHx_IntStatusReg.BLOCK_TFR_DONE_IntStat field
  903. */
  904. uint64_t ioc_blktfr : 1;
  905. /**
  906. * Bits [61:59] is reserved
  907. */
  908. uint64_t rsvd10 : 3;
  909. /**
  910. * Bit 62 is last shadow linked list item
  911. * 0x1 for indicate shadowreg/LLI content is the last one
  912. * 0x0 for indicate shadowreg/LLI content not the last one
  913. */
  914. uint64_t shadowreg_or_lli_last : 1;
  915. /**
  916. * Bit 63 is last shadow linked list item valid
  917. * 0x1 for indicate shadowreg/LLI content is valid
  918. * 0x0 for indicate shadowreg/LLI content is invalid
  919. */
  920. uint64_t shadowreg_or_lli_valid : 1;
  921. } __attribute__((packed, aligned(8))) dmac_ch_ctl_t;
  922. typedef union _dmac_ch_ctl_u
  923. {
  924. dmac_ch_ctl_t ch_ctl;
  925. uint64_t data;
  926. } dmac_ch_ctl_u_t;
  927. typedef struct _dmac_ch_cfg
  928. {
  929. /**
  930. * Bit[1:0] is source multi block transfer type
  931. * 0x0 for continuous multiblock type
  932. * 0x1 for reload multiblock type
  933. * 0x2 for shadow register based multiblock type
  934. * 0x3 for linked lisr bases multiblock type
  935. */
  936. uint64_t src_multblk_type : 2;
  937. /**
  938. * Bit[3:2] is source multi block transfer type
  939. * 0x0 for continuous multiblock type
  940. * 0x1 for reload multiblock type
  941. * 0x2 for shadow register based multiblock type
  942. * 0x3 for linked lisr bases multiblock type
  943. */
  944. uint64_t dst_multblk_type : 2;
  945. /* Bits [31:4] is reserved*/
  946. uint64_t rsvd1 : 28;
  947. /**
  948. * Bits [34:32] is transfer type and flow control
  949. * 0x0 transfer memory to memory and flow controler is dmac
  950. * 0x1 transfer memory to peripheral and flow controler is dmac
  951. * 0x2 transfer peripheral to memory and flow controler is dmac
  952. * 0x3 transfer peripheral to peripheral and flow controler is dmac
  953. * 0x4 transfer peripheral to memory and flow controler is
  954. * source peripheral
  955. * 0x5 transfer peripheral to peripheral and flow controler
  956. * is source peripheral
  957. * 0x6 transfer memory to peripheral and flow controler is
  958. * destination peripheral
  959. * 0x7 transfer peripheral to peripheral and flow controler
  960. * is destination peripheral
  961. */
  962. uint64_t tt_fc : 3;
  963. /**
  964. * Bit 35 is source software or hardware handshaking select
  965. * 0x1 for software handshaking is used
  966. * 0x0 for hardware handshaking is used
  967. */
  968. uint64_t hs_sel_src : 1;
  969. /**
  970. * Bit 36 is destination software or hardware handshaking select
  971. *0x1 for software handshaking is used
  972. *0x0 for hardware handshaking is used
  973. */
  974. uint64_t hs_sel_dst : 1;
  975. /**
  976. * Bit 37 is sorce hardware handshaking interface polarity
  977. * 0x1 active low, 0x0 active high
  978. */
  979. uint64_t src_hwhs_pol : 1;
  980. /**
  981. * Bit 38 is destination hardware handshaking interface polarity
  982. * 0x1 active low, 0x0 active high
  983. */
  984. uint64_t dst_hwhs_pol : 1;
  985. /**
  986. * Bits [41:39] is assign a hardware handshaking interface
  987. * to source of channel x
  988. */
  989. uint64_t src_per : 4;
  990. /* Bit 43 is reserved*/
  991. uint64_t rsvd3 : 1;
  992. /**
  993. * Bits [46:44] is assign a hardware handshaking interface
  994. * to destination of channel x
  995. */
  996. uint64_t dst_per : 4;
  997. /* Bit 48 is reserved*/
  998. uint64_t rsvd5 : 1;
  999. /* Bits [51:49] is channel priority,7 is highest, 0 is lowest*/
  1000. uint64_t ch_prior : 3;
  1001. /**
  1002. * Bit 52 is channel lock bit
  1003. * 0x0 for channel is not locked, 0x1 for channel is locked
  1004. */
  1005. uint64_t lock_ch : 1;
  1006. /**
  1007. * Bits [54:53] is chnannel lock level
  1008. * 0x0 for duration of channel is locked for entire DMA transfer
  1009. * 0x1 for duration of channel is locked for current block transfer
  1010. */
  1011. uint64_t lock_ch_l : 2;
  1012. uint64_t src_osr_lmt : 4;
  1013. /* Bits [58:55] is source outstanding request limit */
  1014. uint64_t dst_osr_lmt : 4;
  1015. /* Bits [62:59] is destination outstanding request limit */
  1016. } __attribute__((packed, aligned(8))) dmac_ch_cfg_t;
  1017. typedef union _dmac_ch_cfg_u
  1018. {
  1019. dmac_ch_cfg_t ch_cfg;
  1020. uint64_t data;
  1021. } dmac_ch_cfg_u_t;
  1022. typedef struct _dmac_ch_llp
  1023. {
  1024. /**
  1025. * Bit 0 is LLI master select
  1026. * 0x0 for next linked list item resides on AXI madster1 interface
  1027. * 0x1 for next linked list item resides on AXI madster2 interface
  1028. */
  1029. uint64_t lms : 1;
  1030. /* Bits [5:1] is reserved */
  1031. uint64_t rsvd1 : 5;
  1032. /* Bits [63:6] is starting address memeory of LLI block */
  1033. uint64_t loc : 58;
  1034. } __attribute__((packed, aligned(8))) dmac_ch_llp_t;
  1035. typedef union _dmac_ch_llp_u
  1036. {
  1037. dmac_ch_llp_t llp;
  1038. uint64_t data;
  1039. } dmac_ch_llp_u_t;
  1040. typedef struct _dmac_ch_status
  1041. {
  1042. /* Bits [21:0] is completed block transfer size */
  1043. uint64_t cmpltd_blk_size : 22;
  1044. /* Bits [46:32] is reserved */
  1045. uint64_t rsvd1 : 15;
  1046. /* Bits [63:47] is reserved */
  1047. uint64_t rsvd2 : 17;
  1048. } __attribute__((packed, aligned(8))) dmac_ch_status_t;
  1049. typedef union _dmac_ch_status_u
  1050. {
  1051. dmac_ch_status_t status;
  1052. uint64_t data;
  1053. } dmac_ch_status_u_t;
  1054. typedef struct _dmac_ch_swhssrc
  1055. {
  1056. /**
  1057. * Bit 0 is software handshake request for channel source
  1058. * 0x1 source periphraral request for a dma transfer
  1059. * 0x0 source peripheral is not request for a burst transfer
  1060. */
  1061. uint64_t swhs_req_src : 1;
  1062. /**
  1063. * Bit 1 is write enable bit for software handshake request
  1064. *0x1 for enable, 0x0 for disable
  1065. */
  1066. uint64_t swhs_req_src_we : 1;
  1067. /**
  1068. * Bit 2 is software handshake single request for channel source
  1069. * 0x1 for source peripheral requesr for a single dma transfer
  1070. * 0x0 for source peripheral is not requesting for a single transfer
  1071. */
  1072. uint64_t swhs_sglreq_src : 1;
  1073. /**
  1074. * Bit 3 is write enable bit for software handshake
  1075. * single request for channle source
  1076. * 0x1 for enable write, 0x0 for disable write
  1077. */
  1078. uint64_t swhs_sglreq_src_we : 1;
  1079. /**
  1080. * Bit 4 software handshake last request for channel source
  1081. * 0x1 for current transfer is last transfer
  1082. * 0x0 for current transfer is not the last transfer
  1083. */
  1084. uint64_t swhs_lst_src : 1;
  1085. /**
  1086. * Bit 5 is write enable bit for software
  1087. * handshake last request
  1088. * 0x1 for enable, 0x0 for disable
  1089. */
  1090. uint64_t swhs_lst_src_we : 1;
  1091. /* Bits [63:6] is reserved */
  1092. uint64_t rsvd : 58;
  1093. } __attribute__((packed, aligned(8))) dmac_ch_swhssrc_t;
  1094. typedef union _dmac_ch_swhssrc_u
  1095. {
  1096. dmac_ch_swhssrc_t swhssrc;
  1097. uint64_t data;
  1098. } dmac_ch_swhssrc_u_t;
  1099. typedef struct _dmac_ch_swhsdst
  1100. {
  1101. /**
  1102. * Bit 0 is software handshake request for channel destination
  1103. * 0x1 destination periphraral request for a dma transfer
  1104. * 0x0 destination peripheral is not request for a burst transfer
  1105. */
  1106. uint64_t swhs_req_dst : 1;
  1107. /**
  1108. * Bit 1 is write enable bit for software handshake request
  1109. * 0x1 for enable, 0x0 for disable
  1110. */
  1111. uint64_t swhs_req_dst_we : 1;
  1112. /**
  1113. * Bit 2 is software handshake single request for channel destination
  1114. * 0x1 for destination peripheral requesr for a single dma transfer
  1115. * 0x0 for destination peripheral is not requesting
  1116. * for a single transfer
  1117. */
  1118. uint64_t swhs_sglreq_dst : 1;
  1119. /**
  1120. * Bit 3 is write enable bit for software handshake
  1121. * single request for channle destination
  1122. * 0x1 for enable write, 0x0 for disable write
  1123. */
  1124. uint64_t swhs_sglreq_dst_we : 1;
  1125. /**
  1126. * Bit 4 software handshake last request for channel dstination
  1127. * 0x1 for current transfer is last transfer
  1128. * 0x0 for current transfer is not the last transfer
  1129. */
  1130. uint64_t swhs_lst_dst : 1;
  1131. /**
  1132. * Bit 5 is write enable bit for software handshake last request
  1133. * 0x1 for enable, 0x0 for disable
  1134. */
  1135. uint64_t swhs_lst_dst_we : 1;
  1136. /* Bits [63:6] is reserved */
  1137. uint64_t rsvd : 58;
  1138. } __attribute__((packed, aligned(8))) dmac_ch_swhsdst_t;
  1139. typedef union _dmac_ch_swhsdst_u
  1140. {
  1141. dmac_ch_swhsdst_t swhsdst;
  1142. uint64_t data;
  1143. } dmac_ch_swhsdst_u_t;
  1144. typedef struct _dmac_ch_blk_tfr_resumereq
  1145. {
  1146. /**
  1147. * Bit 0 is block transfer resume request bit
  1148. * 0x1 for request for resuming
  1149. * 0x0 for no request to resume
  1150. */
  1151. uint64_t blk_tfr_resumereq : 1;
  1152. /* Bits [63:1] is reserved */
  1153. uint64_t rsvd : 63;
  1154. } __attribute__((packed, aligned(8))) dmac_ch_blk_tfr_resumereq_t;
  1155. typedef union _dmac_ch_blk_tfr_resumereq_u
  1156. {
  1157. dmac_ch_blk_tfr_resumereq_t blk_tfr_resumereq;
  1158. uint64_t data;
  1159. } dmac_ch_blk_tfr_resumereq_u_t;
  1160. typedef struct _dmac_ch_intstatus_enable
  1161. {
  1162. /* Bit 0 is block transfer done interrupt status enable */
  1163. uint64_t enable_block_tfr_done_intstatus : 1;
  1164. /* DMA transfer done interrupt status enable */
  1165. uint64_t enable_dma_tfr_done_intstat : 1;
  1166. /* Bit 2 reserved */
  1167. uint64_t rsvd1 : 1;
  1168. /* Bit 3 source transaction complete status enable */
  1169. uint64_t enable_src_transcomp_intstat : 1;
  1170. /* Bit 4 destination transaction complete */
  1171. uint64_t enable_dst_transcomp_intstat : 1;
  1172. /* Bit 5 Source Decode Error Status Enable */
  1173. uint64_t enable_src_dec_err_intstat : 1;
  1174. /* Bit 6 Destination Decode Error Status Enable */
  1175. uint64_t enable_dst_dec_err_intstat : 1;
  1176. /* Bit 7 Source Slave Error Status Enable */
  1177. uint64_t enable_src_slv_err_intstat : 1;
  1178. /* Bit 8 Destination Slave Error Status Enable */
  1179. uint64_t enable_dst_slv_err_intstat : 1;
  1180. /* Bit 9 LLI Read Decode Error Status Enable */
  1181. uint64_t enable_lli_rd_dec_err_intstat : 1;
  1182. /* Bit 10 LLI WRITE Decode Error Status Enable */
  1183. uint64_t enable_lli_wr_dec_err_intstat : 1;
  1184. /* Bit 11 LLI Read Slave Error Status Enable */
  1185. uint64_t enable_lli_rd_slv_err_intstat : 1;
  1186. /* Bit 12 LLI WRITE Slave Error Status Enable */
  1187. uint64_t enable_lli_wr_slv_err_intstat : 1;
  1188. uint64_t rsvd2 : 51;
  1189. } dmac_ch_intstatus_enable_t;
  1190. typedef union _dmac_ch_intstatus_enable_u
  1191. {
  1192. dmac_ch_intstatus_enable_t ch_intstatus_enable;
  1193. uint64_t data;
  1194. } dmac_ch_intstatus_enable_u_t;
  1195. typedef struct _dmac_ch_intclear
  1196. {
  1197. /* Bit 0 block transfer done interrupt clear bit.*/
  1198. uint64_t blk_tfr_done_intstat : 1;
  1199. /* Bit 1 DMA transfer done interrupt clear bit */
  1200. uint64_t dma_tfr_done_intstat : 1;
  1201. /* Bit 2 is reserved */
  1202. uint64_t resv1 : 1;
  1203. uint64_t resv2 : 61;
  1204. } __attribute__((packed, aligned(8))) dmac_ch_intclear_t;
  1205. typedef union _dmac_ch_intclear_u
  1206. {
  1207. uint64_t data;
  1208. dmac_ch_intclear_t intclear;
  1209. } dmac_ch_intclear_u_t;
  1210. typedef struct _dmac_channel
  1211. {
  1212. /* (0x100) SAR Address Register */
  1213. uint64_t sar;
  1214. /* (0x108) DAR Address Register */
  1215. uint64_t dar;
  1216. /* (0x110) Block Transfer Size Register */
  1217. uint64_t block_ts;
  1218. /* (0x118) Control Register */
  1219. uint64_t ctl;
  1220. /* (0x120) Configure Register */
  1221. uint64_t cfg;
  1222. /* (0x128) Linked List Pointer register */
  1223. uint64_t llp;
  1224. /* (0x130) Channelx Status Register */
  1225. uint64_t status;
  1226. /* (0x138) Channelx Software handshake Source Register */
  1227. uint64_t swhssrc;
  1228. /* (0x140) Channelx Software handshake Destination Register */
  1229. uint64_t swhsdst;
  1230. /* (0x148) Channelx Block Transfer Resume Request Register */
  1231. uint64_t blk_tfr;
  1232. /* (0x150) Channelx AXI ID Register */
  1233. uint64_t axi_id;
  1234. /* (0x158) Channelx AXI QOS Register */
  1235. uint64_t axi_qos;
  1236. /* Reserved address */
  1237. uint64_t reserved1[4];
  1238. /* (0x180) Interrupt Status Enable Register */
  1239. uint64_t intstatus_en;
  1240. /* (0x188) Channelx Interrupt Status Register */
  1241. uint64_t intstatus;
  1242. /* (0x190) Interrupt Siganl Enable Register */
  1243. uint64_t intsignal_en;
  1244. /* (0x198) Interrupt Clear Register */
  1245. uint64_t intclear;
  1246. uint64_t reserved2[12];
  1247. } __attribute__((packed, aligned(8))) dmac_channel_t;
  1248. typedef struct _dmac
  1249. {
  1250. /* (0x00) DMAC ID Rgister */
  1251. uint64_t id;
  1252. /* (0x08) DMAC COMPVER Register */
  1253. uint64_t compver;
  1254. /* (0x10) DMAC Configure Register */
  1255. uint64_t cfg;
  1256. /* (0x18) Channel Enable Register */
  1257. uint64_t chen;
  1258. uint64_t reserved1[2];
  1259. /* (0x30) DMAC Interrupt Status Register */
  1260. uint64_t intstatus;
  1261. /* (0x38) DMAC Common register Interrupt Status Register */
  1262. uint64_t com_intclear;
  1263. /* (0x40) DMAC Common Interrupt Enable Register */
  1264. uint64_t com_intstatus_en;
  1265. /* (0x48) DMAC Common Interrupt Signal Enable Register */
  1266. uint64_t com_intsignal_en;
  1267. /* (0x50) DMAC Common Interrupt Status */
  1268. uint64_t com_intstatus;
  1269. /* (0x58) DMAC Reset register */
  1270. uint64_t reset;
  1271. uint64_t reserved2[20];
  1272. dmac_channel_t channel[DMAC_CHANNEL_COUNT];
  1273. } __attribute__((packed, aligned(8))) dmac_t;
  1274. typedef struct _dmac_channel_config
  1275. {
  1276. uint64_t sar;
  1277. uint64_t dar;
  1278. uint8_t ctl_sms;
  1279. uint8_t ctl_dms;
  1280. uint8_t ctl_src_msize;
  1281. uint8_t ctl_drc_msize;
  1282. uint8_t ctl_sinc;
  1283. uint8_t ctl_dinc;
  1284. uint8_t ctl_src_tr_width;
  1285. uint8_t ctl_dst_tr_width;
  1286. uint8_t ctl_ioc_blktfr;
  1287. uint8_t ctl_src_stat_en;
  1288. uint8_t ctl_dst_stat_en;
  1289. uint8_t cfg_dst_per;
  1290. uint8_t cfg_src_per;
  1291. uint8_t cfg_src_hs_pol;
  1292. uint8_t cfg_dst_hs_pol;
  1293. uint8_t cfg_hs_sel_src;
  1294. uint8_t cfg_hs_sel_dst;
  1295. uint64_t cfg_src_multblk_type;
  1296. uint64_t cfg_dst_multblk_type;
  1297. uint64_t llp_loc;
  1298. uint8_t llp_lms;
  1299. uint64_t ctl_block_ts;
  1300. uint8_t ctl_tt_fc;
  1301. uint8_t cfg_protctl;
  1302. uint8_t cfg_fifo_mode;
  1303. uint8_t cfg_fcmode;
  1304. uint8_t cfg_lock_ch_l;
  1305. uint8_t cfg_ch_prior;
  1306. } dmac_channel_config_t;
  1307. #define LIST_ENTRY(ptr, type, member) \
  1308. ((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))
  1309. struct list_head_t
  1310. {
  1311. struct list_head_t *next, *prev;
  1312. };
  1313. /**
  1314. * @brief Dmac.data/dw_dmac_lli_item
  1315. *
  1316. * @desc This structure is used when creating Linked List Items.
  1317. *
  1318. * @see dw_dmac_addLliItem()
  1319. */
  1320. typedef struct _dmac_lli_item
  1321. {
  1322. uint64_t sar;
  1323. uint64_t dar;
  1324. uint64_t ch_block_ts;
  1325. uint64_t llp;
  1326. uint64_t ctl;
  1327. uint64_t sstat;
  1328. uint64_t dstat;
  1329. uint64_t resv;
  1330. } __attribute__((packed, aligned(64))) dmac_lli_item_t;
  1331. extern volatile dmac_t *const dmac;
  1332. /**
  1333. * @brief Dmac initialize
  1334. */
  1335. void dmac_init(void);
  1336. /**
  1337. * @brief Set dmac param
  1338. *
  1339. * @param[in] channel_num Dmac channel
  1340. * @param[in] src Dmac source
  1341. * @param[in] dest Dmac dest
  1342. * @param[in] src_inc Source address increase or not
  1343. * @param[in] dest_inc Dest address increase or not
  1344. * @param[in] dmac_burst_size Dmac burst length
  1345. * @param[in] dmac_trans_width Dmac transfer data width
  1346. * @param[in] block_size Dmac transfer length
  1347. *
  1348. */
  1349. void dmac_set_single_mode(dmac_channel_number_t channel_num,
  1350. const void *src, void *dest, dmac_address_increment_t src_inc,
  1351. dmac_address_increment_t dest_inc,
  1352. dmac_burst_trans_length_t dmac_burst_size,
  1353. dmac_transfer_width_t dmac_trans_width,
  1354. size_t block_size);
  1355. /**
  1356. * @brief Determine the transfer is complete or not
  1357. *
  1358. * @param[in] channel_num Dmac channel
  1359. *
  1360. * @return result
  1361. * - 0 uncompleted
  1362. * - 1 completed
  1363. */
  1364. int dmac_is_done(dmac_channel_number_t channel_num);
  1365. /**
  1366. * @brief Wait for dmac work done
  1367. *
  1368. * @param[in] channel_num Dmac channel
  1369. *
  1370. */
  1371. void dmac_wait_done(dmac_channel_number_t channel_num);
  1372. /**
  1373. * @brief Determine the dma is idle or not
  1374. *
  1375. * @param[in] channel_num Dmac channel
  1376. *
  1377. * @return result
  1378. * - 0 busy
  1379. * - 1 idel
  1380. */
  1381. int dmac_is_idle(dmac_channel_number_t channel_num);
  1382. /**
  1383. * @brief Wait for dmac idle
  1384. *
  1385. * @param[in] channel_num Dmac channel
  1386. *
  1387. */
  1388. void dmac_wait_idle(dmac_channel_number_t channel_num);
  1389. /**
  1390. * @brief Set interrupt param
  1391. *
  1392. * @param[in] channel_num Dmac channel
  1393. * @param[in] dmac_callback Dmac interrupt callback
  1394. * @param[in] ctx The param of callback
  1395. * @param[in] priority Interrupt priority
  1396. */
  1397. void dmac_set_irq(dmac_channel_number_t channel_num, plic_irq_callback_t dmac_callback, void *ctx, uint32_t priority);
  1398. /**
  1399. * @brief Set interrupt param
  1400. *
  1401. * @param[in] channel_num Dmac channel
  1402. * @param[in] dmac_callback Dmac interrupt callback
  1403. * @param[in] ctx The param of callback
  1404. * @param[in] priority Interrupt priority
  1405. */
  1406. void dmac_irq_register(dmac_channel_number_t channel_num, plic_irq_callback_t dmac_callback, void *ctx, uint32_t priority);
  1407. /**
  1408. * @brief Unregister dmac interrupt
  1409. *
  1410. * @param[in] channel_num Dmac channel
  1411. *
  1412. */
  1413. void dmac_irq_unregister(dmac_channel_number_t channel_num);
  1414. /**
  1415. * @brief Disable dmac interrupt
  1416. *
  1417. * @param[in] channel_num Dmac channel
  1418. *
  1419. */
  1420. void dmac_free_irq(dmac_channel_number_t channel_num);
  1421. /**
  1422. * @brief Set source dest and length
  1423. *
  1424. * @param[in] channel_num Dmac channel
  1425. * @param[in] src Source
  1426. * @param[in] dest Dest
  1427. * @param[in] len The length of dmac transfer
  1428. */
  1429. void dmac_set_src_dest_length(dmac_channel_number_t channel_num, const void *src, void *dest, size_t len);
  1430. /**
  1431. * @brief Disable dmac channel interrupt
  1432. *
  1433. * @param[in] channel_num Dmac channel
  1434. *
  1435. */
  1436. void dmac_disable_channel_interrupt(dmac_channel_number_t channel_num);
  1437. /**
  1438. * @brief Disable dmac channel
  1439. *
  1440. * @param[in] channel_num Dmac channel
  1441. *
  1442. */
  1443. void dmac_channel_disable(dmac_channel_number_t channel_num);
  1444. /**
  1445. * @brief Enable dmac channel
  1446. *
  1447. * @param[in] channel_num Dmac channel
  1448. *
  1449. */
  1450. void dmac_channel_enable(dmac_channel_number_t channel_num);
  1451. #ifdef __cplusplus
  1452. }
  1453. #endif
  1454. #endif /* _DRIVER_DMAC_H */