ofw_bus_if.m revision 139749
1139749Simp#-
2133589Smarius# Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
3133589Smarius# Copyright (c) 2004 by Marius Strobl <marius@FreeBSD.org>
4133589Smarius# All rights reserved.
5133589Smarius#
6133589Smarius# Redistribution and use in source and binary forms, with or without
7133589Smarius# modification, are permitted provided that the following conditions
8133589Smarius# are met:
9133589Smarius# 1. Redistributions of source code must retain the above copyright
10133589Smarius#    notice, this list of conditions and the following disclaimer.
11133589Smarius# 2. Redistributions in binary form must reproduce the above copyright
12133589Smarius#    notice, this list of conditions and the following disclaimer in the
13133589Smarius#    documentation and/or other materials provided with the distribution.
14133589Smarius#
15133589Smarius# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16133589Smarius# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17133589Smarius# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18133589Smarius# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19133589Smarius# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20133589Smarius# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21133589Smarius# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22133589Smarius# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23133589Smarius# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
24133589Smarius# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25133589Smarius#
26133589Smarius# $FreeBSD: head/sys/dev/ofw/ofw_bus_if.m 139749 2005-01-06 01:43:34Z imp $
27133589Smarius
28133589Smarius#include <sys/bus.h>
29133589Smarius#include <machine/bus.h>
30133589Smarius
31133589Smarius#include <dev/ofw/openfirm.h>
32133589Smarius
33133589SmariusINTERFACE ofw_bus;
34133589Smarius
35133589SmariusCODE {
36133589Smarius	static ofw_bus_get_compat_t ofw_bus_default_get_compat;
37133589Smarius	static ofw_bus_get_model_t ofw_bus_default_get_model;
38133589Smarius	static ofw_bus_get_name_t ofw_bus_default_get_name;
39133589Smarius	static ofw_bus_get_node_t ofw_bus_default_get_node;
40133589Smarius	static ofw_bus_get_type_t ofw_bus_default_get_type;
41133589Smarius
42133589Smarius	static const char *
43133589Smarius	ofw_bus_default_get_compat(device_t bus, device_t dev)
44133589Smarius	{
45133589Smarius
46133589Smarius		return (NULL);
47133589Smarius	}
48133589Smarius
49133589Smarius	static const char *
50133589Smarius	ofw_bus_default_get_model(device_t bus, device_t dev)
51133589Smarius	{
52133589Smarius
53133589Smarius		return (NULL);
54133589Smarius	}
55133589Smarius
56133589Smarius	static const char *
57133589Smarius	ofw_bus_default_get_name(device_t bus, device_t dev)
58133589Smarius	{
59133589Smarius
60133589Smarius		return (NULL);
61133589Smarius	}
62133589Smarius
63133589Smarius	static phandle_t
64133589Smarius	ofw_bus_default_get_node(device_t bus, device_t dev)
65133589Smarius	{
66133589Smarius
67133589Smarius		return (0);
68133589Smarius	}
69133589Smarius
70133589Smarius	static const char *
71133589Smarius	ofw_bus_default_get_type(device_t bus, device_t dev)
72133589Smarius	{
73133589Smarius
74133589Smarius		return (NULL);
75133589Smarius	}
76133589Smarius};
77133589Smarius
78133589Smarius# Get the alternate firmware name for the device dev on the bus. The default
79133589Smarius# method will return NULL, which means the device doesn't have such a property.
80133589SmariusMETHOD const char * get_compat {
81133589Smarius	device_t bus;
82133589Smarius	device_t dev;
83133589Smarius} DEFAULT ofw_bus_default_get_compat;
84133589Smarius
85133589Smarius# Get the firmware model name for the device dev on the bus. The default method
86133589Smarius# will return NULL, which means the device doesn't have such a property.
87133589SmariusMETHOD const char * get_model {
88133589Smarius	device_t bus;
89133589Smarius	device_t dev;
90133589Smarius} DEFAULT ofw_bus_default_get_model;
91133589Smarius
92133589Smarius# Get the firmware name for the device dev on the bus. The default method will
93133589Smarius# return NULL, which means the device doesn't have such a property.
94133589SmariusMETHOD const char * get_name {
95133589Smarius	device_t bus;
96133589Smarius	device_t dev;
97133589Smarius} DEFAULT ofw_bus_default_get_name;
98133589Smarius
99133589Smarius# Get the firmware node for the device dev on the bus. The default method will
100133589Smarius# return 0, which signals that there is no such node.
101133589SmariusMETHOD phandle_t get_node {
102133589Smarius	device_t bus;
103133589Smarius	device_t dev;
104133589Smarius} DEFAULT ofw_bus_default_get_node;
105133589Smarius
106133589Smarius# Get the firmware device type for the device dev on the bus. The default
107133589Smarius# method will return NULL, which means the device doesn't have such a property.
108133589SmariusMETHOD const char * get_type {
109133589Smarius	device_t bus;
110133589Smarius	device_t dev;
111133589Smarius} DEFAULT ofw_bus_default_get_type;
112