1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2024b246eSLinus Torvalds #ifndef __ALPHA_TSUNAMI__H__ 3024b246eSLinus Torvalds #define __ALPHA_TSUNAMI__H__ 4024b246eSLinus Torvalds 5024b246eSLinus Torvalds #include <linux/types.h> 6024b246eSLinus Torvalds #include <asm/compiler.h> 7024b246eSLinus Torvalds 8024b246eSLinus Torvalds /* 9024b246eSLinus Torvalds * TSUNAMI/TYPHOON are the internal names for the core logic chipset which 10024b246eSLinus Torvalds * provides memory controller and PCI access for the 21264 based systems. 11024b246eSLinus Torvalds * 12024b246eSLinus Torvalds * This file is based on: 13024b246eSLinus Torvalds * 14024b246eSLinus Torvalds * Tsunami System Programmers Manual 15024b246eSLinus Torvalds * Preliminary, Chapters 2-5 16024b246eSLinus Torvalds * 17024b246eSLinus Torvalds */ 18024b246eSLinus Torvalds 19024b246eSLinus Torvalds /* XXX: Do we need to conditionalize on this? */ 20024b246eSLinus Torvalds #ifdef USE_48_BIT_KSEG 21024b246eSLinus Torvalds #define TS_BIAS 0x80000000000UL 22024b246eSLinus Torvalds #else 23024b246eSLinus Torvalds #define TS_BIAS 0x10000000000UL 24024b246eSLinus Torvalds #endif 25024b246eSLinus Torvalds 26024b246eSLinus Torvalds /* 27024b246eSLinus Torvalds * CChip, DChip, and PChip registers 28024b246eSLinus Torvalds */ 29024b246eSLinus Torvalds 30024b246eSLinus Torvalds typedef struct { 31024b246eSLinus Torvalds volatile unsigned long csr __attribute__((aligned(64))); 32024b246eSLinus Torvalds } tsunami_64; 33024b246eSLinus Torvalds 34024b246eSLinus Torvalds typedef struct { 35024b246eSLinus Torvalds tsunami_64 csc; 36024b246eSLinus Torvalds tsunami_64 mtr; 37024b246eSLinus Torvalds tsunami_64 misc; 38024b246eSLinus Torvalds tsunami_64 mpd; 39024b246eSLinus Torvalds tsunami_64 aar0; 40024b246eSLinus Torvalds tsunami_64 aar1; 41024b246eSLinus Torvalds tsunami_64 aar2; 42024b246eSLinus Torvalds tsunami_64 aar3; 43024b246eSLinus Torvalds tsunami_64 dim0; 44024b246eSLinus Torvalds tsunami_64 dim1; 45024b246eSLinus Torvalds tsunami_64 dir0; 46024b246eSLinus Torvalds tsunami_64 dir1; 47024b246eSLinus Torvalds tsunami_64 drir; 48024b246eSLinus Torvalds tsunami_64 prben; 49024b246eSLinus Torvalds tsunami_64 iic; /* a.k.a. iic0 */ 50024b246eSLinus Torvalds tsunami_64 wdr; /* a.k.a. iic1 */ 51024b246eSLinus Torvalds tsunami_64 mpr0; 52024b246eSLinus Torvalds tsunami_64 mpr1; 53024b246eSLinus Torvalds tsunami_64 mpr2; 54024b246eSLinus Torvalds tsunami_64 mpr3; 55024b246eSLinus Torvalds tsunami_64 mctl; 56024b246eSLinus Torvalds tsunami_64 __pad1; 57024b246eSLinus Torvalds tsunami_64 ttr; 58024b246eSLinus Torvalds tsunami_64 tdr; 59024b246eSLinus Torvalds tsunami_64 dim2; 60024b246eSLinus Torvalds tsunami_64 dim3; 61024b246eSLinus Torvalds tsunami_64 dir2; 62024b246eSLinus Torvalds tsunami_64 dir3; 63024b246eSLinus Torvalds tsunami_64 iic2; 64024b246eSLinus Torvalds tsunami_64 iic3; 65024b246eSLinus Torvalds } tsunami_cchip; 66024b246eSLinus Torvalds 67024b246eSLinus Torvalds typedef struct { 68024b246eSLinus Torvalds tsunami_64 dsc; 69024b246eSLinus Torvalds tsunami_64 str; 70024b246eSLinus Torvalds tsunami_64 drev; 71024b246eSLinus Torvalds } tsunami_dchip; 72024b246eSLinus Torvalds 73024b246eSLinus Torvalds typedef struct { 74024b246eSLinus Torvalds tsunami_64 wsba[4]; 75024b246eSLinus Torvalds tsunami_64 wsm[4]; 76024b246eSLinus Torvalds tsunami_64 tba[4]; 77024b246eSLinus Torvalds tsunami_64 pctl; 78024b246eSLinus Torvalds tsunami_64 plat; 79024b246eSLinus Torvalds tsunami_64 reserved; 80024b246eSLinus Torvalds tsunami_64 perror; 81024b246eSLinus Torvalds tsunami_64 perrmask; 82024b246eSLinus Torvalds tsunami_64 perrset; 83024b246eSLinus Torvalds tsunami_64 tlbiv; 84024b246eSLinus Torvalds tsunami_64 tlbia; 85024b246eSLinus Torvalds tsunami_64 pmonctl; 86024b246eSLinus Torvalds tsunami_64 pmoncnt; 87024b246eSLinus Torvalds } tsunami_pchip; 88024b246eSLinus Torvalds 89024b246eSLinus Torvalds #define TSUNAMI_cchip ((tsunami_cchip *)(IDENT_ADDR+TS_BIAS+0x1A0000000UL)) 90024b246eSLinus Torvalds #define TSUNAMI_dchip ((tsunami_dchip *)(IDENT_ADDR+TS_BIAS+0x1B0000800UL)) 91024b246eSLinus Torvalds #define TSUNAMI_pchip0 ((tsunami_pchip *)(IDENT_ADDR+TS_BIAS+0x180000000UL)) 92024b246eSLinus Torvalds #define TSUNAMI_pchip1 ((tsunami_pchip *)(IDENT_ADDR+TS_BIAS+0x380000000UL)) 93024b246eSLinus Torvalds extern int TSUNAMI_bootcpu; 94024b246eSLinus Torvalds 95024b246eSLinus Torvalds /* 96024b246eSLinus Torvalds * TSUNAMI Pchip Error register. 97024b246eSLinus Torvalds */ 98024b246eSLinus Torvalds 99024b246eSLinus Torvalds #define perror_m_lost 0x1 100024b246eSLinus Torvalds #define perror_m_serr 0x2 101024b246eSLinus Torvalds #define perror_m_perr 0x4 102024b246eSLinus Torvalds #define perror_m_dcrto 0x8 103024b246eSLinus Torvalds #define perror_m_sge 0x10 104024b246eSLinus Torvalds #define perror_m_ape 0x20 105024b246eSLinus Torvalds #define perror_m_ta 0x40 106024b246eSLinus Torvalds #define perror_m_rdpe 0x80 107024b246eSLinus Torvalds #define perror_m_nds 0x100 108024b246eSLinus Torvalds #define perror_m_rto 0x200 109024b246eSLinus Torvalds #define perror_m_uecc 0x400 110024b246eSLinus Torvalds #define perror_m_cre 0x800 111024b246eSLinus Torvalds #define perror_m_addrl 0xFFFFFFFF0000UL 112024b246eSLinus Torvalds #define perror_m_addrh 0x7000000000000UL 113024b246eSLinus Torvalds #define perror_m_cmd 0xF0000000000000UL 114024b246eSLinus Torvalds #define perror_m_syn 0xFF00000000000000UL 115024b246eSLinus Torvalds union TPchipPERROR { 116024b246eSLinus Torvalds struct { 117024b246eSLinus Torvalds unsigned int perror_v_lost : 1; 118024b246eSLinus Torvalds unsigned perror_v_serr : 1; 119024b246eSLinus Torvalds unsigned perror_v_perr : 1; 120024b246eSLinus Torvalds unsigned perror_v_dcrto : 1; 121024b246eSLinus Torvalds unsigned perror_v_sge : 1; 122024b246eSLinus Torvalds unsigned perror_v_ape : 1; 123024b246eSLinus Torvalds unsigned perror_v_ta : 1; 124024b246eSLinus Torvalds unsigned perror_v_rdpe : 1; 125024b246eSLinus Torvalds unsigned perror_v_nds : 1; 126024b246eSLinus Torvalds unsigned perror_v_rto : 1; 127024b246eSLinus Torvalds unsigned perror_v_uecc : 1; 128024b246eSLinus Torvalds unsigned perror_v_cre : 1; 129024b246eSLinus Torvalds unsigned perror_v_rsvd1 : 4; 130024b246eSLinus Torvalds unsigned perror_v_addrl : 32; 131024b246eSLinus Torvalds unsigned perror_v_addrh : 3; 132024b246eSLinus Torvalds unsigned perror_v_rsvd2 : 1; 133024b246eSLinus Torvalds unsigned perror_v_cmd : 4; 134024b246eSLinus Torvalds unsigned perror_v_syn : 8; 135024b246eSLinus Torvalds } perror_r_bits; 136024b246eSLinus Torvalds int perror_q_whole [2]; 137024b246eSLinus Torvalds }; 138024b246eSLinus Torvalds 139024b246eSLinus Torvalds /* 140024b246eSLinus Torvalds * TSUNAMI Pchip Window Space Base Address register. 141024b246eSLinus Torvalds */ 142024b246eSLinus Torvalds #define wsba_m_ena 0x1 143024b246eSLinus Torvalds #define wsba_m_sg 0x2 144024b246eSLinus Torvalds #define wsba_m_ptp 0x4 145024b246eSLinus Torvalds #define wsba_m_addr 0xFFF00000 146024b246eSLinus Torvalds #define wmask_k_sz1gb 0x3FF00000 147024b246eSLinus Torvalds union TPchipWSBA { 148024b246eSLinus Torvalds struct { 149024b246eSLinus Torvalds unsigned wsba_v_ena : 1; 150024b246eSLinus Torvalds unsigned wsba_v_sg : 1; 151024b246eSLinus Torvalds unsigned wsba_v_ptp : 1; 152024b246eSLinus Torvalds unsigned wsba_v_rsvd1 : 17; 153024b246eSLinus Torvalds unsigned wsba_v_addr : 12; 154024b246eSLinus Torvalds unsigned wsba_v_rsvd2 : 32; 155024b246eSLinus Torvalds } wsba_r_bits; 156024b246eSLinus Torvalds int wsba_q_whole [2]; 157024b246eSLinus Torvalds }; 158024b246eSLinus Torvalds 159024b246eSLinus Torvalds /* 160024b246eSLinus Torvalds * TSUNAMI Pchip Control Register 161024b246eSLinus Torvalds */ 162024b246eSLinus Torvalds #define pctl_m_fdsc 0x1 163024b246eSLinus Torvalds #define pctl_m_fbtb 0x2 164024b246eSLinus Torvalds #define pctl_m_thdis 0x4 165024b246eSLinus Torvalds #define pctl_m_chaindis 0x8 166024b246eSLinus Torvalds #define pctl_m_tgtlat 0x10 167024b246eSLinus Torvalds #define pctl_m_hole 0x20 168024b246eSLinus Torvalds #define pctl_m_mwin 0x40 169024b246eSLinus Torvalds #define pctl_m_arbena 0x80 170024b246eSLinus Torvalds #define pctl_m_prigrp 0x7F00 171024b246eSLinus Torvalds #define pctl_m_ppri 0x8000 172024b246eSLinus Torvalds #define pctl_m_rsvd1 0x30000 173024b246eSLinus Torvalds #define pctl_m_eccen 0x40000 174024b246eSLinus Torvalds #define pctl_m_padm 0x80000 175024b246eSLinus Torvalds #define pctl_m_cdqmax 0xF00000 176024b246eSLinus Torvalds #define pctl_m_rev 0xFF000000 177024b246eSLinus Torvalds #define pctl_m_crqmax 0xF00000000UL 178024b246eSLinus Torvalds #define pctl_m_ptpmax 0xF000000000UL 179024b246eSLinus Torvalds #define pctl_m_pclkx 0x30000000000UL 180024b246eSLinus Torvalds #define pctl_m_fdsdis 0x40000000000UL 181024b246eSLinus Torvalds #define pctl_m_fdwdis 0x80000000000UL 182024b246eSLinus Torvalds #define pctl_m_ptevrfy 0x100000000000UL 183024b246eSLinus Torvalds #define pctl_m_rpp 0x200000000000UL 184024b246eSLinus Torvalds #define pctl_m_pid 0xC00000000000UL 185024b246eSLinus Torvalds #define pctl_m_rsvd2 0xFFFF000000000000UL 186024b246eSLinus Torvalds 187024b246eSLinus Torvalds union TPchipPCTL { 188024b246eSLinus Torvalds struct { 189024b246eSLinus Torvalds unsigned pctl_v_fdsc : 1; 190024b246eSLinus Torvalds unsigned pctl_v_fbtb : 1; 191024b246eSLinus Torvalds unsigned pctl_v_thdis : 1; 192024b246eSLinus Torvalds unsigned pctl_v_chaindis : 1; 193024b246eSLinus Torvalds unsigned pctl_v_tgtlat : 1; 194024b246eSLinus Torvalds unsigned pctl_v_hole : 1; 195024b246eSLinus Torvalds unsigned pctl_v_mwin : 1; 196024b246eSLinus Torvalds unsigned pctl_v_arbena : 1; 197024b246eSLinus Torvalds unsigned pctl_v_prigrp : 7; 198024b246eSLinus Torvalds unsigned pctl_v_ppri : 1; 199024b246eSLinus Torvalds unsigned pctl_v_rsvd1 : 2; 200024b246eSLinus Torvalds unsigned pctl_v_eccen : 1; 201024b246eSLinus Torvalds unsigned pctl_v_padm : 1; 202024b246eSLinus Torvalds unsigned pctl_v_cdqmax : 4; 203024b246eSLinus Torvalds unsigned pctl_v_rev : 8; 204024b246eSLinus Torvalds unsigned pctl_v_crqmax : 4; 205024b246eSLinus Torvalds unsigned pctl_v_ptpmax : 4; 206024b246eSLinus Torvalds unsigned pctl_v_pclkx : 2; 207024b246eSLinus Torvalds unsigned pctl_v_fdsdis : 1; 208024b246eSLinus Torvalds unsigned pctl_v_fdwdis : 1; 209024b246eSLinus Torvalds unsigned pctl_v_ptevrfy : 1; 210024b246eSLinus Torvalds unsigned pctl_v_rpp : 1; 211024b246eSLinus Torvalds unsigned pctl_v_pid : 2; 212024b246eSLinus Torvalds unsigned pctl_v_rsvd2 : 16; 213024b246eSLinus Torvalds } pctl_r_bits; 214024b246eSLinus Torvalds int pctl_q_whole [2]; 215024b246eSLinus Torvalds }; 216024b246eSLinus Torvalds 217024b246eSLinus Torvalds /* 218024b246eSLinus Torvalds * TSUNAMI Pchip Error Mask Register. 219024b246eSLinus Torvalds */ 220024b246eSLinus Torvalds #define perrmask_m_lost 0x1 221024b246eSLinus Torvalds #define perrmask_m_serr 0x2 222024b246eSLinus Torvalds #define perrmask_m_perr 0x4 223024b246eSLinus Torvalds #define perrmask_m_dcrto 0x8 224024b246eSLinus Torvalds #define perrmask_m_sge 0x10 225024b246eSLinus Torvalds #define perrmask_m_ape 0x20 226024b246eSLinus Torvalds #define perrmask_m_ta 0x40 227024b246eSLinus Torvalds #define perrmask_m_rdpe 0x80 228024b246eSLinus Torvalds #define perrmask_m_nds 0x100 229024b246eSLinus Torvalds #define perrmask_m_rto 0x200 230024b246eSLinus Torvalds #define perrmask_m_uecc 0x400 231024b246eSLinus Torvalds #define perrmask_m_cre 0x800 232024b246eSLinus Torvalds #define perrmask_m_rsvd 0xFFFFFFFFFFFFF000UL 233024b246eSLinus Torvalds union TPchipPERRMASK { 234024b246eSLinus Torvalds struct { 235024b246eSLinus Torvalds unsigned int perrmask_v_lost : 1; 236024b246eSLinus Torvalds unsigned perrmask_v_serr : 1; 237024b246eSLinus Torvalds unsigned perrmask_v_perr : 1; 238024b246eSLinus Torvalds unsigned perrmask_v_dcrto : 1; 239024b246eSLinus Torvalds unsigned perrmask_v_sge : 1; 240024b246eSLinus Torvalds unsigned perrmask_v_ape : 1; 241024b246eSLinus Torvalds unsigned perrmask_v_ta : 1; 242024b246eSLinus Torvalds unsigned perrmask_v_rdpe : 1; 243024b246eSLinus Torvalds unsigned perrmask_v_nds : 1; 244024b246eSLinus Torvalds unsigned perrmask_v_rto : 1; 245024b246eSLinus Torvalds unsigned perrmask_v_uecc : 1; 246024b246eSLinus Torvalds unsigned perrmask_v_cre : 1; 247024b246eSLinus Torvalds unsigned perrmask_v_rsvd1 : 20; 248024b246eSLinus Torvalds unsigned perrmask_v_rsvd2 : 32; 249024b246eSLinus Torvalds } perrmask_r_bits; 250024b246eSLinus Torvalds int perrmask_q_whole [2]; 251024b246eSLinus Torvalds }; 252024b246eSLinus Torvalds 253024b246eSLinus Torvalds /* 254024b246eSLinus Torvalds * Memory spaces: 255024b246eSLinus Torvalds */ 256024b246eSLinus Torvalds #define TSUNAMI_HOSE(h) (((unsigned long)(h)) << 33) 257024b246eSLinus Torvalds #define TSUNAMI_BASE (IDENT_ADDR + TS_BIAS) 258024b246eSLinus Torvalds 259024b246eSLinus Torvalds #define TSUNAMI_MEM(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x000000000UL) 260024b246eSLinus Torvalds #define _TSUNAMI_IACK_SC(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1F8000000UL) 261024b246eSLinus Torvalds #define TSUNAMI_IO(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1FC000000UL) 262024b246eSLinus Torvalds #define TSUNAMI_CONF(h) (TSUNAMI_BASE+TSUNAMI_HOSE(h) + 0x1FE000000UL) 263024b246eSLinus Torvalds 264024b246eSLinus Torvalds #define TSUNAMI_IACK_SC _TSUNAMI_IACK_SC(0) /* hack! */ 265024b246eSLinus Torvalds 266024b246eSLinus Torvalds 267024b246eSLinus Torvalds /* 268024b246eSLinus Torvalds * The canonical non-remaped I/O and MEM addresses have these values 269024b246eSLinus Torvalds * subtracted out. This is arranged so that folks manipulating ISA 270024b246eSLinus Torvalds * devices can use their familiar numbers and have them map to bus 0. 271024b246eSLinus Torvalds */ 272024b246eSLinus Torvalds 273024b246eSLinus Torvalds #define TSUNAMI_IO_BIAS TSUNAMI_IO(0) 274024b246eSLinus Torvalds #define TSUNAMI_MEM_BIAS TSUNAMI_MEM(0) 275024b246eSLinus Torvalds 276024b246eSLinus Torvalds /* The IO address space is larger than 0xffff */ 277024b246eSLinus Torvalds #define TSUNAMI_IO_SPACE (TSUNAMI_CONF(0) - TSUNAMI_IO(0)) 278024b246eSLinus Torvalds 279024b246eSLinus Torvalds /* Offset between ram physical addresses and pci64 DAC bus addresses. */ 280024b246eSLinus Torvalds #define TSUNAMI_DAC_OFFSET (1UL << 40) 281024b246eSLinus Torvalds 282024b246eSLinus Torvalds /* 283024b246eSLinus Torvalds * Data structure for handling TSUNAMI machine checks: 284024b246eSLinus Torvalds */ 285024b246eSLinus Torvalds struct el_TSUNAMI_sysdata_mcheck { 286024b246eSLinus Torvalds }; 287024b246eSLinus Torvalds 288024b246eSLinus Torvalds 289024b246eSLinus Torvalds #ifdef __KERNEL__ 290024b246eSLinus Torvalds 291024b246eSLinus Torvalds #ifndef __EXTERN_INLINE 292024b246eSLinus Torvalds #define __EXTERN_INLINE extern inline 293024b246eSLinus Torvalds #define __IO_EXTERN_INLINE 294024b246eSLinus Torvalds #endif 295024b246eSLinus Torvalds 296024b246eSLinus Torvalds /* 297024b246eSLinus Torvalds * I/O functions: 298024b246eSLinus Torvalds * 299024b246eSLinus Torvalds * TSUNAMI, the 21??? PCI/memory support chipset for the EV6 (21264) 300024b246eSLinus Torvalds * can only use linear accesses to get at PCI memory and I/O spaces. 301024b246eSLinus Torvalds */ 302024b246eSLinus Torvalds 303024b246eSLinus Torvalds /* 304024b246eSLinus Torvalds * Memory functions. all accesses are done through linear space. 305024b246eSLinus Torvalds */ 306024b246eSLinus Torvalds extern void __iomem *tsunami_ioportmap(unsigned long addr); 307024b246eSLinus Torvalds extern void __iomem *tsunami_ioremap(unsigned long addr, unsigned long size); tsunami_is_ioaddr(unsigned long addr)308024b246eSLinus Torvalds__EXTERN_INLINE int tsunami_is_ioaddr(unsigned long addr) 309024b246eSLinus Torvalds { 310024b246eSLinus Torvalds return addr >= TSUNAMI_BASE; 311024b246eSLinus Torvalds } 312024b246eSLinus Torvalds tsunami_is_mmio(const volatile void __iomem * xaddr)313024b246eSLinus Torvalds__EXTERN_INLINE int tsunami_is_mmio(const volatile void __iomem *xaddr) 314024b246eSLinus Torvalds { 315024b246eSLinus Torvalds unsigned long addr = (unsigned long) xaddr; 316024b246eSLinus Torvalds return (addr & 0x100000000UL) == 0; 317024b246eSLinus Torvalds } 318024b246eSLinus Torvalds 319024b246eSLinus Torvalds #undef __IO_PREFIX 320024b246eSLinus Torvalds #define __IO_PREFIX tsunami 321024b246eSLinus Torvalds #define tsunami_trivial_rw_bw 1 322024b246eSLinus Torvalds #define tsunami_trivial_rw_lq 1 323024b246eSLinus Torvalds #define tsunami_trivial_io_bw 1 324024b246eSLinus Torvalds #define tsunami_trivial_io_lq 1 325024b246eSLinus Torvalds #define tsunami_trivial_iounmap 1 326024b246eSLinus Torvalds #include <asm/io_trivial.h> 327024b246eSLinus Torvalds 328024b246eSLinus Torvalds #ifdef __IO_EXTERN_INLINE 329024b246eSLinus Torvalds #undef __EXTERN_INLINE 330024b246eSLinus Torvalds #undef __IO_EXTERN_INLINE 331024b246eSLinus Torvalds #endif 332024b246eSLinus Torvalds 333024b246eSLinus Torvalds #endif /* __KERNEL__ */ 334024b246eSLinus Torvalds 335024b246eSLinus Torvalds #endif /* __ALPHA_TSUNAMI__H__ */ 336