Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | #ifndef __ALPHA_MCPCIA__H__ #define __ALPHA_MCPCIA__H__ /* Define to experiment with fitting everything into one 128MB HAE window. One window per bus, that is. */ #define MCPCIA_ONE_HAE_WINDOW 1 #include <linux/types.h> #include <linux/pci.h> #include <asm/compiler.h> /* * MCPCIA is the internal name for a core logic chipset which provides * PCI access for the RAWHIDE family of systems. * * This file is based on: * * RAWHIDE System Programmer's Manual * 16-May-96 * Rev. 1.4 * */ /*------------------------------------------------------------------------** ** ** ** I/O procedures ** ** ** ** inport[b|w|t|l], outport[b|w|t|l] 8:16:24:32 IO xfers ** ** inportbxt: 8 bits only ** ** inport: alias of inportw ** ** outport: alias of outportw ** ** ** ** inmem[b|w|t|l], outmem[b|w|t|l] 8:16:24:32 ISA memory xfers ** ** inmembxt: 8 bits only ** ** inmem: alias of inmemw ** ** outmem: alias of outmemw ** ** ** **------------------------------------------------------------------------*/ /* MCPCIA ADDRESS BIT DEFINITIONS * * 3333 3333 3322 2222 2222 1111 1111 11 * 9876 5432 1098 7654 3210 9876 5432 1098 7654 3210 * ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- * 1 000 * ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- * | |\| * | Byte Enable --+ | * | Transfer Length --+ * +-- IO space, not cached * * Byte Transfer * Enable Length Transfer Byte Address * adr<6:5> adr<4:3> Length Enable Adder * --------------------------------------------- * 00 00 Byte 1110 0x000 * 01 00 Byte 1101 0x020 * 10 00 Byte 1011 0x040 * 11 00 Byte 0111 0x060 * * 00 01 Word 1100 0x008 * 01 01 Word 1001 0x028 <= Not supported in this code. * 10 01 Word 0011 0x048 * * 00 10 Tribyte 1000 0x010 * 01 10 Tribyte 0001 0x030 * * 10 11 Longword 0000 0x058 * * Note that byte enables are asserted low. * */ #define MCPCIA_MID(m) ((unsigned long)(m) << 33) /* Dodge has PCI0 and PCI1 at MID 4 and 5 respectively. Durango adds PCI2 and PCI3 at MID 6 and 7 respectively. */ #define MCPCIA_HOSE2MID(h) ((h) + 4) #define MCPCIA_MEM_MASK 0x07ffffff /* SPARSE Mem region mask is 27 bits */ /* * Memory spaces: */ #define MCPCIA_SPARSE(m) (IDENT_ADDR + 0xf000000000UL + MCPCIA_MID(m)) #define MCPCIA_DENSE(m) (IDENT_ADDR + 0xf100000000UL + MCPCIA_MID(m)) #define MCPCIA_IO(m) (IDENT_ADDR + 0xf180000000UL + MCPCIA_MID(m)) #define MCPCIA_CONF(m) (IDENT_ADDR + 0xf1c0000000UL + MCPCIA_MID(m)) #define MCPCIA_CSR(m) (IDENT_ADDR + 0xf1e0000000UL + MCPCIA_MID(m)) #define MCPCIA_IO_IACK(m) (IDENT_ADDR + 0xf1f0000000UL + MCPCIA_MID(m)) #define MCPCIA_DENSE_IO(m) (IDENT_ADDR + 0xe1fc000000UL + MCPCIA_MID(m)) #define MCPCIA_DENSE_CONF(m) (IDENT_ADDR + 0xe1fe000000UL + MCPCIA_MID(m)) /* * General Registers */ #define MCPCIA_REV(m) (MCPCIA_CSR(m) + 0x000) #define MCPCIA_WHOAMI(m) (MCPCIA_CSR(m) + 0x040) #define MCPCIA_PCI_LAT(m) (MCPCIA_CSR(m) + 0x080) #define MCPCIA_CAP_CTRL(m) (MCPCIA_CSR(m) + 0x100) #define MCPCIA_HAE_MEM(m) (MCPCIA_CSR(m) + 0x400) #define MCPCIA_HAE_IO(m) (MCPCIA_CSR(m) + 0x440) #define _MCPCIA_IACK_SC(m) (MCPCIA_CSR(m) + 0x480) #define MCPCIA_HAE_DENSE(m) (MCPCIA_CSR(m) + 0x4C0) /* * Interrupt Control registers */ #define MCPCIA_INT_CTL(m) (MCPCIA_CSR(m) + 0x500) #define MCPCIA_INT_REQ(m) (MCPCIA_CSR(m) + 0x540) #define MCPCIA_INT_TARG(m) (MCPCIA_CSR(m) + 0x580) #define MCPCIA_INT_ADR(m) (MCPCIA_CSR(m) + 0x5C0) #define MCPCIA_INT_ADR_EXT(m) (MCPCIA_CSR(m) + 0x600) #define MCPCIA_INT_MASK0(m) (MCPCIA_CSR(m) + 0x640) #define MCPCIA_INT_MASK1(m) (MCPCIA_CSR(m) + 0x680) #define MCPCIA_INT_ACK0(m) (MCPCIA_CSR(m) + 0x10003f00) #define MCPCIA_INT_ACK1(m) (MCPCIA_CSR(m) + 0x10003f40) /* * Performance Monitor registers */ #define MCPCIA_PERF_MON(m) (MCPCIA_CSR(m) + 0x300) #define MCPCIA_PERF_CONT(m) (MCPCIA_CSR(m) + 0x340) /* * Diagnostic Registers */ #define MCPCIA_CAP_DIAG(m) (MCPCIA_CSR(m) + 0x700) #define MCPCIA_TOP_OF_MEM(m) (MCPCIA_CSR(m) + 0x7C0) /* * Error registers */ #define MCPCIA_MC_ERR0(m) (MCPCIA_CSR(m) + 0x800) #define MCPCIA_MC_ERR1(m) (MCPCIA_CSR(m) + 0x840) #define MCPCIA_CAP_ERR(m) (MCPCIA_CSR(m) + 0x880) #define MCPCIA_PCI_ERR1(m) (MCPCIA_CSR(m) + 0x1040) #define MCPCIA_MDPA_STAT(m) (MCPCIA_CSR(m) + 0x4000) #define MCPCIA_MDPA_SYN(m) (MCPCIA_CSR(m) + 0x4040) #define MCPCIA_MDPA_DIAG(m) (MCPCIA_CSR(m) + 0x4080) #define MCPCIA_MDPB_STAT(m) (MCPCIA_CSR(m) + 0x8000) #define MCPCIA_MDPB_SYN(m) (MCPCIA_CSR(m) + 0x8040) #define MCPCIA_MDPB_DIAG(m) (MCPCIA_CSR(m) + 0x8080) /* * PCI Address Translation Registers. */ #define MCPCIA_SG_TBIA(m) (MCPCIA_CSR(m) + 0x1300) #define MCPCIA_HBASE(m) (MCPCIA_CSR(m) + 0x1340) #define MCPCIA_W0_BASE(m) (MCPCIA_CSR(m) + 0x1400) #define MCPCIA_W0_MASK(m) (MCPCIA_CSR(m) + 0x1440) #define MCPCIA_T0_BASE(m) (MCPCIA_CSR(m) + 0x1480) #define MCPCIA_W1_BASE(m) (MCPCIA_CSR(m) + 0x1500) #define MCPCIA_W1_MASK(m) (MCPCIA_CSR(m) + 0x1540) #define MCPCIA_T1_BASE(m) (MCPCIA_CSR(m) + 0x1580) #define MCPCIA_W2_BASE(m) (MCPCIA_CSR(m) + 0x1600) #define MCPCIA_W2_MASK(m) (MCPCIA_CSR(m) + 0x1640) #define MCPCIA_T2_BASE(m) (MCPCIA_CSR(m) + 0x1680) #define MCPCIA_W3_BASE(m) (MCPCIA_CSR(m) + 0x1700) #define MCPCIA_W3_MASK(m) (MCPCIA_CSR(m) + 0x1740) #define MCPCIA_T3_BASE(m) (MCPCIA_CSR(m) + 0x1780) /* Hack! Only words for bus 0. */ #if !MCPCIA_ONE_HAE_WINDOW #define MCPCIA_HAE_ADDRESS MCPCIA_HAE_MEM(4) #endif #define MCPCIA_IACK_SC _MCPCIA_IACK_SC(4) /* * The canonical non-remaped I/O and MEM addresses have these values * subtracted out. This is arranged so that folks manipulating ISA * devices can use their familiar numbers and have them map to bus 0. */ #define MCPCIA_IO_BIAS MCPCIA_IO(4) #define MCPCIA_MEM_BIAS MCPCIA_DENSE(4) /* * Data structure for handling MCPCIA machine checks: */ struct el_MCPCIA_uncorrected_frame_mcheck { struct el_common header; struct el_common_EV5_uncorrectable_mcheck procdata; }; #ifdef __KERNEL__ #ifndef __EXTERN_INLINE #define __EXTERN_INLINE extern inline #define __IO_EXTERN_INLINE #endif /* * I/O functions: * * MCPCIA, the RAWHIDE family PCI/memory support chipset for the EV5 (21164) * and EV56 (21164a) processors, can use either a sparse address mapping * scheme, or the so-called byte-word PCI address space, to get at PCI memory * and I/O. * * Unfortunately, we can't use BWIO with EV5, so for now, we always use SPARSE. */ #define vucp volatile unsigned char * #define vusp volatile unsigned short * #define vip volatile int * #define vuip volatile unsigned int * #define vulp volatile unsigned long * __EXTERN_INLINE unsigned int mcpcia_inb(unsigned long in_addr) { unsigned long addr, hose, result; addr = in_addr & 0xffffUL; hose = in_addr & ~0xffffUL; /* ??? I wish I could get rid of this. But there's no ioremap equivalent for I/O space. PCI I/O can be forced into the correct hose's I/O region, but that doesn't take care of legacy ISA crap. */ hose += MCPCIA_IO_BIAS; result = *(vip) ((addr << 5) + hose + 0x00); return __kernel_extbl(result, addr & 3); } __EXTERN_INLINE void mcpcia_outb(unsigned char b, unsigned long in_addr) { unsigned long addr, hose, w; addr = in_addr & 0xffffUL; hose = in_addr & ~0xffffUL; hose += MCPCIA_IO_BIAS; w = __kernel_insbl(b, addr & 3); *(vuip) ((addr << 5) + hose + 0x00) = w; mb(); } __EXTERN_INLINE unsigned int mcpcia_inw(unsigned long in_addr) { unsigned long addr, hose, result; addr = in_addr & 0xffffUL; hose = in_addr & ~0xffffUL; hose += MCPCIA_IO_BIAS; result = *(vip) ((addr << 5) + hose + 0x08); return __kernel_extwl(result, addr & 3); } __EXTERN_INLINE void mcpcia_outw(unsigned short b, unsigned long in_addr) { unsigned long addr, hose, w; addr = in_addr & 0xffffUL; hose = in_addr & ~0xffffUL; hose += MCPCIA_IO_BIAS; w = __kernel_inswl(b, addr & 3); *(vuip) ((addr << 5) + hose + 0x08) = w; mb(); } __EXTERN_INLINE unsigned int mcpcia_inl(unsigned long in_addr) { unsigned long addr, hose; addr = in_addr & 0xffffUL; hose = in_addr & ~0xffffUL; hose += MCPCIA_IO_BIAS; return *(vuip) ((addr << 5) + hose + 0x18); } __EXTERN_INLINE void mcpcia_outl(unsigned int b, unsigned long in_addr) { unsigned long addr, hose; addr = in_addr & 0xffffUL; hose = in_addr & ~0xffffUL; hose += MCPCIA_IO_BIAS; *(vuip) ((addr << 5) + hose + 0x18) = b; mb(); } /* * Memory functions. 64-bit and 32-bit accesses are done through * dense memory space, everything else through sparse space. * * For reading and writing 8 and 16 bit quantities we need to * go through one of the three sparse address mapping regions * and use the HAE_MEM CSR to provide some bits of the address. * The following few routines use only sparse address region 1 * which gives 1Gbyte of accessible space which relates exactly * to the amount of PCI memory mapping *into* system address space. * See p 6-17 of the specification but it looks something like this: * * 21164 Address: * * 3 2 1 * 9876543210987654321098765432109876543210 * 1ZZZZ0.PCI.QW.Address............BBLL * * ZZ = SBZ * BB = Byte offset * LL = Transfer length * * PCI Address: * * 3 2 1 * 10987654321098765432109876543210 * HHH....PCI.QW.Address........ 00 * * HHH = 31:29 HAE_MEM CSR * */ __EXTERN_INLINE unsigned long mcpcia_ioremap(unsigned long addr) { return addr + MCPCIA_MEM_BIAS; } __EXTERN_INLINE int mcpcia_is_ioaddr(unsigned long addr) { return addr >= MCPCIA_SPARSE(0); } __EXTERN_INLINE unsigned long mcpcia_readb(unsigned long in_addr) { unsigned long addr = in_addr & 0xffffffffUL; unsigned long hose = in_addr & ~0xffffffffUL; unsigned long result, work; #if !MCPCIA_ONE_HAE_WINDOW unsigned long msb; msb = addr & ~MCPCIA_MEM_MASK; set_hae(msb); #endif addr = addr & MCPCIA_MEM_MASK; hose = hose - MCPCIA_DENSE(4) + MCPCIA_SPARSE(4); work = ((addr << 5) + hose + 0x00); result = *(vip) work; return __kernel_extbl(result, addr & 3); } __EXTERN_INLINE unsigned long mcpcia_readw(unsigned long in_addr) { unsigned long addr = in_addr & 0xffffffffUL; unsigned long hose = in_addr & ~0xffffffffUL; unsigned long result, work; #if !MCPCIA_ONE_HAE_WINDOW unsigned long msb; msb = addr & ~MCPCIA_MEM_MASK; set_hae(msb); #endif addr = addr & MCPCIA_MEM_MASK; hose = hose - MCPCIA_DENSE(4) + MCPCIA_SPARSE(4); work = ((addr << 5) + hose + 0x08); result = *(vip) work; return __kernel_extwl(result, addr & 3); } __EXTERN_INLINE void mcpcia_writeb(unsigned char b, unsigned long in_addr) { unsigned long addr = in_addr & 0xffffffffUL; unsigned long hose = in_addr & ~0xffffffffUL; unsigned long w; #if !MCPCIA_ONE_HAE_WINDOW unsigned long msb; msb = addr & ~MCPCIA_MEM_MASK; set_hae(msb); #endif addr = addr & MCPCIA_MEM_MASK; w = __kernel_insbl(b, in_addr & 3); hose = hose - MCPCIA_DENSE(4) + MCPCIA_SPARSE(4); *(vuip) ((addr << 5) + hose + 0x00) = w; } __EXTERN_INLINE void mcpcia_writew(unsigned short b, unsigned long in_addr) { unsigned long addr = in_addr & 0xffffffffUL; unsigned long hose = in_addr & ~0xffffffffUL; unsigned long w; #if !MCPCIA_ONE_HAE_WINDOW unsigned long msb; msb = addr & ~MCPCIA_MEM_MASK; set_hae(msb); #endif addr = addr & MCPCIA_MEM_MASK; w = __kernel_inswl(b, in_addr & 3); hose = hose - MCPCIA_DENSE(4) + MCPCIA_SPARSE(4); *(vuip) ((addr << 5) + hose + 0x08) = w; } __EXTERN_INLINE unsigned long mcpcia_readl(unsigned long addr) { return *(vuip)addr; } __EXTERN_INLINE unsigned long mcpcia_readq(unsigned long addr) { return *(vulp)addr; } __EXTERN_INLINE void mcpcia_writel(unsigned int b, unsigned long addr) { *(vuip)addr = b; } __EXTERN_INLINE void mcpcia_writeq(unsigned long b, unsigned long addr) { *(vulp)addr = b; } #undef vucp #undef vusp #undef vip #undef vuip #undef vulp #ifdef __WANT_IO_DEF #define __inb(p) mcpcia_inb((unsigned long)(p)) #define __inw(p) mcpcia_inw((unsigned long)(p)) #define __inl(p) mcpcia_inl((unsigned long)(p)) #define __outb(x,p) mcpcia_outb((x),(unsigned long)(p)) #define __outw(x,p) mcpcia_outw((x),(unsigned long)(p)) #define __outl(x,p) mcpcia_outl((x),(unsigned long)(p)) #define __readb(a) mcpcia_readb((unsigned long)(a)) #define __readw(a) mcpcia_readw((unsigned long)(a)) #define __readl(a) mcpcia_readl((unsigned long)(a)) #define __readq(a) mcpcia_readq((unsigned long)(a)) #define __writeb(x,a) mcpcia_writeb((x),(unsigned long)(a)) #define __writew(x,a) mcpcia_writew((x),(unsigned long)(a)) #define __writel(x,a) mcpcia_writel((x),(unsigned long)(a)) #define __writeq(x,a) mcpcia_writeq((x),(unsigned long)(a)) #define __ioremap(a) mcpcia_ioremap((unsigned long)(a)) #define __is_ioaddr(a) mcpcia_is_ioaddr((unsigned long)(a)) #define __raw_readl(a) __readl(a) #define __raw_readq(a) __readq(a) #define __raw_writel(v,a) __writel((v),(a)) #define __raw_writeq(v,a) __writeq((v),(a)) #endif /* __WANT_IO_DEF */ #ifdef __IO_EXTERN_INLINE #undef __EXTERN_INLINE #undef __IO_EXTERN_INLINE #endif #endif /* __KERNEL__ */ #endif /* __ALPHA_MCPCIA__H__ */ |