ddb5xxx.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*
  2. * Copyright 2001 MontaVista Software Inc.
  3. * Author: jsun@mvista.com or jsun@junsun.net
  4. *
  5. * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
  6. * Sony Software Development Center Europe (SDCE), Brussels
  7. *
  8. * include/asm-mips/ddb5xxx/ddb5xxx.h
  9. * Common header for all NEC DDB 5xxx boards, including 5074, 5476, 5477.
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2 of the License, or (at your
  14. * option) any later version.
  15. *
  16. */
  17. #ifndef __ASM_DDB5XXX_DDB5XXX_H
  18. #define __ASM_DDB5XXX_DDB5XXX_H
  19. #include <linux/config.h>
  20. #include <linux/types.h>
  21. /*
  22. * This file is based on the following documentation:
  23. *
  24. * NEC Vrc 5074 System Controller Data Sheet, June 1998
  25. *
  26. * [jsun] It is modified so that this file only contains the macros
  27. * that are true for all DDB 5xxx boards. The modification is based on
  28. *
  29. * uPD31577(VRC5477) VR5432-SDRAM/PCI Bridge (Luke)
  30. * Preliminary Specification Decoment, Rev 1.1, 27 Dec, 2000
  31. *
  32. */
  33. #define DDB_BASE 0xbfa00000
  34. #define DDB_SIZE 0x00200000 /* 2 MB */
  35. /*
  36. * Physical Device Address Registers (PDARs)
  37. */
  38. #define DDB_SDRAM0 0x0000 /* SDRAM Bank 0 [R/W] */
  39. #define DDB_SDRAM1 0x0008 /* SDRAM Bank 1 [R/W] */
  40. #define DDB_DCS2 0x0010 /* Device Chip-Select 2 [R/W] */
  41. #define DDB_DCS3 0x0018 /* Device Chip-Select 3 [R/W] */
  42. #define DDB_DCS4 0x0020 /* Device Chip-Select 4 [R/W] */
  43. #define DDB_DCS5 0x0028 /* Device Chip-Select 5 [R/W] */
  44. #define DDB_DCS6 0x0030 /* Device Chip-Select 6 [R/W] */
  45. #define DDB_DCS7 0x0038 /* Device Chip-Select 7 [R/W] */
  46. #define DDB_DCS8 0x0040 /* Device Chip-Select 8 [R/W] */
  47. #define DDB_PCIW0 0x0060 /* PCI Address Window 0 [R/W] */
  48. #define DDB_PCIW1 0x0068 /* PCI Address Window 1 [R/W] */
  49. #define DDB_INTCS 0x0070 /* Controller Internal Registers and Devices */
  50. /* [R/W] */
  51. #define DDB_BOOTCS 0x0078 /* Boot ROM Chip-Select [R/W] */
  52. /* Vrc5477 has two more, IOPCIW0, IOPCIW1 */
  53. /*
  54. * CPU Interface Registers
  55. */
  56. #define DDB_CPUSTAT 0x0080 /* CPU Status [R/W] */
  57. #define DDB_INTCTRL 0x0088 /* Interrupt Control [R/W] */
  58. #define DDB_INTSTAT0 0x0090 /* Interrupt Status 0 [R] */
  59. #define DDB_INTSTAT1 0x0098 /* Interrupt Status 1 and CPU Interrupt */
  60. /* Enable [R/W] */
  61. #define DDB_INTCLR 0x00A0 /* Interrupt Clear [R/W] */
  62. #define DDB_INTPPES 0x00A8 /* PCI Interrupt Control [R/W] */
  63. /*
  64. * Memory-Interface Registers
  65. */
  66. #define DDB_MEMCTRL 0x00C0 /* Memory Control */
  67. #define DDB_ACSTIME 0x00C8 /* Memory Access Timing [R/W] */
  68. #define DDB_CHKERR 0x00D0 /* Memory Check Error Status [R] */
  69. /*
  70. * PCI-Bus Registers
  71. */
  72. #define DDB_PCICTRL 0x00E0 /* PCI Control [R/W] */
  73. #define DDB_PCIARB 0x00E8 /* PCI Arbiter [R/W] */
  74. #define DDB_PCIINIT0 0x00F0 /* PCI Master (Initiator) 0 [R/W] */
  75. #define DDB_PCIINIT1 0x00F8 /* PCI Master (Initiator) 1 [R/W] */
  76. #define DDB_PCIERR 0x00B8 /* PCI Error [R/W] */
  77. /*
  78. * Local-Bus Registers
  79. */
  80. #define DDB_LCNFG 0x0100 /* Local Bus Configuration [R/W] */
  81. #define DDB_LCST2 0x0110 /* Local Bus Chip-Select Timing 2 [R/W] */
  82. #define DDB_LCST3 0x0118 /* Local Bus Chip-Select Timing 3 [R/W] */
  83. #define DDB_LCST4 0x0120 /* Local Bus Chip-Select Timing 4 [R/W] */
  84. #define DDB_LCST5 0x0128 /* Local Bus Chip-Select Timing 5 [R/W] */
  85. #define DDB_LCST6 0x0130 /* Local Bus Chip-Select Timing 6 [R/W] */
  86. #define DDB_LCST7 0x0138 /* Local Bus Chip-Select Timing 7 [R/W] */
  87. #define DDB_LCST8 0x0140 /* Local Bus Chip-Select Timing 8 [R/W] */
  88. #define DDB_DCSFN 0x0150 /* Device Chip-Select Muxing and Output */
  89. /* Enables [R/W] */
  90. #define DDB_DCSIO 0x0158 /* Device Chip-Selects As I/O Bits [R/W] */
  91. #define DDB_BCST 0x0178 /* Local Boot Chip-Select Timing [R/W] */
  92. /*
  93. * DMA Registers
  94. */
  95. #define DDB_DMACTRL0 0x0180 /* DMA Control 0 [R/W] */
  96. #define DDB_DMASRCA0 0x0188 /* DMA Source Address 0 [R/W] */
  97. #define DDB_DMADESA0 0x0190 /* DMA Destination Address 0 [R/W] */
  98. #define DDB_DMACTRL1 0x0198 /* DMA Control 1 [R/W] */
  99. #define DDB_DMASRCA1 0x01A0 /* DMA Source Address 1 [R/W] */
  100. #define DDB_DMADESA1 0x01A8 /* DMA Destination Address 1 [R/W] */
  101. /*
  102. * Timer Registers
  103. */
  104. #define DDB_T0CTRL 0x01C0 /* SDRAM Refresh Control [R/W] */
  105. #define DDB_T0CNTR 0x01C8 /* SDRAM Refresh Counter [R/W] */
  106. #define DDB_T1CTRL 0x01D0 /* CPU-Bus Read Time-Out Control [R/W] */
  107. #define DDB_T1CNTR 0x01D8 /* CPU-Bus Read Time-Out Counter [R/W] */
  108. #define DDB_T2CTRL 0x01E0 /* General-Purpose Timer Control [R/W] */
  109. #define DDB_T2CNTR 0x01E8 /* General-Purpose Timer Counter [R/W] */
  110. #define DDB_T3CTRL 0x01F0 /* Watchdog Timer Control [R/W] */
  111. #define DDB_T3CNTR 0x01F8 /* Watchdog Timer Counter [R/W] */
  112. /*
  113. * PCI Configuration Space Registers
  114. */
  115. #define DDB_PCI_BASE 0x0200
  116. #define DDB_VID 0x0200 /* PCI Vendor ID [R] */
  117. #define DDB_DID 0x0202 /* PCI Device ID [R] */
  118. #define DDB_PCICMD 0x0204 /* PCI Command [R/W] */
  119. #define DDB_PCISTS 0x0206 /* PCI Status [R/W] */
  120. #define DDB_REVID 0x0208 /* PCI Revision ID [R] */
  121. #define DDB_CLASS 0x0209 /* PCI Class Code [R] */
  122. #define DDB_CLSIZ 0x020C /* PCI Cache Line Size [R/W] */
  123. #define DDB_MLTIM 0x020D /* PCI Latency Timer [R/W] */
  124. #define DDB_HTYPE 0x020E /* PCI Header Type [R] */
  125. #define DDB_BIST 0x020F /* BIST [R] (unimplemented) */
  126. #define DDB_BARC 0x0210 /* PCI Base Address Register Control [R/W] */
  127. #define DDB_BAR0 0x0218 /* PCI Base Address Register 0 [R/W] */
  128. #define DDB_BAR1 0x0220 /* PCI Base Address Register 1 [R/W] */
  129. #define DDB_CIS 0x0228 /* PCI Cardbus CIS Pointer [R] */
  130. /* (unimplemented) */
  131. #define DDB_SSVID 0x022C /* PCI Sub-System Vendor ID [R/W] */
  132. #define DDB_SSID 0x022E /* PCI Sub-System ID [R/W] */
  133. #define DDB_ROM 0x0230 /* Expansion ROM Base Address [R] */
  134. /* (unimplemented) */
  135. #define DDB_INTLIN 0x023C /* PCI Interrupt Line [R/W] */
  136. #define DDB_INTPIN 0x023D /* PCI Interrupt Pin [R] */
  137. #define DDB_MINGNT 0x023E /* PCI Min_Gnt [R] (unimplemented) */
  138. #define DDB_MAXLAT 0x023F /* PCI Max_Lat [R] (unimplemented) */
  139. #define DDB_BAR2 0x0240 /* PCI Base Address Register 2 [R/W] */
  140. #define DDB_BAR3 0x0248 /* PCI Base Address Register 3 [R/W] */
  141. #define DDB_BAR4 0x0250 /* PCI Base Address Register 4 [R/W] */
  142. #define DDB_BAR5 0x0258 /* PCI Base Address Register 5 [R/W] */
  143. #define DDB_BAR6 0x0260 /* PCI Base Address Register 6 [R/W] */
  144. #define DDB_BAR7 0x0268 /* PCI Base Address Register 7 [R/W] */
  145. #define DDB_BAR8 0x0270 /* PCI Base Address Register 8 [R/W] */
  146. #define DDB_BARB 0x0278 /* PCI Base Address Register BOOT [R/W] */
  147. /*
  148. * Nile 4 Register Access
  149. */
  150. static inline void ddb_sync(void)
  151. {
  152. /* The DDB5074 doesn't seem to like these accesses. They kill the board on
  153. * interrupt load
  154. */
  155. #ifndef CONFIG_DDB5074
  156. volatile u32 *p = (volatile u32 *)0xbfc00000;
  157. (void)(*p);
  158. #endif
  159. }
  160. static inline void ddb_out32(u32 offset, u32 val)
  161. {
  162. *(volatile u32 *)(DDB_BASE+offset) = val;
  163. ddb_sync();
  164. }
  165. static inline u32 ddb_in32(u32 offset)
  166. {
  167. u32 val = *(volatile u32 *)(DDB_BASE+offset);
  168. ddb_sync();
  169. return val;
  170. }
  171. static inline void ddb_out16(u32 offset, u16 val)
  172. {
  173. *(volatile u16 *)(DDB_BASE+offset) = val;
  174. ddb_sync();
  175. }
  176. static inline u16 ddb_in16(u32 offset)
  177. {
  178. u16 val = *(volatile u16 *)(DDB_BASE+offset);
  179. ddb_sync();
  180. return val;
  181. }
  182. static inline void ddb_out8(u32 offset, u8 val)
  183. {
  184. *(volatile u8 *)(DDB_BASE+offset) = val;
  185. ddb_sync();
  186. }
  187. static inline u8 ddb_in8(u32 offset)
  188. {
  189. u8 val = *(volatile u8 *)(DDB_BASE+offset);
  190. ddb_sync();
  191. return val;
  192. }
  193. /*
  194. * Physical Device Address Registers
  195. */
  196. extern u32
  197. ddb_calc_pdar(u32 phys, u32 size, int width, int on_memory_bus, int pci_visible);
  198. extern void
  199. ddb_set_pdar(u32 pdar, u32 phys, u32 size, int width,
  200. int on_memory_bus, int pci_visible);
  201. /*
  202. * PCI Master Registers
  203. */
  204. #define DDB_PCICMD_IACK 0 /* PCI Interrupt Acknowledge */
  205. #define DDB_PCICMD_IO 1 /* PCI I/O Space */
  206. #define DDB_PCICMD_MEM 3 /* PCI Memory Space */
  207. #define DDB_PCICMD_CFG 5 /* PCI Configuration Space */
  208. /*
  209. * additional options for pci init reg (no shifting needed)
  210. */
  211. #define DDB_PCI_CFGTYPE1 0x200 /* for pci init0/1 regs */
  212. #define DDB_PCI_ACCESS_32 0x10 /* for pci init0/1 regs */
  213. extern void ddb_set_pmr(u32 pmr, u32 type, u32 addr, u32 options);
  214. /*
  215. * we need to reset pci bus when we start up and shutdown
  216. */
  217. extern void ddb_pci_reset_bus(void);
  218. /*
  219. * include the board dependent part
  220. */
  221. #if defined(CONFIG_DDB5074)
  222. #include <asm/ddb5xxx/ddb5074.h>
  223. #elif defined(CONFIG_DDB5476)
  224. #include <asm/ddb5xxx/ddb5476.h>
  225. #elif defined(CONFIG_DDB5477)
  226. #include <asm/ddb5xxx/ddb5477.h>
  227. #else
  228. #error "Unknown DDB board!"
  229. #endif
  230. #endif /* __ASM_DDB5XXX_DDB5XXX_H */