ofw_pci.h revision 141752
1276789Sdim/*-
2276789Sdim * Copyright (c) 1999 The NetBSD Foundation, Inc.
3276789Sdim * All rights reserved.
4276789Sdim *
5276789Sdim * This code is derived from software contributed to The NetBSD Foundation
6276789Sdim * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
7276789Sdim * NASA Ames Research Center.
8276789Sdim *
9276789Sdim * Redistribution and use in source and binary forms, with or without
10276789Sdim * modification, are permitted provided that the following conditions
11276789Sdim * are met:
12276789Sdim * 1. Redistributions of source code must retain the above copyright
13276789Sdim *    notice, this list of conditions and the following disclaimer.
14276789Sdim * 2. Redistributions in binary form must reproduce the above copyright
15276789Sdim *    notice, this list of conditions and the following disclaimer in the
16276789Sdim *    documentation and/or other materials provided with the distribution.
17276789Sdim * 3. All advertising materials mentioning features or use of this software
18276789Sdim *    must display the following acknowledgement:
19276789Sdim *	This product includes software developed by the NetBSD
20276789Sdim *	Foundation, Inc. and its contributors.
21276789Sdim * 4. Neither the name of The NetBSD Foundation nor the names of its
22276789Sdim *    contributors may be used to endorse or promote products derived
23276789Sdim *    from this software without specific prior written permission.
24276789Sdim *
25276789Sdim * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26276789Sdim * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27276789Sdim * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28276789Sdim * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29276789Sdim * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30276789Sdim * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31276789Sdim * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32276789Sdim * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33276789Sdim * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34276789Sdim * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35276789Sdim * POSSIBILITY OF SUCH DAMAGE.
36276789Sdim *
37276789Sdim *	from: NetBSD: ofw_pci.h,v 1.5 2003/10/22 09:04:39 mjl Exp
38276789Sdim *
39276789Sdim * $FreeBSD: head/sys/dev/ofw/ofw_pci.h 141752 2005-02-12 19:12:17Z marius $
40276789Sdim */
41276789Sdim
42276789Sdim#ifndef _DEV_OFW_OFW_PCI_H_
43276789Sdim#define	_DEV_OFW_OFW_PCI_H_
44276789Sdim
45276789Sdim/*
46 * PCI Bus Binding to:
47 *
48 * IEEE Std 1275-1994
49 * Standard for Boot (Initialization Configuration) Firmware
50 *
51 * Revision 2.1
52 */
53
54/*
55 * Section 2.2.1. Physical Address Formats
56 *
57 * A PCI physical address is represented by 3 address cells:
58 *
59 *	phys.hi cell:	npt000ss bbbbbbbb dddddfff rrrrrrrr
60 *	phys.mid cell:	hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
61 *	phys.lo cell:	llllllll llllllll llllllll llllllll
62 *
63 *	n	nonrelocatable
64 *	p	prefetchable
65 *	t	aliased below 1MB (memory) or 64k (i/o)
66 *	ss	space code
67 *	b	bus number
68 *	d	device number
69 *	f	function number
70 *	r	register number
71 *	h	high 32-bits of PCI address
72 *	l	low 32-bits of PCI address
73 */
74
75#define	OFW_PCI_PHYS_HI_NONRELOCATABLE	0x80000000
76#define	OFW_PCI_PHYS_HI_PREFETCHABLE	0x40000000
77#define	OFW_PCI_PHYS_HI_ALIASED		0x20000000
78#define	OFW_PCI_PHYS_HI_SPACEMASK	0x03000000
79#define	OFW_PCI_PHYS_HI_BUSMASK		0x00ff0000
80#define	OFW_PCI_PHYS_HI_BUSSHIFT	16
81#define	OFW_PCI_PHYS_HI_DEVICEMASK	0x0000f800
82#define	OFW_PCI_PHYS_HI_DEVICESHIFT	11
83#define	OFW_PCI_PHYS_HI_FUNCTIONMASK	0x00000700
84#define	OFW_PCI_PHYS_HI_FUNCTIONSHIFT	8
85#define	OFW_PCI_PHYS_HI_REGISTERMASK	0x000000ff
86
87#define	OFW_PCI_PHYS_HI_SPACE_CONFIG	0x00000000
88#define	OFW_PCI_PHYS_HI_SPACE_IO	0x01000000
89#define	OFW_PCI_PHYS_HI_SPACE_MEM32	0x02000000
90#define	OFW_PCI_PHYS_HI_SPACE_MEM64	0x03000000
91
92#define OFW_PCI_PHYS_HI_BUS(hi) \
93	(((hi) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT)
94#define OFW_PCI_PHYS_HI_DEVICE(hi) \
95	(((hi) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT)
96#define OFW_PCI_PHYS_HI_FUNCTION(hi) \
97	(((hi) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT)
98
99/*
100 * This has the 3 32bit cell values, plus 2 more to make up a 64-bit size.
101 */
102struct ofw_pci_register {
103	u_int32_t	phys_hi;
104	u_int32_t	phys_mid;
105	u_int32_t	phys_lo;
106	u_int32_t	size_hi;
107	u_int32_t	size_lo;
108};
109
110#endif /* _DEV_OFW_OFW_PCI_H_ */
111