xref: /freebsd/sys/dev/bhnd/bhndb/bhndb_bus_if.m (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
14ad7e9b0SAdrian Chadd#-
2*111d7cb2SLandon J. Fuller# Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
34ad7e9b0SAdrian Chadd# All rights reserved.
44ad7e9b0SAdrian Chadd#
54ad7e9b0SAdrian Chadd# Redistribution and use in source and binary forms, with or without
64ad7e9b0SAdrian Chadd# modification, are permitted provided that the following conditions
74ad7e9b0SAdrian Chadd# are met:
84ad7e9b0SAdrian Chadd# 1. Redistributions of source code must retain the above copyright
94ad7e9b0SAdrian Chadd#    notice, this list of conditions and the following disclaimer.
104ad7e9b0SAdrian Chadd# 2. Redistributions in binary form must reproduce the above copyright
114ad7e9b0SAdrian Chadd#    notice, this list of conditions and the following disclaimer in the
124ad7e9b0SAdrian Chadd#    documentation and/or other materials provided with the distribution.
134ad7e9b0SAdrian Chadd#
144ad7e9b0SAdrian Chadd# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
154ad7e9b0SAdrian Chadd# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
164ad7e9b0SAdrian Chadd# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
174ad7e9b0SAdrian Chadd# IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
184ad7e9b0SAdrian Chadd# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
194ad7e9b0SAdrian Chadd# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
204ad7e9b0SAdrian Chadd# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
214ad7e9b0SAdrian Chadd# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
224ad7e9b0SAdrian Chadd# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
234ad7e9b0SAdrian Chadd# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244ad7e9b0SAdrian Chadd#
254ad7e9b0SAdrian Chadd
264ad7e9b0SAdrian Chadd#include <sys/types.h>
274ad7e9b0SAdrian Chadd#include <sys/bus.h>
284ad7e9b0SAdrian Chadd
294ad7e9b0SAdrian Chadd#
304ad7e9b0SAdrian Chadd# Parent bus interface required by attached bhndb bridge devices.
314ad7e9b0SAdrian Chadd#
324ad7e9b0SAdrian Chadd
334ad7e9b0SAdrian ChaddINTERFACE bhndb_bus;
344ad7e9b0SAdrian Chadd
354ad7e9b0SAdrian ChaddHEADER {
364ad7e9b0SAdrian Chadd	struct bhnd_core_info;
374ad7e9b0SAdrian Chadd	struct bhndb_hwcfg;
384ad7e9b0SAdrian Chadd	struct bhndb_hw;
394ad7e9b0SAdrian Chadd};
404ad7e9b0SAdrian Chadd
414ad7e9b0SAdrian ChaddCODE {
424ad7e9b0SAdrian Chadd	#include <sys/systm.h>
434ad7e9b0SAdrian Chadd
444ad7e9b0SAdrian Chadd	static const struct bhnd_chipid *
454ad7e9b0SAdrian Chadd	bhndb_null_get_chipid(device_t dev, device_t child)
464ad7e9b0SAdrian Chadd	{
474ad7e9b0SAdrian Chadd		return (NULL);
484ad7e9b0SAdrian Chadd	}
494ad7e9b0SAdrian Chadd
504ad7e9b0SAdrian Chadd	static const struct bhndb_hwcfg *
514ad7e9b0SAdrian Chadd	bhndb_null_get_generic_hwcfg(device_t dev, device_t child)
524ad7e9b0SAdrian Chadd	{
534ad7e9b0SAdrian Chadd		panic("bhndb_get_generic_hwcfg unimplemented");
544ad7e9b0SAdrian Chadd	}
554ad7e9b0SAdrian Chadd
564ad7e9b0SAdrian Chadd	static const struct bhndb_hw *
574ad7e9b0SAdrian Chadd	bhndb_null_get_hardware_table(device_t dev, device_t child)
584ad7e9b0SAdrian Chadd	{
594ad7e9b0SAdrian Chadd		panic("bhndb_get_hardware_table unimplemented");
604ad7e9b0SAdrian Chadd	}
614ad7e9b0SAdrian Chadd
62*111d7cb2SLandon J. Fuller	static const struct bhndb_hw_priority *
63*111d7cb2SLandon J. Fuller	bhndb_null_get_hardware_prio(device_t dev, device_t child)
64*111d7cb2SLandon J. Fuller	{
65*111d7cb2SLandon J. Fuller		panic("bhndb_get_hardware_prio unimplemented");
66*111d7cb2SLandon J. Fuller	}
67*111d7cb2SLandon J. Fuller
684ad7e9b0SAdrian Chadd	static bool
694ad7e9b0SAdrian Chadd	bhndb_null_is_core_disabled(device_t dev, device_t child,
704ad7e9b0SAdrian Chadd	    struct bhnd_core_info *core)
714ad7e9b0SAdrian Chadd	{
724ad7e9b0SAdrian Chadd		return (true);
734ad7e9b0SAdrian Chadd	}
744ad7e9b0SAdrian Chadd}
754ad7e9b0SAdrian Chadd
764ad7e9b0SAdrian Chadd/**
774ad7e9b0SAdrian Chadd * Return a generic hardware configuration to be used by
784ad7e9b0SAdrian Chadd * the bhndb bridge device to enumerate attached devices.
794ad7e9b0SAdrian Chadd *
804ad7e9b0SAdrian Chadd * @param dev The parent device.
814ad7e9b0SAdrian Chadd * @param child The attached bhndb device.
824ad7e9b0SAdrian Chadd *
834ad7e9b0SAdrian Chadd * @retval bhndb_hwcfg The configuration to use for bus enumeration.
844ad7e9b0SAdrian Chadd */
854ad7e9b0SAdrian ChaddMETHOD const struct bhndb_hwcfg * get_generic_hwcfg {
864ad7e9b0SAdrian Chadd	device_t dev;
874ad7e9b0SAdrian Chadd	device_t child;
884ad7e9b0SAdrian Chadd} DEFAULT bhndb_null_get_generic_hwcfg;
894ad7e9b0SAdrian Chadd
904ad7e9b0SAdrian Chadd/**
914ad7e9b0SAdrian Chadd * Provide chip identification information to be used by a @p child during
924ad7e9b0SAdrian Chadd * device enumeration.
934ad7e9b0SAdrian Chadd *
944ad7e9b0SAdrian Chadd * May return NULL if the device includes a ChipCommon core.
954ad7e9b0SAdrian Chadd *
964ad7e9b0SAdrian Chadd * @param dev The parent device.
974ad7e9b0SAdrian Chadd * @param child The attached bhndb device.
984ad7e9b0SAdrian Chadd */
994ad7e9b0SAdrian ChaddMETHOD const struct bhnd_chipid * get_chipid {
1004ad7e9b0SAdrian Chadd	device_t dev;
1014ad7e9b0SAdrian Chadd	device_t child;
1024ad7e9b0SAdrian Chadd} DEFAULT bhndb_null_get_chipid;
1034ad7e9b0SAdrian Chadd
1044ad7e9b0SAdrian Chadd/**
1054ad7e9b0SAdrian Chadd * Return the hardware specification table to be used when identifying the
1064ad7e9b0SAdrian Chadd * bridge's full hardware configuration.
1074ad7e9b0SAdrian Chadd *
1084ad7e9b0SAdrian Chadd * @param dev The parent device.
1094ad7e9b0SAdrian Chadd * @param child The attached bhndb device.
1104ad7e9b0SAdrian Chadd */
1114ad7e9b0SAdrian ChaddMETHOD const struct bhndb_hw * get_hardware_table {
1124ad7e9b0SAdrian Chadd	device_t dev;
1134ad7e9b0SAdrian Chadd	device_t child;
1144ad7e9b0SAdrian Chadd} DEFAULT bhndb_null_get_hardware_table;
1154ad7e9b0SAdrian Chadd
1164ad7e9b0SAdrian Chadd/**
117*111d7cb2SLandon J. Fuller * Return the hardware priority table to be used when allocating bridge
118*111d7cb2SLandon J. Fuller * resources.
119*111d7cb2SLandon J. Fuller *
120*111d7cb2SLandon J. Fuller * @param dev The parent device.
121*111d7cb2SLandon J. Fuller * @param child The attached bhndb device.
122*111d7cb2SLandon J. Fuller */
123*111d7cb2SLandon J. FullerMETHOD const struct bhndb_hw_priority * get_hardware_prio {
124*111d7cb2SLandon J. Fuller	device_t dev;
125*111d7cb2SLandon J. Fuller	device_t child;
126*111d7cb2SLandon J. Fuller} DEFAULT bhndb_null_get_hardware_prio;
127*111d7cb2SLandon J. Fuller
128*111d7cb2SLandon J. Fuller/**
1294ad7e9b0SAdrian Chadd * Return true if the hardware required by @p core is unpopulated or
1304ad7e9b0SAdrian Chadd * otherwise unusable.
1314ad7e9b0SAdrian Chadd *
1324ad7e9b0SAdrian Chadd * In some cases, the core's pins may be left floating, or the hardware
1334ad7e9b0SAdrian Chadd * may otherwise be non-functional; this method allows the parent device
1344ad7e9b0SAdrian Chadd * to explicitly specify whether @p core should be disabled.
1354ad7e9b0SAdrian Chadd *
1364ad7e9b0SAdrian Chadd * @param dev The parent device.
1374ad7e9b0SAdrian Chadd * @param child The attached bhndb device.
1384ad7e9b0SAdrian Chadd * @param core A core discovered on @p child.
1394ad7e9b0SAdrian Chadd */
1404ad7e9b0SAdrian ChaddMETHOD bool is_core_disabled {
1414ad7e9b0SAdrian Chadd	device_t dev;
1424ad7e9b0SAdrian Chadd	device_t child;
1434ad7e9b0SAdrian Chadd	struct bhnd_core_info *core;
1444ad7e9b0SAdrian Chadd} DEFAULT bhndb_null_is_core_disabled;
145