addrs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Derived from IRIX <sys/SN/SN0/addrs.h>, revision 1.126.
  7. *
  8. * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
  9. * Copyright (C) 1999 by Ralf Baechle
  10. */
  11. #ifndef _ASM_SN_SN0_ADDRS_H
  12. #define _ASM_SN_SN0_ADDRS_H
  13. #include <linux/config.h>
  14. /*
  15. * SN0 (on a T5) Address map
  16. *
  17. * This file contains a set of definitions and macros which are used
  18. * to reference into the major address spaces (CAC, HSPEC, IO, MSPEC,
  19. * and UNCAC) used by the SN0 architecture. It also contains addresses
  20. * for "major" statically locatable PROM/Kernel data structures, such as
  21. * the partition table, the configuration data structure, etc.
  22. * We make an implicit assumption that the processor using this file
  23. * follows the R10K's provisions for specifying uncached attributes;
  24. * should this change, the base registers may very well become processor-
  25. * dependent.
  26. *
  27. * For more information on the address spaces, see the "Local Resources"
  28. * chapter of the Hub specification.
  29. *
  30. * NOTE: This header file is included both by C and by assembler source
  31. * files. Please bracket any language-dependent definitions
  32. * appropriately.
  33. */
  34. /*
  35. * Some of the macros here need to be casted to appropriate types when used
  36. * from C. They definitely must not be casted from assembly language so we
  37. * use some new ANSI preprocessor stuff to paste these on where needed.
  38. */
  39. /*
  40. * The following couple of definitions will eventually need to be variables,
  41. * since the amount of address space assigned to each node depends on
  42. * whether the system is running in N-mode (more nodes with less memory)
  43. * or M-mode (fewer nodes with more memory). We expect that it will
  44. * be a while before we need to make this decision dynamically, though,
  45. * so for now we just use defines bracketed by an ifdef.
  46. */
  47. #ifdef CONFIG_SGI_SN0_N_MODE
  48. #define NODE_SIZE_BITS 31
  49. #define BWIN_SIZE_BITS 28
  50. #define NASID_BITS 9
  51. #define NASID_BITMASK (0x1ffLL)
  52. #define NASID_SHFT 31
  53. #define NASID_META_BITS 5
  54. #define NASID_LOCAL_BITS 4
  55. #define BDDIR_UPPER_MASK (UINT64_CAST 0x7ffff << 10)
  56. #define BDECC_UPPER_MASK (UINT64_CAST 0x3ffffff << 3)
  57. #else /* !defined(CONFIG_SGI_SN0_N_MODE), assume that M-mode is desired */
  58. #define NODE_SIZE_BITS 32
  59. #define BWIN_SIZE_BITS 29
  60. #define NASID_BITMASK (0xffLL)
  61. #define NASID_BITS 8
  62. #define NASID_SHFT 32
  63. #define NASID_META_BITS 4
  64. #define NASID_LOCAL_BITS 4
  65. #define BDDIR_UPPER_MASK (UINT64_CAST 0xfffff << 10)
  66. #define BDECC_UPPER_MASK (UINT64_CAST 0x7ffffff << 3)
  67. #endif /* !defined(CONFIG_SGI_SN0_N_MODE) */
  68. #define NODE_ADDRSPACE_SIZE (UINT64_CAST 1 << NODE_SIZE_BITS)
  69. #define NASID_MASK (UINT64_CAST NASID_BITMASK << NASID_SHFT)
  70. #define NASID_GET(_pa) (int) ((UINT64_CAST (_pa) >> \
  71. NASID_SHFT) & NASID_BITMASK)
  72. #if !defined(__ASSEMBLY__) && !defined(_STANDALONE)
  73. #define NODE_SWIN_BASE(nasid, widget) \
  74. ((widget == 0) ? NODE_BWIN_BASE((nasid), SWIN0_BIGWIN) \
  75. : RAW_NODE_SWIN_BASE(nasid, widget))
  76. #else /* __ASSEMBLY__ || _STANDALONE */
  77. #define NODE_SWIN_BASE(nasid, widget) \
  78. (NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS))
  79. #endif /* __ASSEMBLY__ || _STANDALONE */
  80. /*
  81. * The following definitions pertain to the IO special address
  82. * space. They define the location of the big and little windows
  83. * of any given node.
  84. */
  85. #define BWIN_INDEX_BITS 3
  86. #define BWIN_SIZE (UINT64_CAST 1 << BWIN_SIZE_BITS)
  87. #define BWIN_SIZEMASK (BWIN_SIZE - 1)
  88. #define BWIN_WIDGET_MASK 0x7
  89. #define NODE_BWIN_BASE0(nasid) (NODE_IO_BASE(nasid) + BWIN_SIZE)
  90. #define NODE_BWIN_BASE(nasid, bigwin) (NODE_BWIN_BASE0(nasid) + \
  91. (UINT64_CAST (bigwin) << BWIN_SIZE_BITS))
  92. #define BWIN_WIDGETADDR(addr) ((addr) & BWIN_SIZEMASK)
  93. #define BWIN_WINDOWNUM(addr) (((addr) >> BWIN_SIZE_BITS) & BWIN_WIDGET_MASK)
  94. /*
  95. * Verify if addr belongs to large window address of node with "nasid"
  96. *
  97. *
  98. * NOTE: "addr" is expected to be XKPHYS address, and NOT physical
  99. * address
  100. *
  101. *
  102. */
  103. #define NODE_BWIN_ADDR(nasid, addr) \
  104. (((addr) >= NODE_BWIN_BASE0(nasid)) && \
  105. ((addr) < (NODE_BWIN_BASE(nasid, HUB_NUM_BIG_WINDOW) + \
  106. BWIN_SIZE)))
  107. /*
  108. * The following define the major position-independent aliases used
  109. * in SN0.
  110. * CALIAS -- Varies in size, points to the first n bytes of memory
  111. * on the reader's node.
  112. */
  113. #define CALIAS_BASE CAC_BASE
  114. #define BRIDGE_REG_PTR(_base, _off) ((volatile bridgereg_t *) \
  115. ((__psunsigned_t)(_base) + (__psunsigned_t)(_off)))
  116. #define SN0_WIDGET_BASE(_nasid, _wid) (NODE_SWIN_BASE((_nasid), (_wid)))
  117. /* Turn on sable logging for the processors whose bits are set. */
  118. #ifdef SABLE
  119. #define SABLE_LOG_TRIGGER(_map) \
  120. *((volatile hubreg_t *)(IO_BASE + 0x17ffff0)) = (_map)
  121. #else
  122. #define SABLE_LOG_TRIGGER(_map)
  123. #endif /* SABLE */
  124. #ifndef __ASSEMBLY__
  125. #define KERN_NMI_ADDR(nasid, slice) \
  126. TO_NODE_UNCAC((nasid), IP27_NMI_KREGS_OFFSET + \
  127. (IP27_NMI_KREGS_CPU_SIZE * (slice)))
  128. #endif /* !__ASSEMBLY__ */
  129. #ifdef PROM
  130. #define MISC_PROM_BASE PHYS_TO_K0(0x01300000)
  131. #define MISC_PROM_SIZE 0x200000
  132. #define DIAG_BASE PHYS_TO_K0(0x01500000)
  133. #define DIAG_SIZE 0x300000
  134. #define ROUTE_BASE PHYS_TO_K0(0x01800000)
  135. #define ROUTE_SIZE 0x200000
  136. #define IP27PROM_FLASH_HDR PHYS_TO_K0(0x01300000)
  137. #define IP27PROM_FLASH_DATA PHYS_TO_K0(0x01301000)
  138. #define IP27PROM_CORP_MAX 32
  139. #define IP27PROM_CORP PHYS_TO_K0(0x01800000)
  140. #define IP27PROM_CORP_SIZE 0x10000
  141. #define IP27PROM_CORP_STK PHYS_TO_K0(0x01810000)
  142. #define IP27PROM_CORP_STKSIZE 0x2000
  143. #define IP27PROM_DECOMP_BUF PHYS_TO_K0(0x01900000)
  144. #define IP27PROM_DECOMP_SIZE 0xfff00
  145. #define IP27PROM_BASE PHYS_TO_K0(0x01a00000)
  146. #define IP27PROM_BASE_MAPPED (UNCAC_BASE | 0x1fc00000)
  147. #define IP27PROM_SIZE_MAX 0x100000
  148. #define IP27PROM_PCFG PHYS_TO_K0(0x01b00000)
  149. #define IP27PROM_PCFG_SIZE 0xd0000
  150. #define IP27PROM_ERRDMP PHYS_TO_K1(0x01bd0000)
  151. #define IP27PROM_ERRDMP_SIZE 0xf000
  152. #define IP27PROM_INIT_START PHYS_TO_K1(0x01bd0000)
  153. #define IP27PROM_CONSOLE PHYS_TO_K1(0x01bdf000)
  154. #define IP27PROM_CONSOLE_SIZE 0x200
  155. #define IP27PROM_NETUART PHYS_TO_K1(0x01bdf200)
  156. #define IP27PROM_NETUART_SIZE 0x100
  157. #define IP27PROM_UNUSED1 PHYS_TO_K1(0x01bdf300)
  158. #define IP27PROM_UNUSED1_SIZE 0x500
  159. #define IP27PROM_ELSC_BASE_A PHYS_TO_K0(0x01bdf800)
  160. #define IP27PROM_ELSC_BASE_B PHYS_TO_K0(0x01bdfc00)
  161. #define IP27PROM_STACK_A PHYS_TO_K0(0x01be0000)
  162. #define IP27PROM_STACK_B PHYS_TO_K0(0x01bf0000)
  163. #define IP27PROM_STACK_SHFT 16
  164. #define IP27PROM_STACK_SIZE (1 << IP27PROM_STACK_SHFT)
  165. #define IP27PROM_INIT_END PHYS_TO_K0(0x01c00000)
  166. #define SLAVESTACK_BASE PHYS_TO_K0(0x01580000)
  167. #define SLAVESTACK_SIZE 0x40000
  168. #define ENETBUFS_BASE PHYS_TO_K0(0x01f80000)
  169. #define ENETBUFS_SIZE 0x20000
  170. #define IO6PROM_BASE PHYS_TO_K0(0x01c00000)
  171. #define IO6PROM_SIZE 0x400000
  172. #define IO6PROM_BASE_MAPPED (UNCAC_BASE | 0x11c00000)
  173. #define IO6DPROM_BASE PHYS_TO_K0(0x01c00000)
  174. #define IO6DPROM_SIZE 0x200000
  175. #define NODEBUGUNIX_ADDR PHYS_TO_K0(0x00019000)
  176. #define DEBUGUNIX_ADDR PHYS_TO_K0(0x00100000)
  177. #define IP27PROM_INT_LAUNCH 10 /* and 11 */
  178. #define IP27PROM_INT_NETUART 12 /* through 17 */
  179. #endif /* PROM */
  180. /*
  181. * needed by symmon so it needs to be outside #if PROM
  182. */
  183. #define IP27PROM_ELSC_SHFT 10
  184. #define IP27PROM_ELSC_SIZE (1 << IP27PROM_ELSC_SHFT)
  185. /*
  186. * This address is used by IO6PROM to build MemoryDescriptors of
  187. * free memory. This address is important since unix gets loaded
  188. * at this address, and this memory has to be FREE if unix is to
  189. * be loaded.
  190. */
  191. #define FREEMEM_BASE PHYS_TO_K0(0x2000000)
  192. #define IO6PROM_STACK_SHFT 14 /* stack per cpu */
  193. #define IO6PROM_STACK_SIZE (1 << IO6PROM_STACK_SHFT)
  194. /*
  195. * IP27 PROM vectors
  196. */
  197. #define IP27PROM_ENTRY PHYS_TO_COMPATK1(0x1fc00000)
  198. #define IP27PROM_RESTART PHYS_TO_COMPATK1(0x1fc00008)
  199. #define IP27PROM_SLAVELOOP PHYS_TO_COMPATK1(0x1fc00010)
  200. #define IP27PROM_PODMODE PHYS_TO_COMPATK1(0x1fc00018)
  201. #define IP27PROM_IOC3UARTPOD PHYS_TO_COMPATK1(0x1fc00020)
  202. #define IP27PROM_FLASHLEDS PHYS_TO_COMPATK1(0x1fc00028)
  203. #define IP27PROM_REPOD PHYS_TO_COMPATK1(0x1fc00030)
  204. #define IP27PROM_LAUNCHSLAVE PHYS_TO_COMPATK1(0x1fc00038)
  205. #define IP27PROM_WAITSLAVE PHYS_TO_COMPATK1(0x1fc00040)
  206. #define IP27PROM_POLLSLAVE PHYS_TO_COMPATK1(0x1fc00048)
  207. #define KL_UART_BASE LOCAL_HUB_ADDR(MD_UREG0_0) /* base of UART regs */
  208. #define KL_UART_CMD LOCAL_HUB_ADDR(MD_UREG0_0) /* UART command reg */
  209. #define KL_UART_DATA LOCAL_HUB_ADDR(MD_UREG0_1) /* UART data reg */
  210. #define KL_I2C_REG MD_UREG0_0 /* I2C reg */
  211. #ifndef __ASSEMBLY__
  212. /* Address 0x400 to 0x1000 ualias points to cache error eframe + misc
  213. * CACHE_ERR_SP_PTR could either contain an address to the stack, or
  214. * the stack could start at CACHE_ERR_SP_PTR
  215. */
  216. #if defined (HUB_ERR_STS_WAR)
  217. #define CACHE_ERR_EFRAME 0x480
  218. #else /* HUB_ERR_STS_WAR */
  219. #define CACHE_ERR_EFRAME 0x400
  220. #endif /* HUB_ERR_STS_WAR */
  221. #define CACHE_ERR_ECCFRAME (CACHE_ERR_EFRAME + EF_SIZE)
  222. #define CACHE_ERR_SP_PTR (0x1000 - 32) /* why -32? TBD */
  223. #define CACHE_ERR_IBASE_PTR (0x1000 - 40)
  224. #define CACHE_ERR_SP (CACHE_ERR_SP_PTR - 16)
  225. #define CACHE_ERR_AREA_SIZE (ARCS_SPB_OFFSET - CACHE_ERR_EFRAME)
  226. #endif /* !__ASSEMBLY__ */
  227. #define _ARCSPROM
  228. #ifdef _STANDALONE
  229. /*
  230. * The PROM needs to pass the device base address and the
  231. * device pci cfg space address to the device drivers during
  232. * install. The COMPONENT->Key field is used for this purpose.
  233. * Macros needed by SN0 device drivers to convert the
  234. * COMPONENT->Key field to the respective base address.
  235. * Key field looks as follows:
  236. *
  237. * +----------------------------------------------------+
  238. * |devnasid | widget |pciid |hubwidid|hstnasid | adap |
  239. * | 2 | 1 | 1 | 1 | 2 | 1 |
  240. * +----------------------------------------------------+
  241. * | | | | | | |
  242. * 64 48 40 32 24 8 0
  243. *
  244. * These are used by standalone drivers till the io infrastructure
  245. * is in place.
  246. */
  247. #ifndef __ASSEMBLY__
  248. #define uchar unsigned char
  249. #define KEY_DEVNASID_SHFT 48
  250. #define KEY_WIDID_SHFT 40
  251. #define KEY_PCIID_SHFT 32
  252. #define KEY_HUBWID_SHFT 24
  253. #define KEY_HSTNASID_SHFT 8
  254. #define MK_SN0_KEY(nasid, widid, pciid) \
  255. ((((__psunsigned_t)nasid)<< KEY_DEVNASID_SHFT |\
  256. ((__psunsigned_t)widid) << KEY_WIDID_SHFT) |\
  257. ((__psunsigned_t)pciid) << KEY_PCIID_SHFT)
  258. #define ADD_HUBWID_KEY(key,hubwid)\
  259. (key|=((__psunsigned_t)hubwid << KEY_HUBWID_SHFT))
  260. #define ADD_HSTNASID_KEY(key,hstnasid)\
  261. (key|=((__psunsigned_t)hstnasid << KEY_HSTNASID_SHFT))
  262. #define GET_DEVNASID_FROM_KEY(key) ((short)(key >> KEY_DEVNASID_SHFT))
  263. #define GET_WIDID_FROM_KEY(key) ((uchar)(key >> KEY_WIDID_SHFT))
  264. #define GET_PCIID_FROM_KEY(key) ((uchar)(key >> KEY_PCIID_SHFT))
  265. #define GET_HUBWID_FROM_KEY(key) ((uchar)(key >> KEY_HUBWID_SHFT))
  266. #define GET_HSTNASID_FROM_KEY(key) ((short)(key >> KEY_HSTNASID_SHFT))
  267. #define PCI_64_TARGID_SHFT 60
  268. #define GET_PCIBASE_FROM_KEY(key) (NODE_SWIN_BASE(GET_DEVNASID_FROM_KEY(key),\
  269. GET_WIDID_FROM_KEY(key))\
  270. | BRIDGE_DEVIO(GET_PCIID_FROM_KEY(key)))
  271. #define GET_PCICFGBASE_FROM_KEY(key) \
  272. (NODE_SWIN_BASE(GET_DEVNASID_FROM_KEY(key),\
  273. GET_WIDID_FROM_KEY(key))\
  274. | BRIDGE_TYPE0_CFG_DEV(GET_PCIID_FROM_KEY(key)))
  275. #define GET_WIDBASE_FROM_KEY(key) \
  276. (NODE_SWIN_BASE(GET_DEVNASID_FROM_KEY(key),\
  277. GET_WIDID_FROM_KEY(key)))
  278. #define PUT_INSTALL_STATUS(c,s) c->Revision = s
  279. #define GET_INSTALL_STATUS(c) c->Revision
  280. #endif /* !__ASSEMBLY__ */
  281. #endif /* _STANDALONE */
  282. #if defined (HUB_ERR_STS_WAR)
  283. #define ERR_STS_WAR_REGISTER IIO_IIBUSERR
  284. #define ERR_STS_WAR_ADDR LOCAL_HUB_ADDR(IIO_IIBUSERR)
  285. #define ERR_STS_WAR_PHYSADDR TO_PHYS((__psunsigned_t)ERR_STS_WAR_ADDR)
  286. /* Used to match addr in error reg. */
  287. #define OLD_ERR_STS_WAR_OFFSET ((MD_MEM_BANKS * MD_BANK_SIZE) - 0x100)
  288. #endif /* HUB_ERR_STS_WAR */
  289. #endif /* _ASM_SN_SN0_ADDRS_H */