xref: /freebsd-11-stable/sys/dev/bhnd/bhnd_types.h (revision 9d292ea16dbdb9308f88091fcbcffcd73eb9cc76)
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  *    without modification.
11  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13  *    redistribution must be conditioned upon including a substantially
14  *    similar Disclaimer requirement for further binary redistribution.
15  *
16  * NO WARRANTY
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27  * THE POSSIBILITY OF SUCH DAMAGES.
28  *
29  * $FreeBSD$
30  */
31 
32 #ifndef _BHND_BHND_TYPES_H_
33 #define _BHND_BHND_TYPES_H_
34 
35 #include <sys/types.h>
36 
37 /** bhnd(4) device classes. */
38 typedef enum {
39 	BHND_DEVCLASS_CC,		/**< chipcommon i/o controller */
40 	BHND_DEVCLASS_CC_B,		/**< chipcommon auxiliary controller */
41 	BHND_DEVCLASS_PMU,		/**< pmu controller */
42 	BHND_DEVCLASS_PCI,		/**< pci host/device bridge */
43 	BHND_DEVCLASS_PCIE,		/**< pcie host/device bridge */
44 	BHND_DEVCLASS_PCCARD,		/**< pcmcia host/device bridge */
45 	BHND_DEVCLASS_RAM,		/**< internal RAM/SRAM */
46 	BHND_DEVCLASS_MEMC,		/**< memory controller */
47 	BHND_DEVCLASS_ENET,		/**< 802.3 MAC/PHY */
48 	BHND_DEVCLASS_ENET_MAC,		/**< 802.3 MAC */
49 	BHND_DEVCLASS_ENET_PHY,		/**< 802.3 PHY */
50 	BHND_DEVCLASS_WLAN,		/**< 802.11 MAC/PHY/Radio */
51 	BHND_DEVCLASS_WLAN_MAC,		/**< 802.11 MAC */
52 	BHND_DEVCLASS_WLAN_PHY,		/**< 802.11 PHY */
53 	BHND_DEVCLASS_CPU,		/**< cpu core */
54 	BHND_DEVCLASS_SOC_ROUTER,	/**< interconnect router */
55 	BHND_DEVCLASS_SOC_BRIDGE,	/**< interconnect host bridge */
56 	BHND_DEVCLASS_EROM,		/**< bus device enumeration ROM */
57 	BHND_DEVCLASS_NVRAM,		/**< nvram/flash controller */
58 	BHND_DEVCLASS_OTHER,		/**< other / unknown */
59 
60 	BHND_DEVCLASS_INVALID		/**< no/invalid class */
61 } bhnd_devclass_t;
62 
63 
64 /**
65  * bhnd(4) port types.
66  *
67  * Only BHND_PORT_DEVICE is guaranteed to be supported by all bhnd(4) bus
68  * implementations.
69  */
70 typedef enum {
71 	BHND_PORT_DEVICE	= 0,	/**< device memory */
72 	BHND_PORT_BRIDGE	= 1,	/**< bridge memory */
73 	BHND_PORT_AGENT		= 2,	/**< interconnect agent/wrapper */
74 } bhnd_port_type;
75 
76 /**
77  * bhnd(4) attachment types.
78  */
79 typedef enum {
80 	BHND_ATTACH_ADAPTER	= 0,	/**< A bridged card, such as a PCI WiFi chipset  */
81 	BHND_ATTACH_NATIVE	= 1	/**< A bus resident on the native host, such as
82 					  *  the primary or secondary bus of an embedded
83 					  *  SoC */
84 } bhnd_attach_type;
85 
86 /** Evaluates to true if @p cls is a device class that can be configured
87  *  as a host bridge device. */
88 #define	BHND_DEVCLASS_SUPPORTS_HOSTB(cls)					\
89 	((cls) == BHND_DEVCLASS_PCI || (cls) == BHND_DEVCLASS_PCIE ||	\
90 	 (cls) == BHND_DEVCLASS_PCCARD)
91 
92 /**
93  * BHND bus address.
94  *
95  * @note While the interconnect may support 64-bit addressing, not
96  * all bridges and SoC CPUs will.
97  */
98 typedef uint64_t	bhnd_addr_t;
99 #define	BHND_ADDR_MAX	UINT64_MAX	/**< Maximum bhnd_addr_t value */
100 
101 /** BHND bus size. */
102 typedef uint64_t	bhnd_size_t;
103 #define	BHND_SIZE_MAX	UINT64_MAX	/**< Maximum bhnd_size_t value */
104 
105 
106 #endif /* _BHND_BHND_TYPES_H_ */
107