pati.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. /*
  2. * (C) Copyright 2003
  3. * Denis Peter, d.peter@mpl.ch
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. /************************************************************************
  7. * MACROS and register definitions for PATI Registers
  8. ************************************************************************/
  9. #ifndef __PATI_H_
  10. #define __PATI_H_ 1
  11. #define PLD_PART_ID 0x0
  12. #define PLD_BOARD_TIMING 0x4
  13. #define PLD_CONF_REG1 0x8
  14. #define PLD_CONF_REG2 0xC
  15. #define PLD_CONF_RES 0x10
  16. #define SET_REG_BIT(y,x) (y<<(31-x))
  17. #define GET_REG_BIT(y,x) ((y>>(31-x)) & 0x1L)
  18. /* SDRAM Controller PLD_PART_ID */
  19. /* 9 10 11 12 13 14 19 31 */
  20. #define SDRAM_PART3 9
  21. #define SDRAM_PART2 10
  22. #define SDRAM_PART1 11
  23. #define SDRAM_PART0 12
  24. #define SDRAM_ID3 13
  25. #define SDRAM_ID2 14
  26. #define SDRAM_ID1 19
  27. #define SDRAM_ID0 31
  28. #define SDRAM_PART(x) ( \
  29. (GET_REG_BIT(x,SDRAM_PART3)<<3) |\
  30. (GET_REG_BIT(x,SDRAM_PART2)<<2) |\
  31. (GET_REG_BIT(x,SDRAM_PART1)<<1) |\
  32. (GET_REG_BIT(x,SDRAM_PART0)))
  33. #define SDRAM_ID(x) ( \
  34. (GET_REG_BIT(x,SDRAM_ID3)<<3) |\
  35. (GET_REG_BIT(x,SDRAM_ID2)<<2) |\
  36. (GET_REG_BIT(x,SDRAM_ID1)<<1) |\
  37. (GET_REG_BIT(x,SDRAM_ID0)))
  38. /* System Controller */
  39. /* 0 1 3 4 5 16 20 28 29 30 */
  40. #define SYSCNTR_PART4 0
  41. #define SYSCNTR_PART3 1
  42. #define SYSCNTR_PART2 3
  43. #define SYSCNTR_PART1 4
  44. #define SYSCNTR_PART0 5
  45. #define SYSCNTR_ID4 16
  46. #define SYSCNTR_ID3 20
  47. #define SYSCNTR_ID2 28
  48. #define SYSCNTR_ID1 29
  49. #define SYSCNTR_ID0 30
  50. #define SYSCNTR_PART(x) ( \
  51. (GET_REG_BIT(x,SYSCNTR_PART4)<<4) |\
  52. (GET_REG_BIT(x,SYSCNTR_PART3)<<3) |\
  53. (GET_REG_BIT(x,SYSCNTR_PART2)<<2) |\
  54. (GET_REG_BIT(x,SYSCNTR_PART1)<<1) |\
  55. (GET_REG_BIT(x,SYSCNTR_PART0)))
  56. #define SYSCNTR_ID(x) ( \
  57. (GET_REG_BIT(x,SYSCNTR_ID4)<<4) |\
  58. (GET_REG_BIT(x,SYSCNTR_ID3)<<3) |\
  59. (GET_REG_BIT(x,SYSCNTR_ID2)<<2) |\
  60. (GET_REG_BIT(x,SYSCNTR_ID1)<<1) |\
  61. (GET_REG_BIT(x,SYSCNTR_ID0)))
  62. /* SDRAM Controller PLD_BOARD_TIMING */
  63. /* 9 10 11 12 13 14 19 31 */
  64. #define SDRAM_CAL 9
  65. #define SDRAM_RCD 10
  66. #define SDRAM_WREQ 11
  67. #define SDRAM_PR 12
  68. #define SDRAM_RC 13
  69. #define SDRAM_LMR 14
  70. #define SDRAM_IIP 19
  71. #define SDRAM_RES0 31
  72. /* System Controller */
  73. /* 0 1 3 4 5 16 20 28 29 30 */
  74. #define SYSCNTR_BREV0 0
  75. #define SYSCNTR_BREV1 1
  76. #define SYSCNTR_BREV2 3
  77. #define SYSCNTR_BREV3 4
  78. #define SYSCNTR_RES0 5
  79. #define SYSCNTR_RES1 16
  80. #define SYSCNTR_RES2 20
  81. #define SYSCNTR_FLWAIT2 28
  82. #define SYSCNTR_FLWAIT1 29
  83. #define SYSCNTR_FLWAIT0 30
  84. #define SYSCNTR_BREV(x) ( \
  85. (GET_REG_BIT(x,SYSCNTR_BREV3)<<3) |\
  86. (GET_REG_BIT(x,SYSCNTR_BREV2)<<2) |\
  87. (GET_REG_BIT(x,SYSCNTR_BREV1)<<1) |\
  88. (GET_REG_BIT(x,SYSCNTR_BREV0)))
  89. #define GET_SYSCNTR_FLWAIT(x) ( \
  90. (GET_REG_BIT(x,SYSCNTR_FLWAIT2)<<2) |\
  91. (GET_REG_BIT(x,SYSCNTR_FLWAIT1)<<1) |\
  92. (GET_REG_BIT(x,SYSCNTR_FLWAIT0)))
  93. #define SET_SYSCNTR_FLWAIT(x) ( \
  94. (SET_REG_BIT(((x & 0x04)!=0),SYSCNTR_FLWAIT2)) |\
  95. (SET_REG_BIT(((x & 0x02)!=0)x,SYSCNTR_FLWAIT1)) |\
  96. (SET_REG_BIT(((x & 0x01)!=0)x,SYSCNTR_FLWAIT0)))
  97. /* SDRAM Controller REG 2*/
  98. /* 9 10 11 12 13 14 19 31 */
  99. #define SDRAM_MUX0 9
  100. #define SDRAM_MUX1 10
  101. #define SDRAM_PDIS 11
  102. #define SDRAM_RES1 12
  103. #define SDRAM_RES2 13
  104. #define SDRAM_RES3 14
  105. #define SDRAM_RES4 19
  106. #define SDRAM_RIP 31
  107. #define GET_SDRAM_MUX(x) ( \
  108. (GET_REG_BIT(x,SDRAM_MUX1)<<1)| \
  109. (GET_REG_BIT(x,SDRAM_MUX0)))
  110. /* System Controller */
  111. /* 0 1 3 4 5 16 20 28 29 30 */
  112. #define SYSCNTR_FLAG 0
  113. #define SYSCNTR_IP 1
  114. #define SYSCNTR_BIND2 3
  115. #define SYSCNTR_BIND1 4
  116. #define SYSCNTR_BIND0 5
  117. #define SYSCNTR_PRM 16
  118. #define SYSCNTR_ICW 20
  119. #define SYSCNTR_ISB2 28
  120. #define SYSCNTR_ISB1 29
  121. #define SYSCNTR_ISB0 30
  122. #define GET_SYSCNTR_BOOTIND(x) ( \
  123. (GET_REG_BIT(x,SYSCNTR_BIND2)<<2) |\
  124. (GET_REG_BIT(x,SYSCNTR_BIND1)<<1) |\
  125. (GET_REG_BIT(x,SYSCNTR_BIND0)))
  126. #define SET_SYSCNTR_BOOTIND(x) ( \
  127. (SET_REG_BIT(((x & 0x04)!=0),SYSCNTR_BIND2)) |\
  128. (SET_REG_BIT(((x & 0x02)!=0)x,SYSCNTR_BIND1))| \
  129. (SET_REG_BIT(((x & 0x01)!=0)x,SYSCNTR_BIND0)))
  130. #define GET_SYSCNTR_ISB(x) ( \
  131. (GET_REG_BIT(x,SYSCNTR_ISB2)<<2)| \
  132. (GET_REG_BIT(x,SYSCNTR_ISB1)<<1)| \
  133. (GET_REG_BIT(x,SYSCNTR_ISB0)))
  134. #define SET_SYSCNTR_ISB(x) ( \
  135. (SET_REG_BIT(((x & 0x04)!=0),SYSCNTR_ISB2))| \
  136. (SET_REG_BIT(((x & 0x02)!=0)x,SYSCNTR_ISB))| \
  137. (SET_REG_BIT(((x & 0x01)!=0)x,SYSCNTR_ISB0)))
  138. /* SDRAM Controller REG 3*/
  139. /* 9 10 11 12 13 14 19 31 */
  140. #define SDRAM_RES5 9
  141. #define SDRAM_CFG1 10
  142. #define SDRAM_CFG2 11
  143. #define SDRAM_CFG3 12
  144. #define SDRAM_RES6 13
  145. #define SDRAM_CFG5 14
  146. #define SDRAM_CFG6 19
  147. #define SDRAM_RES7 31
  148. #define GET_SDRAM_CFG(x) ( \
  149. (GET_REG_BIT(x,SDRAM_CFG6)<<4) |\
  150. (GET_REG_BIT(x,SDRAM_CFG5)<<3) |\
  151. (GET_REG_BIT(x,SDRAM_CFG3)<<2) |\
  152. (GET_REG_BIT(x,SDRAM_CFG2)<<1) |\
  153. (GET_REG_BIT(x,SDRAM_CFG1)))
  154. /* System Controller */
  155. /* 0 1 3 4 5 16 20 28 29 30 */
  156. #define SYSCNTR_BDIS 0
  157. #define SYSCNTR_PCIM 1
  158. #define SYSCNTR_CFG0 3
  159. #define SYSCNTR_CFG1 4
  160. #define SYSCNTR_CFG2 5
  161. #define SYSCNTR_CFG3 16
  162. #define SYSCNTR_BOOTEN 20
  163. #define SYSCNTR_CPU_VPP 28
  164. #define SYSCNTR_FL_VPP 29
  165. #define SYSCNTR_FL_WP 30
  166. #define GET_SYSCNTR_CFG(x) ( \
  167. (GET_REG_BIT(x,SYSCNTR_CFG3)<<3)| \
  168. (GET_REG_BIT(x,SYSCNTR_CFG2)<<2)| \
  169. (GET_REG_BIT(x,SYSCNTR_CFG1)<<1)| \
  170. (GET_REG_BIT(x,SYSCNTR_CFG0)))
  171. /***************************************************************
  172. * MISC Defines
  173. ***************************************************************/
  174. #define PCI_VENDOR_ID_MPL 0x18E6
  175. #define PCI_DEVICE_ID_PATI 0x00DA
  176. #if defined(CONFIG_TARGET_MIP405) || defined(CONFIG_TARGET_MIP405T)
  177. #define PATI_FIRMWARE_START_OFFSET 0x00300000
  178. #endif
  179. #define PATI_ENDIAN_MODE 0x3E
  180. /*******************************************
  181. * PATI Mapping:
  182. * -------------
  183. * PCI Map:
  184. * -------
  185. * All addreses are mapped into the memory area
  186. * (IO Area on some areas may also be possible)
  187. * - pci_cfg_mem_base: fixed address to the PLX config area size 512Bytes
  188. * - pci_space0_addr: configurable
  189. * - pci_space1_addr configurable
  190. *
  191. * Local Map:
  192. * ----------
  193. * Local addresses (Remap)
  194. * - SDRAM 0x06000000 Size 16MByte mask 0xff000000
  195. * - EPLD CFG 0x07000000 Size 512Bytes
  196. * - FLASH 0x03000000 Size up to 8MByte
  197. * - CPU 0x01000000 Size 4MByte (only accessable if special configured)
  198. *
  199. * Implemention:
  200. * -------------
  201. * To prevent using large resources reservation on the host following
  202. * PCI mapping is choosed:
  203. * - pci_cfg_mem_base: fixed address to the PLX config area size 512Bytes
  204. * - pci_space0_addr: configured to the EPLD Config Area size 256Bytes
  205. * - pci_space1_addr: configured to the SDRAM Area size 1MBytes, this
  206. * space is used to switch between SDRAM, Flash and CPU
  207. *
  208. */
  209. /* Attribute definitions */
  210. #define PATI_BUS_SIZE_8 0
  211. #define PATI_BUS_SIZE_16 1
  212. #define PATI_BUS_SIZE_32 3
  213. #define PATI_SPACE0_MASK (0xFEFFFE00) /* Mask Attributes */
  214. #define PATI_SPACE1_MASK (0x00000000) /* Mask Attributes */
  215. #define PATI_EXTRA_LONG_EEPROM 1
  216. #define SPACE0_TA_ENABLE (1<<6)
  217. #define SPACE1_TA_ENABLE (1<<6)
  218. /* Config Area */
  219. #define PATI_LOC_CFG_ADDR 0x07000000 /* Local Address */
  220. #define PATI_LOC_CFG_MASK 0xFFFFFF00 /* 256 Bytes */
  221. /* Attributes */
  222. #define PATI_LOC_CFG_BUS_SIZE PATI_BUS_SIZE_32 /* 32 Bit */
  223. #define PATI_LOC_CFG_BURST 0 /* No Burst */
  224. #define PATI_LOC_CFG_NO_PREFETCH 1 /* No Prefetch */
  225. #define PATI_LOC_CFG_TA_ENABLE 1 /* Enable TA */
  226. #define PATI_LOC_CFG_SPACE0_ATTR ( \
  227. PATI_LOC_CFG_BUS_SIZE | \
  228. (PATI_LOC_CFG_TA_ENABLE << 6) | \
  229. (PATI_LOC_CFG_NO_PREFETCH << 8) | \
  230. (PATI_LOC_CFG_BURST << 24) | \
  231. (PATI_EXTRA_LONG_EEPROM << 25))
  232. /* should never be used */
  233. #define PATI_LOC_CFG_SPACE1_ATTR ( \
  234. PATI_LOC_CFG_BUS_SIZE | \
  235. (PATI_LOC_CFG_TA_ENABLE << 6) | \
  236. (PATI_LOC_CFG_NO_PREFETCH << 9) | \
  237. (PATI_LOC_CFG_BURST << 8))
  238. /* SDRAM Area */
  239. #define PATI_LOC_SDRAM_ADDR 0x06000000 /* Local Address */
  240. #define PATI_LOC_SDRAM_MASK 0xFFF00000 /* 1MByte */
  241. /* Attributes */
  242. #define PATI_LOC_SDRAM_BUS_SIZE PATI_BUS_SIZE_32 /* 32 Bit */
  243. #define PATI_LOC_SDRAM_BURST 0 /* No Burst */
  244. #define PATI_LOC_SDRAM_NO_PREFETCH 0 /* Prefetch */
  245. #define PATI_LOC_SDRAM_TA_ENABLE 1 /* Enable TA */
  246. /* should never be used */
  247. #define PATI_LOC_SDRAM_SPACE0_ATTR ( \
  248. PATI_LOC_SDRAM_BUS_SIZE | \
  249. (PATI_LOC_SDRAM_TA_ENABLE << 6) | \
  250. (PATI_LOC_SDRAM_NO_PREFETCH << 8) | \
  251. (PATI_LOC_SDRAM_BURST << 24) | \
  252. (PATI_EXTRA_LONG_EEPROM << 25))
  253. #define PATI_LOC_SDRAM_SPACE1_ATTR ( \
  254. PATI_LOC_SDRAM_BUS_SIZE | \
  255. (PATI_LOC_SDRAM_TA_ENABLE << 6) | \
  256. (PATI_LOC_SDRAM_NO_PREFETCH << 9) | \
  257. (PATI_LOC_SDRAM_BURST << 8))
  258. /* Flash Area */
  259. #define PATI_LOC_FLASH_ADDR 0x03000000 /* Local Address */
  260. #define PATI_LOC_FLASH_MASK 0xFFF00000 /* 1MByte */
  261. /* Attributes */
  262. #define PATI_LOC_FLASH_BUS_SIZE PATI_BUS_SIZE_16 /* 16 Bit */
  263. #define PATI_LOC_FLASH_BURST 0 /* No Burst */
  264. #define PATI_LOC_FLASH_NO_PREFETCH 1 /* No Prefetch */
  265. #define PATI_LOC_FLASH_TA_ENABLE 1 /* Enable TA */
  266. /* should never be used */
  267. #define PATI_LOC_FLASH_SPACE0_ATTR ( \
  268. PATI_LOC_FLASH_BUS_SIZE | \
  269. (PATI_LOC_FLASH_TA_ENABLE << 6) | \
  270. (PATI_LOC_FLASH_NO_PREFETCH << 8) | \
  271. (PATI_LOC_FLASH_BURST << 24) | \
  272. (PATI_EXTRA_LONG_EEPROM << 25))
  273. #define PATI_LOC_FLASH_SPACE1_ATTR ( \
  274. PATI_LOC_FLASH_BUS_SIZE | \
  275. (PATI_LOC_FLASH_TA_ENABLE << 6) | \
  276. (PATI_LOC_FLASH_NO_PREFETCH << 9) | \
  277. (PATI_LOC_FLASH_BURST << 8))
  278. /* CPU Area */
  279. #define PATI_LOC_CPU_ADDR 0x01000000 /* Local Address */
  280. #define PATI_LOC_CPU_MASK 0xFFF00000 /* 1Mbyte */
  281. /* Attributes */
  282. #define PATI_LOC_CPU_BUS_SIZE PATI_BUS_SIZE_32 /* 32 Bit */
  283. #define PATI_LOC_CPU_BURST 0 /* No Burst */
  284. #define PATI_LOC_CPU_NO_PREFETCH 1 /* No Prefetch */
  285. #define PATI_LOC_CPU_TA_ENABLE 1 /* Enable TA */
  286. /* should never be used */
  287. #define PATI_LOC_CPU_SPACE0_ATTR ( \
  288. PATI_LOC_CPU_BUS_SIZE | \
  289. (PATI_LOC_CPU_TA_ENABLE << 6) | \
  290. (PATI_LOC_CPU_NO_PREFETCH << 8) | \
  291. (PATI_LOC_CPU_BURST << 24) | \
  292. (PATI_EXTRA_CPU_EEPROM << 25))
  293. #define PATI_LOC_CPU_SPACE1_ATTR ( \
  294. PATI_LOC_CPU_BUS_SIZE | \
  295. (PATI_LOC_CPU_TA_ENABLE << 6) | \
  296. (PATI_LOC_CPU_NO_PREFETCH << 9) | \
  297. (PATI_LOC_CPU_BURST << 8))
  298. /***************************************************
  299. * Hardware Config word definition
  300. ***************************************************/
  301. #define BOOT_EXT_FLASH 0x00000000
  302. #define BOOT_INT_FLASH 0x00000004
  303. #define BOOT_FROM_PCI 0x00000006
  304. #define BOOT_FROM_SDRAM 0x00000005
  305. #define ENABLE_INT_ARB 0x00000008
  306. #define INITIAL_IRQ_PREF 0x00000010
  307. #define INITIAL_MEM_0M 0x00000000
  308. #define INITIAL_MEM_4M 0x00000080
  309. #define INITIAL_MEM_8M 0x00000040
  310. #define INITIAL_MEM_12M 0x000000C0
  311. #define INITIAL_MEM_16M 0x00000020
  312. #define INITIAL_MEM_20M 0x000000A0
  313. #define INITIAL_MEM_24M 0x00000060
  314. #define INITIAL_MEM_28M 0x000000E0
  315. /* CONF */
  316. #define INTERNAL_HWCONF 0x00000100
  317. /* PRPM */
  318. #define LOCAL_CPU_SLAVE 0x00000200
  319. /* BDIS */
  320. #define DISABLE_MEM_CNTR 0x00000400
  321. /* PCIM */
  322. #define PCI_MASTER_ONLY 0x00000800
  323. #define PATI_HW_START ((BOOT_EXT_FLASH | INITIAL_MEM_28M | INITIAL_IRQ_PREF))
  324. #define PATI_HW_PCI_ONLY ((BOOT_EXT_FLASH | INITIAL_MEM_28M | INITIAL_IRQ_PREF | PCI_MASTER_ONLY))
  325. #define PATI_HW_CPU_ACC ((BOOT_EXT_FLASH | INITIAL_MEM_12M | INITIAL_IRQ_PREF | PCI_MASTER_ONLY))
  326. #define PATI_HW_CPU_SLAVE ((BOOT_EXT_FLASH | INITIAL_MEM_12M | INITIAL_IRQ_PREF | PCI_MASTER_ONLY | LOCAL_CPU_SLAVE))
  327. /***************************************************
  328. * Direct Master Config
  329. ***************************************************/
  330. #define PATI_DMASTER_PCI_ADDR 0x01000000
  331. #define PATI_BUS_MASTER 1
  332. #define PATI_DMASTER_MASK 0xFFF00000 /* 1MByte */
  333. #define PATI_DMASTER_ADDR 0x01000000 /* Local Address */
  334. #define PATI_DMASTER_MEMORY_EN 0x00000001 /* 0x00000001 */
  335. #define PATI_DMASTER_READ_AHEAD 0x00000004 /* 0x00000004 */
  336. #define PATI_DMASTER_READ_NOT_AHEAD 0x00000000 /* 0x00000004 */
  337. #define PATI_DMASTER_PRE_SIZE_CNTRL_0 0x00000000
  338. #define PATI_DMASTER_PRE_SIZE_CNTRL_4 0x00000008
  339. #define PATI_DMASTER_PRE_SIZE_CNTRL_8 0x00001000
  340. #define PATI_DMASTER_PRE_SIZE_CNTRL_16 0x00001008
  341. #define PATI_DMASTER_REL_PCI 0x00000000
  342. #define PATI_DMASTER_NOT_REL_PCI 0x00000010
  343. #define PATI_DMASTER_WR_INVAL 0x00000200
  344. #define PATI_DMASTER_NOT_WR_INVAL 0x00000000
  345. #define PATI_DMASTER_PRE_LIMIT 0x00000800
  346. #define PATI_DMASTER_PRE_CONT 0x00000000
  347. #define PATI_DMASTER_DELAY_WR_0 0x00000000
  348. #define PATI_DMASTER_DELAY_WR_4 0x00004000
  349. #define PATI_DMASTER_DELAY_WR_8 0x00008000
  350. #define PATI_DMASTER_DELAY_WR_16 0x0000C000
  351. #define PATI_DMASTER_PCI_ADDR_MASK 0xFFFF0000
  352. #define PATI_DMASTER_ATTR \
  353. PATI_DMASTER_MEMORY_EN | \
  354. PATI_DMASTER_READ_AHEAD | \
  355. PATI_DMASTER_PRE_SIZE_CNTRL_4 | \
  356. PATI_DMASTER_REL_PCI | \
  357. PATI_DMASTER_NOT_WR_INVAL | \
  358. PATI_DMASTER_PRE_LIMIT | \
  359. PATI_DMASTER_DELAY_WR_0
  360. #endif /* #ifndef __PATI_H_ */