mirror of
https://github.com/opnsense/src.git
synced 2026-04-15 14:29:58 -04:00
[bhnd] Add support for querying the attachment type of the bhnd bus.
This adds a BHND_BUS_GET_ATTACH_TYPE(); the primary use-case is to let chipc make a coarse-grained determination as to whether UART, SPI, etc drivers ought to be attached, and on fullmac devices, whether a real CPU driver ought to be skipped for the ARM core, etc. Tested: * BCM4331 (BHND) * BCM4312 (SIBA) Submitted by: Landon Fuller <landonf@landonf.org> Differential Revision: https://reviews.freebsd.org/D6492
This commit is contained in:
parent
aa87465313
commit
9d292ea16d
10 changed files with 137 additions and 38 deletions
|
|
@ -1125,6 +1125,7 @@ dev/bge/if_bge.c optional bge
|
|||
dev/bhnd/bhnd.c optional bhndbus | bhnd
|
||||
dev/bhnd/bhnd_subr.c optional bhndbus | bhnd
|
||||
dev/bhnd/bhnd_bus_if.m optional bhndbus | bhnd
|
||||
dev/bhnd/bhndb/bhnd_bhndb.c optional bhndbus | bhndb
|
||||
dev/bhnd/bhndb/bhndb.c optional bhndbus | bhndb
|
||||
dev/bhnd/bhndb/bhndb_bus_if.m optional bhndbus | bhndb
|
||||
dev/bhnd/bhndb/bhndb_hwdata.c optional bhndbus | bhndb
|
||||
|
|
|
|||
|
|
@ -166,20 +166,6 @@ bcma_bhndb_resume_child(device_t dev, device_t child)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
bcma_bhndb_read_board_info(device_t dev, device_t child,
|
||||
struct bhnd_board_info *info)
|
||||
{
|
||||
int error;
|
||||
|
||||
/* Initialize with NVRAM-derived values */
|
||||
if ((error = bhnd_bus_generic_read_board_info(dev, child, info)))
|
||||
return (error);
|
||||
|
||||
/* Let the bridge fill in any additional data */
|
||||
return (BHNDB_POPULATE_BOARD_INFO(device_get_parent(dev), dev, info));
|
||||
}
|
||||
|
||||
static device_method_t bcma_bhndb_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, bcma_bhndb_probe),
|
||||
|
|
@ -189,14 +175,11 @@ static device_method_t bcma_bhndb_methods[] = {
|
|||
DEVMETHOD(bus_suspend_child, bcma_bhndb_suspend_child),
|
||||
DEVMETHOD(bus_resume_child, bcma_bhndb_resume_child),
|
||||
|
||||
/* BHND interface */
|
||||
DEVMETHOD(bhnd_bus_read_board_info, bcma_bhndb_read_board_info),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(bhnd, bcma_bhndb_driver, bcma_bhndb_methods,
|
||||
sizeof(struct bcma_softc), bcma_driver);
|
||||
DEFINE_CLASS_2(bhnd, bcma_bhndb_driver, bcma_bhndb_methods,
|
||||
sizeof(struct bcma_softc), bhnd_bhndb_driver, bcma_driver);
|
||||
|
||||
DRIVER_MODULE(bcma_bhndb, bhndb, bcma_bhndb_driver, bhnd_devclass, NULL, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -560,6 +560,21 @@ bhnd_get_chipid(device_t dev) {
|
|||
return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev));
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the BHND attachment type of the parent bhnd bus.
|
||||
*
|
||||
* @param dev A bhnd bus child device.
|
||||
*
|
||||
* @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter,
|
||||
* such as a WiFi chipset.
|
||||
* @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock,
|
||||
* CPU, etc) to a directly attached native host.
|
||||
*/
|
||||
static inline bhnd_attach_type
|
||||
bhnd_get_attach_type (device_t dev) {
|
||||
return (BHND_BUS_GET_ATTACH_TYPE(device_get_parent(dev), dev));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to read the BHND board identification from the bhnd bus.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ CODE {
|
|||
panic("bhnd_bus_get_chipid unimplemented");
|
||||
}
|
||||
|
||||
static bhnd_attach_type
|
||||
bhnd_bus_null_get_attach_type(device_t dev, device_t child)
|
||||
{
|
||||
panic("bhnd_bus_get_attach_type unimplemented");
|
||||
}
|
||||
|
||||
static int
|
||||
bhnd_bus_null_read_board_info(device_t dev, device_t child,
|
||||
struct bhnd_board_info *info)
|
||||
|
|
@ -183,6 +189,22 @@ METHOD const struct bhnd_chipid * get_chipid {
|
|||
device_t child;
|
||||
} DEFAULT bhnd_bus_null_get_chipid;
|
||||
|
||||
/**
|
||||
* Return the BHND attachment type of the parent bus.
|
||||
*
|
||||
* @param dev The device whose child is being examined.
|
||||
* @param child The child device.
|
||||
*
|
||||
* @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter,
|
||||
* such as a WiFi chipset.
|
||||
* @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock,
|
||||
* CPU, etc) to a directly attached native host.
|
||||
*/
|
||||
METHOD bhnd_attach_type get_attach_type {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
} DEFAULT bhnd_bus_null_get_attach_type;
|
||||
|
||||
/**
|
||||
* Attempt to read the BHND board identification from the parent bus.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -73,6 +73,15 @@ typedef enum {
|
|||
BHND_PORT_AGENT = 2, /**< interconnect agent/wrapper */
|
||||
} bhnd_port_type;
|
||||
|
||||
/**
|
||||
* bhnd(4) attachment types.
|
||||
*/
|
||||
typedef enum {
|
||||
BHND_ATTACH_ADAPTER = 0, /**< A bridged card, such as a PCI WiFi chipset */
|
||||
BHND_ATTACH_NATIVE = 1 /**< A bus resident on the native host, such as
|
||||
* the primary or secondary bus of an embedded
|
||||
* SoC */
|
||||
} bhnd_attach_type;
|
||||
|
||||
/** Evaluates to true if @p cls is a device class that can be configured
|
||||
* as a host bridge device. */
|
||||
|
|
|
|||
77
sys/dev/bhnd/bhndb/bhnd_bhndb.c
Normal file
77
sys/dev/bhnd/bhndb/bhnd_bhndb.c
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*-
|
||||
* Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include <dev/bhnd/bhnd_ids.h>
|
||||
#include <dev/bhnd/bhnd.h>
|
||||
|
||||
#include "bhndbvar.h"
|
||||
|
||||
/*
|
||||
* bhnd(4) driver mix-in providing a shared common methods for
|
||||
* bhnd devices attached via a bhndb bridge.
|
||||
*/
|
||||
|
||||
static int
|
||||
bhnd_bhndb_read_board_info(device_t dev, device_t child,
|
||||
struct bhnd_board_info *info)
|
||||
{
|
||||
int error;
|
||||
|
||||
/* Initialize with NVRAM-derived values */
|
||||
if ((error = bhnd_bus_generic_read_board_info(dev, child, info)))
|
||||
return (error);
|
||||
|
||||
/* Let the bridge fill in any additional data */
|
||||
return (BHNDB_POPULATE_BOARD_INFO(device_get_parent(dev), dev, info));
|
||||
}
|
||||
|
||||
static bhnd_attach_type
|
||||
bhnd_bhndb_get_attach_type(device_t dev, device_t child)
|
||||
{
|
||||
/* It's safe to assume that a bridged device is always an adapter */
|
||||
return (BHND_ATTACH_ADAPTER);
|
||||
}
|
||||
|
||||
static device_method_t bhnd_bhndb_methods[] = {
|
||||
/* BHND interface */
|
||||
DEVMETHOD(bhnd_bus_get_attach_type, bhnd_bhndb_get_attach_type),
|
||||
DEVMETHOD(bhnd_bus_read_board_info, bhnd_bhndb_read_board_info),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_0(bhnd, bhnd_bhndb_driver, bhnd_bhndb_methods, 0);
|
||||
|
|
@ -44,6 +44,7 @@
|
|||
#include "bhndb_bus_if.h"
|
||||
|
||||
extern devclass_t bhndb_devclass;
|
||||
DECLARE_CLASS(bhnd_bhndb_driver);
|
||||
|
||||
int bhndb_attach_bridge(device_t parent, device_t *bhndb, int unit);
|
||||
|
||||
|
|
|
|||
|
|
@ -205,20 +205,6 @@ siba_bhndb_resume_child(device_t dev, device_t child)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
siba_bhndb_read_board_info(device_t dev, device_t child,
|
||||
struct bhnd_board_info *info)
|
||||
{
|
||||
int error;
|
||||
|
||||
/* Initialize with NVRAM-derived values */
|
||||
if ((error = bhnd_bus_generic_read_board_info(dev, child, info)))
|
||||
return (error);
|
||||
|
||||
/* Let the bridge fill in any additional data */
|
||||
return (BHNDB_POPULATE_BOARD_INFO(device_get_parent(dev), dev, info));
|
||||
}
|
||||
|
||||
/* Work-around implementation for SIBA_QUIRK_PCIE_D11_SB_TIMEOUT */
|
||||
static int
|
||||
siba_bhndb_wars_pcie_clear_d11_timeout(struct siba_softc *sc)
|
||||
|
|
@ -285,14 +271,11 @@ static device_method_t siba_bhndb_methods[] = {
|
|||
DEVMETHOD(bus_suspend_child, siba_bhndb_suspend_child),
|
||||
DEVMETHOD(bus_resume_child, siba_bhndb_resume_child),
|
||||
|
||||
/* BHND interface */
|
||||
DEVMETHOD(bhnd_bus_read_board_info, siba_bhndb_read_board_info),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(bhnd, siba_bhndb_driver, siba_bhndb_methods,
|
||||
sizeof(struct siba_softc), siba_driver);
|
||||
DEFINE_CLASS_2(bhnd, siba_bhndb_driver, siba_bhndb_methods,
|
||||
sizeof(struct siba_softc), bhnd_bhndb_driver, siba_driver);
|
||||
|
||||
DRIVER_MODULE(siba_bhndb, bhndb, siba_bhndb_driver, bhnd_devclass, NULL, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,12 @@ bhnd_soc_is_hw_disabled(device_t dev, device_t child)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
bhnd_soc_get_attach_type(device_t dev, device_t child)
|
||||
{
|
||||
return (BHND_ATTACH_NATIVE);
|
||||
}
|
||||
|
||||
/*
|
||||
* **************************** DRIVER METADATA ****************************
|
||||
*/
|
||||
|
|
@ -247,6 +253,7 @@ static device_method_t bhnd_soc_methods[] = {
|
|||
DEVMETHOD(bhnd_bus_activate_resource, bhnd_soc_activate_resource),
|
||||
DEVMETHOD(bhnd_bus_is_hw_disabled, bhnd_soc_is_hw_disabled),
|
||||
DEVMETHOD(bhnd_bus_get_chipid, bhnd_soc_get_chipid),
|
||||
DEVMETHOD(bhnd_bus_get_attach_type, bhnd_soc_get_attach_type),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
KMOD= bhndb
|
||||
SRCS= bhndb.c bhndb_subr.c bhndb_hwdata.c \
|
||||
bhnd_bhndb.c \
|
||||
bhndb_bus_if.c bhndb_bus_if.h \
|
||||
bhndb_if.c bhndb_if.h
|
||||
SRCS+= bhnd_bus_if.h \
|
||||
|
|
|
|||
Loading…
Reference in a new issue