xref: /freebsd/sys/dev/bhnd/bcma/bcma_eromreg.h (revision 2ff63af9)
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  */
24 
25 #ifndef	_BCMA_BCMA_EROM_REG_H_
26 #define	_BCMA_BCMA_EROM_REG_H_
27 
28 /* Enumeration ROM device registers */
29 #define	BCMA_EROM_TABLE_START	0x000	/**< device enumeration table offset */
30 #define	BCMA_EROM_REMAPCONTROL	0xe00
31 #define	BCMA_EROM_REMAPSELECT	0xe04
32 #define	BCMA_EROM_MASTERSELECT	0xe10
33 #define	BCMA_EROM_ITCR		0xf00
34 #define	BCMA_EROM_ITIP		0xf04
35 #define	BCMA_EROM_TABLE_SIZE	BCMA_EROM_REMAPCONTROL - BCMA_EROM_TABLE_START
36 
37 /**
38  * Extract an entry attribute by applying _MASK and _SHIFT defines.
39  *
40  * @param _entry The entry containing the desired attribute
41  * @param _attr The BCMA EROM attribute name (e.g. ENTRY_ISVALID), to be
42  * concatenated with the `BCMA_EROM_` prefix and `_MASK`/`_SHIFT` suffixes.
43  */
44 #define	BCMA_EROM_GET_ATTR(_entry, _attr)			\
45 	((_entry & BCMA_EROM_ ## _attr ## _MASK)	\
46 	>> BCMA_EROM_ ## _attr ## _SHIFT)
47 
48 /**
49  * Test an EROM entry's validity and type.
50  *
51  * @param _entry The entry to test.
52  * @param _type The required type
53  * @retval true if the entry type matches and the BCMA_EROM_ENTRY_ISVALID flag
54  * is set.
55  * @retval false if the entry is not valid, or if the type does not match.
56  */
57 #define	BCMA_EROM_ENTRY_IS(_entry, _type)					\
58 	(BCMA_EROM_GET_ATTR(_entry, ENTRY_ISVALID) &&			\
59 	 BCMA_EROM_GET_ATTR(_entry, ENTRY_TYPE) == BCMA_EROM_ENTRY_TYPE_ ## _type)
60 
61 /*
62  * Enumeration ROM Constants
63  */
64 #define	BCMA_EROM_TABLE_EOF		0xF		/* end of EROM table */
65 
66 #define	BCMA_EROM_ENTRY_ISVALID_MASK	0x1		/* is entry valid? */
67 #define	BCMA_EROM_ENTRY_ISVALID_SHIFT	0
68 
69 /* EROM Entry Types */
70 #define	BCMA_EROM_ENTRY_TYPE_MASK	0x6		/* entry type mask */
71 #define	BCMA_EROM_ENTRY_TYPE_SHIFT	0
72 #  define BCMA_EROM_ENTRY_TYPE_CORE	0x0		/* core descriptor */
73 #  define BCMA_EROM_ENTRY_TYPE_MPORT	0x2		/* master port descriptor */
74 #  define BCMA_EROM_ENTRY_TYPE_REGION	0x4		/* address region descriptor */
75 
76 /* EROM Core DescriptorA (31:0) */
77 #define	BCMA_EROM_COREA_DESIGNER_MASK	0xFFF00000	/* core designer (JEP-106 mfg id) */
78 #define	BCMA_EROM_COREA_DESIGNER_SHIFT	20
79 #define	BCMA_EROM_COREA_ID_MASK		0x000FFF00	/* broadcom-assigned core id */
80 #define	BCMA_EROM_COREA_ID_SHIFT	8
81 #define	BCMA_EROM_COREA_CLASS_MASK	0x000000F0	/* core class */
82 #define	BCMA_EROM_COREA_CLASS_SHIFT	4
83 
84 /* EROM Core DescriptorB (63:32) */
85 #define	BCMA_EROM_COREB_NUM_MP_MASK	0x000001F0	/* master port count */
86 #define	BCMA_EROM_COREB_NUM_MP_SHIFT	4
87 #define	BCMA_EROM_COREB_NUM_DP_MASK	0x00003E00	/* device/bridge port count */
88 #define	BCMA_EROM_COREB_NUM_DP_SHIFT	9
89 #define	BCMA_EROM_COREB_NUM_WMP_MASK	0x0007C000	/* master wrapper port count */
90 #define	BCMA_EROM_COREB_NUM_WMP_SHIFT	14
91 #define	BCMA_EROM_COREB_NUM_WSP_MASK	0x00F80000	/* slave wrapper port count */
92 #define	BCMA_EROM_COREB_NUM_WSP_SHIFT	19
93 #define	BCMA_EROM_COREB_REV_MASK	0xFF000000	/* broadcom-assigned core revision */
94 #define	BCMA_EROM_COREB_REV_SHIFT	24
95 
96 /* EROM Master Port Descriptor
97  *
98  * The attribute descriptions are derived from background information
99  * on the AXI bus and PL301 interconnect, but are undocumented
100  * by Broadcom and may be incorrect.
101  */
102 #define	BCMA_EROM_MPORT_NUM_MASK	0x0000FF00	/* AXI master number (unique per interconnect) */
103 #define	BCMA_EROM_MPORT_NUM_SHIFT	8
104 #define	BCMA_EROM_MPORT_ID_MASK		0x000000F0	/* AXI master ID (unique per master). */
105 #define	BCMA_EROM_MPORT_ID_SHIFT	4
106 
107 /* EROM Slave Port MMIO Region Descriptor */
108 #define	BCMA_EROM_REGION_BASE_MASK	0xFFFFF000	/* region base address */
109 #define	BCMA_EROM_REGION_BASE_SHIFT	0
110 #define	BCMA_EROM_REGION_64BIT_MASK	0x00000008	/* base address spans two 32-bit entries */
111 #define	BCMA_EROM_REGION_64BIT_SHIFT	0
112 #define	BCMA_EROM_REGION_PORT_MASK	0x00000F00	/* region's associated port */
113 #define	BCMA_EROM_REGION_PORT_SHIFT	8
114 #define	BCMA_EROM_REGION_TYPE_MASK	0x000000C0	/* region type */
115 #define	BCMA_EROM_REGION_TYPE_SHIFT	6
116 #define	  BCMA_EROM_REGION_TYPE_DEVICE	0		/* region maps to a device */
117 #define	  BCMA_EROM_REGION_TYPE_BRIDGE	1		/* region maps to a bridge (e.g. AXI2APB) */
118 #define	  BCMA_EROM_REGION_TYPE_SWRAP	2		/* region maps to a slave port's DMP agent/wrapper */
119 #define	  BCMA_EROM_REGION_TYPE_MWRAP	3		/* region maps to a master port's DMP agent/wrapper */
120 
121 #define	BCMA_EROM_REGION_SIZE_MASK	0x00000030	/* region size encoding */
122 #define	BCMA_EROM_REGION_SIZE_SHIFT	4
123 #define	  BCMA_EROM_REGION_SIZE_4K	0		/* 4K region */
124 #define	  BCMA_EROM_REGION_SIZE_8K	1		/* 8K region */
125 #define	  BCMA_EROM_REGION_SIZE_16K	2		/* 16K region */
126 #define	  BCMA_EROM_REGION_SIZE_OTHER	3		/* defined by an additional size descriptor entry. */
127 #define	BCMA_EROM_REGION_SIZE_BASE	0x1000
128 
129 /* Region Size Descriptor */
130 #define	BCMA_EROM_RSIZE_VAL_MASK	0xFFFFF000	/* region size */
131 #define	BCMA_EROM_RSIZE_VAL_SHIFT	0
132 #define	BCMA_EROM_RSIZE_64BIT_MASK	0x00000008	/* size spans two 32-bit entries */
133 #define	BCMA_EROM_RSIZE_64BIT_SHIFT	0
134 
135 #endif /* _BCMA_BCMA_EROM_REG_H_ */
136