]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bhnd/bhnd_types.h
Copy ^/vendor/NetBSD/tests/dist/lib/libc/hash/t_hmac.c to
[FreeBSD/FreeBSD.git] / sys / dev / bhnd / bhnd_types.h
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 #include "nvram/bhnd_nvram.h"
38
39 /** bhnd(4) device classes. */
40 typedef enum {
41         BHND_DEVCLASS_CC,               /**< chipcommon i/o controller */
42         BHND_DEVCLASS_CC_B,             /**< chipcommon auxiliary controller */
43         BHND_DEVCLASS_PMU,              /**< pmu controller */
44         BHND_DEVCLASS_PCI,              /**< pci host/device bridge */
45         BHND_DEVCLASS_PCIE,             /**< pcie host/device bridge */
46         BHND_DEVCLASS_PCCARD,           /**< pcmcia host/device bridge */
47         BHND_DEVCLASS_RAM,              /**< internal RAM/SRAM */
48         BHND_DEVCLASS_MEMC,             /**< memory controller */
49         BHND_DEVCLASS_ENET,             /**< 802.3 MAC/PHY */
50         BHND_DEVCLASS_ENET_MAC,         /**< 802.3 MAC */
51         BHND_DEVCLASS_ENET_PHY,         /**< 802.3 PHY */
52         BHND_DEVCLASS_WLAN,             /**< 802.11 MAC/PHY/Radio */
53         BHND_DEVCLASS_WLAN_MAC,         /**< 802.11 MAC */
54         BHND_DEVCLASS_WLAN_PHY,         /**< 802.11 PHY */
55         BHND_DEVCLASS_CPU,              /**< cpu core */
56         BHND_DEVCLASS_SOC_ROUTER,       /**< interconnect router */
57         BHND_DEVCLASS_SOC_BRIDGE,       /**< interconnect host bridge */
58         BHND_DEVCLASS_EROM,             /**< bus device enumeration ROM */
59         BHND_DEVCLASS_NVRAM,            /**< nvram/flash controller */
60         BHND_DEVCLASS_USB_HOST,         /**< USB host controller */
61         BHND_DEVCLASS_USB_DEV,          /**< USB device controller */
62         BHND_DEVCLASS_USB_DUAL,         /**< USB host/device controller */
63
64         BHND_DEVCLASS_OTHER     = 1000, /**< other / unknown */
65         BHND_DEVCLASS_INVALID           /**< no/invalid class */
66 } bhnd_devclass_t;
67
68
69 /**
70  * bhnd(4) port types.
71  * 
72  * Only BHND_PORT_DEVICE is guaranteed to be supported by all bhnd(4) bus
73  * implementations.
74  */
75 typedef enum {
76         BHND_PORT_DEVICE        = 0,    /**< device memory */
77         BHND_PORT_BRIDGE        = 1,    /**< bridge memory */
78         BHND_PORT_AGENT         = 2,    /**< interconnect agent/wrapper */
79 } bhnd_port_type;
80
81 /**
82  * bhnd(4) attachment types.
83  */
84 typedef enum {
85         BHND_ATTACH_ADAPTER     = 0,    /**< A bridged card, such as a PCI WiFi chipset  */
86         BHND_ATTACH_NATIVE      = 1     /**< A bus resident on the native host, such as
87                                           *  the primary or secondary bus of an embedded
88                                           *  SoC */
89 } bhnd_attach_type;
90
91 /**
92  * bhnd(4) clock types.
93  */
94 typedef enum {
95         /**
96          * Dynamically select an appropriate clock source based on all
97          * outstanding clock requests.
98          */
99         BHND_CLOCK_DYN          = (1 << 0),
100
101         /**
102          * Idle Low-Power (ILP).
103          * 
104          * No register access is required, or long request latency is
105          * acceptable.
106          */
107         BHND_CLOCK_ILP          = (1 << 1),
108         
109         /**
110          * Active Low-Power (ALP).
111          * 
112          * Low-latency register access and low-rate DMA.
113          */
114         BHND_CLOCK_ALP          = (1 << 2),
115         
116         /**
117          * High Throughput (HT).
118          * 
119          * High bus throughput and lowest-latency register access.
120          */
121         BHND_CLOCK_HT           = (1 << 3)
122 } bhnd_clock;
123
124 /**
125  * Given two clock types, return the type with the highest precedence. 
126  */
127 static inline bhnd_clock
128 bhnd_clock_max(bhnd_clock a, bhnd_clock b) {
129         return (a > b ? a : b);
130 }
131
132 /**
133  * bhnd(4) clock sources.
134  */
135 typedef enum {
136         /**
137          * Clock is provided by the PCI bus clock
138          */
139         BHND_CLKSRC_PCI         = 0,
140
141         /** Clock is provided by a crystal. */
142         BHND_CLKSRC_XTAL        = 1,
143
144         /** Clock is provided by a low power oscillator. */
145         BHND_CLKSRC_LPO         = 2,
146
147         /** Clock source is unknown */
148         BHND_CLKSRC_UNKNOWN     = 3
149 } bhnd_clksrc;
150
151 /** Evaluates to true if @p cls is a device class that can be configured
152  *  as a host bridge device. */
153 #define BHND_DEVCLASS_SUPPORTS_HOSTB(cls)                                       \
154         ((cls) == BHND_DEVCLASS_PCI || (cls) == BHND_DEVCLASS_PCIE ||   \
155          (cls) == BHND_DEVCLASS_PCCARD)
156
157 /**
158  * BHND bus address.
159  * 
160  * @note While the interconnect may support 64-bit addressing, not
161  * all bridges and SoC CPUs will.
162  */
163 typedef uint64_t        bhnd_addr_t;
164 #define BHND_ADDR_MAX   UINT64_MAX      /**< Maximum bhnd_addr_t value */
165
166 /** BHND bus size. */
167 typedef uint64_t        bhnd_size_t;
168 #define BHND_SIZE_MAX   UINT64_MAX      /**< Maximum bhnd_size_t value */
169
170
171 #endif /* _BHND_BHND_TYPES_H_ */