• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * BCM43XX PCIE core hardware definitions.
3  *
4  * Copyright (C) 1999-2017, Broadcom Corporation
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *      Notwithstanding the above, under no circumstances may you combine this
21  * software in any way with any other Broadcom software provided under a license
22  * other than the GPL, without Broadcom's express prior written consent.
23  *
24  *
25  * <<Broadcom-WL-IPTag/Open:>>
26  *
27  * $Id: pcie_core.h 673814 2016-12-05 06:10:24Z $
28  */
29 #ifndef    _PCIE_CORE_H
30 #define    _PCIE_CORE_H
31 
32 #include <sbhnddma.h>
33 #include <siutils.h>
34 
35 /* cpp contortions to concatenate w/arg prescan */
36 #ifndef PAD
37 #define    _PADLINE(line)    pad ## line
38 #define    _XSTR(line)    _PADLINE(line)
39 #define    PAD        _XSTR(__LINE__)
40 #endif
41 
42 /* PCIE Enumeration space offsets */
43 #define  PCIE_CORE_CONFIG_OFFSET    0x0
44 #define  PCIE_FUNC0_CONFIG_OFFSET    0x400
45 #define  PCIE_FUNC1_CONFIG_OFFSET    0x500
46 #define  PCIE_FUNC2_CONFIG_OFFSET    0x600
47 #define  PCIE_FUNC3_CONFIG_OFFSET    0x700
48 #define  PCIE_SPROM_SHADOW_OFFSET    0x800
49 #define  PCIE_SBCONFIG_OFFSET        0xE00
50 
51 
52 #define PCIEDEV_MAX_DMAS            4
53 
54 /* PCIE Bar0 Address Mapping. Each function maps 16KB config space */
55 #define PCIE_DEV_BAR0_SIZE        0x4000
56 #define PCIE_BAR0_WINMAPCORE_OFFSET    0x0
57 #define PCIE_BAR0_EXTSPROM_OFFSET    0x1000
58 #define PCIE_BAR0_PCIECORE_OFFSET    0x2000
59 #define PCIE_BAR0_CCCOREREG_OFFSET    0x3000
60 
61 /* different register spaces to access thr'u pcie indirect access */
62 #define PCIE_CONFIGREGS        1        /* Access to config space */
63 #define PCIE_PCIEREGS        2        /* Access to pcie registers */
64 
65 #define PCIEDEV_HOSTADDR_MAP_BASE     0x8000000
66 #define PCIEDEV_HOSTADDR_MAP_WIN_MASK 0xFC000000
67 
68 /* dma regs to control the flow between host2dev and dev2host  */
69 typedef volatile struct pcie_devdmaregs {
70     dma64regs_t    tx;
71     uint32        PAD[2];
72     dma64regs_t    rx;
73     uint32        PAD[2];
74 } pcie_devdmaregs_t;
75 
76 #define PCIE_DB_HOST2DEV_0        0x1
77 #define PCIE_DB_HOST2DEV_1        0x2
78 #define PCIE_DB_DEV2HOST_0        0x3
79 #define PCIE_DB_DEV2HOST_1        0x4
80 
81 /* door bell register sets */
82 typedef struct pcie_doorbell {
83     uint32        host2dev_0;
84     uint32        host2dev_1;
85     uint32        dev2host_0;
86     uint32        dev2host_1;
87 } pcie_doorbell_t;
88 
89 /* Flow Ring Manager */
90 #define IFRM_FR_IDX_MAX    256
91 #define IFRM_FR_GID_MAX 4
92 #define IFRM_FR_DEV_MAX 8
93 #define IFRM_FR_TID_MAX 8
94 #define IFRM_FR_DEV_VALID 2
95 
96 #define IFRM_VEC_REG_BITS    32
97 
98 #define IFRM_FR_PER_VECREG            4
99 #define IFRM_FR_PER_VECREG_SHIFT    2
100 #define IFRM_FR_PER_VECREG_MASK        ((0x1 << IFRM_FR_PER_VECREG_SHIFT) - 1)
101 
102 #define IFRM_VEC_BITS_PER_FR    (IFRM_VEC_REG_BITS/IFRM_FR_PER_VECREG)
103 
104 /* IFRM_DEV_0 : d11AC, IFRM_DEV_1 : d11AD */
105 #define IFRM_DEV_0    0
106 #define IFRM_DEV_1    1
107 
108 #define IFRM_FR_GID_0 0
109 #define IFRM_FR_GID_1 1
110 #define IFRM_FR_GID_2 2
111 #define IFRM_FR_GID_3 3
112 
113 #define IFRM_TIDMASK 0xffffffff
114 
115 /* ifrm_ctrlst register */
116 #define IFRM_EN (1<<0)
117 #define IFRM_BUFF_INIT_DONE (1<<1)
118 #define IFRM_COMPARE_EN0 (1<<4)
119 #define IFRM_COMPARE_EN1 (1<<5)
120 #define IFRM_COMPARE_EN2 (1<<6)
121 #define IFRM_COMPARE_EN3 (1<<7)
122 #define IFRM_INIT_DV0 (1<<8)
123 #define IFRM_INIT_DV1 (1<<9)
124 #define IFRM_INIT_DV2 (1<<10)
125 #define IFRM_INIT_DV3 (1<<11)
126 
127 /* ifrm_msk_arr.addr, ifrm_tid_arr.addr register */
128 #define IFRM_ADDR_SHIFT 0
129 #define IFRM_FRG_ID_SHIFT 8
130 
131 /* ifrm_vec.diff_lat register */
132 #define IFRM_DV_LAT            (1<<0)
133 #define IFRM_DV_LAT_DONE    (1<<1)
134 #define IFRM_SDV_OFFSET_SHIFT    4
135 #define IFRM_SDV_FRGID_SHIFT    8
136 #define IFRM_VECSTAT_MASK        0x3
137 #define IFRM_VEC_MASK            0xff
138 
139 /* idma frm array */
140 typedef struct pcie_ifrm_array {
141     uint32        addr;
142     uint32        data;
143 } pcie_ifrm_array_t;
144 
145 /* idma frm vector */
146 typedef struct pcie_ifrm_vector {
147     uint32        diff_lat;
148     uint32        sav_tid;
149     uint32        sav_diff;
150     uint32        PAD[1];
151 } pcie_ifrm_vector_t;
152 
153 /* idma frm interrupt */
154 typedef struct pcie_ifrm_intr {
155     uint32        intstat;
156     uint32        intmask;
157 } pcie_ifrm_intr_t;
158 
159 /* SB side: PCIE core and host control registers */
160 typedef volatile struct sbpcieregs {
161     uint32 control;        /* host mode only */
162     uint32 iocstatus;    /* PCIE2: iostatus */
163     uint32 PAD[1];
164     uint32 biststatus;    /* bist Status: 0x00C */
165     uint32 gpiosel;        /* PCIE gpio sel: 0x010 */
166     uint32 gpioouten;    /* PCIE gpio outen: 0x14 */
167     uint32 PAD[2];
168     uint32 intstatus;    /* Interrupt status: 0x20 */
169     uint32 intmask;        /* Interrupt mask: 0x24 */
170     uint32 sbtopcimailbox;    /* sb to pcie mailbox: 0x028 */
171     uint32 obffcontrol;    /* PCIE2: 0x2C */
172     uint32 obffintstatus;    /* PCIE2: 0x30 */
173     uint32 obffdatastatus;    /* PCIE2: 0x34 */
174     uint32 PAD[1];
175     uint32 ctoctrl;        /* PCIE2: 0x3C */
176     uint32 errlog;        /* PCIE2: 0x40 */
177     uint32 errlogaddr;    /* PCIE2: 0x44 */
178     uint32 mailboxint;    /* PCIE2: 0x48 */
179     uint32 mailboxintmsk; /* PCIE2: 0x4c */
180     uint32 ltrspacing;    /* PCIE2: 0x50 */
181     uint32 ltrhysteresiscnt;    /* PCIE2: 0x54 */
182     uint32 msivectorassign;    /* PCIE2: 0x58 */
183     uint32 intmask2;    /* PCIE2: 0x5C */
184     uint32 PAD[40];
185     uint32 sbtopcie0;    /* sb to pcie translation 0: 0x100 */
186     uint32 sbtopcie1;    /* sb to pcie translation 1: 0x104 */
187     uint32 sbtopcie2;    /* sb to pcie translation 2: 0x108 */
188     uint32 PAD[5];
189 
190     /* pcie core supports in direct access to config space */
191     uint32 configaddr;    /* pcie config space access: Address field: 0x120 */
192     uint32 configdata;    /* pcie config space access: Data field: 0x124 */
193     union {
194         struct {
195             /* mdio access to serdes */
196             uint32 mdiocontrol;    /* controls the mdio access: 0x128 */
197             uint32 mdiodata;    /* Data to the mdio access: 0x12c */
198             /* pcie protocol phy/dllp/tlp register indirect access mechanism */
199             uint32 pcieindaddr; /* indirect access to the internal register: 0x130 */
200             uint32 pcieinddata;    /* Data to/from the internal regsiter: 0x134 */
201             uint32 clkreqenctrl;    /* >= rev 6, Clkreq rdma control : 0x138 */
202             uint32 PAD[177];
203             /* 0x400 - 0x7FF, PCIE Cfg Space, note: not used anymore in PcieGen2 */
204             uint32 pciecfg[4][64];
205         } pcie1;
206         struct {
207             /* mdio access to serdes */
208             uint32 mdiocontrol;    /* controls the mdio access: 0x128 */
209             uint32 mdiowrdata;    /* write data to mdio 0x12C */
210             uint32 mdiorddata;    /* read data to mdio 0x130 */
211             uint32    PAD[3];     /* 0x134-0x138-0x13c */
212             /* door bell registers available from gen2 rev5 onwards */
213             pcie_doorbell_t       dbls[PCIEDEV_MAX_DMAS]; /* 0x140 - 0x17F */
214             uint32    dataintf;    /* 0x180 */
215             uint32  PAD[1];        /* 0x184 */
216             uint32    d2h_intrlazy_0; /* 0x188 */
217             uint32    h2d_intrlazy_0; /* 0x18c */
218             uint32  h2d_intstat_0;  /* 0x190 */
219             uint32  h2d_intmask_0;    /* 0x194 */
220             uint32  d2h_intstat_0;  /* 0x198 */
221             uint32  d2h_intmask_0;  /* 0x19c */
222             uint32    ltr_state;    /* 0x1A0 */
223             uint32    pwr_int_status;    /* 0x1A4 */
224             uint32    pwr_int_mask;    /* 0x1A8 */
225             uint32    pme_source; /* 0x1AC */
226             uint32    err_hdr_logreg1; /* 0x1B0 */
227             uint32    err_hdr_logreg2; /* 0x1B4 */
228             uint32    err_hdr_logreg3; /* 0x1B8 */
229             uint32    err_hdr_logreg4; /* 0x1BC */
230             uint32    err_code_logreg; /* 0x1C0 */
231             uint32  PAD[7]; /* 0x1C4 - 0x1DF */
232             uint32  clk_ctl_st;    /* 0x1E0 */
233             uint32  PAD[1];        /* 0x1E4 */
234             uint32    powerctl;    /* 0x1E8 */
235             uint32  PAD[5];        /* 0x1EC - 0x1FF */
236             pcie_devdmaregs_t  h2d0_dmaregs; /* 0x200 - 0x23c */
237             pcie_devdmaregs_t  d2h0_dmaregs; /* 0x240 - 0x27c */
238             pcie_devdmaregs_t  h2d1_dmaregs; /* 0x280 - 0x2bc */
239             pcie_devdmaregs_t  d2h1_dmaregs; /* 0x2c0 - 0x2fc */
240             pcie_devdmaregs_t  h2d2_dmaregs; /* 0x300 - 0x33c */
241             pcie_devdmaregs_t  d2h2_dmaregs; /* 0x340 - 0x37c */
242             pcie_devdmaregs_t  h2d3_dmaregs; /* 0x380 - 0x3bc */
243             pcie_devdmaregs_t  d2h3_dmaregs; /* 0x3c0 - 0x3fc */
244             uint32    d2h_intrlazy_1; /* 0x400 */
245             uint32    h2d_intrlazy_1; /* 0x404 */
246             uint32    h2d_intstat_1;    /* 0x408 */
247             uint32    h2d_intmask_1;    /* 0x40c */
248             uint32    d2h_intstat_1;    /* 0x410 */
249             uint32    d2h_intmask_1;    /* 0x414 */
250             uint32    PAD[2];            /* 0x418 - 0x41C */
251             uint32    d2h_intrlazy_2; /* 0x420 */
252             uint32    h2d_intrlazy_2; /* 0x424 */
253             uint32    h2d_intstat_2;    /* 0x428 */
254             uint32    h2d_intmask_2;    /* 0x42c */
255             uint32    d2h_intstat_2;    /* 0x430 */
256             uint32    d2h_intmask_2;    /* 0x434 */
257             uint32    PAD[10];        /* 0x438 - 0x45F */
258             uint32    ifrm_ctrlst;    /* 0x460 */
259             uint32    PAD[1];            /* 0x464 */
260             pcie_ifrm_array_t    ifrm_msk_arr;        /* 0x468 - 0x46F */
261             pcie_ifrm_array_t    ifrm_tid_arr[IFRM_FR_DEV_VALID];
262                 /* 0x470 - 0x47F */
263             pcie_ifrm_vector_t    ifrm_vec[IFRM_FR_DEV_MAX];
264                 /* 0x480 - 0x4FF */
265             pcie_ifrm_intr_t    ifrm_intr[IFRM_FR_DEV_MAX];
266                 /* 0x500 - 0x53F */
267             uint32    PAD[48];        /* 0x540 - 0x5FF */
268             uint32    PAD[2][64];        /* 0x600 - 0x7FF */
269         } pcie2;
270     } u;
271     uint16    sprom[64];        /* SPROM shadow Area : 0x800 - 0x880 */
272     uint32    PAD[96];        /* 0x880 - 0x9FF */
273     /* direct memory access (pcie2 rev19 and after) : 0xA00 - 0xAFF */
274     uint32        PAD[16];    /* 0xA00 - 0xA3F */
275     uint32        dm_errlog;    /* 0xA40 */
276     uint32        dm_erraddr;    /* 0xA44 */
277     uint32        PAD[37];    /* 0xA48 - 0xADC */
278     uint32        dm_clk_ctl_st;    /* 0xAE0 */
279     uint32        PAD[1];        /* 0xAE4 */
280     uint32        dm_powerctl;    /* 0xAE8 */
281 } sbpcieregs_t;
282 
283 #define PCIE_CFG_DA_OFFSET 0x400    /* direct access register offset for configuration space */
284 
285 /* PCI control */
286 #define PCIE_RST_OE    0x01    /* When set, drives PCI_RESET out to pin */
287 #define PCIE_RST    0x02    /* Value driven out to pin */
288 #define PCIE_SPERST    0x04    /* SurvivePeRst */
289 #define PCIE_FORCECFGCLKON_ALP    0x08
290 #define PCIE_DISABLE_L1CLK_GATING    0x10
291 #define PCIE_DLYPERST    0x100    /* Delay PeRst to CoE Core */
292 #define PCIE_DISSPROMLD    0x200    /* DisableSpromLoadOnPerst */
293 #define PCIE_WakeModeL2    0x1000    /* Wake on L2 */
294 #define PCIE_MULTIMSI_EN        0x2000    /* enable multi-vector MSI messages */
295 #define PCIE_PipeIddqDisable0    0x8000    /* Disable assertion of pcie_pipe_iddq during L1.2 and L2 */
296 #define PCIE_PipeIddqDisable1    0x10000    /* Disable assertion of pcie_pipe_iddq during L2 */
297 #define PCIE_MSI_B2B_EN        0x100000    /* enable back-to-back MSI messages */
298 #define PCIE_MSI_FIFO_CLEAR    0x200000    /* reset MSI FIFO */
299 #define PCIE_IDMA_MODE_EN        0x800000    /* implicit M2M DMA mode */
300 
301 #define    PCIE_CFGADDR    0x120    /* offsetof(configaddr) */
302 #define    PCIE_CFGDATA    0x124    /* offsetof(configdata) */
303 #define PCIE_SWPME_FN0    0x10000
304 #define PCIE_SWPME_FN0_SHF 16
305 
306 /* Interrupt status/mask */
307 #define PCIE_INTA    0x01    /* PCIE INTA message is received */
308 #define PCIE_INTB    0x02    /* PCIE INTB message is received */
309 #define PCIE_INTFATAL    0x04    /* PCIE INTFATAL message is received */
310 #define PCIE_INTNFATAL    0x08    /* PCIE INTNONFATAL message is received */
311 #define PCIE_INTCORR    0x10    /* PCIE INTCORR message is received */
312 #define PCIE_INTPME    0x20    /* PCIE INTPME message is received */
313 #define PCIE_PERST    0x40    /* PCIE Reset Interrupt */
314 
315 #define PCIE_INT_MB_FN0_0 0x0100 /* PCIE to SB Mailbox int Fn0.0 is received */
316 #define PCIE_INT_MB_FN0_1 0x0200 /* PCIE to SB Mailbox int Fn0.1 is received */
317 #define PCIE_INT_MB_FN1_0 0x0400 /* PCIE to SB Mailbox int Fn1.0 is received */
318 #define PCIE_INT_MB_FN1_1 0x0800 /* PCIE to SB Mailbox int Fn1.1 is received */
319 #define PCIE_INT_MB_FN2_0 0x1000 /* PCIE to SB Mailbox int Fn2.0 is received */
320 #define PCIE_INT_MB_FN2_1 0x2000 /* PCIE to SB Mailbox int Fn2.1 is received */
321 #define PCIE_INT_MB_FN3_0 0x4000 /* PCIE to SB Mailbox int Fn3.0 is received */
322 #define PCIE_INT_MB_FN3_1 0x8000 /* PCIE to SB Mailbox int Fn3.1 is received */
323 
324 /* PCIE MSI Vector Assignment register */
325 #define MSIVEC_MB_0    (0x1 << 1) /* MSI Vector offset for mailbox0 is 2 */
326 #define MSIVEC_MB_1    (0x1 << 2) /* MSI Vector offset for mailbox1 is 3 */
327 #define MSIVEC_D2H0_DB0    (0x1 << 3) /* MSI Vector offset for interface0 door bell 0 is 4 */
328 #define MSIVEC_D2H0_DB1    (0x1 << 4) /* MSI Vector offset for interface0 door bell 1 is 5 */
329 
330 /* PCIE MailboxInt/MailboxIntMask register */
331 #define PCIE_MB_TOSB_FN0_0       0x0001 /* write to assert PCIEtoSB Mailbox interrupt */
332 #define PCIE_MB_TOSB_FN0_1       0x0002
333 #define PCIE_MB_TOSB_FN1_0       0x0004
334 #define PCIE_MB_TOSB_FN1_1       0x0008
335 #define PCIE_MB_TOSB_FN2_0       0x0010
336 #define PCIE_MB_TOSB_FN2_1       0x0020
337 #define PCIE_MB_TOSB_FN3_0       0x0040
338 #define PCIE_MB_TOSB_FN3_1       0x0080
339 #define PCIE_MB_TOPCIE_FN0_0     0x0100 /* int status/mask for SBtoPCIE Mailbox interrupts */
340 #define PCIE_MB_TOPCIE_FN0_1     0x0200
341 #define PCIE_MB_TOPCIE_FN1_0     0x0400
342 #define PCIE_MB_TOPCIE_FN1_1     0x0800
343 #define PCIE_MB_TOPCIE_FN2_0     0x1000
344 #define PCIE_MB_TOPCIE_FN2_1     0x2000
345 #define PCIE_MB_TOPCIE_FN3_0     0x4000
346 #define PCIE_MB_TOPCIE_FN3_1     0x8000
347 #define    PCIE_MB_TOPCIE_D2H0_DB0    0x10000
348 #define    PCIE_MB_TOPCIE_D2H0_DB1    0x20000
349 #define    PCIE_MB_TOPCIE_D2H1_DB0    0x40000
350 #define    PCIE_MB_TOPCIE_D2H1_DB1    0x80000
351 #define    PCIE_MB_TOPCIE_D2H2_DB0    0x100000
352 #define    PCIE_MB_TOPCIE_D2H2_DB1    0x200000
353 #define    PCIE_MB_TOPCIE_D2H3_DB0    0x400000
354 #define    PCIE_MB_TOPCIE_D2H3_DB1    0x800000
355 
356 #define PCIE_MB_D2H_MB_MASK        \
357     (PCIE_MB_TOPCIE_D2H0_DB0 | PCIE_MB_TOPCIE_D2H0_DB1 |    \
358     PCIE_MB_TOPCIE_D2H1_DB0  | PCIE_MB_TOPCIE_D2H1_DB1 |    \
359     PCIE_MB_TOPCIE_D2H2_DB0  | PCIE_MB_TOPCIE_D2H2_DB1 |    \
360     PCIE_MB_TOPCIE_D2H3_DB0  | PCIE_MB_TOPCIE_D2H3_DB1)
361 
362 #define SBTOPCIE0_BASE 0x08000000
363 #define SBTOPCIE1_BASE 0x0c000000
364 
365 /* On chips with CCI-400, the small pcie 128 MB region base has shifted */
366 #define CCI400_SBTOPCIE0_BASE  0x20000000
367 #define CCI400_SBTOPCIE1_BASE  0x24000000
368 
369 /* SB to PCIE translation masks */
370 #define SBTOPCIE0_MASK    0xfc000000
371 #define SBTOPCIE1_MASK    0xfc000000
372 #define SBTOPCIE2_MASK    0xc0000000
373 
374 /* Access type bits (0:1) */
375 #define SBTOPCIE_MEM    0
376 #define SBTOPCIE_IO    1
377 #define SBTOPCIE_CFG0    2
378 #define SBTOPCIE_CFG1    3
379 
380 /* Prefetch enable bit 2 */
381 #define SBTOPCIE_PF        4
382 
383 /* Write Burst enable for memory write bit 3 */
384 #define SBTOPCIE_WR_BURST    8
385 
386 /* config access */
387 #define CONFIGADDR_FUNC_MASK    0x7000
388 #define CONFIGADDR_FUNC_SHF    12
389 #define CONFIGADDR_REG_MASK    0x0FFF
390 #define CONFIGADDR_REG_SHF    0
391 
392 #define PCIE_CONFIG_INDADDR(f, r)    ((((f) & CONFIGADDR_FUNC_MASK) << CONFIGADDR_FUNC_SHF) | \
393                              (((r) & CONFIGADDR_REG_MASK) << CONFIGADDR_REG_SHF))
394 
395 /* PCIE protocol regs Indirect Address */
396 #define PCIEADDR_PROT_MASK    0x300
397 #define PCIEADDR_PROT_SHF    8
398 #define PCIEADDR_PL_TLP        0
399 #define PCIEADDR_PL_DLLP    1
400 #define PCIEADDR_PL_PLP        2
401 
402 #define    PCIE_CORE_REG_CONTROL        0x00u   /* Control     */
403 #define    PCIE_CORE_REG_IOSTATUS        0x04u   /* IO status   */
404 #define    PCIE_CORE_REG_BITSTATUS        0x0Cu   /* bitstatus   */
405 #define    PCIE_CORE_REG_GPIO_SEL        0x10u   /* gpio sel    */
406 #define    PCIE_CORE_REG_GPIO_OUT_EN    0x14u   /* gpio out en */
407 #define    PCIE_CORE_REG_INT_STATUS    0x20u   /* int status  */
408 #define    PCIE_CORE_REG_INT_MASK        0x24u   /* int mask    */
409 #define    PCIE_CORE_REG_SB_PCIE_MB    0x28u   /* sbpcie mb   */
410 #define    PCIE_CORE_REG_ERRLOG        0x40u   /* errlog      */
411 #define    PCIE_CORE_REG_ERR_ADDR        0x44u   /* errlog addr */
412 #define    PCIE_CORE_REG_MB_INTR        0x48u   /* MB intr     */
413 #define    PCIE_CORE_REG_SB_PCIE_0        0x100u  /* sbpcie0 map */
414 #define    PCIE_CORE_REG_SB_PCIE_1        0x104u  /* sbpcie1 map */
415 #define    PCIE_CORE_REG_SB_PCIE_2        0x108u  /* sbpcie2 map */
416 
417 /* PCIE Config registers */
418 #define    PCIE_CFG_DEV_STS_CTRL_2        0x0d4u    /* "dev_sts_control_2  */
419 #define    PCIE_CFG_ADV_ERR_CAP        0x100u    /* adv_err_cap         */
420 #define    PCIE_CFG_UC_ERR_STS        0x104u    /* uc_err_status       */
421 #define    PCIE_CFG_UC_ERR_MASK        0x108u    /* ucorr_err_mask      */
422 #define    PCIE_CFG_UNCOR_ERR_SERV        0x10cu    /* ucorr_err_sevr      */
423 #define    PCIE_CFG_CORR_ERR_STS        0x110u    /* corr_err_status     */
424 #define    PCIE_CFG_CORR_ERR_MASK        0x114u    /* corr_err_mask       */
425 #define    PCIE_CFG_ADV_ERR_CTRL        0x118u    /* adv_err_cap_control */
426 #define    PCIE_CFG_HDR_LOG1        0x11Cu    /* header_log1         */
427 #define    PCIE_CFG_HDR_LOG2        0x120u    /* header_log2         */
428 #define    PCIE_CFG_HDR_LOG3        0x124u    /* header_log3         */
429 #define    PCIE_CFG_HDR_LOG4        0x128u    /* header_log4         */
430 #define    PCIE_CFG_PML1_SUB_CAP_ID    0x240u    /* PML1sub_capID       */
431 #define    PCIE_CFG_PML1_SUB_CAP_REG    0x244u    /* PML1_sub_Cap_reg    */
432 #define    PCIE_CFG_PML1_SUB_CTRL1        0x248u    /* PML1_sub_control1   */
433 #define    PCIE_CFG_PML1_SUB_CTRL3        0x24Cu    /* PML1_sub_control2   */
434 #define    PCIE_CFG_TL_CTRL_5        0x814u    /* tl_control_5        */
435 #define    PCIE_CFG_PHY_ERR_ATT_VEC    0x1820u    /* phy_err_attn_vec    */
436 #define    PCIE_CFG_PHY_ERR_ATT_MASK    0x1824u    /* phy_err_attn_mask   */
437 
438 /* PCIE protocol PHY diagnostic registers */
439 #define    PCIE_PLP_MODEREG        0x200u /* Mode */
440 #define    PCIE_PLP_STATUSREG        0x204u /* Status */
441 #define PCIE_PLP_LTSSMCTRLREG        0x208u /* LTSSM control */
442 #define PCIE_PLP_LTLINKNUMREG        0x20cu /* Link Training Link number */
443 #define PCIE_PLP_LTLANENUMREG        0x210u /* Link Training Lane number */
444 #define PCIE_PLP_LTNFTSREG        0x214u /* Link Training N_FTS */
445 #define PCIE_PLP_ATTNREG        0x218u /* Attention */
446 #define PCIE_PLP_ATTNMASKREG        0x21Cu /* Attention Mask */
447 #define PCIE_PLP_RXERRCTR        0x220u /* Rx Error */
448 #define PCIE_PLP_RXFRMERRCTR        0x224u /* Rx Framing Error */
449 #define PCIE_PLP_RXERRTHRESHREG        0x228u /* Rx Error threshold */
450 #define PCIE_PLP_TESTCTRLREG        0x22Cu /* Test Control reg */
451 #define PCIE_PLP_SERDESCTRLOVRDREG    0x230u /* SERDES Control Override */
452 #define PCIE_PLP_TIMINGOVRDREG        0x234u /* Timing param override */
453 #define PCIE_PLP_RXTXSMDIAGREG        0x238u /* RXTX State Machine Diag */
454 #define PCIE_PLP_LTSSMDIAGREG        0x23Cu /* LTSSM State Machine Diag */
455 
456 /* PCIE protocol DLLP diagnostic registers */
457 #define PCIE_DLLP_LCREG            0x100u /* Link Control */
458 #define PCIE_DLLP_LSREG            0x104u /* Link Status */
459 #define PCIE_DLLP_LAREG            0x108u /* Link Attention */
460 #define PCIE_DLLP_LAMASKREG        0x10Cu /* Link Attention Mask */
461 #define PCIE_DLLP_NEXTTXSEQNUMREG    0x110u /* Next Tx Seq Num */
462 #define PCIE_DLLP_ACKEDTXSEQNUMREG    0x114u /* Acked Tx Seq Num */
463 #define PCIE_DLLP_PURGEDTXSEQNUMREG    0x118u /* Purged Tx Seq Num */
464 #define PCIE_DLLP_RXSEQNUMREG        0x11Cu /* Rx Sequence Number */
465 #define PCIE_DLLP_LRREG            0x120u /* Link Replay */
466 #define PCIE_DLLP_LACKTOREG        0x124u /* Link Ack Timeout */
467 #define PCIE_DLLP_PMTHRESHREG        0x128u /* Power Management Threshold */
468 #define PCIE_DLLP_RTRYWPREG        0x12Cu /* Retry buffer write ptr */
469 #define PCIE_DLLP_RTRYRPREG        0x130u /* Retry buffer Read ptr */
470 #define PCIE_DLLP_RTRYPPREG        0x134u /* Retry buffer Purged ptr */
471 #define PCIE_DLLP_RTRRWREG        0x138u /* Retry buffer Read/Write */
472 #define PCIE_DLLP_ECTHRESHREG        0x13Cu /* Error Count Threshold */
473 #define PCIE_DLLP_TLPERRCTRREG        0x140u /* TLP Error Counter */
474 #define PCIE_DLLP_ERRCTRREG        0x144u /* Error Counter */
475 #define PCIE_DLLP_NAKRXCTRREG        0x148u /* NAK Received Counter */
476 #define PCIE_DLLP_TESTREG        0x14Cu /* Test */
477 #define PCIE_DLLP_PKTBIST        0x150u /* Packet BIST */
478 #define PCIE_DLLP_PCIE11        0x154u /* DLLP PCIE 1.1 reg */
479 
480 #define PCIE_DLLP_LSREG_LINKUP        (1u << 16u)
481 
482 /* PCIE protocol TLP diagnostic registers */
483 #define PCIE_TLP_CONFIGREG        0x000u /* Configuration */
484 #define PCIE_TLP_WORKAROUNDSREG        0x004u /* TLP Workarounds */
485 #define PCIE_TLP_WRDMAUPPER        0x010u /* Write DMA Upper Address */
486 #define PCIE_TLP_WRDMALOWER        0x014u /* Write DMA Lower Address */
487 #define PCIE_TLP_WRDMAREQ_LBEREG    0x018u /* Write DMA Len/ByteEn Req */
488 #define PCIE_TLP_RDDMAUPPER        0x01Cu /* Read DMA Upper Address */
489 #define PCIE_TLP_RDDMALOWER        0x020u /* Read DMA Lower Address */
490 #define PCIE_TLP_RDDMALENREG        0x024u /* Read DMA Len Req */
491 #define PCIE_TLP_MSIDMAUPPER        0x028u /* MSI DMA Upper Address */
492 #define PCIE_TLP_MSIDMALOWER        0x02Cu /* MSI DMA Lower Address */
493 #define PCIE_TLP_MSIDMALENREG        0x030u /* MSI DMA Len Req */
494 #define PCIE_TLP_SLVREQLENREG        0x034u /* Slave Request Len */
495 #define PCIE_TLP_FCINPUTSREQ        0x038u /* Flow Control Inputs */
496 #define PCIE_TLP_TXSMGRSREQ        0x03Cu /* Tx StateMachine and Gated Req */
497 #define PCIE_TLP_ADRACKCNTARBLEN    0x040u /* Address Ack XferCnt and ARB Len */
498 #define PCIE_TLP_DMACPLHDR0        0x044u /* DMA Completion Hdr 0 */
499 #define PCIE_TLP_DMACPLHDR1        0x048u /* DMA Completion Hdr 1 */
500 #define PCIE_TLP_DMACPLHDR2        0x04Cu /* DMA Completion Hdr 2 */
501 #define PCIE_TLP_DMACPLMISC0        0x050u /* DMA Completion Misc0 */
502 #define PCIE_TLP_DMACPLMISC1        0x054u /* DMA Completion Misc1 */
503 #define PCIE_TLP_DMACPLMISC2        0x058u /* DMA Completion Misc2 */
504 #define PCIE_TLP_SPTCTRLLEN        0x05Cu /* Split Controller Req len */
505 #define PCIE_TLP_SPTCTRLMSIC0        0x060u /* Split Controller Misc 0 */
506 #define PCIE_TLP_SPTCTRLMSIC1        0x064u /* Split Controller Misc 1 */
507 #define PCIE_TLP_BUSDEVFUNC        0x068u /* Bus/Device/Func */
508 #define PCIE_TLP_RESETCTR        0x06Cu /* Reset Counter */
509 #define PCIE_TLP_RTRYBUF        0x070u /* Retry Buffer value */
510 #define PCIE_TLP_TGTDEBUG1        0x074u /* Target Debug Reg1 */
511 #define PCIE_TLP_TGTDEBUG2        0x078u /* Target Debug Reg2 */
512 #define PCIE_TLP_TGTDEBUG3        0x07Cu /* Target Debug Reg3 */
513 #define PCIE_TLP_TGTDEBUG4        0x080u /* Target Debug Reg4 */
514 
515 /* PCIE2 MDIO register offsets */
516 #define PCIE2_MDIO_CONTROL    0x128
517 #define PCIE2_MDIO_WR_DATA    0x12C
518 #define PCIE2_MDIO_RD_DATA    0x130
519 
520 
521 /* MDIO control */
522 #define MDIOCTL_DIVISOR_MASK        0x7fu    /* clock to be used on MDIO */
523 #define MDIOCTL_DIVISOR_VAL        0x2u
524 #define MDIOCTL_PREAM_EN        0x80u    /* Enable preamble sequnce */
525 #define MDIOCTL_ACCESS_DONE        0x100u   /* Tranaction complete */
526 
527 /* MDIO Data */
528 #define MDIODATA_MASK            0x0000ffff    /* data 2 bytes */
529 #define MDIODATA_TA            0x00020000    /* Turnaround */
530 #define MDIODATA_REGADDR_SHF_OLD    18        /* Regaddr shift (rev < 10) */
531 #define MDIODATA_REGADDR_MASK_OLD    0x003c0000    /* Regaddr Mask (rev < 10) */
532 #define MDIODATA_DEVADDR_SHF_OLD    22        /* Physmedia devaddr shift (rev < 10) */
533 #define MDIODATA_DEVADDR_MASK_OLD    0x0fc00000    /* Physmedia devaddr Mask (rev < 10) */
534 #define MDIODATA_REGADDR_SHF        18        /* Regaddr shift */
535 #define MDIODATA_REGADDR_MASK        0x007c0000    /* Regaddr Mask */
536 #define MDIODATA_DEVADDR_SHF        23        /* Physmedia devaddr shift */
537 #define MDIODATA_DEVADDR_MASK        0x0f800000    /* Physmedia devaddr Mask */
538 #define MDIODATA_WRITE            0x10000000    /* write Transaction */
539 #define MDIODATA_READ            0x20000000    /* Read Transaction */
540 #define MDIODATA_START            0x40000000    /* start of Transaction */
541 
542 #define MDIODATA_DEV_ADDR        0x0        /* dev address for serdes */
543 #define    MDIODATA_BLK_ADDR        0x1F        /* blk address for serdes */
544 
545 /* MDIO control/wrData/rdData register defines for PCIE Gen 2 */
546 #define MDIOCTL2_DIVISOR_MASK        0x7f    /* clock to be used on MDIO */
547 #define MDIOCTL2_DIVISOR_VAL        0x2
548 #define MDIOCTL2_REGADDR_SHF        8        /* Regaddr shift */
549 #define MDIOCTL2_REGADDR_MASK        0x00FFFF00    /* Regaddr Mask */
550 #define MDIOCTL2_DEVADDR_SHF        24        /* Physmedia devaddr shift */
551 #define MDIOCTL2_DEVADDR_MASK        0x0f000000    /* Physmedia devaddr Mask */
552 #define MDIOCTL2_SLAVE_BYPASS        0x10000000    /* IP slave bypass */
553 #define MDIOCTL2_READ            0x20000000    /* IP slave bypass */
554 
555 #define MDIODATA2_DONE            0x80000000u    /* rd/wr transaction done */
556 #define MDIODATA2_MASK            0x7FFFFFFF    /* rd/wr transaction data */
557 #define MDIODATA2_DEVADDR_SHF        4        /* Physmedia devaddr shift */
558 
559 
560 /* MDIO devices (SERDES modules)
561  *  unlike old pcie cores (rev < 10), rev10 pcie serde organizes registers into a few blocks.
562  *  two layers mapping (blockidx, register offset) is required
563  */
564 #define MDIO_DEV_IEEE0        0x000
565 #define MDIO_DEV_IEEE1        0x001
566 #define MDIO_DEV_BLK0        0x800
567 #define MDIO_DEV_BLK1        0x801
568 #define MDIO_DEV_BLK2        0x802
569 #define MDIO_DEV_BLK3        0x803
570 #define MDIO_DEV_BLK4        0x804
571 #define MDIO_DEV_TXPLL        0x808    /* TXPLL register block idx */
572 #define MDIO_DEV_TXCTRL0    0x820
573 #define MDIO_DEV_SERDESID    0x831
574 #define MDIO_DEV_RXCTRL0    0x840
575 
576 
577 /* XgxsBlk1_A Register Offsets */
578 #define BLK1_PWR_MGMT0        0x16
579 #define BLK1_PWR_MGMT1        0x17
580 #define BLK1_PWR_MGMT2        0x18
581 #define BLK1_PWR_MGMT3        0x19
582 #define BLK1_PWR_MGMT4        0x1A
583 
584 /* serdes regs (rev < 10) */
585 #define MDIODATA_DEV_PLL               0x1d    /* SERDES PLL Dev */
586 #define MDIODATA_DEV_TX                0x1e    /* SERDES TX Dev */
587 #define MDIODATA_DEV_RX                0x1f    /* SERDES RX Dev */
588     /* SERDES RX registers */
589 #define SERDES_RX_CTRL            1    /* Rx cntrl */
590 #define SERDES_RX_TIMER1        2    /* Rx Timer1 */
591 #define SERDES_RX_CDR            6    /* CDR */
592 #define SERDES_RX_CDRBW            7    /* CDR BW */
593 
594     /* SERDES RX control register */
595 #define SERDES_RX_CTRL_FORCE        0x80    /* rxpolarity_force */
596 #define SERDES_RX_CTRL_POLARITY        0x40    /* rxpolarity_value */
597 
598     /* SERDES PLL registers */
599 #define SERDES_PLL_CTRL                 1       /* PLL control reg */
600 #define PLL_CTRL_FREQDET_EN             0x4000  /* bit 14 is FREQDET on */
601 
602 /* Power management threshold */
603 #define PCIE_L0THRESHOLDTIME_MASK       0xFF00u    /* bits 0 - 7 */
604 #define PCIE_L1THRESHOLDTIME_MASK       0xFF00u    /* bits 8 - 15 */
605 #define PCIE_L1THRESHOLDTIME_SHIFT      8    /* PCIE_L1THRESHOLDTIME_SHIFT */
606 #define PCIE_L1THRESHOLD_WARVAL         0x72    /* WAR value */
607 #define PCIE_ASPMTIMER_EXTEND        0x01000000    /* > rev7: enable extend ASPM timer */
608 
609 /* SPROM offsets */
610 #define SRSH_ASPM_OFFSET        4    /* word 4 */
611 #define SRSH_ASPM_ENB            0x18    /* bit 3, 4 */
612 #define SRSH_ASPM_L1_ENB        0x10    /* bit 4 */
613 #define SRSH_ASPM_L0s_ENB        0x8    /* bit 3 */
614 #define SRSH_PCIE_MISC_CONFIG        5    /* word 5 */
615 #define SRSH_L23READY_EXIT_NOPERST    0x8000u    /* bit 15 */
616 #define SRSH_CLKREQ_OFFSET_REV5        20    /* word 20 for srom rev <= 5 */
617 #define SRSH_CLKREQ_OFFSET_REV8        52    /* word 52 for srom rev 8 */
618 #define SRSH_CLKREQ_ENB            0x0800    /* bit 11 */
619 #define SRSH_BD_OFFSET                  6       /* word 6 */
620 #define SRSH_AUTOINIT_OFFSET            18      /* auto initialization enable */
621 
622 /* PCI Capability ID's
623  * Reference include/linux/pci_regs.h
624  * #define  PCI_CAP_LIST_ID    0       // Capability ID
625  * #define  PCI_CAP_ID_PM        0x01    // Power Management
626  * #define  PCI_CAP_ID_AGP        0x02    // Accelerated Graphics Port
627  * #define  PCI_CAP_ID_VPD        0x03    // Vital Product Data
628  * #define  PCI_CAP_ID_SLOTID    0x04    // Slot Identification
629  * #define  PCI_CAP_ID_MSI        0x05    // Message Signalled Interrupts
630  * #define  PCI_CAP_ID_CHSWP       0x06    // CompactPCI HotSwap
631  * #define  PCI_CAP_ID_PCIX        0x07    // PCI-X
632  * #define  PCI_CAP_ID_HT          0x08    // HyperTransport
633  * #define  PCI_CAP_ID_VNDR        0x09    // Vendor-Specific
634  * #define  PCI_CAP_ID_DBG         0x0A    // Debug port
635  * #define  PCI_CAP_ID_CCRC        0x0B    // CompactPCI Central Resource Control
636  * #define  PCI_CAP_ID_SHPC        0x0C    // PCI Standard Hot-Plug Controller
637  * #define  PCI_CAP_ID_SSVID       0x0D    // Bridge subsystem vendor/device ID
638  * #define  PCI_CAP_ID_AGP3        0x0E    // AGP Target PCI-PCI bridge
639  * #define  PCI_CAP_ID_SECDEV      0x0F    // Secure Device
640  * #define  PCI_CAP_ID_MSIX        0x11    // MSI-X
641  * #define  PCI_CAP_ID_SATA        0x12    // SATA Data/Index Conf.
642  * #define  PCI_CAP_ID_AF          0x13    // PCI Advanced Features
643  * #define  PCI_CAP_ID_EA          0x14    // PCI Enhanced Allocation
644  * #define  PCI_CAP_ID_MAX         PCI_CAP_ID_EA
645  */
646 
647 #define  PCIE_CAP_ID_EXP         0x10    // PCI Express
648 
649 /* PCIe Capabilities Offsets
650  * Reference include/linux/pci_regs.h
651  * #define PCIE_CAP_FLAGS           2       // Capabilities register
652  * #define PCIE_CAP_DEVCAP          4       // Device capabilities
653  * #define PCIE_CAP_DEVCTL          8       // Device Control
654  * #define PCIE_CAP_DEVSTA          10      // Device Status
655  * #define PCIE_CAP_LNKCAP          12      // Link Capabilities
656  * #define PCIE_CAP_LNKCTL          16      // Link Control
657  * #define PCIE_CAP_LNKSTA          18      // Link Status
658  * #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V1  20      // v1 endpoints end here
659  * #define PCIE_CAP_SLTCAP          20      // Slot Capabilities
660  * #define PCIE_CAP_SLTCTL          24      // Slot Control
661  * #define PCIE_CAP_SLTSTA          26      // Slot Status
662  * #define PCIE_CAP_RTCTL           28      // Root Control
663  * #define PCIE_CAP_RTCAP           30      // Root Capabilities
664  * #define PCIE_CAP_RTSTA           32      // Root Status
665  */
666 
667 
668 /* Linkcapability reg offset in PCIE Cap */
669 #define PCIE_CAP_LINKCAP_OFFSET         12      /* linkcap offset in pcie cap */
670 #define PCIE_CAP_LINKCAP_LNKSPEED_MASK    0xf     /* Supported Link Speeds */
671 #define PCIE_CAP_LINKCAP_GEN2           0x2     /* Value for GEN2 */
672 
673 /* Uc_Err reg offset in AER Cap */
674 #define PCIE_EXTCAP_ID_ERR        0x01    /* Advanced Error Reporting */
675 #define PCIE_EXTCAP_AER_UCERR_OFFSET    4    /* Uc_Err reg offset in AER Cap */
676 
677 /* Linkcontrol reg offset in PCIE Cap */
678 #define PCIE_CAP_LINKCTRL_OFFSET    16    /* linkctrl offset in pcie cap */
679 #define PCIE_CAP_LCREG_ASPML0s        0x01    /* ASPM L0s in linkctrl */
680 #define PCIE_CAP_LCREG_ASPML1        0x02    /* ASPM L1 in linkctrl */
681 #define PCIE_CLKREQ_ENAB        0x100    /* CLKREQ Enab in linkctrl */
682 #define PCIE_LINKSPEED_MASK        0xF0000u    /* bits 0 - 3 of high word */
683 #define PCIE_LINKSPEED_SHIFT        16    /* PCIE_LINKSPEED_SHIFT */
684 
685 /* Devcontrol reg offset in PCIE Cap */
686 #define PCIE_CAP_DEVCTRL_OFFSET        8    /* devctrl offset in pcie cap */
687 #define PCIE_CAP_DEVCTRL_MRRS_MASK    0x7000    /* Max read request size mask */
688 #define PCIE_CAP_DEVCTRL_MRRS_SHIFT    12    /* Max read request size shift */
689 #define PCIE_CAP_DEVCTRL_MRRS_128B    0    /* 128 Byte */
690 #define PCIE_CAP_DEVCTRL_MRRS_256B    1    /* 256 Byte */
691 #define PCIE_CAP_DEVCTRL_MRRS_512B    2    /* 512 Byte */
692 #define PCIE_CAP_DEVCTRL_MRRS_1024B    3    /* 1024 Byte */
693 #define PCIE_CAP_DEVCTRL_MPS_MASK    0x00e0    /* Max payload size mask */
694 #define PCIE_CAP_DEVCTRL_MPS_SHIFT    5    /* Max payload size shift */
695 #define PCIE_CAP_DEVCTRL_MPS_128B    0    /* 128 Byte */
696 #define PCIE_CAP_DEVCTRL_MPS_256B    1    /* 256 Byte */
697 #define PCIE_CAP_DEVCTRL_MPS_512B    2    /* 512 Byte */
698 #define PCIE_CAP_DEVCTRL_MPS_1024B    3    /* 1024 Byte */
699 
700 #define PCIE_ASPM_ENAB            3    /* ASPM L0s & L1 in linkctrl */
701 #define PCIE_ASPM_L1_ENAB        2    /* ASPM L0s & L1 in linkctrl */
702 #define PCIE_ASPM_L0s_ENAB        1    /* ASPM L0s & L1 in linkctrl */
703 #define PCIE_ASPM_DISAB            0    /* ASPM L0s & L1 in linkctrl */
704 
705 #define PCIE_ASPM_L11_ENAB        8    /* ASPM L1.1 in PML1_sub_control2 */
706 #define PCIE_ASPM_L12_ENAB        4    /* ASPM L1.2 in PML1_sub_control2 */
707 
708 /* NumMsg and NumMsgEn in PCIE MSI Cap */
709 #define MSICAP_NUM_MSG_SHF        17
710 #define MSICAP_NUM_MSG_MASK        (0x7 << MSICAP_NUM_MSG_SHF)
711 #define MSICAP_NUM_MSG_EN_SHF    20
712 #define MSICAP_NUM_MSG_EN_MASK    (0x7 << MSICAP_NUM_MSG_EN_SHF)
713 
714 /* Devcontrol2 reg offset in PCIE Cap */
715 #define PCIE_CAP_DEVCTRL2_OFFSET    0x28    /* devctrl2 offset in pcie cap */
716 #define PCIE_CAP_DEVCTRL2_LTR_ENAB_MASK    0x400    /* Latency Tolerance Reporting Enable */
717 #define PCIE_CAP_DEVCTRL2_OBFF_ENAB_SHIFT 13    /* Enable OBFF mechanism, select signaling method */
718 #define PCIE_CAP_DEVCTRL2_OBFF_ENAB_MASK 0x6000    /* Enable OBFF mechanism, select signaling method */
719 
720 /* LTR registers in PCIE Cap */
721 #define PCIE_LTR0_REG_OFFSET    0x844u    /* ltr0_reg offset in pcie cap */
722 #define PCIE_LTR1_REG_OFFSET    0x848u    /* ltr1_reg offset in pcie cap */
723 #define PCIE_LTR2_REG_OFFSET    0x84cu    /* ltr2_reg offset in pcie cap */
724 #define PCIE_LTR0_REG_DEFAULT_60    0x883c883cu    /* active latency default to 60usec */
725 #define PCIE_LTR0_REG_DEFAULT_150    0x88968896u    /* active latency default to 150usec */
726 #define PCIE_LTR1_REG_DEFAULT        0x88648864u    /* idle latency default to 100usec */
727 #define PCIE_LTR2_REG_DEFAULT        0x90039003u    /* sleep latency default to 3msec */
728 
729 /* Status reg PCIE_PLP_STATUSREG */
730 #define PCIE_PLP_POLARITYINV_STAT    0x10
731 
732 
733 /* PCIE BRCM Vendor CAP REVID reg  bits */
734 #define BRCMCAP_PCIEREV_CT_MASK            0xF00u
735 #define BRCMCAP_PCIEREV_CT_SHIFT        8u
736 #define BRCMCAP_PCIEREV_REVID_MASK        0xFFu
737 #define BRCMCAP_PCIEREV_REVID_SHIFT        0
738 
739 #define PCIE_REVREG_CT_PCIE1        0
740 #define PCIE_REVREG_CT_PCIE2        1
741 
742 /* PCIE GEN2 specific defines */
743 /* PCIE BRCM Vendor Cap offsets w.r.t to vendor cap ptr */
744 #define PCIE2R0_BRCMCAP_REVID_OFFSET        4
745 #define PCIE2R0_BRCMCAP_BAR0_WIN0_WRAP_OFFSET    8
746 #define PCIE2R0_BRCMCAP_BAR0_WIN2_OFFSET    12
747 #define PCIE2R0_BRCMCAP_BAR0_WIN2_WRAP_OFFSET    16
748 #define PCIE2R0_BRCMCAP_BAR0_WIN_OFFSET        20
749 #define PCIE2R0_BRCMCAP_BAR1_WIN_OFFSET        24
750 #define PCIE2R0_BRCMCAP_SPROM_CTRL_OFFSET    28
751 #define PCIE2R0_BRCMCAP_BAR2_WIN_OFFSET        32
752 #define PCIE2R0_BRCMCAP_INTSTATUS_OFFSET    36
753 #define PCIE2R0_BRCMCAP_INTMASK_OFFSET        40
754 #define PCIE2R0_BRCMCAP_PCIE2SB_MB_OFFSET    44
755 #define PCIE2R0_BRCMCAP_BPADDR_OFFSET        48
756 #define PCIE2R0_BRCMCAP_BPDATA_OFFSET        52
757 #define PCIE2R0_BRCMCAP_CLKCTLSTS_OFFSET    56
758 
759 /* definition of configuration space registers of PCIe gen2
760  * http://hwnbu-twiki.sj.broadcom.com/twiki/pub/Mwgroup/CurrentPcieGen2ProgramGuide/pcie_ep.htm
761  */
762 #define PCIECFGREG_STATUS_CMD        0x4
763 #define PCIECFGREG_PM_CSR        0x4C
764 #define PCIECFGREG_MSI_CAP        0x58
765 #define PCIECFGREG_MSI_ADDR_L        0x5C
766 #define PCIECFGREG_MSI_ADDR_H        0x60
767 #define PCIECFGREG_MSI_DATA        0x64
768 #define PCIECFGREG_LINK_STATUS_CTRL    0xBCu
769 #define PCIECFGREG_DEV_STATUS_CTRL 0xB4u
770 #define PCIECFGGEN_DEV_STATUS_CTRL2    0xD4
771 #define PCIECFGREG_LINK_STATUS_CTRL2    0xDCu
772 #define PCIECFGREG_RBAR_CTRL        0x228
773 #define PCIECFGREG_PML1_SUB_CTRL1    0x248
774 #define PCIECFGREG_PML1_SUB_CTRL2    0x24C
775 #define PCIECFGREG_REG_BAR2_CONFIG    0x4E0
776 #define PCIECFGREG_REG_BAR3_CONFIG    0x4F4
777 #define PCIECFGREG_PDL_CTRL1        0x1004
778 #define PCIECFGREG_PDL_IDDQ        0x1814
779 #define PCIECFGREG_REG_PHY_CTL7        0x181c
780 #define PCIECFGREG_PHY_DBG_CLKREQ0        0x1E10
781 #define PCIECFGREG_PHY_DBG_CLKREQ1        0x1E14
782 #define PCIECFGREG_PHY_DBG_CLKREQ2        0x1E18
783 #define PCIECFGREG_PHY_DBG_CLKREQ3        0x1E1C
784 
785 /* PCIECFGREG_PML1_SUB_CTRL1 Bit Definition */
786 #define PCI_PM_L1_2_ENA_MASK        0x00000001    /* PCI-PM L1.2 Enabled */
787 #define PCI_PM_L1_1_ENA_MASK        0x00000002    /* PCI-PM L1.1 Enabled */
788 #define ASPM_L1_2_ENA_MASK        0x00000004    /* ASPM L1.2 Enabled */
789 #define ASPM_L1_1_ENA_MASK        0x00000008    /* ASPM L1.1 Enabled */
790 
791 /* PCIe gen2 mailbox interrupt masks */
792 #define I_MB    0x3
793 #define I_BIT0  0x1
794 #define I_BIT1  0x2
795 
796 /* PCIE gen2 config regs */
797 #define PCIIntstatus    0x090
798 #define PCIIntmask    0x094
799 #define PCISBMbx    0x98
800 
801 /* enumeration Core regs */
802 #define PCIH2D_MailBox  0x140
803 #define PCIH2D_DB1        0x144
804 #define PCID2H_MailBox  0x148
805 #define PCIH2D_MailBox_1    0x150  /* for dma channel1 */
806 #define PCIH2D_DB1_1        0x154
807 #define PCID2H_MailBox_1    0x158
808 #define PCIH2D_MailBox_2    0x160  /* for dma channel2 which will be used for Implicit DMA */
809 #define PCIH2D_DB1_2        0x164
810 #define PCID2H_MailBox_2    0x168
811 
812 #define PCIMailBoxInt    0x48
813 #define PCIMailBoxMask    0x4C
814 #define PCIMSIVecAssign    0x58
815 
816 #define I_F0_B0         (0x1 << 8) /* Mail box interrupt Function 0 interrupt, bit 0 */
817 #define I_F0_B1         (0x1 << 9) /* Mail box interrupt Function 0 interrupt, bit 1 */
818 
819 #define PCIECFGREG_DEVCONTROL    0xB4
820 #define PCIECFGREG_BASEADDR0    0x10
821 #define PCIECFGREG_DEVCONTROL_MRRS_SHFT    12
822 #define PCIECFGREG_DEVCONTROL_MRRS_MASK    (0x7 << PCIECFGREG_DEVCONTROL_MRRS_SHFT)
823 #define PCIECFGREG_DEVCTRL_MPS_SHFT    5
824 #define PCIECFGREG_DEVCTRL_MPS_MASK (0x7 << PCIECFGREG_DEVCTRL_MPS_SHFT)
825 #define PCIECFGREG_PM_CSR_STATE_MASK 0x00000003
826 #define PCIECFGREG_PM_CSR_STATE_D0 0
827 #define PCIECFGREG_PM_CSR_STATE_D1 1
828 #define PCIECFGREG_PM_CSR_STATE_D2 2
829 #define PCIECFGREG_PM_CSR_STATE_D3_HOT 3
830 #define PCIECFGREG_PM_CSR_STATE_D3_COLD 4
831 
832 
833 /* SROM hardware region */
834 #define SROM_OFFSET_BAR1_CTRL  52
835 
836 #define BAR1_ENC_SIZE_MASK    0x000e
837 #define BAR1_ENC_SIZE_SHIFT    1
838 
839 #define BAR1_ENC_SIZE_1M    0
840 #define BAR1_ENC_SIZE_2M    1
841 #define BAR1_ENC_SIZE_4M    2
842 
843 #define PCIEGEN2_CAP_DEVSTSCTRL2_OFFSET        0xD4
844 #define PCIEGEN2_CAP_DEVSTSCTRL2_LTRENAB    0x400
845 
846 /*
847  * Latency Tolerance Reporting (LTR) states
848  * Active has the least tolerant latency requirement
849  * Sleep is most tolerant
850  */
851 #define LTR_ACTIVE                2
852 #define LTR_ACTIVE_IDLE                1
853 #define LTR_SLEEP                0
854 #define LTR_FINAL_MASK                0x300
855 #define LTR_FINAL_SHIFT                8
856 
857 /* pwrinstatus, pwrintmask regs */
858 #define PCIEGEN2_PWRINT_D0_STATE_SHIFT        0
859 #define PCIEGEN2_PWRINT_D1_STATE_SHIFT        1
860 #define PCIEGEN2_PWRINT_D2_STATE_SHIFT        2
861 #define PCIEGEN2_PWRINT_D3_STATE_SHIFT        3
862 #define PCIEGEN2_PWRINT_L0_LINK_SHIFT        4
863 #define PCIEGEN2_PWRINT_L0s_LINK_SHIFT        5
864 #define PCIEGEN2_PWRINT_L1_LINK_SHIFT        6
865 #define PCIEGEN2_PWRINT_L2_L3_LINK_SHIFT    7
866 #define PCIEGEN2_PWRINT_OBFF_CHANGE_SHIFT    8
867 
868 #define PCIEGEN2_PWRINT_D0_STATE_MASK        (1 << PCIEGEN2_PWRINT_D0_STATE_SHIFT)
869 #define PCIEGEN2_PWRINT_D1_STATE_MASK        (1 << PCIEGEN2_PWRINT_D1_STATE_SHIFT)
870 #define PCIEGEN2_PWRINT_D2_STATE_MASK        (1 << PCIEGEN2_PWRINT_D2_STATE_SHIFT)
871 #define PCIEGEN2_PWRINT_D3_STATE_MASK        (1 << PCIEGEN2_PWRINT_D3_STATE_SHIFT)
872 #define PCIEGEN2_PWRINT_L0_LINK_MASK        (1 << PCIEGEN2_PWRINT_L0_LINK_SHIFT)
873 #define PCIEGEN2_PWRINT_L0s_LINK_MASK        (1 << PCIEGEN2_PWRINT_L0s_LINK_SHIFT)
874 #define PCIEGEN2_PWRINT_L1_LINK_MASK        (1 << PCIEGEN2_PWRINT_L1_LINK_SHIFT)
875 #define PCIEGEN2_PWRINT_L2_L3_LINK_MASK        (1 << PCIEGEN2_PWRINT_L2_L3_LINK_SHIFT)
876 #define PCIEGEN2_PWRINT_OBFF_CHANGE_MASK    (1 << PCIEGEN2_PWRINT_OBFF_CHANGE_SHIFT)
877 
878 /* sbtopcie mail box */
879 #define SBTOPCIE_MB_FUNC0_SHIFT 8
880 #define SBTOPCIE_MB_FUNC1_SHIFT 10
881 #define SBTOPCIE_MB_FUNC2_SHIFT 12
882 #define SBTOPCIE_MB_FUNC3_SHIFT 14
883 
884 #define SBTOPCIE_MB1_FUNC0_SHIFT 9
885 #define SBTOPCIE_MB1_FUNC1_SHIFT 11
886 #define SBTOPCIE_MB1_FUNC2_SHIFT 13
887 #define SBTOPCIE_MB1_FUNC3_SHIFT 15
888 
889 /* pcieiocstatus */
890 #define PCIEGEN2_IOC_D0_STATE_SHIFT        8
891 #define PCIEGEN2_IOC_D1_STATE_SHIFT        9
892 #define PCIEGEN2_IOC_D2_STATE_SHIFT        10
893 #define PCIEGEN2_IOC_D3_STATE_SHIFT        11
894 #define PCIEGEN2_IOC_L0_LINK_SHIFT        12
895 #define PCIEGEN2_IOC_L1_LINK_SHIFT        13
896 #define PCIEGEN2_IOC_L1L2_LINK_SHIFT        14
897 #define PCIEGEN2_IOC_L2_L3_LINK_SHIFT        15
898 
899 #define PCIEGEN2_IOC_D0_STATE_MASK        (1 << PCIEGEN2_IOC_D0_STATE_SHIFT)
900 #define PCIEGEN2_IOC_D1_STATE_MASK        (1 << PCIEGEN2_IOC_D1_STATE_SHIFT)
901 #define PCIEGEN2_IOC_D2_STATE_MASK        (1 << PCIEGEN2_IOC_D2_STATE_SHIFT)
902 #define PCIEGEN2_IOC_D3_STATE_MASK        (1 << PCIEGEN2_IOC_D3_STATE_SHIFT)
903 #define PCIEGEN2_IOC_L0_LINK_MASK        (1 << PCIEGEN2_IOC_L0_LINK_SHIFT)
904 #define PCIEGEN2_IOC_L1_LINK_MASK        (1 << PCIEGEN2_IOC_L1_LINK_SHIFT)
905 #define PCIEGEN2_IOC_L1L2_LINK_MASK        (1 << PCIEGEN2_IOC_L1L2_LINK_SHIFT)
906 #define PCIEGEN2_IOC_L2_L3_LINK_MASK        (1 << PCIEGEN2_IOC_L2_L3_LINK_SHIFT)
907 
908 /* stat_ctrl */
909 #define PCIE_STAT_CTRL_RESET        0x1
910 #define PCIE_STAT_CTRL_ENABLE        0x2
911 #define PCIE_STAT_CTRL_INTENABLE    0x4
912 #define PCIE_STAT_CTRL_INTSTATUS    0x8
913 
914 /* cpl_timeout_ctrl_reg */
915 #define PCIE_CTO_TO_THRESHOLD_SHIFT    0
916 #define PCIE_CTO_TO_THRESHHOLD_MASK    (0xfffff << PCIE_CTO_TO_THRESHOLD_SHIFT)
917 
918 #define PCIE_CTO_CLKCHKCNT_SHIFT        24
919 #define PCIE_CTO_CLKCHKCNT_MASK        (0xf << PCIE_CTO_CLKCHKCNT_SHIFT)
920 
921 #define PCIE_CTO_ENAB_SHIFT            31
922 #define PCIE_CTO_ENAB_MASK            (0x1 << PCIE_CTO_ENAB_SHIFT)
923 
924 #define PCIE_CTO_TO_THRESH_DEFAULT    0x58000
925 #define PCIE_CTO_CLKCHKCNT_VAL        0xA
926 
927 /* ErrLog */
928 #define PCIE_SROMRD_ERR_SHIFT            5
929 #define PCIE_SROMRD_ERR_MASK            (0x1 << PCIE_SROMRD_ERR_SHIFT)
930 
931 #define PCIE_CTO_ERR_SHIFT            8
932 #define PCIE_CTO_ERR_MASK                (0x1 << PCIE_CTO_ERR_SHIFT)
933 
934 #define PCIE_CTO_ERR_CODE_SHIFT        9
935 #define PCIE_CTO_ERR_CODE_MASK        (0x3 << PCIE_CTO_ERR_CODE_SHIFT)
936 
937 #define PCIE_BP_CLK_OFF_ERR_SHIFT        12
938 #define PCIE_BP_CLK_OFF_ERR_MASK        (0x1 << PCIE_BP_CLK_OFF_ERR_SHIFT)
939 
940 #define PCIE_BP_IN_RESET_ERR_SHIFT    13
941 #define PCIE_BP_IN_RESET_ERR_MASK        (0x1 << PCIE_BP_IN_RESET_ERR_SHIFT)
942 
943 #ifdef BCMDRIVER
944 void pcie_watchdog_reset(osl_t *osh, si_t *sih, sbpcieregs_t *sbpcieregs);
945 void pcie_serdes_iddqdisable(osl_t *osh, si_t *sih, sbpcieregs_t *sbpcieregs);
946 void pcie_set_trefup_time_100us(si_t *sih);
947 #endif /* BCMDRIVER */
948 
949 /* DMA intstatus and intmask */
950 #define    I_PC        (1 << 10)    /* pci descriptor error */
951 #define    I_PD        (1 << 11)    /* pci data error */
952 #define    I_DE        (1 << 12)    /* descriptor protocol error */
953 #define    I_RU        (1 << 13)    /* receive descriptor underflow */
954 #define    I_RO        (1 << 14)    /* receive fifo overflow */
955 #define    I_XU        (1 << 15)    /* transmit fifo underflow */
956 #define    I_RI        (1 << 16)    /* receive interrupt */
957 #define    I_XI        (1 << 24)    /* transmit interrupt */
958 
959 #endif    /* _PCIE_CORE_H */
960