blob: 885c231b03b583410ab329a9c018c402612cad5a [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' */
15#define REG_SWITCH_CNTRL 0x00
16#define MDIO_MASTER_SEL (1 << 0)
17
18#define REG_SWITCH_STATUS 0x04
19#define REG_DIR_DATA_WRITE 0x08
20#define REG_DIR_DATA_READ 0x0C
21
22#define REG_SWITCH_REVISION 0x18
23#define SF2_REV_MASK 0xffff
24#define SWITCH_TOP_REV_SHIFT 16
25#define SWITCH_TOP_REV_MASK 0xffff
26
27#define REG_PHY_REVISION 0x1C
28
29#define REG_SPHY_CNTRL 0x2C
30#define IDDQ_BIAS (1 << 0)
31#define EXT_PWR_DOWN (1 << 1)
32#define FORCE_DLL_EN (1 << 2)
33#define IDDQ_GLOBAL_PWR (1 << 3)
34#define CK25_DIS (1 << 4)
35#define PHY_RESET (1 << 5)
36#define PHY_PHYAD_SHIFT 8
37#define PHY_PHYAD_MASK 0x1F
38
39#define REG_RGMII_0_BASE 0x34
40#define REG_RGMII_CNTRL 0x00
41#define REG_RGMII_IB_STATUS 0x04
42#define REG_RGMII_RX_CLOCK_DELAY_CNTRL 0x08
43#define REG_RGMII_CNTRL_SIZE 0x0C
44#define REG_RGMII_CNTRL_P(x) (REG_RGMII_0_BASE + \
45 ((x) * REG_RGMII_CNTRL_SIZE))
46/* Relative to REG_RGMII_CNTRL */
47#define RGMII_MODE_EN (1 << 0)
48#define ID_MODE_DIS (1 << 1)
49#define PORT_MODE_SHIFT 2
50#define INT_EPHY (0 << PORT_MODE_SHIFT)
51#define INT_GPHY (1 << PORT_MODE_SHIFT)
52#define EXT_EPHY (2 << PORT_MODE_SHIFT)
53#define EXT_GPHY (3 << PORT_MODE_SHIFT)
54#define EXT_REVMII (4 << PORT_MODE_SHIFT)
55#define PORT_MODE_MASK 0x7
56#define RVMII_REF_SEL (1 << 5)
57#define RX_PAUSE_EN (1 << 6)
58#define TX_PAUSE_EN (1 << 7)
59#define TX_CLK_STOP_EN (1 << 8)
60#define LPI_COUNT_SHIFT 9
61#define LPI_COUNT_MASK 0x3F
62
63/* Register set relative to 'INTRL2_0' and 'INTRL2_1' */
64#define INTRL2_CPU_STATUS 0x00
65#define INTRL2_CPU_SET 0x04
66#define INTRL2_CPU_CLEAR 0x08
67#define INTRL2_CPU_MASK_STATUS 0x0c
68#define INTRL2_CPU_MASK_SET 0x10
69#define INTRL2_CPU_MASK_CLEAR 0x14
70
71/* Shared INTRL2_0 and INTRL2_ interrupt sources macros */
72#define P_LINK_UP_IRQ(x) (1 << (0 + (x)))
73#define P_LINK_DOWN_IRQ(x) (1 << (1 + (x)))
74#define P_ENERGY_ON_IRQ(x) (1 << (2 + (x)))
75#define P_ENERGY_OFF_IRQ(x) (1 << (3 + (x)))
76#define P_GPHY_IRQ(x) (1 << (4 + (x)))
77#define P_NUM_IRQ 5
78#define P_IRQ_MASK(x) (P_LINK_UP_IRQ((x)) | \
79 P_LINK_DOWN_IRQ((x)) | \
80 P_ENERGY_ON_IRQ((x)) | \
81 P_ENERGY_OFF_IRQ((x)) | \
82 P_GPHY_IRQ((x)))
83
84/* INTRL2_0 interrupt sources */
85#define P0_IRQ_OFF 0
86#define MEM_DOUBLE_IRQ (1 << 5)
87#define EEE_LPI_IRQ (1 << 6)
88#define P5_CPU_WAKE_IRQ (1 << 7)
89#define P8_CPU_WAKE_IRQ (1 << 8)
90#define P7_CPU_WAKE_IRQ (1 << 9)
91#define IEEE1588_IRQ (1 << 10)
92#define MDIO_ERR_IRQ (1 << 11)
93#define MDIO_DONE_IRQ (1 << 12)
94#define GISB_ERR_IRQ (1 << 13)
95#define UBUS_ERR_IRQ (1 << 14)
96#define FAILOVER_ON_IRQ (1 << 15)
97#define FAILOVER_OFF_IRQ (1 << 16)
98#define TCAM_SOFT_ERR_IRQ (1 << 17)
99
100/* INTRL2_1 interrupt sources */
101#define P7_IRQ_OFF 0
102#define P_IRQ_OFF(x) ((6 - (x)) * P_NUM_IRQ)
103
104/* Register set relative to 'CORE' */
105#define CORE_G_PCTL_PORT0 0x00000
106#define CORE_G_PCTL_PORT(x) (CORE_G_PCTL_PORT0 + (x * 0x4))
107#define CORE_IMP_CTL 0x00020
108#define RX_DIS (1 << 0)
109#define TX_DIS (1 << 1)
110#define RX_BCST_EN (1 << 2)
111#define RX_MCST_EN (1 << 3)
112#define RX_UCST_EN (1 << 4)
113#define G_MISTP_STATE_SHIFT 5
114#define G_MISTP_NO_STP (0 << G_MISTP_STATE_SHIFT)
115#define G_MISTP_DIS_STATE (1 << G_MISTP_STATE_SHIFT)
116#define G_MISTP_BLOCK_STATE (2 << G_MISTP_STATE_SHIFT)
117#define G_MISTP_LISTEN_STATE (3 << G_MISTP_STATE_SHIFT)
118#define G_MISTP_LEARN_STATE (4 << G_MISTP_STATE_SHIFT)
119#define G_MISTP_FWD_STATE (5 << G_MISTP_STATE_SHIFT)
120#define G_MISTP_STATE_MASK 0x7
121
122#define CORE_SWMODE 0x0002c
123#define SW_FWDG_MODE (1 << 0)
124#define SW_FWDG_EN (1 << 1)
125#define RTRY_LMT_DIS (1 << 2)
126
127#define CORE_STS_OVERRIDE_IMP 0x00038
128#define GMII_SPEED_UP_2G (1 << 6)
129#define MII_SW_OR (1 << 7)
130
131#define CORE_NEW_CTRL 0x00084
132#define IP_MC (1 << 0)
133#define OUTRANGEERR_DISCARD (1 << 1)
134#define INRANGEERR_DISCARD (1 << 2)
135#define CABLE_DIAG_LEN (1 << 3)
136#define OVERRIDE_AUTO_PD_WAR (1 << 4)
137#define EN_AUTO_PD_WAR (1 << 5)
138#define UC_FWD_EN (1 << 6)
139#define MC_FWD_EN (1 << 7)
140
141#define CORE_SWITCH_CTRL 0x00088
142#define MII_DUMB_FWDG_EN (1 << 6)
143
144#define CORE_SFT_LRN_CTRL 0x000f8
145#define SW_LEARN_CNTL(x) (1 << (x))
146
147#define CORE_STS_OVERRIDE_GMIIP_PORT(x) (0x160 + (x) * 4)
148#define LINK_STS (1 << 0)
149#define DUPLX_MODE (1 << 1)
150#define SPEED_SHIFT 2
151#define SPEED_MASK 0x3
152#define RXFLOW_CNTL (1 << 4)
153#define TXFLOW_CNTL (1 << 5)
154#define SW_OVERRIDE (1 << 6)
155
156#define CORE_WATCHDOG_CTRL 0x001e4
157#define SOFTWARE_RESET (1 << 7)
158#define EN_CHIP_RST (1 << 6)
159#define EN_SW_RESET (1 << 4)
160
161#define CORE_LNKSTS 0x00400
162#define LNK_STS_MASK 0x1ff
163
164#define CORE_SPDSTS 0x00410
165#define SPDSTS_10 0
166#define SPDSTS_100 1
167#define SPDSTS_1000 2
168#define SPDSTS_SHIFT 2
169#define SPDSTS_MASK 0x3
170
171#define CORE_DUPSTS 0x00420
172#define CORE_DUPSTS_MASK 0x1ff
173
174#define CORE_PAUSESTS 0x00428
175#define PAUSESTS_TX_PAUSE_SHIFT 9
176
177#define CORE_GMNCFGCFG 0x0800
178#define RST_MIB_CNT (1 << 0)
179#define RXBPDU_EN (1 << 1)
180
181#define CORE_IMP0_PRT_ID 0x0804
182
183#define CORE_BRCM_HDR_CTRL 0x0080c
184#define BRCM_HDR_EN_P8 (1 << 0)
185#define BRCM_HDR_EN_P5 (1 << 1)
186#define BRCM_HDR_EN_P7 (1 << 2)
187
188#define CORE_BRCM_HDR_CTRL2 0x0828
189
190#define CORE_HL_PRTC_CTRL 0x0940
191#define ARP_EN (1 << 0)
192#define RARP_EN (1 << 1)
193#define DHCP_EN (1 << 2)
194#define ICMPV4_EN (1 << 3)
195#define ICMPV6_EN (1 << 4)
196#define ICMPV6_FWD_MODE (1 << 5)
197#define IGMP_DIP_EN (1 << 8)
198#define IGMP_RPTLVE_EN (1 << 9)
199#define IGMP_RTPLVE_FWD_MODE (1 << 10)
200#define IGMP_QRY_EN (1 << 11)
201#define IGMP_QRY_FWD_MODE (1 << 12)
202#define IGMP_UKN_EN (1 << 13)
203#define IGMP_UKN_FWD_MODE (1 << 14)
204#define MLD_RPTDONE_EN (1 << 15)
205#define MLD_RPTDONE_FWD_MODE (1 << 16)
206#define MLD_QRY_EN (1 << 17)
207#define MLD_QRY_FWD_MODE (1 << 18)
208
209#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
214#define CORE_MEM_PSM_VDD_CTRL 0x2380
215#define P_TXQ_PSM_VDD_SHIFT 2
216#define P_TXQ_PSM_VDD_MASK 0x3
217#define P_TXQ_PSM_VDD(x) (P_TXQ_PSM_VDD_MASK << \
218 ((x) * P_TXQ_PSM_VDD_SHIFT))
219
220#define CORE_P0_MIB_OFFSET 0x8000
221#define P_MIB_SIZE 0x400
222#define CORE_P_MIB_OFFSET(x) (CORE_P0_MIB_OFFSET + (x) * P_MIB_SIZE)
223
224#define CORE_PORT_VLAN_CTL_PORT(x) (0xc400 + ((x) * 0x8))
225#define PORT_VLAN_CTRL_MASK 0x1ff
226
227#endif /* __BCM_SF2_REGS_H */