smi_reg.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. #ifndef _SMI_REG_H__
  2. #define _SMI_REG_H__
  3. #ifndef CONFIG_MTK_SMI_VARIANT
  4. #define SMI_COMMON_EXT_BASE (smi_reg_base_common_ext)
  5. #define LARB0_BASE (smi_reg_base_barb0)
  6. #define LARB1_BASE (smi_reg_base_barb1)
  7. #if defined D2
  8. #define LARB2_BASE (smi_reg_base_barb2)
  9. #elif defined D1 || defined D3
  10. #define LARB2_BASE (smi_reg_base_barb2)
  11. #define LARB3_BASE (smi_reg_base_barb3)
  12. #endif
  13. #else
  14. extern struct mtk_smi_data *smi_data;
  15. #define LARB0_BASE smi_data->larb_base[0]
  16. #define LARB1_BASE smi_data->larb_base[1]
  17. #define LARB2_BASE smi_data->larb_base[2]
  18. #define LARB3_BASE smi_data->larb_base[3]
  19. #define LARB4_BASE smi_data->larb_base[4]
  20. #define LARB5_BASE smi_data->larb_base[5]
  21. #define SMI_COMMON_EXT_BASE smi_data->smi_common_base
  22. #endif
  23. /* ================================================= */
  24. /* common macro definitions */
  25. #define F_VAL(val, msb, lsb) (((val)&((1<<(msb-lsb+1))-1))<<lsb)
  26. #define F_MSK(msb, lsb) F_VAL(0xffffffff, msb, lsb)
  27. #define F_BIT_SET(bit) (1<<(bit))
  28. #define F_BIT_VAL(val, bit) ((!!(val))<<(bit))
  29. #define F_MSK_SHIFT(regval, msb, lsb) (((regval)&F_MSK(msb, lsb))>>lsb)
  30. /* ===================================================== */
  31. /* M4U register definition */
  32. /* ===================================================== */
  33. #define REG_MMUg_PT_BASE (0x0)
  34. #define F_MMUg_PT_VA_MSK 0xffff0000
  35. #define REG_MMUg_PT_BASE_SEC (0x4)
  36. #define F_MMUg_PT_VA_MSK_SEC 0xffff0000
  37. #define REG_MMU_PROG_EN 0x10
  38. #define F_MMU0_PROG_EN 1
  39. #define F_MMU1_PROG_EN 2
  40. #define REG_MMU_PROG_VA 0x14
  41. #define F_PROG_VA_LOCK_BIT (1<<11)
  42. #define F_PROG_VA_LAYER_BIT F_BIT_SET(9)
  43. #define F_PROG_VA_SIZE16X_BIT F_BIT_SET(8)
  44. #define F_PROG_VA_SECURE_BIT (1<<7)
  45. #define F_PROG_VA_MASK 0xfffff000
  46. #define REG_MMU_PROG_DSC 0x18
  47. #define REG_MMU_INVLD (0x20)
  48. #define F_MMU_INV_ALL 0x2
  49. #define F_MMU_INV_RANGE 0x1
  50. #define REG_MMU_INVLD_SA (0x24)
  51. #define REG_MMU_INVLD_EA (0x28)
  52. #define REG_MMU_INVLD_SEC (0x2c)
  53. #define F_MMU_INV_SEC_ALL 0x2
  54. #define F_MMU_INV_SEC_RANGE 0x1
  55. #define REG_MMU_INVLD_SA_SEC (0x30)
  56. #define REG_MMU_INVLD_EA_SEC (0x34)
  57. #define REG_INVLID_SEL (0x38)
  58. #define F_MMU_INV_EN_L1 (1<<0)
  59. #define F_MMU_INV_EN_L2 (1<<1)
  60. #define REG_INVLID_SEL_SEC (0x3c)
  61. #define F_MMU_INV_SEC_EN_L1 (1<<0)
  62. #define F_MMU_INV_SEC_EN_L2 (1<<1)
  63. #define F_MMU_INV_SEC_INV_DONE (1<<2)
  64. #define F_MMU_INV_SEC_INV_INT_SET (1<<3)
  65. #define F_MMU_INV_SEC_INV_INT_CLR (1<<4)
  66. #define F_MMU_INV_SEC_DBG (1<<5)
  67. #define REG_MMU_SEC_ABORT_INFO (0x40)
  68. #define REG_MMU_STANDARD_AXI_MODE (0x48)
  69. #define REG_MMU_PRIORITY (0x4c)
  70. #define REG_MMU_DCM_DIS (0x50)
  71. #define REG_MMU_WR_LEN (0x54)
  72. #define REG_MMU_HW_DEBUG (0x58)
  73. #define F_MMU_HW_DBG_L2_SCAN_ALL F_BIT_SET(1)
  74. #define F_MMU_HW_DBG_PFQ_BRDCST F_BIT_SET(0)
  75. #define REG_MMU_NON_BLOCKING_DIS 0x5C
  76. #define F_MMU_NON_BLOCK_DISABLE_BIT 1
  77. #define F_MMU_NON_BLOCK_HALF_ENTRY_BIT 2
  78. #define REG_MMU_LEGACY_4KB_MODE (0x60)
  79. #define REG_MMU_PFH_DIST0 0x80
  80. #define REG_MMU_PFH_DIST1 0x84
  81. #define REG_MMU_PFH_DIST2 0x88
  82. #define REG_MMU_PFH_DIST3 0x8c
  83. #define REG_MMU_PFH_DIST4 0x90
  84. #define REG_MMU_PFH_DIST5 0x94
  85. #define REG_MMU_PFH_DIST6 0x98
  86. #define REG_MMU_PFH_DIST(port) (0x80+(((port)>>3)<<2))
  87. #define F_MMU_PFH_DIST_VAL(port, val) ((val&0xf)<<(((port)&0x7)<<2))
  88. #define F_MMU_PFH_DIST_MASK(port) F_MMU_PFH_DIST_VAL((port), 0xf)
  89. #define REG_MMU_PFH_DIR0 0xF0
  90. #define REG_MMU_PFH_DIR1 0xF4
  91. #define REG_MMU_PFH_DIR(port) (((port) < 32) ? REG_MMU_PFH_DIR0 : REG_MMU_PFH_DIR1)
  92. #define F_MMU_PFH_DIR(port, val) ((!!(val))<<((port)&0x1f))
  93. #define REG_MMU_READ_ENTRY 0x100
  94. #define F_READ_ENTRY_EN F_BIT_SET(31)
  95. #define F_READ_ENTRY_MM1_MAIN F_BIT_SET(26)
  96. #define F_READ_ENTRY_MM0_MAIN F_BIT_SET(25)
  97. #define F_READ_ENTRY_MMx_MAIN(id) F_BIT_SET(25+id)
  98. #define F_READ_ENTRY_PFH F_BIT_SET(24)
  99. #define F_READ_ENTRY_MAIN_IDX(idx) F_VAL(idx, 21, 16)
  100. #define F_READ_ENTRY_PFH_IDX(idx) F_VAL(idx, 11, 5)
  101. /* #define F_READ_ENTRY_PFH_HI_LO(high) F_VAL(high, 4,4) */
  102. /* #define F_READ_ENTRY_PFH_PAGE(page) F_VAL(page, 3,2) */
  103. #define F_READ_ENTRY_PFH_PAGE_IDX(idx) F_VAL(idx, 4, 2)
  104. #define F_READ_ENTRY_PFH_WAY(way) F_VAL(way, 1, 0)
  105. #define REG_MMU_DES_RDATA 0x104
  106. #define REG_MMU_PFH_TAG_RDATA 0x108
  107. #define F_PFH_TAG_VA_GET(mmu, tag) (F_MSK_SHIFT(tag, 14, 4)<<(MMU_SET_MSB_OFFSET(mmu)+1))
  108. #define F_PFH_TAG_LAYER_BIT F_BIT_SET(3)
  109. #define F_PFH_TAG_16X_BIT F_BIT_SET(2) /* this bit is always 0 -- cost down. */
  110. #define F_PFH_TAG_SEC_BIT F_BIT_SET(1)
  111. #define F_PFH_TAG_AUTO_PFH F_BIT_SET(0)
  112. /* tag related macro */
  113. /* #define MMU0_SET_ORDER 7 */
  114. /* #define MMU1_SET_ORDER 6 */
  115. #define MMU_SET_ORDER(mmu) (7-(mmu))
  116. #define MMU_SET_NR(mmu) (1<<MMU_SET_ORDER(mmu))
  117. #define MMU_SET_LSB_OFFSET 15
  118. #define MMU_SET_MSB_OFFSET(mmu) (MMU_SET_LSB_OFFSET+MMU_SET_ORDER(mmu)-1)
  119. #define MMU_PFH_VA_TO_SET(mmu, va) F_MSK_SHIFT(va, MMU_SET_MSB_OFFSET(mmu), MMU_SET_LSB_OFFSET)
  120. #define MMU_PAGE_PER_LINE 8
  121. #define MMU_WAY_NR 4
  122. #define MMU_PFH_TOTAL_LINE(mmu) (MMU_SET_NR(mmu)*MMU_WAY_NR)
  123. #define REG_MMU_CTRL_REG 0x110
  124. #define F_MMU_CTRL_PFH_DIS(dis) F_BIT_VAL(dis, 0)
  125. #define F_MMU_CTRL_TLB_WALK_DIS(dis) F_BIT_VAL(dis, 1)
  126. #define F_MMU_CTRL_MONITOR_EN(en) F_BIT_VAL(en, 2)
  127. #define F_MMU_CTRL_MONITOR_CLR(clr) F_BIT_VAL(clr, 3)
  128. #define F_MMU_CTRL_PFH_RT_RPL_MODE(mod) F_BIT_VAL(mod, 4)
  129. #define F_MMU_CTRL_TF_PROT_VAL(prot) F_VAL(prot, 6, 5)
  130. #define F_MMU_CTRL_TF_PROT_MSK F_MSK(6, 5)
  131. #define F_MMU_CTRL_INT_HANG_en(en) F_BIT_VAL(en, 7)
  132. #define F_MMU_CTRL_COHERE_EN(en) F_BIT_VAL(en, 8)
  133. #define F_MMU_CTRL_IN_ORDER_WR(en) F_BIT_VAL(en, 9)
  134. #define F_MMU_CTRL_MAIN_TLB_SHARE_ALL(en) F_BIT_VAL(en, 10)
  135. #define REG_MMU_IVRP_PADDR 0x114
  136. #define F_MMU_IVRP_PA_SET(PA) (PA>>1)
  137. #define F_MMU_IVRP_8G_PA_SET(PA) ((PA>>1)|(1<<31))
  138. #define REG_MMU_INT_L2_CONTROL 0x120
  139. #define F_INT_L2_CLR_BIT (1<<12)
  140. #define F_INT_L2_MULTI_HIT_FAULT F_BIT_SET(0)
  141. #define F_INT_L2_TABLE_WALK_FAULT F_BIT_SET(1)
  142. #define F_INT_L2_PFH_DMA_FIFO_OVERFLOW F_BIT_SET(2)
  143. #define F_INT_L2_MISS_DMA_FIFO_OVERFLOW F_BIT_SET(3)
  144. #define F_INT_L2_INVALD_DONE F_BIT_SET(4)
  145. #define F_INT_L2_PFH_IN_OUT_FIFO_ERROR F_BIT_SET(5)
  146. #define F_INT_L2_MISS_FIFO_ERR F_BIT_SET(6)
  147. #define REG_MMU_INT_MAIN_CONTROL 0x124
  148. #define F_INT_TRANSLATION_FAULT(MMU) F_BIT_SET(0+(((MMU)<<1)|((MMU)<<2)))
  149. #define F_INT_MAIN_MULTI_HIT_FAULT(MMU) F_BIT_SET(1+(((MMU)<<1)|((MMU)<<2)))
  150. #define F_INT_INVALID_PHYSICAL_ADDRESS_FAULT(MMU) F_BIT_SET(2+(((MMU)<<1)|((MMU)<<2)))
  151. #define F_INT_ENTRY_REPLACEMENT_FAULT(MMU) F_BIT_SET(3+(((MMU)<<1)|((MMU)<<2)))
  152. #define F_INT_TLB_MISS_FAULT(MMU) F_BIT_SET(5+(((MMU)<<1)|((MMU)<<2)))
  153. #define F_INT_PFH_FIFO_ERR(MMU) F_BIT_SET(6+(((MMU)<<1)|((MMU)<<2)))
  154. #define F_INT_MAU(mmu, set) F_BIT_SET(14+(set)+(mmu<<2)) /* (14+(set)+(mmu*4)) */
  155. #define F_INT_MMU0_MAIN_MSK F_MSK(6, 0)
  156. #define F_INT_MMU1_MAIN_MSK F_MSK(13, 7)
  157. #define F_INT_MMU0_MAU_MSK F_MSK(17, 14)
  158. #define F_INT_MMU1_MAU_MSK F_MSK(21, 18)
  159. #define REG_MMU_CPE_DONE_SEC 0x128
  160. #define REG_MMU_CPE_DONE 0x12C
  161. #define REG_MMU_L2_FAULT_ST 0x130
  162. #define F_INT_L2_MISS_OUT_FIFO_ERROR F_BIT_SET(7)
  163. #define F_INT_L2_MISS_IN_FIFO_ERR F_BIT_SET(8)
  164. #define REG_MMU_MAIN_FAULT_ST 0x134
  165. #define REG_MMU_TBWALK_FAULT_VA 0x138
  166. #define F_MMU_TBWALK_FAULT_VA_MSK F_MSK(31, 12)
  167. #define F_MMU_TBWALK_FAULT_LAYER(regval) F_MSK_SHIFT(regval, 0, 0)
  168. #define REG_MMU_FAULT_VA(mmu) (0x13c+((mmu)<<3))
  169. #define F_MMU_FAULT_VA_MSK F_MSK(31, 12)
  170. #define F_MMU_FAULT_VA_WRITE_BIT F_BIT_SET(1)
  171. #define F_MMU_FAULT_VA_LAYER_BIT F_BIT_SET(0)
  172. #define REG_MMU_INVLD_PA(mmu) (0x140+((mmu)<<3))
  173. #define REG_MMU_INT_ID(mmu) (0x150+((mmu)<<2))
  174. #define REG_MMU_PF_MSCNT 0x160
  175. #define REG_MMU_PF_CNT 0x164
  176. #define REG_MMU_ACC_CNT(mmu) (0x168+(((mmu)<<3)|((mmu)<<2))) /* (0x168+((mmu)*12) */
  177. #define REG_MMU_MAIN_MSCNT(mmu) (0x16c+(((mmu)<<3)|((mmu)<<2)))
  178. #define REG_MMU_RS_PERF_CNT(mmu) (0x170+(((mmu)<<3)|((mmu)<<2)))
  179. #define MMU01_SQ_OFFSET (0x600-0x300)
  180. #define REG_MMU_SQ_START(mmu, x) (0x300+((x)<<3)+((mmu)*MMU01_SQ_OFFSET))
  181. #define F_SQ_VA_MASK F_MSK(31, 18)
  182. #define F_SQ_EN_BIT (1<<17)
  183. /* #define F_SQ_MULTI_ENTRY_VAL(x) (((x)&0xf)<<13) */
  184. #define REG_MMU_SQ_END(mmu, x) (0x304+((x)<<3)+((mmu)*MMU01_SQ_OFFSET))
  185. #define MMU_TOTAL_RS_NR 8
  186. #define REG_MMU_RSx_VA(mmu, x) (0x380+((x)<<4)+((mmu)*MMU01_SQ_OFFSET))
  187. #define F_MMU_RSx_VA_GET(regval) ((regval)&F_MSK(31, 12))
  188. #define F_MMU_RSx_VA_VALID(regval) F_MSK_SHIFT(regval, 11, 11)
  189. #define F_MMU_RSx_VA_PID(regval) F_MSK_SHIFT(regval, 9, 0)
  190. #define REG_MMU_RSx_PA(mmu, x) (0x384+((x)<<4)+((mmu)*MMU01_SQ_OFFSET))
  191. #define F_MMU_RSx_PA_GET(regval) ((regval)&F_MSK(31, 12))
  192. #define F_MMU_RSx_PA_VALID(regval) F_MSK_SHIFT(regval, 1, 0)
  193. #define REG_MMU_RSx_2ND_BASE(mmu, x) (0x388+((x)<<4)+((mmu)*MMU01_SQ_OFFSET))
  194. #define REG_MMU_RSx_ST(mmu, x) (0x38c+((x)<<4)+((mmu)*MMU01_SQ_OFFSET))
  195. #define F_MMU_RSx_ST_LID(regval) F_MSK_SHIFT(regval, 21, 20)
  196. #define F_MMU_RSx_ST_WRT(regval) F_MSK_SHIFT(regval, 12, 12)
  197. #define F_MMU_RSx_ST_OTHER(regval) F_MSK_SHIFT(regval, 8, 0)
  198. #define REG_MMU_MAIN_TAG(mmu, x) (0x500+((x)<<2)+((mmu)*MMU01_SQ_OFFSET))
  199. #define F_MAIN_TLB_VA_MSK F_MSK(31, 12)
  200. #define F_MAIN_TLB_LOCK_BIT (1<<11)
  201. #define F_MAIN_TLB_VALID_BIT (1<<10)
  202. #define F_MAIN_TLB_LAYER_BIT F_BIT_SET(9)
  203. #define F_MAIN_TLB_16X_BIT F_BIT_SET(8)
  204. #define F_MAIN_TLB_SEC_BIT F_BIT_SET(7)
  205. #define F_MAIN_TLB_INV_DES_BIT (1<<6)
  206. #define F_MAIN_TLB_SQ_EN_BIT (1<<5)
  207. #define F_MAIN_TLB_SQ_INDEX_MSK F_MSK(4, 1)
  208. #define F_MAIN_TLB_SQ_INDEX_GET(regval) F_MSK_SHIFT(regval, 4, 1)
  209. #define REG_MMU_MAU_START(mmu, mau) (0x900+((mau)*0x20)+((mmu)*0xa0))
  210. #define REG_MMU_MAU_START_BIT32(mmu, mau) (0x904+((mau)*0x20)+((mmu)*0xa0))
  211. #define REG_MMU_MAU_END(mmu, mau) (0x908+((mau)*0x20)+((mmu)*0xa0))
  212. #define REG_MMU_MAU_END_BIT32(mmu, mau) (0x90C+((mau)*0x20)+((mmu)*0xa0))
  213. #define REG_MMU_MAU_PORT_EN(mmu, mau) (0x910+((mau)*0x20)+((mmu)*0xa0))
  214. #define REG_MMU_MAU_ASSERT_ID(mmu, mau) (0x914+((mau)*0x20)+((mmu)*0xa0))
  215. #define REG_MMU_MAU_ADDR(mmu, mau) (0x918+((mau)*0x20)+((mmu)*0xa0))
  216. #define REG_MMU_MAU_ADDR_BIT32(mmu, mau) (0x91C+((mau)*0x20)+((mmu)*0xa0))
  217. #define REG_MMU_MAU_LARB_EN(mmu) (0x980+((mmu)*0xa0))
  218. #define F_MAU_LARB_VAL(mau, larb) ((larb)<<(mau*8))
  219. #define F_MAU_LARB_MSK(mau) (0xff<<(mau*8))
  220. #define REG_MMU_MAU_CLR(mmu) (0x984+((mmu)*0xa0))
  221. #define REG_MMU_MAU_IO(mmu) (0x988+((mmu)*0xa0))
  222. #define F_MAU_BIT_VAL(val, mau) F_BIT_VAL(val, mau)
  223. #define REG_MMU_MAU_RW(mmu) (0x98c+((mmu)*0xa0))
  224. #define REG_MMU_MAU_VA(mmu) (0x990+((mmu)*0xa0))
  225. #define REG_MMU_MAU_ASSERT_ST(mmu) (0x994+((mmu)*0xa0))
  226. #define REG_MMU_PFH_VLD_0 (0x180)
  227. #define REG_MMU_PFH_VLD(set, way) (REG_MMU_PFH_VLD_0+(((set)>>5)<<2)+((way)<<4)) /* +((set/32)*4)+(way*16) */
  228. #define F_MMU_PFH_VLD_BIT(set, way) F_BIT_SET((set)&0x1f) /* set%32 */
  229. /* ================================================================ */
  230. /* SMI larb */
  231. /* ================================================================ */
  232. #define SMI_ERROR_ADDR 0
  233. #if defined D2
  234. #define SMI_LARB_NR 3
  235. #define SMI_LARB0_PORT_NUM 8
  236. #define SMI_LARB1_PORT_NUM 7
  237. #define SMI_LARB2_PORT_NUM 13
  238. #elif defined D1
  239. #define SMI_LARB_NR 4
  240. #define SMI_LARB0_PORT_NUM 7
  241. #define SMI_LARB1_PORT_NUM 7
  242. #define SMI_LARB2_PORT_NUM 21
  243. #define SMI_LARB3_PORT_NUM 13
  244. #elif defined D3
  245. #define SMI_LARB_NR 4
  246. #define SMI_LARB0_PORT_NUM 10
  247. #define SMI_LARB1_PORT_NUM 7
  248. #define SMI_LARB2_PORT_NUM 21
  249. #define SMI_LARB3_PORT_NUM 13
  250. #elif defined R
  251. #define SMI_LARB_NR 2
  252. #define SMI_LARB0_PORT_NUM 7
  253. #define SMI_LARB1_PORT_NUM 11
  254. #elif defined MT73
  255. #define SMI_LARB_NR 6
  256. #elif defined MT27
  257. #define SMI_LARB_NR 3
  258. #endif
  259. #define SMI_LARB_STAT (0x0)
  260. #define SMI_LARB_IRQ_EN (0x4)
  261. #define SMI_LARB_IRQ_STATUS (0x8)
  262. #define SMI_LARB_SLP_CON (0xc)
  263. #define SMI_LARB_CON (0x10)
  264. #define SMI_LARB_CON_SET (0x14)
  265. #define SMI_LARB_CON_CLR (0x18)
  266. #define SMI_LARB_VC_PRI_MODE (0x20)
  267. #define SMI_LARB_CMD_THRT_CON (0x24)
  268. #define SMI_LARB_STARV_CON (0x28)
  269. #define SMI_LARB_EMI_CON (0x2C)
  270. #define SMI_LARB_SHARE_EN (0x30)
  271. #define SMI_LARB_BWL_EN (0x50)
  272. #define SMI_LARB_BWL_SOFT_EN (0x54)
  273. #define SMI_LARB_BWL_CON (0x58)
  274. #define SMI_LARB_OSTDL_EN (0x60)
  275. #define SMI_LARB_OSTDL_SOFT_EN (0x64)
  276. #define SMI_LARB_ULTRA_DIS (0x70)
  277. #define SMI_LARB_PREULTRA_DIS (0x74)
  278. #define SMI_LARB_FORCE_ULTRA (0x78)
  279. #define SMI_LARB_FORCE_PREULTRA (0x7c)
  280. #define SMI_LARB_MST_GRP_SEL_L (0x80)
  281. #define SMI_LARB_MST_GRP_SEL_H (0x84)
  282. #define SMI_LARB_INT_PATH_SEL (0x90)
  283. #define SMI_LARB_EXT_GREQ_VIO (0xa0)
  284. #define SMI_LARB_INT_GREQ_VIO (0xa4)
  285. #define SMI_LARB_OSTD_UDF_VIO (0xa8)
  286. #define SMI_LARB_OSTD_CRS_VIO (0xac)
  287. #define SMI_LARB_FIFO_STAT (0xb0)
  288. #define SMI_LARB_BUS_STAT (0xb4)
  289. #define SMI_LARB_CMD_THRT_STAT (0xb8)
  290. #define SMI_LARB_MON_REQ (0xbc)
  291. #define SMI_LARB_REQ_MASK (0xc0)
  292. #define SMI_LARB_REQ_DET (0xc4)
  293. #define SMI_LARB_EXT_ONGOING (0xc8)
  294. #define SMI_LARB_INT_ONGOING (0xcc)
  295. #define SMI_LARB_MISC_MON0 (0xd0)
  296. #define SMI_LARB_DBG_CON (0xf0)
  297. #define SMI_LARB_TST_MODE (0xf4)
  298. #define SMI_LARB_WRR_PORT (0x100)
  299. #define SMI_LARB_BWL_PORT (0x180)
  300. #define SMI_LARB_OSTDL_PORT (0x200)
  301. #define SMI_LARB_OSTD_MON_PORT (0x280)
  302. #define SMI_LARB_PINFO (0x300)
  303. #define SMI_LARB_MON_EN (0x400)
  304. #define SMI_LARB_MON_CLR (0x404)
  305. #define SMI_LARB_MON_PORT (0x408)
  306. #define SMI_LARB_MON_CON (0x40c)
  307. #define SMI_LARB_MON_ACT_CNT (0x410)
  308. #define SMI_LARB_MON_REQ_CNT (0x414)
  309. #define SMI_LARB_MON_BEAT_CNT (0x418)
  310. #define SMI_LARB_MON_BYTE_CNT (0x41c)
  311. #define SMI_LARB_MON_CP_CNT (0x420)
  312. #define SMI_LARB_MON_DP_CNT (0x424)
  313. #define SMI_LARB_MON_OSTD_CNT (0x428)
  314. #define SMI_LARB_MON_CP_MAX (0x430)
  315. #define SMI_LARB_MON_COS_MAX (0x434)
  316. #define SMI_LARB_MMU_EN (0xf00)
  317. #define F_SMI_MMU_EN(port, en) ((en)<<((port)))
  318. #define F_SMI_SEC_EN(port, en) ((en)<<((port)))
  319. #define REG_SMI_LARB_DOMN_OF_PORT(port) (((port) > 15) ? 0xf0c : 0xf08)
  320. #define F_SMI_DOMN(port, domain) (((domain)&0x3)<<((((port) > 15) ? (port-16) : port)<<1))
  321. /*
  322. #define SMI_SHARE_EN (0x210)
  323. #define F_SMI_SHARE_EN(port) F_BIT_SET(m4u_port_2_larb_port(port))
  324. #define SMI_ROUTE_SEL (0x220)
  325. #define F_SMI_ROUTE_SEL_EMI(port) F_BIT_SET(m4u_port_2_larb_port(port))
  326. #define SMI_MMULOCK_EN (0x230)
  327. */
  328. /* ===============================================================
  329. * SMI COMMON
  330. * =============================================================== */
  331. #if defined R
  332. #define REG_OFFSET_SMI_L1LEN (0x200)
  333. #define REG_OFFSET_SMI_L1ARB0 (0x204)
  334. #define REG_OFFSET_SMI_L1ARB1 (0x208)
  335. #define REG_OFFSET_SMI_L1ARB2 (0x20C)
  336. #define REG_OFFSET_SMI_L1ARB3 (0x210)
  337. #define REG_OFFSET_SMI_L1ARB4 (0x214)
  338. #elif defined MT73
  339. #define REG_OFFSET_SMI_L1LEN (0x200)
  340. #define REG_OFFSET_SMI_L1ARB0 (0x204)
  341. #define REG_OFFSET_SMI_L1ARB1 (0x208)
  342. #define REG_OFFSET_SMI_L1ARB2 (0x20C)
  343. #define REG_OFFSET_SMI_L1ARB3 (0x210)
  344. #define REG_OFFSET_SMI_L1ARB4 (0x214)
  345. #define REG_OFFSET_SMI_L1ARB5 (0x218)
  346. #else
  347. #define REG_OFFSET_SMI_L1LEN (0x100)
  348. #define REG_OFFSET_SMI_L1ARB0 (0x104)
  349. #define REG_OFFSET_SMI_L1ARB1 (0x108)
  350. #define REG_OFFSET_SMI_L1ARB2 (0x10C)
  351. #define REG_OFFSET_SMI_L1ARB3 (0x110)
  352. #define REG_OFFSET_SMI_L1ARB4 (0x114)
  353. #endif
  354. /*
  355. #define REG_SMI_MON_AXI_ENA (0x1a0+SMI_COMMON_EXT_BASE)
  356. #define REG_SMI_MON_AXI_CLR (0x1a4+SMI_COMMON_EXT_BASE)
  357. #define REG_SMI_MON_AXI_TYPE (0x1ac+SMI_COMMON_EXT_BASE)
  358. #define REG_SMI_MON_AXI_CON (0x1b0+SMI_COMMON_EXT_BASE)
  359. #define REG_SMI_MON_AXI_ACT_CNT (0x1c0+SMI_COMMON_EXT_BASE)
  360. #define REG_SMI_MON_AXI_REQ_CNT (0x1c4+SMI_COMMON_EXT_BASE)
  361. #define REG_SMI_MON_AXI_OSTD_CNT (0x1c8+SMI_COMMON_EXT_BASE)
  362. #define REG_SMI_MON_AXI_BEA_CNT (0x1cc+SMI_COMMON_EXT_BASE)
  363. #define REG_SMI_MON_AXI_BYT_CNT (0x1d0+SMI_COMMON_EXT_BASE)
  364. #define REG_SMI_MON_AXI_CP_CNT (0x1d4+SMI_COMMON_EXT_BASE)
  365. #define REG_SMI_MON_AXI_DP_CNT (0x1d8+SMI_COMMON_EXT_BASE)
  366. #define REG_SMI_MON_AXI_CP_MAX (0x1dc+SMI_COMMON_EXT_BASE)
  367. #define REG_SMI_MON_AXI_COS_MAX (0x1e0+SMI_COMMON_EXT_BASE)
  368. #define REG_SMI_L1LEN (0x200+SMI_COMMON_EXT_BASE)
  369. #define REG_SMI_L1ARB0 (0x204+SMI_COMMON_EXT_BASE)
  370. #define REG_SMI_L1ARB1 (0x208+SMI_COMMON_EXT_BASE)
  371. #define REG_SMI_L1ARB2 (0x20C+SMI_COMMON_EXT_BASE)
  372. #define REG_SMI_L1ARB3 (0x210+SMI_COMMON_EXT_BASE)
  373. #define REG_SMI_L1ARB4 (0x214+SMI_COMMON_EXT_BASE)
  374. #define REG_SMI_BUS_SEL (0x220+SMI_COMMON_EXT_BASE)
  375. #define F_SMI_BUS_SEL_larb0(mmu_idx) F_VAL(mmu_idx, 1, 0)
  376. #define F_SMI_BUS_SEL_larb1(mmu_idx) F_VAL(mmu_idx, 3, 2)
  377. #define F_SMI_BUS_SEL_larb2(mmu_idx) F_VAL(mmu_idx, 5, 4)
  378. #define F_SMI_BUS_SEL_larb3(mmu_idx) F_VAL(mmu_idx, 7, 6)
  379. #define F_SMI_BUS_SEL_larb4(mmu_idx) F_VAL(mmu_idx, 9, 8)
  380. #define REG_SMI_WRR_REG0 (0x228+SMI_COMMON_EXT_BASE)
  381. #define REG_SMI_READ_FIFO_TH (0x230+SMI_COMMON_EXT_BASE)
  382. #define REG_SMI_SMI_M4U_TH (0x234+SMI_COMMON_EXT_BASE)
  383. #define REG_SMI_SMI_FIFO2_TH (0x238+SMI_COMMON_EXT_BASE)
  384. #define REG_SMI_SMI_PREULTRA_MASK0 (0x23c+SMI_COMMON_EXT_BASE)
  385. #define REG_SMI_SMI_PREULTRA_MASK1 (0x240+SMI_COMMON_EXT_BASE)
  386. #define REG_SMI_DCM (0x300+SMI_COMMON_EXT_BASE)
  387. #define REG_SMI_SMI_ELA (0x304+SMI_COMMON_EXT_BASE)
  388. #define REG_SMI_DEBUG0 (0x400+SMI_COMMON_EXT_BASE)
  389. #define REG_SMI_DEBUG1 (0x404+SMI_COMMON_EXT_BASE)
  390. #define REG_SMI_DEBUG2 (0x408+SMI_COMMON_EXT_BASE)
  391. #define REG_SMI_DUMMY (0x418+SMI_COMMON_EXT_BASE)
  392. */
  393. #define REG_SMI_M4U_TH (0x234 + SMI_COMMON_EXT_BASE)
  394. #define REG_SMI_L1LEN (0x200 + SMI_COMMON_EXT_BASE)
  395. #define REG_SMI_L1ARB0 (0x204 + SMI_COMMON_EXT_BASE)
  396. #define REG_SMI_L1ARB1 (0x208 + SMI_COMMON_EXT_BASE)
  397. #define REG_SMI_L1ARB2 (0x20C + SMI_COMMON_EXT_BASE)
  398. #define REG_SMI_WRR_REG0 (0x228 + SMI_COMMON_EXT_BASE)
  399. #define REG_SMI_READ_FIFO_TH (0x230 + SMI_COMMON_EXT_BASE)
  400. /* ========================================================================= */
  401. /* peripheral system */
  402. /* ========================================================================= */
  403. #define REG_PERIAXI_BUS_CTL3 (0x208+0xf0003000)
  404. #define F_PERI_MMU_EN(port, en) ((en)<<((port)))
  405. static inline unsigned int M4U_ReadReg32(unsigned long M4uBase, unsigned long Offset)
  406. {
  407. unsigned int val;
  408. val = ioread32((void *)(M4uBase + Offset));
  409. return val;
  410. }
  411. static inline void M4U_WriteReg32(unsigned long M4uBase, unsigned long Offset, unsigned int Val)
  412. {
  413. /* unsigned int read; */
  414. iowrite32(Val, (void *)(M4uBase + Offset));
  415. /* make sure memory manipulation sequence is OK */
  416. mb();
  417. }
  418. static inline unsigned int COM_ReadReg32(unsigned long addr)
  419. {
  420. return ioread32((void *)addr);
  421. }
  422. static inline void COM_WriteReg32(unsigned long addr, unsigned int Val)
  423. {
  424. iowrite32(Val, (void *)addr);
  425. /* make sure memory manipulation sequence is OK */
  426. mb();
  427. }
  428. extern unsigned long smi_reg_base_common_ext;
  429. extern unsigned long smi_reg_base_barb0;
  430. extern unsigned long smi_reg_base_barb1;
  431. #if defined D2
  432. extern unsigned long smi_reg_base_barb2;
  433. #elif defined D1 || defined D3
  434. extern unsigned long smi_reg_base_barb2;
  435. extern unsigned long smi_reg_base_barb3;
  436. #endif
  437. #endif