pci-sh7751.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. * Low-Level PCI Support for SH7751 targets
  3. *
  4. * Dustin McIntire (dustin@sensoria.com) (c) 2001
  5. * Paul Mundt (lethal@linux-sh.org) (c) 2003
  6. *
  7. * May be copied or modified under the terms of the GNU General Public
  8. * License. See linux/COPYING for more information.
  9. *
  10. */
  11. #ifndef _PCI_SH7751_H_
  12. #define _PCI_SH7751_H_
  13. #include <linux/pci.h>
  14. /* set debug level 4=verbose...1=terse */
  15. //#define DEBUG_PCI 3
  16. #undef DEBUG_PCI
  17. #ifdef DEBUG_PCI
  18. #define PCIDBG(n, x...) { if(DEBUG_PCI>=n) printk(x); }
  19. #else
  20. #define PCIDBG(n, x...)
  21. #endif
  22. /* startup values */
  23. #define PCI_PROBE_BIOS 1
  24. #define PCI_PROBE_CONF1 2
  25. #define PCI_PROBE_CONF2 4
  26. #define PCI_NO_SORT 0x100
  27. #define PCI_BIOS_SORT 0x200
  28. #define PCI_NO_CHECKS 0x400
  29. #define PCI_ASSIGN_ROMS 0x1000
  30. #define PCI_BIOS_IRQ_SCAN 0x2000
  31. /* Platform Specific Values */
  32. #define SH7751_VENDOR_ID 0x1054
  33. #define SH7751_DEVICE_ID 0x3505
  34. #define SH7751R_DEVICE_ID 0x350e
  35. /* SH7751 Specific Values */
  36. #define SH7751_PCI_CONFIG_BASE 0xFD000000 /* Config space base addr */
  37. #define SH7751_PCI_CONFIG_SIZE 0x1000000 /* Config space size */
  38. #define SH7751_PCI_MEMORY_BASE 0xFD000000 /* Memory space base addr */
  39. #define SH7751_PCI_MEM_SIZE 0x01000000 /* Size of Memory window */
  40. #define SH7751_PCI_IO_BASE 0xFE240000 /* IO space base address */
  41. #define SH7751_PCI_IO_SIZE 0x40000 /* Size of IO window */
  42. #define SH7751_PCIREG_BASE 0xFE200000 /* PCI regs base address */
  43. #define PCI_REG(n) (SH7751_PCIREG_BASE+ n)
  44. #define SH7751_PCICONF0 0x0 /* PCI Config Reg 0 */
  45. #define SH7751_PCICONF0_DEVID 0xFFFF0000 /* Device ID */
  46. #define SH7751_PCICONF0_VNDID 0x0000FFFF /* Vendor ID */
  47. #define SH7751_PCICONF1 0x4 /* PCI Config Reg 1 */
  48. #define SH7751_PCICONF1_DPE 0x80000000 /* Data Parity Error */
  49. #define SH7751_PCICONF1_SSE 0x40000000 /* System Error Status */
  50. #define SH7751_PCICONF1_RMA 0x20000000 /* Master Abort */
  51. #define SH7751_PCICONF1_RTA 0x10000000 /* Target Abort Rx Status */
  52. #define SH7751_PCICONF1_STA 0x08000000 /* Target Abort Exec Status */
  53. #define SH7751_PCICONF1_DEV 0x06000000 /* Timing Status */
  54. #define SH7751_PCICONF1_DPD 0x01000000 /* Data Parity Status */
  55. #define SH7751_PCICONF1_FBBC 0x00800000 /* Back 2 Back Status */
  56. #define SH7751_PCICONF1_UDF 0x00400000 /* User Defined Status */
  57. #define SH7751_PCICONF1_66M 0x00200000 /* 66Mhz Operation Status */
  58. #define SH7751_PCICONF1_PM 0x00100000 /* Power Management Status */
  59. #define SH7751_PCICONF1_PBBE 0x00000200 /* Back 2 Back Control */
  60. #define SH7751_PCICONF1_SER 0x00000100 /* SERR Output Control */
  61. #define SH7751_PCICONF1_WCC 0x00000080 /* Wait Cycle Control */
  62. #define SH7751_PCICONF1_PER 0x00000040 /* Parity Error Response */
  63. #define SH7751_PCICONF1_VPS 0x00000020 /* VGA Pallet Snoop */
  64. #define SH7751_PCICONF1_MWIE 0x00000010 /* Memory Write+Invalidate */
  65. #define SH7751_PCICONF1_SPC 0x00000008 /* Special Cycle Control */
  66. #define SH7751_PCICONF1_BUM 0x00000004 /* Bus Master Control */
  67. #define SH7751_PCICONF1_MES 0x00000002 /* Memory Space Control */
  68. #define SH7751_PCICONF1_IOS 0x00000001 /* I/O Space Control */
  69. #define SH7751_PCICONF2 0x8 /* PCI Config Reg 2 */
  70. #define SH7751_PCICONF2_BCC 0xFF000000 /* Base Class Code */
  71. #define SH7751_PCICONF2_SCC 0x00FF0000 /* Sub-Class Code */
  72. #define SH7751_PCICONF2_RLPI 0x0000FF00 /* Programming Interface */
  73. #define SH7751_PCICONF2_REV 0x000000FF /* Revision ID */
  74. #define SH7751_PCICONF3 0xC /* PCI Config Reg 3 */
  75. #define SH7751_PCICONF3_BIST7 0x80000000 /* Bist Supported */
  76. #define SH7751_PCICONF3_BIST6 0x40000000 /* Bist Executing */
  77. #define SH7751_PCICONF3_BIST3_0 0x0F000000 /* Bist Passed */
  78. #define SH7751_PCICONF3_HD7 0x00800000 /* Single Funtion device */
  79. #define SH7751_PCICONF3_HD6_0 0x007F0000 /* Configuration Layout */
  80. #define SH7751_PCICONF3_LAT 0x0000FF00 /* Latency Timer */
  81. #define SH7751_PCICONF3_CLS 0x000000FF /* Cache Line Size */
  82. #define SH7751_PCICONF4 0x10 /* PCI Config Reg 4 */
  83. #define SH7751_PCICONF4_BASE 0xFFFFFFFC /* I/O Space Base Addr */
  84. #define SH7751_PCICONF4_ASI 0x00000001 /* Address Space Type */
  85. #define SH7751_PCICONF5 0x14 /* PCI Config Reg 5 */
  86. #define SH7751_PCICONF5_BASE 0xFFFFFFF0 /* Mem Space Base Addr */
  87. #define SH7751_PCICONF5_LAP 0x00000008 /* Prefetch Enabled */
  88. #define SH7751_PCICONF5_LAT 0x00000006 /* Local Memory type */
  89. #define SH7751_PCICONF5_ASI 0x00000001 /* Address Space Type */
  90. #define SH7751_PCICONF6 0x18 /* PCI Config Reg 6 */
  91. #define SH7751_PCICONF6_BASE 0xFFFFFFF0 /* Mem Space Base Addr */
  92. #define SH7751_PCICONF6_LAP 0x00000008 /* Prefetch Enabled */
  93. #define SH7751_PCICONF6_LAT 0x00000006 /* Local Memory type */
  94. #define SH7751_PCICONF6_ASI 0x00000001 /* Address Space Type */
  95. /* PCICONF7 - PCICONF10 are undefined */
  96. #define SH7751_PCICONF11 0x2C /* PCI Config Reg 11 */
  97. #define SH7751_PCICONF11_SSID 0xFFFF0000 /* Subsystem ID */
  98. #define SH7751_PCICONF11_SVID 0x0000FFFF /* Subsystem Vendor ID */
  99. /* PCICONF12 is undefined */
  100. #define SH7751_PCICONF13 0x34 /* PCI Config Reg 13 */
  101. #define SH7751_PCICONF13_CPTR 0x000000FF /* PM function pointer */
  102. /* PCICONF14 is undefined */
  103. #define SH7751_PCICONF15 0x3C /* PCI Config Reg 15 */
  104. #define SH7751_PCICONF15_IPIN 0x000000FF /* Interrupt Pin */
  105. #define SH7751_PCICONF16 0x40 /* PCI Config Reg 16 */
  106. #define SH7751_PCICONF16_PMES 0xF8000000 /* PME Support */
  107. #define SH7751_PCICONF16_D2S 0x04000000 /* D2 Support */
  108. #define SH7751_PCICONF16_D1S 0x02000000 /* D1 Support */
  109. #define SH7751_PCICONF16_DSI 0x00200000 /* Bit Device Init. */
  110. #define SH7751_PCICONF16_PMCK 0x00080000 /* Clock for PME req. */
  111. #define SH7751_PCICONF16_VER 0x00070000 /* PM Version */
  112. #define SH7751_PCICONF16_NIP 0x0000FF00 /* Next Item Pointer */
  113. #define SH7751_PCICONF16_CID 0x000000FF /* Capability Identifier */
  114. #define SH7751_PCICONF17 0x44 /* PCI Config Reg 17 */
  115. #define SH7751_PCICONF17_DATA 0xFF000000 /* Data field for PM */
  116. #define SH7751_PCICONF17_PMES 0x00800000 /* PME Status */
  117. #define SH7751_PCICONF17_DSCL 0x00600000 /* Data Scaling Value */
  118. #define SH7751_PCICONF17_DSEL 0x001E0000 /* Data Select */
  119. #define SH7751_PCICONF17_PMEN 0x00010000 /* PME Enable */
  120. #define SH7751_PCICONF17_PWST 0x00000003 /* Power State */
  121. /* SH7715 Internal PCI Registers */
  122. #define SH7751_PCICR 0x100 /* PCI Control Register */
  123. #define SH7751_PCICR_PREFIX 0xA5000000 /* CR prefix for write */
  124. #define SH7751_PCICR_TRSB 0x00000200 /* Target Read Single */
  125. #define SH7751_PCICR_BSWP 0x00000100 /* Target Byte Swap */
  126. #define SH7751_PCICR_PLUP 0x00000080 /* Enable PCI Pullup */
  127. #define SH7751_PCICR_ARBM 0x00000040 /* PCI Arbitration Mode */
  128. #define SH7751_PCICR_MD 0x00000030 /* MD9 and MD10 status */
  129. #define SH7751_PCICR_SERR 0x00000008 /* SERR output assert */
  130. #define SH7751_PCICR_INTA 0x00000004 /* INTA output assert */
  131. #define SH7751_PCICR_PRST 0x00000002 /* PCI Reset Assert */
  132. #define SH7751_PCICR_CFIN 0x00000001 /* Central Fun. Init Done */
  133. #define SH7751_PCILSR0 0x104 /* PCI Local Space Register0 */
  134. #define SH7751_PCILSR1 0x108 /* PCI Local Space Register1 */
  135. #define SH7751_PCILAR0 0x10C /* PCI Local Address Register1 */
  136. #define SH7751_PCILAR1 0x110 /* PCI Local Address Register1 */
  137. #define SH7751_PCIINT 0x114 /* PCI Interrupt Register */
  138. #define SH7751_PCIINT_MLCK 0x00008000 /* Master Lock Error */
  139. #define SH7751_PCIINT_TABT 0x00004000 /* Target Abort Error */
  140. #define SH7751_PCIINT_TRET 0x00000200 /* Target Retry Error */
  141. #define SH7751_PCIINT_MFDE 0x00000100 /* Master Func. Disable Error */
  142. #define SH7751_PCIINT_PRTY 0x00000080 /* Address Parity Error */
  143. #define SH7751_PCIINT_SERR 0x00000040 /* SERR Detection Error */
  144. #define SH7751_PCIINT_TWDP 0x00000020 /* Tgt. Write Parity Error */
  145. #define SH7751_PCIINT_TRDP 0x00000010 /* Tgt. Read Parity Error Det. */
  146. #define SH7751_PCIINT_MTABT 0x00000008 /* Master-Tgt. Abort Error */
  147. #define SH7751_PCIINT_MMABT 0x00000004 /* Master-Master Abort Error */
  148. #define SH7751_PCIINT_MWPD 0x00000002 /* Master Write PERR Detect */
  149. #define SH7751_PCIINT_MRPD 0x00000002 /* Master Read PERR Detect */
  150. #define SH7751_PCIINTM 0x118 /* PCI Interrupt Mask Register */
  151. #define SH7751_PCIALR 0x11C /* Error Address Register */
  152. #define SH7751_PCICLR 0x120 /* Error Command/Data Register */
  153. #define SH7751_PCICLR_MPIO 0x80000000 /* Error Command/Data Register */
  154. #define SH7751_PCICLR_MDMA0 0x40000000 /* DMA0 Transfer Error */
  155. #define SH7751_PCICLR_MDMA1 0x20000000 /* DMA1 Transfer Error */
  156. #define SH7751_PCICLR_MDMA2 0x10000000 /* DMA2 Transfer Error */
  157. #define SH7751_PCICLR_MDMA3 0x08000000 /* DMA3 Transfer Error */
  158. #define SH7751_PCICLR_TGT 0x04000000 /* Target Transfer Error */
  159. #define SH7751_PCICLR_CMDL 0x0000000F /* PCI Command at Error */
  160. #define SH7751_PCIAINT 0x130 /* Arbiter Interrupt Register */
  161. #define SH7751_PCIAINT_MBKN 0x00002000 /* Master Broken Interrupt */
  162. #define SH7751_PCIAINT_TBTO 0x00001000 /* Target Bus Time Out */
  163. #define SH7751_PCIAINT_MBTO 0x00001000 /* Master Bus Time Out */
  164. #define SH7751_PCIAINT_TABT 0x00000008 /* Target Abort */
  165. #define SH7751_PCIAINT_MABT 0x00000004 /* Master Abort */
  166. #define SH7751_PCIAINT_RDPE 0x00000002 /* Read Data Parity Error */
  167. #define SH7751_PCIAINT_WDPE 0x00000002 /* Write Data Parity Error */
  168. #define SH7751_PCIAINTM 0x134 /* Arbiter Int. Mask Register */
  169. #define SH7751_PCIBMLR 0x138 /* Error Bus Master Register */
  170. #define SH7751_PCIBMLR_REQ4 0x00000010 /* REQ4 bus master at error */
  171. #define SH7751_PCIBMLR_REQ3 0x00000008 /* REQ3 bus master at error */
  172. #define SH7751_PCIBMLR_REQ2 0x00000004 /* REQ2 bus master at error */
  173. #define SH7751_PCIBMLR_REQ1 0x00000002 /* REQ1 bus master at error */
  174. #define SH7751_PCIBMLR_REQ0 0x00000001 /* REQ0 bus master at error */
  175. #define SH7751_PCIDMABT 0x140 /* DMA Transfer Arb. Register */
  176. #define SH7751_PCIDMABT_RRBN 0x00000001 /* DMA Arbitor Round-Robin */
  177. #define SH7751_PCIDPA0 0x180 /* DMA0 Transfer Addr. Register */
  178. #define SH7751_PCIDLA0 0x184 /* DMA0 Local Addr. Register */
  179. #define SH7751_PCIDTC0 0x188 /* DMA0 Transfer Cnt. Register */
  180. #define SH7751_PCIDCR0 0x18C /* DMA0 Control Register */
  181. #define SH7751_PCIDCR_ALGN 0x00000600 /* DMA Alignment Mode */
  182. #define SH7751_PCIDCR_MAST 0x00000100 /* DMA Termination Type */
  183. #define SH7751_PCIDCR_INTM 0x00000080 /* DMA Interrupt Done Mask*/
  184. #define SH7751_PCIDCR_INTS 0x00000040 /* DMA Interrupt Done Status */
  185. #define SH7751_PCIDCR_LHLD 0x00000020 /* Local Address Control */
  186. #define SH7751_PCIDCR_PHLD 0x00000010 /* PCI Address Control*/
  187. #define SH7751_PCIDCR_IOSEL 0x00000008 /* PCI Address Space Type */
  188. #define SH7751_PCIDCR_DIR 0x00000004 /* DMA Transfer Direction */
  189. #define SH7751_PCIDCR_STOP 0x00000002 /* Force DMA Stop */
  190. #define SH7751_PCIDCR_STRT 0x00000001 /* DMA Start */
  191. #define SH7751_PCIDPA1 0x190 /* DMA1 Transfer Addr. Register */
  192. #define SH7751_PCIDLA1 0x194 /* DMA1 Local Addr. Register */
  193. #define SH7751_PCIDTC1 0x198 /* DMA1 Transfer Cnt. Register */
  194. #define SH7751_PCIDCR1 0x19C /* DMA1 Control Register */
  195. #define SH7751_PCIDPA2 0x1A0 /* DMA2 Transfer Addr. Register */
  196. #define SH7751_PCIDLA2 0x1A4 /* DMA2 Local Addr. Register */
  197. #define SH7751_PCIDTC2 0x1A8 /* DMA2 Transfer Cnt. Register */
  198. #define SH7751_PCIDCR2 0x1AC /* DMA2 Control Register */
  199. #define SH7751_PCIDPA3 0x1B0 /* DMA3 Transfer Addr. Register */
  200. #define SH7751_PCIDLA3 0x1B4 /* DMA3 Local Addr. Register */
  201. #define SH7751_PCIDTC3 0x1B8 /* DMA3 Transfer Cnt. Register */
  202. #define SH7751_PCIDCR3 0x1BC /* DMA3 Control Register */
  203. #define SH7751_PCIPAR 0x1C0 /* PIO Address Register */
  204. #define SH7751_PCIPAR_CFGEN 0x80000000 /* Configuration Enable */
  205. #define SH7751_PCIPAR_BUSNO 0x00FF0000 /* Config. Bus Number */
  206. #define SH7751_PCIPAR_DEVNO 0x0000FF00 /* Config. Device Number */
  207. #define SH7751_PCIPAR_REGAD 0x000000FC /* Register Address Number */
  208. #define SH7751_PCIMBR 0x1C4 /* Memory Base Address Register */
  209. #define SH7751_PCIMBR_MASK 0xFF000000 /* Memory Space Mask */
  210. #define SH7751_PCIMBR_LOCK 0x00000001 /* Lock Memory Space */
  211. #define SH7751_PCIIOBR 0x1C8 /* I/O Base Address Register */
  212. #define SH7751_PCIIOBR_MASK 0xFFFC0000 /* IO Space Mask */
  213. #define SH7751_PCIIOBR_LOCK 0x00000001 /* Lock IO Space */
  214. #define SH7751_PCIPINT 0x1CC /* Power Mgmnt Int. Register */
  215. #define SH7751_PCIPINT_D3 0x00000002 /* D3 Pwr Mgmt. Interrupt */
  216. #define SH7751_PCIPINT_D0 0x00000001 /* D0 Pwr Mgmt. Interrupt */
  217. #define SH7751_PCIPINTM 0x1D0 /* Power Mgmnt Mask Register */
  218. #define SH7751_PCICLKR 0x1D4 /* Clock Ctrl. Register */
  219. #define SH7751_PCICLKR_PCSTP 0x00000002 /* PCI Clock Stop */
  220. #define SH7751_PCICLKR_BCSTP 0x00000002 /* BCLK Clock Stop */
  221. /* For definitions of BCR, MCR see ... */
  222. #define SH7751_PCIBCR1 0x1E0 /* Memory BCR1 Register */
  223. #define SH7751_PCIBCR2 0x1E4 /* Memory BCR2 Register */
  224. #define SH7751_PCIWCR1 0x1E8 /* Wait Control 1 Register */
  225. #define SH7751_PCIWCR2 0x1EC /* Wait Control 2 Register */
  226. #define SH7751_PCIWCR3 0x1F0 /* Wait Control 3 Register */
  227. #define SH7751_PCIMCR 0x1F4 /* Memory Control Register */
  228. #define SH7751_PCIBCR3 0x1f8 /* Memory BCR3 Register */
  229. #define SH7751_PCIPCTR 0x200 /* Port Control Register */
  230. #define SH7751_PCIPCTR_P2EN 0x000400000 /* Port 2 Enable */
  231. #define SH7751_PCIPCTR_P1EN 0x000200000 /* Port 1 Enable */
  232. #define SH7751_PCIPCTR_P0EN 0x000100000 /* Port 0 Enable */
  233. #define SH7751_PCIPCTR_P2UP 0x000000020 /* Port2 Pull Up Enable */
  234. #define SH7751_PCIPCTR_P2IO 0x000000010 /* Port2 Output Enable */
  235. #define SH7751_PCIPCTR_P1UP 0x000000008 /* Port1 Pull Up Enable */
  236. #define SH7751_PCIPCTR_P1IO 0x000000004 /* Port1 Output Enable */
  237. #define SH7751_PCIPCTR_P0UP 0x000000002 /* Port0 Pull Up Enable */
  238. #define SH7751_PCIPCTR_P0IO 0x000000001 /* Port0 Output Enable */
  239. #define SH7751_PCIPDTR 0x204 /* Port Data Register */
  240. #define SH7751_PCIPDTR_PB5 0x000000020 /* Port 5 Enable */
  241. #define SH7751_PCIPDTR_PB4 0x000000010 /* Port 4 Enable */
  242. #define SH7751_PCIPDTR_PB3 0x000000008 /* Port 3 Enable */
  243. #define SH7751_PCIPDTR_PB2 0x000000004 /* Port 2 Enable */
  244. #define SH7751_PCIPDTR_PB1 0x000000002 /* Port 1 Enable */
  245. #define SH7751_PCIPDTR_PB0 0x000000001 /* Port 0 Enable */
  246. #define SH7751_PCIPDR 0x220 /* Port IO Data Register */
  247. /* Memory Control Registers */
  248. #define SH7751_BCR1 0xFF800000 /* Memory BCR1 Register */
  249. #define SH7751_BCR2 0xFF800004 /* Memory BCR2 Register */
  250. #define SH7751_BCR3 0xFF800050 /* Memory BCR3 Register */
  251. #define SH7751_BCR4 0xFE0A00F0 /* Memory BCR4 Register */
  252. #define SH7751_WCR1 0xFF800008 /* Wait Control 1 Register */
  253. #define SH7751_WCR2 0xFF80000C /* Wait Control 2 Register */
  254. #define SH7751_WCR3 0xFF800010 /* Wait Control 3 Register */
  255. #define SH7751_MCR 0xFF800014 /* Memory Control Register */
  256. /* General Memory Config Addresses */
  257. #define SH7751_CS0_BASE_ADDR 0x0
  258. #define SH7751_MEM_REGION_SIZE 0x04000000
  259. #define SH7751_CS1_BASE_ADDR (SH7751_CS0_BASE_ADDR + SH7751_MEM_REGION_SIZE)
  260. #define SH7751_CS2_BASE_ADDR (SH7751_CS1_BASE_ADDR + SH7751_MEM_REGION_SIZE)
  261. #define SH7751_CS3_BASE_ADDR (SH7751_CS2_BASE_ADDR + SH7751_MEM_REGION_SIZE)
  262. #define SH7751_CS4_BASE_ADDR (SH7751_CS3_BASE_ADDR + SH7751_MEM_REGION_SIZE)
  263. #define SH7751_CS5_BASE_ADDR (SH7751_CS4_BASE_ADDR + SH7751_MEM_REGION_SIZE)
  264. #define SH7751_CS6_BASE_ADDR (SH7751_CS5_BASE_ADDR + SH7751_MEM_REGION_SIZE)
  265. /* General PCI values */
  266. #define SH7751_PCI_HOST_BRIDGE 0x6
  267. /* Flags */
  268. #define SH7751_PCIC_NO_RESET 0x0001
  269. /* External functions defined per platform i.e. Big Sur, SE... (these could be routed
  270. * through the machine vectors... */
  271. extern int pcibios_init_platform(void);
  272. extern int pcibios_map_platform_irq(u8 slot, u8 pin);
  273. struct sh7751_pci_address_space {
  274. unsigned long base;
  275. unsigned long size;
  276. };
  277. struct sh7751_pci_address_map {
  278. struct sh7751_pci_address_space window0;
  279. struct sh7751_pci_address_space window1;
  280. unsigned long flags;
  281. };
  282. /* arch/sh/drivers/pci/pci-sh7751.c */
  283. extern int sh7751_pcic_init(struct sh7751_pci_address_map *map);
  284. #endif /* _PCI_SH7751_H_ */