bhnd_pcireg.h revision 298479
1238367Sjkim/*-
2238367Sjkim * Copyright (c) 2015 Landon Fuller <landon@landonf.org>
3238367Sjkim * Copyright (c) 2010 Broadcom Corporation
4238367Sjkim * All rights reserved.
5238367Sjkim *
6238367Sjkim * This file is derived from the hndsoc.h, pci_core.h, and pcie_core.h headers
7238367Sjkim * distributed with Broadcom's initial brcm80211 Linux driver release, as
8306536Sjkim * contributed to the Linux staging repository.
9238367Sjkim *
10238367Sjkim * Permission to use, copy, modify, and/or distribute this software for any
11238367Sjkim * purpose with or without fee is hereby granted, provided that the above
12238367Sjkim * copyright notice and this permission notice appear in all copies.
13238367Sjkim *
14238367Sjkim * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15238367Sjkim * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16238367Sjkim * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17238367Sjkim * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18238367Sjkim * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19238367Sjkim * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20238367Sjkim * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21238367Sjkim *
22238367Sjkim * $FreeBSD: head/sys/dev/bhnd/cores/pci/bhnd_pcireg.h 298479 2016-04-22 16:26:53Z adrian $
23238367Sjkim */
24238367Sjkim
25238367Sjkim#ifndef _BHND_CORES_PCI_BHND_PCIREG_H_
26238367Sjkim#define _BHND_CORES_PCI_BHND_PCIREG_H_
27238367Sjkim
28238367Sjkim/*
29238367Sjkim * PCI/PCIe-Gen1 DMA Constants
30238367Sjkim */
31238367Sjkim
32238367Sjkim#define	BHND_PCI_DMA32_TRANSLATION	0x40000000	/* Client Mode sb2pcitranslation2 (1 GB) */
33238367Sjkim#define	BHND_PCI_DMA32_SZ		0x40000000	/* Client Mode sb2pcitranslation2 size in bytes */
34238367Sjkim
35238367Sjkim#define	BHND_PCIE_DMA32_TRANSLATION	BHND_PCI_DMA32_TRANSLATION
36238367Sjkim#define	BHND_PCIE_DMA32_SZ		BHND_PCI_DMA32_SZ
37238367Sjkim
38238367Sjkim#define	BHND_PCIE_DMA64_L32		0x00000000	/**< 64-bit client mode sb2pcitranslation2 (2 ZettaBytes, low 32 bits) */
39238367Sjkim#define	BHND_PCIE_DMA64_H32		0x80000000	/**< 64-bit client mode sb2pcitranslation2 (2 ZettaBytes, high 32 bits) */
40238367Sjkim
41238367Sjkim/*
42238367Sjkim * PCI Core Registers
43238367Sjkim */
44281075Sdim
45238367Sjkim#define	BHND_PCI_CTL			0x000	/**< PCI core control*/
46238381Sjkim#define	BHND_PCI_ARB_CTL		0x010	/**< PCI arbiter control */
47238381Sjkim#define	BHND_PCI_CLKRUN_CTL		0x014	/**< PCI clckrun control (>= rev11) */
48238381Sjkim#define	BHND_PCI_INTR_STATUS		0x020	/**< Interrupt status */
49238381Sjkim#define	BHND_PCI_INTR_MASK		0x024	/**< Interrupt mask */
50306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX		0x028	/**< Sonics to PCI mailbox */
51238367Sjkim#define	BHND_PCI_BCAST_ADDR		0x050	/**< Sonics broadcast address (pci) */
52238367Sjkim#define	BHND_PCI_BCAST_DATA		0x054	/**< Sonics broadcast data (pci) */
53238367Sjkim#define	BHND_PCI_GPIO_IN		0x060	/**< GPIO input (>= rev2) */
54238367Sjkim#define	BHND_PCI_GPIO_OUT		0x064	/**< GPIO output (>= rev2) */
55238367Sjkim#define	BHND_PCI_GPIO_EN		0x068	/**< GPIO output enable (>= rev2) */
56238367Sjkim#define	BHND_PCI_GPIO_CTL		0x06C	/**< GPIO control (>= rev2) */
57238367Sjkim#define	BHND_PCI_SBTOPCI0		0x100	/**< Sonics to PCI translation 0 */
58238367Sjkim#define	BHND_PCI_SBTOPCI1		0x104	/**< Sonics to PCI translation 1 */
59238367Sjkim#define	BHND_PCI_SBTOPCI2		0x108	/**< Sonics to PCI translation 2 */
60238367Sjkim#define	BHND_PCI_FUNC0_CFG		0x400	/**< PCI function 0 cfg space (>= rev8) */
61238367Sjkim#define	BHND_PCI_FUNC1_CFG		0x500	/**< PCI function 1 cfg space (>= rev8) */
62238367Sjkim#define	BHND_PCI_FUNC2_CFG		0x600	/**< PCI function 2 cfg space (>= rev8) */
63238367Sjkim#define	BHND_PCI_FUNC3_CFG		0x700	/**< PCI function 3 cfg space (>= rev8) */
64238367Sjkim#define	BHND_PCI_SPROM_SHADOW		0x800	/**< PCI SPROM shadow */
65238367Sjkim
66238367Sjkim/* BHND_PCI_CTL */
67238367Sjkim#define	BHND_PCI_CTL_RST_OE		0x01	/* When set, drives PCI_RESET out to pin */
68238367Sjkim#define	BHND_PCI_CTL_RST		0x02	/* Value driven out to pin */
69238367Sjkim#define	BHND_PCI_CTL_CLK_OE		0x04	/* When set, drives clock as gated by PCI_CLK out to pin */
70238367Sjkim#define	BHND_PCI_CTL_CLK		0x08	/* Gate for clock driven out to pin */
71238367Sjkim
72238367Sjkim/* BHND_PCI_ARB_CTL */
73238367Sjkim#define	BHND_PCI_ARB_INT		0x01	/* When set, use an internal arbiter */
74238367Sjkim#define	BHND_PCI_ARB_EXT		0x02	/* When set, use an external arbiter */
75238367Sjkim
76238367Sjkim/* BHND_PCI_ARB_CTL - ParkID (>= rev8) */
77238367Sjkim#define	BHND_PCI_ARB_PARKID_MASK	0x1c	/* Selects which agent is parked on an idle bus */
78306536Sjkim#define	BHND_PCI_ARB_PARKID_SHIFT	2
79306536Sjkim#define	BHND_PCI_ARB_PARKID_EXT0	0	/* External master 0 */
80306536Sjkim#define	BHND_PCI_ARB_PARKID_EXT1	1	/* External master 1 */
81306536Sjkim#define	BHND_PCI_ARB_PARKID_EXT2	2	/* External master 2 */
82306536Sjkim#define	BHND_PCI_ARB_PARKID_EXT3	3	/* External master 3 (rev >= 11) */
83306536Sjkim#define	BHND_PCI_ARB_PARKID_INT_r10	3	/* Internal master (rev < 11) */
84306536Sjkim#define	BHND_PCI_ARB_PARKID_INT_r11	4	/* Internal master (rev >= 11) */
85306536Sjkim#define	BHND_PCI_ARB_PARKID_LAST_r10	4	/* Last active master (rev < 11) */
86306536Sjkim#define	BHND_PCI_ARB_PARKID_LAST_r11	5	/* Last active master (rev >= 11) */
87306536Sjkim
88306536Sjkim/* BHND_PCI_CLKRUN_CTL */
89306536Sjkim#define	BHND_PCI_CLKRUN_DSBL		0x8000	/* Bit 15 forceClkrun */
90306536Sjkim
91306536Sjkim/* BHND_PCI_INTR_STATUS / BHND_PCI_INTR_MASK */
92306536Sjkim#define	BHND_PCI_INTR_A			0x01	/* PCI INTA# is asserted */
93306536Sjkim#define	BHND_PCI_INTR_B			0x02	/* PCI INTB# is asserted */
94306536Sjkim#define	BHND_PCI_INTR_SERR		0x04	/* PCI SERR# has been asserted (write one to clear) */
95306536Sjkim#define	BHND_PCI_INTR_PERR		0x08	/* PCI PERR# has been asserted (write one to clear) */
96306536Sjkim
97238367Sjkim/* BHND_PCI_SBTOPCI_MBOX
98238367Sjkim * (General) PCI/SB mailbox interrupts, two bits per pci function */
99238367Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F0_0	0x100	/* function 0, int 0 */
100306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F0_1	0x200	/* function 0, int 1 */
101306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F1_0	0x400	/* function 1, int 0 */
102306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F1_1	0x800	/* function 1, int 1 */
103306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F2_0	0x1000	/* function 2, int 0 */
104306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F2_1	0x2000	/* function 2, int 1 */
105306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F3_0	0x4000	/* function 3, int 0 */
106306536Sjkim#define	BHND_PCI_SBTOPCI_MBOX_F3_1	0x8000	/* function 3, int 1 */
107306536Sjkim
108238367Sjkim/* BHND_PCI_BCAST_ADDR */
109238367Sjkim#define	BHNC_PCI_BCAST_ADDR_MASK	0xFF	/* Broadcast register address */
110238367Sjkim
111238367Sjkim/* Sonics to PCI translation types */
112238367Sjkim#define BHND_PCI_SBTOPCI0_MASK	0xfc000000
113238367Sjkim#define BHND_PCI_SBTOPCI1_MASK	0xfc000000
114306536Sjkim#define BHND_PCI_SBTOPCI2_MASK	0xc0000000
115306536Sjkim
116306536Sjkim/* Access type bits (0:1) */
117306536Sjkim#define	BHND_PCI_SBTOPCI_MEM		0
118306536Sjkim#define	BHND_PCI_SBTOPCI_IO		1
119306536Sjkim#define	BHND_PCI_SBTOPCI_CFG0		2
120306536Sjkim#define	BHND_PCI_SBTOPCI_CFG1		3
121306536Sjkim
122306536Sjkim#define	BHND_PCI_SBTOPCI_PREF		0x4	/* prefetch enable */
123306536Sjkim#define	BHND_PCI_SBTOPCI_BURST		0x8	/* burst enable */
124306536Sjkim
125306536Sjkim#define	BHND_PCI_SBTOPCI_RC_MASK	0x30	/* read command (>= rev11) */
126306536Sjkim#define	BHND_PCI_SBTOPCI_RC_READ	0x00	/* memory read */
127306536Sjkim#define	BHND_PCI_SBTOPCI_RC_READLINE	0x10	/* memory read line */
128306536Sjkim#define	BHND_PCI_SBTOPCI_RC_READMULTI	0x20	/* memory read multiple */
129306536Sjkim
130238367Sjkim/* PCI core index in SROM shadow area */
131238367Sjkim#define	BHND_PCI_SRSH_PI_OFFSET		0	/* first word */
132238367Sjkim#define	BHND_PCI_SRSH_PI_MASK		0xf000	/* bit 15:12 */
133281075Sdim#define	BHND_PCI_SRSH_PI_SHIFT		12	/* bit 15:12 */
134238367Sjkim
135238367Sjkim
136238367Sjkim
137238367Sjkim/*
138238367Sjkim * PCIe-Gen1 Core Registers
139238367Sjkim */
140238367Sjkim
141238367Sjkim#define	BHND_PCIE_CTL		BHND_PCI_CTL		/**< PCI core control*/
142238367Sjkim#define	BHND_PCIE_BIST_STATUS	0x00C			/**< BIST status */
143238367Sjkim#define	BHND_PCIE_GPIO_SEL	0x010			/**< GPIO select */
144238367Sjkim#define	BHND_PCIE_GPIO_OUT_EN	0x014			/**< GPIO output enable */
145238367Sjkim#define	BHND_PCIE_INTR_STATUS	BHND_PCI_INTR_STATUS	/**< Interrupt status */
146238367Sjkim#define	BHND_PCIE_INTR_MASK	BHND_PCI_INTR_MASK	/**< Interrupt mask */
147238367Sjkim#define	BHND_PCIE_SBTOPCI_MBOX	BHND_PCI_SBTOPCI_MBOX	/**< Sonics to PCI mailbox */
148238367Sjkim#define	BHND_PCIE_SBTOPCI0	BHND_PCI_SBTOPCI0	/**< Sonics to PCI translation 0 */
149306536Sjkim#define	BHND_PCIE_SBTOPCI1	BHND_PCI_SBTOPCI1	/**< Sonics to PCI translation 1 */
150238367Sjkim#define	BHND_PCIE_SBTOPCI2	BHND_PCI_SBTOPCI2	/**< Sonics to PCI translation 2 */
151238367Sjkim
152238367Sjkim/* indirect pci config space access */
153238367Sjkim#define	BHND_PCIE_CFG_ADDR	0x120			/**< pcie config space address */
154238367Sjkim#define	BHND_PCIE_CFG_DATA	0x124			/**< pcie config space data */
155238367Sjkim
156306536Sjkim/* mdio register access */
157306536Sjkim#define	BHND_PCIE_MDIO_CTL	0x128			/**< mdio control */
158306536Sjkim#define	BHND_PCIE_MDIO_DATA	0x12C			/**< mdio data */
159238367Sjkim
160238367Sjkim/* indirect protocol phy/dllp/tlp register access */
161238367Sjkim#define	BHND_PCIE_IND_ADDR	0x130			/**< internal protocol register address */
162238367Sjkim#define	BHND_PCIE_IND_DATA	0x134			/**< internal protocol register data */
163238367Sjkim
164238367Sjkim#define	BHND_PCIE_CLKREQEN_CTL	0x138			/**< clkreq rdma control */
165238367Sjkim#define	BHND_PCIE_FUNC0_CFG	BHND_PCI_FUNC0_CFG	/**< PCI function 0 cfg space */
166238367Sjkim#define	BHND_PCIE_FUNC1_CFG	BHND_PCI_FUNC1_CFG	/**< PCI function 1 cfg space */
167238367Sjkim#define	BHND_PCIE_FUNC2_CFG	BHND_PCI_FUNC2_CFG	/**< PCI function 2 cfg space */
168238367Sjkim#define	BHND_PCIE_FUNC3_CFG	BHND_PCI_FUNC3_CFG	/**< PCI function 3 cfg space */
169238367Sjkim#define	BHND_PCIE_SPROM_SHADOW	BHND_PCI_SPROM_SHADOW	/**< PCI SPROM shadow */
170306536Sjkim
171306536Sjkim/* BHND_PCIE_CTL */
172238367Sjkim#define	BHND_PCIE_CTL_RST_OE	BHND_PCI_CTL_RST_OE	/* When set, drives PCI_RESET out to pin */
173306536Sjkim#define	BHND_PCIE_CTL_RST	BHND_PCI_CTL_RST_OE	/* Value driven out to pin */
174306536Sjkim
175238367Sjkim/* BHND_PCI_INTR_STATUS / BHND_PCI_INTR_MASK */
176238367Sjkim#define	BHND_PCIE_INTR_A	BHND_PCI_INTR_A		/* PCIE INTA message is received */
177238367Sjkim#define	BHND_PCIE_INTR_B	BHND_PCI_INTR_B		/* PCIE INTB message is received */
178238367Sjkim#define	BHND_PCIE_INTR_FATAL	0x04			/* PCIE INTFATAL message is received */
179238367Sjkim#define	BHND_PCIE_INTR_NFATAL	0x08			/* PCIE INTNONFATAL message is received */
180238367Sjkim#define	BHND_PCIE_INTR_CORR	0x10			/* PCIE INTCORR message is received */
181238367Sjkim#define	BHND_PCIE_INTR_PME	0x20			/* PCIE INTPME message is received */
182238367Sjkim
183238367Sjkim/* SB to PCIE translation masks */
184281075Sdim#define	BHND_PCIE_SBTOPCI0_MASK	BHND_PCI_SBTOPCI0_MASK
185238367Sjkim#define	BHND_PCIE_SBTOPCI1_MASK	BHND_PCI_SBTOPCI1_MASK
186306536Sjkim#define	BHND_PCIE_SBTOPCI2_MASK	BHND_PCI_SBTOPCI2_MASK
187238367Sjkim
188238367Sjkim/* Access type bits (0:1) */
189238367Sjkim#define	BHND_PCIE_SBTOPCI_MEM	BHND_PCI_SBTOPCI_MEM
190238367Sjkim#define	BHND_PCIE_SBTOPCI_IO	BHND_PCI_SBTOPCI_IO
191238367Sjkim#define	BHND_PCIE_SBTOPCI_CFG0	BHND_PCI_SBTOPCI_CFG0
192238367Sjkim#define	BHND_PCIE_SBTOPCI_CFG1	BHND_PCI_SBTOPCI_CFG1
193238367Sjkim
194238367Sjkim#define	BHND_PCIE_SBTOPCI_PREF	BHND_PCI_SBTOPCI_PREF	/* prefetch enable */
195238367Sjkim#define	BHND_PCIE_SBTOPCI_BURST	BHND_PCI_SBTOPCI_BURST	/* burst enable */
196306536Sjkim
197238367Sjkim/* BHND_PCIE_CFG_ADDR / BHND_PCIE_CFG_DATA */
198238367Sjkim#define	BHND_PCIE_CFG_ADDR_FUNC_MASK	0x7000
199238367Sjkim#define	BHND_PCIE_CFG_ADDR_FUNC_SHIFT	12
200238367Sjkim#define	BHND_PCIE_CFG_ADDR_REG_MASK	0x0FFF
201238367Sjkim#define	BHND_PCIE_CFG_ADDR_REG_SHIFT	0
202238367Sjkim
203238367Sjkim#define	BHND_PCIE_CFG_OFFSET(f, r)	\
204238367Sjkim	((((f) & BHND_PCIE_CFG_ADDR_FUNC_MASK) << BHND_PCIE_CFG_ADDR_FUNC_SHIFT) | \
205238367Sjkim	(((r) & BHND_PCIE_CFG_ADDR_FUNC_SHIFT) << BHND_PCIE_CFG_ADDR_REG_SHIFT))
206238367Sjkim
207306536Sjkim/* BHND_PCIE_MDIO_CTL control */
208238367Sjkim#define	BHND_PCIE_MDIOCTL_DIVISOR_MASK		0x7f	/* clock divisor mask */
209238367Sjkim#define	BHND_PCIE_MDIOCTL_DIVISOR_VAL		0x2	/* default clock divisor */
210238367Sjkim#define	BHND_PCIE_MDIOCTL_PREAM_EN		0x80	/* enable preamble mode */
211238367Sjkim#define	BHND_PCIE_MDIOCTL_DONE			0x100	/* tranaction completed */
212238367Sjkim
213238367Sjkim/* PCIe BHND_PCIE_MDIO_DATA Data */
214306536Sjkim#define	BHND_PCIE_MDIODATA_PHYADDR_MASK		0x0f800000	/* phy addr */
215238367Sjkim#define	BHND_PCIE_MDIODATA_PHYADDR_SHIFT	23
216238367Sjkim#define	BHND_PCIE_MDIODATA_REGADDR_MASK		0x007c0000	/* reg/dev addr */
217306536Sjkim#define	BHND_PCIE_MDIODATA_REGADDR_SHIFT	18
218306536Sjkim#define	BHND_PCIE_MDIODATA_DATA_MASK		0x0000ffff	/* data  */
219238367Sjkim
220306536Sjkim#define	BHND_PCIE_MDIODATA_TA			0x00020000	/* slave turnaround time */
221306536Sjkim#define	BHND_PCIE_MDIODATA_START		0x40000000	/* start of transaction */
222306536Sjkim#define	BHND_PCIE_MDIODATA_CMD_WRITE		0x10000000	/* write command */
223306536Sjkim#define	BHND_PCIE_MDIODATA_CMD_READ		0x20000000	/* read command */
224238367Sjkim
225238367Sjkim#define	BHND_PCIE_MDIODATA_ADDR(_phyaddr, _regaddr)	(		\
226238367Sjkim	(((_phyaddr) << BHND_PCIE_MDIODATA_PHYADDR_SHIFT) &		\
227238367Sjkim	    BHND_PCIE_MDIODATA_PHYADDR_MASK) |				\
228250838Sjkim	(((_regaddr) << BHND_PCIE_MDIODATA_REGADDR_SHIFT) &		\
229238367Sjkim	    BHND_PCIE_MDIODATA_REGADDR_MASK)				\
230306536Sjkim)
231306536Sjkim
232306536Sjkim/* PCIE protocol PHY diagnostic registers */
233306536Sjkim#define	BHND_PCIE_PLP_MODEREG			0x200	/* Mode */
234306536Sjkim#define	BHND_PCIE_PLP_STATUSREG			0x204	/* Status */
235306536Sjkim#define	BHND_PCIE_PLP_LTSSMCTRLREG		0x208	/* LTSSM control */
236306536Sjkim#define	BHND_PCIE_PLP_LTLINKNUMREG		0x20c	/* Link Training Link number */
237238367Sjkim#define	BHND_PCIE_PLP_LTLANENUMREG		0x210	/* Link Training Lane number */
238238367Sjkim#define	BHND_PCIE_PLP_LTNFTSREG			0x214	/* Link Training N_FTS */
239238367Sjkim#define	BHND_PCIE_PLP_ATTNREG			0x218	/* Attention */
240238367Sjkim#define	BHND_PCIE_PLP_ATTNMASKREG		0x21C	/* Attention Mask */
241238367Sjkim#define	BHND_PCIE_PLP_RXERRCTR			0x220	/* Rx Error */
242238367Sjkim#define	BHND_PCIE_PLP_RXFRMERRCTR		0x224	/* Rx Framing Error */
243238367Sjkim#define	BHND_PCIE_PLP_RXERRTHRESHREG		0x228	/* Rx Error threshold */
244306536Sjkim#define	BHND_PCIE_PLP_TESTCTRLREG		0x22C	/* Test Control reg */
245306536Sjkim#define	BHND_PCIE_PLP_SERDESCTRLOVRDREG		0x230	/* SERDES Control Override */
246306536Sjkim#define	BHND_PCIE_PLP_TIMINGOVRDREG		0x234	/* Timing param override */
247306536Sjkim#define	BHND_PCIE_PLP_RXTXSMDIAGREG		0x238	/* RXTX State Machine Diag */
248306536Sjkim#define	BHND_PCIE_PLP_LTSSMDIAGREG		0x23C	/* LTSSM State Machine Diag */
249306536Sjkim
250306536Sjkim/* PCIE protocol DLLP diagnostic registers */
251306536Sjkim#define	BHND_PCIE_DLLP_LCREG			0x100	/* Link Control */
252306536Sjkim#define	  BHND_PCIE_DLLP_LCREG_PCIPM_EN		0x40	/* Enable PCI-PM power management */
253306536Sjkim#define	BHND_PCIE_DLLP_LSREG			0x104	/* Link Status */
254306536Sjkim#define	BHND_PCIE_DLLP_LAREG			0x108	/* Link Attention */
255306536Sjkim#define	BHND_PCIE_DLLP_LAMASKREG		0x10C	/* Link Attention Mask */
256306536Sjkim#define	BHND_PCIE_DLLP_NEXTTXSEQNUMREG		0x110	/* Next Tx Seq Num */
257306536Sjkim#define	BHND_PCIE_DLLP_ACKEDTXSEQNUMREG		0x114	/* Acked Tx Seq Num */
258306536Sjkim#define	BHND_PCIE_DLLP_PURGEDTXSEQNUMREG	0x118	/* Purged Tx Seq Num */
259306536Sjkim#define	BHND_PCIE_DLLP_RXSEQNUMREG		0x11C	/* Rx Sequence Number */
260306536Sjkim#define	BHND_PCIE_DLLP_LRREG			0x120	/* Link Replay */
261238367Sjkim#define	BHND_PCIE_DLLP_LACKTOREG		0x124	/* Link Ack Timeout */
262238367Sjkim#define	BHND_PCIE_DLLP_PMTHRESHREG		0x128	/* Power Management Threshold */
263238367Sjkim#define	  BHND_PCIE_L0THRESHOLDTIME_MASK	0xFF00	/* bits 0 - 7 */
264306536Sjkim#define	  BHND_PCIE_L1THRESHOLDTIME_MASK	0xFF00	/* bits 8 - 15 */
265306536Sjkim#define	  BHND_PCIE_L1THRESHOLDTIME_SHIFT	8	/* PCIE_L1THRESHOLDTIME_SHIFT */
266306536Sjkim#define	  BHND_PCIE_L1THRESHOLD_WARVAL		0x72	/* WAR value */
267306536Sjkim#define	  BHND_PCIE_ASPMTIMER_EXTEND		0x1000000 /* > rev7: enable extend ASPM timer */
268306536Sjkim#define	BHND_PCIE_DLLP_RTRYWPREG		0x12C	/* Retry buffer write ptr */
269306536Sjkim#define	BHND_PCIE_DLLP_RTRYRPREG		0x130	/* Retry buffer Read ptr */
270306536Sjkim#define	BHND_PCIE_DLLP_RTRYPPREG		0x134	/* Retry buffer Purged ptr */
271306536Sjkim#define	BHND_PCIE_DLLP_RTRRWREG			0x138	/* Retry buffer Read/Write */
272306536Sjkim#define	BHND_PCIE_DLLP_ECTHRESHREG		0x13C	/* Error Count Threshold */
273306536Sjkim#define	BHND_PCIE_DLLP_TLPERRCTRREG		0x140	/* TLP Error Counter */
274306536Sjkim#define	BHND_PCIE_DLLP_ERRCTRREG		0x144	/* Error Counter */
275238367Sjkim#define	BHND_PCIE_DLLP_NAKRXCTRREG		0x148	/* NAK Received Counter */
276306536Sjkim#define	BHND_PCIE_DLLP_TESTREG			0x14C	/* Test */
277306536Sjkim#define	BHND_PCIE_DLLP_PKTBIST			0x150	/* Packet BIST */
278306536Sjkim#define	BHND_PCIE_DLLP_PCIE11			0x154	/* DLLP PCIE 1.1 reg */
279306536Sjkim
280306536Sjkim#define	BHND_PCIE_DLLP_LSREG_LINKUP		(1 << 16)
281238367Sjkim
282238367Sjkim/* PCIE protocol TLP diagnostic registers */
283238367Sjkim#define	BHND_PCIE_TLP_CONFIGREG			0x000	/* Configuration */
284238367Sjkim#define	BHND_PCIE_TLP_WORKAROUNDSREG		0x004	/* TLP Workarounds */
285238367Sjkim#define	  BHND_PCIE_TLP_WORKAROUND_URBIT	0x8	/* If enabled, UR status bit is set
286238367Sjkim							 * on memory access of an unmatched
287238367Sjkim							 * address */
288238367Sjkim
289281075Sdim#define	BHND_PCIE_TLP_WRDMAUPPER		0x010	/* Write DMA Upper Address */
290281075Sdim#define	BHND_PCIE_TLP_WRDMALOWER		0x014	/* Write DMA Lower Address */
291281075Sdim#define	BHND_PCIE_TLP_WRDMAREQ_LBEREG		0x018	/* Write DMA Len/ByteEn Req */
292281075Sdim#define	BHND_PCIE_TLP_RDDMAUPPER		0x01C	/* Read DMA Upper Address */
293281075Sdim#define	BHND_PCIE_TLP_RDDMALOWER		0x020	/* Read DMA Lower Address */
294281075Sdim#define	BHND_PCIE_TLP_RDDMALENREG		0x024	/* Read DMA Len Req */
295281075Sdim#define	BHND_PCIE_TLP_MSIDMAUPPER		0x028	/* MSI DMA Upper Address */
296281075Sdim#define	BHND_PCIE_TLP_MSIDMALOWER		0x02C	/* MSI DMA Lower Address */
297281075Sdim#define	BHND_PCIE_TLP_MSIDMALENREG		0x030	/* MSI DMA Len Req */
298281075Sdim#define	BHND_PCIE_TLP_SLVREQLENREG		0x034	/* Slave Request Len */
299281075Sdim#define	BHND_PCIE_TLP_FCINPUTSREQ		0x038	/* Flow Control Inputs */
300281075Sdim#define	BHND_PCIE_TLP_TXSMGRSREQ		0x03C	/* Tx StateMachine and Gated Req */
301281075Sdim#define	BHND_PCIE_TLP_ADRACKCNTARBLEN		0x040	/* Address Ack XferCnt and ARB Len */
302281075Sdim#define	BHND_PCIE_TLP_DMACPLHDR0		0x044	/* DMA Completion Hdr 0 */
303281075Sdim#define	BHND_PCIE_TLP_DMACPLHDR1		0x048	/* DMA Completion Hdr 1 */
304281075Sdim#define	BHND_PCIE_TLP_DMACPLHDR2		0x04C	/* DMA Completion Hdr 2 */
305281075Sdim#define	BHND_PCIE_TLP_DMACPLMISC0		0x050	/* DMA Completion Misc0 */
306281075Sdim#define	BHND_PCIE_TLP_DMACPLMISC1		0x054	/* DMA Completion Misc1 */
307281075Sdim#define	BHND_PCIE_TLP_DMACPLMISC2		0x058	/* DMA Completion Misc2 */
308281075Sdim#define	BHND_PCIE_TLP_SPTCTRLLEN		0x05C	/* Split Controller Req len */
309281075Sdim#define	BHND_PCIE_TLP_SPTCTRLMSIC0		0x060	/* Split Controller Misc 0 */
310281075Sdim#define	BHND_PCIE_TLP_SPTCTRLMSIC1		0x064	/* Split Controller Misc 1 */
311281075Sdim#define	BHND_PCIE_TLP_BUSDEVFUNC		0x068	/* Bus/Device/Func */
312281075Sdim#define	BHND_PCIE_TLP_RESETCTR			0x06C	/* Reset Counter */
313281075Sdim#define	BHND_PCIE_TLP_RTRYBUF			0x070	/* Retry Buffer value */
314281075Sdim#define	BHND_PCIE_TLP_TGTDEBUG1			0x074	/* Target Debug Reg1 */
315281075Sdim#define	BHND_PCIE_TLP_TGTDEBUG2			0x078	/* Target Debug Reg2 */
316281075Sdim#define	BHND_PCIE_TLP_TGTDEBUG3			0x07C	/* Target Debug Reg3 */
317281075Sdim#define	BHND_PCIE_TLP_TGTDEBUG4			0x080	/* Target Debug Reg4 */
318306536Sjkim
319281075Sdim
320281075Sdim/*
321281075Sdim * PCIe-G1 SerDes MDIO Registers (>= rev10)
322306536Sjkim */
323281075Sdim#define BHND_PCIE_PHYADDR_SD		0x0	/* serdes PHY address */
324281075Sdim#define	BHND_PCIE_DEVAD_SD		0x1	/* serdes pseudo-devad (PMA) recognized by
325281075Sdim						   the bhnd_mdio_pcie driver */
326281075Sdim
327281075Sdim#define	BHND_PCIE_SD_ADDREXT		0x1F	/* serdes address extension register */
328281075Sdim#define	BHND_PCIE_SD_ADDREXT_BLK_MASK	0xFFF0	/* register block mask */
329281075Sdim#define	BHND_PCIE_SD_ADDREXT_REG_MASK	0x000F	/* register address mask */
330281075Sdim
331281075Sdim#define	BHND_PCIE_SD_REGS_IEEE0		0x0000	/* IEEE0 AN CTRL block */
332281075Sdim#define	BHND_PCIE_SD_REGS_IEEE1		0x0010	/* IEEE1 AN ADV block */
333281075Sdim#define	BHND_PCIE_SD_REGS_BLK0		0x8000	/* ??? */
334281075Sdim#define	BHND_PCIE_SD_REGS_BLK1		0x8010	/* ??? */
335281075Sdim#define	BHND_PCIE_SD_REGS_BLK2		0x8020	/* ??? */
336238367Sjkim#define	BHND_PCIE_SD_REGS_BLK3		0x8030	/* ??? */
337238367Sjkim#define	BHND_PCIE_SD_REGS_BLK4		0x8040	/* ??? */
338238367Sjkim#define	BHND_PCIE_SD_REGS_TXPLL		0x8080	/* TXPLL register block */
339238367Sjkim#define	BHND_PCIE_SD_REGS_TXCTRL0		0x8200	/* ??? */
340238367Sjkim#define	BHND_PCIE_SD_REGS_SERDESID		0x8310	/* ??? */
341238367Sjkim#define	BHND_PCIE_SD_REGS_RXCTRL0		0x8400	/* ??? */
342238367Sjkim
343238367Sjkim/*
344238367Sjkim * PCIe-G1 SerDes-R9 MDIO Registers (<= rev9)
345238367Sjkim *
346241973Sjkim * These register definitions appear to match those provided in the
347238367Sjkim * "PCI Express SerDes Registers" section of the BCM5761 Ethernet Controller
348238367Sjkim * Programmer's Reference Guide.
349238367Sjkim */
350238367Sjkim#define	BHND_PCIE_PHY_SDR9_PLL       		0x1C	/* SerDes PLL PHY Address*/
351238367Sjkim#define	  BHND_PCIE_SDR9_PLL_CTRL		0x17	/* PLL control reg */
352238367Sjkim#define	    BHND_PCIE_SDR9_PLL_CTRL_FREQDET_EN	0x4000	/* bit 14 is FREQDET on */
353238367Sjkim#define	BHND_PCIE_PHY_SDR9_TXRX       	 	0x0F	/* SerDes RX/TX PHY Address */
354238367Sjkim
355238367Sjkim#define	BHND_PCIE_SDR9_RX_CTRL			0x11	/* RX ctrl register */
356238367Sjkim#define	    BHND_PCIE_SDR9_RX_CTRL_FORCE	0x80	/* rxpolarity_force */
357238367Sjkim#define	    BHND_PCIE_SDR9_RX_CTRL_POLARITY_INV	0x40	/* rxpolarity_value (if set, inverse polarity) */
358238367Sjkim
359238367Sjkim#define	BHND_PCIE_SDR9_RX_CDR			0x16	/* RX CDR ctrl register */
360238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDR_FREQ_OVR_EN	0x0100	/* freq_override_en flag */
361238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDR_FREQ_OVR_MASK	0x00FF	/* freq_override_val */
362238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDR_FREQ_OVR_SHIFT	0
363238367Sjkim
364238367Sjkim#define	BHND_PCIE_SDR9_RX_CDRBW			0x17	/* RX CDR bandwidth (PLL tuning) */
365238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_INTGTRK_MASK	0x7000	/* integral loop bandwidth (phase tracking mode) */
366238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_INTGTRK_SHIFT	11
367238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_INTGACQ_MASK	0x0700	/* integral loop bandwidth (phase acquisition mode) */
368238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_INTGACQ_SHIFT	8
369238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_PROPTRK_MASK	0x0070	/* proportional loop bandwidth (phase tracking mode) */
370238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_PROPTRK_SHIFT	4
371238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_PROPACQ_MASK	0x0007	/* proportional loop bandwidth (phase acquisition mode) */
372238367Sjkim#define	  BHND_PCIE_SDR9_RX_CDRBW_PROPACQ_SHIFT	0
373238367Sjkim
374238367Sjkim#define	BHND_PCIE_SDR9_RX_TIMER1		0x12	/* timer1 register */
375238367Sjkim#define	  BHND_PCIE_SDR9_RX_TIMER1_LKTRK_MASK	0xFF00	/* phase tracking delay before asserting RX seq completion (in 16ns units) */
376238367Sjkim#define	  BHND_PCIE_SDR9_RX_TIMER1_LKTRK_SHIFT	8
377238367Sjkim#define	  BHND_PCIE_SDR9_RX_TIMER1_LKACQ_MASK	0x00FF	/* phase acquisition mode time (in 1024ns units) */
378238367Sjkim#define	  BHND_PCIE_SDR9_RX_TIMER1_LKACQ_SHIFT	0
379306536Sjkim
380281075Sdim
381281075Sdim/* SPROM offsets */
382281075Sdim#define	BHND_PCIE_SRSH_PI_OFFSET		BHND_PCI_SRSH_PI_OFFSET	/**< PCI core index in SROM shadow area */
383306536Sjkim#define	BHND_PCIE_SRSH_PI_MASK			BHND_PCI_SRSH_PI_MASK
384306536Sjkim#define	BHND_PCIE_SRSH_PI_SHIFT			BHND_PCI_SRSH_PI_SHIFT
385281075Sdim
386281075Sdim#define	BHND_PCIE_SRSH_ASPM_OFFSET		8	/* word 4 */
387238367Sjkim#define	BHND_PCIE_SRSH_ASPM_ENB			0x18	/* bit 3, 4 */
388238367Sjkim#define	BHND_PCIE_SRSH_ASPM_L1_ENB		0x10	/* bit 4 */
389238367Sjkim#define	BHND_PCIE_SRSH_ASPM_L0s_ENB		0x8	/* bit 3 */
390238367Sjkim#define	BHND_PCIE_SRSH_PCIE_MISC_CONFIG		10	/* word 5 */
391238367Sjkim#define	BHND_PCIE_SRSH_L23READY_EXIT_NOPRST	0x8000	/* bit 15 */
392281075Sdim#define	BHND_PCIE_SRSH_CLKREQ_OFFSET_REV5	40	/* word 20 for srom rev <= 5 */
393281075Sdim#define	BHND_PCIE_SRSH_CLKREQ_OFFSET_REV8	104	/* word 52 for srom rev 8 */
394281075Sdim#define	BHND_PCIE_SRSH_CLKREQ_ENB		0x0800	/* bit 11 */
395281075Sdim#define	BHND_PCIE_SRSH_BD_OFFSET		12	/* word 6 */
396306536Sjkim#define	BHND_PCIE_SRSH_AUTOINIT_OFFSET		36	/* auto initialization enable */
397306536Sjkim
398281075Sdim/* Linkcontrol reg offset in PCIE Cap */
399281075Sdim#define	BHND_PCIE_CAP_LINKCTRL_OFFSET		16	/* linkctrl offset in pcie cap */
400281075Sdim#define	BHND_PCIE_CAP_LCREG_ASPML0s		0x01	/* ASPM L0s in linkctrl */
401281075Sdim#define	BHND_PCIE_CAP_LCREG_ASPML1		0x02	/* ASPM L1 in linkctrl */
402281075Sdim#define	BHND_PCIE_CLKREQ_ENAB			0x100	/* CLKREQ Enab in linkctrl */
403238367Sjkim
404238367Sjkim#define	BHND_PCIE_ASPM_ENAB			3	/* ASPM L0s & L1 in linkctrl */
405238367Sjkim#define	BHND_PCIE_ASPM_L1_ENAB			2	/* ASPM L0s & L1 in linkctrl */
406238367Sjkim#define	BHND_PCIE_ASPM_L0s_ENAB			1	/* ASPM L0s & L1 in linkctrl */
407238367Sjkim#define	BHND_PCIE_ASPM_DISAB			0	/* ASPM L0s & L1 in linkctrl */
408238367Sjkim
409238367Sjkim/* Status reg PCIE_PLP_STATUSREG */
410306536Sjkim#define	BHND_PCIE_PLP_POLARITY_INV		0x10	/* lane polarity is inverted */
411238367Sjkim
412238367Sjkim#endif /* _BHND_CORES_PCI_BHND_PCIREG_H_ */
413238367Sjkim