1 #ifndef __ALPHA_T2__H__
2 #define __ALPHA_T2__H__
4 #include <linux/config.h>
5 #include <linux/types.h>
6 #include <asm/compiler.h>
10 * T2 is the internal name for the core logic chipset which provides
11 * memory controller and PCI access for the SABLE-based systems.
13 * This file is based on:
15 * SABLE I/O Specification
16 * Revision/Update Information: 1.3
18 * jestabro@amt.tay1.dec.com Initial Version.
22 #define T2_MEM_R1_MASK 0x07ffffff /* Mem sparse region 1 mask is 26 bits */
24 /* GAMMA-SABLE is a SABLE with EV5-based CPUs */
25 #define _GAMMA_BIAS 0x8000000000UL
27 #if defined(CONFIG_ALPHA_GENERIC)
28 #define GAMMA_BIAS alpha_mv.sys.t2.gamma_bias
29 #elif defined(CONFIG_ALPHA_GAMMA)
30 #define GAMMA_BIAS _GAMMA_BIAS
38 #define T2_CONF (IDENT_ADDR + GAMMA_BIAS + 0x390000000UL)
39 #define T2_IO (IDENT_ADDR + GAMMA_BIAS + 0x3a0000000UL)
40 #define T2_SPARSE_MEM (IDENT_ADDR + GAMMA_BIAS + 0x200000000UL)
41 #define T2_DENSE_MEM (IDENT_ADDR + GAMMA_BIAS + 0x3c0000000UL)
43 #define T2_IOCSR (IDENT_ADDR + GAMMA_BIAS + 0x38e000000UL)
44 #define T2_CERR1 (IDENT_ADDR + GAMMA_BIAS + 0x38e000020UL)
45 #define T2_CERR2 (IDENT_ADDR + GAMMA_BIAS + 0x38e000040UL)
46 #define T2_CERR3 (IDENT_ADDR + GAMMA_BIAS + 0x38e000060UL)
47 #define T2_PERR1 (IDENT_ADDR + GAMMA_BIAS + 0x38e000080UL)
48 #define T2_PERR2 (IDENT_ADDR + GAMMA_BIAS + 0x38e0000a0UL)
49 #define T2_PSCR (IDENT_ADDR + GAMMA_BIAS + 0x38e0000c0UL)
50 #define T2_HAE_1 (IDENT_ADDR + GAMMA_BIAS + 0x38e0000e0UL)
51 #define T2_HAE_2 (IDENT_ADDR + GAMMA_BIAS + 0x38e000100UL)
52 #define T2_HBASE (IDENT_ADDR + GAMMA_BIAS + 0x38e000120UL)
53 #define T2_WBASE1 (IDENT_ADDR + GAMMA_BIAS + 0x38e000140UL)
54 #define T2_WMASK1 (IDENT_ADDR + GAMMA_BIAS + 0x38e000160UL)
55 #define T2_TBASE1 (IDENT_ADDR + GAMMA_BIAS + 0x38e000180UL)
56 #define T2_WBASE2 (IDENT_ADDR + GAMMA_BIAS + 0x38e0001a0UL)
57 #define T2_WMASK2 (IDENT_ADDR + GAMMA_BIAS + 0x38e0001c0UL)
58 #define T2_TBASE2 (IDENT_ADDR + GAMMA_BIAS + 0x38e0001e0UL)
59 #define T2_TLBBR (IDENT_ADDR + GAMMA_BIAS + 0x38e000200UL)
61 #define T2_HAE_3 (IDENT_ADDR + GAMMA_BIAS + 0x38e000240UL)
62 #define T2_HAE_4 (IDENT_ADDR + GAMMA_BIAS + 0x38e000260UL)
64 #define T2_HAE_ADDRESS T2_HAE_1
66 /* T2 CSRs are in the non-cachable primary IO space from 3.8000.0000 to
69 * +--------------+ 3 8000 0000
71 * +--------------+ 3 8100 0000
73 * +--------------+ 3 8200 0000
75 * +--------------+ 3 8300 0000
77 * +--------------+ 3 8400 0000
79 * +--------------+ 3 8700 0000
81 * +--------------+ 3 8800 0000
83 * +--------------+ 3 8900 0000
85 * +--------------+ 3 8a00 0000
87 * +--------------+ 3 8b00 0000
89 * +--------------+ 3 8c00 0000
91 * +--------------+ 3 8e00 0000
93 * +--------------+ 3 8f00 0000
95 * +--------------+ 3 9000 0000
99 #define T2_CPU0_BASE (IDENT_ADDR + GAMMA_BIAS + 0x380000000L)
100 #define T2_CPU1_BASE (IDENT_ADDR + GAMMA_BIAS + 0x381000000L)
101 #define T2_CPU2_BASE (IDENT_ADDR + GAMMA_BIAS + 0x382000000L)
102 #define T2_CPU3_BASE (IDENT_ADDR + GAMMA_BIAS + 0x383000000L)
103 #define T2_MEM0_BASE (IDENT_ADDR + GAMMA_BIAS + 0x388000000L)
104 #define T2_MEM1_BASE (IDENT_ADDR + GAMMA_BIAS + 0x389000000L)
105 #define T2_MEM2_BASE (IDENT_ADDR + GAMMA_BIAS + 0x38a000000L)
106 #define T2_MEM3_BASE (IDENT_ADDR + GAMMA_BIAS + 0x38b000000L)
110 * Sable CPU Module CSRS
112 * These are CSRs for hardware other than the CPU chip on the CPU module.
113 * The CPU module has Backup Cache control logic, Cbus control logic, and
114 * interrupt control logic on it. There is a duplicate tag store to speed
115 * up maintaining cache coherency.
118 struct sable_cpu_csr {
119 unsigned long bcc; long fill_00[3]; /* Backup Cache Control */
120 unsigned long bcce; long fill_01[3]; /* Backup Cache Correctable Error */
121 unsigned long bccea; long fill_02[3]; /* B-Cache Corr Err Address Latch */
122 unsigned long bcue; long fill_03[3]; /* B-Cache Uncorrectable Error */
123 unsigned long bcuea; long fill_04[3]; /* B-Cache Uncorr Err Addr Latch */
124 unsigned long dter; long fill_05[3]; /* Duplicate Tag Error */
125 unsigned long cbctl; long fill_06[3]; /* CBus Control */
126 unsigned long cbe; long fill_07[3]; /* CBus Error */
127 unsigned long cbeal; long fill_08[3]; /* CBus Error Addr Latch low */
128 unsigned long cbeah; long fill_09[3]; /* CBus Error Addr Latch high */
129 unsigned long pmbx; long fill_10[3]; /* Processor Mailbox */
130 unsigned long ipir; long fill_11[3]; /* Inter-Processor Int Request */
131 unsigned long sic; long fill_12[3]; /* System Interrupt Clear */
132 unsigned long adlk; long fill_13[3]; /* Address Lock (LDxL/STxC) */
133 unsigned long madrl; long fill_14[3]; /* CBus Miss Address */
134 unsigned long rev; long fill_15[3]; /* CMIC Revision */
138 * Data structure for handling T2 machine checks:
140 struct el_t2_frame_header {
141 unsigned int elcf_fid; /* Frame ID (from above) */
142 unsigned int elcf_size; /* Size of frame in bytes */
145 struct el_t2_procdata_mcheck {
146 unsigned long elfmc_paltemp[32]; /* PAL TEMP REGS. */
147 /* EV4-specific fields */
148 unsigned long elfmc_exc_addr; /* Addr of excepting insn. */
149 unsigned long elfmc_exc_sum; /* Summary of arith traps. */
150 unsigned long elfmc_exc_mask; /* Exception mask (from exc_sum). */
151 unsigned long elfmc_iccsr; /* IBox hardware enables. */
152 unsigned long elfmc_pal_base; /* Base address for PALcode. */
153 unsigned long elfmc_hier; /* Hardware Interrupt Enable. */
154 unsigned long elfmc_hirr; /* Hardware Interrupt Request. */
155 unsigned long elfmc_mm_csr; /* D-stream fault info. */
156 unsigned long elfmc_dc_stat; /* D-cache status (ECC/Parity Err). */
157 unsigned long elfmc_dc_addr; /* EV3 Phys Addr for ECC/DPERR. */
158 unsigned long elfmc_abox_ctl; /* ABox Control Register. */
159 unsigned long elfmc_biu_stat; /* BIU Status. */
160 unsigned long elfmc_biu_addr; /* BUI Address. */
161 unsigned long elfmc_biu_ctl; /* BIU Control. */
162 unsigned long elfmc_fill_syndrome; /* For correcting ECC errors. */
163 unsigned long elfmc_fill_addr;/* Cache block which was being read. */
164 unsigned long elfmc_va; /* Effective VA of fault or miss. */
165 unsigned long elfmc_bc_tag; /* Backup Cache Tag Probe Results. */
169 * Sable processor specific Machine Check Data segment.
172 struct el_t2_logout_header {
173 unsigned int elfl_size; /* size in bytes of logout area. */
174 int elfl_sbz1:31; /* Should be zero. */
175 char elfl_retry:1; /* Retry flag. */
176 unsigned int elfl_procoffset; /* Processor-specific offset. */
177 unsigned int elfl_sysoffset; /* Offset of system-specific. */
178 unsigned int elfl_error_type; /* PAL error type code. */
179 unsigned int elfl_frame_rev; /* PAL Frame revision. */
181 struct el_t2_sysdata_mcheck {
182 unsigned long elcmc_bcc; /* CSR 0 */
183 unsigned long elcmc_bcce; /* CSR 1 */
184 unsigned long elcmc_bccea; /* CSR 2 */
185 unsigned long elcmc_bcue; /* CSR 3 */
186 unsigned long elcmc_bcuea; /* CSR 4 */
187 unsigned long elcmc_dter; /* CSR 5 */
188 unsigned long elcmc_cbctl; /* CSR 6 */
189 unsigned long elcmc_cbe; /* CSR 7 */
190 unsigned long elcmc_cbeal; /* CSR 8 */
191 unsigned long elcmc_cbeah; /* CSR 9 */
192 unsigned long elcmc_pmbx; /* CSR 10 */
193 unsigned long elcmc_ipir; /* CSR 11 */
194 unsigned long elcmc_sic; /* CSR 12 */
195 unsigned long elcmc_adlk; /* CSR 13 */
196 unsigned long elcmc_madrl; /* CSR 14 */
197 unsigned long elcmc_crrev4; /* CSR 15 */
201 * Sable memory error frame - sable pfms section 3.42
203 struct el_t2_data_memory {
204 struct el_t2_frame_header elcm_hdr; /* ID$MEM-FERR = 0x08 */
205 unsigned int elcm_module; /* Module id. */
206 unsigned int elcm_res04; /* Reserved. */
207 unsigned long elcm_merr; /* CSR0: Error Reg 1. */
208 unsigned long elcm_mcmd1; /* CSR1: Command Trap 1. */
209 unsigned long elcm_mcmd2; /* CSR2: Command Trap 2. */
210 unsigned long elcm_mconf; /* CSR3: Configuration. */
211 unsigned long elcm_medc1; /* CSR4: EDC Status 1. */
212 unsigned long elcm_medc2; /* CSR5: EDC Status 2. */
213 unsigned long elcm_medcc; /* CSR6: EDC Control. */
214 unsigned long elcm_msctl; /* CSR7: Stream Buffer Control. */
215 unsigned long elcm_mref; /* CSR8: Refresh Control. */
216 unsigned long elcm_filter; /* CSR9: CRD Filter Control. */
221 * Sable other CPU error frame - sable pfms section 3.43
223 struct el_t2_data_other_cpu {
224 short elco_cpuid; /* CPU ID */
226 unsigned long elco_bcc; /* CSR 0 */
227 unsigned long elco_bcce; /* CSR 1 */
228 unsigned long elco_bccea; /* CSR 2 */
229 unsigned long elco_bcue; /* CSR 3 */
230 unsigned long elco_bcuea; /* CSR 4 */
231 unsigned long elco_dter; /* CSR 5 */
232 unsigned long elco_cbctl; /* CSR 6 */
233 unsigned long elco_cbe; /* CSR 7 */
234 unsigned long elco_cbeal; /* CSR 8 */
235 unsigned long elco_cbeah; /* CSR 9 */
236 unsigned long elco_pmbx; /* CSR 10 */
237 unsigned long elco_ipir; /* CSR 11 */
238 unsigned long elco_sic; /* CSR 12 */
239 unsigned long elco_adlk; /* CSR 13 */
240 unsigned long elco_madrl; /* CSR 14 */
241 unsigned long elco_crrev4; /* CSR 15 */
245 * Sable other CPU error frame - sable pfms section 3.44
247 struct el_t2_data_t2{
248 struct el_t2_frame_header elct_hdr; /* ID$T2-FRAME */
249 unsigned long elct_iocsr; /* IO Control and Status Register */
250 unsigned long elct_cerr1; /* Cbus Error Register 1 */
251 unsigned long elct_cerr2; /* Cbus Error Register 2 */
252 unsigned long elct_cerr3; /* Cbus Error Register 3 */
253 unsigned long elct_perr1; /* PCI Error Register 1 */
254 unsigned long elct_perr2; /* PCI Error Register 2 */
255 unsigned long elct_hae0_1; /* High Address Extension Register 1 */
256 unsigned long elct_hae0_2; /* High Address Extension Register 2 */
257 unsigned long elct_hbase; /* High Base Register */
258 unsigned long elct_wbase1; /* Window Base Register 1 */
259 unsigned long elct_wmask1; /* Window Mask Register 1 */
260 unsigned long elct_tbase1; /* Translated Base Register 1 */
261 unsigned long elct_wbase2; /* Window Base Register 2 */
262 unsigned long elct_wmask2; /* Window Mask Register 2 */
263 unsigned long elct_tbase2; /* Translated Base Register 2 */
264 unsigned long elct_tdr0; /* TLB Data Register 0 */
265 unsigned long elct_tdr1; /* TLB Data Register 1 */
266 unsigned long elct_tdr2; /* TLB Data Register 2 */
267 unsigned long elct_tdr3; /* TLB Data Register 3 */
268 unsigned long elct_tdr4; /* TLB Data Register 4 */
269 unsigned long elct_tdr5; /* TLB Data Register 5 */
270 unsigned long elct_tdr6; /* TLB Data Register 6 */
271 unsigned long elct_tdr7; /* TLB Data Register 7 */
275 * Sable error log data structure - sable pfms section 3.40
277 struct el_t2_data_corrected {
278 unsigned long elcpb_biu_stat;
279 unsigned long elcpb_biu_addr;
280 unsigned long elcpb_biu_ctl;
281 unsigned long elcpb_fill_syndrome;
282 unsigned long elcpb_fill_addr;
283 unsigned long elcpb_bc_tag;
287 * Sable error log data structure
288 * Note there are 4 memory slots on sable (see t2.h)
290 struct el_t2_frame_mcheck {
291 struct el_t2_frame_header elfmc_header; /* ID$P-FRAME_MCHECK */
292 struct el_t2_logout_header elfmc_hdr;
293 struct el_t2_procdata_mcheck elfmc_procdata;
294 struct el_t2_sysdata_mcheck elfmc_sysdata;
295 struct el_t2_data_t2 elfmc_t2data;
296 struct el_t2_data_memory elfmc_memdata[4];
297 struct el_t2_frame_header elfmc_footer; /* empty */
302 * Sable error log data structures on memory errors
304 struct el_t2_frame_corrected {
305 struct el_t2_frame_header elfcc_header; /* ID$P-BC-COR */
306 struct el_t2_logout_header elfcc_hdr;
307 struct el_t2_data_corrected elfcc_procdata;
308 /* struct el_t2_data_t2 elfcc_t2data; */
309 /* struct el_t2_data_memory elfcc_memdata[4]; */
310 struct el_t2_frame_header elfcc_footer; /* empty */
316 #ifndef __EXTERN_INLINE
317 #define __EXTERN_INLINE extern inline
318 #define __IO_EXTERN_INLINE
324 * T2 (the core logic PCI/memory support chipset for the SABLE
325 * series of processors uses a sparse address mapping scheme to
326 * get at PCI memory and I/O.
329 #define vip volatile int *
330 #define vuip volatile unsigned int *
332 __EXTERN_INLINE u8 t2_inb(unsigned long addr)
334 long result = *(vip) ((addr << 5) + T2_IO + 0x00);
335 return __kernel_extbl(result, addr & 3);
338 __EXTERN_INLINE void t2_outb(u8 b, unsigned long addr)
342 w = __kernel_insbl(b, addr & 3);
343 *(vuip) ((addr << 5) + T2_IO + 0x00) = w;
347 __EXTERN_INLINE u16 t2_inw(unsigned long addr)
349 long result = *(vip) ((addr << 5) + T2_IO + 0x08);
350 return __kernel_extwl(result, addr & 3);
353 __EXTERN_INLINE void t2_outw(u16 b, unsigned long addr)
357 w = __kernel_inswl(b, addr & 3);
358 *(vuip) ((addr << 5) + T2_IO + 0x08) = w;
362 __EXTERN_INLINE u32 t2_inl(unsigned long addr)
364 return *(vuip) ((addr << 5) + T2_IO + 0x18);
367 __EXTERN_INLINE void t2_outl(u32 b, unsigned long addr)
369 *(vuip) ((addr << 5) + T2_IO + 0x18) = b;
377 * For reading and writing 8 and 16 bit quantities we need to
378 * go through one of the three sparse address mapping regions
379 * and use the HAE_MEM CSR to provide some bits of the address.
380 * The following few routines use only sparse address region 1
381 * which gives 1Gbyte of accessible space which relates exactly
382 * to the amount of PCI memory mapping *into* system address space.
383 * See p 6-17 of the specification but it looks something like this:
388 * 9876543210987654321098765432109876543210
389 * 1ZZZZ0.PCI.QW.Address............BBLL
393 * LL = Transfer length
398 * 10987654321098765432109876543210
399 * HHH....PCI.QW.Address........ 00
401 * HHH = 31:29 HAE_MEM CSR
405 #define t2_set_hae { \
407 addr &= T2_MEM_R1_MASK; \
411 __EXTERN_INLINE u8 t2_readb(unsigned long addr)
413 unsigned long result, msb;
417 result = *(vip) ((addr << 5) + T2_SPARSE_MEM + 0x00);
418 return __kernel_extbl(result, addr & 3);
421 __EXTERN_INLINE u16 t2_readw(unsigned long addr)
423 unsigned long result, msb;
427 result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08);
428 return __kernel_extwl(result, addr & 3);
431 /* On SABLE with T2, we must use SPARSE memory even for 32-bit access. */
432 __EXTERN_INLINE u32 t2_readl(unsigned long addr)
438 return *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18);
441 __EXTERN_INLINE u64 t2_readq(unsigned long addr)
443 unsigned long r0, r1, work, msb;
447 work = (addr << 5) + T2_SPARSE_MEM + 0x18;
449 r1 = *(vuip)(work + (4 << 5));
450 return r1 << 32 | r0;
453 __EXTERN_INLINE void t2_writeb(u8 b, unsigned long addr)
455 unsigned long msb, w;
459 w = __kernel_insbl(b, addr & 3);
460 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x00) = w;
463 __EXTERN_INLINE void t2_writew(u16 b, unsigned long addr)
465 unsigned long msb, w;
469 w = __kernel_inswl(b, addr & 3);
470 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08) = w;
473 /* On SABLE with T2, we must use SPARSE memory even for 32-bit access. */
474 __EXTERN_INLINE void t2_writel(u32 b, unsigned long addr)
480 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18) = b;
483 __EXTERN_INLINE void t2_writeq(u64 b, unsigned long addr)
485 unsigned long msb, work;
489 work = (addr << 5) + T2_SPARSE_MEM + 0x18;
491 *(vuip)(work + (4 << 5)) = b >> 32;
494 __EXTERN_INLINE unsigned long t2_ioremap(unsigned long addr,
496 __attribute__((unused)))
501 __EXTERN_INLINE void t2_iounmap(unsigned long addr)
506 __EXTERN_INLINE int t2_is_ioaddr(unsigned long addr)
508 return (long)addr >= 0;
516 #define __inb(p) t2_inb((unsigned long)(p))
517 #define __inw(p) t2_inw((unsigned long)(p))
518 #define __inl(p) t2_inl((unsigned long)(p))
519 #define __outb(x,p) t2_outb((x),(unsigned long)(p))
520 #define __outw(x,p) t2_outw((x),(unsigned long)(p))
521 #define __outl(x,p) t2_outl((x),(unsigned long)(p))
522 #define __readb(a) t2_readb((unsigned long)(a))
523 #define __readw(a) t2_readw((unsigned long)(a))
524 #define __readl(a) t2_readl((unsigned long)(a))
525 #define __readq(a) t2_readq((unsigned long)(a))
526 #define __writeb(x,a) t2_writeb((x),(unsigned long)(a))
527 #define __writew(x,a) t2_writew((x),(unsigned long)(a))
528 #define __writel(x,a) t2_writel((x),(unsigned long)(a))
529 #define __writeq(x,a) t2_writeq((x),(unsigned long)(a))
530 #define __ioremap(a,s) t2_ioremap((unsigned long)(a),(s))
531 #define __iounmap(a) t2_iounmap((unsigned long)(a))
532 #define __is_ioaddr(a) t2_is_ioaddr((unsigned long)(a))
534 #endif /* __WANT_IO_DEF */
536 #ifdef __IO_EXTERN_INLINE
537 #undef __EXTERN_INLINE
538 #undef __IO_EXTERN_INLINE
541 #endif /* __KERNEL__ */
543 #endif /* __ALPHA_T2__H__ */