blob: 6b7fe6fdd13b9b27b4a1573e8c7b3869b17bcc19 [file] [log] [blame]
Sunil Goutham4863dea2015-05-26 19:20:15 -07001/*
2 * Copyright (C) 2015 Cavium, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 */
8
9#ifndef THUNDER_BGX_H
10#define THUNDER_BGX_H
11
Sunil Goutham57aaf632016-08-12 16:51:31 +053012/* PCI device ID */
13#define PCI_DEVICE_ID_THUNDER_BGX 0xA026
Sunil Goutham64658592016-08-12 16:51:33 +053014#define PCI_DEVICE_ID_THUNDER_RGX 0xA054
Sunil Goutham57aaf632016-08-12 16:51:31 +053015
16/* Subsystem device IDs */
17#define PCI_SUBSYS_DEVID_88XX_BGX 0xA126
18#define PCI_SUBSYS_DEVID_81XX_BGX 0xA226
George Cherianb47a57a2017-04-13 07:25:01 +000019#define PCI_SUBSYS_DEVID_81XX_RGX 0xA254
Sunil Goutham57aaf632016-08-12 16:51:31 +053020#define PCI_SUBSYS_DEVID_83XX_BGX 0xA326
21
Sunil Goutham09de3912016-08-12 16:51:35 +053022#define MAX_BGX_THUNDER 8 /* Max 2 nodes, 4 per node */
Sunil Goutham4863dea2015-05-26 19:20:15 -070023#define MAX_BGX_PER_CN88XX 2
Sunil Goutham64658592016-08-12 16:51:33 +053024#define MAX_BGX_PER_CN81XX 3 /* 2 BGXs + 1 RGX */
Sunil Goutham0025d93e2016-08-12 16:51:26 +053025#define MAX_BGX_PER_CN83XX 4
Sunil Goutham4863dea2015-05-26 19:20:15 -070026#define MAX_LMAC_PER_BGX 4
27#define MAX_BGX_CHANS_PER_LMAC 16
28#define MAX_DMAC_PER_LMAC 8
29#define MAX_FRAME_SIZE 9216
Sunil Goutham430da202016-11-24 14:48:03 +053030#define DEFAULT_PAUSE_TIME 0xFFFF
Sunil Goutham4863dea2015-05-26 19:20:15 -070031
Radha Mohan Chintakuntla612e94b2016-11-15 17:37:16 +053032#define BGX_ID_MASK 0x3
33
Sunil Goutham4863dea2015-05-26 19:20:15 -070034#define MAX_DMAC_PER_LMAC_TNS_BYPASS_MODE 2
35
Sunil Goutham4863dea2015-05-26 19:20:15 -070036/* Registers */
37#define BGX_CMRX_CFG 0x00
38#define CMR_PKT_TX_EN BIT_ULL(13)
39#define CMR_PKT_RX_EN BIT_ULL(14)
40#define CMR_EN BIT_ULL(15)
41#define BGX_CMR_GLOBAL_CFG 0x08
42#define CMR_GLOBAL_CFG_FCS_STRIP BIT_ULL(6)
43#define BGX_CMRX_RX_ID_MAP 0x60
44#define BGX_CMRX_RX_STAT0 0x70
45#define BGX_CMRX_RX_STAT1 0x78
46#define BGX_CMRX_RX_STAT2 0x80
47#define BGX_CMRX_RX_STAT3 0x88
48#define BGX_CMRX_RX_STAT4 0x90
49#define BGX_CMRX_RX_STAT5 0x98
50#define BGX_CMRX_RX_STAT6 0xA0
51#define BGX_CMRX_RX_STAT7 0xA8
52#define BGX_CMRX_RX_STAT8 0xB0
53#define BGX_CMRX_RX_STAT9 0xB8
54#define BGX_CMRX_RX_STAT10 0xC0
55#define BGX_CMRX_RX_BP_DROP 0xC8
56#define BGX_CMRX_RX_DMAC_CTL 0x0E8
Sunil Goutham3f4c68c2016-06-27 15:30:02 +053057#define BGX_CMRX_RX_FIFO_LEN 0x108
Sunil Goutham4863dea2015-05-26 19:20:15 -070058#define BGX_CMR_RX_DMACX_CAM 0x200
59#define RX_DMACX_CAM_EN BIT_ULL(48)
60#define RX_DMACX_CAM_LMACID(x) (x << 49)
61#define RX_DMAC_COUNT 32
62#define BGX_CMR_RX_STREERING 0x300
63#define RX_TRAFFIC_STEER_RULE_COUNT 8
64#define BGX_CMR_CHAN_MSK_AND 0x450
65#define BGX_CMR_BIST_STATUS 0x460
66#define BGX_CMR_RX_LMACS 0x468
Sunil Goutham3f4c68c2016-06-27 15:30:02 +053067#define BGX_CMRX_TX_FIFO_LEN 0x518
Sunil Goutham4863dea2015-05-26 19:20:15 -070068#define BGX_CMRX_TX_STAT0 0x600
69#define BGX_CMRX_TX_STAT1 0x608
70#define BGX_CMRX_TX_STAT2 0x610
71#define BGX_CMRX_TX_STAT3 0x618
72#define BGX_CMRX_TX_STAT4 0x620
73#define BGX_CMRX_TX_STAT5 0x628
74#define BGX_CMRX_TX_STAT6 0x630
75#define BGX_CMRX_TX_STAT7 0x638
76#define BGX_CMRX_TX_STAT8 0x640
77#define BGX_CMRX_TX_STAT9 0x648
78#define BGX_CMRX_TX_STAT10 0x650
79#define BGX_CMRX_TX_STAT11 0x658
80#define BGX_CMRX_TX_STAT12 0x660
81#define BGX_CMRX_TX_STAT13 0x668
82#define BGX_CMRX_TX_STAT14 0x670
83#define BGX_CMRX_TX_STAT15 0x678
84#define BGX_CMRX_TX_STAT16 0x680
85#define BGX_CMRX_TX_STAT17 0x688
86#define BGX_CMR_TX_LMACS 0x1000
87
88#define BGX_SPUX_CONTROL1 0x10000
89#define SPU_CTL_LOW_POWER BIT_ULL(11)
Sunil Gouthamd77a2382015-08-30 12:29:16 +030090#define SPU_CTL_LOOPBACK BIT_ULL(14)
Sunil Goutham4863dea2015-05-26 19:20:15 -070091#define SPU_CTL_RESET BIT_ULL(15)
92#define BGX_SPUX_STATUS1 0x10008
93#define SPU_STATUS1_RCV_LNK BIT_ULL(2)
94#define BGX_SPUX_STATUS2 0x10020
95#define SPU_STATUS2_RCVFLT BIT_ULL(10)
96#define BGX_SPUX_BX_STATUS 0x10028
97#define SPU_BX_STATUS_RX_ALIGN BIT_ULL(12)
98#define BGX_SPUX_BR_STATUS1 0x10030
99#define SPU_BR_STATUS_BLK_LOCK BIT_ULL(0)
100#define SPU_BR_STATUS_RCV_LNK BIT_ULL(12)
101#define BGX_SPUX_BR_PMD_CRTL 0x10068
102#define SPU_PMD_CRTL_TRAIN_EN BIT_ULL(1)
103#define BGX_SPUX_BR_PMD_LP_CUP 0x10078
104#define BGX_SPUX_BR_PMD_LD_CUP 0x10088
105#define BGX_SPUX_BR_PMD_LD_REP 0x10090
106#define BGX_SPUX_FEC_CONTROL 0x100A0
107#define SPU_FEC_CTL_FEC_EN BIT_ULL(0)
108#define SPU_FEC_CTL_ERR_EN BIT_ULL(1)
109#define BGX_SPUX_AN_CONTROL 0x100C8
110#define SPU_AN_CTL_AN_EN BIT_ULL(12)
111#define SPU_AN_CTL_XNP_EN BIT_ULL(13)
112#define BGX_SPUX_AN_ADV 0x100D8
113#define BGX_SPUX_MISC_CONTROL 0x10218
114#define SPU_MISC_CTL_INTLV_RDISP BIT_ULL(10)
115#define SPU_MISC_CTL_RX_DIS BIT_ULL(12)
116#define BGX_SPUX_INT 0x10220 /* +(0..3) << 20 */
117#define BGX_SPUX_INT_W1S 0x10228
118#define BGX_SPUX_INT_ENA_W1C 0x10230
119#define BGX_SPUX_INT_ENA_W1S 0x10238
120#define BGX_SPU_DBG_CONTROL 0x10300
121#define SPU_DBG_CTL_AN_ARB_LINK_CHK_EN BIT_ULL(18)
122#define SPU_DBG_CTL_AN_NONCE_MCT_DIS BIT_ULL(29)
123
124#define BGX_SMUX_RX_INT 0x20000
125#define BGX_SMUX_RX_JABBER 0x20030
126#define BGX_SMUX_RX_CTL 0x20048
127#define SMU_RX_CTL_STATUS (3ull << 0)
128#define BGX_SMUX_TX_APPEND 0x20100
129#define SMU_TX_APPEND_FCS_D BIT_ULL(2)
Sunil Goutham430da202016-11-24 14:48:03 +0530130#define BGX_SMUX_TX_PAUSE_PKT_TIME 0x20110
Sunil Goutham4863dea2015-05-26 19:20:15 -0700131#define BGX_SMUX_TX_MIN_PKT 0x20118
Sunil Goutham430da202016-11-24 14:48:03 +0530132#define BGX_SMUX_TX_PAUSE_PKT_INTERVAL 0x20120
133#define BGX_SMUX_TX_PAUSE_ZERO 0x20138
Sunil Goutham4863dea2015-05-26 19:20:15 -0700134#define BGX_SMUX_TX_INT 0x20140
135#define BGX_SMUX_TX_CTL 0x20178
136#define SMU_TX_CTL_DIC_EN BIT_ULL(0)
137#define SMU_TX_CTL_UNI_EN BIT_ULL(1)
138#define SMU_TX_CTL_LNK_STATUS (3ull << 4)
139#define BGX_SMUX_TX_THRESH 0x20180
140#define BGX_SMUX_CTL 0x20200
141#define SMU_CTL_RX_IDLE BIT_ULL(0)
142#define SMU_CTL_TX_IDLE BIT_ULL(1)
Sunil Goutham430da202016-11-24 14:48:03 +0530143#define BGX_SMUX_CBFC_CTL 0x20218
144#define RX_EN BIT_ULL(0)
145#define TX_EN BIT_ULL(1)
146#define BCK_EN BIT_ULL(2)
147#define DRP_EN BIT_ULL(3)
Sunil Goutham4863dea2015-05-26 19:20:15 -0700148
149#define BGX_GMP_PCS_MRX_CTL 0x30000
150#define PCS_MRX_CTL_RST_AN BIT_ULL(9)
151#define PCS_MRX_CTL_PWR_DN BIT_ULL(11)
152#define PCS_MRX_CTL_AN_EN BIT_ULL(12)
Sunil Gouthamd77a2382015-08-30 12:29:16 +0300153#define PCS_MRX_CTL_LOOPBACK1 BIT_ULL(14)
Sunil Goutham4863dea2015-05-26 19:20:15 -0700154#define PCS_MRX_CTL_RESET BIT_ULL(15)
155#define BGX_GMP_PCS_MRX_STATUS 0x30008
Thanneeru Srinivasulu075ad762017-02-08 18:09:00 +0530156#define PCS_MRX_STATUS_LINK BIT_ULL(2)
Sunil Goutham4863dea2015-05-26 19:20:15 -0700157#define PCS_MRX_STATUS_AN_CPT BIT_ULL(5)
Thanneeru Srinivasulu075ad762017-02-08 18:09:00 +0530158#define BGX_GMP_PCS_ANX_ADV 0x30010
Sunil Goutham4863dea2015-05-26 19:20:15 -0700159#define BGX_GMP_PCS_ANX_AN_RESULTS 0x30020
Thanneeru Srinivasulu075ad762017-02-08 18:09:00 +0530160#define BGX_GMP_PCS_LINKX_TIMER 0x30040
161#define PCS_LINKX_TIMER_COUNT 0x1E84
Sunil Goutham4863dea2015-05-26 19:20:15 -0700162#define BGX_GMP_PCS_SGM_AN_ADV 0x30068
163#define BGX_GMP_PCS_MISCX_CTL 0x30078
Thanneeru Srinivasulu075ad762017-02-08 18:09:00 +0530164#define PCS_MISC_CTL_MODE BIT_ULL(8)
Sunil Goutham3f8057c2016-08-12 16:51:32 +0530165#define PCS_MISC_CTL_DISP_EN BIT_ULL(13)
Sunil Goutham4863dea2015-05-26 19:20:15 -0700166#define PCS_MISC_CTL_GMX_ENO BIT_ULL(11)
167#define PCS_MISC_CTL_SAMP_PT_MASK 0x7Full
168#define BGX_GMP_GMI_PRTX_CFG 0x38020
169#define GMI_PORT_CFG_SPEED BIT_ULL(1)
170#define GMI_PORT_CFG_DUPLEX BIT_ULL(2)
171#define GMI_PORT_CFG_SLOT_TIME BIT_ULL(3)
172#define GMI_PORT_CFG_SPEED_MSB BIT_ULL(8)
173#define BGX_GMP_GMI_RXX_JABBER 0x38038
174#define BGX_GMP_GMI_TXX_THRESH 0x38210
175#define BGX_GMP_GMI_TXX_APPEND 0x38218
176#define BGX_GMP_GMI_TXX_SLOT 0x38220
177#define BGX_GMP_GMI_TXX_BURST 0x38228
178#define BGX_GMP_GMI_TXX_MIN_PKT 0x38240
179#define BGX_GMP_GMI_TXX_SGMII_CTL 0x38300
180
181#define BGX_MSIX_VEC_0_29_ADDR 0x400000 /* +(0..29) << 4 */
182#define BGX_MSIX_VEC_0_29_CTL 0x400008
183#define BGX_MSIX_PBA_0 0x4F0000
184
185/* MSI-X interrupts */
186#define BGX_MSIX_VECTORS 30
187#define BGX_LMAC_VEC_OFFSET 7
188#define BGX_MSIX_VEC_SHIFT 4
189
190#define CMRX_INT 0
191#define SPUX_INT 1
192#define SMUX_RX_INT 2
193#define SMUX_TX_INT 3
194#define GMPX_PCS_INT 4
195#define GMPX_GMI_RX_INT 5
196#define GMPX_GMI_TX_INT 6
197#define CMR_MEM_INT 28
198#define SPU_MEM_INT 29
199
200#define LMAC_INTR_LINK_UP BIT(0)
201#define LMAC_INTR_LINK_DOWN BIT(1)
202
203/* RX_DMAC_CTL configuration*/
204enum MCAST_MODE {
205 MCAST_MODE_REJECT,
206 MCAST_MODE_ACCEPT,
207 MCAST_MODE_CAM_FILTER,
208 RSVD
209};
210
211#define BCAST_ACCEPT 1
212#define CAM_ACCEPT 1
213
Thanneeru Srinivasulu723cda52015-12-02 15:36:13 +0530214void octeon_mdiobus_force_mod_depencency(void);
Sunil Gouthambc69fdf2015-12-02 15:36:17 +0530215void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable);
Sunil Goutham4863dea2015-05-26 19:20:15 -0700216void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac);
217unsigned bgx_get_map(int node);
218int bgx_get_lmac_count(int node, int bgx);
Aleksey Makarove610cb32015-06-02 11:00:21 -0700219const u8 *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid);
220void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac);
Sunil Goutham4863dea2015-05-26 19:20:15 -0700221void bgx_get_lmac_link_state(int node, int bgx_idx, int lmacid, void *status);
Sunil Gouthamd77a2382015-08-30 12:29:16 +0300222void bgx_lmac_internal_loopback(int node, int bgx_idx,
223 int lmac_idx, bool enable);
Sunil Goutham430da202016-11-24 14:48:03 +0530224void bgx_lmac_get_pfc(int node, int bgx_idx, int lmacid, void *pause);
225void bgx_lmac_set_pfc(int node, int bgx_idx, int lmacid, void *pause);
226
Sunil Goutham64658592016-08-12 16:51:33 +0530227void xcv_init_hw(void);
228void xcv_setup_link(bool link_up, int link_speed);
229
Sunil Goutham4863dea2015-05-26 19:20:15 -0700230u64 bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx);
231u64 bgx_get_tx_stats(int node, int bgx_idx, int lmac, int idx);
232#define BGX_RX_STATS_COUNT 11
233#define BGX_TX_STATS_COUNT 18
234
235struct bgx_stats {
236 u64 rx_stats[BGX_RX_STATS_COUNT];
237 u64 tx_stats[BGX_TX_STATS_COUNT];
238};
239
240enum LMAC_TYPE {
241 BGX_MODE_SGMII = 0, /* 1 lane, 1.250 Gbaud */
242 BGX_MODE_XAUI = 1, /* 4 lanes, 3.125 Gbaud */
243 BGX_MODE_DXAUI = 1, /* 4 lanes, 6.250 Gbaud */
244 BGX_MODE_RXAUI = 2, /* 2 lanes, 6.250 Gbaud */
245 BGX_MODE_XFI = 3, /* 1 lane, 10.3125 Gbaud */
246 BGX_MODE_XLAUI = 4, /* 4 lanes, 10.3125 Gbaud */
247 BGX_MODE_10G_KR = 3,/* 1 lane, 10.3125 Gbaud */
248 BGX_MODE_40G_KR = 4,/* 4 lanes, 10.3125 Gbaud */
Sunil Goutham57aaf632016-08-12 16:51:31 +0530249 BGX_MODE_RGMII = 5,
250 BGX_MODE_QSGMII = 6,
251 BGX_MODE_INVALID = 7,
Sunil Goutham4863dea2015-05-26 19:20:15 -0700252};
253
Sunil Goutham4863dea2015-05-26 19:20:15 -0700254#endif /* THUNDER_BGX_H */