]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bhnd/bcma/bcma_eromreg.h
MFV r342175:
[FreeBSD/FreeBSD.git] / sys / dev / bhnd / bcma / bcma_eromreg.h
1 /*-
2  * SPDX-License-Identifier: ISC
3  *
4  * Copyright (c) 2015 Landon Fuller <landon@landonf.org>
5  * Copyright (c) 2010 Broadcom Corporation
6  * 
7  * Portions of this file were derived from the aidmp.h header
8  * distributed with Broadcom's initial brcm80211 Linux driver release, as
9  * contributed to the Linux staging repository.
10  *
11  * Permission to use, copy, modify, and/or distribute this software for any
12  * purpose with or without fee is hereby granted, provided that the above
13  * copyright notice and this permission notice appear in all copies.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  * 
23  * $FreeBSD$
24  */
25
26 #ifndef _BCMA_BCMA_EROM_REG_H_
27 #define _BCMA_BCMA_EROM_REG_H_
28
29 /* Enumeration ROM device registers */
30 #define BCMA_EROM_TABLE_START   0x000   /**< device enumeration table offset */
31 #define BCMA_EROM_REMAPCONTROL  0xe00
32 #define BCMA_EROM_REMAPSELECT   0xe04
33 #define BCMA_EROM_MASTERSELECT  0xe10
34 #define BCMA_EROM_ITCR          0xf00
35 #define BCMA_EROM_ITIP          0xf04
36 #define BCMA_EROM_TABLE_SIZE    BCMA_EROM_REMAPCONTROL - BCMA_EROM_TABLE_START
37
38 /**
39  * Extract an entry attribute by applying _MASK and _SHIFT defines.
40  * 
41  * @param _entry The entry containing the desired attribute
42  * @param _attr The BCMA EROM attribute name (e.g. ENTRY_ISVALID), to be
43  * concatenated with the `BCMA_EROM_` prefix and `_MASK`/`_SHIFT` suffixes.
44  */
45 #define BCMA_EROM_GET_ATTR(_entry, _attr)                       \
46         ((_entry & BCMA_EROM_ ## _attr ## _MASK)        \
47         >> BCMA_EROM_ ## _attr ## _SHIFT)
48
49 /**
50  * Test an EROM entry's validity and type.
51  *
52  * @param _entry The entry to test.
53  * @param _type The required type
54  * @retval true if the entry type matches and the BCMA_EROM_ENTRY_ISVALID flag
55  * is set.
56  * @retval false if the entry is not valid, or if the type does not match.
57  */
58 #define BCMA_EROM_ENTRY_IS(_entry, _type)                                       \
59         (BCMA_EROM_GET_ATTR(_entry, ENTRY_ISVALID) &&                   \
60          BCMA_EROM_GET_ATTR(_entry, ENTRY_TYPE) == BCMA_EROM_ENTRY_TYPE_ ## _type)
61
62 /*
63  * Enumeration ROM Constants
64  */
65 #define BCMA_EROM_TABLE_EOF             0xF             /* end of EROM table */
66
67 #define BCMA_EROM_ENTRY_ISVALID_MASK    0x1             /* is entry valid? */
68 #define BCMA_EROM_ENTRY_ISVALID_SHIFT   0
69
70 /* EROM Entry Types */
71 #define BCMA_EROM_ENTRY_TYPE_MASK       0x6             /* entry type mask */
72 #define BCMA_EROM_ENTRY_TYPE_SHIFT      0
73 #  define BCMA_EROM_ENTRY_TYPE_CORE     0x0             /* core descriptor */
74 #  define BCMA_EROM_ENTRY_TYPE_MPORT    0x2             /* master port descriptor */
75 #  define BCMA_EROM_ENTRY_TYPE_REGION   0x4             /* address region descriptor */
76
77 /* EROM Core DescriptorA (31:0) */
78 #define BCMA_EROM_COREA_DESIGNER_MASK   0xFFF00000      /* core designer (JEP-106 mfg id) */
79 #define BCMA_EROM_COREA_DESIGNER_SHIFT  20
80 #define BCMA_EROM_COREA_ID_MASK         0x000FFF00      /* broadcom-assigned core id */
81 #define BCMA_EROM_COREA_ID_SHIFT        8
82 #define BCMA_EROM_COREA_CLASS_MASK      0x000000F0      /* core class */
83 #define BCMA_EROM_COREA_CLASS_SHIFT     4
84
85 /* EROM Core DescriptorB (63:32) */
86 #define BCMA_EROM_COREB_NUM_MP_MASK     0x000001F0      /* master port count */
87 #define BCMA_EROM_COREB_NUM_MP_SHIFT    4
88 #define BCMA_EROM_COREB_NUM_DP_MASK     0x00003E00      /* device/bridge port count */
89 #define BCMA_EROM_COREB_NUM_DP_SHIFT    9
90 #define BCMA_EROM_COREB_NUM_WMP_MASK    0x0007C000      /* master wrapper port count */
91 #define BCMA_EROM_COREB_NUM_WMP_SHIFT   14
92 #define BCMA_EROM_COREB_NUM_WSP_MASK    0x00F80000      /* slave wrapper port count */
93 #define BCMA_EROM_COREB_NUM_WSP_SHIFT   19
94 #define BCMA_EROM_COREB_REV_MASK        0xFF000000      /* broadcom-assigned core revision */
95 #define BCMA_EROM_COREB_REV_SHIFT       24
96
97 /* EROM Master Port Descriptor 
98  * 
99  * The attribute descriptions are derived from background information
100  * on the AXI bus and PL301 interconnect, but are undocumented
101  * by Broadcom and may be incorrect.
102  */
103 #define BCMA_EROM_MPORT_NUM_MASK        0x0000FF00      /* AXI master number (unique per interconnect) */
104 #define BCMA_EROM_MPORT_NUM_SHIFT       8
105 #define BCMA_EROM_MPORT_ID_MASK         0x000000F0      /* AXI master ID (unique per master). */
106 #define BCMA_EROM_MPORT_ID_SHIFT        4
107
108
109 /* EROM Slave Port MMIO Region Descriptor */
110 #define BCMA_EROM_REGION_BASE_MASK      0xFFFFF000      /* region base address */
111 #define BCMA_EROM_REGION_BASE_SHIFT     0
112 #define BCMA_EROM_REGION_64BIT_MASK     0x00000008      /* base address spans two 32-bit entries */
113 #define BCMA_EROM_REGION_64BIT_SHIFT    0
114 #define BCMA_EROM_REGION_PORT_MASK      0x00000F00      /* region's associated port */
115 #define BCMA_EROM_REGION_PORT_SHIFT     8
116 #define BCMA_EROM_REGION_TYPE_MASK      0x000000C0      /* region type */
117 #define BCMA_EROM_REGION_TYPE_SHIFT     6
118 #define   BCMA_EROM_REGION_TYPE_DEVICE  0               /* region maps to a device */
119 #define   BCMA_EROM_REGION_TYPE_BRIDGE  1               /* region maps to a bridge (e.g. AXI2APB) */
120 #define   BCMA_EROM_REGION_TYPE_SWRAP   2               /* region maps to a slave port's DMP agent/wrapper */
121 #define   BCMA_EROM_REGION_TYPE_MWRAP   3               /* region maps to a master port's DMP agent/wrapper */
122
123 #define BCMA_EROM_REGION_SIZE_MASK      0x00000030      /* region size encoding */
124 #define BCMA_EROM_REGION_SIZE_SHIFT     4
125 #define   BCMA_EROM_REGION_SIZE_4K      0               /* 4K region */
126 #define   BCMA_EROM_REGION_SIZE_8K      1               /* 8K region */
127 #define   BCMA_EROM_REGION_SIZE_16K     2               /* 16K region */
128 #define   BCMA_EROM_REGION_SIZE_OTHER   3               /* defined by an additional size descriptor entry. */
129 #define BCMA_EROM_REGION_SIZE_BASE      0x1000
130
131 /* Region Size Descriptor */
132 #define BCMA_EROM_RSIZE_VAL_MASK        0xFFFFF000      /* region size */
133 #define BCMA_EROM_RSIZE_VAL_SHIFT       0
134 #define BCMA_EROM_RSIZE_64BIT_MASK      0x00000008      /* size spans two 32-bit entries */
135 #define BCMA_EROM_RSIZE_64BIT_SHIFT     0
136
137 #endif /* _BCMA_BCMA_EROM_REG_H_ */