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

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef __ALPHA_TSUNAMI__H__
  2. #define __ALPHA_TSUNAMI__H__
  3. #include <linux/types.h>
  4. #include <asm/compiler.h>
  5. /*
  6.  * TSUNAMI/TYPHOON are the internal names for the core logic chipset which
  7.  * provides memory controller and PCI access for the 21264 based systems.
  8.  *
  9.  * This file is based on:
  10.  *
  11.  * Tsunami System Programmers Manual
  12.  * Preliminary, Chapters 2-5
  13.  *
  14.  */
  15. /* XXX: Do we need to conditionalize on this?  */
  16. #ifdef USE_48_BIT_KSEG
  17. #define TS_BIAS 0x80000000000UL
  18. #else
  19. #define TS_BIAS 0x10000000000UL
  20. #endif
  21. /*
  22.  * CChip, DChip, and PChip registers
  23.  */
  24. typedef struct {
  25. volatile unsigned long csr __attribute__((aligned(64)));
  26. } tsunami_64;
  27. typedef struct {
  28. tsunami_64 csc;
  29. tsunami_64 mtr;
  30. tsunami_64 misc;
  31. tsunami_64 mpd;
  32. tsunami_64 aar0;
  33. tsunami_64 aar1;
  34. tsunami_64 aar2;
  35. tsunami_64 aar3;
  36. tsunami_64 dim0;
  37. tsunami_64 dim1;
  38. tsunami_64 dir0;
  39. tsunami_64 dir1;
  40. tsunami_64 drir;
  41. tsunami_64 prben;
  42. tsunami_64 iic; /* a.k.a. iic0 */
  43. tsunami_64 wdr; /* a.k.a. iic1 */
  44. tsunami_64 mpr0;
  45. tsunami_64 mpr1;
  46. tsunami_64 mpr2;
  47. tsunami_64 mpr3;
  48. tsunami_64 mctl;
  49. tsunami_64 __pad1;
  50. tsunami_64 ttr;
  51. tsunami_64 tdr;
  52. tsunami_64 dim2;
  53. tsunami_64 dim3;
  54. tsunami_64 dir2;
  55. tsunami_64 dir3;
  56. tsunami_64 iic2;
  57. tsunami_64 iic3;
  58. } tsunami_cchip;
  59. typedef struct {
  60. tsunami_64 dsc;
  61. tsunami_64 str;
  62. tsunami_64 drev;
  63. } tsunami_dchip;
  64. typedef struct {
  65. tsunami_64 wsba[4];
  66. tsunami_64 wsm[4];
  67. tsunami_64 tba[4];
  68. tsunami_64 pctl;
  69. tsunami_64 plat;
  70. tsunami_64 reserved;
  71. tsunami_64 perror;
  72. tsunami_64 perrmask;
  73. tsunami_64 perrset;
  74. tsunami_64 tlbiv;
  75. tsunami_64 tlbia;
  76. tsunami_64 pmonctl;
  77. tsunami_64 pmoncnt;
  78. } tsunami_pchip;
  79. #define TSUNAMI_cchip  ((tsunami_cchip *)(IDENT_ADDR+TS_BIAS+0x1A0000000UL))
  80. #define TSUNAMI_dchip  ((tsunami_dchip *)(IDENT_ADDR+TS_BIAS+0x1B0000800UL))
  81. #define TSUNAMI_pchip0 ((tsunami_pchip *)(IDENT_ADDR+TS_BIAS+0x180000000UL))
  82. #define TSUNAMI_pchip1 ((tsunami_pchip *)(IDENT_ADDR+TS_BIAS+0x380000000UL))
  83. extern int TSUNAMI_bootcpu;
  84. /*
  85.  * TSUNAMI Pchip Error register.
  86.  */
  87. #define perror_m_lost 0x1
  88. #define perror_m_serr 0x2
  89. #define perror_m_perr 0x4
  90. #define perror_m_dcrto 0x8
  91. #define perror_m_sge 0x10
  92. #define perror_m_ape 0x20
  93. #define perror_m_ta 0x40
  94. #define perror_m_rdpe 0x80
  95. #define perror_m_nds 0x100
  96. #define perror_m_rto 0x200
  97. #define perror_m_uecc 0x400
  98. #define perror_m_cre 0x800
  99. #define perror_m_addrl 0xFFFFFFFF0000UL
  100. #define perror_m_addrh 0x7000000000000UL
  101. #define perror_m_cmd 0xF0000000000000UL
  102. #define perror_m_syn 0xFF00000000000000UL
  103. union TPchipPERROR {   
  104. struct  {
  105. unsigned int perror_v_lost : 1;
  106. unsigned perror_v_serr : 1;
  107. unsigned perror_v_perr : 1;
  108. unsigned perror_v_dcrto : 1;
  109. unsigned perror_v_sge : 1;
  110. unsigned perror_v_ape : 1;
  111. unsigned perror_v_ta : 1;
  112. unsigned perror_v_rdpe : 1;
  113. unsigned perror_v_nds : 1;
  114. unsigned perror_v_rto : 1;
  115. unsigned perror_v_uecc : 1;
  116. unsigned perror_v_cre : 1;                 
  117. unsigned perror_v_rsvd1 : 4;
  118. unsigned perror_v_addrl : 32;
  119. unsigned perror_v_addrh : 3;
  120. unsigned perror_v_rsvd2 : 1;
  121. unsigned perror_v_cmd : 4;
  122. unsigned perror_v_syn : 8;
  123. } perror_r_bits;
  124. int perror_q_whole [2];
  125. };                       
  126. /*
  127.  * TSUNAMI Pchip Window Space Base Address register.
  128.  */
  129. #define wsba_m_ena 0x1                
  130. #define wsba_m_sg 0x2
  131. #define wsba_m_ptp 0x4
  132. #define wsba_m_addr 0xFFF00000  
  133. #define wmask_k_sz1gb 0x3FF00000                   
  134. union TPchipWSBA {
  135. struct  {
  136. unsigned wsba_v_ena : 1;
  137. unsigned wsba_v_sg : 1;
  138. unsigned wsba_v_ptp : 1;
  139. unsigned wsba_v_rsvd1 : 17;
  140. unsigned wsba_v_addr : 12;
  141. unsigned wsba_v_rsvd2 : 32;
  142. } wsba_r_bits;
  143. int wsba_q_whole [2];
  144. };
  145. /*
  146.  * TSUNAMI Pchip Control Register
  147.  */
  148. #define pctl_m_fdsc 0x1
  149. #define pctl_m_fbtb 0x2
  150. #define pctl_m_thdis 0x4
  151. #define pctl_m_chaindis 0x8
  152. #define pctl_m_tgtlat 0x10
  153. #define pctl_m_hole 0x20
  154. #define pctl_m_mwin 0x40
  155. #define pctl_m_arbena 0x80
  156. #define pctl_m_prigrp 0x7F00
  157. #define pctl_m_ppri 0x8000
  158. #define pctl_m_rsvd1 0x30000
  159. #define pctl_m_eccen 0x40000
  160. #define pctl_m_padm 0x80000
  161. #define pctl_m_cdqmax 0xF00000
  162. #define pctl_m_rev 0xFF000000
  163. #define pctl_m_crqmax 0xF00000000UL
  164. #define pctl_m_ptpmax 0xF000000000UL
  165. #define pctl_m_pclkx 0x30000000000UL
  166. #define pctl_m_fdsdis 0x40000000000UL
  167. #define pctl_m_fdwdis 0x80000000000UL
  168. #define pctl_m_ptevrfy 0x100000000000UL
  169. #define pctl_m_rpp 0x200000000000UL
  170. #define pctl_m_pid 0xC00000000000UL
  171. #define pctl_m_rsvd2 0xFFFF000000000000UL
  172. union TPchipPCTL {
  173. struct {
  174. unsigned pctl_v_fdsc : 1;
  175. unsigned pctl_v_fbtb : 1;
  176. unsigned pctl_v_thdis : 1;
  177. unsigned pctl_v_chaindis : 1;
  178. unsigned pctl_v_tgtlat : 1;
  179. unsigned pctl_v_hole : 1;
  180. unsigned pctl_v_mwin : 1;
  181. unsigned pctl_v_arbena : 1;
  182. unsigned pctl_v_prigrp : 7;
  183. unsigned pctl_v_ppri : 1;
  184. unsigned pctl_v_rsvd1 : 2;
  185. unsigned pctl_v_eccen : 1;
  186. unsigned pctl_v_padm : 1;
  187. unsigned pctl_v_cdqmax : 4;
  188. unsigned pctl_v_rev : 8;
  189. unsigned pctl_v_crqmax : 4;
  190. unsigned pctl_v_ptpmax : 4;
  191. unsigned pctl_v_pclkx : 2;
  192. unsigned pctl_v_fdsdis : 1;
  193. unsigned pctl_v_fdwdis : 1;
  194. unsigned pctl_v_ptevrfy : 1;
  195. unsigned pctl_v_rpp : 1;
  196. unsigned pctl_v_pid : 2;
  197. unsigned pctl_v_rsvd2 : 16;
  198. } pctl_r_bits;
  199. int pctl_q_whole [2];
  200. };
  201. /*
  202.  * TSUNAMI Pchip Error Mask Register.
  203.  */
  204. #define perrmask_m_lost 0x1
  205. #define perrmask_m_serr 0x2
  206. #define perrmask_m_perr 0x4
  207. #define perrmask_m_dcrto 0x8
  208. #define perrmask_m_sge 0x10
  209. #define perrmask_m_ape 0x20
  210. #define perrmask_m_ta 0x40
  211. #define perrmask_m_rdpe 0x80
  212. #define perrmask_m_nds 0x100
  213. #define perrmask_m_rto 0x200
  214. #define perrmask_m_uecc 0x400
  215. #define perrmask_m_cre 0x800
  216. #define perrmask_m_rsvd 0xFFFFFFFFFFFFF000UL
  217. union TPchipPERRMASK {   
  218. struct  {
  219. unsigned int perrmask_v_lost : 1;
  220. unsigned perrmask_v_serr : 1;
  221. unsigned perrmask_v_perr : 1;
  222. unsigned perrmask_v_dcrto : 1;
  223. unsigned perrmask_v_sge : 1;
  224. unsigned perrmask_v_ape : 1;
  225. unsigned perrmask_v_ta : 1;
  226. unsigned perrmask_v_rdpe : 1;
  227. unsigned perrmask_v_nds : 1;
  228. unsigned perrmask_v_rto : 1;
  229. unsigned perrmask_v_uecc : 1;
  230. unsigned perrmask_v_cre : 1;                 
  231. unsigned perrmask_v_rsvd1 : 20;
  232. unsigned perrmask_v_rsvd2 : 32;
  233. } perrmask_r_bits;
  234. int perrmask_q_whole [2];
  235. };                       
  236. /*
  237.  * Memory spaces:
  238.  */
  239. #define TSUNAMI_HOSE(h) (((unsigned long)(h)) << 33)
  240. #define TSUNAMI_BASE (IDENT_ADDR + TS_BIAS)
  241. #define TSUNAMI_MEM(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x000000000UL)
  242. #define _TSUNAMI_IACK_SC(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1F8000000UL)
  243. #define TSUNAMI_IO(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1FC000000UL)
  244. #define TSUNAMI_CONF(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1FE000000UL)
  245. #define TSUNAMI_IACK_SC _TSUNAMI_IACK_SC(0) /* hack! */
  246. /* 
  247.  * The canonical non-remaped I/O and MEM addresses have these values
  248.  * subtracted out.  This is arranged so that folks manipulating ISA
  249.  * devices can use their familiar numbers and have them map to bus 0.
  250.  */
  251. #define TSUNAMI_IO_BIAS          TSUNAMI_IO(0)
  252. #define TSUNAMI_MEM_BIAS         TSUNAMI_MEM(0)
  253. /* The IO address space is larger than 0xffff */
  254. #define TSUNAMI_IO_SPACE (TSUNAMI_CONF(0) - TSUNAMI_IO(0))
  255. /* Offset between ram physical addresses and pci64 DAC bus addresses.  */
  256. #define TSUNAMI_DAC_OFFSET (1UL << 40)
  257. /*
  258.  * Data structure for handling TSUNAMI machine checks:
  259.  */
  260. struct el_TSUNAMI_sysdata_mcheck {
  261. };
  262. #ifdef __KERNEL__
  263. #ifndef __EXTERN_INLINE
  264. #define __EXTERN_INLINE static inline
  265. #define __IO_EXTERN_INLINE
  266. #endif
  267. /*
  268.  * I/O functions:
  269.  *
  270.  * TSUNAMI, the 21??? PCI/memory support chipset for the EV6 (21264)
  271.  * can only use linear accesses to get at PCI memory and I/O spaces.
  272.  */
  273. #define vucp volatile unsigned char *
  274. #define vusp volatile unsigned short *
  275. #define vuip volatile unsigned int *
  276. #define vulp volatile unsigned long *
  277. __EXTERN_INLINE u8 tsunami_inb(unsigned long addr)
  278. {
  279. /* ??? I wish I could get rid of this.  But there's no ioremap
  280.    equivalent for I/O space.  PCI I/O can be forced into the
  281.    correct hose's I/O region, but that doesn't take care of
  282.    legacy ISA crap.  */
  283. addr += TSUNAMI_IO_BIAS;
  284. return __kernel_ldbu(*(vucp)addr);
  285. }
  286. __EXTERN_INLINE void tsunami_outb(u8 b, unsigned long addr)
  287. {
  288. addr += TSUNAMI_IO_BIAS;
  289. __kernel_stb(b, *(vucp)addr);
  290. mb();
  291. }
  292. __EXTERN_INLINE u16 tsunami_inw(unsigned long addr)
  293. {
  294. addr += TSUNAMI_IO_BIAS;
  295. return __kernel_ldwu(*(vusp)addr);
  296. }
  297. __EXTERN_INLINE void tsunami_outw(u16 b, unsigned long addr)
  298. {
  299. addr += TSUNAMI_IO_BIAS;
  300. __kernel_stw(b, *(vusp)addr);
  301. mb();
  302. }
  303. __EXTERN_INLINE u32 tsunami_inl(unsigned long addr)
  304. {
  305. addr += TSUNAMI_IO_BIAS;
  306. return *(vuip)addr;
  307. }
  308. __EXTERN_INLINE void tsunami_outl(u32 b, unsigned long addr)
  309. {
  310. addr += TSUNAMI_IO_BIAS;
  311. *(vuip)addr = b;
  312. mb();
  313. }
  314. /*
  315.  * Memory functions.  all accesses are done through linear space.
  316.  */
  317. __EXTERN_INLINE unsigned long tsunami_ioremap(unsigned long addr, 
  318.       unsigned long size
  319.       __attribute__((unused)))
  320. {
  321. return addr + TSUNAMI_MEM_BIAS;
  322. }
  323. __EXTERN_INLINE void tsunami_iounmap(unsigned long addr)
  324. {
  325. return;
  326. }
  327. __EXTERN_INLINE int tsunami_is_ioaddr(unsigned long addr)
  328. {
  329. return addr >= TSUNAMI_BASE;
  330. }
  331. __EXTERN_INLINE u8 tsunami_readb(unsigned long addr)
  332. {
  333. return __kernel_ldbu(*(vucp)addr);
  334. }
  335. __EXTERN_INLINE u16 tsunami_readw(unsigned long addr)
  336. {
  337. return __kernel_ldwu(*(vusp)addr);
  338. }
  339. __EXTERN_INLINE u32 tsunami_readl(unsigned long addr)
  340. {
  341. return *(vuip)addr;
  342. }
  343. __EXTERN_INLINE u64 tsunami_readq(unsigned long addr)
  344. {
  345. return *(vulp)addr;
  346. }
  347. __EXTERN_INLINE void tsunami_writeb(u8 b, unsigned long addr)
  348. {
  349. __kernel_stb(b, *(vucp)addr);
  350. }
  351. __EXTERN_INLINE void tsunami_writew(u16 b, unsigned long addr)
  352. {
  353. __kernel_stw(b, *(vusp)addr);
  354. }
  355. __EXTERN_INLINE void tsunami_writel(u32 b, unsigned long addr)
  356. {
  357. *(vuip)addr = b;
  358. }
  359. __EXTERN_INLINE void tsunami_writeq(u64 b, unsigned long addr)
  360. {
  361. *(vulp)addr = b;
  362. }
  363. #undef vucp
  364. #undef vusp
  365. #undef vuip
  366. #undef vulp
  367. #ifdef __WANT_IO_DEF
  368. #define __inb(p) tsunami_inb((unsigned long)(p))
  369. #define __inw(p) tsunami_inw((unsigned long)(p))
  370. #define __inl(p) tsunami_inl((unsigned long)(p))
  371. #define __outb(x,p) tsunami_outb((x),(unsigned long)(p))
  372. #define __outw(x,p) tsunami_outw((x),(unsigned long)(p))
  373. #define __outl(x,p) tsunami_outl((x),(unsigned long)(p))
  374. #define __readb(a) tsunami_readb((unsigned long)(a))
  375. #define __readw(a) tsunami_readw((unsigned long)(a))
  376. #define __readl(a) tsunami_readl((unsigned long)(a))
  377. #define __readq(a) tsunami_readq((unsigned long)(a))
  378. #define __writeb(x,a) tsunami_writeb((x),(unsigned long)(a))
  379. #define __writew(x,a) tsunami_writew((x),(unsigned long)(a))
  380. #define __writel(x,a) tsunami_writel((x),(unsigned long)(a))
  381. #define __writeq(x,a) tsunami_writeq((x),(unsigned long)(a))
  382. #define __ioremap(a,s) tsunami_ioremap((unsigned long)(a),(s))
  383. #define __iounmap(a) tsunami_iounmap((unsigned long)(a))
  384. #define __is_ioaddr(a) tsunami_is_ioaddr((unsigned long)(a))
  385. #define inb(p) __inb(p)
  386. #define inw(p) __inw(p)
  387. #define inl(p) __inl(p)
  388. #define outb(x,p) __outb((x),(p))
  389. #define outw(x,p) __outw((x),(p))
  390. #define outl(x,p) __outl((x),(p))
  391. #define __raw_readb(a) __readb(a)
  392. #define __raw_readw(a) __readw(a)
  393. #define __raw_readl(a) __readl(a)
  394. #define __raw_readq(a) __readq(a)
  395. #define __raw_writeb(v,a) __writeb((v),(a))
  396. #define __raw_writew(v,a) __writew((v),(a))
  397. #define __raw_writel(v,a) __writel((v),(a))
  398. #define __raw_writeq(v,a) __writeq((v),(a))
  399. #endif /* __WANT_IO_DEF */
  400. #ifdef __IO_EXTERN_INLINE
  401. #undef __EXTERN_INLINE
  402. #undef __IO_EXTERN_INLINE
  403. #endif
  404. #endif /* __KERNEL__ */
  405. #endif /* __ALPHA_TSUNAMI__H__ */