ofw_pci_if.m revision 170930
1139825Simp#-
2117119Stmm# Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
386234Stmm# All rights reserved.
486234Stmm#
586234Stmm# Redistribution and use in source and binary forms, with or without
686234Stmm# modification, are permitted provided that the following conditions
786234Stmm# are met:
886234Stmm# 1. Redistributions of source code must retain the above copyright
986234Stmm#    notice, this list of conditions and the following disclaimer.
1086234Stmm# 2. Redistributions in binary form must reproduce the above copyright
1186234Stmm#    notice, this list of conditions and the following disclaimer in the
1286234Stmm#    documentation and/or other materials provided with the distribution.
1386234Stmm#
1486234Stmm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1586234Stmm# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1686234Stmm# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1786234Stmm# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
1886234Stmm# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1986234Stmm# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2086234Stmm# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2186234Stmm# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2286234Stmm# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2386234Stmm# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2486234Stmm#
2586234Stmm# $FreeBSD: head/sys/sparc64/pci/ofw_pci_if.m 170930 2007-06-18 21:49:42Z marius $
2686234Stmm
2786234Stmm#include <sys/bus.h>
2886234Stmm
29115417Stmm#include <dev/ofw/openfirm.h>
30115417Stmm
31117119Stmm#include <sparc64/pci/ofw_pci.h>
3286234Stmm
33117119StmmINTERFACE ofw_pci;
3486234Stmm
3586234StmmCODE {
36117119Stmm	static ofw_pci_intr_pending_t ofw_pci_default_intr_pending;
37170930Smarius	static ofw_pci_alloc_busno_t ofw_pci_default_alloc_busno;
38117119Stmm	static ofw_pci_adjust_busrange_t ofw_pci_default_adjust_busrange;
39117119Stmm
4086234Stmm	static int
41117119Stmm	ofw_pci_default_intr_pending(device_t dev, ofw_pci_intr_t intr)
4286234Stmm	{
4386234Stmm
44170930Smarius		if (device_get_parent(dev) != NULL)
45170930Smarius			return (OFW_PCI_INTR_PENDING(device_get_parent(dev),
46170930Smarius			    intr));
47170930Smarius		return (0);
4886234Stmm	}
4986234Stmm
50170930Smarius	static int
51170930Smarius	ofw_pci_default_alloc_busno(device_t dev)
52170930Smarius	{
53170930Smarius
54170930Smarius		if (device_get_parent(dev) != NULL)
55170930Smarius			return (OFW_PCI_ALLOC_BUSNO(device_get_parent(dev)));
56170930Smarius		return (-1);
57170930Smarius	}
58170930Smarius
59117119Stmm	static void
60117119Stmm	ofw_pci_default_adjust_busrange(device_t dev, u_int busno)
61117119Stmm	{
62117119Stmm
63170930Smarius		if (device_get_parent(dev) != NULL)
64170930Smarius			return (OFW_PCI_ADJUST_BUSRANGE(device_get_parent(dev),
65170930Smarius			    busno));
66117119Stmm	}
6786234Stmm};
6886234Stmm
6986234Stmm# Return whether an interrupt request is pending for the INO intr.
7086234StmmMETHOD int intr_pending {
7186234Stmm	device_t dev;
72117119Stmm	ofw_pci_intr_t intr;
73117119Stmm} DEFAULT ofw_pci_default_intr_pending;
7486234Stmm
75170930Smarius# Allocate a bus number for reenumerating a PCI bus. A return value of -1
76170930Smarius# means that reenumeration is generally not supported, otherwise all PCI
77170930Smarius# busses must be reenumerated using bus numbers obtained via this method.
78170930SmariusMETHOD int alloc_busno {
79170930Smarius	device_t dev;
80170930Smarius} DEFAULT ofw_pci_default_alloc_busno;
81170930Smarius
82170930Smarius# Make sure that all PCI bridges up in the hierarchy contain this bus in
83170930Smarius# their subordinate bus range. This is required when reenumerating the PCI
84117119Stmm# buses.
85117119StmmMETHOD void adjust_busrange {
86117119Stmm	device_t dev;
87117119Stmm	u_int subbus;
88117119Stmm} DEFAULT ofw_pci_default_adjust_busrange;
89