blob: f5e566304f0cf56cc2ac291954941a71903b58ea [file] [log] [blame]
Florian Fainelli246d7f72014-08-27 17:04:56 -07001/*
2 * Broadcom Starfighter 2 switch register defines
3 *
4 * Copyright (C) 2014, Broadcom Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef __BCM_SF2_REGS_H
12#define __BCM_SF2_REGS_H
13
14/* Register set relative to 'REG' */
Florian Fainellia78e86e2017-01-20 12:36:29 -080015
16enum bcm_sf2_reg_offs {
17 REG_SWITCH_CNTRL = 0,
18 REG_SWITCH_STATUS,
19 REG_DIR_DATA_WRITE,
20 REG_DIR_DATA_READ,
21 REG_SWITCH_REVISION,
22 REG_PHY_REVISION,
23 REG_SPHY_CNTRL,
24 REG_RGMII_0_CNTRL,
25 REG_RGMII_1_CNTRL,
26 REG_RGMII_2_CNTRL,
27 REG_LED_0_CNTRL,
28 REG_LED_1_CNTRL,
29 REG_LED_2_CNTRL,
30 REG_SWITCH_REG_MAX,
31};
32
33/* Relative to REG_SWITCH_CNTRL */
Florian Fainelli246d7f72014-08-27 17:04:56 -070034#define MDIO_MASTER_SEL (1 << 0)
35
Florian Fainellia78e86e2017-01-20 12:36:29 -080036/* Relative to REG_SWITCH_REVISION */
Florian Fainelli246d7f72014-08-27 17:04:56 -070037#define SF2_REV_MASK 0xffff
38#define SWITCH_TOP_REV_SHIFT 16
39#define SWITCH_TOP_REV_MASK 0xffff
40
Florian Fainellia78e86e2017-01-20 12:36:29 -080041/* Relative to REG_PHY_REVISION */
Florian Fainelliaa9aef72014-09-19 13:07:55 -070042#define PHY_REVISION_MASK 0xffff
Florian Fainelli246d7f72014-08-27 17:04:56 -070043
Florian Fainellia78e86e2017-01-20 12:36:29 -080044/* Relative to REG_SPHY_CNTRL */
Florian Fainelli246d7f72014-08-27 17:04:56 -070045#define IDDQ_BIAS (1 << 0)
46#define EXT_PWR_DOWN (1 << 1)
47#define FORCE_DLL_EN (1 << 2)
48#define IDDQ_GLOBAL_PWR (1 << 3)
49#define CK25_DIS (1 << 4)
50#define PHY_RESET (1 << 5)
51#define PHY_PHYAD_SHIFT 8
52#define PHY_PHYAD_MASK 0x1F
53
Florian Fainellia78e86e2017-01-20 12:36:29 -080054#define REG_RGMII_CNTRL_P(x) (REG_RGMII_0_CNTRL + (x))
55
Florian Fainelli246d7f72014-08-27 17:04:56 -070056/* Relative to REG_RGMII_CNTRL */
57#define RGMII_MODE_EN (1 << 0)
58#define ID_MODE_DIS (1 << 1)
59#define PORT_MODE_SHIFT 2
60#define INT_EPHY (0 << PORT_MODE_SHIFT)
61#define INT_GPHY (1 << PORT_MODE_SHIFT)
62#define EXT_EPHY (2 << PORT_MODE_SHIFT)
63#define EXT_GPHY (3 << PORT_MODE_SHIFT)
64#define EXT_REVMII (4 << PORT_MODE_SHIFT)
65#define PORT_MODE_MASK 0x7
66#define RVMII_REF_SEL (1 << 5)
67#define RX_PAUSE_EN (1 << 6)
68#define TX_PAUSE_EN (1 << 7)
69#define TX_CLK_STOP_EN (1 << 8)
70#define LPI_COUNT_SHIFT 9
71#define LPI_COUNT_MASK 0x3F
72
Florian Fainellia78e86e2017-01-20 12:36:29 -080073#define REG_LED_CNTRL(x) (REG_LED_0_CNTRL + (x))
74
Florian Fainelli9af197a2015-02-05 11:40:42 -080075#define SPDLNK_SRC_SEL (1 << 24)
76
Florian Fainelli246d7f72014-08-27 17:04:56 -070077/* Register set relative to 'INTRL2_0' and 'INTRL2_1' */
78#define INTRL2_CPU_STATUS 0x00
79#define INTRL2_CPU_SET 0x04
80#define INTRL2_CPU_CLEAR 0x08
81#define INTRL2_CPU_MASK_STATUS 0x0c
82#define INTRL2_CPU_MASK_SET 0x10
83#define INTRL2_CPU_MASK_CLEAR 0x14
84
85/* Shared INTRL2_0 and INTRL2_ interrupt sources macros */
86#define P_LINK_UP_IRQ(x) (1 << (0 + (x)))
87#define P_LINK_DOWN_IRQ(x) (1 << (1 + (x)))
88#define P_ENERGY_ON_IRQ(x) (1 << (2 + (x)))
89#define P_ENERGY_OFF_IRQ(x) (1 << (3 + (x)))
90#define P_GPHY_IRQ(x) (1 << (4 + (x)))
91#define P_NUM_IRQ 5
92#define P_IRQ_MASK(x) (P_LINK_UP_IRQ((x)) | \
93 P_LINK_DOWN_IRQ((x)) | \
94 P_ENERGY_ON_IRQ((x)) | \
95 P_ENERGY_OFF_IRQ((x)) | \
96 P_GPHY_IRQ((x)))
97
98/* INTRL2_0 interrupt sources */
99#define P0_IRQ_OFF 0
100#define MEM_DOUBLE_IRQ (1 << 5)
101#define EEE_LPI_IRQ (1 << 6)
102#define P5_CPU_WAKE_IRQ (1 << 7)
103#define P8_CPU_WAKE_IRQ (1 << 8)
104#define P7_CPU_WAKE_IRQ (1 << 9)
105#define IEEE1588_IRQ (1 << 10)
106#define MDIO_ERR_IRQ (1 << 11)
107#define MDIO_DONE_IRQ (1 << 12)
108#define GISB_ERR_IRQ (1 << 13)
109#define UBUS_ERR_IRQ (1 << 14)
110#define FAILOVER_ON_IRQ (1 << 15)
111#define FAILOVER_OFF_IRQ (1 << 16)
112#define TCAM_SOFT_ERR_IRQ (1 << 17)
113
114/* INTRL2_1 interrupt sources */
115#define P7_IRQ_OFF 0
116#define P_IRQ_OFF(x) ((6 - (x)) * P_NUM_IRQ)
117
118/* Register set relative to 'CORE' */
119#define CORE_G_PCTL_PORT0 0x00000
120#define CORE_G_PCTL_PORT(x) (CORE_G_PCTL_PORT0 + (x * 0x4))
121#define CORE_IMP_CTL 0x00020
122#define RX_DIS (1 << 0)
123#define TX_DIS (1 << 1)
124#define RX_BCST_EN (1 << 2)
125#define RX_MCST_EN (1 << 3)
126#define RX_UCST_EN (1 << 4)
Florian Fainelli246d7f72014-08-27 17:04:56 -0700127
128#define CORE_SWMODE 0x0002c
129#define SW_FWDG_MODE (1 << 0)
130#define SW_FWDG_EN (1 << 1)
131#define RTRY_LMT_DIS (1 << 2)
132
133#define CORE_STS_OVERRIDE_IMP 0x00038
134#define GMII_SPEED_UP_2G (1 << 6)
135#define MII_SW_OR (1 << 7)
136
137#define CORE_NEW_CTRL 0x00084
138#define IP_MC (1 << 0)
139#define OUTRANGEERR_DISCARD (1 << 1)
140#define INRANGEERR_DISCARD (1 << 2)
141#define CABLE_DIAG_LEN (1 << 3)
142#define OVERRIDE_AUTO_PD_WAR (1 << 4)
143#define EN_AUTO_PD_WAR (1 << 5)
144#define UC_FWD_EN (1 << 6)
145#define MC_FWD_EN (1 << 7)
146
147#define CORE_SWITCH_CTRL 0x00088
148#define MII_DUMB_FWDG_EN (1 << 6)
149
150#define CORE_SFT_LRN_CTRL 0x000f8
151#define SW_LEARN_CNTL(x) (1 << (x))
152
153#define CORE_STS_OVERRIDE_GMIIP_PORT(x) (0x160 + (x) * 4)
154#define LINK_STS (1 << 0)
155#define DUPLX_MODE (1 << 1)
156#define SPEED_SHIFT 2
157#define SPEED_MASK 0x3
158#define RXFLOW_CNTL (1 << 4)
159#define TXFLOW_CNTL (1 << 5)
160#define SW_OVERRIDE (1 << 6)
161
162#define CORE_WATCHDOG_CTRL 0x001e4
163#define SOFTWARE_RESET (1 << 7)
164#define EN_CHIP_RST (1 << 6)
165#define EN_SW_RESET (1 << 4)
166
Florian Fainelli12f460f2015-02-24 13:15:34 -0800167#define CORE_FAST_AGE_CTRL 0x00220
168#define EN_FAST_AGE_STATIC (1 << 0)
169#define EN_AGE_DYNAMIC (1 << 1)
170#define EN_AGE_PORT (1 << 2)
171#define EN_AGE_VLAN (1 << 3)
172#define EN_AGE_SPT (1 << 4)
173#define EN_AGE_MCAST (1 << 5)
174#define FAST_AGE_STR_DONE (1 << 7)
175
176#define CORE_FAST_AGE_PORT 0x00224
177#define AGE_PORT_MASK 0xf
178
179#define CORE_FAST_AGE_VID 0x00228
180#define AGE_VID_MASK 0x3fff
181
Florian Fainelli246d7f72014-08-27 17:04:56 -0700182#define CORE_LNKSTS 0x00400
183#define LNK_STS_MASK 0x1ff
184
185#define CORE_SPDSTS 0x00410
186#define SPDSTS_10 0
187#define SPDSTS_100 1
188#define SPDSTS_1000 2
189#define SPDSTS_SHIFT 2
190#define SPDSTS_MASK 0x3
191
192#define CORE_DUPSTS 0x00420
193#define CORE_DUPSTS_MASK 0x1ff
194
195#define CORE_PAUSESTS 0x00428
196#define PAUSESTS_TX_PAUSE_SHIFT 9
197
198#define CORE_GMNCFGCFG 0x0800
199#define RST_MIB_CNT (1 << 0)
200#define RXBPDU_EN (1 << 1)
201
202#define CORE_IMP0_PRT_ID 0x0804
203
204#define CORE_BRCM_HDR_CTRL 0x0080c
205#define BRCM_HDR_EN_P8 (1 << 0)
206#define BRCM_HDR_EN_P5 (1 << 1)
207#define BRCM_HDR_EN_P7 (1 << 2)
208
Florian Fainelli246d7f72014-08-27 17:04:56 -0700209#define CORE_RST_MIB_CNT_EN 0x0950
210
211#define CORE_BRCM_HDR_RX_DIS 0x0980
212#define CORE_BRCM_HDR_TX_DIS 0x0988
213
Florian Fainelli064523f2016-06-09 17:42:07 -0700214#define CORE_ARLA_VTBL_RWCTRL 0x1600
215#define ARLA_VTBL_CMD_WRITE 0
216#define ARLA_VTBL_CMD_READ 1
217#define ARLA_VTBL_CMD_CLEAR 2
218#define ARLA_VTBL_STDN (1 << 7)
219
220#define CORE_ARLA_VTBL_ADDR 0x1604
221#define VTBL_ADDR_INDEX_MASK 0xfff
222
223#define CORE_ARLA_VTBL_ENTRY 0x160c
224#define FWD_MAP_MASK 0x1ff
225#define UNTAG_MAP_MASK 0x1ff
226#define UNTAG_MAP_SHIFT 9
227#define MSTP_INDEX_MASK 0x7
228#define MSTP_INDEX_SHIFT 18
229#define FWD_MODE (1 << 21)
230
Florian Fainelli246d7f72014-08-27 17:04:56 -0700231#define CORE_MEM_PSM_VDD_CTRL 0x2380
232#define P_TXQ_PSM_VDD_SHIFT 2
233#define P_TXQ_PSM_VDD_MASK 0x3
234#define P_TXQ_PSM_VDD(x) (P_TXQ_PSM_VDD_MASK << \
235 ((x) * P_TXQ_PSM_VDD_SHIFT))
236
Florian Fainelli246d7f72014-08-27 17:04:56 -0700237#define CORE_PORT_VLAN_CTL_PORT(x) (0xc400 + ((x) * 0x8))
238#define PORT_VLAN_CTRL_MASK 0x1ff
239
Florian Fainelli064523f2016-06-09 17:42:07 -0700240#define CORE_DEFAULT_1Q_TAG_P(x) (0xd040 + ((x) * 8))
241#define CFI_SHIFT 12
242#define PRI_SHIFT 13
243#define PRI_MASK 0x7
244
245#define CORE_JOIN_ALL_VLAN_EN 0xd140
246
Florian Fainelli450b05c2014-09-24 17:05:22 -0700247#define CORE_EEE_EN_CTRL 0x24800
248#define CORE_EEE_LPI_INDICATE 0x24810
249
Florian Fainelli246d7f72014-08-27 17:04:56 -0700250#endif /* __BCM_SF2_REGS_H */