xref: /freebsd/sys/dev/bhnd/bhndb/bhndb_pcireg.h (revision 243e928310d073338c5ec089f0dce238a80b9866)
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 bcmdevs.h header contributed by
6  * Broadcom to Android's bcmdhd driver module, and the pcicfg.h header
7  * distributed with Broadcom's initial brcm80211 Linux driver release.
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 _BHND_BHNDB_PCIREG_H_
25 #define _BHND_BHNDB_PCIREG_H_
26 
27 /*
28  * Common PCI/PCIE Bridge Configuration Registers.
29  *
30  * = MAJOR CORE REVISIONS =
31  *
32  * There have been four revisions to the BAR0 memory mappings used
33  * in BHND PCI/PCIE bridge cores:
34  *
35  * == PCI_V0 ==
36  * Applies to:
37  * -  PCI (cid=0x804, revision <= 12)
38  * BAR0 size: 8KB
39  * Address Map:
40  *	[offset+  size]	type	description
41  * 	[0x0000+0x1000]	dynamic mapped backplane address space (window 0).
42  * 	[0x1000+0x0800]	fixed	SPROM shadow
43  * 	[0x1800+0x0800]	fixed	pci core registers
44  *
45  * == PCI_V1 ==
46  * Applies to:
47  * -  PCI (cid=0x804, revision >= 13)
48  * -  PCIE (cid=0x820) with ChipCommon (revision <= 31)
49  * BAR0 size: 16KB
50  * Address Map:
51  *	[offset+  size]	type	description
52  *	[0x0000+0x1000]	dynamic	mapped backplane address space (window 0).
53  *	[0x1000+0x1000]	fixed	SPROM shadow
54  *	[0x2000+0x1000]	fixed	pci/pcie core registers
55  *	[0x3000+0x1000]	fixed	chipcommon core registers
56  *
57  * == PCI_V2 ==
58  * Applies to:
59  * - PCIE (cid=0x820) with ChipCommon (revision >= 32)
60  * BAR0 size: 16KB
61  * Address Map:
62  *	[offset+  size]	type	description
63  *	[0x0000+0x1000]	dynamic	mapped backplane address space (window 0).
64  *	[0x1000+0x1000]	dynamic	mapped backplane address space (window 1).
65  *	[0x2000+0x1000]	fixed	pci/pcie core registers
66  *	[0x3000+0x1000]	fixed	chipcommon core registers
67  *
68  * == PCI_V3 ==
69  * Applies to:
70  * - PCIE Gen 2 (cid=0x83c)
71  * BAR0 size: 32KB
72  * Address Map:
73  *	[offset+  size]	type	description
74  *	[0x0000+0x1000]	dynamic	mapped backplane address space (window 0).
75  *	[0x1000+0x1000]	dynamic	mapped backplane address space (window 1).
76  *	[0x2000+0x1000]	fixed	pci/pcie core registers
77  *	[0x3000+0x1000]	fixed	chipcommon core registers
78  *	[???]
79  * BAR1 size: varies
80  * Address Map:
81  *	[offset+  size]	type	description
82  *	[0x0000+0x????]	fixed	ARM tightly-coupled memory (TCM).
83  *				While fullmac chipsets provided a fixed
84  *				4KB mapping, newer devices will vary.
85  *
86  * = MINOR CORE REVISIONS =
87  *
88  * == PCI Cores Revision >= 3 ==
89  * - Mapped GPIO CSRs into the PCI config space. Refer to
90  *   BHND_PCI_GPIO_*.
91  *
92  * == PCI/PCIE Cores Revision >= 14 ==
93  * - Mapped the clock CSR into the PCI config space. Refer to
94  *   BHND_PCI_CLK_CTL_ST
95  */
96 
97 /* Common PCI/PCIE Config Registers */
98 #define	BHNDB_PCI_SPROM_CONTROL		0x88	/* sprom property control */
99 #define	BHNDB_PCI_BAR1_CONTROL		0x8c	/* BAR1 region prefetch/burst control */
100 #define	BHNDB_PCI_INT_STATUS		0x90	/* PCI and other cores interrupts */
101 #define	BHNDB_PCI_INT_MASK		0x94	/* mask of PCI and other cores interrupts */
102 #define	BHNDB_PCI_TO_SB_MB		0x98	/* signal backplane interrupts */
103 #define	BHNDB_PCI_BACKPLANE_ADDR	0xa0	/* address an arbitrary location on the system backplane */
104 #define	BHNDB_PCI_BACKPLANE_DATA	0xa4	/* data at the location specified by above address */
105 
106 /* PCI (non-PCIe) GPIO/Clock Config Registers */
107 #define	BHNDB_PCI_CLK_CTL		0xa8	/* clock control/status (pci >=rev14) */
108 #define	BHNDB_PCI_GPIO_IN		0xb0	/* gpio input (pci >=rev3) */
109 #define	BHNDB_PCI_GPIO_OUT		0xb4	/* gpio output (pci >=rev3) */
110 #define	BHNDB_PCI_GPIO_OUTEN		0xb8	/* gpio output enable (pci >=rev3) */
111 
112 /* Hardware revisions used to determine PCI revision */
113 #define	BHNDB_PCI_V0_MAX_PCI_HWREV	12
114 #define	BHNDB_PCI_V1_MIN_PCI_HWREV	13
115 #define	BHNDB_PCI_V1_MAX_CHIPC_HWREV	31
116 #define	BHNDB_PCI_V2_MIN_CHIPC_HWREV	32
117 
118 /**
119  * Number of times to retry writing to a PCI window address register.
120  *
121  * On siba(4) devices, it's possible that writing a PCI window register may
122  * not succeed; it's necessary to immediately read the configuration register
123  * and retry if not set to the desired value.
124  */
125 #define	BHNDB_PCI_BARCTRL_WRITE_RETRY	50
126 
127 /* PCI_V0  */
128 #define	BHNDB_PCI_V0_BAR0_WIN0_CONTROL	0x80	/* backplane address space accessed by BAR0/WIN0 */
129 #define	BHNDB_PCI_V0_BAR1_WIN0_CONTROL	0x84	/* backplane address space accessed by BAR1/WIN0. */
130 
131 #define	BHNDB_PCI_V0_BAR0_SIZE		0x2000	/* 8KB BAR0 */
132 #define	BHNDB_PCI_V0_BAR0_WIN0_OFFSET	0x0	/* bar0 + 0x0 accesses configurable 4K region of backplane address space */
133 #define	BHNDB_PCI_V0_BAR0_WIN0_SIZE	0x1000
134 #define	BHNDB_PCI_V0_BAR0_SPROM_OFFSET	0x1000	/* bar0 + 4K accesses sprom shadow (in pci core) */
135 #define BHNDB_PCI_V0_BAR0_SPROM_SIZE	0x0800
136 #define	BHNDB_PCI_V0_BAR0_PCIREG_OFFSET	0x1800	/* bar0 + 6K accesses pci core registers */
137 #define	BHNDB_PCI_V0_BAR0_PCIREG_SIZE	0x0800
138 
139 /* PCI_V1 */
140 #define	BHNDB_PCI_V1_BAR0_WIN0_CONTROL	0x80	/* backplane address space accessed by BAR0/WIN0 */
141 #define	BHNDB_PCI_V1_BAR1_WIN0_CONTROL	0x84	/* backplane address space accessed by BAR1/WIN0. */
142 
143 #define	BHNDB_PCI_V1_BAR0_SIZE		0x4000	/* 16KB BAR0 */
144 #define	BHNDB_PCI_V1_BAR0_WIN0_OFFSET	0x0	/* bar0 + 0x0 accesses configurable 4K region of backplane address space */
145 #define	BHNDB_PCI_V1_BAR0_WIN0_SIZE	0x1000
146 #define	BHNDB_PCI_V1_BAR0_SPROM_OFFSET	0x1000	/* bar0 + 4K accesses sprom shadow (in pci core) */
147 #define BHNDB_PCI_V1_BAR0_SPROM_SIZE	0x1000
148 #define	BHNDB_PCI_V1_BAR0_PCIREG_OFFSET	0x2000	/* bar0 + 8K accesses pci/pcie core registers */
149 #define	BHNDB_PCI_V1_BAR0_PCIREG_SIZE	0x1000
150 #define	BHNDB_PCI_V1_BAR0_CCREGS_OFFSET	0x3000	/* bar0 + 12K accesses chipc core registers */
151 #define	BHNDB_PCI_V1_BAR0_CCREGS_SIZE	0x1000
152 
153 /* PCI_V2 */
154 #define	BHNDB_PCI_V2_BAR0_WIN0_CONTROL	0x80	/* backplane address space accessed by BAR0/WIN0 */
155 #define	BHNDB_PCI_V2_BAR1_WIN0_CONTROL	0x84	/* backplane address space accessed by BAR1/WIN0. */
156 #define	BHNDB_PCI_V2_BAR0_WIN1_CONTROL	0xAC	/* backplane address space accessed by BAR0/WIN1 */
157 
158 #define	BHNDB_PCI_V2_BAR0_SIZE		0x4000	/* 16KB BAR0 */
159 #define	BHNDB_PCI_V2_BAR0_WIN0_OFFSET	0x0	/* bar0 + 0x0 accesses configurable 4K region of backplane address space */
160 #define	BHNDB_PCI_V2_BAR0_WIN0_SIZE	0x1000
161 #define	BHNDB_PCI_V2_BAR0_WIN1_OFFSET	0x1000	/* bar0 + 4K accesses second 4K window */
162 #define BHNDB_PCI_V2_BAR0_WIN1_SIZE	0x1000
163 #define	BHNDB_PCI_V2_BAR0_PCIREG_OFFSET	0x2000	/* bar0 + 8K accesses pci/pcie core registers */
164 #define	BHNDB_PCI_V2_BAR0_PCIREG_SIZE	0x1000
165 #define	BHNDB_PCI_V2_BAR0_CCREGS_OFFSET	0x3000	/* bar0 + 12K accesses chipc core registers */
166 #define	BHNDB_PCI_V2_BAR0_CCREGS_SIZE	0x1000
167 
168 /* PCI_V3 (PCIe-G2) */
169 #define	BHNDB_PCI_V3_BAR0_WIN0_CONTROL	0x80	/* backplane address space accessed by BAR0/WIN0 */
170 #define BHNDB_PCI_V3_BAR0_WIN1_CONTROL	0x70	/* backplane address space accessed by BAR0/WIN1 */
171 
172 #define	BHNDB_PCI_V3_BAR0_SIZE		0x8000	/* 32KB BAR0 */
173 #define	BHNDB_PCI_V3_BAR0_WIN0_OFFSET	0x0	/* bar0 + 0x0 accesses configurable 4K region of backplane address space */
174 #define	BHNDB_PCI_V3_BAR0_WIN0_SIZE	0x1000
175 #define	BHNDB_PCI_V3_BAR0_WIN1_OFFSET	0x1000	/* bar0 + 4K accesses second 4K window */
176 #define BHNDB_PCI_V3_BAR0_WIN1_SIZE	0x1000
177 #define	BHNDB_PCI_V3_BAR0_PCIREG_OFFSET	0x2000	/* bar0 + 8K accesses pci/pcie core registers */
178 #define	BHNDB_PCI_V3_BAR0_PCIREG_SIZE	0x1000
179 #define	BHNDB_PCI_V3_BAR0_CCREGS_OFFSET	0x3000	/* bar0 + 12K accesses chipc core registers */
180 #define	BHNDB_PCI_V3_BAR0_CCREGS_SIZE	0x1000
181 
182 /* BHNDB_PCI_INT_STATUS */
183 #define	BHNDB_PCI_SBIM_STATUS_SERR	0x4	/* backplane SBErr interrupt status */
184 
185 /* BHNDB_PCI_INT_MASK */
186 #define	BHNDB_PCI_SBIM_SHIFT		8	/* backplane core interrupt mask bits offset */
187 #define	BHNDB_PCI_SBIM_MASK		0xff00	/* backplane core interrupt mask */
188 #define	BHNDB_PCI_SBIM_MASK_SERR	0x4	/* backplane SBErr interrupt mask */
189 
190 /* BHNDB_PCI_SPROM_CONTROL */
191 #define	BHNDB_PCI_SPROM_SZ_MASK		0x03	/**< sprom size mask */
192 #define	BHNDB_PCI_SPROM_SZ_1KB		0x00	/**< 1KB sprom size */
193 #define	BHNDB_PCI_SPROM_SZ_4KB		0x01	/**< 4KB sprom size */
194 #define	BHNDB_PCI_SPROM_SZ_16KB		0x02	/**< 16KB sprom size */
195 #define	BHNDB_PCI_SPROM_SZ_RESERVED	0x03	/**< unsupported sprom size */
196 #define	BHNDB_PCI_SPROM_LOCKED		0x08	/**< sprom locked */
197 #define	BHNDB_PCI_SPROM_BLANK		0x04	/**< sprom blank */
198 #define	BHNDB_PCI_SPROM_WRITEEN		0x10	/**< sprom write enable */
199 #define	BHNDB_PCI_SPROM_BOOTROM_WE	0x20	/**< external bootrom write enable */
200 #define	BHNDB_PCI_SPROM_BACKPLANE_EN	0x40	/**< enable indirect backplane access (BHNDB_PCI_BACKPLANE_*) */
201 #define	BHNDB_PCI_SPROM_OTPIN_USE	0x80	/**< device OTP in use */
202 
203 
204 /* PCI (non-PCIe) BHNDB_PCI_GPIO_OUTEN  */
205 #define	BHNDB_PCI_GPIO_SCS		0x10	/* PCI config space bit 4 for 4306c0 slow clock source */
206 #define	BHNDB_PCI_GPIO_HWRAD_OFF		0x20	/* PCI config space GPIO 13 for hw radio disable */
207 #define	BHNDB_PCI_GPIO_XTAL_ON		0x40	/* PCI config space GPIO 14 for Xtal power-up */
208 #define	BHNDB_PCI_GPIO_PLL_OFF		0x80	/* PCI config space GPIO 15 for PLL power-down */
209 
210 #endif /* _BHND_BHNDB_PCIREG_H_ */
211