xref: /freebsd/sys/dev/bhnd/bhndb/bhndb_bus_if.m (revision 15c433351f54e7cd5bec8d36c8e89e6a7fa55b26)
1#-
2# Copyright (c) 2015 Landon Fuller <landon@landonf.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 bool
64	bhndb_null_is_core_disabled(device_t dev, device_t child,
65	    struct bhnd_core_info *core)
66	{
67		return (true);
68	}
69}
70
71/**
72 * Return a generic hardware configuration to be used by
73 * the bhndb bridge device to enumerate attached devices.
74 *
75 * @param dev The parent device.
76 * @param child The attached bhndb device.
77 *
78 * @retval bhndb_hwcfg The configuration to use for bus enumeration.
79 */
80METHOD const struct bhndb_hwcfg * get_generic_hwcfg {
81	device_t dev;
82	device_t child;
83} DEFAULT bhndb_null_get_generic_hwcfg;
84
85/**
86 * Provide chip identification information to be used by a @p child during
87 * device enumeration.
88 *
89 * May return NULL if the device includes a ChipCommon core.
90 *
91 * @param dev The parent device.
92 * @param child The attached bhndb device.
93 */
94METHOD const struct bhnd_chipid * get_chipid {
95	device_t dev;
96	device_t child;
97} DEFAULT bhndb_null_get_chipid;
98
99/**
100 * Return the hardware specification table to be used when identifying the
101 * bridge's full hardware configuration.
102 *
103 * @param dev The parent device.
104 * @param child The attached bhndb device.
105 */
106METHOD const struct bhndb_hw * get_hardware_table {
107	device_t dev;
108	device_t child;
109} DEFAULT bhndb_null_get_hardware_table;
110
111/**
112 * Return true if the hardware required by @p core is unpopulated or
113 * otherwise unusable.
114 *
115 * In some cases, the core's pins may be left floating, or the hardware
116 * may otherwise be non-functional; this method allows the parent device
117 * to explicitly specify whether @p core should be disabled.
118 *
119 * @param dev The parent device.
120 * @param child The attached bhndb device.
121 * @param core A core discovered on @p child.
122 */
123METHOD bool is_core_disabled {
124	device_t dev;
125	device_t child;
126	struct bhnd_core_info *core;
127} DEFAULT bhndb_null_is_core_disabled;
128