psychoreg.h revision 128625
1/*
2 * Copyright (c) 1998, 1999 Eduardo E. Horvath
3 * Copyright (c) 1999 Matthew R. Green
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 *    derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *	from: NetBSD: psychoreg.h,v 1.8 2001/09/10 16:17:06 eeh Exp
30 *
31 * $FreeBSD: head/sys/sparc64/pci/psychoreg.h 128625 2004-04-25 00:30:28Z tmm $
32 */
33
34#ifndef _SPARC64_PCI_PSYCHOREG_H_
35#define _SPARC64_PCI_PSYCHOREG_H_
36
37/*
38 * Sun4u PCI definitions.  Here's where we deal w/the machine
39 * dependencies of psycho and the PCI controller on the UltraIIi.
40 *
41 * All PCI registers are bit-swapped, however they are not byte-swapped.
42 * This means that they must be accessed using little-endian access modes,
43 * either map the pages little-endian or use little-endian ASIs.
44 *
45 * PSYCHO implements two PCI buses, A and B.
46 */
47
48/*
49 * psycho register offsets.
50 *
51 * NB: FFB0 and FFB1 intr map regs also appear at 0x6000 and 0x8000
52 * respectively.
53 */
54#define	PSR_UPA_PORTID		0x0000	/* UPA port ID register */
55#define	PSR_UPA_CONFIG		0x0008	/* UPA config register */
56#define	PSR_CS			0x0010	/* PSYCHO control/status register */
57#define	PSR_ECCC		0x0020	/* ECC control register */
58#define	PSR_UE_AFS		0x0030	/* Uncorrectable Error AFSR */
59#define	PSR_UE_AFA		0x0038	/* Uncorrectable Error AFAR */
60#define	PSR_CE_AFS		0x0040	/* Correctable Error AFSR */
61#define	PSR_CE_AFA		0x0048	/* Correctable Error AFAR */
62#define	PSR_PM_CTL		0x0100	/* Performance monitor control reg */
63#define	PSR_PM_COUNT		0x0108	/* Performance monitor counter reg */
64#define	PSR_IOMMU		0x0200	/* IOMMU registers. */
65#define	PSR_PCIA0_INT_MAP	0x0c00	/* PCI bus a slot 0 irq map reg */
66#define	PSR_PCIA1_INT_MAP	0x0c08	/* PCI bus a slot 1 irq map reg */
67#define	PSR_PCIA2_INT_MAP	0x0c10	/* PCI bus a slot 2 irq map reg (IIi) */
68#define	PSR_PCIA3_INT_MAP	0x0c18	/* PCI bus a slot 3 irq map reg (IIi) */
69#define	PSR_PCIB0_INT_MAP	0x0c20	/* PCI bus b slot 0 irq map reg */
70#define	PSR_PCIB1_INT_MAP	0x0c28	/* PCI bus b slot 1 irq map reg */
71#define	PSR_PCIB2_INT_MAP	0x0c30	/* PCI bus b slot 2 irq map reg */
72#define	PSR_PCIB3_INT_MAP	0x0c38	/* PCI bus b slot 3 irq map reg */
73#define	PSR_SCSI_INT_MAP	0x1000	/* SCSI interrupt map reg */
74#define	PSR_ETHER_INT_MAP	0x1008	/* ethernet interrupt map reg */
75#define	PSR_BPP_INT_MAP		0x1010	/* parallel interrupt map reg */
76#define	PSR_AUDIOR_INT_MAP	0x1018	/* audio record interrupt map reg */
77#define	PSR_AUDIOP_INT_MAP	0x1020	/* audio playback interrupt map reg */
78#define	PSR_POWER_INT_MAP	0x1028	/* power fail interrupt map reg */
79#define	PSR_SKBDMS_INT_MAP	0x1030	/* serial/kbd/mouse interrupt map reg */
80#define	PSR_FD_INT_MAP		0x1038	/* floppy interrupt map reg */
81#define	PSR_SPARE_INT_MAP	0x1040	/* spare interrupt map reg */
82#define	PSR_KBD_INT_MAP		0x1048	/* kbd [unused] interrupt map reg */
83#define	PSR_MOUSE_INT_MAP	0x1050	/* mouse [unused] interrupt map reg */
84#define	PSR_SERIAL_INT_MAP	0x1058	/* second serial interrupt map reg */
85#define	PSR_TIMER0_INT_MAP	0x1060	/* timer 0 interrupt map reg */
86#define	PSR_TIMER1_INT_MAP	0x1068	/* timer 1 interrupt map reg */
87#define	PSR_UE_INT_MAP		0x1070	/* UE interrupt map reg */
88#define	PSR_CE_INT_MAP		0x1078	/* CE interrupt map reg */
89#define	PSR_PCIAERR_INT_MAP	0x1080	/* PCI bus a error interrupt map reg */
90#define	PSR_PCIBERR_INT_MAP	0x1088	/* PCI bus b error interrupt map reg */
91#define	PSR_PWRMGT_INT_MAP	0x1090	/* power mgmt wake interrupt map reg */
92#define	PSR_FFB0_INT_MAP	0x1098	/* FFB0 graphics interrupt map reg */
93#define	PSR_FFB1_INT_MAP	0x10a0	/* FFB1 graphics interrupt map reg */
94/* Note: clear interrupt 0 registers are not really used */
95#define	PSR_PCIA0_INT_CLR	0x1400	/* PCI a slot 0 clear int regs 0..3 */
96#define	PSR_PCIA1_INT_CLR	0x1420	/* PCI a slot 1 clear int regs 0..3 */
97#define	PSR_PCIA2_INT_CLR	0x1440	/* PCI a slot 2 clear int regs 0..3 */
98#define	PSR_PCIA3_INT_CLR	0x1460	/* PCI a slot 3 clear int regs 0..3 */
99#define	PSR_PCIB0_INT_CLR	0x1480	/* PCI b slot 0 clear int regs 0..3 */
100#define	PSR_PCIB1_INT_CLR	0x14a0	/* PCI b slot 1 clear int regs 0..3 */
101#define	PSR_PCIB2_INT_CLR	0x14c0	/* PCI b slot 2 clear int regs 0..3 */
102#define	PSR_PCIB3_INT_CLR	0x14d0	/* PCI b slot 3 clear int regs 0..3 */
103#define	PSR_SCSI_INT_CLR	0x1800	/* SCSI clear int reg */
104#define	PSR_ETHER_INT_CLR	0x1808	/* ethernet clear int reg */
105#define	PSR_BPP_INT_CLR		0x1810	/* parallel clear int reg */
106#define	PSR_AUDIOR_INT_CLR	0x1818	/* audio record clear int reg */
107#define	PSR_AUDIOP_INT_CLR	0x1820	/* audio playback clear int reg */
108#define	PSR_POWER_INT_CLR	0x1828	/* power fail clear int reg */
109#define	PSR_SKBDMS_INT_CLR	0x1830	/* serial/kbd/mouse clear int reg */
110#define	PSR_FD_INT_CLR		0x1838	/* floppy clear int reg */
111#define	PSR_SPARE_INT_CLR	0x1840	/* spare clear int reg */
112#define	PSR_KBD_INT_CLR		0x1848	/* kbd [unused] clear int reg */
113#define	PSR_MOUSE_INT_CLR	0x1850	/* mouse [unused] clear int reg */
114#define	PSR_SERIAL_INT_CLR	0x1858	/* second serial clear int reg */
115#define	PSR_TIMER0_INT_CLR	0x1860	/* timer 0 clear int reg */
116#define	PSR_TIMER1_INT_CLR	0x1868	/* timer 1 clear int reg */
117#define	PSR_UE_INT_CLR		0x1870	/* UE clear int reg */
118#define	PSR_CE_INT_CLR		0x1878	/* CE clear int reg */
119#define	PSR_PCIAERR_INT_CLR	0x1880	/* PCI bus a error clear int reg */
120#define	PSR_PCIBERR_INT_CLR	0x1888	/* PCI bus b error clear int reg */
121#define	PSR_PWRMGT_INT_CLR	0x1890	/* power mgmt wake clr interrupt reg */
122#define	PSR_INTR_RETRY_TIM	0x1a00	/* interrupt retry timer */
123#define	PSR_TC0			0x1c00	/* timer/counter 0 */
124#define	PSR_TC1			0x1c10	/* timer/counter 1 */
125#define	PSR_DMA_WRITE_SYNC	0x1c20	/* PCI DMA write sync register (IIi) */
126#define	PSR_PCICTL0		0x2000	/* PCICTL registers for 1st psycho. */
127#define	PSR_PCICTL1		0x4000	/* PCICTL registers for 2nd psycho. */
128#define	PSR_DMA_SCB_DIAG0	0xa000	/* DMA scoreboard diag reg 0 */
129#define	PSR_DMA_SCB_DIAG1	0xa008	/* DMA scoreboard diag reg 1 */
130#define	PSR_IOMMU_SVADIAG	0xa400	/* IOMMU virtual addr diag reg */
131#define	PSR_IOMMU_TLB_CMP_DIAG	0xa408	/* IOMMU TLB tag compare diag reg */
132#define	PSR_IOMMU_QUEUE_DIAG	0xa500	/* IOMMU LRU queue diag regs 0..15 */
133#define	PSR_IOMMU_TLB_TAG_DIAG	0xa580	/* TLB tag diag regs 0..15 */
134#define	PSR_IOMMU_TLB_DATA_DIAG	0xa600	/* TLB data RAM diag regs 0..15 */
135#define	PSR_PCI_INT_DIAG	0xa800	/* PCI int state diag reg */
136#define	PSR_OBIO_INT_DIAG	0xa808	/* OBIO and misc int state diag reg */
137#define	PSR_STRBUF_DIAG		0xb000	/* Streaming buffer diag regs */
138/*
139 * Here is the rest of the map, which we're not specifying:
140 *
141 * 1fe.0100.0000 - 1fe.01ff.ffff	PCI configuration space
142 * 1fe.0100.0000 - 1fe.0100.00ff	PCI B configuration header
143 * 1fe.0101.0000 - 1fe.0101.00ff	PCI A configuration header
144 * 1fe.0200.0000 - 1fe.0200.ffff	PCI A I/O space
145 * 1fe.0201.0000 - 1fe.0201.ffff	PCI B I/O space
146 * 1ff.0000.0000 - 1ff.7fff.ffff	PCI A memory space
147 * 1ff.8000.0000 - 1ff.ffff.ffff	PCI B memory space
148 *
149 * NB: config and I/O space can use 1-4 byte accesses, not 8 byte
150 * accesses.  Memory space can use any sized accesses.
151 *
152 * Note that the SUNW,sabre/SUNW,simba combinations found on the
153 * Ultra5 and Ultra10 machines uses slightly differrent addresses
154 * than the above.  This is mostly due to the fact that the APB is
155 * a multi-function PCI device with two PCI bridges, and the U2P is
156 * two separate PCI bridges.  It uses the same PCI configuration
157 * space, though the configuration header for each PCI bus is
158 * located differently due to the SUNW,simba PCI busses being
159 * function 0 and function 1 of the APB, whereas the psycho's are
160 * each their own PCI device.  The I/O and memory spaces are each
161 * split into 8 equally sized areas (8x2MB blocks for I/O space,
162 * and 8x512MB blocks for memory space).  These are allocated in to
163 * either PCI A or PCI B, or neither in the APB's `I/O Address Map
164 * Register A/B' (0xde) and `Memory Address Map Register A/B' (0xdf)
165 * registers of each simba.  We must ensure that both of the
166 * following are correct (the prom should do this for us):
167 *
168 *    (PCI A Memory Address Map) & (PCI B Memory Address Map) == 0
169 *
170 *    (PCI A I/O Address Map) & (PCI B I/O Address Map) == 0
171 *
172 * 1fe.0100.0000 - 1fe.01ff.ffff	PCI configuration space
173 * 1fe.0100.0800 - 1fe.0100.08ff	PCI B configuration header
174 * 1fe.0100.0900 - 1fe.0100.09ff	PCI A configuration header
175 * 1fe.0200.0000 - 1fe.02ff.ffff	PCI I/O space (divided)
176 * 1ff.0000.0000 - 1ff.ffff.ffff	PCI memory space (divided)
177 */
178
179/*
180 * PSR_CS defines:
181 *
182 * 63     59     55     50     45     4        3       2     1      0
183 * +------+------+------+------+--//---+--------+-------+-----+------+
184 * | IMPL | VERS | MID  | IGN  |  xxx  | APCKEN | APERR | IAP | MODE |
185 * +------+------+------+------+--//---+--------+-------+-----+------+
186 *
187 */
188#define PSYCHO_GCSR_IMPL(csr)	((u_int)(((csr) >> 60) & 0xf))
189#define PSYCHO_GCSR_VERS(csr)	((u_int)(((csr) >> 56) & 0xf))
190#define PSYCHO_GCSR_MID(csr)	((u_int)(((csr) >> 51) & 0x1f))
191#define PSYCHO_GCSR_IGN(csr)	((u_int)(((csr) >> 46) & 0x1f))
192#define PSYCHO_CSR_APCKEN	8	/* UPA addr parity check enable */
193#define PSYCHO_CSR_APERR	4	/* UPA addr parity error */
194#define PSYCHO_CSR_IAP		2	/* invert UPA address parity */
195#define PSYCHO_CSR_MODE		1	/* UPA/PCI handshake */
196
197/* Offsets into the PSR_PCICTL* register block. */
198#define	PCR_CS			0x0000	/* PCI control/status register */
199#define	PCR_AFS			0x0010	/* PCI AFSR register */
200#define	PCR_AFA			0x0018	/* PCI AFAR register */
201#define	PCR_DIAG		0x0020	/* PCI diagnostic register */
202#define	PCR_TAS			0x0028	/* PCI target address space reg (IIi) */
203#define	PCR_STRBUF		0x0800	/* IOMMU streaming buffer registers. */
204
205/* Device space defines. */
206#define	PSYCHO_CONF_SIZE	0x1000000
207#define	PSYCHO_CONF_BUS_SHIFT	16
208#define	PSYCHO_CONF_DEV_SHIFT	11
209#define	PSYCHO_CONF_FUNC_SHIFT	8
210#define	PSYCHO_CONF_REG_SHIFT	0
211#define	PSYCHO_IO_SIZE		0x1000000
212#define	PSYCHO_MEM_SIZE		0x100000000
213
214#define	PSYCHO_CONF_OFF(bus, slot, func, reg)				\
215	(((bus) << PSYCHO_CONF_BUS_SHIFT) |				\
216	((slot) << PSYCHO_CONF_DEV_SHIFT) |				\
217	((func) << PSYCHO_CONF_FUNC_SHIFT) |				\
218	((reg) << PSYCHO_CONF_REG_SHIFT))
219
220/* what the bits mean! */
221
222/* PCI [a|b] control/status register */
223/* note that the sabre only has one set of PCI control/status registers */
224#define	PCICTL_MRLM	0x0000001000000000	/* Memory Read Line/Multiple */
225#define	PCICTL_SERR	0x0000000400000000	/* SERR asserted; W1C */
226#define	PCICTL_ARB_PARK	0x0000000000200000	/* PCI arbitration parking */
227#define	PCICTL_CPU_PRIO	0x0000000000100000	/* PCI arbitration parking */
228#define	PCICTL_ARB_PRIO	0x00000000000f0000	/* PCI arbitration parking */
229#define	PCICTL_ERRINTEN	0x0000000000000100	/* PCI error interrupt enable */
230#define	PCICTL_RTRYWAIT 0x0000000000000080	/* PCI error interrupt enable */
231#define	PCICTL_4ENABLE	0x000000000000000f	/* enable 4 PCI slots */
232#define	PCICTL_6ENABLE	0x000000000000003f	/* enable 6 PCI slots */
233
234/* Uncorrectable error asynchronous fault status registers */
235#define	UEAFSR_BLK	(1UL << 23)	/* Error caused by block transaction. */
236#define	UEAFSR_P_DTE	(1UL << 56)	/* Pri. DVMA translation error. */
237#define	UEAFSR_S_DTE	(1UL << 57)	/* Sec. DVMA translation error. */
238#define	UEAFSR_S_DWR	(1UL << 58)	/* Sec. error during DVMA write. */
239#define	UEAFSR_S_DRD	(1UL << 59)	/* Sec. error during DVMA read. */
240#define	UEAFSR_S_PIO	(1UL << 60)	/* Sec. error during PIO access. */
241#define	UEAFSR_P_DWR	(1UL << 61)	/* Pri. error during DVMA write. */
242#define	UEAFSR_P_DRD	(1UL << 62)	/* Pri. error during DVMA read. */
243#define	UEAFSR_P_PIO	(1UL << 63)	/* Pri. error during PIO access. */
244
245/* Correctable error asynchronous fault status registers */
246#define	CEAFSR_BLK	(1UL << 23)	/* Error caused by block transaction. */
247#define	CEAFSR_S_DWR	(1UL << 58)	/* Sec. error caused by DVMA write. */
248#define	CEAFSR_S_DRD	(1UL << 59)	/* Sec. error caused by DVMA read. */
249#define	CEAFSR_S_PIO	(1UL << 60)	/* Sec. error caused by PIO access. */
250#define	CEAFSR_P_DWR	(1UL << 61)	/* Pri. error caused by DVMA write. */
251#define	CEAFSR_P_DRD	(1UL << 62)	/* Pri. error caused by DVMA read. */
252#define	CEAFSR_P_PIO	(1UL << 63)	/* Pri. error caused by PIO access. */
253
254#define	CEAFSR_ERRMASK							\
255	(CEAFSR_P_PIO | CEAFSR_P_DRD | CEAFSR_P_DWR |			\
256	 CEAFSR_S_PIO | CEAFSR_S_DRD | CEAFSR_S_DWR)
257
258/* Definitions for the target address space register. */
259#define	PCITAS_ADDR_SHIFT	29
260
261/* Definitions for the psycho configuration space */
262#define	PCS_DEVICE	0		/* Device number of psycho CS entry */
263#define	PCS_FUNC	0		/* Function number of psycho CS entry */
264
265/* Non-Standard registers in the configration space */
266#define	PCSR_SECBUS	0x40		/* Secondary bus number register */
267#define	PCSR_SUBBUS	0x41		/* Subordinate bus number register */
268
269#endif /* _SPARC64_PCI_PSYCHOREG_H_ */
270