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