xref: /netbsd/sys/arch/sparc64/dev/psychoreg.h (revision bf9ec67e)
1 /*	$NetBSD: psychoreg.h,v 1.9 2001/09/15 07:10:05 eeh Exp $ */
2 
3 /*
4  * Copyright (c) 1998, 1999 Eduardo E. Horvath
5  * Copyright (c) 1999 Matthew R. Green
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, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 #ifndef _SPARC64_DEV_PSYCHOREG_H_
32 #define _SPARC64_DEV_PSYCHOREG_H_
33 
34 /*
35  * Sun4u PCI definitions.  Here's where we deal w/the machine
36  * dependencies of psycho and the PCI controller on the UltraIIi.
37  *
38  * All PCI registers are bit-swapped, however they are not byte-swapped.
39  * This means that they must be accessed using little-endian access modes,
40  * either map the pages little-endian or use little-endian ASIs.
41  *
42  * PSYCHO implements two PCI buses, A and B.
43  */
44 
45 struct psychoreg {
46 	struct upareg {
47 		u_int64_t	upa_portid;	/* UPA port ID register */		/* 1fe.0000.0000 */
48 		u_int64_t	upa_config;	/* UPA config register */		/* 1fe.0000.0008 */
49 	} sys_upa;
50 
51 	u_int64_t	psy_csr;		/* PSYCHO control/status register */	/* 1fe.0000.0010 */
52 	/*
53 	 * 63     59     55     50     45     4        3       2     1      0
54 	 * +------+------+------+------+--//---+--------+-------+-----+------+
55 	 * | IMPL | VERS | MID  | IGN  |  xxx  | APCKEN | APERR | IAP | MODE |
56 	 * +------+------+------+------+--//---+--------+-------+-----+------+
57 	 *
58 	 */
59 #define PSYCHO_GCSR_IMPL(csr)	((u_int)(((csr) >> 60) & 0xf))
60 #define PSYCHO_GCSR_VERS(csr)	((u_int)(((csr) >> 56) & 0xf))
61 #define PSYCHO_GCSR_MID(csr)	((u_int)(((csr) >> 51) & 0x1f))
62 #define PSYCHO_GCSR_IGN(csr)	((u_int)(((csr) >> 46) & 0x1f))
63 #define PSYCHO_CSR_APCKEN	8	/* UPA addr parity check enable */
64 #define PSYCHO_CSR_APERR	4	/* UPA addr parity error */
65 #define PSYCHO_CSR_IAP		2	/* invert UPA address parity */
66 #define PSYCHO_CSR_MODE		1	/* UPA/PCI handshake */
67 
68 	u_int64_t	pad0;
69 	u_int64_t	psy_ecccr;		/* ECC control register */		/* 1fe.0000.0020 */
70 	u_int64_t	reserved;							/* 1fe.0000.0028 */
71 	u_int64_t	psy_ue_afsr;		/* Uncorrectable Error AFSR */		/* 1fe.0000.0030 */
72 #define	PSYCHO_UE_AFSR_BITS	"\177\020"				\
73 	"b\27BLK\0b\070P_DTE\0b\071S_DTE\0b\072S_DWR\0b\073S_DRD\0b"	\
74 	"\075P_DWR\0b\076P_DRD\0\0"
75 	u_int64_t	psy_ue_afar;		/* Uncorrectable Error AFAR */		/* 1fe.0000.0038 */
76 	u_int64_t	psy_ce_afsr;		/* Correctable Error AFSR */		/* 1fe.0000.0040 */
77 	u_int64_t	psy_ce_afar;		/* Correctable Error AFAR */		/* 1fe.0000.0048 */
78 
79 	u_int64_t	pad1[22];
80 
81 	struct perfmon {
82 		u_int64_t	pm_cr;		/* Performance monitor control reg */	/* 1fe.0000.0100 */
83 		u_int64_t	pm_count;	/* Performance monitor counter reg */	/* 1fe.0000.0108 */
84 	} psy_pm;
85 
86 	u_int64_t	pad2[30];
87 
88 	struct iommureg psy_iommu;							/* 1fe.0000.0200,0210 */
89 
90 	u_int64_t	pad3[317];
91 
92 	u_int64_t	pcia_slot0_int;		/* PCI bus a slot 0 irq map reg */	/* 1fe.0000.0c00 */
93 	u_int64_t	pcia_slot1_int;		/* PCI bus a slot 1 irq map reg */	/* 1fe.0000.0c08 */
94 	u_int64_t	pcia_slot2_int;		/* PCI bus a slot 2 irq map reg (IIi)*/	/* 1fe.0000.0c10 */
95 	u_int64_t	pcia_slot3_int;		/* PCI bus a slot 3 irq map reg (IIi)*/	/* 1fe.0000.0c18 */
96 	u_int64_t	pcib_slot0_int;		/* PCI bus b slot 0 irq map reg */	/* 1fe.0000.0c20 */
97 	u_int64_t	pcib_slot1_int;		/* PCI bus b slot 1 irq map reg */	/* 1fe.0000.0c28 */
98 	u_int64_t	pcib_slot2_int;		/* PCI bus b slot 1 irq map reg */	/* 1fe.0000.0c30 */
99 	u_int64_t	pcib_slot3_int;		/* PCI bus b slot 1 irq map reg */	/* 1fe.0000.0c38 */
100 
101 	u_int64_t	pad4[120];
102 
103 	u_int64_t	scsi_int_map;		/* SCSI interrupt map reg */		/* 1fe.0000.1000 */
104 	u_int64_t	ether_int_map;		/* ethernet interrupt map reg */	/* 1fe.0000.1008 */
105 	u_int64_t	bpp_int_map;		/* parallel interrupt map reg */	/* 1fe.0000.1010 */
106 	u_int64_t	audior_int_map;		/* audio record interrupt map reg */	/* 1fe.0000.1018 */
107 	u_int64_t	audiop_int_map;		/* audio playback interrupt map reg */	/* 1fe.0000.1020 */
108 	u_int64_t	power_int_map;		/* power fail interrupt map reg */	/* 1fe.0000.1028 */
109 	u_int64_t	ser_kbd_ms_int_map;	/* serial/kbd/mouse interrupt map reg *//* 1fe.0000.1030 */
110 	u_int64_t	fd_int_map;		/* floppy interrupt map reg */		/* 1fe.0000.1038 */
111 	u_int64_t	spare_int_map;		/* spare interrupt map reg */		/* 1fe.0000.1040 */
112 	u_int64_t	kbd_int_map;		/* kbd [unused] interrupt map reg */	/* 1fe.0000.1048 */
113 	u_int64_t	mouse_int_map;		/* mouse [unused] interrupt map reg */	/* 1fe.0000.1050 */
114 	u_int64_t	serial_int_map;		/* second serial interrupt map reg */	/* 1fe.0000.1058 */
115 	u_int64_t	timer0_int_map;		/* timer 0 interrupt map reg */		/* 1fe.0000.1060 */
116 	u_int64_t	timer1_int_map;		/* timer 1 interrupt map reg */		/* 1fe.0000.1068 */
117 	u_int64_t	ue_int_map;		/* UE interrupt map reg */		/* 1fe.0000.1070 */
118 	u_int64_t	ce_int_map;		/* CE interrupt map reg */		/* 1fe.0000.1078 */
119 	u_int64_t	pciaerr_int_map;	/* PCI bus a error interrupt map reg */	/* 1fe.0000.1080 */
120 	u_int64_t	pciberr_int_map;	/* PCI bus b error interrupt map reg */	/* 1fe.0000.1088 */
121 	u_int64_t	pwrmgt_int_map;		/* power mgmt wake interrupt map reg */	/* 1fe.0000.1090 */
122 	u_int64_t	ffb0_int_map;		/* FFB0 graphics interrupt map reg */	/* 1fe.0000.1098 */
123 	u_int64_t	ffb1_int_map;		/* FFB1 graphics interrupt map reg */	/* 1fe.0000.10a0 */
124 
125 	u_int64_t	pad5[107];
126 
127 	/* Note: clear interrupt 0 registers are not really used */
128 	u_int64_t	pcia0_clr_int[4];	/* PCI a slot 0 clear int regs 0..7 */	/* 1fe.0000.1400-1418 */
129 	u_int64_t	pcia1_clr_int[4];	/* PCI a slot 1 clear int regs 0..7 */	/* 1fe.0000.1420-1438 */
130 	u_int64_t	pcia2_clr_int[4];	/* PCI a slot 2 clear int regs 0..7 */	/* 1fe.0000.1440-1458 */
131 	u_int64_t	pcia3_clr_int[4];	/* PCI a slot 3 clear int regs 0..7 */	/* 1fe.0000.1480-1478 */
132 	u_int64_t	pcib0_clr_int[4];	/* PCI b slot 0 clear int regs 0..7 */	/* 1fe.0000.1480-1498 */
133 	u_int64_t	pcib1_clr_int[4];	/* PCI b slot 1 clear int regs 0..7 */	/* 1fe.0000.14a0-14b8 */
134 	u_int64_t	pcib2_clr_int[4];	/* PCI b slot 2 clear int regs 0..7 */	/* 1fe.0000.14c0-14d8 */
135 	u_int64_t	pcib3_clr_int[4];	/* PCI b slot 3 clear int regs 0..7 */	/* 1fe.0000.14d0-14f8 */
136 
137 	u_int64_t	pad6[96];
138 
139 	u_int64_t	scsi_clr_int;		/* SCSI clear int reg */		/* 1fe.0000.1800 */
140 	u_int64_t	ether_clr_int;		/* ethernet clear int reg */		/* 1fe.0000.1808 */
141 	u_int64_t	bpp_clr_int;		/* parallel clear int reg */		/* 1fe.0000.1810 */
142 	u_int64_t	audior_clr_int;		/* audio record clear int reg */	/* 1fe.0000.1818 */
143 	u_int64_t	audiop_clr_int;		/* audio playback clear int reg */	/* 1fe.0000.1820 */
144 	u_int64_t	power_clr_int;		/* power fail clear int reg */		/* 1fe.0000.1828 */
145 	u_int64_t	ser_kb_ms_clr_int;	/* serial/kbd/mouse clear int reg */	/* 1fe.0000.1830 */
146 	u_int64_t	fd_clr_int;		/* floppy clear int reg */		/* 1fe.0000.1838 */
147 	u_int64_t	spare_clr_int;		/* spare clear int reg */		/* 1fe.0000.1840 */
148 	u_int64_t	kbd_clr_int;		/* kbd [unused] clear int reg */	/* 1fe.0000.1848 */
149 	u_int64_t	mouse_clr_int;		/* mouse [unused] clear int reg */	/* 1fe.0000.1850 */
150 	u_int64_t	serial_clr_int;		/* second serial clear int reg */	/* 1fe.0000.1858 */
151 	u_int64_t	timer0_clr_int;		/* timer 0 clear int reg */		/* 1fe.0000.1860 */
152 	u_int64_t	timer1_clr_int;		/* timer 1 clear int reg */		/* 1fe.0000.1868 */
153 	u_int64_t	ue_clr_int;		/* UE clear int reg */			/* 1fe.0000.1870 */
154 	u_int64_t	ce_clr_int;		/* CE clear int reg */			/* 1fe.0000.1878 */
155 	u_int64_t	pciaerr_clr_int;	/* PCI bus a error clear int reg */	/* 1fe.0000.1880 */
156 	u_int64_t	pciberr_clr_int;	/* PCI bus b error clear int reg */	/* 1fe.0000.1888 */
157 	u_int64_t	pwrmgt_clr_int;		/* power mgmt wake clr interrupt reg */	/* 1fe.0000.1890 */
158 
159 	u_int64_t	pad7[45];
160 
161 	u_int64_t	intr_retry_timer;	/* interrupt retry timer */		/* 1fe.0000.1a00 */
162 
163 	u_int64_t	pad8[63];
164 
165 	struct timer_counter {
166 		u_int64_t	tc_count;	/* timer/counter 0/1 count register */	/* 1fe.0000.1c00,1c10 */
167 		u_int64_t	tc_limit;	/* timer/counter 0/1 limit register */	/* 1fe.0000.1c08,1c18 */
168 	} tc[2];
169 
170 	u_int64_t	pci_dma_write_sync;	/* PCI DMA write sync register (IIi) */	/* 1fe.0000.1c20 */
171 
172 	u_int64_t	pad9[123];
173 
174 	struct pci_ctl {
175 		u_int64_t	pci_csr;	/* PCI a/b control/status register */	/* 1fe.0000.2000,4000 */
176 		u_int64_t	pad10;
177 		u_int64_t	pci_afsr;	/* PCI a/b AFSR register */		/* 1fe.0000.2010,4010 */
178 		u_int64_t	pci_afar;	/* PCI a/b AFAR register */		/* 1fe.0000.2018,4018 */
179 		u_int64_t	pci_diag;	/* PCI a/b diagnostic register */	/* 1fe.0000.2020,4020 */
180 		u_int64_t	pci_tasr;	/* PCI target address space reg (IIi)*/	/* 1fe.0000.2028,4028 */
181 
182 		u_int64_t	pad11[250];
183 
184 		/* This is really the IOMMU's, not the PCI bus's */
185 		struct iommu_strbuf pci_strbuf;						/* 1fe.0000.2800-210 */
186 #define psy_iommu_strbuf psy_pcictl[0].pci_strbuf
187 
188 		u_int64_t	pad12[765];
189 	} psy_pcictl[2];			/* For PCI a and b */
190 
191 	/* NB: FFB0 and FFB1 intr map regs also appear at 1fe.0000.6000 and 1fe.0000.8000 respectively */
192 	u_int64_t	pad13[2048];
193 
194 	u_int64_t	dma_scb_diag0;		/* DMA scoreboard diag reg 0 */		/* 1fe.0000.a000 */
195 	u_int64_t	dma_scb_diag1;		/* DMA scoreboard diag reg 1 */		/* 1fe.0000.a008 */
196 
197 	u_int64_t	pad14[126];
198 
199 	u_int64_t	iommu_svadiag;		/* IOMMU virtual addr diag reg */	/* 1fe.0000.a400 */
200 	u_int64_t	iommu_tlb_comp_diag;	/* IOMMU TLB tag compare diag reg */	/* 1fe.0000.a408 */
201 
202 	u_int64_t	pad15[30];
203 
204 	u_int64_t	iommu_queue_diag[16];	/* IOMMU LRU queue diag */		/* 1fe.0000.a500-a578 */
205 	u_int64_t	tlb_tag_diag[16];	/* TLB tag diag */			/* 1fe.0000.a580-a5f8 */
206 	u_int64_t	tlb_data_diag[16];	/* TLB data RAM diag */			/* 1fe.0000.a600-a678 */
207 
208 	u_int64_t	pad16[48];
209 
210 	u_int64_t	pci_int_diag;		/* SBUS int state diag reg */		/* 1fe.0000.a800 */
211 	u_int64_t	obio_int_diag;		/* OBIO and misc int state diag reg */	/* 1fe.0000.a808 */
212 
213 	u_int64_t	pad17[254];
214 
215 	struct strbuf_diag {
216 		u_int64_t	strbuf_data_diag[128];	/* streaming buffer data RAM diag */	/* 1fe.0000.b000-b3f8 */
217 		u_int64_t	strbuf_error_diag[128];	/* streaming buffer error status diag *//* 1fe.0000.b400-b7f8 */
218 		u_int64_t	strbuf_pg_tag_diag[16];	/* streaming buffer page tag diag */	/* 1fe.0000.b800-b878 */
219 		u_int64_t	pad18[16];
220 		u_int64_t	strbuf_ln_tag_diag[16];	/* streaming buffer line tag diag */	/* 1fe.0000.b900-b978 */
221 		u_int64_t	pad19[208];
222 	} psy_strbufdiag[2];					/* For PCI a and b */
223 
224 	/*
225 	 * Here is the rest of the map, which we're not specifying:
226 	 *
227 	 * 1fe.0100.0000 - 1fe.01ff.ffff	PCI configuration space
228 	 * 1fe.0100.0000 - 1fe.0100.00ff	PCI B configuration header
229 	 * 1fe.0101.0000 - 1fe.0101.00ff	PCI A configuration header
230 	 * 1fe.0200.0000 - 1fe.0200.ffff	PCI A I/O space
231 	 * 1fe.0201.0000 - 1fe.0201.ffff	PCI B I/O space
232 	 * 1ff.0000.0000 - 1ff.7fff.ffff	PCI A memory space
233 	 * 1ff.8000.0000 - 1ff.ffff.ffff	PCI B memory space
234 	 *
235 	 * NB: config and I/O space can use 1-4 byte accesses, not 8 byte
236 	 * accesses.  Memory space can use any sized accesses.
237 	 *
238 	 * Note that the SUNW,sabre/SUNW,simba combinations found on the
239 	 * Ultra5 and Ultra10 machines uses slightly differrent addresses
240 	 * than the above.  This is mostly due to the fact that the APB is
241 	 * a multi-function PCI device with two PCI bridges, and the U2P is
242 	 * two separate PCI bridges.  It uses the same PCI configuration
243 	 * space, though the configuration header for each PCI bus is
244 	 * located differently due to the SUNW,simba PCI busses being
245 	 * function 0 and function 1 of the APB, whereas the psycho's are
246 	 * each their own PCI device.  The I/O and memory spaces are each
247 	 * split into 8 equally sized areas (8x2MB blocks for I/O space,
248 	 * and 8x512MB blocks for memory space).  These are allocated in to
249 	 * either PCI A or PCI B, or neither in the APB's `I/O Address Map
250 	 * Register A/B' (0xde) and `Memory Address Map Register A/B' (0xdf)
251 	 * registers of each simba.  We must ensure that both of the
252 	 * following are correct (the prom should do this for us):
253 	 *
254 	 *    (PCI A Memory Address Map) & (PCI B Memory Address Map) == 0
255 	 *
256 	 *    (PCI A I/O Address Map) & (PCI B I/O Address Map) == 0
257 	 *
258 	 * 1fe.0100.0000 - 1fe.01ff.ffff	PCI configuration space
259 	 * 1fe.0100.0800 - 1fe.0100.08ff	PCI B configuration header
260 	 * 1fe.0100.0900 - 1fe.0100.09ff	PCI A configuration header
261 	 * 1fe.0200.0000 - 1fe.02ff.ffff	PCI I/O space (divided)
262 	 * 1ff.0000.0000 - 1ff.ffff.ffff	PCI memory space (divided)
263 	 */
264 };
265 
266 /* what the bits mean! */
267 
268 /* PCI [a|b] control/status register */
269 /* note that the sabre only has one set of PCI control/status registers */
270 #define	PCICTL_MRLM	0x0000001000000000	/* Memory Read Line/Multiple */
271 #define	PCICTL_SERR	0x0000000400000000	/* SERR asserted; W1C */
272 #define	PCICTL_ARB_PARK	0x0000000000200000	/* PCI arbitration parking */
273 #define	PCICTL_CPU_PRIO	0x0000000000100000	/* PCI arbitration parking */
274 #define	PCICTL_ARB_PRIO	0x00000000000f0000	/* PCI arbitration parking */
275 #define	PCICTL_ERRINTEN	0x0000000000000100	/* PCI error interrupt enable */
276 #define	PCICTL_RTRYWAIT 0x0000000000000080	/* PCI error interrupt enable */
277 #define	PCICTL_4ENABLE	0x000000000000000f	/* enable 4 PCI slots */
278 #define	PCICTL_6ENABLE	0x000000000000003f	/* enable 6 PCI slots */
279 
280 /*
281  * these are the PROM structures we grovel
282  */
283 
284 /*
285  * For the physical adddresses split into 3 32 bit values, we deocde
286  * them like the following (IEEE1275 PCI Bus binding 2.0, 2.2.1.1
287  * Numerical Representation):
288  *
289  * 	phys.hi cell:	npt000ss bbbbbbbb dddddfff rrrrrrrr
290  * 	phys.mid cell:	hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
291  * 	phys.lo cell:	llllllll llllllll llllllll llllllll
292  *
293  * where these bits affect the address' properties:
294  *	n	not-relocatable
295  *	p	prefetchable
296  *	t	aliased (non-relocatable IO), below 1MB (memory) or
297  *		below 64KB (reloc. IO)
298  *	ss	address space code:
299  *		00 - configuration space
300  *		01 - I/O space
301  *		10 - 32 bit memory space
302  *		11 - 64 bit memory space
303  *	bb..bb	8 bit bus number
304  *	ddddd	5 bit device number
305  *	fff	3 bit function number
306  *	rr..rr	8 bit register number
307  *	hh..hh	32 bit unsigned value
308  *	ll..ll	32 bit unsigned value
309  * the values of hh..hh and ll..ll are combined to form a larger number.
310  *
311  * For config space, we don't have to do much special.  For I/O space,
312  * hh..hh must be zero, and if n == 0 ll..ll is the offset from the
313  * start of I/O space, otherwise ll..ll is the I/O space.  For memory
314  * space, hh..hh must be zero for the 32 bit space, and is the high 32
315  * bits in 64 bit space, with ll..ll being the low 32 bits in both cases,
316  * with offset handling being driver via `n == 0' as for I/O space.
317  */
318 
319 /* commonly used */
320 #define TAG2BUS(tag)	((tag) >> 16) & 0xff;
321 #define TAG2DEV(tag)	((tag) >> 11) & 0x1f;
322 #define TAG2FN(tag)	((tag) >> 8) & 0x7;
323 
324 struct psycho_registers {
325 	u_int32_t	phys_hi;
326 	u_int32_t	phys_mid;
327 	u_int32_t	phys_lo;
328 	u_int32_t	size_hi;
329 	u_int32_t	size_lo;
330 };
331 
332 struct psycho_ranges {
333 	u_int32_t	cspace;
334 	u_int32_t	child_hi;
335 	u_int32_t	child_lo;
336 	u_int32_t	phys_hi;
337 	u_int32_t	phys_lo;
338 	u_int32_t	size_hi;
339 	u_int32_t	size_lo;
340 };
341 
342 struct psycho_interrupt_map {
343 	u_int32_t	phys_hi;
344 	u_int32_t	phys_mid;
345 	u_int32_t	phys_lo;
346 	u_int32_t	intr;
347 	int32_t		child_node;
348 	u_int32_t	child_intr;
349 };
350 
351 struct psycho_interrupt_map_mask {
352 	u_int32_t	phys_hi;
353 	u_int32_t	phys_mid;
354 	u_int32_t	phys_lo;
355 	u_int32_t	intr;
356 };
357 
358 #endif /* _SPARC64_DEV_PSYCHOREG_H_ */
359