xref: /freebsd/sys/dev/bhnd/bhndb/bhndb_bus_if.m (revision 5dae51da3da0cc94d17bd67b308fad304ebec7e0)
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# $FreeBSD$
26
27#include <sys/types.h>
28#include <sys/bus.h>
29
30#
31# Parent bus interface required by attached bhndb bridge devices.
32#
33
34INTERFACE bhndb_bus;
35
36HEADER {
37	struct bhnd_core_info;
38	struct bhndb_hwcfg;
39	struct bhndb_hw;
40};
41
42CODE {
43	#include <sys/systm.h>
44
45	static const struct bhnd_chipid *
46	bhndb_null_get_chipid(device_t dev, device_t child)
47	{
48		return (NULL);
49	}
50
51	static const struct bhndb_hwcfg *
52	bhndb_null_get_generic_hwcfg(device_t dev, device_t child)
53	{
54		panic("bhndb_get_generic_hwcfg unimplemented");
55	}
56
57	static const struct bhndb_hw *
58	bhndb_null_get_hardware_table(device_t dev, device_t child)
59	{
60		panic("bhndb_get_hardware_table unimplemented");
61	}
62
63	static const struct bhndb_hw_priority *
64	bhndb_null_get_hardware_prio(device_t dev, device_t child)
65	{
66		panic("bhndb_get_hardware_prio unimplemented");
67	}
68
69	static bool
70	bhndb_null_is_core_disabled(device_t dev, device_t child,
71	    struct bhnd_core_info *core)
72	{
73		return (true);
74	}
75}
76
77/**
78 * Return a generic hardware configuration to be used by
79 * the bhndb bridge device to enumerate attached devices.
80 *
81 * @param dev The parent device.
82 * @param child The attached bhndb device.
83 *
84 * @retval bhndb_hwcfg The configuration to use for bus enumeration.
85 */
86METHOD const struct bhndb_hwcfg * get_generic_hwcfg {
87	device_t dev;
88	device_t child;
89} DEFAULT bhndb_null_get_generic_hwcfg;
90
91/**
92 * Provide chip identification information to be used by a @p child during
93 * device enumeration.
94 *
95 * May return NULL if the device includes a ChipCommon core.
96 *
97 * @param dev The parent device.
98 * @param child The attached bhndb device.
99 */
100METHOD const struct bhnd_chipid * get_chipid {
101	device_t dev;
102	device_t child;
103} DEFAULT bhndb_null_get_chipid;
104
105/**
106 * Return the hardware specification table to be used when identifying the
107 * bridge's full hardware configuration.
108 *
109 * @param dev The parent device.
110 * @param child The attached bhndb device.
111 */
112METHOD const struct bhndb_hw * get_hardware_table {
113	device_t dev;
114	device_t child;
115} DEFAULT bhndb_null_get_hardware_table;
116
117/**
118 * Return the hardware priority table to be used when allocating bridge
119 * resources.
120 *
121 * @param dev The parent device.
122 * @param child The attached bhndb device.
123 */
124METHOD const struct bhndb_hw_priority * get_hardware_prio {
125	device_t dev;
126	device_t child;
127} DEFAULT bhndb_null_get_hardware_prio;
128
129/**
130 * Return true if the hardware required by @p core is unpopulated or
131 * otherwise unusable.
132 *
133 * In some cases, the core's pins may be left floating, or the hardware
134 * may otherwise be non-functional; this method allows the parent device
135 * to explicitly specify whether @p core should be disabled.
136 *
137 * @param dev The parent device.
138 * @param child The attached bhndb device.
139 * @param core A core discovered on @p child.
140 */
141METHOD bool is_core_disabled {
142	device_t dev;
143	device_t child;
144	struct bhnd_core_info *core;
145} DEFAULT bhndb_null_is_core_disabled;
146