hpm_femc_regs.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_FEMC_H
  8. #define HPM_FEMC_H
  9. typedef struct {
  10. __RW uint32_t CTRL; /* 0x0: Control Register */
  11. __RW uint32_t IOCTRL; /* 0x4: IO Mux Control Register */
  12. __RW uint32_t BMW0; /* 0x8: Bus (AXI) Weight Control Register 0 */
  13. __RW uint32_t BMW1; /* 0xC: Bus (AXI) Weight Control Register 1 */
  14. __RW uint32_t BR[7]; /* 0x10 - 0x28: Base Register 0 (for SDRAM CS0 device) */
  15. __R uint8_t RESERVED0[12]; /* 0x2C - 0x37: Reserved */
  16. __RW uint32_t INTEN; /* 0x38: Interrupt Enable Register */
  17. __W uint32_t INTR; /* 0x3C: Interrupt Status Register */
  18. __RW uint32_t SDRCTRL0; /* 0x40: SDRAM Control Register 0 */
  19. __RW uint32_t SDRCTRL1; /* 0x44: SDRAM Control Register 1 */
  20. __RW uint32_t SDRCTRL2; /* 0x48: SDRAM Control Register 2 */
  21. __RW uint32_t SDRCTRL3; /* 0x4C: SDRAM Control Register 3 */
  22. __R uint8_t RESERVED1[32]; /* 0x50 - 0x6F: Reserved */
  23. __RW uint32_t SRCTRL0; /* 0x70: SRAM control register 0 */
  24. __RW uint32_t SRCTRL1; /* 0x74: SRAM control register 1 */
  25. __R uint8_t RESERVED2[24]; /* 0x78 - 0x8F: Reserved */
  26. __RW uint32_t SADDR; /* 0x90: IP Command Control Register 0 */
  27. __RW uint32_t DATSZ; /* 0x94: IP Command Control Register 1 */
  28. __RW uint32_t BYTEMSK; /* 0x98: IP Command Control Register 2 */
  29. __RW uint32_t IPCMD; /* 0x9C: IP Command Register */
  30. __RW uint32_t IPTX; /* 0xA0: TX DATA Register */
  31. __R uint8_t RESERVED3[12]; /* 0xA4 - 0xAF: Reserved */
  32. __RW uint32_t IPRX; /* 0xB0: RX DATA Register */
  33. __R uint8_t RESERVED4[12]; /* 0xB4 - 0xBF: Reserved */
  34. __R uint32_t STAT0; /* 0xC0: Status Register 0 */
  35. __R uint8_t RESERVED5[140]; /* 0xC4 - 0x14F: Reserved */
  36. __RW uint32_t DLYCFG; /* 0x150: Delay Line Config Register */
  37. } FEMC_Type;
  38. /* Bitfield definition for register: CTRL */
  39. /*
  40. * BTO (RW)
  41. *
  42. * Bus timeout cycles
  43. * AXI Bus timeout cycle is as following (255*(2^BTO)):
  44. * 00000b - 255*1
  45. * 00001-11110b - 255*2 - 255*2^30
  46. * 11111b - 255*2^31
  47. */
  48. #define FEMC_CTRL_BTO_MASK (0x1F000000UL)
  49. #define FEMC_CTRL_BTO_SHIFT (24U)
  50. #define FEMC_CTRL_BTO_SET(x) (((uint32_t)(x) << FEMC_CTRL_BTO_SHIFT) & FEMC_CTRL_BTO_MASK)
  51. #define FEMC_CTRL_BTO_GET(x) (((uint32_t)(x) & FEMC_CTRL_BTO_MASK) >> FEMC_CTRL_BTO_SHIFT)
  52. /*
  53. * CTO (RW)
  54. *
  55. * Command Execution timeout cycles
  56. * When Command Execution time exceed this timeout cycles, IPCMDERR or AXICMDERR interrupt is
  57. * generated. When CTO is set to zero, timeout cycle is 256*1024 cycle. otherwisee timeout cycle is
  58. * CTO*1024 cycle.
  59. */
  60. #define FEMC_CTRL_CTO_MASK (0xFF0000UL)
  61. #define FEMC_CTRL_CTO_SHIFT (16U)
  62. #define FEMC_CTRL_CTO_SET(x) (((uint32_t)(x) << FEMC_CTRL_CTO_SHIFT) & FEMC_CTRL_CTO_MASK)
  63. #define FEMC_CTRL_CTO_GET(x) (((uint32_t)(x) & FEMC_CTRL_CTO_MASK) >> FEMC_CTRL_CTO_SHIFT)
  64. /*
  65. * DQS (RW)
  66. *
  67. * DQS (read strobe) mode
  68. * 0b - Dummy read strobe loopbacked internally
  69. * 1b - Dummy read strobe loopbacked from DQS pad
  70. */
  71. #define FEMC_CTRL_DQS_MASK (0x4U)
  72. #define FEMC_CTRL_DQS_SHIFT (2U)
  73. #define FEMC_CTRL_DQS_SET(x) (((uint32_t)(x) << FEMC_CTRL_DQS_SHIFT) & FEMC_CTRL_DQS_MASK)
  74. #define FEMC_CTRL_DQS_GET(x) (((uint32_t)(x) & FEMC_CTRL_DQS_MASK) >> FEMC_CTRL_DQS_SHIFT)
  75. /*
  76. * DIS (RW)
  77. *
  78. * Module Disable
  79. * 0b - Module enabled
  80. * 1b - Module disabled
  81. */
  82. #define FEMC_CTRL_DIS_MASK (0x2U)
  83. #define FEMC_CTRL_DIS_SHIFT (1U)
  84. #define FEMC_CTRL_DIS_SET(x) (((uint32_t)(x) << FEMC_CTRL_DIS_SHIFT) & FEMC_CTRL_DIS_MASK)
  85. #define FEMC_CTRL_DIS_GET(x) (((uint32_t)(x) & FEMC_CTRL_DIS_MASK) >> FEMC_CTRL_DIS_SHIFT)
  86. /*
  87. * RST (RW)
  88. *
  89. * Software Reset
  90. * Reset all internal logic in SEMC except configuration register
  91. */
  92. #define FEMC_CTRL_RST_MASK (0x1U)
  93. #define FEMC_CTRL_RST_SHIFT (0U)
  94. #define FEMC_CTRL_RST_SET(x) (((uint32_t)(x) << FEMC_CTRL_RST_SHIFT) & FEMC_CTRL_RST_MASK)
  95. #define FEMC_CTRL_RST_GET(x) (((uint32_t)(x) & FEMC_CTRL_RST_MASK) >> FEMC_CTRL_RST_SHIFT)
  96. /* Bitfield definition for register: IOCTRL */
  97. /*
  98. * IO_CSX (RW)
  99. *
  100. * IO_CSX output selection
  101. * 0001b - SDRAM CS1
  102. * 0110b - SRAM CE#
  103. */
  104. #define FEMC_IOCTRL_IO_CSX_MASK (0xF0U)
  105. #define FEMC_IOCTRL_IO_CSX_SHIFT (4U)
  106. #define FEMC_IOCTRL_IO_CSX_SET(x) (((uint32_t)(x) << FEMC_IOCTRL_IO_CSX_SHIFT) & FEMC_IOCTRL_IO_CSX_MASK)
  107. #define FEMC_IOCTRL_IO_CSX_GET(x) (((uint32_t)(x) & FEMC_IOCTRL_IO_CSX_MASK) >> FEMC_IOCTRL_IO_CSX_SHIFT)
  108. /* Bitfield definition for register: BMW0 */
  109. /*
  110. * RWS (RW)
  111. *
  112. * Weight of slave hit with Read/Write Switch. This weight score is valid when queue command's slave is
  113. * same as current executing command with read/write operation switch.
  114. */
  115. #define FEMC_BMW0_RWS_MASK (0xFF0000UL)
  116. #define FEMC_BMW0_RWS_SHIFT (16U)
  117. #define FEMC_BMW0_RWS_SET(x) (((uint32_t)(x) << FEMC_BMW0_RWS_SHIFT) & FEMC_BMW0_RWS_MASK)
  118. #define FEMC_BMW0_RWS_GET(x) (((uint32_t)(x) & FEMC_BMW0_RWS_MASK) >> FEMC_BMW0_RWS_SHIFT)
  119. /*
  120. * SH (RW)
  121. *
  122. * Weight of Slave Hit without read/write switch. This weight score is valid when queue command's slave is
  123. * same as current executing command without read/write operation switch.
  124. */
  125. #define FEMC_BMW0_SH_MASK (0xFF00U)
  126. #define FEMC_BMW0_SH_SHIFT (8U)
  127. #define FEMC_BMW0_SH_SET(x) (((uint32_t)(x) << FEMC_BMW0_SH_SHIFT) & FEMC_BMW0_SH_MASK)
  128. #define FEMC_BMW0_SH_GET(x) (((uint32_t)(x) & FEMC_BMW0_SH_MASK) >> FEMC_BMW0_SH_SHIFT)
  129. /*
  130. * AGE (RW)
  131. *
  132. * Weight of AGE calculation. Each command in queue has an age signal to indicate its wait period. It is
  133. * multiplied by WAGE to get weight score.
  134. */
  135. #define FEMC_BMW0_AGE_MASK (0xF0U)
  136. #define FEMC_BMW0_AGE_SHIFT (4U)
  137. #define FEMC_BMW0_AGE_SET(x) (((uint32_t)(x) << FEMC_BMW0_AGE_SHIFT) & FEMC_BMW0_AGE_MASK)
  138. #define FEMC_BMW0_AGE_GET(x) (((uint32_t)(x) & FEMC_BMW0_AGE_MASK) >> FEMC_BMW0_AGE_SHIFT)
  139. /*
  140. * QOS (RW)
  141. *
  142. * Weight of QOS calculation. AXI bus access has AxQOS signal set, which is used as a priority indicator
  143. * for the associated write or read transaction. A higher value indicates a higher priority transaction. AxQOS
  144. * is multiplied by WQOS to get weight score.
  145. */
  146. #define FEMC_BMW0_QOS_MASK (0xFU)
  147. #define FEMC_BMW0_QOS_SHIFT (0U)
  148. #define FEMC_BMW0_QOS_SET(x) (((uint32_t)(x) << FEMC_BMW0_QOS_SHIFT) & FEMC_BMW0_QOS_MASK)
  149. #define FEMC_BMW0_QOS_GET(x) (((uint32_t)(x) & FEMC_BMW0_QOS_MASK) >> FEMC_BMW0_QOS_SHIFT)
  150. /* Bitfield definition for register: BMW1 */
  151. /*
  152. * BR (RW)
  153. *
  154. * Weight of Bank Rotation. This weight score is valid when queue command's bank is not same as current
  155. * executing command.
  156. */
  157. #define FEMC_BMW1_BR_MASK (0xFF000000UL)
  158. #define FEMC_BMW1_BR_SHIFT (24U)
  159. #define FEMC_BMW1_BR_SET(x) (((uint32_t)(x) << FEMC_BMW1_BR_SHIFT) & FEMC_BMW1_BR_MASK)
  160. #define FEMC_BMW1_BR_GET(x) (((uint32_t)(x) & FEMC_BMW1_BR_MASK) >> FEMC_BMW1_BR_SHIFT)
  161. /*
  162. * RWS (RW)
  163. *
  164. * Weight of slave hit with Read/Write Switch. This weight score is valid when queue command's slave is
  165. * same as current executing command with read/write operation switch.
  166. */
  167. #define FEMC_BMW1_RWS_MASK (0xFF0000UL)
  168. #define FEMC_BMW1_RWS_SHIFT (16U)
  169. #define FEMC_BMW1_RWS_SET(x) (((uint32_t)(x) << FEMC_BMW1_RWS_SHIFT) & FEMC_BMW1_RWS_MASK)
  170. #define FEMC_BMW1_RWS_GET(x) (((uint32_t)(x) & FEMC_BMW1_RWS_MASK) >> FEMC_BMW1_RWS_SHIFT)
  171. /*
  172. * PH (RW)
  173. *
  174. * Weight of Slave Hit without read/write switch. This weight score is valid when queue command's slave is
  175. * same as current executing command without read/write operation switch.
  176. */
  177. #define FEMC_BMW1_PH_MASK (0xFF00U)
  178. #define FEMC_BMW1_PH_SHIFT (8U)
  179. #define FEMC_BMW1_PH_SET(x) (((uint32_t)(x) << FEMC_BMW1_PH_SHIFT) & FEMC_BMW1_PH_MASK)
  180. #define FEMC_BMW1_PH_GET(x) (((uint32_t)(x) & FEMC_BMW1_PH_MASK) >> FEMC_BMW1_PH_SHIFT)
  181. /*
  182. * AGE (RW)
  183. *
  184. * Weight of AGE calculation. Each command in queue has an age signal to indicate its wait period. It is
  185. * multiplied by WAGE to get weight score.
  186. */
  187. #define FEMC_BMW1_AGE_MASK (0xF0U)
  188. #define FEMC_BMW1_AGE_SHIFT (4U)
  189. #define FEMC_BMW1_AGE_SET(x) (((uint32_t)(x) << FEMC_BMW1_AGE_SHIFT) & FEMC_BMW1_AGE_MASK)
  190. #define FEMC_BMW1_AGE_GET(x) (((uint32_t)(x) & FEMC_BMW1_AGE_MASK) >> FEMC_BMW1_AGE_SHIFT)
  191. /*
  192. * QOS (RW)
  193. *
  194. * Weight of QOS calculation. AXI bus access has AxQOS signal set, which is used as a priority indicator
  195. * for the associated write or read transaction. A higher value indicates a higher priority transaction. AxQOS
  196. * is multiplied by WQOS to get weight score.
  197. */
  198. #define FEMC_BMW1_QOS_MASK (0xFU)
  199. #define FEMC_BMW1_QOS_SHIFT (0U)
  200. #define FEMC_BMW1_QOS_SET(x) (((uint32_t)(x) << FEMC_BMW1_QOS_SHIFT) & FEMC_BMW1_QOS_MASK)
  201. #define FEMC_BMW1_QOS_GET(x) (((uint32_t)(x) & FEMC_BMW1_QOS_MASK) >> FEMC_BMW1_QOS_SHIFT)
  202. /* Bitfield definition for register array: BR */
  203. /*
  204. * BASE (RW)
  205. *
  206. * Base Address
  207. * This field determines high position 20 bits of SoC level Base Address. SoC level Base Address low
  208. * position 12 bits are all zero.
  209. */
  210. #define FEMC_BR_BASE_MASK (0xFFFFF000UL)
  211. #define FEMC_BR_BASE_SHIFT (12U)
  212. #define FEMC_BR_BASE_SET(x) (((uint32_t)(x) << FEMC_BR_BASE_SHIFT) & FEMC_BR_BASE_MASK)
  213. #define FEMC_BR_BASE_GET(x) (((uint32_t)(x) & FEMC_BR_BASE_MASK) >> FEMC_BR_BASE_SHIFT)
  214. /*
  215. * SIZE (RW)
  216. *
  217. * Memory size
  218. * 00000b - 4KB
  219. * 00001b - 8KB
  220. * 00010b - 16KB
  221. * 00011b - 32KB
  222. * 00100b - 64KB
  223. * 00101b - 128KB
  224. * 00110b - 256KB
  225. * 00111b - 512KB
  226. * 01000b - 1MB
  227. * 01001b - 2MB
  228. * 01010b - 4MB
  229. * 01011b - 8MB
  230. * 01100b - 16MB
  231. * 01101b - 32MB
  232. * 01110b - 64MB
  233. * 01111b - 128MB
  234. * 10000b - 256MB
  235. * 10001b - 512MB
  236. * 10010b - 1GB
  237. * 10011b - 2GB
  238. * 10100-11111b - 4GB
  239. */
  240. #define FEMC_BR_SIZE_MASK (0x3EU)
  241. #define FEMC_BR_SIZE_SHIFT (1U)
  242. #define FEMC_BR_SIZE_SET(x) (((uint32_t)(x) << FEMC_BR_SIZE_SHIFT) & FEMC_BR_SIZE_MASK)
  243. #define FEMC_BR_SIZE_GET(x) (((uint32_t)(x) & FEMC_BR_SIZE_MASK) >> FEMC_BR_SIZE_SHIFT)
  244. /*
  245. * VLD (RW)
  246. *
  247. * Valid
  248. */
  249. #define FEMC_BR_VLD_MASK (0x1U)
  250. #define FEMC_BR_VLD_SHIFT (0U)
  251. #define FEMC_BR_VLD_SET(x) (((uint32_t)(x) << FEMC_BR_VLD_SHIFT) & FEMC_BR_VLD_MASK)
  252. #define FEMC_BR_VLD_GET(x) (((uint32_t)(x) & FEMC_BR_VLD_MASK) >> FEMC_BR_VLD_SHIFT)
  253. /* Bitfield definition for register: INTEN */
  254. /*
  255. * AXIBUSERR (RW)
  256. *
  257. * AXI BUS error interrupt enable
  258. * 0b - Interrupt is disabled
  259. * 1b - Interrupt is enabled
  260. */
  261. #define FEMC_INTEN_AXIBUSERR_MASK (0x8U)
  262. #define FEMC_INTEN_AXIBUSERR_SHIFT (3U)
  263. #define FEMC_INTEN_AXIBUSERR_SET(x) (((uint32_t)(x) << FEMC_INTEN_AXIBUSERR_SHIFT) & FEMC_INTEN_AXIBUSERR_MASK)
  264. #define FEMC_INTEN_AXIBUSERR_GET(x) (((uint32_t)(x) & FEMC_INTEN_AXIBUSERR_MASK) >> FEMC_INTEN_AXIBUSERR_SHIFT)
  265. /*
  266. * AXICMDERR (RW)
  267. *
  268. * AXI command error interrupt enable
  269. * 0b - Interrupt is disabled
  270. * 1b - Interrupt is enabled
  271. */
  272. #define FEMC_INTEN_AXICMDERR_MASK (0x4U)
  273. #define FEMC_INTEN_AXICMDERR_SHIFT (2U)
  274. #define FEMC_INTEN_AXICMDERR_SET(x) (((uint32_t)(x) << FEMC_INTEN_AXICMDERR_SHIFT) & FEMC_INTEN_AXICMDERR_MASK)
  275. #define FEMC_INTEN_AXICMDERR_GET(x) (((uint32_t)(x) & FEMC_INTEN_AXICMDERR_MASK) >> FEMC_INTEN_AXICMDERR_SHIFT)
  276. /*
  277. * IPCMDERR (RW)
  278. *
  279. * IP command error interrupt enable
  280. * 0b - Interrupt is disabled
  281. * 1b - Interrupt is enabled
  282. */
  283. #define FEMC_INTEN_IPCMDERR_MASK (0x2U)
  284. #define FEMC_INTEN_IPCMDERR_SHIFT (1U)
  285. #define FEMC_INTEN_IPCMDERR_SET(x) (((uint32_t)(x) << FEMC_INTEN_IPCMDERR_SHIFT) & FEMC_INTEN_IPCMDERR_MASK)
  286. #define FEMC_INTEN_IPCMDERR_GET(x) (((uint32_t)(x) & FEMC_INTEN_IPCMDERR_MASK) >> FEMC_INTEN_IPCMDERR_SHIFT)
  287. /*
  288. * IPCMDDONE (RW)
  289. *
  290. * IP command done interrupt enable
  291. * 0b - Interrupt is disabled
  292. * 1b - Interrupt is enabled
  293. */
  294. #define FEMC_INTEN_IPCMDDONE_MASK (0x1U)
  295. #define FEMC_INTEN_IPCMDDONE_SHIFT (0U)
  296. #define FEMC_INTEN_IPCMDDONE_SET(x) (((uint32_t)(x) << FEMC_INTEN_IPCMDDONE_SHIFT) & FEMC_INTEN_IPCMDDONE_MASK)
  297. #define FEMC_INTEN_IPCMDDONE_GET(x) (((uint32_t)(x) & FEMC_INTEN_IPCMDDONE_MASK) >> FEMC_INTEN_IPCMDDONE_SHIFT)
  298. /* Bitfield definition for register: INTR */
  299. /*
  300. * AXIBUSERR (W1C)
  301. *
  302. * AXI bus error interrupt
  303. * AXI Bus error interrupt is generated in following cases:
  304. * • AXI address is invalid
  305. * • AXI 8-bit or 16-bit WRAP write/read
  306. */
  307. #define FEMC_INTR_AXIBUSERR_MASK (0x8U)
  308. #define FEMC_INTR_AXIBUSERR_SHIFT (3U)
  309. #define FEMC_INTR_AXIBUSERR_SET(x) (((uint32_t)(x) << FEMC_INTR_AXIBUSERR_SHIFT) & FEMC_INTR_AXIBUSERR_MASK)
  310. #define FEMC_INTR_AXIBUSERR_GET(x) (((uint32_t)(x) & FEMC_INTR_AXIBUSERR_MASK) >> FEMC_INTR_AXIBUSERR_SHIFT)
  311. /*
  312. * AXICMDERR (W1C)
  313. *
  314. * AXI command error interrupt
  315. * AXI command error interrupt is generated when AXI command execution timeout.
  316. */
  317. #define FEMC_INTR_AXICMDERR_MASK (0x4U)
  318. #define FEMC_INTR_AXICMDERR_SHIFT (2U)
  319. #define FEMC_INTR_AXICMDERR_SET(x) (((uint32_t)(x) << FEMC_INTR_AXICMDERR_SHIFT) & FEMC_INTR_AXICMDERR_MASK)
  320. #define FEMC_INTR_AXICMDERR_GET(x) (((uint32_t)(x) & FEMC_INTR_AXICMDERR_MASK) >> FEMC_INTR_AXICMDERR_SHIFT)
  321. /*
  322. * IPCMDERR (W1C)
  323. *
  324. * IP command error done interrupt
  325. * IP command error interrupt is generated in following case:
  326. * • IP Command Address target invalid device space
  327. * • IP Command Code unsupported
  328. * • IP Command triggered when previous command
  329. */
  330. #define FEMC_INTR_IPCMDERR_MASK (0x2U)
  331. #define FEMC_INTR_IPCMDERR_SHIFT (1U)
  332. #define FEMC_INTR_IPCMDERR_SET(x) (((uint32_t)(x) << FEMC_INTR_IPCMDERR_SHIFT) & FEMC_INTR_IPCMDERR_MASK)
  333. #define FEMC_INTR_IPCMDERR_GET(x) (((uint32_t)(x) & FEMC_INTR_IPCMDERR_MASK) >> FEMC_INTR_IPCMDERR_SHIFT)
  334. /*
  335. * IPCMDDONE (W1C)
  336. *
  337. * IP command normal done interrupt
  338. */
  339. #define FEMC_INTR_IPCMDDONE_MASK (0x1U)
  340. #define FEMC_INTR_IPCMDDONE_SHIFT (0U)
  341. #define FEMC_INTR_IPCMDDONE_SET(x) (((uint32_t)(x) << FEMC_INTR_IPCMDDONE_SHIFT) & FEMC_INTR_IPCMDDONE_MASK)
  342. #define FEMC_INTR_IPCMDDONE_GET(x) (((uint32_t)(x) & FEMC_INTR_IPCMDDONE_MASK) >> FEMC_INTR_IPCMDDONE_SHIFT)
  343. /* Bitfield definition for register: SDRCTRL0 */
  344. /*
  345. * BANK2 (RW)
  346. *
  347. * 2 Bank selection bit
  348. * 0b - SDRAM device has 4 banks.
  349. * 1b - SDRAM device has 2 banks.
  350. */
  351. #define FEMC_SDRCTRL0_BANK2_MASK (0x4000U)
  352. #define FEMC_SDRCTRL0_BANK2_SHIFT (14U)
  353. #define FEMC_SDRCTRL0_BANK2_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_BANK2_SHIFT) & FEMC_SDRCTRL0_BANK2_MASK)
  354. #define FEMC_SDRCTRL0_BANK2_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_BANK2_MASK) >> FEMC_SDRCTRL0_BANK2_SHIFT)
  355. /*
  356. * CAS (RW)
  357. *
  358. * CAS Latency
  359. * 00b - 1
  360. * 01b - 1
  361. * 10b - 2
  362. * 11b - 3
  363. */
  364. #define FEMC_SDRCTRL0_CAS_MASK (0xC00U)
  365. #define FEMC_SDRCTRL0_CAS_SHIFT (10U)
  366. #define FEMC_SDRCTRL0_CAS_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_CAS_SHIFT) & FEMC_SDRCTRL0_CAS_MASK)
  367. #define FEMC_SDRCTRL0_CAS_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_CAS_MASK) >> FEMC_SDRCTRL0_CAS_SHIFT)
  368. /*
  369. * COL (RW)
  370. *
  371. * Column address bit number
  372. * 00b - 12 bit
  373. * 01b - 11 bit
  374. * 10b - 10 bit
  375. * 11b - 9 bit
  376. */
  377. #define FEMC_SDRCTRL0_COL_MASK (0x300U)
  378. #define FEMC_SDRCTRL0_COL_SHIFT (8U)
  379. #define FEMC_SDRCTRL0_COL_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_COL_SHIFT) & FEMC_SDRCTRL0_COL_MASK)
  380. #define FEMC_SDRCTRL0_COL_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_COL_MASK) >> FEMC_SDRCTRL0_COL_SHIFT)
  381. /*
  382. * COL8 (RW)
  383. *
  384. * Column 8 selection bit
  385. * 0b - Column address bit number is decided by COL field.
  386. * 1b - Column address bit number is 8. COL field is ignored.
  387. */
  388. #define FEMC_SDRCTRL0_COL8_MASK (0x80U)
  389. #define FEMC_SDRCTRL0_COL8_SHIFT (7U)
  390. #define FEMC_SDRCTRL0_COL8_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_COL8_SHIFT) & FEMC_SDRCTRL0_COL8_MASK)
  391. #define FEMC_SDRCTRL0_COL8_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_COL8_MASK) >> FEMC_SDRCTRL0_COL8_SHIFT)
  392. /*
  393. * BURSTLEN (RW)
  394. *
  395. * Burst Length
  396. * 000b - 1
  397. * 001b - 2
  398. * 010b - 4
  399. * 011b - 8
  400. * 100b - 8
  401. * 101b - 8
  402. * 110b - 8
  403. * 111b - 8
  404. */
  405. #define FEMC_SDRCTRL0_BURSTLEN_MASK (0x70U)
  406. #define FEMC_SDRCTRL0_BURSTLEN_SHIFT (4U)
  407. #define FEMC_SDRCTRL0_BURSTLEN_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_BURSTLEN_SHIFT) & FEMC_SDRCTRL0_BURSTLEN_MASK)
  408. #define FEMC_SDRCTRL0_BURSTLEN_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_BURSTLEN_MASK) >> FEMC_SDRCTRL0_BURSTLEN_SHIFT)
  409. /*
  410. * HIGHBAND (RW)
  411. *
  412. * high band select
  413. * 0: use data[15:0] for 16bit SDRAM;
  414. * 1: use data[31:16] for 16bit SDRAM;
  415. * only used when Port Size is 16bit(PORTSZ=01b)
  416. */
  417. #define FEMC_SDRCTRL0_HIGHBAND_MASK (0x8U)
  418. #define FEMC_SDRCTRL0_HIGHBAND_SHIFT (3U)
  419. #define FEMC_SDRCTRL0_HIGHBAND_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_HIGHBAND_SHIFT) & FEMC_SDRCTRL0_HIGHBAND_MASK)
  420. #define FEMC_SDRCTRL0_HIGHBAND_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_HIGHBAND_MASK) >> FEMC_SDRCTRL0_HIGHBAND_SHIFT)
  421. /*
  422. * PORTSZ (RW)
  423. *
  424. * Port Size
  425. * 00b - 8bit
  426. * 01b - 16bit
  427. * 10b - 32bit
  428. */
  429. #define FEMC_SDRCTRL0_PORTSZ_MASK (0x3U)
  430. #define FEMC_SDRCTRL0_PORTSZ_SHIFT (0U)
  431. #define FEMC_SDRCTRL0_PORTSZ_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL0_PORTSZ_SHIFT) & FEMC_SDRCTRL0_PORTSZ_MASK)
  432. #define FEMC_SDRCTRL0_PORTSZ_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL0_PORTSZ_MASK) >> FEMC_SDRCTRL0_PORTSZ_SHIFT)
  433. /* Bitfield definition for register: SDRCTRL1 */
  434. /*
  435. * ACT2PRE (RW)
  436. *
  437. * ACT to Precharge minimum time
  438. * It is promised ACT2PRE+1 clock cycles delay between ACTIVE command to PRECHARGE/PRECHARGE_ALL command.
  439. */
  440. #define FEMC_SDRCTRL1_ACT2PRE_MASK (0xF00000UL)
  441. #define FEMC_SDRCTRL1_ACT2PRE_SHIFT (20U)
  442. #define FEMC_SDRCTRL1_ACT2PRE_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL1_ACT2PRE_SHIFT) & FEMC_SDRCTRL1_ACT2PRE_MASK)
  443. #define FEMC_SDRCTRL1_ACT2PRE_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL1_ACT2PRE_MASK) >> FEMC_SDRCTRL1_ACT2PRE_SHIFT)
  444. /*
  445. * CKEOFF (RW)
  446. *
  447. * CKE OFF minimum time
  448. * It is promised clock suspend last at leat CKEOFF+1 clock cycles.
  449. */
  450. #define FEMC_SDRCTRL1_CKEOFF_MASK (0xF0000UL)
  451. #define FEMC_SDRCTRL1_CKEOFF_SHIFT (16U)
  452. #define FEMC_SDRCTRL1_CKEOFF_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL1_CKEOFF_SHIFT) & FEMC_SDRCTRL1_CKEOFF_MASK)
  453. #define FEMC_SDRCTRL1_CKEOFF_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL1_CKEOFF_MASK) >> FEMC_SDRCTRL1_CKEOFF_SHIFT)
  454. /*
  455. * WRC (RW)
  456. *
  457. * Write recovery time
  458. * It is promised WRC+1 clock cycles delay between WRITE command to PRECHARGE/PRECHARGE_ALL command. This could help to meet tWR timing requirement by SDRAM device.
  459. */
  460. #define FEMC_SDRCTRL1_WRC_MASK (0xE000U)
  461. #define FEMC_SDRCTRL1_WRC_SHIFT (13U)
  462. #define FEMC_SDRCTRL1_WRC_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL1_WRC_SHIFT) & FEMC_SDRCTRL1_WRC_MASK)
  463. #define FEMC_SDRCTRL1_WRC_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL1_WRC_MASK) >> FEMC_SDRCTRL1_WRC_SHIFT)
  464. /*
  465. * RFRC (RW)
  466. *
  467. * Refresh recovery time
  468. * It is promised RFRC+1 clock cycles delay between REFRESH command to ACTIVE command. Thiscould help to meet tRFC timing requirement by SDRAM device.
  469. */
  470. #define FEMC_SDRCTRL1_RFRC_MASK (0x1F00U)
  471. #define FEMC_SDRCTRL1_RFRC_SHIFT (8U)
  472. #define FEMC_SDRCTRL1_RFRC_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL1_RFRC_SHIFT) & FEMC_SDRCTRL1_RFRC_MASK)
  473. #define FEMC_SDRCTRL1_RFRC_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL1_RFRC_MASK) >> FEMC_SDRCTRL1_RFRC_SHIFT)
  474. /*
  475. * ACT2RW (RW)
  476. *
  477. * ACT to Read/Write wait time
  478. * It is promised ACT2RW+1 clock cycles delay between ACTIVE command to READ/WRITE command.This could help to meet tRCD timing requirement by SDRAM device.
  479. */
  480. #define FEMC_SDRCTRL1_ACT2RW_MASK (0xF0U)
  481. #define FEMC_SDRCTRL1_ACT2RW_SHIFT (4U)
  482. #define FEMC_SDRCTRL1_ACT2RW_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL1_ACT2RW_SHIFT) & FEMC_SDRCTRL1_ACT2RW_MASK)
  483. #define FEMC_SDRCTRL1_ACT2RW_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL1_ACT2RW_MASK) >> FEMC_SDRCTRL1_ACT2RW_SHIFT)
  484. /*
  485. * PRE2ACT (RW)
  486. *
  487. * PRECHARGE to ACT/Refresh wait time
  488. * It is promised PRE2ACT+1 clock cycles delay between PRECHARGE/PRECHARGE_ALL commandto ACTIVE/REFRESH command. This could help to meet tRP timing requirement by SDRAM device.
  489. */
  490. #define FEMC_SDRCTRL1_PRE2ACT_MASK (0xFU)
  491. #define FEMC_SDRCTRL1_PRE2ACT_SHIFT (0U)
  492. #define FEMC_SDRCTRL1_PRE2ACT_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL1_PRE2ACT_SHIFT) & FEMC_SDRCTRL1_PRE2ACT_MASK)
  493. #define FEMC_SDRCTRL1_PRE2ACT_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL1_PRE2ACT_MASK) >> FEMC_SDRCTRL1_PRE2ACT_SHIFT)
  494. /* Bitfield definition for register: SDRCTRL2 */
  495. /*
  496. * ITO (RW)
  497. *
  498. * SDRAM Idle timeout
  499. * It closes all opened pages if the SDRAM idle time lasts more than idle timeout period. SDRAM is
  500. * considered idle when there is no AXI Bus transfer and no SDRAM command pending.
  501. * 00000000b - IDLE timeout period is 256*Prescale period.
  502. * 00000001-11111111b - IDLE timeout period is ITO*Prescale period.
  503. */
  504. #define FEMC_SDRCTRL2_ITO_MASK (0xFF000000UL)
  505. #define FEMC_SDRCTRL2_ITO_SHIFT (24U)
  506. #define FEMC_SDRCTRL2_ITO_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL2_ITO_SHIFT) & FEMC_SDRCTRL2_ITO_MASK)
  507. #define FEMC_SDRCTRL2_ITO_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL2_ITO_MASK) >> FEMC_SDRCTRL2_ITO_SHIFT)
  508. /*
  509. * ACT2ACT (RW)
  510. *
  511. * ACT to ACT wait time
  512. * It is promised ACT2ACT+1 clock cycles delay between ACTIVE command to ACTIVE command. This
  513. * could help to meet tRRD timing requirement by SDRAM device.
  514. */
  515. #define FEMC_SDRCTRL2_ACT2ACT_MASK (0xFF0000UL)
  516. #define FEMC_SDRCTRL2_ACT2ACT_SHIFT (16U)
  517. #define FEMC_SDRCTRL2_ACT2ACT_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL2_ACT2ACT_SHIFT) & FEMC_SDRCTRL2_ACT2ACT_MASK)
  518. #define FEMC_SDRCTRL2_ACT2ACT_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL2_ACT2ACT_MASK) >> FEMC_SDRCTRL2_ACT2ACT_SHIFT)
  519. /*
  520. * REF2REF (RW)
  521. *
  522. * Refresh to Refresh wait time
  523. * It is promised REF2REF+1 clock cycles delay between REFRESH command to REFRESH command.
  524. * This could help to meet tRFC timing requirement by SDRAM device.
  525. */
  526. #define FEMC_SDRCTRL2_REF2REF_MASK (0xFF00U)
  527. #define FEMC_SDRCTRL2_REF2REF_SHIFT (8U)
  528. #define FEMC_SDRCTRL2_REF2REF_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL2_REF2REF_SHIFT) & FEMC_SDRCTRL2_REF2REF_MASK)
  529. #define FEMC_SDRCTRL2_REF2REF_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL2_REF2REF_MASK) >> FEMC_SDRCTRL2_REF2REF_SHIFT)
  530. /*
  531. * SRRC (RW)
  532. *
  533. * Self Refresh Recovery time
  534. * It is promised SRRC+1 clock cycles delay between Self-REFRESH command to any command.
  535. */
  536. #define FEMC_SDRCTRL2_SRRC_MASK (0xFFU)
  537. #define FEMC_SDRCTRL2_SRRC_SHIFT (0U)
  538. #define FEMC_SDRCTRL2_SRRC_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL2_SRRC_SHIFT) & FEMC_SDRCTRL2_SRRC_MASK)
  539. #define FEMC_SDRCTRL2_SRRC_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL2_SRRC_MASK) >> FEMC_SDRCTRL2_SRRC_SHIFT)
  540. /* Bitfield definition for register: SDRCTRL3 */
  541. /*
  542. * UT (RW)
  543. *
  544. * Refresh urgent threshold
  545. * Internal refresh request is generated on every Refresh period. Before internal request timer count up to
  546. * urgent request threshold, the refresh request is considered as normal refresh request. Normal refresh
  547. * request is handled in lower priority than any pending AXI command or IP command to SDRAM device.
  548. * When internal request timer count up to this urgent threshold, refresh request is considered as urgent
  549. * refresh request. Urgent refresh request is handled in higher priority than any pending AXI command or IP
  550. * command to SDRAM device.
  551. * NOTE: When urgent threshold is no less than refresh period, refresh request is always considered as
  552. * urgent refresh request.
  553. * Refresh urgent threshold is as follwoing:
  554. * 00000000b - 256*Prescaler period
  555. * 00000001-11111111b - UT*Prescaler period
  556. */
  557. #define FEMC_SDRCTRL3_UT_MASK (0xFF000000UL)
  558. #define FEMC_SDRCTRL3_UT_SHIFT (24U)
  559. #define FEMC_SDRCTRL3_UT_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL3_UT_SHIFT) & FEMC_SDRCTRL3_UT_MASK)
  560. #define FEMC_SDRCTRL3_UT_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL3_UT_MASK) >> FEMC_SDRCTRL3_UT_SHIFT)
  561. /*
  562. * RT (RW)
  563. *
  564. * Refresh timer period
  565. * Refresh timer period is as following:
  566. * 00000000b - 256*Prescaler period
  567. * 00000001-11111111b - RT*Prescaler period
  568. */
  569. #define FEMC_SDRCTRL3_RT_MASK (0xFF0000UL)
  570. #define FEMC_SDRCTRL3_RT_SHIFT (16U)
  571. #define FEMC_SDRCTRL3_RT_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL3_RT_SHIFT) & FEMC_SDRCTRL3_RT_MASK)
  572. #define FEMC_SDRCTRL3_RT_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL3_RT_MASK) >> FEMC_SDRCTRL3_RT_SHIFT)
  573. /*
  574. * PRESCALE (RW)
  575. *
  576. * Prescaler timer period
  577. * Prescaler timer period is as following:
  578. * 00000000b - 256*16 clock cycles
  579. * 00000001-11111111b - PRESCALE*16 clock cycles
  580. */
  581. #define FEMC_SDRCTRL3_PRESCALE_MASK (0xFF00U)
  582. #define FEMC_SDRCTRL3_PRESCALE_SHIFT (8U)
  583. #define FEMC_SDRCTRL3_PRESCALE_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL3_PRESCALE_SHIFT) & FEMC_SDRCTRL3_PRESCALE_MASK)
  584. #define FEMC_SDRCTRL3_PRESCALE_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL3_PRESCALE_MASK) >> FEMC_SDRCTRL3_PRESCALE_SHIFT)
  585. /*
  586. * REBL (RW)
  587. *
  588. * Refresh burst length
  589. * It could send multiple Auto-Refresh command in one burst when REBL is set to non-zero. The
  590. * number of Auto-Refresh command cycle sent to all SDRAM device in one refresh period is as following.
  591. * 000b - 1
  592. * 001b - 2
  593. * 010b - 3
  594. * 011b - 4
  595. * 100b - 5
  596. * 101b - 6
  597. * 110b - 7
  598. * 111b - 8
  599. */
  600. #define FEMC_SDRCTRL3_REBL_MASK (0xEU)
  601. #define FEMC_SDRCTRL3_REBL_SHIFT (1U)
  602. #define FEMC_SDRCTRL3_REBL_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL3_REBL_SHIFT) & FEMC_SDRCTRL3_REBL_MASK)
  603. #define FEMC_SDRCTRL3_REBL_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL3_REBL_MASK) >> FEMC_SDRCTRL3_REBL_SHIFT)
  604. /*
  605. * REN (RW)
  606. *
  607. * Refresh enable
  608. */
  609. #define FEMC_SDRCTRL3_REN_MASK (0x1U)
  610. #define FEMC_SDRCTRL3_REN_SHIFT (0U)
  611. #define FEMC_SDRCTRL3_REN_SET(x) (((uint32_t)(x) << FEMC_SDRCTRL3_REN_SHIFT) & FEMC_SDRCTRL3_REN_MASK)
  612. #define FEMC_SDRCTRL3_REN_GET(x) (((uint32_t)(x) & FEMC_SDRCTRL3_REN_MASK) >> FEMC_SDRCTRL3_REN_SHIFT)
  613. /* Bitfield definition for register: SRCTRL0 */
  614. /*
  615. * ADVH (RW)
  616. *
  617. * ADV hold state
  618. * 0b - ADV is high during address hold state
  619. * 1b - ADV is low during address hold state
  620. */
  621. #define FEMC_SRCTRL0_ADVH_MASK (0x800U)
  622. #define FEMC_SRCTRL0_ADVH_SHIFT (11U)
  623. #define FEMC_SRCTRL0_ADVH_SET(x) (((uint32_t)(x) << FEMC_SRCTRL0_ADVH_SHIFT) & FEMC_SRCTRL0_ADVH_MASK)
  624. #define FEMC_SRCTRL0_ADVH_GET(x) (((uint32_t)(x) & FEMC_SRCTRL0_ADVH_MASK) >> FEMC_SRCTRL0_ADVH_SHIFT)
  625. /*
  626. * ADVP (RW)
  627. *
  628. * ADV polarity
  629. * 0b - ADV is active low
  630. * 1b - ADV is active high
  631. */
  632. #define FEMC_SRCTRL0_ADVP_MASK (0x400U)
  633. #define FEMC_SRCTRL0_ADVP_SHIFT (10U)
  634. #define FEMC_SRCTRL0_ADVP_SET(x) (((uint32_t)(x) << FEMC_SRCTRL0_ADVP_SHIFT) & FEMC_SRCTRL0_ADVP_MASK)
  635. #define FEMC_SRCTRL0_ADVP_GET(x) (((uint32_t)(x) & FEMC_SRCTRL0_ADVP_MASK) >> FEMC_SRCTRL0_ADVP_SHIFT)
  636. /*
  637. * ADM (RW)
  638. *
  639. * address data mode
  640. * 00b - address and data MUX mode
  641. * 11b - address and data non-MUX mode
  642. */
  643. #define FEMC_SRCTRL0_ADM_MASK (0x300U)
  644. #define FEMC_SRCTRL0_ADM_SHIFT (8U)
  645. #define FEMC_SRCTRL0_ADM_SET(x) (((uint32_t)(x) << FEMC_SRCTRL0_ADM_SHIFT) & FEMC_SRCTRL0_ADM_MASK)
  646. #define FEMC_SRCTRL0_ADM_GET(x) (((uint32_t)(x) & FEMC_SRCTRL0_ADM_MASK) >> FEMC_SRCTRL0_ADM_SHIFT)
  647. /*
  648. * PORTSZ (RW)
  649. *
  650. * port size
  651. * 0b - 8bit
  652. * 1b - 16bit
  653. */
  654. #define FEMC_SRCTRL0_PORTSZ_MASK (0x1U)
  655. #define FEMC_SRCTRL0_PORTSZ_SHIFT (0U)
  656. #define FEMC_SRCTRL0_PORTSZ_SET(x) (((uint32_t)(x) << FEMC_SRCTRL0_PORTSZ_SHIFT) & FEMC_SRCTRL0_PORTSZ_MASK)
  657. #define FEMC_SRCTRL0_PORTSZ_GET(x) (((uint32_t)(x) & FEMC_SRCTRL0_PORTSZ_MASK) >> FEMC_SRCTRL0_PORTSZ_SHIFT)
  658. /* Bitfield definition for register: SRCTRL1 */
  659. /*
  660. * OEH (RW)
  661. *
  662. * OE high time, is OEH+1 clock cycles
  663. */
  664. #define FEMC_SRCTRL1_OEH_MASK (0xF0000000UL)
  665. #define FEMC_SRCTRL1_OEH_SHIFT (28U)
  666. #define FEMC_SRCTRL1_OEH_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_OEH_SHIFT) & FEMC_SRCTRL1_OEH_MASK)
  667. #define FEMC_SRCTRL1_OEH_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_OEH_MASK) >> FEMC_SRCTRL1_OEH_SHIFT)
  668. /*
  669. * OEL (RW)
  670. *
  671. * OE low time, is OEL+1 clock cycles
  672. */
  673. #define FEMC_SRCTRL1_OEL_MASK (0xF000000UL)
  674. #define FEMC_SRCTRL1_OEL_SHIFT (24U)
  675. #define FEMC_SRCTRL1_OEL_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_OEL_SHIFT) & FEMC_SRCTRL1_OEL_MASK)
  676. #define FEMC_SRCTRL1_OEL_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_OEL_MASK) >> FEMC_SRCTRL1_OEL_SHIFT)
  677. /*
  678. * WEH (RW)
  679. *
  680. * WE high time, is WEH+1 clock cycles
  681. */
  682. #define FEMC_SRCTRL1_WEH_MASK (0xF00000UL)
  683. #define FEMC_SRCTRL1_WEH_SHIFT (20U)
  684. #define FEMC_SRCTRL1_WEH_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_WEH_SHIFT) & FEMC_SRCTRL1_WEH_MASK)
  685. #define FEMC_SRCTRL1_WEH_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_WEH_MASK) >> FEMC_SRCTRL1_WEH_SHIFT)
  686. /*
  687. * WEL (RW)
  688. *
  689. * WE low time, is WEL+1 clock cycles
  690. */
  691. #define FEMC_SRCTRL1_WEL_MASK (0xF0000UL)
  692. #define FEMC_SRCTRL1_WEL_SHIFT (16U)
  693. #define FEMC_SRCTRL1_WEL_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_WEL_SHIFT) & FEMC_SRCTRL1_WEL_MASK)
  694. #define FEMC_SRCTRL1_WEL_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_WEL_MASK) >> FEMC_SRCTRL1_WEL_SHIFT)
  695. /*
  696. * AH (RW)
  697. *
  698. * Address hold time, is AH+1 clock cycles
  699. */
  700. #define FEMC_SRCTRL1_AH_MASK (0xF000U)
  701. #define FEMC_SRCTRL1_AH_SHIFT (12U)
  702. #define FEMC_SRCTRL1_AH_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_AH_SHIFT) & FEMC_SRCTRL1_AH_MASK)
  703. #define FEMC_SRCTRL1_AH_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_AH_MASK) >> FEMC_SRCTRL1_AH_SHIFT)
  704. /*
  705. * AS (RW)
  706. *
  707. * Address setup time, is AS+1 clock cycles
  708. */
  709. #define FEMC_SRCTRL1_AS_MASK (0xF00U)
  710. #define FEMC_SRCTRL1_AS_SHIFT (8U)
  711. #define FEMC_SRCTRL1_AS_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_AS_SHIFT) & FEMC_SRCTRL1_AS_MASK)
  712. #define FEMC_SRCTRL1_AS_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_AS_MASK) >> FEMC_SRCTRL1_AS_SHIFT)
  713. /*
  714. * CEH (RW)
  715. *
  716. * Chip enable hold time, is CEH+1 clock cycles
  717. */
  718. #define FEMC_SRCTRL1_CEH_MASK (0xF0U)
  719. #define FEMC_SRCTRL1_CEH_SHIFT (4U)
  720. #define FEMC_SRCTRL1_CEH_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_CEH_SHIFT) & FEMC_SRCTRL1_CEH_MASK)
  721. #define FEMC_SRCTRL1_CEH_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_CEH_MASK) >> FEMC_SRCTRL1_CEH_SHIFT)
  722. /*
  723. * CES (RW)
  724. *
  725. * Chip enable setup time, is CES+1 clock cycles
  726. */
  727. #define FEMC_SRCTRL1_CES_MASK (0xFU)
  728. #define FEMC_SRCTRL1_CES_SHIFT (0U)
  729. #define FEMC_SRCTRL1_CES_SET(x) (((uint32_t)(x) << FEMC_SRCTRL1_CES_SHIFT) & FEMC_SRCTRL1_CES_MASK)
  730. #define FEMC_SRCTRL1_CES_GET(x) (((uint32_t)(x) & FEMC_SRCTRL1_CES_MASK) >> FEMC_SRCTRL1_CES_SHIFT)
  731. /* Bitfield definition for register: SADDR */
  732. /*
  733. * SA (RW)
  734. *
  735. * Slave address
  736. */
  737. #define FEMC_SADDR_SA_MASK (0xFFFFFFFFUL)
  738. #define FEMC_SADDR_SA_SHIFT (0U)
  739. #define FEMC_SADDR_SA_SET(x) (((uint32_t)(x) << FEMC_SADDR_SA_SHIFT) & FEMC_SADDR_SA_MASK)
  740. #define FEMC_SADDR_SA_GET(x) (((uint32_t)(x) & FEMC_SADDR_SA_MASK) >> FEMC_SADDR_SA_SHIFT)
  741. /* Bitfield definition for register: DATSZ */
  742. /*
  743. * DATSZ (RW)
  744. *
  745. * Data Size in Byte
  746. * When IP command is not a write/read operation, DATSZ field would be ignored.
  747. * 000b - 4
  748. * 001b - 1
  749. * 010b - 2
  750. * 011b - 3
  751. * 100b - 4
  752. * 101b - 4
  753. * 110b - 4
  754. * 111b - 4
  755. */
  756. #define FEMC_DATSZ_DATSZ_MASK (0x7U)
  757. #define FEMC_DATSZ_DATSZ_SHIFT (0U)
  758. #define FEMC_DATSZ_DATSZ_SET(x) (((uint32_t)(x) << FEMC_DATSZ_DATSZ_SHIFT) & FEMC_DATSZ_DATSZ_MASK)
  759. #define FEMC_DATSZ_DATSZ_GET(x) (((uint32_t)(x) & FEMC_DATSZ_DATSZ_MASK) >> FEMC_DATSZ_DATSZ_SHIFT)
  760. /* Bitfield definition for register: BYTEMSK */
  761. /*
  762. * BM3 (RW)
  763. *
  764. * Byte Mask for Byte 3 (IPTXD bit 31:24)
  765. * 0b - Byte Unmasked
  766. * 1b - Byte Masked
  767. */
  768. #define FEMC_BYTEMSK_BM3_MASK (0x8U)
  769. #define FEMC_BYTEMSK_BM3_SHIFT (3U)
  770. #define FEMC_BYTEMSK_BM3_SET(x) (((uint32_t)(x) << FEMC_BYTEMSK_BM3_SHIFT) & FEMC_BYTEMSK_BM3_MASK)
  771. #define FEMC_BYTEMSK_BM3_GET(x) (((uint32_t)(x) & FEMC_BYTEMSK_BM3_MASK) >> FEMC_BYTEMSK_BM3_SHIFT)
  772. /*
  773. * BM2 (RW)
  774. *
  775. * Byte Mask for Byte 2 (IPTXD bit 23:16)
  776. * 0b - Byte Unmasked
  777. * 1b - Byte Masked
  778. */
  779. #define FEMC_BYTEMSK_BM2_MASK (0x4U)
  780. #define FEMC_BYTEMSK_BM2_SHIFT (2U)
  781. #define FEMC_BYTEMSK_BM2_SET(x) (((uint32_t)(x) << FEMC_BYTEMSK_BM2_SHIFT) & FEMC_BYTEMSK_BM2_MASK)
  782. #define FEMC_BYTEMSK_BM2_GET(x) (((uint32_t)(x) & FEMC_BYTEMSK_BM2_MASK) >> FEMC_BYTEMSK_BM2_SHIFT)
  783. /*
  784. * BM1 (RW)
  785. *
  786. * Byte Mask for Byte 1 (IPTXD bit 15:8)
  787. * 0b - Byte Unmasked
  788. * 1b - Byte Masked
  789. */
  790. #define FEMC_BYTEMSK_BM1_MASK (0x2U)
  791. #define FEMC_BYTEMSK_BM1_SHIFT (1U)
  792. #define FEMC_BYTEMSK_BM1_SET(x) (((uint32_t)(x) << FEMC_BYTEMSK_BM1_SHIFT) & FEMC_BYTEMSK_BM1_MASK)
  793. #define FEMC_BYTEMSK_BM1_GET(x) (((uint32_t)(x) & FEMC_BYTEMSK_BM1_MASK) >> FEMC_BYTEMSK_BM1_SHIFT)
  794. /*
  795. * BM0 (RW)
  796. *
  797. * Byte Mask for Byte 0 (IPTXD bit 7:0)
  798. * 0b - Byte Unmasked
  799. * 1b - Byte Masked
  800. */
  801. #define FEMC_BYTEMSK_BM0_MASK (0x1U)
  802. #define FEMC_BYTEMSK_BM0_SHIFT (0U)
  803. #define FEMC_BYTEMSK_BM0_SET(x) (((uint32_t)(x) << FEMC_BYTEMSK_BM0_SHIFT) & FEMC_BYTEMSK_BM0_MASK)
  804. #define FEMC_BYTEMSK_BM0_GET(x) (((uint32_t)(x) & FEMC_BYTEMSK_BM0_MASK) >> FEMC_BYTEMSK_BM0_SHIFT)
  805. /* Bitfield definition for register: IPCMD */
  806. /*
  807. * KEY (WO)
  808. *
  809. * This field should be written with 0x5AA5 when trigging an IP command for all device types. The memory
  810. * device is selected by BRx settings and IPCR0 registers.
  811. */
  812. #define FEMC_IPCMD_KEY_MASK (0xFFFF0000UL)
  813. #define FEMC_IPCMD_KEY_SHIFT (16U)
  814. #define FEMC_IPCMD_KEY_SET(x) (((uint32_t)(x) << FEMC_IPCMD_KEY_SHIFT) & FEMC_IPCMD_KEY_MASK)
  815. #define FEMC_IPCMD_KEY_GET(x) (((uint32_t)(x) & FEMC_IPCMD_KEY_MASK) >> FEMC_IPCMD_KEY_SHIFT)
  816. /*
  817. * CMD (RW)
  818. *
  819. * SDRAM Commands:
  820. * • 0x8: READ
  821. * • 0x9: WRITE
  822. * • 0xA: MODESET
  823. * • 0xB: ACTIVE
  824. * • 0xC: AUTO REFRESH
  825. * • 0xD: SELF REFRESH
  826. * • 0xE: PRECHARGE
  827. * • 0xF: PRECHARGE ALL
  828. * • Others: RSVD
  829. * NOTE: SELF REFRESH is sent to all SDRAM devices because they shared same CLK pin.
  830. */
  831. #define FEMC_IPCMD_CMD_MASK (0xFFFFU)
  832. #define FEMC_IPCMD_CMD_SHIFT (0U)
  833. #define FEMC_IPCMD_CMD_SET(x) (((uint32_t)(x) << FEMC_IPCMD_CMD_SHIFT) & FEMC_IPCMD_CMD_MASK)
  834. #define FEMC_IPCMD_CMD_GET(x) (((uint32_t)(x) & FEMC_IPCMD_CMD_MASK) >> FEMC_IPCMD_CMD_SHIFT)
  835. /* Bitfield definition for register: IPTX */
  836. /*
  837. * DAT (RW)
  838. *
  839. * Data
  840. */
  841. #define FEMC_IPTX_DAT_MASK (0xFFFFFFFFUL)
  842. #define FEMC_IPTX_DAT_SHIFT (0U)
  843. #define FEMC_IPTX_DAT_SET(x) (((uint32_t)(x) << FEMC_IPTX_DAT_SHIFT) & FEMC_IPTX_DAT_MASK)
  844. #define FEMC_IPTX_DAT_GET(x) (((uint32_t)(x) & FEMC_IPTX_DAT_MASK) >> FEMC_IPTX_DAT_SHIFT)
  845. /* Bitfield definition for register: IPRX */
  846. /*
  847. * DAT (RW)
  848. *
  849. * Data
  850. */
  851. #define FEMC_IPRX_DAT_MASK (0xFFFFFFFFUL)
  852. #define FEMC_IPRX_DAT_SHIFT (0U)
  853. #define FEMC_IPRX_DAT_SET(x) (((uint32_t)(x) << FEMC_IPRX_DAT_SHIFT) & FEMC_IPRX_DAT_MASK)
  854. #define FEMC_IPRX_DAT_GET(x) (((uint32_t)(x) & FEMC_IPRX_DAT_MASK) >> FEMC_IPRX_DAT_SHIFT)
  855. /* Bitfield definition for register: STAT0 */
  856. /*
  857. * IDLE (RO)
  858. *
  859. * Indicating whether it is in IDLE state.
  860. * When IDLE=1, it is in IDLE state. There is no pending AXI command in internal queue and no
  861. * pending device access.
  862. */
  863. #define FEMC_STAT0_IDLE_MASK (0x1U)
  864. #define FEMC_STAT0_IDLE_SHIFT (0U)
  865. #define FEMC_STAT0_IDLE_GET(x) (((uint32_t)(x) & FEMC_STAT0_IDLE_MASK) >> FEMC_STAT0_IDLE_SHIFT)
  866. /* Bitfield definition for register: DLYCFG */
  867. /*
  868. * OE (RW)
  869. *
  870. * delay clock output enable, should be set after setting DLYEN and DLYSEL
  871. */
  872. #define FEMC_DLYCFG_OE_MASK (0x2000U)
  873. #define FEMC_DLYCFG_OE_SHIFT (13U)
  874. #define FEMC_DLYCFG_OE_SET(x) (((uint32_t)(x) << FEMC_DLYCFG_OE_SHIFT) & FEMC_DLYCFG_OE_MASK)
  875. #define FEMC_DLYCFG_OE_GET(x) (((uint32_t)(x) & FEMC_DLYCFG_OE_MASK) >> FEMC_DLYCFG_OE_SHIFT)
  876. /*
  877. * DLYSEL (RW)
  878. *
  879. * delay line select, 0 for 1 cell, 31 for all 32 cells
  880. */
  881. #define FEMC_DLYCFG_DLYSEL_MASK (0x3EU)
  882. #define FEMC_DLYCFG_DLYSEL_SHIFT (1U)
  883. #define FEMC_DLYCFG_DLYSEL_SET(x) (((uint32_t)(x) << FEMC_DLYCFG_DLYSEL_SHIFT) & FEMC_DLYCFG_DLYSEL_MASK)
  884. #define FEMC_DLYCFG_DLYSEL_GET(x) (((uint32_t)(x) & FEMC_DLYCFG_DLYSEL_MASK) >> FEMC_DLYCFG_DLYSEL_SHIFT)
  885. /*
  886. * DLYEN (RW)
  887. *
  888. * delay line enable
  889. */
  890. #define FEMC_DLYCFG_DLYEN_MASK (0x1U)
  891. #define FEMC_DLYCFG_DLYEN_SHIFT (0U)
  892. #define FEMC_DLYCFG_DLYEN_SET(x) (((uint32_t)(x) << FEMC_DLYCFG_DLYEN_SHIFT) & FEMC_DLYCFG_DLYEN_MASK)
  893. #define FEMC_DLYCFG_DLYEN_GET(x) (((uint32_t)(x) & FEMC_DLYCFG_DLYEN_MASK) >> FEMC_DLYCFG_DLYEN_SHIFT)
  894. /* BR register group index macro definition */
  895. #define FEMC_BR_BASE0 (0UL)
  896. #define FEMC_BR_BASE1 (1UL)
  897. #define FEMC_BR_BASE6 (6UL)
  898. #endif /* HPM_FEMC_H */