1 /*	$NetBSD: ibm405gp.h,v 1.5 2001/10/21 15:09:36 simonb Exp $	*/
2 
3 /*
4  * Copyright 2001 Wasabi Systems, Inc.
5  * All rights reserved.
6  *
7  * Written by Simon Burge and Eduardo Horvath for Wasabi Systems, Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, 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. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed for the NetBSD Project by
20  *      Wasabi Systems, Inc.
21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22  *    or promote products derived from this software without specific prior
23  *    written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef _IBM4XX_IBM405GP_H_
39 #define	_IBM4XX_IBM405GP_H_
40 
41 /* 405GP PVR */
42 #define PVR_405GP      		0x40110000
43 #define PVR_405GP_PASS1 	0x40110000	/* RevA */
44 #define PVR_405GP_PASS2 	0x40110040	/* RevB */
45 #define PVR_405GP_PASS2_1 	0x40110082	/* RevC */
46 #define PVR_405GP_PASS3 	0x401100c4	/* RevD */
47 
48 /*
49  * Memory and PCI addresses
50  */
51 
52 /* Local Memory and Peripherals */
53 #define	LOCAL_MEM_START		0x00000000
54 #define	LOCAL_MEM_END		0x7fffffff
55 
56 /* PCI Memory - 1.625GB */
57 #define	PCI_MEM_START		0x80000000
58 #define	PCI_MEM_END		0xe7ffffff
59 
60 /* PCI I/O - PCI I/O accesses from 0 to 64kB-1 (64kB) */
61 #define	PCI_IO_LOW_START	0xe8000000
62 #define	PCI_IO_LOW_END		0xe800ffff
63 
64 /* PCI I/O - PCI I/O accesses from 8MB to 64MB-1 (56MB) */
65 #define	PCI_IO_HIGH_START	0xe8800000
66 #define	PCI_IO_HIGH_END		0xebffffff
67 
68 /* PCI Configuaration Registers */
69 #define	PCIC0_BASE		0xeec00000
70 #define	PCIC0_CFGADDR		0x00
71 #define	PCIC0_CFGDATA		0x04
72 
73 #define	PCIC0_VENDID		0x00
74 #define	PCIC0_DEVID		0x02
75 #define	PCIC0_CMD		0x04
76 #define	PCIC0_STATUS		0x06
77 #define	PCIC0_REVID		0x08
78 #define	PCIC0_CLS		0x09
79 #define	PCIC0_CACHELS		0x0c
80 #define	PCIC0_LATTIM		0x0d
81 #define	PCIC0_HDTYPE		0x0e
82 #define	PCIC0_BIST		0x0f
83 #define	PCIC0_BAR0		0x10
84 #define	PCIC0_BAR1		0x14		/* PCI name */
85 #define	PCIC0_PTM1BAR		PCIC0_BAR1	/* 405GP name */
86 #define	PCIC0_BAR2		0x18		/* PCI name */
87 #define	PCIC0_PTM2BAR		PCIC0_BAR2	/* 405GP name */
88 #define	PCIC0_BAR3		0x1C
89 #define	PCIC0_BAR4		0x20
90 #define	PCIC0_BAR5		0x24
91 #define	PCIC0_SBSYSVID		0x2c
92 #define	PCIC0_SBSYSID		0x2e
93 #define	PCIC0_CAP		0x34
94 #define	PCIC0_INTLN		0x3c
95 #define	PCIC0_INTPN		0x3d
96 #define	PCIC0_MINGNT		0x3e
97 #define	PCIC0_MAXLTNCY		0x3f
98 
99 #define	PCIC0_ICS		0x44	/* 405GP specific parameters */
100 #define	PCIC0_ERREN		0x48
101 #define	PCIC0_ERRSTS		0x49
102 #define	PCIC0_BRDGOPT1		0x4a
103 #define	PCIC0_PLBBESR0		0x4c
104 #define	PCIC0_PLBBESR1		0x50
105 #define	PCIC0_PLBBEAR		0x54
106 #define	PCIC0_CAPID		0x58
107 #define	PCIC0_NEXTIPTR		0x59
108 #define	PCIC0_PMC		0x5a
109 #define	PCIC0_PMCSR		0x5c
110 #define	PCIC0_PMCSRBSE		0x5e
111 #define	PCIC0_DATA		0x5f
112 #define	PCIC0_BRDGOPT2		0x60
113 #define	PCIC0_PMSCRR		0x64
114 
115 
116 /* PCI Interrupt Acknowledge (read: 0xeed00000 0xeed00003 - 4 bytes) */
117 #define	PCIIA0			0xeed00000
118 
119 /* PCI Special Cycle (write: 0xeed00000 0xeed00003 - 4 bytes) */
120 #define	PCISC0			0xeed00000
121 
122 /* PCI Bridge Local Configuation Registers (0xef400000 0xef40003f - 64 bytes) */
123 #define	PCIL0_BASE		0xef400000
124 #define	PCIL0_PMM0LA		0x00	/* PCI Master Map 0: Local Address */
125 #define	PCIL0_PMM0MA		0x04	/*		     Mask/Attribute */
126 #define	PCIL0_PMM0PCILA		0x08	/*		     PCI Low Address */
127 #define	PCIL0_PMM0PCIHA		0x0c	/*		     PCI High Address */
128 #define	PCIL0_PMM1LA		0x10
129 #define	PCIL0_PMM1MA		0x14
130 #define	PCIL0_PMM1PCILA		0x18
131 #define	PCIL0_PMM1PCIHA		0x1c
132 #define	PCIL0_PMM2LA		0x20
133 #define	PCIL0_PMM2MA		0x24
134 #define	PCIL0_PMM2PCILA		0x28
135 #define	PCIL0_PMM2PCIHA		0x2c
136 #define	PCIL0_PTM1MS		0x30
137 #define	PCIL0_PTM1LA		0x34
138 #define	PCIL0_PTM2MS		0x38
139 #define	PCIL0_PTM2LA		0x3c
140 
141 /*
142  * Internal Peripherals
143  */
144 
145 /* UART0 Registers */
146 #define	UART0_BASE		0xef600300
147 #define	UART0_RBR		0x00	/* R    Receiver Buffer Register */
148 #define	UART0_THR		0x00	/*   W  Transmitter Holding Register */
149 #define	UART0_IER		0x01	/* R/W  Interrupt Enable Register */
150 #define	UART0_IIR		0x02	/* R    Interrupt Identification Register */
151 #define	UART0_FCR		0x02	/*   W  FIFO Control Register */
152 #define	UART0_LCR		0x03	/* R/W  Line Control Register */
153 #define	UART0_MCR		0x04	/* R/W  Modem Control Register */
154 #define	UART0_LSR		0x05	/* R/W  Line Status Register */
155 #define	UART0_MSR		0x06	/* R/W  Modem Status Register */
156 #define	UART0_SCR		0x07	/* R/W  Scratch Register */
157 #define	UART0_DLL		0x00	/* R/W* Divisor Latch (LSB) */
158 #define	UART0_DLM		0x01	/* R/W* Divisor Latch (MSB) */
159 
160 /* UART1 Registers */
161 #define	UART1_BASE		0xef600400
162 #define	UART1_RBR		UART0_RBR /* R    Receiver Buffer Register */
163 #define	UART1_THR		UART0_THR /*   W  Transmitter Holding Register */
164 #define	UART1_IER		UART0_IER /* R/W  Interrupt Enable Register */
165 #define	UART1_IIR		UART0_IIR /* R    Interrupt Identification Register */
166 #define	UART1_FCR		UART0_FCR /*   W  FIFO Control Register */
167 #define	UART1_LCR		UART0_LCR /* R/W  Line Control Register */
168 #define	UART1_MCR		UART0_MCR /* R/W  Modem Control Register */
169 #define	UART1_LSR		UART0_LSR /* R/W  Line Status Register */
170 #define	UART1_MSR		UART0_MSR /* R/W  Modem Status Register */
171 #define	UART1_SCR		UART0_SCR /* R/W  Scratch Register */
172 #define	UART1_DLL		UART0_DLL /* R/W* Divisor Latch (LSB) */
173 #define	UART1_DLM		UART0_DLM /* R/W* Divisor Latch (MSB) */
174 
175 /* IIC Registers */
176 #define	IIC0_BASE		0xef600500
177 #define	IIC0_MDBUF		0x00	/* Master Data Buffer */
178 #define	IIC0_SDBUF		0x02	/* Slave Data Buffer */
179 #define	IIC0_LMADR		0x04	/* Low Master Address */
180 #define	IIC0_HMADR		0x05	/* High Master Address */
181 #define	IIC0_CNTL		0x06	/* Control */
182 #define	IIC0_MDCNTL		0x07	/* Mode Control */
183 #define	IIC0_STS		0x08	/* Status */
184 #define	IIC0_EXTSTS		0x09	/* Extended Status */
185 #define	IIC0_LSADR		0x0a	/* Low Slave Address */
186 #define	IIC0_HSADR		0x0b	/* High Slave Address */
187 #define	IIC0_CLKDIV		0x0c	/* Clock Divide */
188 #define	IIC0_INTRMSK		0x0d	/* Interrupt Mask */
189 #define	IIC0_XFRCNT		0x0e	/* Transfer Count */
190 #define	IIC0_XTCNTLSS		0x0f	/* Extended Control and Slave Status */
191 #define	IIC0_DIRECTCNTL		0x10	/* Direct Control */
192 
193 /* OPB Arbiter Registers */
194 #define	OPBA0_BASE		0xef600600
195 #define	OPBA0_PR		0x00	/* Priority Register */
196 #define	OPBA0_CR		0x01	/* Control Register */
197 
198 /* GPIO Registers */
199 #define	GPIO0_BASE		0xef600700
200 #define	GPIO0_OR		0x00	/* Output */
201 #define	GPIO0_TCR		0x04	/* Three-State Control */
202 #define	GPIO0_ODR		0x18	/* Open Drain */
203 #define	GPIO0_IR		0x1c	/* Input */
204 
205 /* Ethernet MAC Registers */
206 #define	EMAC0_BASE		0xef600800
207 
208 #define	EMAC0_MR0		0x00	/* Mode Register 0 */
209 #define	  MR0_RXI		  0x80000000	/* Receive MAC Idle */
210 #define	  MR0_TXI		  0x40000000	/* Transmit MAC Idle */
211 #define	  MR0_SRST		  0x20000000	/* Soft Reset */
212 #define	  MR0_TXE		  0x10000000	/* Transmit MAC Enable */
213 #define	  MR0_RXE		  0x08000000	/* Receive MAC Enable */
214 #define	  MR0_WKE		  0x04000000	/* Wake-up Enable */
215 
216 #define	EMAC0_MR1		0x04	/* Mode Register 1 */
217 #define	  MR1_FDE		  0x80000000	/* Full-Duplex Enable */
218 #define	  MR1_ILE		  0x40000000	/* Internal Loop-back Enable */
219 #define	  MR1_VLE		  0x20000000	/* VLAN Enable */
220 #define	  MR1_EIFC		  0x10000000	/* Enable Integrated Flow Control */
221 #define	  MR1_APP		  0x08000000	/* Allow Pause Packet */
222 #define	  MR1_IST		  0x01000000	/* Ignore SQE Test */
223 #define	  MR1_MF_MASK		  0x00c00000	/* Medium Frequency mask */
224 #define	  MR1_MF_10MBS		  0x00000000	/* 10MB/sec */
225 #define	  MR1_MF_100MBS		  0x00400000	/* 100MB/sec */
226 #define	  MR1_RFS_MASK		  0x00300000	/* Receive FIFO size */
227 #define	  MR1_RFS_512		  0x00000000	/* 512 bytes */
228 #define	  MR1_RFS_1KB		  0x00100000	/* 1kByte */
229 #define	  MR1_RFS_2KB		  0x00200000	/* 2kByte */
230 #define	  MR1_RFS_4KB		  0x00300000	/* 4kByte */
231 #define	  MR1_TFS_MASK		  0x000c0000	/* Transmit FIFO size */
232 #define	  MR1_TFS_1KB		  0x00040000	/* 1kByte */
233 #define	  MR1_TFS_2KB		  0x00080000	/* 2kByte */
234 #define	  MR1_TR0_MASK		  0x00018000	/* Transmit Request 0 */
235 #define	  MR1_TR0_SINGLE	  0x00000000	/* Single Packet mode */
236 #define	  MR1_TR0_MULTIPLE	  0x00008000	/* Multiple Packet mode */
237 #define	  MR1_TR0_DEPENDANT	  0x00010000	/* Dependent Mode */
238 #define	  MR1_TR1_MASK		  0x00006000	/* Transmit Request 1 */
239 #define	  MR1_TR1_SINGLE	  0x00000000	/* Single Packet mode */
240 #define	  MR1_TR1_MULTIPLE	  0x00002000	/* Multiply Packet mode */
241 #define	  MR1_TR1_DEPENDANT	  0x00004000	/* Dependent Mode */
242 
243 #define	EMAC0_TMR0		0x08	/* Transmit Mode Register 0 */
244 #define	  TMR0_GNP0		  0x80000000	/* Get New Packet for Channel 0 */
245 #define	  TMR0_GNP1		  0x40000000	/* Get New Packet for Channel 1 */
246 #define	  TMR0_GNPD		  0x20000000	/* Get New Packet for Dependent mode */
247 #define	  TMR0_FC_MASK		  0x10000000	/* First Channel */
248 #define	  TMR0_FC_CHAN0		  0x00000000	/* Channel 0 */
249 #define	  TMR0_FC_CHAN1		  0x10000000	/* Channel 1 */
250 
251 #define	EMAC0_TMR1		0x0c	/* Transmit Mode Register 1 */
252 #define	  TMR1_TLR_MASK		  0xf8000000	/* Transmit Low Request */
253 #define	  TMR1_TLR_SHIFT	  27
254 #define	  TMR1_TUR_MASK		  0x00ff0000	/* Transmit Urgent Request */
255 #define	  TMR1_TUR_SHIFT	  16
256 
257 #define	EMAC0_RMR		0x10	/* Receive Mode Register */
258 #define	  RMR_SP		  0x80000000	/* Strip Padding */
259 #define	  RMR_SFCS		  0x40000000	/* Strip FCS */
260 #define	  RMR_RRP		  0x20000000	/* Receive Runt Packets */
261 #define	  RMR_RFP		  0x10000000	/* Receive FCS Packets */
262 #define	  RMR_ROP		  0x08000000	/* Receive Oversize Packets */
263 #define	  RMR_RPIR		  0x04000000	/* Receive Packets with In Range Error */
264 #define	  RMR_PPP		  0x02000000	/* Propagate Pause Packet */
265 #define	  RMR_PME		  0x01000000	/* Promiscuous Mode Enable */
266 #define	  RMR_PMME		  0x00800000	/* Promiscuous Multicast Mode Enable */
267 #define	  RMR_IAE		  0x00400000	/* Individual Address Enable */
268 #define	  RMR_MIAE		  0x00200000	/* Multiple Individual Address Enable */
269 #define	  RMR_BAE		  0x00100000	/* Broadcast Address Enable */
270 #define	  RMR_MAE		  0x00080000	/* Multicast Address Enable */
271 
272 #define	EMAC0_ISR		0x14	/* Interrupt Status Register */
273 #define	  ISR_OVR		  0x02000000	/* Overrun Error */
274 #define	  ISR_PP		  0x01000000	/* Pause Packet */
275 #define	  ISR_BP		  0x00800000	/* Bad Packet */
276 #define	  ISR_RP		  0x00400000	/* Runt Packet */
277 #define	  ISR_SE		  0x00200000	/* Short Event */
278 #define	  ISR_ALE		  0x00100000	/* Alignment Error */
279 #define	  ISR_BFCS		  0x00080000	/* Bad FCS */
280 #define	  ISR_PTLE		  0x00040000	/* Packet Too Long Error */
281 #define	  ISR_ORE		  0x00020000	/* Out of Range Error */
282 #define	  ISR_IRE		  0x00010000	/* In Range Error */
283 #define	  ISR_DBDM		  0x00000200	/* Dead Bit Dependent Mode */
284 #define	  ISR_DB0		  0x00000100	/* Dead Bit 0 */
285 #define	  ISR_SE0		  0x00000080	/* SQE Error 0 */
286 #define	  ISR_TE0		  0x00000040	/* Transmit Error 0 */
287 #define	  ISR_DB1		  0x00000020	/* Dead Bit 1 */
288 #define	  ISR_SE1		  0x00000010	/* SQE Error 1 */
289 #define	  ISR_TE1		  0x00000008	/* Transmit Error 1 */
290 #define	  ISR_MOS		  0x00000002	/* MMA Operation Succeeded */
291 #define	  ISR_MOF		  0x00000001	/* MMA Operation Failed */
292 
293 #define	EMAC0_ISER		0x18	/* Interrupt Status Enable Register */
294 #define	  ISER_OVR		  ISR_OVR
295 #define	  ISER_PP		  ISR_PP
296 #define	  ISER_BP		  ISR_BP
297 #define	  ISER_RP		  ISR_RP
298 #define	  ISER_SE		  ISR_SE
299 #define	  ISER_ALE		  ISR_ALE
300 #define	  ISER_BFCS		  ISR_BFCS
301 #define	  ISER_PTLE		  ISR_PTLE
302 #define	  ISER_ORE		  ISR_ORE
303 #define	  ISER_IRE		  ISR_IRE
304 #define	  ISER_DBDM		  ISR_DBDM
305 #define	  ISER_DB0		  ISR_DB0
306 #define	  ISER_SE0		  ISR_SE0
307 #define	  ISER_TE0		  ISR_TE0
308 #define	  ISER_DB1		  ISR_DB1
309 #define	  ISER_SE1		  ISR_SE1
310 #define	  ISER_TE1		  ISR_TE1
311 #define	  ISER_MOS		  ISR_MOS
312 #define	  ISER_MOF		  ISR_MOF
313 
314 #define	EMAC0_IAHR		0x1c	/* Individual Address High Register */
315 #define	EMAC0_IALR		0x20	/* Individual Address Low Register */
316 #define	EMAC0_VTPID		0x24	/* VLAN TPID Register */
317 #define	EMAC0_VTCI		0x28	/* VLAN TCI Register */
318 #define	EMAC0_PTR		0x2c	/* Pause Timer Register */
319 #define	EMAC0_IAHT1		0x30	/* Individual Address Hash Table 1 */
320 #define	EMAC0_IAHT2		0x34	/* Individual Address Hash Table 2 */
321 #define	EMAC0_IAHT3		0x38	/* Individual Address Hash Table 3 */
322 #define	EMAC0_IAHT4		0x3c	/* Individual Address Hash Table 4 */
323 #define	EMAC0_GAHT1		0x40	/* Group Address Hash Table 1 */
324 #define	EMAC0_GAHT2		0x44	/* Group Address Hash Table 2 */
325 #define	EMAC0_GAHT3		0x48	/* Group Address Hash Table 3 */
326 #define	EMAC0_GAHT4		0x4c	/* Group Address Hash Table 4 */
327 #define	EMAC0_LSAH		0x50	/* Last Source Address High */
328 #define	EMAC0_LSAL		0x54	/* Last Source Address Low */
329 #define	EMAC0_IPGVR		0x58	/* Inter-Packet Gap Value Register */
330 
331 #define	EMAC0_STACR		0x5c	/* STA Control Register */
332 #define	  STACR_PHYD		  0xffff0000	/* PHY data mask */
333 #define	  STACR_PHYDSHIFT	  16
334 #define	  STACR_OC		  0x00008000	/* operation complete */
335 #define	  STACR_PHYE		  0x00004000	/* PHY error */
336 #define	  STACR_WRITE		  0x00002000	/* STA command - write */
337 #define	  STACR_READ		  0x00001000	/* STA command - read */
338 #define	  STACR_OPBC_MASK	  0x00000c00	/* OPB bus clock freq mask */
339 #define	  STACR_OPBC_50MHZ	  0x00000000	/* OPB bus clock freq -  50MHz */
340 #define	  STACR_OPBC_66MHZ	  0x00000400	/* OPB bus clock freq -  66MHz */
341 #define	  STACR_OPBC_83MHZ	  0x00000800	/* OPB bus clock freq -  83MHz */
342 #define	  STACR_OPBC_100MHZ	  0x00000c00	/* OPB bus clock freq - 100MHz */
343 #define	  STACR_PCDA		  0x000003e0	/* PHY cmd dest address mask */
344 #define	  STACR_PCDASHIFT	  5
345 #define	  STACR_PRA		  0x0000001f	/* PHY register address mask */
346 #define	  STACR_PRASHIFT	  0
347 
348 #define	EMAC0_TRTR		0x60	/* Transmit Request Threshold Register */
349 #define	  TRTR_64		  0x00000000	/* 64 bytes */
350 #define	  TRTR_128		  0x08000000	/* 128 bytes */
351 #define	  TRTR_192		  0x10000000	/* 192 bytes */
352 #define	  TRTR_256		  0x18000000	/* 256 bytes */
353 /* ... and so on +64 until ... */
354 #define	  TRTR_2048		  0xf8000000	/* 2048 bytes */
355 
356 #define	EMAC0_RWMR		0x64	/* Receive Low/High Water Mark Register */
357 #define	  RWMR_RLWM_MASK	  0xff800000	/* Receive Low Water Mark */
358 #define	  RWMR_RLWM_SHIFT	    23
359 #define	  RWMR_RHWM_MASK	  0x0000ff80	/* Receive High Water Mark */
360 #define	  RWMR_RHWM_SHIFT	    7
361 
362 #define	EMAC0_OCTX		0x68	/* Number of Octets Transmitted */
363 #define	EMAC0_OCRX		0x6c	/* Number of Octets Received */
364 
365 
366 /* Expansion ROM - 254MB */
367 #define	EXPANSION_ROM_START	0xf0000000
368 #define	EXPANSION_ROM_END	0xffdfffff
369 
370 /* Boot ROM - 2MB */
371 #define	BOOT_ROM_START		0xffe00000
372 #define	BOOT_ROM_END		0xffffffff
373 
374 #ifndef _LOCORE
375 void galaxy_show_pci_map(void);
376 void galaxy_setup_pci(void);
377 #endif /* _LOCORE */
378 #endif	/* _IBM4XX_IBM405GP_H_ */
379