root/include/asm-alpha/apecs.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. virt_to_bus
  2. bus_to_virt
  3. __inb
  4. __outb
  5. __inw
  6. __outw
  7. __inl
  8. __outl
  9. __readb
  10. __readw
  11. __readl
  12. __writeb
  13. __writew
  14. __writel
  15. readl
  16. writel

   1 #ifndef __ALPHA_APECS__H__
   2 #define __ALPHA_APECS__H__
   3 
   4 #include <linux/types.h>
   5 
   6 /*
   7  * APECS is the internal name for the 2107x chipset which provides
   8  * memory controller and PCI access for the 21064 chip based systems.
   9  *
  10  * This file is based on:
  11  *
  12  * DECchip 21071-AA and DECchip 21072-AA Core Logic Chipsets
  13  * Data Sheet
  14  *
  15  * EC-N0648-72
  16  *
  17  *
  18  * david.rusling@reo.mts.dec.com Initial Version.
  19  *
  20  */
  21 
  22 #define APECS_DMA_WIN_BASE      (1024*1024*1024)
  23 #define APECS_DMA_WIN_SIZE      (1024*1024*1024)
  24 
  25 /*
  26  * 21071-DA Control and Status registers.
  27  * These are used for PCI memory access.
  28  */
  29 #define APECS_IOC_DCSR                  (IDENT_ADDR + 0x1A0000000UL)
  30 #define APECS_IOC_PEAR                  (IDENT_ADDR + 0x1A0000020UL)
  31 #define APECS_IOC_SEAR                  (IDENT_ADDR + 0x1A0000040UL)
  32 #define APECS_IOC_DR1                   (IDENT_ADDR + 0x1A0000060UL)
  33 #define APECS_IOC_DR2                   (IDENT_ADDR + 0x1A0000080UL)
  34 #define APECS_IOC_DR3                   (IDENT_ADDR + 0x1A00000A0UL)
  35 
  36 #define APECS_IOC_TB1R                  (IDENT_ADDR + 0x1A00000C0UL)
  37 #define APECS_IOC_TB2R                  (IDENT_ADDR + 0x1A00000E0UL)
  38 
  39 #define APECS_IOC_PB1R                  (IDENT_ADDR + 0x1A0000100UL)
  40 #define APECS_IOC_PB2R                  (IDENT_ADDR + 0x1A0000120UL)
  41 
  42 #define APECS_IOC_PM1R                  (IDENT_ADDR + 0x1A0000140UL)
  43 #define APECS_IOC_PM2R                  (IDENT_ADDR + 0x1A0000160UL)
  44 
  45 #define APECS_IOC_HAXR0                 (IDENT_ADDR + 0x1A0000180UL)
  46 #define APECS_IOC_HAXR1                 (IDENT_ADDR + 0x1A00001A0UL)
  47 #define APECS_IOC_HAXR2                 (IDENT_ADDR + 0x1A00001C0UL)
  48 
  49 #define APECS_IOC_PMLT                  (IDENT_ADDR + 0x1A00001E0UL)
  50 
  51 #define APECS_IOC_TLBTAG0               (IDENT_ADDR + 0x1A0000200UL)
  52 #define APECS_IOC_TLBTAG1               (IDENT_ADDR + 0x1A0000220UL)
  53 #define APECS_IOC_TLBTAG2               (IDENT_ADDR + 0x1A0000240UL)
  54 #define APECS_IOC_TLBTAG3               (IDENT_ADDR + 0x1A0000260UL)
  55 #define APECS_IOC_TLBTAG4               (IDENT_ADDR + 0x1A0000280UL)
  56 #define APECS_IOC_TLBTAG5               (IDENT_ADDR + 0x1A00002A0UL)
  57 #define APECS_IOC_TLBTAG6               (IDENT_ADDR + 0x1A00002C0UL)
  58 #define APECS_IOC_TLBTAG7               (IDENT_ADDR + 0x1A00002E0UL)
  59 
  60 #define APECS_IOC_TLBDATA0              (IDENT_ADDR + 0x1A0000300UL)
  61 #define APECS_IOC_TLBDATA1              (IDENT_ADDR + 0x1A0000320UL)
  62 #define APECS_IOC_TLBDATA2              (IDENT_ADDR + 0x1A0000340UL)
  63 #define APECS_IOC_TLBDATA3              (IDENT_ADDR + 0x1A0000360UL)
  64 #define APECS_IOC_TLBDATA4              (IDENT_ADDR + 0x1A0000380UL)
  65 #define APECS_IOC_TLBDATA5              (IDENT_ADDR + 0x1A00003A0UL)
  66 #define APECS_IOC_TLBDATA6              (IDENT_ADDR + 0x1A00003C0UL)
  67 #define APECS_IOC_TLBDATA7              (IDENT_ADDR + 0x1A00003E0UL)
  68 
  69 #define APECS_IOC_TBIA                  (IDENT_ADDR + 0x1A0000400UL)
  70 
  71 
  72 /*
  73  * 21071-CA Control and Status registers.
  74  * These are used to program memory timing,
  75  *  configure memory and initialise the B-Cache.
  76  */
  77 #define APECS_IOC_GCR                   (IDENT_ADDR + 0x180000000UL)
  78 #define APECS_IOC_EDSR                  (IDENT_ADDR + 0x180000040UL)
  79 #define APECS_IOC_TAR                   (IDENT_ADDR + 0x180000060UL)
  80 #define APECS_IOC_ELAR                  (IDENT_ADDR + 0x180000080UL)
  81 #define APECS_IOC_EHAR                  (IDENT_ADDR + 0x1800000a0UL)
  82 #define APECS_IOC_SFT_RST               (IDENT_ADDR + 0x1800000c0UL)
  83 #define APECS_IOC_LDxLAR                (IDENT_ADDR + 0x1800000e0UL)
  84 #define APECS_IOC_LDxHAR                (IDENT_ADDR + 0x180000100UL)
  85 #define APECS_IOC_GTR                   (IDENT_ADDR + 0x180000200UL)
  86 #define APECS_IOC_RTR                   (IDENT_ADDR + 0x180000220UL)
  87 #define APECS_IOC_VFPR                  (IDENT_ADDR + 0x180000240UL)
  88 #define APECS_IOC_PDLDR                 (IDENT_ADDR + 0x180000260UL)
  89 #define APECS_IOC_PDhDR                 (IDENT_ADDR + 0x180000280UL)
  90 
  91 /* Bank x Base Address Register */
  92 #define APECS_IOC_B0BAR                 (IDENT_ADDR + 0x180000800UL)
  93 #define APECS_IOC_B1BAR                 (IDENT_ADDR + 0x180000820UL)
  94 #define APECS_IOC_B2BAR                 (IDENT_ADDR + 0x180000840UL)
  95 #define APECS_IOC_B3BAR                 (IDENT_ADDR + 0x180000860UL)
  96 #define APECS_IOC_B4BAR                 (IDENT_ADDR + 0x180000880UL)
  97 #define APECS_IOC_B5BAR                 (IDENT_ADDR + 0x1800008A0UL)
  98 #define APECS_IOC_B6BAR                 (IDENT_ADDR + 0x1800008C0UL)
  99 #define APECS_IOC_B7BAR                 (IDENT_ADDR + 0x1800008E0UL)
 100 #define APECS_IOC_B8BAR                 (IDENT_ADDR + 0x180000900UL)
 101 
 102 /* Bank x Configuration Register */
 103 #define APECS_IOC_B0BCR                 (IDENT_ADDR + 0x180000A00UL)
 104 #define APECS_IOC_B1BCR                 (IDENT_ADDR + 0x180000A20UL)
 105 #define APECS_IOC_B2BCR                 (IDENT_ADDR + 0x180000A40UL)
 106 #define APECS_IOC_B3BCR                 (IDENT_ADDR + 0x180000A60UL)
 107 #define APECS_IOC_B4BCR                 (IDENT_ADDR + 0x180000A80UL)
 108 #define APECS_IOC_B5BCR                 (IDENT_ADDR + 0x180000AA0UL)
 109 #define APECS_IOC_B6BCR                 (IDENT_ADDR + 0x180000AC0UL)
 110 #define APECS_IOC_B7BCR                 (IDENT_ADDR + 0x180000AE0UL)
 111 #define APECS_IOC_B8BCR                 (IDENT_ADDR + 0x180000B00UL)
 112 
 113 /* Bank x Timing Register A */
 114 #define APECS_IOC_B0TRA                 (IDENT_ADDR + 0x180000C00UL)
 115 #define APECS_IOC_B1TRA                 (IDENT_ADDR + 0x180000C20UL)
 116 #define APECS_IOC_B2TRA                 (IDENT_ADDR + 0x180000C40UL)
 117 #define APECS_IOC_B3TRA                 (IDENT_ADDR + 0x180000C60UL)
 118 #define APECS_IOC_B4TRA                 (IDENT_ADDR + 0x180000C80UL)
 119 #define APECS_IOC_B5TRA                 (IDENT_ADDR + 0x180000CA0UL)
 120 #define APECS_IOC_B6TRA                 (IDENT_ADDR + 0x180000CC0UL)
 121 #define APECS_IOC_B7TRA                 (IDENT_ADDR + 0x180000CE0UL)
 122 #define APECS_IOC_B8TRA                 (IDENT_ADDR + 0x180000D00UL)
 123 
 124 /* Bank x Timing Register B */
 125 #define APECS_IOC_B0TRB                 (IDENT_ADDR + 0x180000E00UL)
 126 #define APECS_IOC_B1TRB                 (IDENT_ADDR + 0x180000E20UL)
 127 #define APECS_IOC_B2TRB                 (IDENT_ADDR + 0x180000E40UL)
 128 #define APECS_IOC_B3TRB                 (IDENT_ADDR + 0x180000E60UL)
 129 #define APECS_IOC_B4TRB                 (IDENT_ADDR + 0x180000E80UL)
 130 #define APECS_IOC_B5TRB                 (IDENT_ADDR + 0x180000EA0UL)
 131 #define APECS_IOC_B6TRB                 (IDENT_ADDR + 0x180000EC0UL)
 132 #define APECS_IOC_B7TRB                 (IDENT_ADDR + 0x180000EE0UL)
 133 #define APECS_IOC_B8TRB                 (IDENT_ADDR + 0x180000F00UL)
 134 
 135 
 136 /*
 137  * Memory spaces:
 138  */
 139 #define APECS_IACK_SC                   (IDENT_ADDR + 0x1b0000000UL)
 140 #define APECS_CONF                      (IDENT_ADDR + 0x1e0000000UL)
 141 #define APECS_IO                        (IDENT_ADDR + 0x1c0000000UL)
 142 #define APECS_SPARSE_MEM                (IDENT_ADDR + 0x200000000UL)
 143 #define APECS_DENSE_MEM                 (IDENT_ADDR + 0x300000000UL)
 144 
 145 /*
 146  * Bit definitions for I/O Controller status register 0:
 147  */
 148 #define APECS_IOC_STAT0_CMD             0xf
 149 #define APECS_IOC_STAT0_ERR             (1<<4)
 150 #define APECS_IOC_STAT0_LOST            (1<<5)
 151 #define APECS_IOC_STAT0_THIT            (1<<6)
 152 #define APECS_IOC_STAT0_TREF            (1<<7)
 153 #define APECS_IOC_STAT0_CODE_SHIFT      8
 154 #define APECS_IOC_STAT0_CODE_MASK       0x7
 155 #define APECS_IOC_STAT0_P_NBR_SHIFT     13
 156 #define APECS_IOC_STAT0_P_NBR_MASK      0x7ffff
 157 
 158 #define HAE_ADDRESS     APECS_IOC_HAXR1
 159 
 160 #ifdef __KERNEL__
 161 
 162 /*
 163  * Translate physical memory address as seen on (PCI) bus into
 164  * a kernel virtual address and vv.
 165  */
 166 extern inline unsigned long virt_to_bus(void * address)
     /* [previous][next][first][last][top][bottom][index][help] */
 167 {
 168         return virt_to_phys(address) + APECS_DMA_WIN_BASE;
 169 }
 170 
 171 extern inline void * bus_to_virt(unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 172 {
 173         return phys_to_virt(address - APECS_DMA_WIN_BASE);
 174 }
 175 
 176 /*
 177  * I/O functions:
 178  *
 179  * Unlike Jensen, the APECS machines have no concept of local
 180  * I/O---everything goes over the PCI bus.
 181  *
 182  * There is plenty room for optimization here.  In particular,
 183  * the Alpha's insb/insw/extb/extw should be useful in moving
 184  * data to/from the right byte-lanes.
 185  */
 186 
 187 #define vuip    volatile unsigned int *
 188 
 189 extern inline unsigned int __inb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 190 {
 191         long result = *(vuip) ((addr << 5) + APECS_IO + 0x00);
 192         result >>= (addr & 3) * 8;
 193         return 0xffUL & result;
 194 }
 195 
 196 extern inline void __outb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 197 {
 198         unsigned int w;
 199 
 200         asm ("insbl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
 201         *(vuip) ((addr << 5) + APECS_IO + 0x00) = w;
 202         mb();
 203 }
 204 
 205 extern inline unsigned int __inw(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 206 {
 207         long result = *(vuip) ((addr << 5) + APECS_IO + 0x08);
 208         result >>= (addr & 3) * 8;
 209         return 0xffffUL & result;
 210 }
 211 
 212 extern inline void __outw(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 213 {
 214         unsigned int w;
 215 
 216         asm ("inswl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b));
 217         *(vuip) ((addr << 5) + APECS_IO + 0x08) = w;
 218         mb();
 219 }
 220 
 221 extern inline unsigned int __inl(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 222 {
 223         return *(vuip) ((addr << 5) + APECS_IO + 0x18);
 224 }
 225 
 226 extern inline void __outl(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 227 {
 228         *(vuip) ((addr << 5) + APECS_IO + 0x18) = b;
 229         mb();
 230 }
 231 
 232 
 233 /*
 234  * Memory functions.  64-bit and 32-bit accesses are done through
 235  * dense memory space, everything else through sparse space.
 236  */
 237 extern inline unsigned long __readb(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 238 {
 239         unsigned long result, shift, msb;
 240 
 241         shift = (addr & 0x3) * 8;
 242         if (addr >= (1UL << 24)) {
 243                 msb = addr & 0xf8000000;
 244                 addr -= msb;
 245                 if (msb != hae.cache) {
 246                         set_hae(msb);
 247                 }
 248         }
 249         result = *(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x00);
 250         result >>= shift;
 251         return 0xffUL & result;
 252 }
 253 
 254 extern inline unsigned long __readw(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 255 {
 256         unsigned long result, shift, msb;
 257 
 258         shift = (addr & 0x3) * 8;
 259         if (addr >= (1UL << 24)) {
 260                 msb = addr & 0xf8000000;
 261                 addr -= msb;
 262                 if (msb != hae.cache) {
 263                         set_hae(msb);
 264                 }
 265         }
 266         result = *(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x08);
 267         result >>= shift;
 268         return 0xffffUL & result;
 269 }
 270 
 271 extern inline unsigned long __readl(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 272 {
 273         return *(vuip) (addr + APECS_DENSE_MEM);
 274 }
 275 
 276 extern inline void __writeb(unsigned char b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 277 {
 278         unsigned long msb;
 279 
 280         if (addr >= (1UL << 24)) {
 281                 msb = addr & 0xf8000000;
 282                 addr -= msb;
 283                 if (msb != hae.cache) {
 284                         set_hae(msb);
 285                 }
 286         }
 287         *(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x00) = b * 0x01010101;
 288 }
 289 
 290 extern inline void __writew(unsigned short b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 291 {
 292         unsigned long msb;
 293 
 294         if (addr >= (1UL << 24)) {
 295                 msb = addr & 0xf8000000;
 296                 addr -= msb;
 297                 if (msb != hae.cache) {
 298                         set_hae(msb);
 299                 }
 300         }
 301         *(vuip) ((addr << 5) + APECS_SPARSE_MEM + 0x08) = b * 0x00010001;
 302 }
 303 
 304 extern inline void __writel(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 305 {
 306         *(vuip) (addr + APECS_DENSE_MEM) = b;
 307 }
 308 
 309 /*
 310  * Most of the above have so much overhead that it probably doesn't
 311  * make sense to have them inlined (better icache behavior).
 312  */
 313 extern unsigned int inb(unsigned long addr);
 314 extern unsigned int inw(unsigned long addr);
 315 extern unsigned int inl(unsigned long addr);
 316 
 317 extern void outb(unsigned char b, unsigned long addr);
 318 extern void outw(unsigned short b, unsigned long addr);
 319 extern void outl(unsigned int b, unsigned long addr);
 320 
 321 extern unsigned long readb(unsigned long addr);
 322 extern unsigned long readw(unsigned long addr);
 323 
 324 extern void writeb(unsigned char b, unsigned long addr);
 325 extern void writew(unsigned short b, unsigned long addr);
 326 
 327 #define inb(port) \
 328 (__builtin_constant_p((port))?__inb(port):(inb)(port))
 329 
 330 #define outb(x, port) \
 331 (__builtin_constant_p((port))?__outb((x),(port)):(outb)((x),(port)))
 332 
 333 #define inb_p inb
 334 #define outb_p outb
 335 
 336 extern inline unsigned long readl(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 337 {
 338         return __readl(addr);
 339 }
 340 
 341 extern inline void writel(unsigned int b, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 342 {
 343         __writel(b, addr);
 344 }
 345 
 346 #undef vuip
 347 
 348 extern unsigned long apecs_init (unsigned long mem_start,
 349                                  unsigned long mem_end);
 350 
 351 #endif /* __KERNEL__ */
 352 
 353 /*
 354  * data structures for handling APECS machine checks
 355  */
 356 
 357 struct el_common_logout_header {
 358         u_int   elfl_size;              /* size in bytes of logout area. */
 359         int     elfl_sbz1:31;           /* Should be zero. */
 360         char    elfl_retry:1;           /* Retry flag. */
 361         u_int   elfl_procoffset;        /* Processor-specific offset. */
 362         u_int   elfl_sysoffset;         /* Offset of system-specific. */
 363 };
 364 
 365 struct el_apecs_sysdata_mcheck {
 366     u_long      coma_gcr;                       
 367     u_long      coma_edsr;                      
 368     u_long      coma_ter;                       
 369     u_long      coma_elar;                      
 370     u_long      coma_ehar;                      
 371     u_long      coma_ldlr;                      
 372     u_long      coma_ldhr;                      
 373     u_long      coma_base0;                     
 374     u_long      coma_base1;                     
 375     u_long      coma_base2;                     
 376     u_long      coma_cnfg0;                     
 377     u_long      coma_cnfg1;                     
 378     u_long      coma_cnfg2;                     
 379     u_long      epic_dcsr;                      
 380     u_long      epic_pear;                      
 381     u_long      epic_sear;                      
 382     u_long      epic_tbr1;                      
 383     u_long      epic_tbr2;                      
 384     u_long      epic_pbr1;                      
 385     u_long      epic_pbr2;                      
 386     u_long      epic_pmr1;                      
 387     u_long      epic_pmr2;                      
 388     u_long      epic_harx1;                     
 389     u_long      epic_harx2;                     
 390     u_long      epic_pmlt;                      
 391     u_long      epic_tag0;                      
 392     u_long      epic_tag1;                      
 393     u_long      epic_tag2;                      
 394     u_long      epic_tag3;                      
 395     u_long      epic_tag4;                      
 396     u_long      epic_tag5;                      
 397     u_long      epic_tag6;                      
 398     u_long      epic_tag7;                      
 399     u_long      epic_data0;                     
 400     u_long      epic_data1;                     
 401     u_long      epic_data2;                     
 402     u_long      epic_data3;                     
 403     u_long      epic_data4;                     
 404     u_long      epic_data5;                     
 405     u_long      epic_data6;                     
 406     u_long      epic_data7;                     
 407 };
 408 
 409 #define RTC_PORT(x)     (0x70 + (x))
 410 #define RTC_ADDR(x)     (0x80 | (x))
 411 #define RTC_ALWAYS_BCD  0
 412 
 413 #endif /* __ALPHA_APECS__H__ */

/* [previous][next][first][last][top][bottom][index][help] */