xref: /openbsd-src/sys/dev/ofw/ofw_pci.h (revision d874cce4b1d9fe6b41c9e4f2117a77d8a4a37b92)
1*d874cce4Sray /*	$OpenBSD: ofw_pci.h,v 1.4 2008/06/26 05:42:17 ray Exp $	*/
2a941ee9aSart /*	$NetBSD: ofw_pci.h,v 1.4 2001/02/17 16:28:37 mrg Exp $	*/
3a941ee9aSart 
4a941ee9aSart /*-
5a941ee9aSart  * Copyright (c) 1999 The NetBSD Foundation, Inc.
6a941ee9aSart  * All rights reserved.
7a941ee9aSart  *
8a941ee9aSart  * This code is derived from software contributed to The NetBSD Foundation
9a941ee9aSart  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10a941ee9aSart  * NASA Ames Research Center.
11a941ee9aSart  *
12a941ee9aSart  * Redistribution and use in source and binary forms, with or without
13a941ee9aSart  * modification, are permitted provided that the following conditions
14a941ee9aSart  * are met:
15a941ee9aSart  * 1. Redistributions of source code must retain the above copyright
16a941ee9aSart  *    notice, this list of conditions and the following disclaimer.
17a941ee9aSart  * 2. Redistributions in binary form must reproduce the above copyright
18a941ee9aSart  *    notice, this list of conditions and the following disclaimer in the
19a941ee9aSart  *    documentation and/or other materials provided with the distribution.
20a941ee9aSart  *
21a941ee9aSart  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22a941ee9aSart  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23a941ee9aSart  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24a941ee9aSart  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25a941ee9aSart  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26a941ee9aSart  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27a941ee9aSart  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28a941ee9aSart  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29a941ee9aSart  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30a941ee9aSart  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31a941ee9aSart  * POSSIBILITY OF SUCH DAMAGE.
32a941ee9aSart  */
33a941ee9aSart 
34a941ee9aSart #ifndef _DEV_OFW_OFW_PCI_H_
35a941ee9aSart #define	_DEV_OFW_OFW_PCI_H_
36a941ee9aSart 
37a941ee9aSart /*
38a941ee9aSart  * PCI Bus Binding to:
39a941ee9aSart  *
40a941ee9aSart  * IEEE Std 1275-1994
41a941ee9aSart  * Standard for Boot (Initialization Configuration) Firmware
42a941ee9aSart  *
43a941ee9aSart  * Revision 2.1
44a941ee9aSart  */
45a941ee9aSart 
46a941ee9aSart /*
47a941ee9aSart  * Section 2.2.1. Physical Address Formats
48a941ee9aSart  *
49a941ee9aSart  * A PCI physical address is represented by 3 address cells:
50a941ee9aSart  *
51a941ee9aSart  *	phys.hi cell:	npt000ss bbbbbbbb dddddfff rrrrrrrr
52a941ee9aSart  *	phys.mid cell:	hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
53a941ee9aSart  *	phys.lo cell:	llllllll llllllll llllllll llllllll
54a941ee9aSart  *
55a941ee9aSart  *	n	nonrelocatable
5666a03061Sjmc  *	p	prefetchable
57a941ee9aSart  *	t	aliased below 1MB (memory) or 64k (i/o)
58a941ee9aSart  *	ss	space code
59a941ee9aSart  *	b	bus number
60a941ee9aSart  *	d	device number
61a941ee9aSart  *	f	function number
62a941ee9aSart  *	r	register number
63a941ee9aSart  *	h	high 32-bits of PCI address
64a941ee9aSart  *	l	low 32-bits of PCI address
65a941ee9aSart  */
66a941ee9aSart 
67a941ee9aSart #define	OFW_PCI_PHYS_HI_NONRELOCATABLE	0x80000000
68a941ee9aSart #define	OFW_PCI_PHYS_HI_PREFETCHABLE	0x40000000
69a941ee9aSart #define	OFW_PCI_PHYS_HI_ALIASED		0x20000000
70a941ee9aSart #define	OFW_PCI_PHYS_HI_SPACEMASK	0x03000000
71a941ee9aSart #define	OFW_PCI_PHYS_HI_BUSMASK		0x00ff0000
72a941ee9aSart #define	OFW_PCI_PHYS_HI_BUSSHIFT	16
73a941ee9aSart #define	OFW_PCI_PHYS_HI_DEVICEMASK	0x0000f800
74a941ee9aSart #define	OFW_PCI_PHYS_HI_DEVICESHIFT	11
75a941ee9aSart #define	OFW_PCI_PHYS_HI_FUNCTIONMASK	0x00000700
76a941ee9aSart #define	OFW_PCI_PHYS_HI_FUNCTIONSHIFT	8
77a941ee9aSart #define	OFW_PCI_PHYS_HI_REGISTERMASK	0x000000ff
78a941ee9aSart 
79a941ee9aSart #define	OFW_PCI_PHYS_HI_SPACE_CONFIG	0x00000000
80a941ee9aSart #define	OFW_PCI_PHYS_HI_SPACE_IO	0x01000000
81a941ee9aSart #define	OFW_PCI_PHYS_HI_SPACE_MEM32	0x02000000
82a941ee9aSart #define	OFW_PCI_PHYS_HI_SPACE_MEM64	0x03000000
83a941ee9aSart 
84a941ee9aSart #define OFW_PCI_PHYS_HI_BUS(hi) \
85a941ee9aSart 	(((hi) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT)
86a941ee9aSart #define OFW_PCI_PHYS_HI_DEVICE(hi) \
87a941ee9aSart 	(((hi) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT)
88a941ee9aSart #define OFW_PCI_PHYS_HI_FUNCTION(hi) \
89a941ee9aSart 	(((hi) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT)
90a941ee9aSart 
91a941ee9aSart /*
92a941ee9aSart  * This has the 3 32bit cell values, plus 2 more to make up a 64-bit size.
93a941ee9aSart  */
94a941ee9aSart struct ofw_pci_register {
95a941ee9aSart 	u_int32_t	phys_hi;
96a941ee9aSart 	u_int32_t	phys_mid;
97a941ee9aSart 	u_int32_t	phys_lo;
98a941ee9aSart 	u_int32_t	size_hi;
99a941ee9aSart 	u_int32_t	size_lo;
100a941ee9aSart };
101a941ee9aSart 
102a941ee9aSart #endif /* _DEV_OFW_OFW_PCI_H_ */
103