pati.h 13 KB

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