Home | History | Annotate | Line # | Download | only in pci
tsreg.h revision 1.8.8.1
      1  1.8.8.1     cjep /* $NetBSD: tsreg.h,v 1.8.8.1 2021/05/31 22:15:10 cjep Exp $ */
      2      1.1     ross 
      3      1.1     ross /*-
      4      1.1     ross  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
      5      1.1     ross  *
      6      1.1     ross  * Redistribution and use in source and binary forms, with or without
      7      1.1     ross  * modification, are permitted provided that the following conditions
      8      1.1     ross  * are met:
      9      1.1     ross  * 1. Redistributions of source code must retain the above copyright
     10      1.1     ross  *    notice, this list of conditions and the following disclaimer.
     11      1.1     ross  * 2. Redistributions in binary form must reproduce the above copyright
     12      1.1     ross  *    notice, this list of conditions and the following disclaimer in the
     13      1.1     ross  *    documentation and/or other materials provided with the distribution.
     14      1.1     ross  * 3. All advertising materials mentioning features or use of this software
     15      1.1     ross  *    must display the following acknowledgement:
     16      1.1     ross  *	This product includes software developed by Ross Harvey.
     17      1.1     ross  * 4. The name of Ross Harvey may not be used to endorse or promote products
     18      1.1     ross  *    derived from this software without specific prior written permission.
     19      1.1     ross  *
     20      1.1     ross  * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
     21      1.1     ross  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     22      1.1     ross  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
     23      1.1     ross  * ARE DISCLAIMED.  IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
     24      1.1     ross  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25      1.1     ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26      1.1     ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27      1.1     ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28      1.1     ross  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29      1.1     ross  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30      1.1     ross  * SUCH DAMAGE.
     31      1.1     ross  *
     32      1.1     ross  */
     33      1.1     ross 
     34      1.1     ross /*
     35      1.1     ross  * 21272 Core Logic registers and constants.
     36      1.1     ross  */
     37      1.1     ross 
     38      1.1     ross #define	tsreg() { Generate ctags(1) key. }
     39      1.1     ross 
     40      1.1     ross /*
     41      1.1     ross  * Superpage pointer from physical address.
     42      1.1     ross  */
     43      1.1     ross #define	S_PAGE(phys) ((void *)ALPHA_PHYS_TO_K0SEG(phys))
     44      1.1     ross 
     45      1.1     ross /*
     46      1.1     ross  * {LD,ST}QP: LoaD and STore Quad Physical
     47      1.1     ross  */
     48      1.1     ross #define	LDQP(a)	(*(volatile long *)ALPHA_PHYS_TO_K0SEG(a))
     49      1.1     ross #define	STQP(a) LDQP(a)
     50      1.1     ross 
     51      1.1     ross /*
     52      1.1     ross  * Define extraction functions for bit fields via length and left,right bitno
     53      1.1     ross  */
     54      1.1     ross #define	TSFIELD(r,offs,len) (((r) >> (offs)) & (~0UL >> (64 - (len))))
     55      1.1     ross #define	TSFIELDBB(r,lb,rb) TSFIELD((r), (rb), (lb) - (rb) + 1)
     56      1.1     ross 
     57      1.1     ross /*
     58      1.1     ross  * EV6 has a new superpage which can pass through 44 address bits.  (Umm, a
     59      1.1     ross  * superduperpage?) But, the firmware doesn't turn it on, so we use the old
     60      1.1     ross  * one and let the HW sign extend va/pa<40> to get us the pa<43> that makes
     61      1.1     ross  * the needed I/O space access. This is just as well; it means we don't have
     62      1.1     ross  * to worry about which GENERIC code might get called on other CPU models.
     63      1.1     ross  *
     64      1.1     ross  *	E.g., we want this:	      0x0801##a000##0000
     65      1.1     ross  *	We use this:		      0x0101##a000##0000
     66      1.1     ross  *	...mix in the old SP:	0xffff##fc00##0000##0000
     67      1.1     ross  *	...after PA sign ext:	0xffff##ff00##a000##0000
     68      1.1     ross  *	(PA<42:41> ignored)
     69      1.1     ross  */
     70      1.2  thorpej 
     71      1.2  thorpej /*
     72      1.2  thorpej  * This hack allows us to map the I/O address space without using
     73      1.3   toshii  * the KSEG sign extension hack.
     74      1.2  thorpej  */
     75      1.2  thorpej #define	TS_PHYSADDR(x)							\
     76      1.2  thorpej 	(((x) & ~0x0100##0000##0000) | 0x0800##0000##0000)
     77      1.1     ross 
     78      1.1     ross /*
     79      1.1     ross  * Cchip CSR Map
     80      1.1     ross  */
     81      1.1     ross 
     82      1.1     ross #define TS_C_CSC	0x101##a000##0000UL	/* Cchip System Configuration */
     83      1.1     ross 
     84      1.1     ross #	define	CSC_P1P		(1L << 14)
     85      1.1     ross #	define	CSC_BC(r)	TSFIELD((r), 0, 2)
     86      1.1     ross #	define	CSC_AW		(1L << 8)
     87      1.1     ross 
     88      1.1     ross #define TS_C_MTR	0x101##a000##0040UL
     89      1.1     ross 
     90      1.1     ross #define TS_C_MISC	0x101##a000##0080UL	/* Miscellaneous Register */
     91      1.1     ross 
     92      1.4     hans #	define	MISC_NXM(r)	TSFIELD((r), 28, 1)
     93      1.4     hans #	define	MISC_NXM_SRC(r)	TSFIELD((r), 29, 3)
     94      1.1     ross #	define	MISC_REV(r)	TSFIELD((r), 39, 8)
     95      1.1     ross 
     96      1.1     ross #define TS_C_MPD	0x101##a000##00c0UL
     97      1.1     ross 
     98      1.7      jdc #	define	MPD_DR	0x08	/* RO: Data receive */
     99      1.7      jdc #	define	MPD_CKR	0x04	/* RO: Clock receive */
    100      1.7      jdc #	define	MPD_DS	0x02	/* WO: Data send - Must be a 1 to receive */
    101      1.7      jdc #	define	MPD_CKS	0x01	/* WO: Clock send */
    102      1.7      jdc 
    103      1.1     ross #define TS_C_AAR0	0x101##a000##0100UL
    104      1.1     ross #define TS_C_AAR1	0x101##a000##0140UL
    105      1.1     ross #define TS_C_AAR2	0x101##a000##0180UL
    106      1.1     ross #define TS_C_AAR3	0x101##a000##01c0UL
    107      1.1     ross 
    108      1.1     ross #	define	AAR_ASIZ(r)	TSFIELD((r), 12, 4)
    109      1.1     ross #	define	AAR_SPLIT	(1L << 8)
    110      1.1     ross 
    111      1.1     ross #define TS_C_DIM0	0x101##a000##0200UL
    112      1.1     ross #define TS_C_DIM1	0x101##a000##0240UL
    113      1.1     ross #define TS_C_DIR0	0x101##a000##0280UL
    114      1.1     ross #define TS_C_DIR1	0x101##a000##02c0UL
    115      1.1     ross #define TS_C_DRIR	0x101##a000##0300UL
    116      1.1     ross #define TS_C_PRBEN	0x101##a000##0340UL
    117      1.1     ross #define TS_C_IIC0	0x101##a000##0380UL
    118      1.1     ross #define TS_C_IIC1	0x101##a000##03c0UL
    119      1.1     ross #define TS_C_MPR0	0x101##a000##0400UL
    120      1.1     ross #define TS_C_MPR1	0x101##a000##0440UL
    121      1.1     ross #define TS_C_MPR2	0x101##a000##0480UL
    122      1.1     ross #define TS_C_MPR3	0x101##a000##04c0UL
    123      1.1     ross #define TS_C_MCTL	0x101##a000##0500UL
    124      1.1     ross 
    125      1.1     ross #define TS_C_TTR	0x101##a000##0580UL
    126      1.1     ross #define TS_C_TDR	0x101##a000##05c0UL
    127      1.8  thorpej #define TS_C_DIM2	0x101##a000##0600UL
    128      1.8  thorpej #define TS_C_DIM3	0x101##a000##0640UL
    129      1.8  thorpej #define TS_C_DIR2	0x101##a000##0680UL
    130      1.8  thorpej #define TS_C_DIR3	0x101##a000##06c0UL
    131      1.8  thorpej #define TS_C_IIC2	0x101##a000##0700UL
    132      1.8  thorpej #define TS_C_IIC3	0x101##a000##0740UL
    133      1.1     ross 
    134      1.1     ross /*
    135      1.1     ross  * Dchip CSR Map
    136      1.1     ross  */
    137      1.1     ross 
    138      1.1     ross #define TS_D_DSC	0x101##b000##0800UL
    139      1.1     ross #define TS_D_STR	0x101##b000##0840UL
    140      1.1     ross #define TS_D_DREV	0x101##b000##0880UL
    141      1.1     ross #define TS_D_DSC2	0x101##b000##08c0UL
    142      1.1     ross 
    143      1.1     ross /*
    144      1.1     ross  * Pchip CSR Offsets
    145      1.1     ross  */
    146      1.1     ross 
    147      1.1     ross #define P_WSBA0		0x0000
    148      1.1     ross #define P_WSBA1		0x0040
    149      1.1     ross #define P_WSBA2		0x0080
    150      1.1     ross #define P_WSBA3		0x00c0
    151      1.1     ross 
    152      1.1     ross #	define	WSBA_ADDR(r) (TSFIELDBB((r), 31, 20) << 20)
    153      1.1     ross #	define	WSBA_SG	     2
    154      1.1     ross #	define	WSBA_ENA     1
    155      1.1     ross 
    156      1.1     ross #define P_WSM0		0x0100
    157      1.1     ross #define P_WSM1		0x0140
    158      1.1     ross #define P_WSM2		0x0180
    159      1.1     ross #define P_WSM3		0x01c0
    160      1.1     ross 
    161      1.1     ross #	define	WSM_AM(r)    TSFIELDBB((r), 31, 20)
    162      1.1     ross #	define	WSM_LEN(r)   ((WSM_AM(r) + 1) << 20)
    163      1.1     ross 
    164      1.1     ross #define P_TBA0		0x0200
    165      1.1     ross #define P_TBA1		0x0240
    166      1.1     ross #define P_TBA2		0x0280
    167      1.1     ross #define P_TBA3		0x02c0
    168      1.1     ross 
    169      1.1     ross #define P_PCTL		0x0300
    170  1.8.8.1     cjep 
    171  1.8.8.1     cjep #define	PCTL_FDSC	__BIT(0)	/* fast discard enable */
    172  1.8.8.1     cjep #define	PCTL_FBTB	__BIT(1)	/* fast back-to-back enable */
    173  1.8.8.1     cjep #define	PCTL_THDIS	__BIT(2)	/* disable TLB anti-thrash (debug) */
    174  1.8.8.1     cjep #define	PCTL_CHAINDIS	__BIT(3)	/* disable chaining */
    175  1.8.8.1     cjep #define	PCTL_TGTLAT	__BIT(4)	/* target latency timers enable */
    176  1.8.8.1     cjep #define	PCTL_HOLE	__BIT(5)	/* 512KB->1M hole enable */
    177  1.8.8.1     cjep #define	PCTL_MWIN	__BIT(6)	/* monster window enable */
    178  1.8.8.1     cjep #define	PCTL_PRIGRP	__BITS(8,14)	/* arbiter priority group */
    179  1.8.8.1     cjep #define	PCTL_PPRI	__BIT(15)	/* arbiter priority group for Pchip */
    180  1.8.8.1     cjep #define	PCTL_ECCEN	__BIT(18)	/* ECC enable for DMA and SGTE */
    181  1.8.8.1     cjep #define	PCTL_PADM	__BIT(19)	/* PADbus mode */
    182  1.8.8.1     cjep #define	PCTL_CDQMAX	__BITS(20,23)	/* see manual */
    183  1.8.8.1     cjep #define	PCTL_REV	__BITS(24,31)	/* Pchip revision */
    184  1.8.8.1     cjep #define	PCTL_CRQMAX	__BITS(32,35)	/* see manual */
    185  1.8.8.1     cjep #define	PCTL_PTPMAX	__BITS(36,39)	/* see manual */
    186  1.8.8.1     cjep #define	PCTL_PCLKX	__BITS(40,41)	/* PCI clock freq multipler */
    187  1.8.8.1     cjep #define	PCTL_FDSDIS	__BIT(42)	/* fast DMA start and SGTE disable */
    188  1.8.8.1     cjep #define	PCTL_FDWDIS	__BIT(43)	/* fast DMA read cache block disable */
    189  1.8.8.1     cjep #define	PCTL_PTEVRFY	__BIT(44)	/* PTE verify for DMA read */
    190  1.8.8.1     cjep #define	PCTL_RPP	__BIT(45)	/* remote Pchip present */
    191  1.8.8.1     cjep #define	PCTL_PID	__BITS(46,47)	/* Pchip ID */
    192  1.8.8.1     cjep 
    193      1.1     ross #define P_PLAT		0x0340
    194      1.1     ross 	/* reserved	0x0380 */
    195      1.1     ross #define P_PERROR	0x03c0
    196      1.1     ross 
    197      1.4     hans #	define	PER_ERR(r)	TSFIELD((r),  0, 12)
    198      1.4     hans #	define	PER_ECC(r)	TSFIELD((r), 10, 2)
    199      1.4     hans #	define	PER_SADR(r)	TSFIELD((r), 16, 34)
    200      1.4     hans #	define	PER_PADR(r)	(TSFIELD((r), 18, 32) << 2)
    201      1.4     hans #	define	PER_TRNS(r)	TSFIELD((r), 16, 2)
    202      1.4     hans #	define	PER_INV(r)	TSFIELD((r), 51, 1)
    203      1.4     hans #	define	PER_CMD(r)	TSFIELD((r), 52, 4)
    204      1.4     hans #	define	PER_SYN(r)	TSFIELD((r), 56, 8)
    205      1.4     hans 
    206      1.1     ross #define P_PERRMASK	0x0400
    207      1.1     ross #define P_PERRSET	0x0440
    208      1.1     ross #define P_TLBIV		0x0480
    209      1.1     ross #define P_TLBIA		0x04c0
    210      1.1     ross 
    211      1.1     ross #define P_PMONCTL	0x0500
    212      1.1     ross #define P_PMONCNT	0x0540
    213      1.1     ross 
    214      1.1     ross #define P_SPRST		0x0800
    215      1.1     ross 
    216      1.1     ross #define	TS_STEP		0x40
    217      1.1     ross 
    218      1.1     ross /*
    219      1.1     ross  * Pchip I/O offsets
    220      1.1     ross  */
    221      1.1     ross 
    222      1.1     ross #define	P_CSRBASE	 0x001##8000##0000UL
    223      1.6  tsutsui #define	P_PCI_MEM	 0x800##0000##0000UL
    224      1.1     ross #define	P_PCI_IO	 0x001##fc00##0000UL
    225      1.1     ross #define	P_PCI_CONFIG	 0x001##fe00##0000UL
    226      1.1     ross 
    227      1.1     ross /*
    228      1.1     ross  * Construct EV6 I/O Space Address for Pchip 0 and Pchip 1.
    229      1.1     ross  */
    230      1.1     ross 
    231      1.1     ross #define	TS_P0(offs)	(0x100##0000##0000UL + (offs))
    232      1.1     ross #define	TS_P1(offs)	(0x102##0000##0000UL + (offs))
    233      1.1     ross #define	TS_Pn(n, offs)	(0x100##0000##0000UL + 0x2##0000##0000UL * (n) + (offs))
    234      1.1     ross 
    235      1.1     ross /*
    236      1.1     ross  * Tsunami Generic Register Type
    237      1.1     ross  */
    238      1.1     ross typedef struct _ts_gr {
    239      1.5     matt 	volatile uint64_t tsg_r;
    240      1.1     ross 	long	tsg_deadspace[7];
    241      1.1     ross } TS_GR;
    242      1.1     ross 
    243      1.1     ross /*
    244      1.1     ross  * Tsunami Pchip
    245      1.1     ross  */
    246      1.6  tsutsui struct	ts_pport {
    247      1.1     ross 	TS_GR	tsp_resA;
    248      1.1     ross 	TS_GR	tsp_error;	/* Pchip Error */
    249      1.1     ross 
    250      1.1     ross 	TS_GR	tsp_perrmask;	/* Pchip Error Mask */
    251      1.1     ross 	TS_GR	tsp_perrset;	/* Pchip Error Set */
    252      1.1     ross 	TS_GR	tsp_tlbiv;	/* Translation Buffer Invalidate Virtual */
    253      1.1     ross 	TS_GR	tsp_tlbia;	/* Translation Buffer Invalidate All */
    254      1.1     ross 
    255      1.1     ross 	TS_GR	tsp_pmonctl;	/* PChip Monitor Control */
    256      1.1     ross 	TS_GR	tsp_pmoncnt;	/* PChip Monitor Counters */
    257      1.1     ross 	TS_GR	tsp_resB;
    258      1.1     ross 	TS_GR	tsp_resC;
    259      1.1     ross 
    260      1.1     ross 	TS_GR	tsp_resD_K[8];
    261      1.6  tsutsui };
    262      1.6  tsutsui 
    263      1.6  tsutsui struct	ts_gport {
    264      1.6  tsutsui 	TS_GR	tsp_resA[2];
    265      1.6  tsutsui 	TS_GR	tsp_serror;
    266      1.6  tsutsui 	TS_GR	tsp_serrmask;
    267      1.6  tsutsui 	TS_GR	tsp_serrset;
    268      1.6  tsutsui 	TS_GR	tsp_resB;
    269      1.6  tsutsui 	TS_GR	tsp_gperrmask;
    270      1.6  tsutsui 	TS_GR	tsp_gperren;
    271      1.6  tsutsui 	TS_GR	tsp_gperrset;
    272      1.6  tsutsui 	TS_GR	tsp_resC;
    273      1.6  tsutsui 	TS_GR	tsp_tlbiv;
    274      1.6  tsutsui 	TS_GR	tsp_tlbia;
    275      1.6  tsutsui 	TS_GR	tsp_resD[2];
    276      1.6  tsutsui 	TS_GR	tsp_sctl;
    277      1.6  tsutsui 	TS_GR	tsp_resE[3];
    278      1.6  tsutsui };
    279      1.6  tsutsui 
    280      1.6  tsutsui struct	ts_aport {
    281      1.6  tsutsui 	TS_GR	tsp_resA[2];
    282      1.6  tsutsui 	TS_GR	tsp_agperror;
    283      1.6  tsutsui 	TS_GR	tsp_agperrmask;
    284      1.6  tsutsui 	TS_GR	tsp_agperrset;
    285      1.6  tsutsui 	TS_GR	tsp_agplastwr;
    286      1.6  tsutsui 	TS_GR	tsp_aperror;
    287      1.6  tsutsui 	TS_GR	tsp_aperrmask;
    288      1.6  tsutsui 	TS_GR	tsp_aperrset;
    289      1.6  tsutsui 	TS_GR	tsp_resB;
    290      1.6  tsutsui 	TS_GR	tsp_tlbiv;
    291      1.6  tsutsui 	TS_GR	tsp_tlbia;
    292      1.6  tsutsui 	TS_GR	tsp_resC[6];
    293      1.6  tsutsui };
    294      1.6  tsutsui 
    295      1.6  tsutsui struct	ts_pchip {
    296      1.6  tsutsui 	TS_GR	tsp_wsba[4];	/* Window Space Base Address */
    297      1.6  tsutsui 
    298      1.6  tsutsui 	TS_GR	tsp_wsm[4];	/* Window Space Mask */
    299      1.6  tsutsui 
    300      1.6  tsutsui 	TS_GR	tsp_tba[4];	/* Translated Base Address */
    301      1.6  tsutsui 
    302      1.6  tsutsui 	TS_GR	tsp_pctl;	/* Pchip Control */
    303      1.6  tsutsui 	TS_GR	tsp_plat;	/* Pchip Latency */
    304      1.6  tsutsui 
    305      1.6  tsutsui 	union {
    306      1.6  tsutsui 		struct ts_pport	p;
    307      1.6  tsutsui 		struct ts_gport	g;
    308      1.6  tsutsui 		struct ts_aport	a;
    309      1.6  tsutsui 	} port;
    310      1.1     ross 
    311      1.1     ross 	TS_GR	tsp_sprts;	/* ??? */
    312      1.6  tsutsui 	TS_GR   tsp_res[31];
    313      1.1     ross };
    314