1398e05abSThomas Moestl /*- 2*b61a5730SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 4398e05abSThomas Moestl * Copyright (c) 1999 The NetBSD Foundation, Inc. 5398e05abSThomas Moestl * All rights reserved. 6398e05abSThomas Moestl * 7398e05abSThomas Moestl * This code is derived from software contributed to The NetBSD Foundation 8398e05abSThomas Moestl * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9398e05abSThomas Moestl * NASA Ames Research Center. 10398e05abSThomas Moestl * 11398e05abSThomas Moestl * Redistribution and use in source and binary forms, with or without 12398e05abSThomas Moestl * modification, are permitted provided that the following conditions 13398e05abSThomas Moestl * are met: 14398e05abSThomas Moestl * 1. Redistributions of source code must retain the above copyright 15398e05abSThomas Moestl * notice, this list of conditions and the following disclaimer. 16398e05abSThomas Moestl * 2. Redistributions in binary form must reproduce the above copyright 17398e05abSThomas Moestl * notice, this list of conditions and the following disclaimer in the 18398e05abSThomas Moestl * documentation and/or other materials provided with the distribution. 19398e05abSThomas Moestl * 20398e05abSThomas Moestl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21398e05abSThomas Moestl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22398e05abSThomas Moestl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23398e05abSThomas Moestl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24398e05abSThomas Moestl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25398e05abSThomas Moestl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26398e05abSThomas Moestl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27398e05abSThomas Moestl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28398e05abSThomas Moestl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29398e05abSThomas Moestl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30398e05abSThomas Moestl * POSSIBILITY OF SUCH DAMAGE. 31398e05abSThomas Moestl * 3261e2f265SMarius Strobl * from: NetBSD: ofw_pci.h,v 1.5 2003/10/22 09:04:39 mjl Exp 33398e05abSThomas Moestl */ 34398e05abSThomas Moestl 35398e05abSThomas Moestl #ifndef _DEV_OFW_OFW_PCI_H_ 36398e05abSThomas Moestl #define _DEV_OFW_OFW_PCI_H_ 37398e05abSThomas Moestl 38398e05abSThomas Moestl /* 39398e05abSThomas Moestl * PCI Bus Binding to: 40398e05abSThomas Moestl * 41398e05abSThomas Moestl * IEEE Std 1275-1994 42398e05abSThomas Moestl * Standard for Boot (Initialization Configuration) Firmware 43398e05abSThomas Moestl * 44398e05abSThomas Moestl * Revision 2.1 45398e05abSThomas Moestl */ 46398e05abSThomas Moestl 47398e05abSThomas Moestl /* 48398e05abSThomas Moestl * Section 2.2.1. Physical Address Formats 49398e05abSThomas Moestl * 50398e05abSThomas Moestl * A PCI physical address is represented by 3 address cells: 51398e05abSThomas Moestl * 52398e05abSThomas Moestl * phys.hi cell: npt000ss bbbbbbbb dddddfff rrrrrrrr 53398e05abSThomas Moestl * phys.mid cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh 54398e05abSThomas Moestl * phys.lo cell: llllllll llllllll llllllll llllllll 55398e05abSThomas Moestl * 56398e05abSThomas Moestl * n nonrelocatable 5761e2f265SMarius Strobl * p prefetchable 58398e05abSThomas Moestl * t aliased below 1MB (memory) or 64k (i/o) 59398e05abSThomas Moestl * ss space code 60398e05abSThomas Moestl * b bus number 61398e05abSThomas Moestl * d device number 62398e05abSThomas Moestl * f function number 63398e05abSThomas Moestl * r register number 64398e05abSThomas Moestl * h high 32-bits of PCI address 65398e05abSThomas Moestl * l low 32-bits of PCI address 66398e05abSThomas Moestl */ 67398e05abSThomas Moestl 68398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_NONRELOCATABLE 0x80000000 69398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_PREFETCHABLE 0x40000000 70398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_ALIASED 0x20000000 71398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_SPACEMASK 0x03000000 72398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_BUSMASK 0x00ff0000 73398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_BUSSHIFT 16 74398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_DEVICEMASK 0x0000f800 75398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_DEVICESHIFT 11 76398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_FUNCTIONMASK 0x00000700 77398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_FUNCTIONSHIFT 8 78398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_REGISTERMASK 0x000000ff 79398e05abSThomas Moestl 80398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_SPACE_CONFIG 0x00000000 81398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_SPACE_IO 0x01000000 82398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_SPACE_MEM32 0x02000000 83398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_SPACE_MEM64 0x03000000 84398e05abSThomas Moestl 85398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_BUS(hi) \ 86398e05abSThomas Moestl (((hi) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT) 87398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_DEVICE(hi) \ 88398e05abSThomas Moestl (((hi) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT) 89398e05abSThomas Moestl #define OFW_PCI_PHYS_HI_FUNCTION(hi) \ 90398e05abSThomas Moestl (((hi) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT) 91398e05abSThomas Moestl 92398e05abSThomas Moestl /* 93398e05abSThomas Moestl * This has the 3 32bit cell values, plus 2 more to make up a 64-bit size. 94398e05abSThomas Moestl */ 95398e05abSThomas Moestl struct ofw_pci_register { 96398e05abSThomas Moestl u_int32_t phys_hi; 97398e05abSThomas Moestl u_int32_t phys_mid; 98398e05abSThomas Moestl u_int32_t phys_lo; 99398e05abSThomas Moestl u_int32_t size_hi; 100398e05abSThomas Moestl u_int32_t size_lo; 101398e05abSThomas Moestl }; 102398e05abSThomas Moestl 103398e05abSThomas Moestl #endif /* _DEV_OFW_OFW_PCI_H_ */ 104