Home | History | Annotate | Line # | Download | only in pci
dwlpxreg.h revision 1.7
      1 /* $NetBSD: dwlpxreg.h,v 1.7 1997/06/08 07:57:40 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997 by Matthew Jacob
      5  * NASA AMES Research Center.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice immediately at the beginning of the file, without modification,
     13  *    this list of conditions, and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     24  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  * SUCH DAMAGE.
     31  */
     32 
     33 /*
     34  * Taken from combinations of:
     35  *
     36  *	``DWLPA and DWLPB PCI Adapter Technical Manual,
     37  *	  Order Number: EK-DWLPX-TM.A01''
     38  *
     39  *  and
     40  *
     41  *	``AlphaServer 8200/8400 System Technical Manual,
     42  *	  Order Number EK-T8030-TM. A01''
     43  */
     44 
     45 #define	REGVAL(r)	(*(volatile int32_t *)ALPHA_PHYS_TO_K0SEG(r))
     46 
     47 /*
     48  * There are (potentially) 4 I/O hoses, and there are three
     49  * (electrically distinct) PCI busses per DWLPX (which appear
     50  * as one logical PCI bus).
     51  *
     52  * A CPU to PCI Address Mapping looks (roughly) like this:
     53  *
     54  *  39 38........36 35.34 33.....32 31....................5 4.........3 2...0
     55  *  --------------------------------------------------------------------------
     56  *  |1| I/O NodeID |Hose#|PCI Space|Byte Aligned I/O <26:0>|Byte Length|0 0 0|
     57  *  --------------------------------------------------------------------------
     58  *
     59  * I/O Node is the TLSB Node ID minus 4. Don't ask.
     60  */
     61 
     62 #define	NHPC	3
     63 
     64 /*
     65  * Address Space Cookies
     66  *
     67  * (lacking I/O Node ID and Hose Numbers)
     68  */
     69 
     70 #define	DWLPX_PCI_DENSE		0x000000000LL
     71 #define	DWLPX_PCI_SPARSE	0x100000000LL
     72 #define	DWLPX_PCI_IOSPACE	0x200000000LL
     73 #define	DWLPX_PCI_CONF		0x300000000LL
     74 
     75 /*
     76  * PCIA Interface Adapter Register Addresses (Offsets from Node Address)
     77  *
     78  *
     79  * Addresses are for Hose #0, PCI bus #0. Macros below will offset
     80  * per bus. I/O Hose and TLSB Node I/D offsets must be added separately.
     81  */
     82 
     83 #define	_PCIA_CTL	0x380000000LL	/* PCI 0 Bus Control */
     84 #define	_PCIA_MRETRY	0x380000080LL	/* PCI 0 Master Retry Limit */
     85 #define	_PCIA_GPR	0x380000100LL	/* PCI 0 General Purpose */
     86 #define	_PCIA_ERR	0x380000180LL	/* PCI 0 Error Summary */
     87 #define	_PCIA_FADR	0x380000200LL	/* PCI 0 Failing Address */
     88 #define	_PCIA_IMASK	0x380000280LL	/* PCI 0 Interrupt Mask */
     89 #define	_PCIA_DIAG	0x380000300LL	/* PCI 0 Diagnostic  */
     90 #define	_PCIA_IPEND	0x380000380LL	/* PCI 0 Interrupt Pending */
     91 #define	_PCIA_IPROG	0x380000400LL	/* PCI 0 Interrupt in Progress */
     92 #define	_PCIA_WMASK_A	0x380000480LL	/* PCI 0 Window Mask A */
     93 #define	_PCIA_WBASE_A	0x380000500LL	/* PCI 0 Window Base A */
     94 #define	_PCIA_TBASE_A	0x380000580LL	/* PCI 0 Window Translated Base A */
     95 #define	_PCIA_WMASK_B	0x380000600LL	/* PCI 0 Window Mask B */
     96 #define	_PCIA_WBASE_B	0x380000680LL	/* PCI 0 Window Base B */
     97 #define	_PCIA_TBASE_B	0x380000700LL	/* PCI 0 Window Translated Base B */
     98 #define	_PCIA_WMASK_C	0x380000780LL	/* PCI 0 Window Mask C */
     99 #define	_PCIA_WBASE_C	0x380000800LL	/* PCI 0 Window Base C */
    100 #define	_PCIA_TBASE_C	0x380000880LL	/* PCI 0 Window Translated Base C */
    101 #define	_PCIA_ERRVEC	0x380000900LL	/* PCI 0 Error Interrupt Vector */
    102 #define	_PCIA_DEVVEC	0x380001000LL	/* PCI 0 Device Interrupt Vector */
    103 
    104 
    105 #define	PCIA_CTL(hpc)		(_PCIA_CTL	+ (0x200000 * (hpc)))
    106 #define	PCIA_MRETRY(hpc)	(_PCIA_MRETRY	+ (0x200000 * (hpc)))
    107 #define	PCIA_GPR(hpc)		(_PCIA_GPR	+ (0x200000 * (hpc)))
    108 #define	PCIA_ERR(hpc)		(_PCIA_ERR	+ (0x200000 * (hpc)))
    109 #define	PCIA_FADR(hpc)		(_PCIA_FADR	+ (0x200000 * (hpc)))
    110 #define	PCIA_IMASK(hpc)		(_PCIA_IMASK	+ (0x200000 * (hpc)))
    111 #define	PCIA_DIAG(hpc)		(_PCIA_DIAG	+ (0x200000 * (hpc)))
    112 #define	PCIA_IPEND(hpc)		(_PCIA_IPEND	+ (0x200000 * (hpc)))
    113 #define	PCIA_IPROG(hpc)		(_PCIA_IPROG	+ (0x200000 * (hpc)))
    114 #define	PCIA_WMASK_A(hpc)	(_PCIA_WMASK_A	+ (0x200000 * (hpc)))
    115 #define	PCIA_WBASE_A(hpc)	(_PCIA_WBASE_A	+ (0x200000 * (hpc)))
    116 #define	PCIA_TBASE_A(hpc)	(_PCIA_TBASE_A	+ (0x200000 * (hpc)))
    117 #define	PCIA_WMASK_B(hpc)	(_PCIA_WMASK_B	+ (0x200000 * (hpc)))
    118 #define	PCIA_WBASE_B(hpc)	(_PCIA_WBASE_B	+ (0x200000 * (hpc)))
    119 #define	PCIA_TBASE_B(hpc)	(_PCIA_TBASE_B	+ (0x200000 * (hpc)))
    120 #define	PCIA_WMASK_C(hpc)	(_PCIA_WMASK_C	+ (0x200000 * (hpc)))
    121 #define	PCIA_WBASE_C(hpc)	(_PCIA_WBASE_C	+ (0x200000 * (hpc)))
    122 #define	PCIA_TBASE_C(hpc)	(_PCIA_TBASE_C	+ (0x200000 * (hpc)))
    123 #define	PCIA_ERRVEC(hpc)	(_PCIA_ERRVEC	+ (0x200000 * (hpc)))
    124 
    125 #define	PCIA_DEVVEC(hpc, subslot, ipin)	\
    126  (_PCIA_DEVVEC + (0x200000 * (hpc)) + ((subslot) * 0x200) + ((ipin-1) * 0x80))
    127 
    128 #define	PCIA_SCYCLE	0x380002000LL	/* PCI Special Cycle */
    129 #define	PCIA_IACK	0x380002080LL	/* PCI Interrupt Acknowledge */
    130 
    131 #define	PCIA_PRESENT	0x380800000LL	/* PCI Slot Present */
    132 #define	PCIA_TBIT	0x380A00000LL	/* PCI TBIT */
    133 #define	PCIA_MCTL	0x380C00000LL	/* PCI Module Control */
    134 #define	PCIA_IBR	0x380E00000LL	/* PCI Information Base Repair */
    135 
    136 /*
    137  * Bits in PCIA_PRESENT.
    138  */
    139 #define	PCIA_PRESENT_REVSHIFT	25	/* shift by this to get revision */
    140 #define	PCIA_PRESENT_REVMASK	0xf
    141 #define	PCIA_PRESENT_STDIO	0x01000000 /* STD I/O bridge present */
    142 #define	PCIA_PRESENT_SLOTSHIFT(hpc, slot) \
    143 		(((hpc) << 3) + ((slot) << 1))
    144 #define	PCIA_PRESENT_SLOT_MASK	0x3
    145 #define	PCIA_PRESENT_SLOT_NONE	0x0
    146 #define	PCIA_PRESENT_SLOT_25W	0x1
    147 #define	PCIA_PRESENT_SLOT_15W	0x2
    148 #define	PCIA_PRESENT_SLOW_7W	0x3
    149 
    150 /*
    151  * Location of the DWLPx SGMAP page table SRAM.
    152  */
    153 #define	PCIA_SGMAP_PT	0x381000000UL
    154 
    155 /*
    156  * Values for PCIA_WMASK_x
    157  */
    158 #define	PCIA_WMASK_MASK	0xffff0000	/* mask of valid bits */
    159 #define	PCIA_WMASK_64K	0x00000000
    160 #define	PCIA_WMASK_128K	0x00010000
    161 #define	PCIA_WMASK_256K	0x00030000
    162 #define	PCIA_WMASK_512K	0x00070000
    163 #define	PCIA_WMASK_1M	0x000f0000
    164 #define	PCIA_WMASK_2M	0x001f0000
    165 #define	PCIA_WMASK_4M	0x003f0000
    166 #define	PCIA_WMASK_8M	0x007f0000
    167 #define	PCIA_WMASK_16M	0x00ff0000
    168 #define	PCIA_WMASK_32M	0x01ff0000
    169 #define	PCIA_WMASK_64M	0x03ff0000
    170 #define	PCIA_WMASK_128M	0x07ff0000
    171 #define	PCIA_WMASK_256M	0x0fff0000
    172 #define	PCIA_WMASK_512M	0x1fff0000
    173 #define	PCIA_WMASK_1G	0x3fff0000
    174 #define	PCIA_WMASK_2G	0x7fff0000
    175 #define	PCIA_WMASK_4G	0xffff0000
    176 
    177 /*
    178  * Values for PCIA_WBASE_x
    179  */
    180 #define	PCIA_WBASE_MASK	 0xffff0000	/* mask of valid bits in address */
    181 #define	PCIA_WBASE_W_EN	 0x00000002	/* window enable */
    182 #define	PCIA_WBASE_SG_EN 0x00000001	/* SGMAP enable */
    183 
    184 /*
    185  * Values for PCIA_TBASE_x
    186  *
    187  * NOTE: Translated Base is only used on direct-mapped DMA on the
    188  * DWLPx!!
    189  */
    190 #define	PCIA_TBASE_MASK	 0x00fffffe
    191 #define	PCIA_TBASE_SHIFT 15
    192