ofw_bus_if.m revision 233018
1178173Simp#-
2178173Simp# Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
3178173Simp# Copyright (c) 2004, 2005 by Marius Strobl <marius@FreeBSD.org>
4178173Simp# All rights reserved.
5178173Simp#
6178173Simp# Redistribution and use in source and binary forms, with or without
7178173Simp# modification, are permitted provided that the following conditions
8178173Simp# are met:
9178173Simp# 1. Redistributions of source code must retain the above copyright
10178173Simp#    notice, this list of conditions and the following disclaimer.
11178173Simp# 2. Redistributions in binary form must reproduce the above copyright
12178173Simp#    notice, this list of conditions and the following disclaimer in the
13178173Simp#    documentation and/or other materials provided with the distribution.
14178173Simp#
15178173Simp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16178173Simp# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17178173Simp# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18178173Simp# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19178173Simp# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20178173Simp# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21178173Simp# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22178173Simp# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23178173Simp# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
24178173Simp# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25178173Simp#
26178173Simp# $FreeBSD: head/sys/dev/ofw/ofw_bus_if.m 233018 2012-03-15 22:53:39Z nwhitehorn $
27178173Simp
28178173Simp# Interface for retrieving the package handle and a subset, namely
29178173Simp# 'compatible', 'device_type', 'model' and 'name', of the standard
30178173Simp# properties of a device on an Open Firmware assisted bus for use
31178173Simp# in device drivers. The rest of the standard properties, 'address',
32178173Simp# 'interrupts', 'reg' and 'status', are not covered by this interface
33178173Simp# as they are expected to be only of interest in the respective bus
34178173Simp# driver.
35178173Simp
36178173Simp#include <sys/bus.h>
37178173Simp
38178173Simp#include <dev/ofw/openfirm.h>
39178173Simp
40178173SimpINTERFACE ofw_bus;
41178173Simp
42178173SimpHEADER {
43178173Simp	struct ofw_bus_devinfo {
44178173Simp		phandle_t	obd_node;
45178173Simp		char		*obd_compat;
46178173Simp		char		*obd_model;
47178173Simp		char		*obd_name;
48178173Simp		char		*obd_type;
49178173Simp	};
50178173Simp};
51178173Simp
52178173SimpCODE {
53178173Simp	static ofw_bus_get_devinfo_t ofw_bus_default_get_devinfo;
54178173Simp	static ofw_bus_get_compat_t ofw_bus_default_get_compat;
55178173Simp	static ofw_bus_get_model_t ofw_bus_default_get_model;
56178173Simp	static ofw_bus_get_name_t ofw_bus_default_get_name;
57178173Simp	static ofw_bus_get_node_t ofw_bus_default_get_node;
58178173Simp	static ofw_bus_get_type_t ofw_bus_default_get_type;
59178173Simp
60178173Simp	static const struct ofw_bus_devinfo *
61178173Simp	ofw_bus_default_get_devinfo(device_t bus, device_t dev)
62178173Simp	{
63178173Simp
64178173Simp		return (NULL);
65178173Simp	}
66178173Simp
67178173Simp	static const char *
68	ofw_bus_default_get_compat(device_t bus, device_t dev)
69	{
70
71		return (NULL);
72	}
73
74	static const char *
75	ofw_bus_default_get_model(device_t bus, device_t dev)
76	{
77
78		return (NULL);
79	}
80
81	static const char *
82	ofw_bus_default_get_name(device_t bus, device_t dev)
83	{
84
85		return (NULL);
86	}
87
88	static phandle_t
89	ofw_bus_default_get_node(device_t bus, device_t dev)
90	{
91
92		return (-1);
93	}
94
95	static const char *
96	ofw_bus_default_get_type(device_t bus, device_t dev)
97	{
98
99		return (NULL);
100	}
101};
102
103# Get the ofw_bus_devinfo struct for the device dev on the bus. Used for bus
104# drivers which use the generic methods in ofw_bus_subr.c to implement the
105# reset of this interface. The default method will return NULL, which means
106# there is no such struct associated with the device.
107METHOD const struct ofw_bus_devinfo * get_devinfo {
108	device_t bus;
109	device_t dev;
110} DEFAULT ofw_bus_default_get_devinfo;
111
112# Get the alternate firmware name for the device dev on the bus. The default
113# method will return NULL, which means the device doesn't have such a property.
114METHOD const char * get_compat {
115	device_t bus;
116	device_t dev;
117} DEFAULT ofw_bus_default_get_compat;
118
119# Get the firmware model name for the device dev on the bus. The default method
120# will return NULL, which means the device doesn't have such a property.
121METHOD const char * get_model {
122	device_t bus;
123	device_t dev;
124} DEFAULT ofw_bus_default_get_model;
125
126# Get the firmware name for the device dev on the bus. The default method will
127# return NULL, which means the device doesn't have such a property.
128METHOD const char * get_name {
129	device_t bus;
130	device_t dev;
131} DEFAULT ofw_bus_default_get_name;
132
133# Get the firmware node for the device dev on the bus. The default method will
134# return 0, which signals that there is no such node.
135METHOD phandle_t get_node {
136	device_t bus;
137	device_t dev;
138} DEFAULT ofw_bus_default_get_node;
139
140# Get the firmware device type for the device dev on the bus. The default
141# method will return NULL, which means the device doesn't have such a property.
142METHOD const char * get_type {
143	device_t bus;
144	device_t dev;
145} DEFAULT ofw_bus_default_get_type;
146