core_irongate.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:9k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef __ALPHA_IRONGATE__H__
  2. #define __ALPHA_IRONGATE__H__
  3. #include <linux/types.h>
  4. #include <asm/compiler.h>
  5. /*
  6.  * IRONGATE is the internal name for the AMD-751 K7 core logic chipset
  7.  * which provides memory controller and PCI access for NAUTILUS-based
  8.  * EV6 (21264) systems.
  9.  *
  10.  * This file is based on:
  11.  *
  12.  * IronGate management library, (c) 1999 Alpha Processor, Inc.
  13.  * Copyright (C) 1999 Alpha Processor, Inc.,
  14.  * (David Daniel, Stig Telfer, Soohoon Lee)
  15.  */
  16. /*
  17.  * The 21264 supports, and internally recognizes, a 44-bit physical
  18.  * address space that is divided equally between memory address space
  19.  * and I/O address space. Memory address space resides in the lower
  20.  * half of the physical address space (PA[43]=0) and I/O address space
  21.  * resides in the upper half of the physical address space (PA[43]=1).
  22.  */
  23. /*
  24.  * Irongate CSR map.  Some of the CSRs are 8 or 16 bits, but all access
  25.  * through the routines given is 32-bit.
  26.  *
  27.  * The first 0x40 bytes are standard as per the PCI spec.
  28.  */
  29. typedef volatile __u32 igcsr32;
  30. typedef struct {
  31. igcsr32 dev_vendor; /* 0x00 - device ID, vendor ID */
  32. igcsr32 stat_cmd; /* 0x04 - status, command */
  33. igcsr32 class; /* 0x08 - class code, rev ID */
  34. igcsr32 latency; /* 0x0C - header type, PCI latency */
  35. igcsr32 bar0; /* 0x10 - BAR0 - AGP */
  36. igcsr32 bar1; /* 0x14 - BAR1 - GART */
  37. igcsr32 bar2; /* 0x18 - Power Management reg block */
  38. igcsr32 rsrvd0[6]; /* 0x1C-0x33 reserved */
  39. igcsr32 capptr; /* 0x34 - Capabilities pointer */
  40. igcsr32 rsrvd1[2]; /* 0x38-0x3F reserved */
  41. igcsr32 bacsr10; /* 0x40 - base address chip selects */
  42. igcsr32 bacsr32; /* 0x44 - base address chip selects */
  43. igcsr32 bacsr54; /* 0x48 - base address chip selects */
  44. igcsr32 rsrvd2[1]; /* 0x4C-0x4F reserved */
  45. igcsr32 drammap; /* 0x50 - address mapping control */
  46. igcsr32 dramtm; /* 0x54 - timing, driver strength */
  47. igcsr32 dramms; /* 0x58 - ECC, mode/status */
  48. igcsr32 rsrvd3[1]; /* 0x5C-0x5F reserved */
  49. igcsr32 biu0; /* 0x60 - bus interface unit */
  50. igcsr32 biusip; /* 0x64 - Serial initialisation pkt */
  51. igcsr32 rsrvd4[2]; /* 0x68-0x6F reserved */
  52. igcsr32 mro; /* 0x70 - memory request optimiser */
  53. igcsr32 rsrvd5[3]; /* 0x74-0x7F reserved */
  54. igcsr32 whami; /* 0x80 - who am I */
  55. igcsr32 pciarb; /* 0x84 - PCI arbitration control */
  56. igcsr32 pcicfg; /* 0x88 - PCI config status */
  57. igcsr32 rsrvd6[5]; /* 0x8C-0x9F reserved */
  58. /* AGP (bus 1) control registers */
  59. igcsr32 agpcap; /* 0xA0 - AGP Capability Identifier */
  60. igcsr32 agpstat; /* 0xA4 - AGP status register */
  61. igcsr32 agpcmd; /* 0xA8 - AGP control register */
  62. igcsr32 agpva; /* 0xAC - AGP Virtual Address Space */
  63. igcsr32 agpmode; /* 0xB0 - AGP/GART mode control */
  64. } Irongate0;
  65. typedef struct {
  66. igcsr32 dev_vendor; /* 0x00 - Device and Vendor IDs */
  67. igcsr32 stat_cmd; /* 0x04 - Status and Command regs */
  68. igcsr32 class; /* 0x08 - subclass, baseclass etc */
  69. igcsr32 htype; /* 0x0C - header type (at 0x0E) */
  70. igcsr32 rsrvd0[2]; /* 0x10-0x17 reserved */
  71. igcsr32 busnos; /* 0x18 - Primary, secondary bus nos */
  72. igcsr32 io_baselim_regs; /* 0x1C - IO base, IO lim, AGP status */
  73. igcsr32 mem_baselim; /* 0x20 - memory base, memory lim */
  74. igcsr32 pfmem_baselim; /* 0x24 - prefetchable base, lim */
  75. igcsr32 rsrvd1[2]; /* 0x28-0x2F reserved */
  76. igcsr32 io_baselim; /* 0x30 - IO base, IO limit */
  77. igcsr32 rsrvd2[2]; /* 0x34-0x3B - reserved */
  78. igcsr32 interrupt; /* 0x3C - interrupt, PCI bridge ctrl */
  79. } Irongate1;
  80. /*
  81.  * Memory spaces:
  82.  */
  83. /* Irongate is consistent with a subset of the Tsunami memory map */
  84. #ifdef USE_48_BIT_KSEG
  85. #define IRONGATE_BIAS 0x80000000000UL
  86. #else
  87. #define IRONGATE_BIAS 0x10000000000UL
  88. #endif
  89. #define IRONGATE_MEM (IDENT_ADDR | IRONGATE_BIAS | 0x000000000UL)
  90. #define IRONGATE_IACK_SC (IDENT_ADDR | IRONGATE_BIAS | 0x1F8000000UL)
  91. #define IRONGATE_IO (IDENT_ADDR | IRONGATE_BIAS | 0x1FC000000UL)
  92. #define IRONGATE_CONF (IDENT_ADDR | IRONGATE_BIAS | 0x1FE000000UL)
  93. /*
  94.  * PCI Configuration space accesses are formed like so:
  95.  *
  96.  * 0x1FE << 24 |  : 2 2 2 2 1 1 1 1 : 1 1 1 1 1 1 0 0 : 0 0 0 0 0 0 0 0 :
  97.  *                : 3 2 1 0 9 8 7 6 : 5 4 3 2 1 0 9 8 : 7 6 5 4 3 2 1 0 :
  98.  *                  ---bus numer---   -device-- -fun-   ---register----
  99.  */
  100. #define IGCSR(dev,fun,reg) ( IRONGATE_CONF | 
  101. ((dev)<<11) | 
  102. ((fun)<<8) | 
  103. (reg) )
  104. #define IRONGATE0 ((Irongate0 *) IGCSR(0, 0, 0))
  105. #define IRONGATE1 ((Irongate1 *) IGCSR(1, 0, 0))
  106. /*
  107.  * Data structure for handling IRONGATE machine checks:
  108.  * This is the standard OSF logout frame
  109.  */
  110. #define SCB_Q_SYSERR 0x620 /* OSF definitions */
  111. #define SCB_Q_PROCERR 0x630
  112. #define SCB_Q_SYSMCHK 0x660
  113. #define SCB_Q_PROCMCHK 0x670
  114. struct el_IRONGATE_sysdata_mcheck {
  115. __u32 FrameSize;                 /* Bytes, including this field */
  116. __u32 FrameFlags;                /* <31> = Retry, <30> = Second Error */
  117. __u32 CpuOffset;                 /* Offset to CPU-specific into */
  118. __u32 SystemOffset;              /* Offset to system-specific info */
  119. __u32 MCHK_Code;
  120. __u32 MCHK_Frame_Rev;
  121. __u64 I_STAT;
  122. __u64 DC_STAT;
  123. __u64 C_ADDR;
  124. __u64 DC1_SYNDROME;
  125. __u64 DC0_SYNDROME;
  126. __u64 C_STAT;
  127. __u64 C_STS;
  128. __u64 RESERVED0;
  129. __u64 EXC_ADDR;
  130. __u64 IER_CM;
  131. __u64 ISUM;
  132. __u64 MM_STAT;
  133. __u64 PAL_BASE;
  134. __u64 I_CTL;
  135. __u64 PCTX;
  136. };
  137. #ifdef __KERNEL__
  138. #ifndef __EXTERN_INLINE
  139. #define __EXTERN_INLINE extern inline
  140. #define __IO_EXTERN_INLINE
  141. #endif
  142. /*
  143.  * I/O functions:
  144.  *
  145.  * IRONGATE (AMD-751) PCI/memory support chip for the EV6 (21264) and
  146.  * K7 can only use linear accesses to get at PCI memory and I/O spaces.
  147.  */
  148. #define vucp volatile unsigned char *
  149. #define vusp volatile unsigned short *
  150. #define vuip volatile unsigned int *
  151. #define vulp volatile unsigned long *
  152. __EXTERN_INLINE u8 irongate_inb(unsigned long addr)
  153. {
  154. return __kernel_ldbu(*(vucp)(addr + IRONGATE_IO));
  155. }
  156. __EXTERN_INLINE void irongate_outb(u8 b, unsigned long addr)
  157. {
  158.         __kernel_stb(b, *(vucp)(addr + IRONGATE_IO));
  159. mb();
  160. }
  161. __EXTERN_INLINE u16 irongate_inw(unsigned long addr)
  162. {
  163. return __kernel_ldwu(*(vusp)(addr + IRONGATE_IO));
  164. }
  165. __EXTERN_INLINE void irongate_outw(u16 b, unsigned long addr)
  166. {
  167.         __kernel_stw(b, *(vusp)(addr + IRONGATE_IO));
  168. mb();
  169. }
  170. __EXTERN_INLINE u32 irongate_inl(unsigned long addr)
  171. {
  172. return *(vuip)(addr + IRONGATE_IO);
  173. }
  174. __EXTERN_INLINE void irongate_outl(u32 b, unsigned long addr)
  175. {
  176.         *(vuip)(addr + IRONGATE_IO) = b;
  177. mb();
  178. }
  179. /*
  180.  * Memory functions.  All accesses are done through linear space.
  181.  */
  182. __EXTERN_INLINE u8 irongate_readb(unsigned long addr)
  183. {
  184. return __kernel_ldbu(*(vucp)addr);
  185. }
  186. __EXTERN_INLINE u16 irongate_readw(unsigned long addr)
  187. {
  188. return __kernel_ldwu(*(vusp)addr);
  189. }
  190. __EXTERN_INLINE u32 irongate_readl(unsigned long addr)
  191. {
  192. return (*(vuip)addr) & 0xffffffff;
  193. }
  194. __EXTERN_INLINE u64 irongate_readq(unsigned long addr)
  195. {
  196. return *(vulp)addr;
  197. }
  198. __EXTERN_INLINE void irongate_writeb(u8 b, unsigned long addr)
  199. {
  200. __kernel_stb(b, *(vucp)addr);
  201. }
  202. __EXTERN_INLINE void irongate_writew(u16 b, unsigned long addr)
  203. {
  204. __kernel_stw(b, *(vusp)addr);
  205. }
  206. __EXTERN_INLINE void irongate_writel(u32 b, unsigned long addr)
  207. {
  208. *(vuip)addr = b;
  209. }
  210. __EXTERN_INLINE void irongate_writeq(u64 b, unsigned long addr)
  211. {
  212. *(vulp)addr = b;
  213. }
  214. extern unsigned long irongate_ioremap(unsigned long addr, unsigned long size);
  215. extern void irongate_iounmap(unsigned long addr);
  216. __EXTERN_INLINE int irongate_is_ioaddr(unsigned long addr)
  217. {
  218. return addr >= IRONGATE_MEM;
  219. }
  220. #undef vucp
  221. #undef vusp
  222. #undef vuip
  223. #undef vulp
  224. #ifdef __WANT_IO_DEF
  225. #define __inb(p) irongate_inb((unsigned long)(p))
  226. #define __inw(p) irongate_inw((unsigned long)(p))
  227. #define __inl(p) irongate_inl((unsigned long)(p))
  228. #define __outb(x,p) irongate_outb((x),(unsigned long)(p))
  229. #define __outw(x,p) irongate_outw((x),(unsigned long)(p))
  230. #define __outl(x,p) irongate_outl((x),(unsigned long)(p))
  231. #define __readb(a) irongate_readb((unsigned long)(a))
  232. #define __readw(a) irongate_readw((unsigned long)(a))
  233. #define __readl(a) irongate_readl((unsigned long)(a))
  234. #define __readq(a) irongate_readq((unsigned long)(a))
  235. #define __writeb(x,a) irongate_writeb((x),(unsigned long)(a))
  236. #define __writew(x,a) irongate_writew((x),(unsigned long)(a))
  237. #define __writel(x,a) irongate_writel((x),(unsigned long)(a))
  238. #define __writeq(x,a) irongate_writeq((x),(unsigned long)(a))
  239. #define __ioremap(a,s) irongate_ioremap((unsigned long)(a),(s))
  240. #define __iounmap(a) irongate_iounmap((unsigned long)(a))
  241. #define __is_ioaddr(a) irongate_is_ioaddr((unsigned long)(a))
  242. #define inb(p) __inb(p)
  243. #define inw(p) __inw(p)
  244. #define inl(p) __inl(p)
  245. #define outb(x,p) __outb((x),(p))
  246. #define outw(x,p) __outw((x),(p))
  247. #define outl(x,p) __outl((x),(p))
  248. #define __raw_readb(a) __readb(a)
  249. #define __raw_readw(a) __readw(a)
  250. #define __raw_readl(a) __readl(a)
  251. #define __raw_readq(a) __readq(a)
  252. #define __raw_writeb(v,a) __writeb((v),(a))
  253. #define __raw_writew(v,a) __writew((v),(a))
  254. #define __raw_writel(v,a) __writel((v),(a))
  255. #define __raw_writeq(v,a) __writeq((v),(a))
  256. #endif /* __WANT_IO_DEF */
  257. #ifdef __IO_EXTERN_INLINE
  258. #undef __EXTERN_INLINE
  259. #undef __IO_EXTERN_INLINE
  260. #endif
  261. #endif /* __KERNEL__ */
  262. #endif /* __ALPHA_IRONGATE__H__ */