wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | /******************************************************************************/ |
| 2 | /* */ |
| 3 | /* Broadcom BCM5700 Linux Network Driver, Copyright (c) 2001 Broadcom */ |
| 4 | /* Corporation. */ |
| 5 | /* All rights reserved. */ |
| 6 | /* */ |
| 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. */ |
| 10 | /* */ |
| 11 | /* History: */ |
| 12 | /******************************************************************************/ |
| 13 | #if !defined(CONFIG_NET_MULTI) |
| 14 | #if INCLUDE_TBI_SUPPORT |
| 15 | #include "bcm570x_autoneg.h" |
| 16 | #include "bcm570x_mm.h" |
| 17 | |
| 18 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 19 | /******************************************************************************/ |
| 20 | /* Description: */ |
| 21 | /* */ |
| 22 | /* Return: */ |
| 23 | /******************************************************************************/ |
| 24 | void |
| 25 | MM_AnTxConfig( |
| 26 | PAN_STATE_INFO pAnInfo) |
| 27 | { |
| 28 | PLM_DEVICE_BLOCK pDevice; |
| 29 | |
| 30 | pDevice = (PLM_DEVICE_BLOCK) pAnInfo->pContext; |
| 31 | |
| 32 | REG_WR(pDevice, MacCtrl.TxAutoNeg, (LM_UINT32) pAnInfo->TxConfig.AsUSHORT); |
| 33 | |
| 34 | pDevice->MacMode |= MAC_MODE_SEND_CONFIGS; |
| 35 | REG_WR(pDevice, MacCtrl.Mode, pDevice->MacMode); |
| 36 | } |
| 37 | |
| 38 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 39 | /******************************************************************************/ |
| 40 | /* Description: */ |
| 41 | /* */ |
| 42 | /* Return: */ |
| 43 | /******************************************************************************/ |
| 44 | void |
| 45 | MM_AnTxIdle( |
| 46 | PAN_STATE_INFO pAnInfo) |
| 47 | { |
| 48 | PLM_DEVICE_BLOCK pDevice; |
| 49 | |
| 50 | pDevice = (PLM_DEVICE_BLOCK) pAnInfo->pContext; |
| 51 | |
| 52 | pDevice->MacMode &= ~MAC_MODE_SEND_CONFIGS; |
| 53 | REG_WR(pDevice, MacCtrl.Mode, pDevice->MacMode); |
| 54 | } |
| 55 | |
| 56 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 57 | /******************************************************************************/ |
| 58 | /* Description: */ |
| 59 | /* */ |
| 60 | /* Return: */ |
| 61 | /******************************************************************************/ |
| 62 | char |
| 63 | MM_AnRxConfig( |
| 64 | PAN_STATE_INFO pAnInfo, |
| 65 | unsigned short *pRxConfig) |
| 66 | { |
| 67 | PLM_DEVICE_BLOCK pDevice; |
| 68 | LM_UINT32 Value32; |
| 69 | char Retcode; |
| 70 | |
| 71 | Retcode = AN_FALSE; |
| 72 | |
| 73 | pDevice = (PLM_DEVICE_BLOCK) pAnInfo->pContext; |
| 74 | |
| 75 | Value32 = REG_RD(pDevice, MacCtrl.Status); |
| 76 | if(Value32 & MAC_STATUS_RECEIVING_CFG) |
| 77 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 78 | Value32 = REG_RD(pDevice, MacCtrl.RxAutoNeg); |
| 79 | *pRxConfig = (unsigned short) Value32; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 80 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 81 | Retcode = AN_TRUE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | return Retcode; |
| 85 | } |
| 86 | |
| 87 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 88 | /******************************************************************************/ |
| 89 | /* Description: */ |
| 90 | /* */ |
| 91 | /* Return: */ |
| 92 | /******************************************************************************/ |
| 93 | void |
| 94 | AutonegInit( |
| 95 | PAN_STATE_INFO pAnInfo) |
| 96 | { |
| 97 | unsigned long j; |
| 98 | |
| 99 | for(j = 0; j < sizeof(AN_STATE_INFO); j++) |
| 100 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 101 | ((unsigned char *) pAnInfo)[j] = 0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | /* Initialize the default advertisement register. */ |
| 105 | pAnInfo->mr_adv_full_duplex = 1; |
| 106 | pAnInfo->mr_adv_sym_pause = 1; |
| 107 | pAnInfo->mr_adv_asym_pause = 1; |
| 108 | pAnInfo->mr_an_enable = 1; |
| 109 | } |
| 110 | |
| 111 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 112 | /******************************************************************************/ |
| 113 | /* Description: */ |
| 114 | /* */ |
| 115 | /* Return: */ |
| 116 | /******************************************************************************/ |
| 117 | AUTONEG_STATUS |
| 118 | Autoneg8023z( |
| 119 | PAN_STATE_INFO pAnInfo) |
| 120 | { |
| 121 | unsigned short RxConfig; |
| 122 | unsigned long Delta_us; |
| 123 | AUTONEG_STATUS AnRet; |
| 124 | |
| 125 | /* Get the current time. */ |
| 126 | if(pAnInfo->State == AN_STATE_UNKNOWN) |
| 127 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 128 | pAnInfo->RxConfig.AsUSHORT = 0; |
| 129 | pAnInfo->CurrentTime_us = 0; |
| 130 | pAnInfo->LinkTime_us = 0; |
| 131 | pAnInfo->AbilityMatchCfg = 0; |
| 132 | pAnInfo->AbilityMatchCnt = 0; |
| 133 | pAnInfo->AbilityMatch = AN_FALSE; |
| 134 | pAnInfo->IdleMatch = AN_FALSE; |
| 135 | pAnInfo->AckMatch = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | /* Increment the timer tick. This function is called every microsecon. */ |
| 139 | /* pAnInfo->CurrentTime_us++; */ |
| 140 | |
| 141 | /* Set the AbilityMatch, IdleMatch, and AckMatch flags if their */ |
| 142 | /* corresponding conditions are satisfied. */ |
| 143 | if(MM_AnRxConfig(pAnInfo, &RxConfig)) |
| 144 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 145 | if(RxConfig != pAnInfo->AbilityMatchCfg) |
| 146 | { |
| 147 | pAnInfo->AbilityMatchCfg = RxConfig; |
| 148 | pAnInfo->AbilityMatch = AN_FALSE; |
| 149 | pAnInfo->AbilityMatchCnt = 0; |
| 150 | } |
| 151 | else |
| 152 | { |
| 153 | pAnInfo->AbilityMatchCnt++; |
| 154 | if(pAnInfo->AbilityMatchCnt > 1) |
| 155 | { |
| 156 | pAnInfo->AbilityMatch = AN_TRUE; |
| 157 | pAnInfo->AbilityMatchCfg = RxConfig; |
| 158 | } |
| 159 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 160 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 161 | if(RxConfig & AN_CONFIG_ACK) |
| 162 | { |
| 163 | pAnInfo->AckMatch = AN_TRUE; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | pAnInfo->AckMatch = AN_FALSE; |
| 168 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 169 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 170 | pAnInfo->IdleMatch = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 171 | } |
| 172 | else |
| 173 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 174 | pAnInfo->IdleMatch = AN_TRUE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 175 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 176 | pAnInfo->AbilityMatchCfg = 0; |
| 177 | pAnInfo->AbilityMatchCnt = 0; |
| 178 | pAnInfo->AbilityMatch = AN_FALSE; |
| 179 | pAnInfo->AckMatch = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 180 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 181 | RxConfig = 0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /* Save the last Config. */ |
| 185 | pAnInfo->RxConfig.AsUSHORT = RxConfig; |
| 186 | |
| 187 | /* Default return code. */ |
| 188 | AnRet = AUTONEG_STATUS_OK; |
| 189 | |
| 190 | /* Autoneg state machine as defined in 802.3z section 37.3.1.5. */ |
| 191 | switch(pAnInfo->State) |
| 192 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 193 | case AN_STATE_UNKNOWN: |
| 194 | if(pAnInfo->mr_an_enable || pAnInfo->mr_restart_an) |
| 195 | { |
| 196 | pAnInfo->CurrentTime_us = 0; |
| 197 | pAnInfo->State = AN_STATE_AN_ENABLE; |
| 198 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 199 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 200 | /* Fall through.*/ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 201 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 202 | case AN_STATE_AN_ENABLE: |
| 203 | pAnInfo->mr_an_complete = AN_FALSE; |
| 204 | pAnInfo->mr_page_rx = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 205 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 206 | if(pAnInfo->mr_an_enable) |
| 207 | { |
| 208 | pAnInfo->LinkTime_us = 0; |
| 209 | pAnInfo->AbilityMatchCfg = 0; |
| 210 | pAnInfo->AbilityMatchCnt = 0; |
| 211 | pAnInfo->AbilityMatch = AN_FALSE; |
| 212 | pAnInfo->IdleMatch = AN_FALSE; |
| 213 | pAnInfo->AckMatch = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 214 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 215 | pAnInfo->State = AN_STATE_AN_RESTART_INIT; |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | pAnInfo->State = AN_STATE_DISABLE_LINK_OK; |
| 220 | } |
| 221 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 222 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 223 | case AN_STATE_AN_RESTART_INIT: |
| 224 | pAnInfo->LinkTime_us = pAnInfo->CurrentTime_us; |
| 225 | pAnInfo->mr_np_loaded = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 226 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 227 | pAnInfo->TxConfig.AsUSHORT = 0; |
| 228 | MM_AnTxConfig(pAnInfo); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 229 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 230 | AnRet = AUTONEG_STATUS_TIMER_ENABLED; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 231 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 232 | pAnInfo->State = AN_STATE_AN_RESTART; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 233 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 234 | /* Fall through.*/ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 235 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 236 | case AN_STATE_AN_RESTART: |
| 237 | /* Get the current time and compute the delta with the saved */ |
| 238 | /* link timer. */ |
| 239 | Delta_us = pAnInfo->CurrentTime_us - pAnInfo->LinkTime_us; |
| 240 | if(Delta_us > AN_LINK_TIMER_INTERVAL_US) |
| 241 | { |
| 242 | pAnInfo->State = AN_STATE_ABILITY_DETECT_INIT; |
| 243 | } |
| 244 | else |
| 245 | { |
| 246 | AnRet = AUTONEG_STATUS_TIMER_ENABLED; |
| 247 | } |
| 248 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 249 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 250 | case AN_STATE_DISABLE_LINK_OK: |
| 251 | AnRet = AUTONEG_STATUS_DONE; |
| 252 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 253 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 254 | case AN_STATE_ABILITY_DETECT_INIT: |
| 255 | /* Note: in the state diagram, this variable is set to */ |
| 256 | /* mr_adv_ability<12>. Is this right?. */ |
| 257 | pAnInfo->mr_toggle_tx = AN_FALSE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 258 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 259 | /* Send the config as advertised in the advertisement register. */ |
| 260 | pAnInfo->TxConfig.AsUSHORT = 0; |
| 261 | pAnInfo->TxConfig.D5_FD = pAnInfo->mr_adv_full_duplex; |
| 262 | pAnInfo->TxConfig.D6_HD = pAnInfo->mr_adv_half_duplex; |
| 263 | pAnInfo->TxConfig.D7_PS1 = pAnInfo->mr_adv_sym_pause; |
| 264 | pAnInfo->TxConfig.D8_PS2 = pAnInfo->mr_adv_asym_pause; |
| 265 | pAnInfo->TxConfig.D12_RF1 = pAnInfo->mr_adv_remote_fault1; |
| 266 | pAnInfo->TxConfig.D13_RF2 = pAnInfo->mr_adv_remote_fault2; |
| 267 | pAnInfo->TxConfig.D15_NP = pAnInfo->mr_adv_next_page; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 268 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 269 | MM_AnTxConfig(pAnInfo); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 270 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 271 | pAnInfo->State = AN_STATE_ABILITY_DETECT; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 272 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 273 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 274 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 275 | case AN_STATE_ABILITY_DETECT: |
| 276 | if(pAnInfo->AbilityMatch == AN_TRUE && |
| 277 | pAnInfo->RxConfig.AsUSHORT != 0) |
| 278 | { |
| 279 | pAnInfo->State = AN_STATE_ACK_DETECT_INIT; |
| 280 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 281 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 282 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 283 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 284 | case AN_STATE_ACK_DETECT_INIT: |
| 285 | pAnInfo->TxConfig.D14_ACK = 1; |
| 286 | MM_AnTxConfig(pAnInfo); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 287 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 288 | pAnInfo->State = AN_STATE_ACK_DETECT; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 289 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 290 | /* Fall through. */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 291 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 292 | case AN_STATE_ACK_DETECT: |
| 293 | if(pAnInfo->AckMatch == AN_TRUE) |
| 294 | { |
| 295 | if((pAnInfo->RxConfig.AsUSHORT & ~AN_CONFIG_ACK) == |
| 296 | (pAnInfo->AbilityMatchCfg & ~AN_CONFIG_ACK)) |
| 297 | { |
| 298 | pAnInfo->State = AN_STATE_COMPLETE_ACK_INIT; |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | pAnInfo->State = AN_STATE_AN_ENABLE; |
| 303 | } |
| 304 | } |
| 305 | else if(pAnInfo->AbilityMatch == AN_TRUE && |
| 306 | pAnInfo->RxConfig.AsUSHORT == 0) |
| 307 | { |
| 308 | pAnInfo->State = AN_STATE_AN_ENABLE; |
| 309 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 310 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 311 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 312 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 313 | case AN_STATE_COMPLETE_ACK_INIT: |
| 314 | /* Make sure invalid bits are not set. */ |
| 315 | if(pAnInfo->RxConfig.bits.D0 || pAnInfo->RxConfig.bits.D1 || |
| 316 | pAnInfo->RxConfig.bits.D2 || pAnInfo->RxConfig.bits.D3 || |
| 317 | pAnInfo->RxConfig.bits.D4 || pAnInfo->RxConfig.bits.D9 || |
| 318 | pAnInfo->RxConfig.bits.D10 || pAnInfo->RxConfig.bits.D11) |
| 319 | { |
| 320 | AnRet = AUTONEG_STATUS_FAILED; |
| 321 | break; |
| 322 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 323 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 324 | /* Set up the link partner advertisement register. */ |
| 325 | pAnInfo->mr_lp_adv_full_duplex = pAnInfo->RxConfig.D5_FD; |
| 326 | pAnInfo->mr_lp_adv_half_duplex = pAnInfo->RxConfig.D6_HD; |
| 327 | pAnInfo->mr_lp_adv_sym_pause = pAnInfo->RxConfig.D7_PS1; |
| 328 | pAnInfo->mr_lp_adv_asym_pause = pAnInfo->RxConfig.D8_PS2; |
| 329 | pAnInfo->mr_lp_adv_remote_fault1 = pAnInfo->RxConfig.D12_RF1; |
| 330 | pAnInfo->mr_lp_adv_remote_fault2 = pAnInfo->RxConfig.D13_RF2; |
| 331 | pAnInfo->mr_lp_adv_next_page = pAnInfo->RxConfig.D15_NP; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 332 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 333 | pAnInfo->LinkTime_us = pAnInfo->CurrentTime_us; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 334 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 335 | pAnInfo->mr_toggle_tx = !pAnInfo->mr_toggle_tx; |
| 336 | pAnInfo->mr_toggle_rx = pAnInfo->RxConfig.bits.D11; |
| 337 | pAnInfo->mr_np_rx = pAnInfo->RxConfig.D15_NP; |
| 338 | pAnInfo->mr_page_rx = AN_TRUE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 339 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 340 | pAnInfo->State = AN_STATE_COMPLETE_ACK; |
| 341 | AnRet = AUTONEG_STATUS_TIMER_ENABLED; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 342 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 343 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 344 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 345 | case AN_STATE_COMPLETE_ACK: |
| 346 | if(pAnInfo->AbilityMatch == AN_TRUE && |
| 347 | pAnInfo->RxConfig.AsUSHORT == 0) |
| 348 | { |
| 349 | pAnInfo->State = AN_STATE_AN_ENABLE; |
| 350 | break; |
| 351 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 352 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 353 | Delta_us = pAnInfo->CurrentTime_us - pAnInfo->LinkTime_us; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 354 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 355 | if(Delta_us > AN_LINK_TIMER_INTERVAL_US) |
| 356 | { |
| 357 | if(pAnInfo->mr_adv_next_page == 0 || |
| 358 | pAnInfo->mr_lp_adv_next_page == 0) |
| 359 | { |
| 360 | pAnInfo->State = AN_STATE_IDLE_DETECT_INIT; |
| 361 | } |
| 362 | else |
| 363 | { |
| 364 | if(pAnInfo->TxConfig.bits.D15 == 0 && |
| 365 | pAnInfo->mr_np_rx == 0) |
| 366 | { |
| 367 | pAnInfo->State = AN_STATE_IDLE_DETECT_INIT; |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | AnRet = AUTONEG_STATUS_FAILED; |
| 372 | } |
| 373 | } |
| 374 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 375 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 376 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 377 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 378 | case AN_STATE_IDLE_DETECT_INIT: |
| 379 | pAnInfo->LinkTime_us = pAnInfo->CurrentTime_us; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 380 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 381 | MM_AnTxIdle(pAnInfo); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 382 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 383 | pAnInfo->State = AN_STATE_IDLE_DETECT; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 384 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 385 | AnRet = AUTONEG_STATUS_TIMER_ENABLED; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 386 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 387 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 388 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 389 | case AN_STATE_IDLE_DETECT: |
| 390 | if(pAnInfo->AbilityMatch == AN_TRUE && |
| 391 | pAnInfo->RxConfig.AsUSHORT == 0) |
| 392 | { |
| 393 | pAnInfo->State = AN_STATE_AN_ENABLE; |
| 394 | break; |
| 395 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 396 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 397 | Delta_us = pAnInfo->CurrentTime_us - pAnInfo->LinkTime_us; |
| 398 | if(Delta_us > AN_LINK_TIMER_INTERVAL_US) |
| 399 | { |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 400 | #if 0 |
| 401 | /* if(pAnInfo->IdleMatch == AN_TRUE) */ |
| 402 | /* { */ |
| 403 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 404 | pAnInfo->State = AN_STATE_LINK_OK; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 405 | #if 0 |
| 406 | /* } */ |
| 407 | /* else */ |
| 408 | /* { */ |
| 409 | /* AnRet = AUTONEG_STATUS_FAILED; */ |
| 410 | /* break; */ |
| 411 | /* } */ |
| 412 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 413 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 414 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 415 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 416 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 417 | case AN_STATE_LINK_OK: |
| 418 | pAnInfo->mr_an_complete = AN_TRUE; |
| 419 | pAnInfo->mr_link_ok = AN_TRUE; |
| 420 | AnRet = AUTONEG_STATUS_DONE; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 421 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 422 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 423 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 424 | case AN_STATE_NEXT_PAGE_WAIT_INIT: |
| 425 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 426 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 427 | case AN_STATE_NEXT_PAGE_WAIT: |
| 428 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 429 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 430 | default: |
| 431 | AnRet = AUTONEG_STATUS_FAILED; |
| 432 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | return AnRet; |
| 436 | } |
| 437 | #endif /* INCLUDE_TBI_SUPPORT */ |
| 438 | |
| 439 | #endif /* !defined(CONFIG_NET_MULTI) */ |