xref: /freebsd/sys/dev/bhnd/bhndb/bhndb_bus_if.m (revision 61e21613)
1#-
2# Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24#
25
26#include <sys/types.h>
27#include <sys/bus.h>
28
29#
30# Parent bus interface required by attached bhndb bridge devices.
31#
32
33INTERFACE bhndb_bus;
34
35HEADER {
36	struct bhnd_core_info;
37	struct bhndb_hwcfg;
38	struct bhndb_hw;
39};
40
41CODE {
42	#include <sys/systm.h>
43
44	static const struct bhnd_chipid *
45	bhndb_null_get_chipid(device_t dev, device_t child)
46	{
47		return (NULL);
48	}
49
50	static const struct bhndb_hwcfg *
51	bhndb_null_get_generic_hwcfg(device_t dev, device_t child)
52	{
53		panic("bhndb_get_generic_hwcfg unimplemented");
54	}
55
56	static const struct bhndb_hw *
57	bhndb_null_get_hardware_table(device_t dev, device_t child)
58	{
59		panic("bhndb_get_hardware_table unimplemented");
60	}
61
62	static const struct bhndb_hw_priority *
63	bhndb_null_get_hardware_prio(device_t dev, device_t child)
64	{
65		panic("bhndb_get_hardware_prio unimplemented");
66	}
67
68	static bool
69	bhndb_null_is_core_disabled(device_t dev, device_t child,
70	    struct bhnd_core_info *core)
71	{
72		return (true);
73	}
74}
75
76/**
77 * Return a generic hardware configuration to be used by
78 * the bhndb bridge device to enumerate attached devices.
79 *
80 * @param dev The parent device.
81 * @param child The attached bhndb device.
82 *
83 * @retval bhndb_hwcfg The configuration to use for bus enumeration.
84 */
85METHOD const struct bhndb_hwcfg * get_generic_hwcfg {
86	device_t dev;
87	device_t child;
88} DEFAULT bhndb_null_get_generic_hwcfg;
89
90/**
91 * Provide chip identification information to be used by a @p child during
92 * device enumeration.
93 *
94 * May return NULL if the device includes a ChipCommon core.
95 *
96 * @param dev The parent device.
97 * @param child The attached bhndb device.
98 */
99METHOD const struct bhnd_chipid * get_chipid {
100	device_t dev;
101	device_t child;
102} DEFAULT bhndb_null_get_chipid;
103
104/**
105 * Return the hardware specification table to be used when identifying the
106 * bridge's full hardware configuration.
107 *
108 * @param dev The parent device.
109 * @param child The attached bhndb device.
110 */
111METHOD const struct bhndb_hw * get_hardware_table {
112	device_t dev;
113	device_t child;
114} DEFAULT bhndb_null_get_hardware_table;
115
116/**
117 * Return the hardware priority table to be used when allocating bridge
118 * resources.
119 *
120 * @param dev The parent device.
121 * @param child The attached bhndb device.
122 */
123METHOD const struct bhndb_hw_priority * get_hardware_prio {
124	device_t dev;
125	device_t child;
126} DEFAULT bhndb_null_get_hardware_prio;
127
128/**
129 * Return true if the hardware required by @p core is unpopulated or
130 * otherwise unusable.
131 *
132 * In some cases, the core's pins may be left floating, or the hardware
133 * may otherwise be non-functional; this method allows the parent device
134 * to explicitly specify whether @p core should be disabled.
135 *
136 * @param dev The parent device.
137 * @param child The attached bhndb device.
138 * @param core A core discovered on @p child.
139 */
140METHOD bool is_core_disabled {
141	device_t dev;
142	device_t child;
143	struct bhnd_core_info *core;
144} DEFAULT bhndb_null_is_core_disabled;
145