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