ofw_pci.h revision 204520
1111823Sgshapiro/*- 290792Sgshapiro * Copyright (c) 1999 The NetBSD Foundation, Inc. 390792Sgshapiro * All rights reserved. 490792Sgshapiro * 590792Sgshapiro * This code is derived from software contributed to The NetBSD Foundation 690792Sgshapiro * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 790792Sgshapiro * NASA Ames Research Center. 8168515Sgshapiro * 990792Sgshapiro * Redistribution and use in source and binary forms, with or without 1090792Sgshapiro * modification, are permitted provided that the following conditions 1190792Sgshapiro * are met: 1290792Sgshapiro * 1. Redistributions of source code must retain the above copyright 1390792Sgshapiro * notice, this list of conditions and the following disclaimer. 1490792Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright 1590792Sgshapiro * notice, this list of conditions and the following disclaimer in the 1690792Sgshapiro * documentation and/or other materials provided with the distribution. 1790792Sgshapiro * 1890792Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1990792Sgshapiro * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2090792Sgshapiro * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2190792Sgshapiro * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2290792Sgshapiro * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2390792Sgshapiro * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2490792Sgshapiro * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2590792Sgshapiro * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2690792Sgshapiro * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2790792Sgshapiro * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2890792Sgshapiro * POSSIBILITY OF SUCH DAMAGE. 2990792Sgshapiro * 3090792Sgshapiro * from: NetBSD: ofw_pci.h,v 1.5 2003/10/22 09:04:39 mjl Exp 3190792Sgshapiro * 3290792Sgshapiro * $FreeBSD: head/sys/dev/ofw/ofw_pci.h 204520 2010-03-01 16:52:11Z joel $ 3390792Sgshapiro */ 3490792Sgshapiro 3590792Sgshapiro#ifndef _DEV_OFW_OFW_PCI_H_ 3690792Sgshapiro#define _DEV_OFW_OFW_PCI_H_ 3790792Sgshapiro 3890792Sgshapiro/* 3990792Sgshapiro * PCI Bus Binding to: 4090792Sgshapiro * 4190792Sgshapiro * IEEE Std 1275-1994 42168515Sgshapiro * Standard for Boot (Initialization Configuration) Firmware 4390792Sgshapiro * 4490792Sgshapiro * Revision 2.1 4590792Sgshapiro */ 4690792Sgshapiro 4790792Sgshapiro/* 4890792Sgshapiro * Section 2.2.1. Physical Address Formats 4990792Sgshapiro * 5090792Sgshapiro * A PCI physical address is represented by 3 address cells: 5190792Sgshapiro * 52168515Sgshapiro * phys.hi cell: npt000ss bbbbbbbb dddddfff rrrrrrrr 5390792Sgshapiro * phys.mid cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh 5490792Sgshapiro * phys.lo cell: llllllll llllllll llllllll llllllll 5590792Sgshapiro * 5690792Sgshapiro * n nonrelocatable 5790792Sgshapiro * p prefetchable 5890792Sgshapiro * t aliased below 1MB (memory) or 64k (i/o) 5990792Sgshapiro * ss space code 6090792Sgshapiro * b bus number 6190792Sgshapiro * d device number 6290792Sgshapiro * f function number 6390792Sgshapiro * r register number 6490792Sgshapiro * h high 32-bits of PCI address 6590792Sgshapiro * l low 32-bits of PCI address 6690792Sgshapiro */ 6790792Sgshapiro 6890792Sgshapiro#define OFW_PCI_PHYS_HI_NONRELOCATABLE 0x80000000 6990792Sgshapiro#define OFW_PCI_PHYS_HI_PREFETCHABLE 0x40000000 7090792Sgshapiro#define OFW_PCI_PHYS_HI_ALIASED 0x20000000 7190792Sgshapiro#define OFW_PCI_PHYS_HI_SPACEMASK 0x03000000 7290792Sgshapiro#define OFW_PCI_PHYS_HI_BUSMASK 0x00ff0000 7390792Sgshapiro#define OFW_PCI_PHYS_HI_BUSSHIFT 16 7490792Sgshapiro#define OFW_PCI_PHYS_HI_DEVICEMASK 0x0000f800 7590792Sgshapiro#define OFW_PCI_PHYS_HI_DEVICESHIFT 11 7690792Sgshapiro#define OFW_PCI_PHYS_HI_FUNCTIONMASK 0x00000700 7790792Sgshapiro#define OFW_PCI_PHYS_HI_FUNCTIONSHIFT 8 7890792Sgshapiro#define OFW_PCI_PHYS_HI_REGISTERMASK 0x000000ff 79168515Sgshapiro 8090792Sgshapiro#define OFW_PCI_PHYS_HI_SPACE_CONFIG 0x00000000 8190792Sgshapiro#define OFW_PCI_PHYS_HI_SPACE_IO 0x01000000 8290792Sgshapiro#define OFW_PCI_PHYS_HI_SPACE_MEM32 0x02000000 8390792Sgshapiro#define OFW_PCI_PHYS_HI_SPACE_MEM64 0x03000000 8490792Sgshapiro 8590792Sgshapiro#define OFW_PCI_PHYS_HI_BUS(hi) \ 8690792Sgshapiro (((hi) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT) 8790792Sgshapiro#define OFW_PCI_PHYS_HI_DEVICE(hi) \ 8890792Sgshapiro (((hi) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT) 8990792Sgshapiro#define OFW_PCI_PHYS_HI_FUNCTION(hi) \ 9090792Sgshapiro (((hi) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT) 9190792Sgshapiro 9290792Sgshapiro/* 9390792Sgshapiro * This has the 3 32bit cell values, plus 2 more to make up a 64-bit size. 9490792Sgshapiro */ 9590792Sgshapirostruct ofw_pci_register { 9690792Sgshapiro u_int32_t phys_hi; 9790792Sgshapiro u_int32_t phys_mid; 98168515Sgshapiro u_int32_t phys_lo; 9990792Sgshapiro u_int32_t size_hi; 10090792Sgshapiro u_int32_t size_lo; 10190792Sgshapiro}; 10290792Sgshapiro 10390792Sgshapiro#endif /* _DEV_OFW_OFW_PCI_H_ */ 10490792Sgshapiro