#define tsreg() { Generate ctags(1) key. }
#define S_PAGE(phys) ((void *)ALPHA_PHYS_TO_K0SEG(phys))
#define LDQP(a) (*(volatile long *)ALPHA_PHYS_TO_K0SEG(a))
#define STQP(a) LDQP(a)
#define TSFIELD(r,offs,len) (((r) >> (offs)) & (~0UL >> (64 - (len))))
#define TSFIELDBB(r,lb,rb) TSFIELD((r), (rb), (lb) - (rb) + 1)
#define TS_PHYSADDR(x) \
(((x) & ~0x0100##0000##0000) | 0x0800##0000##0000)
#define TS_C_CSC 0x101##a000##0000UL
# define CSC_P1P (1L << 14)
# define CSC_BC(r) TSFIELD((r), 0, 2)
# define CSC_AW (1L << 8)
#define TS_C_MTR 0x101##a000##0040UL
#define TS_C_MISC 0x101##a000##0080UL
# define MISC_NXM(r) TSFIELD((r), 28, 1)
# define MISC_NXM_SRC(r) TSFIELD((r), 29, 3)
# define MISC_REV(r) TSFIELD((r), 39, 8)
#define TS_C_MPD 0x101##a000##00c0UL
# define MPD_DR 0x08
# define MPD_CKR 0x04
# define MPD_DS 0x02
# define MPD_CKS 0x01
#define TS_C_AAR0 0x101##a000##0100UL
#define TS_C_AAR1 0x101##a000##0140UL
#define TS_C_AAR2 0x101##a000##0180UL
#define TS_C_AAR3 0x101##a000##01c0UL
# define AAR_ASIZ(r) TSFIELD((r), 12, 4)
# define AAR_SPLIT (1L << 8)
#define TS_C_DIM0 0x101##a000##0200UL
#define TS_C_DIM1 0x101##a000##0240UL
#define TS_C_DIR0 0x101##a000##0280UL
#define TS_C_DIR1 0x101##a000##02c0UL
#define TS_C_DRIR 0x101##a000##0300UL
#define TS_C_PRBEN 0x101##a000##0340UL
#define TS_C_IIC0 0x101##a000##0380UL
#define TS_C_IIC1 0x101##a000##03c0UL
#define TS_C_MPR0 0x101##a000##0400UL
#define TS_C_MPR1 0x101##a000##0440UL
#define TS_C_MPR2 0x101##a000##0480UL
#define TS_C_MPR3 0x101##a000##04c0UL
#define TS_C_MCTL 0x101##a000##0500UL
#define TS_C_TTR 0x101##a000##0580UL
#define TS_C_TDR 0x101##a000##05c0UL
#define TS_C_DIM2 0x101##a000##0600UL
#define TS_C_DIM3 0x101##a000##0640UL
#define TS_C_DIR2 0x101##a000##0680UL
#define TS_C_DIR3 0x101##a000##06c0UL
#define TS_C_IIC2 0x101##a000##0700UL
#define TS_C_IIC3 0x101##a000##0740UL
#define TS_D_DSC 0x101##b000##0800UL
#define TS_D_STR 0x101##b000##0840UL
#define TS_D_DREV 0x101##b000##0880UL
#define TS_D_DSC2 0x101##b000##08c0UL
#define P_WSBA0 0x0000
#define P_WSBA1 0x0040
#define P_WSBA2 0x0080
#define P_WSBA3 0x00c0
# define WSBA_ADDR(r) (TSFIELDBB((r), 31, 20) << 20)
# define WSBA3_DAC __BIT(39)
# define WSBA_SG __BIT(1)
# define WSBA_ENA __BIT(0)
#define P_WSM0 0x0100
#define P_WSM1 0x0140
#define P_WSM2 0x0180
#define P_WSM3 0x01c0
# define WSM_1MB (0x000UL << 20)
# define WSM_2MB (0x001UL << 20)
# define WSM_4MB (0x003UL << 20)
# define WSM_8MB (0x007UL << 20)
# define WSM_16MB (0x00fUL << 20)
# define WSM_32MB (0x01fUL << 20)
# define WSM_64MB (0x03fUL << 20)
# define WSM_128MB (0x07fUL << 20)
# define WSM_256MB (0x0ffUL << 20)
# define WSM_512MB (0x1ffUL << 20)
# define WSM_1GB (0x3ffUL << 20)
# define WSM_2GB (0x7ffUL << 20)
# define WSM_AM(r) TSFIELDBB((r), 31, 20)
# define WSM_LEN(r) ((WSM_AM(r) + 1) << 20)
#define P_TBA0 0x0200
#define P_TBA1 0x0240
#define P_TBA2 0x0280
#define P_TBA3 0x02c0
#define P_PCTL 0x0300
#define PCTL_FDSC __BIT(0)
#define PCTL_FBTB __BIT(1)
#define PCTL_THDIS __BIT(2)
#define PCTL_CHAINDIS __BIT(3)
#define PCTL_TGTLAT __BIT(4)
#define PCTL_HOLE __BIT(5)
#define PCTL_MWIN __BIT(6)
#define PCTL_PRIGRP __BITS(8,14)
#define PCTL_PPRI __BIT(15)
#define PCTL_ECCEN __BIT(18)
#define PCTL_PADM __BIT(19)
#define PCTL_CDQMAX __BITS(20,23)
#define PCTL_REV __BITS(24,31)
#define PCTL_CRQMAX __BITS(32,35)
#define PCTL_PTPMAX __BITS(36,39)
#define PCTL_PCLKX __BITS(40,41)
#define PCTL_FDSDIS __BIT(42)
#define PCTL_FDWDIS __BIT(43)
#define PCTL_PTEVRFY __BIT(44)
#define PCTL_RPP __BIT(45)
#define PCTL_PID __BITS(46,47)
#define P_PLAT 0x0340
#define P_PERROR 0x03c0
# define PER_ERR(r) TSFIELD((r), 0, 12)
# define PER_ECC(r) TSFIELD((r), 10, 2)
# define PER_SADR(r) TSFIELD((r), 16, 34)
# define PER_PADR(r) (TSFIELD((r), 18, 32) << 2)
# define PER_TRNS(r) TSFIELD((r), 16, 2)
# define PER_INV(r) TSFIELD((r), 51, 1)
# define PER_CMD(r) TSFIELD((r), 52, 4)
# define PER_SYN(r) TSFIELD((r), 56, 8)
#define P_PERRMASK 0x0400
#define P_PERRSET 0x0440
#define P_TLBIV 0x0480
#define P_TLBIA 0x04c0
#define P_PMONCTL 0x0500
#define P_PMONCNT 0x0540
#define P_SPRST 0x0800
#define TS_STEP 0x40
#define P_CSRBASE 0x001##8000##0000UL
#define P_PCI_MEM 0x800##0000##0000UL
#define P_PCI_IO 0x001##fc00##0000UL
#define P_PCI_CONFIG 0x001##fe00##0000UL
#define TS_P0(offs) (0x100##0000##0000UL + (offs))
#define TS_P1(offs) (0x102##0000##0000UL + (offs))
#define TS_Pn(n, offs) (0x100##0000##0000UL + 0x2##0000##0000UL * (n) + (offs))
typedef struct _ts_gr {
volatile uint64_t tsg_r;
long tsg_deadspace[7];
} TS_GR;
struct ts_pport {
TS_GR tsp_resA;
TS_GR tsp_error;
TS_GR tsp_perrmask;
TS_GR tsp_perrset;
TS_GR tsp_tlbiv;
TS_GR tsp_tlbia;
TS_GR tsp_pmonctl;
TS_GR tsp_pmoncnt;
TS_GR tsp_resB;
TS_GR tsp_resC;
TS_GR tsp_resD_K[8];
};
struct ts_gport {
TS_GR tsp_resA[2];
TS_GR tsp_serror;
TS_GR tsp_serrmask;
TS_GR tsp_serrset;
TS_GR tsp_resB;
TS_GR tsp_gperrmask;
TS_GR tsp_gperren;
TS_GR tsp_gperrset;
TS_GR tsp_resC;
TS_GR tsp_tlbiv;
TS_GR tsp_tlbia;
TS_GR tsp_resD[2];
TS_GR tsp_sctl;
TS_GR tsp_resE[3];
};
struct ts_aport {
TS_GR tsp_resA[2];
TS_GR tsp_agperror;
TS_GR tsp_agperrmask;
TS_GR tsp_agperrset;
TS_GR tsp_agplastwr;
TS_GR tsp_aperror;
TS_GR tsp_aperrmask;
TS_GR tsp_aperrset;
TS_GR tsp_resB;
TS_GR tsp_tlbiv;
TS_GR tsp_tlbia;
TS_GR tsp_resC[6];
};
struct ts_pchip {
TS_GR tsp_wsba[4];
TS_GR tsp_wsm[4];
TS_GR tsp_tba[4];
TS_GR tsp_pctl;
TS_GR tsp_plat;
union {
struct ts_pport p;
struct ts_gport g;
struct ts_aport a;
} port;
TS_GR tsp_sprts;
TS_GR tsp_res[31];
};