xref: /openbmc/linux/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.h (revision 58e16d792a6a8c6b750f637a4649967fcac853dc)
1*d0ae6124SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2aa43c215SJeff Kirsher /*
3aa43c215SJeff Kirsher  * Copyright (C) 2003 - 2009 NetXen, Inc.
4aa43c215SJeff Kirsher  * Copyright (C) 2009 - QLogic Corporation.
5aa43c215SJeff Kirsher  * All rights reserved.
6aa43c215SJeff Kirsher  */
7aa43c215SJeff Kirsher 
8aa43c215SJeff Kirsher #ifndef __NETXEN_NIC_HW_H_
9aa43c215SJeff Kirsher #define __NETXEN_NIC_HW_H_
10aa43c215SJeff Kirsher 
11aa43c215SJeff Kirsher /* Hardware memory size of 128 meg */
12aa43c215SJeff Kirsher #define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
13aa43c215SJeff Kirsher 
14aa43c215SJeff Kirsher struct netxen_adapter;
15aa43c215SJeff Kirsher 
16aa43c215SJeff Kirsher #define NETXEN_PCI_MAPSIZE_BYTES  (NETXEN_PCI_MAPSIZE << 20)
17aa43c215SJeff Kirsher 
18aa43c215SJeff Kirsher void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
19aa43c215SJeff Kirsher 
20aa43c215SJeff Kirsher /* Nibble or Byte mode for phy interface (GbE mode only) */
21aa43c215SJeff Kirsher 
22aa43c215SJeff Kirsher #define _netxen_crb_get_bit(var, bit)  ((var >> bit) & 0x1)
23aa43c215SJeff Kirsher 
24aa43c215SJeff Kirsher /*
25aa43c215SJeff Kirsher  * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
26aa43c215SJeff Kirsher  *
27aa43c215SJeff Kirsher  *	Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
28aa43c215SJeff Kirsher  *	Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
29aa43c215SJeff Kirsher  *	Bit 2 : enable_rx => 1:enable frame recv, 0:disable
30aa43c215SJeff Kirsher  *	Bit 3 : rx_synced => R/O: recv enable synched to recv stream
31aa43c215SJeff Kirsher  *	Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
32aa43c215SJeff Kirsher  *	Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
33aa43c215SJeff Kirsher  *	Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
34aa43c215SJeff Kirsher  *	Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
35aa43c215SJeff Kirsher  *	Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
36aa43c215SJeff Kirsher  *	Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
37aa43c215SJeff Kirsher  *	Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
38aa43c215SJeff Kirsher  *	Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
39aa43c215SJeff Kirsher  */
40aa43c215SJeff Kirsher 
41aa43c215SJeff Kirsher #define netxen_gb_tx_flowctl(config_word)	\
42aa43c215SJeff Kirsher 	((config_word) |= 1 << 4)
43aa43c215SJeff Kirsher #define netxen_gb_rx_flowctl(config_word)	\
44aa43c215SJeff Kirsher 	((config_word) |= 1 << 5)
45aa43c215SJeff Kirsher #define netxen_gb_tx_reset_pb(config_word)	\
46aa43c215SJeff Kirsher 	((config_word) |= 1 << 16)
47aa43c215SJeff Kirsher #define netxen_gb_rx_reset_pb(config_word)	\
48aa43c215SJeff Kirsher 	((config_word) |= 1 << 17)
49aa43c215SJeff Kirsher #define netxen_gb_tx_reset_mac(config_word)	\
50aa43c215SJeff Kirsher 	((config_word) |= 1 << 18)
51aa43c215SJeff Kirsher #define netxen_gb_rx_reset_mac(config_word)	\
52aa43c215SJeff Kirsher 	((config_word) |= 1 << 19)
53aa43c215SJeff Kirsher 
54aa43c215SJeff Kirsher #define netxen_gb_unset_tx_flowctl(config_word)	\
55aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 4))
56aa43c215SJeff Kirsher #define netxen_gb_unset_rx_flowctl(config_word)	\
57aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 5))
58aa43c215SJeff Kirsher 
59aa43c215SJeff Kirsher #define netxen_gb_get_tx_synced(config_word)	\
60aa43c215SJeff Kirsher 		_netxen_crb_get_bit((config_word), 1)
61aa43c215SJeff Kirsher #define netxen_gb_get_rx_synced(config_word)	\
62aa43c215SJeff Kirsher 		_netxen_crb_get_bit((config_word), 3)
63aa43c215SJeff Kirsher #define netxen_gb_get_tx_flowctl(config_word)	\
64aa43c215SJeff Kirsher 		_netxen_crb_get_bit((config_word), 4)
65aa43c215SJeff Kirsher #define netxen_gb_get_rx_flowctl(config_word)	\
66aa43c215SJeff Kirsher 		_netxen_crb_get_bit((config_word), 5)
67aa43c215SJeff Kirsher #define netxen_gb_get_soft_reset(config_word)	\
68aa43c215SJeff Kirsher 		_netxen_crb_get_bit((config_word), 31)
69aa43c215SJeff Kirsher 
70aa43c215SJeff Kirsher #define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
71aa43c215SJeff Kirsher 
72aa43c215SJeff Kirsher #define netxen_gb_set_mii_mgmt_clockselect(config_word, val)	\
73aa43c215SJeff Kirsher 		((config_word) |= ((val) & 0x07))
74aa43c215SJeff Kirsher #define netxen_gb_mii_mgmt_reset(config_word)	\
75aa43c215SJeff Kirsher 		((config_word) |= 1 << 31)
76aa43c215SJeff Kirsher #define netxen_gb_mii_mgmt_unset(config_word)	\
77aa43c215SJeff Kirsher 		((config_word) &= ~(1 << 31))
78aa43c215SJeff Kirsher 
79aa43c215SJeff Kirsher /*
80aa43c215SJeff Kirsher  * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
81aa43c215SJeff Kirsher  * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
82aa43c215SJeff Kirsher  * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
83aa43c215SJeff Kirsher  */
84aa43c215SJeff Kirsher 
85aa43c215SJeff Kirsher #define netxen_gb_mii_mgmt_set_read_cycle(config_word)	\
86aa43c215SJeff Kirsher 		((config_word) |= 1 << 0)
87aa43c215SJeff Kirsher #define netxen_gb_mii_mgmt_reg_addr(config_word, val)	\
88aa43c215SJeff Kirsher 		((config_word) |= ((val) & 0x1F))
89aa43c215SJeff Kirsher #define netxen_gb_mii_mgmt_phy_addr(config_word, val)	\
90aa43c215SJeff Kirsher 		((config_word) |= (((val) & 0x1F) << 8))
91aa43c215SJeff Kirsher 
92aa43c215SJeff Kirsher /*
93aa43c215SJeff Kirsher  * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
94aa43c215SJeff Kirsher  * Read-only register.
95aa43c215SJeff Kirsher  * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
96aa43c215SJeff Kirsher  * Bit 1 : scanning => 1:scan operation in progress, 0:idle
97aa43c215SJeff Kirsher  * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
98aa43c215SJeff Kirsher  */
99aa43c215SJeff Kirsher #define netxen_get_gb_mii_mgmt_busy(config_word)	\
100aa43c215SJeff Kirsher 		_netxen_crb_get_bit(config_word, 0)
101aa43c215SJeff Kirsher #define netxen_get_gb_mii_mgmt_scanning(config_word)	\
102aa43c215SJeff Kirsher 		_netxen_crb_get_bit(config_word, 1)
103aa43c215SJeff Kirsher #define netxen_get_gb_mii_mgmt_notvalid(config_word)	\
104aa43c215SJeff Kirsher 		_netxen_crb_get_bit(config_word, 2)
105aa43c215SJeff Kirsher /*
106aa43c215SJeff Kirsher  * NIU XG Pause Ctl Register
107aa43c215SJeff Kirsher  *
108aa43c215SJeff Kirsher  *      Bit 0       : xg0_mask => 1:disable tx pause frames
109aa43c215SJeff Kirsher  *      Bit 1       : xg0_request => 1:request single pause frame
110aa43c215SJeff Kirsher  *      Bit 2       : xg0_on_off => 1:request is pause on, 0:off
111aa43c215SJeff Kirsher  *      Bit 3       : xg1_mask => 1:disable tx pause frames
112aa43c215SJeff Kirsher  *      Bit 4       : xg1_request => 1:request single pause frame
113aa43c215SJeff Kirsher  *      Bit 5       : xg1_on_off => 1:request is pause on, 0:off
114aa43c215SJeff Kirsher  */
115aa43c215SJeff Kirsher 
116aa43c215SJeff Kirsher #define netxen_xg_set_xg0_mask(config_word)    \
117aa43c215SJeff Kirsher 	((config_word) |= 1 << 0)
118aa43c215SJeff Kirsher #define netxen_xg_set_xg1_mask(config_word)    \
119aa43c215SJeff Kirsher 	((config_word) |= 1 << 3)
120aa43c215SJeff Kirsher 
121aa43c215SJeff Kirsher #define netxen_xg_get_xg0_mask(config_word)    \
122aa43c215SJeff Kirsher 	_netxen_crb_get_bit((config_word), 0)
123aa43c215SJeff Kirsher #define netxen_xg_get_xg1_mask(config_word)    \
124aa43c215SJeff Kirsher 	_netxen_crb_get_bit((config_word), 3)
125aa43c215SJeff Kirsher 
126aa43c215SJeff Kirsher #define netxen_xg_unset_xg0_mask(config_word)  \
127aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 0))
128aa43c215SJeff Kirsher #define netxen_xg_unset_xg1_mask(config_word)  \
129aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 3))
130aa43c215SJeff Kirsher 
131aa43c215SJeff Kirsher /*
132aa43c215SJeff Kirsher  * NIU XG Pause Ctl Register
133aa43c215SJeff Kirsher  *
134aa43c215SJeff Kirsher  *      Bit 0       : xg0_mask => 1:disable tx pause frames
135aa43c215SJeff Kirsher  *      Bit 1       : xg0_request => 1:request single pause frame
136aa43c215SJeff Kirsher  *      Bit 2       : xg0_on_off => 1:request is pause on, 0:off
137aa43c215SJeff Kirsher  *      Bit 3       : xg1_mask => 1:disable tx pause frames
138aa43c215SJeff Kirsher  *      Bit 4       : xg1_request => 1:request single pause frame
139aa43c215SJeff Kirsher  *      Bit 5       : xg1_on_off => 1:request is pause on, 0:off
140aa43c215SJeff Kirsher  */
141aa43c215SJeff Kirsher #define netxen_gb_set_gb0_mask(config_word)    \
142aa43c215SJeff Kirsher 	((config_word) |= 1 << 0)
143aa43c215SJeff Kirsher #define netxen_gb_set_gb1_mask(config_word)    \
144aa43c215SJeff Kirsher 	((config_word) |= 1 << 2)
145aa43c215SJeff Kirsher #define netxen_gb_set_gb2_mask(config_word)    \
146aa43c215SJeff Kirsher 	((config_word) |= 1 << 4)
147aa43c215SJeff Kirsher #define netxen_gb_set_gb3_mask(config_word)    \
148aa43c215SJeff Kirsher 	((config_word) |= 1 << 6)
149aa43c215SJeff Kirsher 
150aa43c215SJeff Kirsher #define netxen_gb_get_gb0_mask(config_word)    \
151aa43c215SJeff Kirsher 	_netxen_crb_get_bit((config_word), 0)
152aa43c215SJeff Kirsher #define netxen_gb_get_gb1_mask(config_word)    \
153aa43c215SJeff Kirsher 	_netxen_crb_get_bit((config_word), 2)
154aa43c215SJeff Kirsher #define netxen_gb_get_gb2_mask(config_word)    \
155aa43c215SJeff Kirsher 	_netxen_crb_get_bit((config_word), 4)
156aa43c215SJeff Kirsher #define netxen_gb_get_gb3_mask(config_word)    \
157aa43c215SJeff Kirsher 	_netxen_crb_get_bit((config_word), 6)
158aa43c215SJeff Kirsher 
159aa43c215SJeff Kirsher #define netxen_gb_unset_gb0_mask(config_word)  \
160aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 0))
161aa43c215SJeff Kirsher #define netxen_gb_unset_gb1_mask(config_word)  \
162aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 2))
163aa43c215SJeff Kirsher #define netxen_gb_unset_gb2_mask(config_word)  \
164aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 4))
165aa43c215SJeff Kirsher #define netxen_gb_unset_gb3_mask(config_word)  \
166aa43c215SJeff Kirsher 	((config_word) &= ~(1 << 6))
167aa43c215SJeff Kirsher 
168aa43c215SJeff Kirsher 
169aa43c215SJeff Kirsher /*
170aa43c215SJeff Kirsher  * PHY-Specific MII control/status registers.
171aa43c215SJeff Kirsher  */
172aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL		0
173aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS		1
174aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0		2
175aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1		3
176aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG		4
177aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART		5
178aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE	6
179aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT	7
180aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE	8
181aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL	9
182aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS	10
183aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS	15
184aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL		16
185aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS		17
186aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE		18
187aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS		19
188aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE	20
189aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT	21
190aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL		24
191aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE	25
192aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET	26
193aa43c215SJeff Kirsher #define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE	27
194aa43c215SJeff Kirsher 
195aa43c215SJeff Kirsher /*
196aa43c215SJeff Kirsher  * PHY-Specific Status Register (reg 17).
197aa43c215SJeff Kirsher  *
198aa43c215SJeff Kirsher  * Bit 0      : jabber => 1:jabber detected, 0:not
199aa43c215SJeff Kirsher  * Bit 1      : polarity => 1:polarity reversed, 0:normal
200aa43c215SJeff Kirsher  * Bit 2      : recvpause => 1:receive pause enabled, 0:disabled
201aa43c215SJeff Kirsher  * Bit 3      : xmitpause => 1:transmit pause enabled, 0:disabled
202aa43c215SJeff Kirsher  * Bit 4      : energydetect => 1:sleep, 0:active
203aa43c215SJeff Kirsher  * Bit 5      : downshift => 1:downshift, 0:no downshift
204aa43c215SJeff Kirsher  * Bit 6      : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
205aa43c215SJeff Kirsher  * Bits 7-9   : cablelen => not valid in 10Mb/s mode
206aa43c215SJeff Kirsher  *			0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
207aa43c215SJeff Kirsher  * Bit 10     : link => 1:link up, 0:link down
208aa43c215SJeff Kirsher  * Bit 11     : resolved => 1:speed and duplex resolved, 0:not yet
209aa43c215SJeff Kirsher  * Bit 12     : pagercvd => 1:page received, 0:page not received
210aa43c215SJeff Kirsher  * Bit 13     : duplex => 1:full duplex, 0:half duplex
211aa43c215SJeff Kirsher  * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
212aa43c215SJeff Kirsher  */
213aa43c215SJeff Kirsher 
214aa43c215SJeff Kirsher #define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
215aa43c215SJeff Kirsher 
216aa43c215SJeff Kirsher #define netxen_set_phy_speed(config_word, val)	\
217aa43c215SJeff Kirsher 		((config_word) |= ((val & 0x03) << 14))
218aa43c215SJeff Kirsher #define netxen_set_phy_duplex(config_word)	\
219aa43c215SJeff Kirsher 		((config_word) |= 1 << 13)
220aa43c215SJeff Kirsher #define netxen_clear_phy_duplex(config_word)	\
221aa43c215SJeff Kirsher 		((config_word) &= ~(1 << 13))
222aa43c215SJeff Kirsher 
223aa43c215SJeff Kirsher #define netxen_get_phy_link(config_word)	\
224aa43c215SJeff Kirsher 		_netxen_crb_get_bit(config_word, 10)
225aa43c215SJeff Kirsher #define netxen_get_phy_duplex(config_word)	\
226aa43c215SJeff Kirsher 		_netxen_crb_get_bit(config_word, 13)
227aa43c215SJeff Kirsher 
228aa43c215SJeff Kirsher /*
229aa43c215SJeff Kirsher  * NIU Mode Register.
230aa43c215SJeff Kirsher  * Bit 0 : enable FibreChannel
231aa43c215SJeff Kirsher  * Bit 1 : enable 10/100/1000 Ethernet
232aa43c215SJeff Kirsher  * Bit 2 : enable 10Gb Ethernet
233aa43c215SJeff Kirsher  */
234aa43c215SJeff Kirsher 
235aa43c215SJeff Kirsher #define netxen_get_niu_enable_ge(config_word)	\
236aa43c215SJeff Kirsher 		_netxen_crb_get_bit(config_word, 1)
237aa43c215SJeff Kirsher 
238aa43c215SJeff Kirsher #define NETXEN_NIU_NON_PROMISC_MODE	0
239aa43c215SJeff Kirsher #define NETXEN_NIU_PROMISC_MODE		1
240aa43c215SJeff Kirsher #define NETXEN_NIU_ALLMULTI_MODE	2
241aa43c215SJeff Kirsher 
242aa43c215SJeff Kirsher /*
243aa43c215SJeff Kirsher  * NIU XG MAC Config Register
244aa43c215SJeff Kirsher  *
245aa43c215SJeff Kirsher  * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
246aa43c215SJeff Kirsher  * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
247aa43c215SJeff Kirsher  * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
248aa43c215SJeff Kirsher  * Bit 27: xaui_framer_reset
249aa43c215SJeff Kirsher  * Bit 28: xaui_rx_reset
250aa43c215SJeff Kirsher  * Bit 29: xaui_tx_reset
251aa43c215SJeff Kirsher  * Bit 30: xg_ingress_afifo_reset
252aa43c215SJeff Kirsher  * Bit 31: xg_egress_afifo_reset
253aa43c215SJeff Kirsher  */
254aa43c215SJeff Kirsher 
255aa43c215SJeff Kirsher #define netxen_xg_soft_reset(config_word)	\
256aa43c215SJeff Kirsher 		((config_word) |= 1 << 4)
257aa43c215SJeff Kirsher 
258aa43c215SJeff Kirsher typedef struct {
259aa43c215SJeff Kirsher 	unsigned valid;
260aa43c215SJeff Kirsher 	unsigned start_128M;
261aa43c215SJeff Kirsher 	unsigned end_128M;
262aa43c215SJeff Kirsher 	unsigned start_2M;
263aa43c215SJeff Kirsher } crb_128M_2M_sub_block_map_t;
264aa43c215SJeff Kirsher 
265aa43c215SJeff Kirsher typedef struct {
266aa43c215SJeff Kirsher 	crb_128M_2M_sub_block_map_t sub_block[16];
267aa43c215SJeff Kirsher } crb_128M_2M_block_map_t;
268aa43c215SJeff Kirsher 
269aa43c215SJeff Kirsher #endif				/* __NETXEN_NIC_HW_H_ */
270