Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146398594
D6492.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D6492.id.diff
View Options
Index: head/sys/conf/files
===================================================================
--- head/sys/conf/files
+++ head/sys/conf/files
@@ -1125,6 +1125,7 @@
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
Index: head/sys/dev/bhnd/bcma/bcma_bhndb.c
===================================================================
--- head/sys/dev/bhnd/bcma/bcma_bhndb.c
+++ head/sys/dev/bhnd/bcma/bcma_bhndb.c
@@ -166,20 +166,6 @@
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 @@
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);
Index: head/sys/dev/bhnd/bhnd.h
===================================================================
--- head/sys/dev/bhnd/bhnd.h
+++ head/sys/dev/bhnd/bhnd.h
@@ -561,6 +561,21 @@
};
/**
+ * 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.
*
* This relies on NVRAM access, and will fail if a valid NVRAM device cannot
Index: head/sys/dev/bhnd/bhnd_bus_if.m
===================================================================
--- head/sys/dev/bhnd/bhnd_bus_if.m
+++ head/sys/dev/bhnd/bhnd_bus_if.m
@@ -55,6 +55,12 @@
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)
@@ -184,6 +190,22 @@
} 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.
*
* This relies on NVRAM access, and will fail if a valid NVRAM device cannot
Index: head/sys/dev/bhnd/bhnd_types.h
===================================================================
--- head/sys/dev/bhnd/bhnd_types.h
+++ head/sys/dev/bhnd/bhnd_types.h
@@ -73,6 +73,15 @@
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. */
Index: head/sys/dev/bhnd/bhndb/bhnd_bhndb.c
===================================================================
--- head/sys/dev/bhnd/bhndb/bhnd_bhndb.c
+++ head/sys/dev/bhnd/bhndb/bhnd_bhndb.c
@@ -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);
Index: head/sys/dev/bhnd/bhndb/bhndb.h
===================================================================
--- head/sys/dev/bhnd/bhndb/bhndb.h
+++ head/sys/dev/bhnd/bhndb/bhndb.h
@@ -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);
Index: head/sys/dev/bhnd/siba/siba_bhndb.c
===================================================================
--- head/sys/dev/bhnd/siba/siba_bhndb.c
+++ head/sys/dev/bhnd/siba/siba_bhndb.c
@@ -205,20 +205,6 @@
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 @@
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);
Index: head/sys/dev/bhnd/soc/bhnd_soc.c
===================================================================
--- head/sys/dev/bhnd/soc/bhnd_soc.c
+++ head/sys/dev/bhnd/soc/bhnd_soc.c
@@ -216,6 +216,12 @@
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 @@
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
};
Index: head/sys/modules/bhnd/bhndb/Makefile
===================================================================
--- head/sys/modules/bhnd/bhndb/Makefile
+++ head/sys/modules/bhnd/bhndb/Makefile
@@ -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 \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 3, 9:31 AM (14 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29192615
Default Alt Text
D6492.id.diff (10 KB)
Attached To
Mode
D6492: Add support for querying the attachment type of the bhnd bus
Attached
Detach File
Event Timeline
Log In to Comment