1 /******************************************************************************/
3 /* Broadcom BCM5700 Linux Network Driver, Copyright (c) 2001 Broadcom */
5 /* All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify */
8 /* it under the terms of the GNU General Public License as published by */
9 /* the Free Software Foundation, located in the file LICENSE. */
12 /******************************************************************************/
19 /******************************************************************************/
21 /******************************************************************************/
23 #define AN_LINK_TIMER_INTERVAL_US 9000 /* 10ms */
30 /******************************************************************************/
31 /* Main data structure for keeping track of 802.3z auto-negotation state */
32 /* variables as shown in Figure 37-6 of the IEEE 802.3z specification. */
33 /******************************************************************************/
37 /* Current auto-negotiation state. */
39 #define AN_STATE_UNKNOWN 0
40 #define AN_STATE_AN_ENABLE 1
41 #define AN_STATE_AN_RESTART_INIT 2
42 #define AN_STATE_AN_RESTART 3
43 #define AN_STATE_DISABLE_LINK_OK 4
44 #define AN_STATE_ABILITY_DETECT_INIT 5
45 #define AN_STATE_ABILITY_DETECT 6
46 #define AN_STATE_ACK_DETECT_INIT 7
47 #define AN_STATE_ACK_DETECT 8
48 #define AN_STATE_COMPLETE_ACK_INIT 9
49 #define AN_STATE_COMPLETE_ACK 10
50 #define AN_STATE_IDLE_DETECT_INIT 11
51 #define AN_STATE_IDLE_DETECT 12
52 #define AN_STATE_LINK_OK 13
53 #define AN_STATE_NEXT_PAGE_WAIT_INIT 14
54 #define AN_STATE_NEXT_PAGE_WAIT 16
57 unsigned long LinkTime_us
;
60 unsigned long CurrentTime_us
;
62 /* Need these values for consistency check. */
63 unsigned short AbilityMatchCfg
;
65 /* Ability, idle, and ack match functions. */
66 unsigned long AbilityMatchCnt
;
74 /* The TxConfig register is arranged as follows: */
77 /* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ */
78 /* | D7| D6| D5| D4| D3| D2| D1| D0|D15|D14|D13|D12|D11|D10| D9| D8| */
79 /* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ */
82 #ifdef BIG_ENDIAN_HOST
83 unsigned int D7
:1; /* PS1 */
84 unsigned int D6
:1; /* HD */
85 unsigned int D5
:1; /* FD */
91 unsigned int D15
:1; /* NP */
92 unsigned int D14
:1; /* ACK */
93 unsigned int D13
:1; /* RF2 */
94 unsigned int D12
:1; /* RF1 */
98 unsigned int D8
:1; /* PS2 */
99 #else /* BIG_ENDIAN_HOST */
100 unsigned int D8
:1; /* PS2 */
104 unsigned int D12
:1; /* RF1 */
105 unsigned int D13
:1; /* RF2 */
106 unsigned int D14
:1; /* ACK */
107 unsigned int D15
:1; /* NP */
113 unsigned int D5
:1; /* FD */
114 unsigned int D6
:1; /* HD */
115 unsigned int D7
:1; /* PS1 */
119 unsigned short AsUSHORT
;
121 #define D8_PS2 bits.D8
122 #define D12_RF1 bits.D12
123 #define D13_RF2 bits.D13
124 #define D14_ACK bits.D14
125 #define D15_NP bits.D15
126 #define D5_FD bits.D5
127 #define D6_HD bits.D6
128 #define D7_PS1 bits.D7
134 /* The RxConfig register is arranged as follows: */
137 /* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ */
138 /* | D7| D6| D5| D4| D3| D2| D1| D0|D15|D14|D13|D12|D11|D10| D9| D8| */
139 /* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ */
142 #ifdef BIG_ENDIAN_HOST
143 unsigned int D7
:1; /* PS1 */
144 unsigned int D6
:1; /* HD */
145 unsigned int D5
:1; /* FD */
151 unsigned int D15
:1; /* NP */
152 unsigned int D14
:1; /* ACK */
153 unsigned int D13
:1; /* RF2 */
154 unsigned int D12
:1; /* RF1 */
158 unsigned int D8
:1; /* PS2 */
159 #else /* BIG_ENDIAN_HOST */
160 unsigned int D8
:1; /* PS2 */
164 unsigned int D12
:1; /* RF1 */
165 unsigned int D13
:1; /* RF2 */
166 unsigned int D14
:1; /* ACK */
167 unsigned int D15
:1; /* NP */
173 unsigned int D5
:1; /* FD */
174 unsigned int D6
:1; /* HD */
175 unsigned int D7
:1; /* PS1 */
179 unsigned short AsUSHORT
;
182 #define AN_CONFIG_NP 0x0080
183 #define AN_CONFIG_ACK 0x0040
184 #define AN_CONFIG_RF2 0x0020
185 #define AN_CONFIG_RF1 0x0010
186 #define AN_CONFIG_PS2 0x0001
187 #define AN_CONFIG_PS1 0x8000
188 #define AN_CONFIG_HD 0x4000
189 #define AN_CONFIG_FD 0x2000
192 /* Management registers. */
194 /* Control register. */
199 unsigned int an_enable
:1;
200 unsigned int loopback
:1;
201 unsigned int reset
:1;
202 unsigned int restart_an
:1;
205 unsigned short AsUSHORT
;
207 #define mr_an_enable Mr0.bits.an_enable
208 #define mr_loopback Mr0.bits.loopback
209 #define mr_main_reset Mr0.bits.reset
210 #define mr_restart_an Mr0.bits.restart_an
213 /* Status register. */
218 unsigned int an_complete
:1;
219 unsigned int link_ok
:1;
222 unsigned short AsUSHORT
;
224 #define mr_an_complete Mr1.bits.an_complete
225 #define mr_link_ok Mr1.bits.link_ok
228 /* Advertisement register. */
233 unsigned int reserved_4
:5;
234 unsigned int full_duplex
:1;
235 unsigned int half_duplex
:1;
236 unsigned int sym_pause
:1;
237 unsigned int asym_pause
:1;
238 unsigned int reserved_11
:3;
239 unsigned int remote_fault1
:1;
240 unsigned int remote_fault2
:1;
241 unsigned int reserved_14
:1;
242 unsigned int next_page
:1;
245 unsigned short AsUSHORT
;
247 #define mr_adv_full_duplex Mr4.bits.full_duplex
248 #define mr_adv_half_duplex Mr4.bits.half_duplex
249 #define mr_adv_sym_pause Mr4.bits.sym_pause
250 #define mr_adv_asym_pause Mr4.bits.asym_pause
251 #define mr_adv_remote_fault1 Mr4.bits.remote_fault1
252 #define mr_adv_remote_fault2 Mr4.bits.remote_fault2
253 #define mr_adv_next_page Mr4.bits.next_page
256 /* Link partner advertisement register. */
261 unsigned int reserved_4
:5;
262 unsigned int lp_full_duplex
:1;
263 unsigned int lp_half_duplex
:1;
264 unsigned int lp_sym_pause
:1;
265 unsigned int lp_asym_pause
:1;
266 unsigned int reserved_11
:3;
267 unsigned int lp_remote_fault1
:1;
268 unsigned int lp_remote_fault2
:1;
269 unsigned int lp_ack
:1;
270 unsigned int lp_next_page
:1;
273 unsigned short AsUSHORT
;
275 #define mr_lp_adv_full_duplex Mr5.bits.lp_full_duplex
276 #define mr_lp_adv_half_duplex Mr5.bits.lp_half_duplex
277 #define mr_lp_adv_sym_pause Mr5.bits.lp_sym_pause
278 #define mr_lp_adv_asym_pause Mr5.bits.lp_asym_pause
279 #define mr_lp_adv_remote_fault1 Mr5.bits.lp_remote_fault1
280 #define mr_lp_adv_remote_fault2 Mr5.bits.lp_remote_fault2
281 #define mr_lp_adv_next_page Mr5.bits.lp_next_page
284 /* Auto-negotiation expansion register. */
289 unsigned int reserved_0
:1;
290 unsigned int page_received
:1;
291 unsigned int next_pageable
:1;
292 unsigned int reserved_15
:13;
295 unsigned short AsUSHORT
;
298 /* Auto-negotiation next page transmit register. */
303 unsigned int code_field
:11;
304 unsigned int toggle
:1;
306 unsigned int message_page
:1;
307 unsigned int reserved_14
:1;
308 unsigned int next_page
:1;
311 unsigned short AsUSHORT
;
313 #define mr_np_tx Mr7.AsUSHORT
316 /* Auto-negotiation link partner ability register. */
321 unsigned int code_field
:11;
322 unsigned int toggle
:1;
324 unsigned int message_page
:1;
326 unsigned int next_page
:1;
329 unsigned short AsUSHORT
;
331 #define mr_lp_np_rx Mr8.AsUSHORT
334 /* Extended status register. */
339 unsigned int reserved_11
:12;
340 unsigned int base1000_t_hd
:1;
341 unsigned int base1000_t_fd
:1;
342 unsigned int base1000_x_hd
:1;
343 unsigned int base1000_x_fd
:1;
346 unsigned short AsUSHORT
;
349 /* Miscellaneous state variables. */
354 unsigned int toggle_tx
:1;
355 unsigned int toggle_rx
:1;
356 unsigned int np_rx
:1;
357 unsigned int page_rx
:1;
358 unsigned int np_loaded
:1;
361 unsigned short AsUSHORT
;
363 #define mr_toggle_tx MrMisc.bits.toggle_tx
364 #define mr_toggle_rx MrMisc.bits.toggle_rx
365 #define mr_np_rx MrMisc.bits.np_rx
366 #define mr_page_rx MrMisc.bits.page_rx
367 #define mr_np_loaded MrMisc.bits.np_loaded
371 /* Implement specifics */
373 /* Pointer to the operating system specific data structure. */
375 } AN_STATE_INFO
, *PAN_STATE_INFO
;
378 /******************************************************************************/
379 /* Return code of Autoneg8023z. */
380 /******************************************************************************/
384 AUTONEG_STATUS_OK
= 0,
385 AUTONEG_STATUS_DONE
= 1,
386 AUTONEG_STATUS_TIMER_ENABLED
= 2,
387 AUTONEG_STATUS_FAILED
= 0xfffffff
388 } AUTONEG_STATUS
, *PAUTONEG_STATUS
;
391 /******************************************************************************/
392 /* Function prototypes. */
393 /******************************************************************************/
395 AUTONEG_STATUS
Autoneg8023z(PAN_STATE_INFO pAnInfo
);
396 void AutonegInit(PAN_STATE_INFO pAnInfo
);
399 /******************************************************************************/
400 /* The following functions are defined in the os-dependent module. */
401 /******************************************************************************/
403 void MM_AnTxConfig(PAN_STATE_INFO pAnInfo
);
404 void MM_AnTxIdle(PAN_STATE_INFO pAnInfo
);
405 char MM_AnRxConfig(PAN_STATE_INFO pAnInfo
, unsigned short *pRxConfig
);
408 #endif /* AUTONEG_H */