wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /******************************************************************************/ |
| 2 | /* */ |
| 3 | /* Broadcom BCM5700 Linux Network Driver, Copyright (c) 2000 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 | #include <common.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 14 | #include <asm/types.h> |
Shinya Kuribayashi | 3b904cc | 2008-06-09 23:37:44 +0900 | [diff] [blame] | 15 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 16 | #ifdef CONFIG_BMW |
| 17 | #include <mpc824x.h> |
| 18 | #endif |
| 19 | #include <malloc.h> |
| 20 | #include <linux/byteorder/big_endian.h> |
wdenk | 6069ff2 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 21 | #include "bcm570x_mm.h" |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 22 | |
| 23 | #define EMBEDDED 1 |
| 24 | /******************************************************************************/ |
| 25 | /* Local functions. */ |
| 26 | /******************************************************************************/ |
| 27 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 28 | LM_STATUS LM_Abort (PLM_DEVICE_BLOCK pDevice); |
| 29 | LM_STATUS LM_QueueRxPackets (PLM_DEVICE_BLOCK pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 30 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 31 | static LM_STATUS LM_TranslateRequestedMediaType (LM_REQUESTED_MEDIA_TYPE |
| 32 | RequestedMediaType, |
| 33 | PLM_MEDIA_TYPE pMediaType, |
| 34 | PLM_LINE_SPEED pLineSpeed, |
| 35 | PLM_DUPLEX_MODE pDuplexMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 36 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 37 | static LM_STATUS LM_InitBcm540xPhy (PLM_DEVICE_BLOCK pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 38 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 39 | __inline static LM_VOID LM_ServiceRxInterrupt (PLM_DEVICE_BLOCK pDevice); |
| 40 | __inline static LM_VOID LM_ServiceTxInterrupt (PLM_DEVICE_BLOCK pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 41 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 42 | static LM_STATUS LM_ForceAutoNegBcm540xPhy (PLM_DEVICE_BLOCK pDevice, |
| 43 | LM_REQUESTED_MEDIA_TYPE |
| 44 | RequestedMediaType); |
| 45 | static LM_STATUS LM_ForceAutoNeg (PLM_DEVICE_BLOCK pDevice, |
| 46 | LM_REQUESTED_MEDIA_TYPE RequestedMediaType); |
| 47 | static LM_UINT32 GetPhyAdFlowCntrlSettings (PLM_DEVICE_BLOCK pDevice); |
| 48 | STATIC LM_STATUS LM_SetFlowControl (PLM_DEVICE_BLOCK pDevice, |
| 49 | LM_UINT32 LocalPhyAd, |
| 50 | LM_UINT32 RemotePhyAd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 51 | #if INCLUDE_TBI_SUPPORT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 52 | STATIC LM_STATUS LM_SetupFiberPhy (PLM_DEVICE_BLOCK pDevice); |
| 53 | STATIC LM_STATUS LM_InitBcm800xPhy (PLM_DEVICE_BLOCK pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 54 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 55 | STATIC LM_STATUS LM_SetupCopperPhy (PLM_DEVICE_BLOCK pDevice); |
| 56 | STATIC PLM_ADAPTER_INFO LM_GetAdapterInfoBySsid (LM_UINT16 Svid, |
| 57 | LM_UINT16 Ssid); |
| 58 | STATIC LM_STATUS LM_DmaTest (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pBufferVirt, |
| 59 | LM_PHYSICAL_ADDRESS BufferPhy, |
| 60 | LM_UINT32 BufferSize); |
| 61 | STATIC LM_STATUS LM_HaltCpu (PLM_DEVICE_BLOCK pDevice, LM_UINT32 cpu_number); |
| 62 | STATIC LM_STATUS LM_ResetChip (PLM_DEVICE_BLOCK pDevice); |
| 63 | STATIC LM_STATUS LM_Test4GBoundary (PLM_DEVICE_BLOCK pDevice, |
| 64 | PLM_PACKET pPacket, PT3_SND_BD pSendBd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 65 | |
| 66 | /******************************************************************************/ |
| 67 | /* External functions. */ |
| 68 | /******************************************************************************/ |
| 69 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 70 | LM_STATUS LM_LoadRlsFirmware (PLM_DEVICE_BLOCK pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 71 | |
| 72 | /******************************************************************************/ |
| 73 | /* Description: */ |
| 74 | /* */ |
| 75 | /* Return: */ |
| 76 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 77 | LM_UINT32 LM_RegRdInd (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Register) |
| 78 | { |
| 79 | LM_UINT32 Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 80 | |
| 81 | #if PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 82 | MM_ACQUIRE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 83 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 84 | MM_WriteConfig32 (pDevice, T3_PCI_REG_ADDR_REG, Register); |
| 85 | MM_ReadConfig32 (pDevice, T3_PCI_REG_DATA_REG, &Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 86 | #if PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 87 | MM_RELEASE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | #endif |
| 89 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 90 | return Value32; |
| 91 | } /* LM_RegRdInd */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 92 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | /******************************************************************************/ |
| 94 | /* Description: */ |
| 95 | /* */ |
| 96 | /* Return: */ |
| 97 | /******************************************************************************/ |
| 98 | LM_VOID |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 99 | LM_RegWrInd (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Register, LM_UINT32 Value32) |
| 100 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 101 | |
| 102 | #if PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 103 | MM_ACQUIRE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 104 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 105 | MM_WriteConfig32 (pDevice, T3_PCI_REG_ADDR_REG, Register); |
| 106 | MM_WriteConfig32 (pDevice, T3_PCI_REG_DATA_REG, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 107 | #if PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 108 | MM_RELEASE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 109 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 110 | } /* LM_RegWrInd */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 111 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | /******************************************************************************/ |
| 113 | /* Description: */ |
| 114 | /* */ |
| 115 | /* Return: */ |
| 116 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 117 | LM_UINT32 LM_MemRdInd (PLM_DEVICE_BLOCK pDevice, LM_UINT32 MemAddr) |
| 118 | { |
| 119 | LM_UINT32 Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 120 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 121 | MM_ACQUIRE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 122 | #ifdef BIG_ENDIAN_HOST |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 123 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_ADDR_REG, MemAddr); |
| 124 | Value32 = REG_RD (pDevice, PciCfg.MemWindowData); |
| 125 | /* Value32 = REG_RD(pDevice,uIntMem.Mbuf[(MemAddr & 0x7fff)/4]); */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 126 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 127 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_ADDR_REG, MemAddr); |
| 128 | MM_ReadConfig32 (pDevice, T3_PCI_MEM_WIN_DATA_REG, &Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 129 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 130 | MM_RELEASE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 131 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 132 | return Value32; |
| 133 | } /* LM_MemRdInd */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 134 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | /******************************************************************************/ |
| 136 | /* Description: */ |
| 137 | /* */ |
| 138 | /* Return: */ |
| 139 | /******************************************************************************/ |
| 140 | LM_VOID |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 141 | LM_MemWrInd (PLM_DEVICE_BLOCK pDevice, LM_UINT32 MemAddr, LM_UINT32 Value32) |
| 142 | { |
| 143 | MM_ACQUIRE_UNDI_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 144 | #ifdef BIG_ENDIAN_HOST |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 145 | REG_WR (pDevice, PciCfg.MemWindowBaseAddr, MemAddr); |
| 146 | REG_WR (pDevice, uIntMem.Mbuf[(MemAddr & 0x7fff) / 4], Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 147 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 148 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_ADDR_REG, MemAddr); |
| 149 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_DATA_REG, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 150 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 151 | MM_RELEASE_UNDI_LOCK (pDevice); |
| 152 | } /* LM_MemWrInd */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 153 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 154 | /******************************************************************************/ |
| 155 | /* Description: */ |
| 156 | /* */ |
| 157 | /* Return: */ |
| 158 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 159 | LM_STATUS LM_QueueRxPackets (PLM_DEVICE_BLOCK pDevice) |
| 160 | { |
| 161 | LM_STATUS Lmstatus; |
| 162 | PLM_PACKET pPacket; |
| 163 | PT3_RCV_BD pRcvBd; |
| 164 | LM_UINT32 StdBdAdded = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 165 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 166 | LM_UINT32 JumboBdAdded = 0; |
| 167 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 168 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 169 | Lmstatus = LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 170 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 171 | pPacket = (PLM_PACKET) QQ_PopHead (&pDevice->RxPacketFreeQ.Container); |
| 172 | while (pPacket) { |
| 173 | switch (pPacket->u.Rx.RcvProdRing) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 174 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 175 | case T3_JUMBO_RCV_PROD_RING: /* Jumbo Receive Ring. */ |
| 176 | /* Initialize the buffer descriptor. */ |
| 177 | pRcvBd = |
| 178 | &pDevice->pRxJumboBdVirt[pDevice->RxJumboProdIdx]; |
| 179 | pRcvBd->Flags = |
| 180 | RCV_BD_FLAG_END | RCV_BD_FLAG_JUMBO_RING; |
| 181 | pRcvBd->Len = (LM_UINT16) pDevice->RxJumboBufferSize; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 182 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 183 | /* Initialize the receive buffer pointer */ |
| 184 | #if 0 /* Jimmy, deleted in new */ |
| 185 | pRcvBd->HostAddr.Low = pPacket->u.Rx.RxBufferPhy.Low; |
| 186 | pRcvBd->HostAddr.High = pPacket->u.Rx.RxBufferPhy.High; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 187 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 188 | MM_MapRxDma (pDevice, pPacket, &pRcvBd->HostAddr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 189 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 190 | /* The opaque field may point to an offset from a fix addr. */ |
| 191 | pRcvBd->Opaque = (LM_UINT32) (MM_UINT_PTR (pPacket) - |
| 192 | MM_UINT_PTR (pDevice-> |
| 193 | pPacketDescBase)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 194 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 195 | /* Update the producer index. */ |
| 196 | pDevice->RxJumboProdIdx = |
| 197 | (pDevice->RxJumboProdIdx + |
| 198 | 1) & T3_JUMBO_RCV_RCB_ENTRY_COUNT_MASK; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 199 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 200 | JumboBdAdded++; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 201 | break; |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 202 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
| 203 | |
| 204 | case T3_STD_RCV_PROD_RING: /* Standard Receive Ring. */ |
| 205 | /* Initialize the buffer descriptor. */ |
| 206 | pRcvBd = &pDevice->pRxStdBdVirt[pDevice->RxStdProdIdx]; |
| 207 | pRcvBd->Flags = RCV_BD_FLAG_END; |
| 208 | pRcvBd->Len = MAX_STD_RCV_BUFFER_SIZE; |
| 209 | |
| 210 | /* Initialize the receive buffer pointer */ |
| 211 | #if 0 /* Jimmy, deleted in new replaced with MM_MapRxDma */ |
| 212 | pRcvBd->HostAddr.Low = pPacket->u.Rx.RxBufferPhy.Low; |
| 213 | pRcvBd->HostAddr.High = pPacket->u.Rx.RxBufferPhy.High; |
| 214 | #endif |
| 215 | MM_MapRxDma (pDevice, pPacket, &pRcvBd->HostAddr); |
| 216 | |
| 217 | /* The opaque field may point to an offset from a fix addr. */ |
| 218 | pRcvBd->Opaque = (LM_UINT32) (MM_UINT_PTR (pPacket) - |
| 219 | MM_UINT_PTR (pDevice-> |
| 220 | pPacketDescBase)); |
| 221 | |
| 222 | /* Update the producer index. */ |
| 223 | pDevice->RxStdProdIdx = (pDevice->RxStdProdIdx + 1) & |
| 224 | T3_STD_RCV_RCB_ENTRY_COUNT_MASK; |
| 225 | |
| 226 | StdBdAdded++; |
| 227 | break; |
| 228 | |
| 229 | case T3_UNKNOWN_RCV_PROD_RING: |
| 230 | default: |
| 231 | Lmstatus = LM_STATUS_FAILURE; |
| 232 | break; |
| 233 | } /* switch */ |
| 234 | |
| 235 | /* Bail out if there is any error. */ |
| 236 | if (Lmstatus != LM_STATUS_SUCCESS) { |
| 237 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 238 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 239 | |
| 240 | pPacket = |
| 241 | (PLM_PACKET) QQ_PopHead (&pDevice->RxPacketFreeQ.Container); |
| 242 | } /* while */ |
| 243 | |
| 244 | wmb (); |
| 245 | /* Update the procedure index. */ |
| 246 | if (StdBdAdded) { |
| 247 | MB_REG_WR (pDevice, Mailbox.RcvStdProdIdx.Low, |
| 248 | pDevice->RxStdProdIdx); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 249 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 250 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
| 251 | if (JumboBdAdded) { |
| 252 | MB_REG_WR (pDevice, Mailbox.RcvJumboProdIdx.Low, |
| 253 | pDevice->RxJumboProdIdx); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 254 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 255 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
| 256 | |
| 257 | return Lmstatus; |
| 258 | } /* LM_QueueRxPackets */ |
| 259 | |
| 260 | /******************************************************************************/ |
| 261 | /* Description: */ |
| 262 | /* */ |
| 263 | /* Return: */ |
| 264 | /******************************************************************************/ |
| 265 | STATIC LM_VOID LM_NvramInit (PLM_DEVICE_BLOCK pDevice) |
| 266 | { |
| 267 | LM_UINT32 Value32; |
| 268 | LM_UINT32 j; |
| 269 | |
| 270 | /* Intialize clock period and state machine. */ |
| 271 | Value32 = SEEPROM_ADDR_CLK_PERD (SEEPROM_CLOCK_PERIOD) | |
| 272 | SEEPROM_ADDR_FSM_RESET; |
| 273 | REG_WR (pDevice, Grc.EepromAddr, Value32); |
| 274 | |
| 275 | for (j = 0; j < 100; j++) { |
| 276 | MM_Wait (10); |
| 277 | } |
| 278 | |
| 279 | /* Serial eeprom access using the Grc.EepromAddr/EepromData registers. */ |
| 280 | Value32 = REG_RD (pDevice, Grc.LocalCtrl); |
| 281 | REG_WR (pDevice, Grc.LocalCtrl, |
| 282 | Value32 | GRC_MISC_LOCAL_CTRL_AUTO_SEEPROM); |
| 283 | |
| 284 | /* Set the 5701 compatibility mode if we are using EEPROM. */ |
| 285 | if (T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5700 && |
| 286 | T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5701) { |
| 287 | Value32 = REG_RD (pDevice, Nvram.Config1); |
| 288 | if ((Value32 & FLASH_INTERFACE_ENABLE) == 0) { |
| 289 | /* Use the new interface to read EEPROM. */ |
| 290 | Value32 &= ~FLASH_COMPAT_BYPASS; |
| 291 | |
| 292 | REG_WR (pDevice, Nvram.Config1, Value32); |
| 293 | } |
| 294 | } |
| 295 | } /* LM_NvRamInit */ |
| 296 | |
| 297 | /******************************************************************************/ |
| 298 | /* Description: */ |
| 299 | /* */ |
| 300 | /* Return: */ |
| 301 | /******************************************************************************/ |
| 302 | STATIC LM_STATUS |
| 303 | LM_EepromRead (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset, LM_UINT32 * pData) |
| 304 | { |
| 305 | LM_UINT32 Value32; |
| 306 | LM_UINT32 Addr; |
| 307 | LM_UINT32 Dev; |
| 308 | LM_UINT32 j; |
| 309 | |
| 310 | if (Offset > SEEPROM_CHIP_SIZE) { |
| 311 | return LM_STATUS_FAILURE; |
| 312 | } |
| 313 | |
| 314 | Dev = Offset / SEEPROM_CHIP_SIZE; |
| 315 | Addr = Offset % SEEPROM_CHIP_SIZE; |
| 316 | |
| 317 | Value32 = REG_RD (pDevice, Grc.EepromAddr); |
| 318 | Value32 &= ~(SEEPROM_ADDR_ADDRESS_MASK | SEEPROM_ADDR_DEV_ID_MASK | |
| 319 | SEEPROM_ADDR_RW_MASK); |
| 320 | REG_WR (pDevice, Grc.EepromAddr, Value32 | SEEPROM_ADDR_DEV_ID (Dev) | |
| 321 | SEEPROM_ADDR_ADDRESS (Addr) | SEEPROM_ADDR_START | |
| 322 | SEEPROM_ADDR_READ); |
| 323 | |
| 324 | for (j = 0; j < 1000; j++) { |
| 325 | Value32 = REG_RD (pDevice, Grc.EepromAddr); |
| 326 | if (Value32 & SEEPROM_ADDR_COMPLETE) { |
| 327 | break; |
| 328 | } |
| 329 | MM_Wait (10); |
| 330 | } |
| 331 | |
| 332 | if (Value32 & SEEPROM_ADDR_COMPLETE) { |
| 333 | Value32 = REG_RD (pDevice, Grc.EepromData); |
| 334 | *pData = Value32; |
| 335 | |
| 336 | return LM_STATUS_SUCCESS; |
| 337 | } |
| 338 | |
| 339 | return LM_STATUS_FAILURE; |
| 340 | } /* LM_EepromRead */ |
| 341 | |
| 342 | /******************************************************************************/ |
| 343 | /* Description: */ |
| 344 | /* */ |
| 345 | /* Return: */ |
| 346 | /******************************************************************************/ |
| 347 | STATIC LM_STATUS |
| 348 | LM_NvramRead (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset, LM_UINT32 * pData) |
| 349 | { |
| 350 | LM_UINT32 Value32; |
| 351 | LM_STATUS Status; |
| 352 | LM_UINT32 j; |
| 353 | |
| 354 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 355 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 356 | Status = LM_EepromRead (pDevice, Offset, pData); |
| 357 | } else { |
| 358 | /* Determine if we have flash or EEPROM. */ |
| 359 | Value32 = REG_RD (pDevice, Nvram.Config1); |
| 360 | if (Value32 & FLASH_INTERFACE_ENABLE) { |
| 361 | if (Value32 & FLASH_SSRAM_BUFFERRED_MODE) { |
| 362 | Offset = ((Offset / BUFFERED_FLASH_PAGE_SIZE) << |
| 363 | BUFFERED_FLASH_PAGE_POS) + |
| 364 | (Offset % BUFFERED_FLASH_PAGE_SIZE); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | REG_WR (pDevice, Nvram.SwArb, SW_ARB_REQ_SET1); |
| 369 | for (j = 0; j < 1000; j++) { |
| 370 | if (REG_RD (pDevice, Nvram.SwArb) & SW_ARB_GNT1) { |
| 371 | break; |
| 372 | } |
| 373 | MM_Wait (20); |
| 374 | } |
| 375 | if (j == 1000) { |
| 376 | return LM_STATUS_FAILURE; |
| 377 | } |
| 378 | |
| 379 | /* Read from flash or EEPROM with the new 5703/02 interface. */ |
| 380 | REG_WR (pDevice, Nvram.Addr, Offset & NVRAM_ADDRESS_MASK); |
| 381 | |
| 382 | REG_WR (pDevice, Nvram.Cmd, NVRAM_CMD_RD | NVRAM_CMD_DO_IT | |
| 383 | NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_DONE); |
| 384 | |
| 385 | /* Wait for the done bit to clear. */ |
| 386 | for (j = 0; j < 500; j++) { |
| 387 | MM_Wait (10); |
| 388 | |
| 389 | Value32 = REG_RD (pDevice, Nvram.Cmd); |
| 390 | if (!(Value32 & NVRAM_CMD_DONE)) { |
| 391 | break; |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | /* Wait for the done bit. */ |
| 396 | if (!(Value32 & NVRAM_CMD_DONE)) { |
| 397 | for (j = 0; j < 500; j++) { |
| 398 | MM_Wait (10); |
| 399 | |
| 400 | Value32 = REG_RD (pDevice, Nvram.Cmd); |
| 401 | if (Value32 & NVRAM_CMD_DONE) { |
| 402 | MM_Wait (10); |
| 403 | |
| 404 | *pData = |
| 405 | REG_RD (pDevice, Nvram.ReadData); |
| 406 | |
| 407 | /* Change the endianess. */ |
| 408 | *pData = |
| 409 | ((*pData & 0xff) << 24) | |
| 410 | ((*pData & 0xff00) << 8) | |
| 411 | ((*pData & 0xff0000) >> 8) | |
| 412 | ((*pData >> 24) & 0xff); |
| 413 | |
| 414 | break; |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | REG_WR (pDevice, Nvram.SwArb, SW_ARB_REQ_CLR1); |
| 420 | if (Value32 & NVRAM_CMD_DONE) { |
| 421 | Status = LM_STATUS_SUCCESS; |
| 422 | } else { |
| 423 | Status = LM_STATUS_FAILURE; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | return Status; |
| 428 | } /* LM_NvramRead */ |
| 429 | |
| 430 | STATIC void LM_ReadVPD (PLM_DEVICE_BLOCK pDevice) |
| 431 | { |
| 432 | LM_UINT32 Vpd_arr[256 / 4]; |
| 433 | LM_UINT8 *Vpd = (LM_UINT8 *) & Vpd_arr[0]; |
| 434 | LM_UINT32 *Vpd_dptr = &Vpd_arr[0]; |
| 435 | LM_UINT32 Value32; |
| 436 | unsigned int j; |
| 437 | |
| 438 | /* Read PN from VPD */ |
| 439 | for (j = 0; j < 256; j += 4, Vpd_dptr++) { |
| 440 | if (LM_NvramRead (pDevice, 0x100 + j, &Value32) != |
| 441 | LM_STATUS_SUCCESS) { |
| 442 | printf ("BCM570x: LM_ReadVPD: VPD read failed" |
| 443 | " (no EEPROM onboard)\n"); |
| 444 | return; |
| 445 | } |
| 446 | *Vpd_dptr = cpu_to_le32 (Value32); |
| 447 | } |
| 448 | for (j = 0; j < 256;) { |
| 449 | unsigned int Vpd_r_len; |
| 450 | unsigned int Vpd_r_end; |
| 451 | |
| 452 | if ((Vpd[j] == 0x82) || (Vpd[j] == 0x91)) { |
| 453 | j = j + 3 + Vpd[j + 1] + (Vpd[j + 2] << 8); |
| 454 | } else if (Vpd[j] == 0x90) { |
| 455 | Vpd_r_len = Vpd[j + 1] + (Vpd[j + 2] << 8); |
| 456 | j += 3; |
| 457 | Vpd_r_end = Vpd_r_len + j; |
| 458 | while (j < Vpd_r_end) { |
| 459 | if ((Vpd[j] == 'P') && (Vpd[j + 1] == 'N')) { |
| 460 | unsigned int len = Vpd[j + 2]; |
| 461 | |
| 462 | if (len <= 24) { |
| 463 | memcpy (pDevice->PartNo, |
| 464 | &Vpd[j + 3], len); |
| 465 | } |
| 466 | break; |
| 467 | } else { |
| 468 | if (Vpd[j + 2] == 0) { |
| 469 | break; |
| 470 | } |
| 471 | j = j + Vpd[j + 2]; |
| 472 | } |
| 473 | } |
| 474 | break; |
| 475 | } else { |
| 476 | break; |
| 477 | } |
| 478 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 479 | } |
| 480 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 481 | STATIC void LM_ReadBootCodeVersion (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 482 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 483 | LM_UINT32 Value32, offset, ver_offset; |
| 484 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 485 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 486 | if (LM_NvramRead (pDevice, 0x0, &Value32) != LM_STATUS_SUCCESS) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 487 | return; |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 488 | if (Value32 != 0xaa559966) |
| 489 | return; |
| 490 | if (LM_NvramRead (pDevice, 0xc, &offset) != LM_STATUS_SUCCESS) |
| 491 | return; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 492 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 493 | offset = ((offset & 0xff) << 24) | ((offset & 0xff00) << 8) | |
| 494 | ((offset & 0xff0000) >> 8) | ((offset >> 24) & 0xff); |
| 495 | if (LM_NvramRead (pDevice, offset, &Value32) != LM_STATUS_SUCCESS) |
| 496 | return; |
| 497 | if ((Value32 == 0x0300000e) && |
| 498 | (LM_NvramRead (pDevice, offset + 4, &Value32) == LM_STATUS_SUCCESS) |
| 499 | && (Value32 == 0)) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 500 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 501 | if (LM_NvramRead (pDevice, offset + 8, &ver_offset) != |
| 502 | LM_STATUS_SUCCESS) |
| 503 | return; |
| 504 | ver_offset = ((ver_offset & 0xff0000) >> 8) | |
| 505 | ((ver_offset >> 24) & 0xff); |
| 506 | for (i = 0; i < 16; i += 4) { |
| 507 | if (LM_NvramRead |
| 508 | (pDevice, offset + ver_offset + i, |
| 509 | &Value32) != LM_STATUS_SUCCESS) { |
| 510 | return; |
| 511 | } |
| 512 | *((LM_UINT32 *) & pDevice->BootCodeVer[i]) = |
| 513 | cpu_to_le32 (Value32); |
| 514 | } |
| 515 | } else { |
| 516 | char c; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 517 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 518 | if (LM_NvramRead (pDevice, 0x94, &Value32) != LM_STATUS_SUCCESS) |
| 519 | return; |
| 520 | |
| 521 | i = 0; |
| 522 | c = ((Value32 & 0xff0000) >> 16); |
| 523 | |
| 524 | if (c < 10) { |
| 525 | pDevice->BootCodeVer[i++] = c + '0'; |
| 526 | } else { |
| 527 | pDevice->BootCodeVer[i++] = (c / 10) + '0'; |
| 528 | pDevice->BootCodeVer[i++] = (c % 10) + '0'; |
| 529 | } |
| 530 | pDevice->BootCodeVer[i++] = '.'; |
| 531 | c = (Value32 & 0xff000000) >> 24; |
| 532 | if (c < 10) { |
| 533 | pDevice->BootCodeVer[i++] = c + '0'; |
| 534 | } else { |
| 535 | pDevice->BootCodeVer[i++] = (c / 10) + '0'; |
| 536 | pDevice->BootCodeVer[i++] = (c % 10) + '0'; |
| 537 | } |
| 538 | pDevice->BootCodeVer[i] = 0; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 539 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 540 | } |
| 541 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 542 | STATIC void LM_GetBusSpeed (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 543 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 544 | LM_UINT32 PciState = pDevice->PciState; |
| 545 | LM_UINT32 ClockCtrl; |
| 546 | char *SpeedStr = ""; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 547 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 548 | if (PciState & T3_PCI_STATE_32BIT_PCI_BUS) { |
| 549 | strcpy (pDevice->BusSpeedStr, "32-bit "); |
| 550 | } else { |
| 551 | strcpy (pDevice->BusSpeedStr, "64-bit "); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 552 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 553 | if (PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE) { |
| 554 | strcat (pDevice->BusSpeedStr, "PCI "); |
| 555 | if (PciState & T3_PCI_STATE_HIGH_BUS_SPEED) { |
| 556 | SpeedStr = "66MHz"; |
| 557 | } else { |
| 558 | SpeedStr = "33MHz"; |
| 559 | } |
| 560 | } else { |
| 561 | strcat (pDevice->BusSpeedStr, "PCIX "); |
| 562 | if (pDevice->BondId == GRC_MISC_BD_ID_5704CIOBE) { |
| 563 | SpeedStr = "133MHz"; |
| 564 | } else { |
| 565 | ClockCtrl = REG_RD (pDevice, PciCfg.ClockCtrl) & 0x1f; |
| 566 | switch (ClockCtrl) { |
| 567 | case 0: |
| 568 | SpeedStr = "33MHz"; |
| 569 | break; |
| 570 | |
| 571 | case 2: |
| 572 | SpeedStr = "50MHz"; |
| 573 | break; |
| 574 | |
| 575 | case 4: |
| 576 | SpeedStr = "66MHz"; |
| 577 | break; |
| 578 | |
| 579 | case 6: |
| 580 | SpeedStr = "100MHz"; |
| 581 | break; |
| 582 | |
| 583 | case 7: |
| 584 | SpeedStr = "133MHz"; |
| 585 | break; |
| 586 | } |
| 587 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 588 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 589 | strcat (pDevice->BusSpeedStr, SpeedStr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /******************************************************************************/ |
| 593 | /* Description: */ |
| 594 | /* This routine initializes default parameters and reads the PCI */ |
| 595 | /* configurations. */ |
| 596 | /* */ |
| 597 | /* Return: */ |
| 598 | /* LM_STATUS_SUCCESS */ |
| 599 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 600 | LM_STATUS LM_GetAdapterInfo (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 601 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 602 | PLM_ADAPTER_INFO pAdapterInfo; |
| 603 | LM_UINT32 Value32; |
| 604 | LM_STATUS Status; |
| 605 | LM_UINT32 j; |
| 606 | LM_UINT32 EeSigFound; |
| 607 | LM_UINT32 EePhyTypeSerdes = 0; |
| 608 | LM_UINT32 EePhyLedMode = 0; |
| 609 | LM_UINT32 EePhyId = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 610 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 611 | /* Get Device Id and Vendor Id */ |
| 612 | Status = MM_ReadConfig32 (pDevice, PCI_VENDOR_ID_REG, &Value32); |
| 613 | if (Status != LM_STATUS_SUCCESS) { |
| 614 | return Status; |
| 615 | } |
| 616 | pDevice->PciVendorId = (LM_UINT16) Value32; |
| 617 | pDevice->PciDeviceId = (LM_UINT16) (Value32 >> 16); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 618 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 619 | /* If we are not getting the write adapter, exit. */ |
| 620 | if ((Value32 != T3_PCI_ID_BCM5700) && |
| 621 | (Value32 != T3_PCI_ID_BCM5701) && |
| 622 | (Value32 != T3_PCI_ID_BCM5702) && |
| 623 | (Value32 != T3_PCI_ID_BCM5702x) && |
| 624 | (Value32 != T3_PCI_ID_BCM5702FE) && |
| 625 | (Value32 != T3_PCI_ID_BCM5703) && |
| 626 | (Value32 != T3_PCI_ID_BCM5703x) && (Value32 != T3_PCI_ID_BCM5704)) { |
| 627 | return LM_STATUS_FAILURE; |
| 628 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 629 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 630 | Status = MM_ReadConfig32 (pDevice, PCI_REV_ID_REG, &Value32); |
| 631 | if (Status != LM_STATUS_SUCCESS) { |
| 632 | return Status; |
| 633 | } |
| 634 | pDevice->PciRevId = (LM_UINT8) Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 635 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 636 | /* Get IRQ. */ |
| 637 | Status = MM_ReadConfig32 (pDevice, PCI_INT_LINE_REG, &Value32); |
| 638 | if (Status != LM_STATUS_SUCCESS) { |
| 639 | return Status; |
| 640 | } |
| 641 | pDevice->Irq = (LM_UINT8) Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 642 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 643 | /* Get interrupt pin. */ |
| 644 | pDevice->IntPin = (LM_UINT8) (Value32 >> 8); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 645 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 646 | /* Get chip revision id. */ |
| 647 | Status = MM_ReadConfig32 (pDevice, T3_PCI_MISC_HOST_CTRL_REG, &Value32); |
| 648 | pDevice->ChipRevId = Value32 >> 16; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 649 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 650 | /* Get subsystem vendor. */ |
| 651 | Status = |
| 652 | MM_ReadConfig32 (pDevice, PCI_SUBSYSTEM_VENDOR_ID_REG, &Value32); |
| 653 | if (Status != LM_STATUS_SUCCESS) { |
| 654 | return Status; |
| 655 | } |
| 656 | pDevice->SubsystemVendorId = (LM_UINT16) Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 657 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 658 | /* Get PCI subsystem id. */ |
| 659 | pDevice->SubsystemId = (LM_UINT16) (Value32 >> 16); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 660 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 661 | /* Get the cache line size. */ |
| 662 | MM_ReadConfig32 (pDevice, PCI_CACHE_LINE_SIZE_REG, &Value32); |
| 663 | pDevice->CacheLineSize = (LM_UINT8) Value32; |
| 664 | pDevice->SavedCacheLineReg = Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 665 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 666 | if (pDevice->ChipRevId != T3_CHIP_ID_5703_A1 && |
| 667 | pDevice->ChipRevId != T3_CHIP_ID_5703_A2 && |
| 668 | pDevice->ChipRevId != T3_CHIP_ID_5704_A0) { |
| 669 | pDevice->UndiFix = FALSE; |
| 670 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 671 | #if !PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 672 | pDevice->UndiFix = FALSE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 673 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 674 | /* Map the memory base to system address space. */ |
| 675 | if (!pDevice->UndiFix) { |
| 676 | Status = MM_MapMemBase (pDevice); |
| 677 | if (Status != LM_STATUS_SUCCESS) { |
| 678 | return Status; |
| 679 | } |
| 680 | /* Initialize the memory view pointer. */ |
| 681 | pDevice->pMemView = (PT3_STD_MEM_MAP) pDevice->pMappedMemBase; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 682 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 683 | #if PCIX_TARGET_WORKAROUND |
| 684 | /* store whether we are in PCI are PCI-X mode */ |
| 685 | pDevice->EnablePciXFix = FALSE; |
| 686 | |
| 687 | MM_ReadConfig32 (pDevice, T3_PCI_STATE_REG, &Value32); |
| 688 | if ((Value32 & T3_PCI_STATE_CONVENTIONAL_PCI_MODE) == 0) { |
| 689 | /* Enable PCI-X workaround only if we are running on 5700 BX. */ |
| 690 | if (T3_CHIP_REV (pDevice->ChipRevId) == T3_CHIP_REV_5700_BX) { |
| 691 | pDevice->EnablePciXFix = TRUE; |
| 692 | } |
| 693 | } |
| 694 | if (pDevice->UndiFix) { |
| 695 | pDevice->EnablePciXFix = TRUE; |
| 696 | } |
| 697 | #endif |
| 698 | /* Bx bug: due to the "byte_enable bug" in PCI-X mode, the power */ |
| 699 | /* management register may be clobbered which may cause the */ |
| 700 | /* BCM5700 to go into D3 state. While in this state, we will */ |
| 701 | /* not have memory mapped register access. As a workaround, we */ |
| 702 | /* need to restore the device to D0 state. */ |
| 703 | MM_ReadConfig32 (pDevice, T3_PCI_PM_STATUS_CTRL_REG, &Value32); |
| 704 | Value32 |= T3_PM_PME_ASSERTED; |
| 705 | Value32 &= ~T3_PM_POWER_STATE_MASK; |
| 706 | Value32 |= T3_PM_POWER_STATE_D0; |
| 707 | MM_WriteConfig32 (pDevice, T3_PCI_PM_STATUS_CTRL_REG, Value32); |
| 708 | |
| 709 | /* read the current PCI command word */ |
| 710 | MM_ReadConfig32 (pDevice, PCI_COMMAND_REG, &Value32); |
| 711 | |
| 712 | /* Make sure bus-mastering is enabled. */ |
| 713 | Value32 |= PCI_BUSMASTER_ENABLE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 714 | |
| 715 | #if PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 716 | /* if we are in PCI-X mode, also make sure mem-mapping and SERR#/PERR# |
| 717 | are enabled */ |
| 718 | if (pDevice->EnablePciXFix == TRUE) { |
| 719 | Value32 |= (PCI_MEM_SPACE_ENABLE | PCI_SYSTEM_ERROR_ENABLE | |
| 720 | PCI_PARITY_ERROR_ENABLE); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 721 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 722 | if (pDevice->UndiFix) { |
| 723 | Value32 &= ~PCI_MEM_SPACE_ENABLE; |
| 724 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 725 | #endif |
| 726 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 727 | if (pDevice->EnableMWI) { |
| 728 | Value32 |= PCI_MEMORY_WRITE_INVALIDATE; |
| 729 | } else { |
| 730 | Value32 &= (~PCI_MEMORY_WRITE_INVALIDATE); |
| 731 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 732 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 733 | /* Error out if mem-mapping is NOT enabled for PCI systems */ |
| 734 | if (!(Value32 | PCI_MEM_SPACE_ENABLE)) { |
| 735 | return LM_STATUS_FAILURE; |
| 736 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 737 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 738 | /* save the value we are going to write into the PCI command word */ |
| 739 | pDevice->PciCommandStatusWords = Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 740 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 741 | Status = MM_WriteConfig32 (pDevice, PCI_COMMAND_REG, Value32); |
| 742 | if (Status != LM_STATUS_SUCCESS) { |
| 743 | return Status; |
| 744 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 745 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 746 | /* Set power state to D0. */ |
| 747 | LM_SetPowerState (pDevice, LM_POWER_STATE_D0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 748 | |
| 749 | #ifdef BIG_ENDIAN_PCI |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 750 | pDevice->MiscHostCtrl = |
| 751 | MISC_HOST_CTRL_MASK_PCI_INT | |
| 752 | MISC_HOST_CTRL_ENABLE_INDIRECT_ACCESS | |
| 753 | MISC_HOST_CTRL_ENABLE_ENDIAN_WORD_SWAP | |
| 754 | MISC_HOST_CTRL_ENABLE_PCI_STATE_REG_RW; |
| 755 | #else /* No CPU Swap modes for PCI IO */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 756 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 757 | /* Setup the mode registers. */ |
| 758 | pDevice->MiscHostCtrl = |
| 759 | MISC_HOST_CTRL_MASK_PCI_INT | |
| 760 | MISC_HOST_CTRL_ENABLE_ENDIAN_WORD_SWAP | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 761 | #ifdef BIG_ENDIAN_HOST |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 762 | MISC_HOST_CTRL_ENABLE_ENDIAN_BYTE_SWAP | |
| 763 | #endif /* BIG_ENDIAN_HOST */ |
| 764 | MISC_HOST_CTRL_ENABLE_INDIRECT_ACCESS | |
| 765 | MISC_HOST_CTRL_ENABLE_PCI_STATE_REG_RW; |
| 766 | #endif /* !BIG_ENDIAN_PCI */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 767 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 768 | /* write to PCI misc host ctr first in order to enable indirect accesses */ |
| 769 | MM_WriteConfig32 (pDevice, T3_PCI_MISC_HOST_CTRL_REG, |
| 770 | pDevice->MiscHostCtrl); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 771 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 772 | REG_WR (pDevice, PciCfg.MiscHostCtrl, pDevice->MiscHostCtrl); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 773 | |
| 774 | #ifdef BIG_ENDIAN_PCI |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 775 | Value32 = GRC_MODE_WORD_SWAP_DATA | GRC_MODE_WORD_SWAP_NON_FRAME_DATA; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 776 | #else |
| 777 | /* No CPU Swap modes for PCI IO */ |
| 778 | #ifdef BIG_ENDIAN_HOST |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 779 | Value32 = GRC_MODE_BYTE_SWAP_NON_FRAME_DATA | |
| 780 | GRC_MODE_WORD_SWAP_NON_FRAME_DATA; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 781 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 782 | Value32 = GRC_MODE_BYTE_SWAP_NON_FRAME_DATA | GRC_MODE_BYTE_SWAP_DATA; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 783 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 784 | #endif /* !BIG_ENDIAN_PCI */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 785 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 786 | REG_WR (pDevice, Grc.Mode, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 787 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 788 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 789 | REG_WR (pDevice, Grc.LocalCtrl, |
| 790 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT1 | |
| 791 | GRC_MISC_LOCAL_CTRL_GPIO_OE1); |
| 792 | } |
| 793 | MM_Wait (40); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 794 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 795 | /* Enable indirect memory access */ |
| 796 | REG_WR (pDevice, MemArbiter.Mode, T3_MEM_ARBITER_MODE_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 797 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 798 | if (REG_RD (pDevice, PciCfg.ClockCtrl) & T3_PCI_44MHZ_CORE_CLOCK) { |
| 799 | REG_WR (pDevice, PciCfg.ClockCtrl, T3_PCI_44MHZ_CORE_CLOCK | |
| 800 | T3_PCI_SELECT_ALTERNATE_CLOCK); |
| 801 | REG_WR (pDevice, PciCfg.ClockCtrl, |
| 802 | T3_PCI_SELECT_ALTERNATE_CLOCK); |
| 803 | MM_Wait (40); /* required delay is 27usec */ |
| 804 | } |
| 805 | REG_WR (pDevice, PciCfg.ClockCtrl, 0); |
| 806 | REG_WR (pDevice, PciCfg.MemWindowBaseAddr, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 807 | |
| 808 | #if PCIX_TARGET_WORKAROUND |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 809 | MM_ReadConfig32 (pDevice, T3_PCI_STATE_REG, &Value32); |
| 810 | if ((pDevice->EnablePciXFix == FALSE) && |
| 811 | ((Value32 & T3_PCI_STATE_CONVENTIONAL_PCI_MODE) == 0)) { |
| 812 | if (pDevice->ChipRevId == T3_CHIP_ID_5701_A0 || |
| 813 | pDevice->ChipRevId == T3_CHIP_ID_5701_B0 || |
| 814 | pDevice->ChipRevId == T3_CHIP_ID_5701_B2 || |
| 815 | pDevice->ChipRevId == T3_CHIP_ID_5701_B5) { |
| 816 | __raw_writel (0, |
| 817 | &(pDevice->pMemView->uIntMem. |
| 818 | MemBlock32K[0x300])); |
| 819 | __raw_writel (0, |
| 820 | &(pDevice->pMemView->uIntMem. |
| 821 | MemBlock32K[0x301])); |
| 822 | __raw_writel (0xffffffff, |
| 823 | &(pDevice->pMemView->uIntMem. |
| 824 | MemBlock32K[0x301])); |
| 825 | if (__raw_readl |
| 826 | (&(pDevice->pMemView->uIntMem.MemBlock32K[0x300]))) |
| 827 | { |
| 828 | pDevice->EnablePciXFix = TRUE; |
| 829 | } |
| 830 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 831 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 832 | #endif |
| 833 | #if 1 |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 834 | /* |
| 835 | * This code was at the beginning of else block below, but that's |
| 836 | * a bug if node address in shared memory. |
| 837 | */ |
| 838 | MM_Wait (50); |
| 839 | LM_NvramInit (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 840 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 841 | /* Get the node address. First try to get in from the shared memory. */ |
| 842 | /* If the signature is not present, then get it from the NVRAM. */ |
| 843 | Value32 = MEM_RD_OFFSET (pDevice, T3_MAC_ADDR_HIGH_MAILBOX); |
| 844 | if ((Value32 >> 16) == 0x484b) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 845 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 846 | pDevice->NodeAddress[0] = (LM_UINT8) (Value32 >> 8); |
| 847 | pDevice->NodeAddress[1] = (LM_UINT8) Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 848 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 849 | Value32 = MEM_RD_OFFSET (pDevice, T3_MAC_ADDR_LOW_MAILBOX); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 850 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 851 | pDevice->NodeAddress[2] = (LM_UINT8) (Value32 >> 24); |
| 852 | pDevice->NodeAddress[3] = (LM_UINT8) (Value32 >> 16); |
| 853 | pDevice->NodeAddress[4] = (LM_UINT8) (Value32 >> 8); |
| 854 | pDevice->NodeAddress[5] = (LM_UINT8) Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 855 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 856 | Status = LM_STATUS_SUCCESS; |
| 857 | } else { |
| 858 | Status = LM_NvramRead (pDevice, 0x7c, &Value32); |
| 859 | if (Status == LM_STATUS_SUCCESS) { |
| 860 | pDevice->NodeAddress[0] = (LM_UINT8) (Value32 >> 16); |
| 861 | pDevice->NodeAddress[1] = (LM_UINT8) (Value32 >> 24); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 862 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 863 | Status = LM_NvramRead (pDevice, 0x80, &Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 864 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 865 | pDevice->NodeAddress[2] = (LM_UINT8) Value32; |
| 866 | pDevice->NodeAddress[3] = (LM_UINT8) (Value32 >> 8); |
| 867 | pDevice->NodeAddress[4] = (LM_UINT8) (Value32 >> 16); |
| 868 | pDevice->NodeAddress[5] = (LM_UINT8) (Value32 >> 24); |
| 869 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 870 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 871 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 872 | /* Assign a default address. */ |
| 873 | if (Status != LM_STATUS_SUCCESS) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 874 | #ifndef EMBEDDED |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 875 | printk (KERN_ERR |
| 876 | "Cannot get MAC addr from NVRAM. Using default.\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 877 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 878 | pDevice->NodeAddress[0] = 0x00; |
| 879 | pDevice->NodeAddress[1] = 0x10; |
| 880 | pDevice->NodeAddress[2] = 0x18; |
| 881 | pDevice->NodeAddress[3] = 0x68; |
| 882 | pDevice->NodeAddress[4] = 0x61; |
| 883 | pDevice->NodeAddress[5] = 0x76; |
| 884 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 885 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 886 | pDevice->PermanentNodeAddress[0] = pDevice->NodeAddress[0]; |
| 887 | pDevice->PermanentNodeAddress[1] = pDevice->NodeAddress[1]; |
| 888 | pDevice->PermanentNodeAddress[2] = pDevice->NodeAddress[2]; |
| 889 | pDevice->PermanentNodeAddress[3] = pDevice->NodeAddress[3]; |
| 890 | pDevice->PermanentNodeAddress[4] = pDevice->NodeAddress[4]; |
| 891 | pDevice->PermanentNodeAddress[5] = pDevice->NodeAddress[5]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 892 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 893 | /* Initialize the default values. */ |
| 894 | pDevice->NoTxPseudoHdrChksum = FALSE; |
| 895 | pDevice->NoRxPseudoHdrChksum = FALSE; |
| 896 | pDevice->NicSendBd = FALSE; |
| 897 | pDevice->TxPacketDescCnt = DEFAULT_TX_PACKET_DESC_COUNT; |
| 898 | pDevice->RxStdDescCnt = DEFAULT_STD_RCV_DESC_COUNT; |
| 899 | pDevice->RxCoalescingTicks = DEFAULT_RX_COALESCING_TICKS; |
| 900 | pDevice->TxCoalescingTicks = DEFAULT_TX_COALESCING_TICKS; |
| 901 | pDevice->RxMaxCoalescedFrames = DEFAULT_RX_MAX_COALESCED_FRAMES; |
| 902 | pDevice->TxMaxCoalescedFrames = DEFAULT_TX_MAX_COALESCED_FRAMES; |
| 903 | pDevice->RxCoalescingTicksDuringInt = BAD_DEFAULT_VALUE; |
| 904 | pDevice->TxCoalescingTicksDuringInt = BAD_DEFAULT_VALUE; |
| 905 | pDevice->RxMaxCoalescedFramesDuringInt = BAD_DEFAULT_VALUE; |
| 906 | pDevice->TxMaxCoalescedFramesDuringInt = BAD_DEFAULT_VALUE; |
| 907 | pDevice->StatsCoalescingTicks = DEFAULT_STATS_COALESCING_TICKS; |
| 908 | pDevice->EnableMWI = FALSE; |
| 909 | pDevice->TxMtu = MAX_ETHERNET_PACKET_SIZE_NO_CRC; |
| 910 | pDevice->RxMtu = MAX_ETHERNET_PACKET_SIZE_NO_CRC; |
| 911 | pDevice->DisableAutoNeg = FALSE; |
| 912 | pDevice->PhyIntMode = T3_PHY_INT_MODE_AUTO; |
| 913 | pDevice->LinkChngMode = T3_LINK_CHNG_MODE_AUTO; |
| 914 | pDevice->LedMode = LED_MODE_AUTO; |
| 915 | pDevice->ResetPhyOnInit = TRUE; |
| 916 | pDevice->DelayPciGrant = TRUE; |
| 917 | pDevice->UseTaggedStatus = FALSE; |
| 918 | pDevice->OneDmaAtOnce = BAD_DEFAULT_VALUE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 919 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 920 | pDevice->DmaMbufLowMark = T3_DEF_DMA_MBUF_LOW_WMARK_JUMBO; |
| 921 | pDevice->RxMacMbufLowMark = T3_DEF_RX_MAC_MBUF_LOW_WMARK_JUMBO; |
| 922 | pDevice->MbufHighMark = T3_DEF_MBUF_HIGH_WMARK_JUMBO; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 923 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 924 | pDevice->RequestedMediaType = LM_REQUESTED_MEDIA_TYPE_AUTO; |
| 925 | pDevice->TaskOffloadCap = LM_TASK_OFFLOAD_NONE; |
| 926 | pDevice->FlowControlCap = LM_FLOW_CONTROL_AUTO_PAUSE; |
| 927 | pDevice->EnableTbi = FALSE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 928 | #if INCLUDE_TBI_SUPPORT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 929 | pDevice->PollTbiLink = BAD_DEFAULT_VALUE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 930 | #endif |
| 931 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 932 | switch (T3_ASIC_REV (pDevice->ChipRevId)) { |
| 933 | case T3_ASIC_REV_5704: |
| 934 | pDevice->MbufBase = T3_NIC_MBUF_POOL_ADDR; |
| 935 | pDevice->MbufSize = T3_NIC_MBUF_POOL_SIZE64; |
| 936 | break; |
| 937 | default: |
| 938 | pDevice->MbufBase = T3_NIC_MBUF_POOL_ADDR; |
| 939 | pDevice->MbufSize = T3_NIC_MBUF_POOL_SIZE96; |
| 940 | break; |
| 941 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 942 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 943 | pDevice->LinkStatus = LM_STATUS_LINK_DOWN; |
| 944 | pDevice->QueueRxPackets = TRUE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 945 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 946 | pDevice->EnableWireSpeed = TRUE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 947 | |
| 948 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 949 | pDevice->RxJumboDescCnt = DEFAULT_JUMBO_RCV_DESC_COUNT; |
| 950 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 951 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 952 | /* Make this is a known adapter. */ |
| 953 | pAdapterInfo = LM_GetAdapterInfoBySsid (pDevice->SubsystemVendorId, |
| 954 | pDevice->SubsystemId); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 955 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 956 | pDevice->BondId = REG_RD (pDevice, Grc.MiscCfg) & GRC_MISC_BD_ID_MASK; |
| 957 | if (pDevice->BondId != GRC_MISC_BD_ID_5700 && |
| 958 | pDevice->BondId != GRC_MISC_BD_ID_5701 && |
| 959 | pDevice->BondId != GRC_MISC_BD_ID_5702FE && |
| 960 | pDevice->BondId != GRC_MISC_BD_ID_5703 && |
| 961 | pDevice->BondId != GRC_MISC_BD_ID_5703S && |
| 962 | pDevice->BondId != GRC_MISC_BD_ID_5704 && |
| 963 | pDevice->BondId != GRC_MISC_BD_ID_5704CIOBE) { |
| 964 | return LM_STATUS_UNKNOWN_ADAPTER; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 965 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 966 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 967 | pDevice->SplitModeEnable = SPLIT_MODE_DISABLE; |
| 968 | if ((pDevice->ChipRevId == T3_CHIP_ID_5704_A0) && |
| 969 | (pDevice->BondId == GRC_MISC_BD_ID_5704CIOBE)) { |
| 970 | pDevice->SplitModeEnable = SPLIT_MODE_ENABLE; |
| 971 | pDevice->SplitModeMaxReq = SPLIT_MODE_5704_MAX_REQ; |
| 972 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 973 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 974 | /* Get Eeprom info. */ |
| 975 | Value32 = MEM_RD_OFFSET (pDevice, T3_NIC_DATA_SIG_ADDR); |
| 976 | if (Value32 == T3_NIC_DATA_SIG) { |
| 977 | EeSigFound = TRUE; |
| 978 | Value32 = MEM_RD_OFFSET (pDevice, T3_NIC_DATA_NIC_CFG_ADDR); |
| 979 | |
| 980 | /* Determine PHY type. */ |
| 981 | switch (Value32 & T3_NIC_CFG_PHY_TYPE_MASK) { |
| 982 | case T3_NIC_CFG_PHY_TYPE_COPPER: |
| 983 | EePhyTypeSerdes = FALSE; |
| 984 | break; |
| 985 | |
| 986 | case T3_NIC_CFG_PHY_TYPE_FIBER: |
| 987 | EePhyTypeSerdes = TRUE; |
| 988 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 989 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 990 | default: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 991 | EePhyTypeSerdes = FALSE; |
| 992 | break; |
| 993 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 994 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 995 | /* Determine PHY led mode. */ |
| 996 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 997 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 998 | switch (Value32 & T3_NIC_CFG_LED_MODE_MASK) { |
| 999 | case T3_NIC_CFG_LED_MODE_TRIPLE_SPEED: |
| 1000 | EePhyLedMode = LED_MODE_THREE_LINK; |
| 1001 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1002 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1003 | case T3_NIC_CFG_LED_MODE_LINK_SPEED: |
| 1004 | EePhyLedMode = LED_MODE_LINK10; |
| 1005 | break; |
| 1006 | |
| 1007 | default: |
| 1008 | EePhyLedMode = LED_MODE_AUTO; |
| 1009 | break; |
| 1010 | } |
| 1011 | } else { |
| 1012 | switch (Value32 & T3_NIC_CFG_LED_MODE_MASK) { |
| 1013 | case T3_NIC_CFG_LED_MODE_OPEN_DRAIN: |
| 1014 | EePhyLedMode = LED_MODE_OPEN_DRAIN; |
| 1015 | break; |
| 1016 | |
| 1017 | case T3_NIC_CFG_LED_MODE_OUTPUT: |
| 1018 | EePhyLedMode = LED_MODE_OUTPUT; |
| 1019 | break; |
| 1020 | |
| 1021 | default: |
| 1022 | EePhyLedMode = LED_MODE_AUTO; |
| 1023 | break; |
| 1024 | } |
| 1025 | } |
| 1026 | if (pDevice->ChipRevId == T3_CHIP_ID_5703_A1 || |
| 1027 | pDevice->ChipRevId == T3_CHIP_ID_5703_A2) { |
| 1028 | /* Enable EEPROM write protection. */ |
| 1029 | if (Value32 & T3_NIC_EEPROM_WP) { |
| 1030 | pDevice->EepromWp = TRUE; |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | /* Get the PHY Id. */ |
| 1035 | Value32 = MEM_RD_OFFSET (pDevice, T3_NIC_DATA_PHY_ID_ADDR); |
| 1036 | if (Value32) { |
| 1037 | EePhyId = (((Value32 & T3_NIC_PHY_ID1_MASK) >> 16) & |
| 1038 | PHY_ID1_OUI_MASK) << 10; |
| 1039 | |
| 1040 | Value32 = Value32 & T3_NIC_PHY_ID2_MASK; |
| 1041 | |
| 1042 | EePhyId |= ((Value32 & PHY_ID2_OUI_MASK) << 16) | |
| 1043 | (Value32 & PHY_ID2_MODEL_MASK) | (Value32 & |
| 1044 | PHY_ID2_REV_MASK); |
| 1045 | } else { |
| 1046 | EePhyId = 0; |
| 1047 | } |
| 1048 | } else { |
| 1049 | EeSigFound = FALSE; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1050 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1051 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1052 | /* Set the PHY address. */ |
| 1053 | pDevice->PhyAddr = PHY_DEVICE_ID; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1054 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1055 | /* Disable auto polling. */ |
| 1056 | pDevice->MiMode = 0xc0000; |
| 1057 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode); |
| 1058 | MM_Wait (40); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1059 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1060 | /* Get the PHY id. */ |
| 1061 | LM_ReadPhy (pDevice, PHY_ID1_REG, &Value32); |
| 1062 | pDevice->PhyId = (Value32 & PHY_ID1_OUI_MASK) << 10; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1063 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1064 | LM_ReadPhy (pDevice, PHY_ID2_REG, &Value32); |
| 1065 | pDevice->PhyId |= ((Value32 & PHY_ID2_OUI_MASK) << 16) | |
| 1066 | (Value32 & PHY_ID2_MODEL_MASK) | (Value32 & PHY_ID2_REV_MASK); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1067 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1068 | /* Set the EnableTbi flag to false if we have a copper PHY. */ |
| 1069 | switch (pDevice->PhyId & PHY_ID_MASK) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1070 | case PHY_BCM5400_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1071 | pDevice->EnableTbi = FALSE; |
| 1072 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1073 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1074 | case PHY_BCM5401_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1075 | pDevice->EnableTbi = FALSE; |
| 1076 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1077 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1078 | case PHY_BCM5411_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1079 | pDevice->EnableTbi = FALSE; |
| 1080 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1081 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1082 | case PHY_BCM5701_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1083 | pDevice->EnableTbi = FALSE; |
| 1084 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1085 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1086 | case PHY_BCM5703_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1087 | pDevice->EnableTbi = FALSE; |
| 1088 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1089 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1090 | case PHY_BCM5704_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1091 | pDevice->EnableTbi = FALSE; |
| 1092 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1093 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1094 | case PHY_BCM8002_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1095 | pDevice->EnableTbi = TRUE; |
| 1096 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1097 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1098 | default: |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1099 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1100 | if (pAdapterInfo) { |
| 1101 | pDevice->PhyId = pAdapterInfo->PhyId; |
| 1102 | pDevice->EnableTbi = pAdapterInfo->Serdes; |
| 1103 | } else if (EeSigFound) { |
| 1104 | pDevice->PhyId = EePhyId; |
| 1105 | pDevice->EnableTbi = EePhyTypeSerdes; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1106 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1107 | break; |
| 1108 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1109 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1110 | /* Bail out if we don't know the copper PHY id. */ |
| 1111 | if (UNKNOWN_PHY_ID (pDevice->PhyId) && !pDevice->EnableTbi) { |
| 1112 | return LM_STATUS_FAILURE; |
| 1113 | } |
| 1114 | |
| 1115 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5703) { |
| 1116 | if ((pDevice->SavedCacheLineReg & 0xff00) < 0x4000) { |
| 1117 | pDevice->SavedCacheLineReg &= 0xffff00ff; |
| 1118 | pDevice->SavedCacheLineReg |= 0x4000; |
| 1119 | } |
| 1120 | } |
| 1121 | /* Change driver parameters. */ |
| 1122 | Status = MM_GetConfig (pDevice); |
| 1123 | if (Status != LM_STATUS_SUCCESS) { |
| 1124 | return Status; |
| 1125 | } |
| 1126 | #if INCLUDE_5701_AX_FIX |
| 1127 | if (pDevice->ChipRevId == T3_CHIP_ID_5701_A0 || |
| 1128 | pDevice->ChipRevId == T3_CHIP_ID_5701_B0) { |
| 1129 | pDevice->ResetPhyOnInit = TRUE; |
| 1130 | } |
| 1131 | #endif |
| 1132 | |
| 1133 | /* Save the current phy link status. */ |
| 1134 | if (!pDevice->EnableTbi) { |
| 1135 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 1136 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 1137 | |
| 1138 | /* If we don't have link reset the PHY. */ |
| 1139 | if (!(Value32 & PHY_STATUS_LINK_PASS) |
| 1140 | || pDevice->ResetPhyOnInit) { |
| 1141 | |
| 1142 | LM_WritePhy (pDevice, PHY_CTRL_REG, PHY_CTRL_PHY_RESET); |
| 1143 | |
| 1144 | for (j = 0; j < 100; j++) { |
| 1145 | MM_Wait (10); |
| 1146 | |
| 1147 | LM_ReadPhy (pDevice, PHY_CTRL_REG, &Value32); |
| 1148 | if (Value32 && !(Value32 & PHY_CTRL_PHY_RESET)) { |
| 1149 | MM_Wait (40); |
| 1150 | break; |
| 1151 | } |
| 1152 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1153 | |
| 1154 | #if INCLUDE_5701_AX_FIX |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1155 | /* 5701_AX_BX bug: only advertises 10mb speed. */ |
| 1156 | if (pDevice->ChipRevId == T3_CHIP_ID_5701_A0 || |
| 1157 | pDevice->ChipRevId == T3_CHIP_ID_5701_B0) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1158 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1159 | Value32 = PHY_AN_AD_PROTOCOL_802_3_CSMA_CD | |
| 1160 | PHY_AN_AD_10BASET_HALF | |
| 1161 | PHY_AN_AD_10BASET_FULL | |
| 1162 | PHY_AN_AD_100BASETX_FULL | |
| 1163 | PHY_AN_AD_100BASETX_HALF; |
| 1164 | Value32 |= GetPhyAdFlowCntrlSettings (pDevice); |
| 1165 | LM_WritePhy (pDevice, PHY_AN_AD_REG, Value32); |
| 1166 | pDevice->advertising = Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1167 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1168 | Value32 = BCM540X_AN_AD_1000BASET_HALF | |
| 1169 | BCM540X_AN_AD_1000BASET_FULL | |
| 1170 | BCM540X_CONFIG_AS_MASTER | |
| 1171 | BCM540X_ENABLE_CONFIG_AS_MASTER; |
| 1172 | LM_WritePhy (pDevice, |
| 1173 | BCM540X_1000BASET_CTRL_REG, |
| 1174 | Value32); |
| 1175 | pDevice->advertising1000 = Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1176 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1177 | LM_WritePhy (pDevice, PHY_CTRL_REG, |
| 1178 | PHY_CTRL_AUTO_NEG_ENABLE | |
| 1179 | PHY_CTRL_RESTART_AUTO_NEG); |
| 1180 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1181 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1182 | if (T3_ASIC_REV (pDevice->ChipRevId) == |
| 1183 | T3_ASIC_REV_5703) { |
| 1184 | LM_WritePhy (pDevice, 0x18, 0x0c00); |
| 1185 | LM_WritePhy (pDevice, 0x17, 0x201f); |
| 1186 | LM_WritePhy (pDevice, 0x15, 0x2aaa); |
| 1187 | } |
| 1188 | if (pDevice->ChipRevId == T3_CHIP_ID_5704_A0) { |
| 1189 | LM_WritePhy (pDevice, 0x1c, 0x8d68); |
| 1190 | LM_WritePhy (pDevice, 0x1c, 0x8d68); |
| 1191 | } |
| 1192 | /* Enable Ethernet@WireSpeed. */ |
| 1193 | if (pDevice->EnableWireSpeed) { |
| 1194 | LM_WritePhy (pDevice, 0x18, 0x7007); |
| 1195 | LM_ReadPhy (pDevice, 0x18, &Value32); |
| 1196 | LM_WritePhy (pDevice, 0x18, |
| 1197 | Value32 | BIT_15 | BIT_4); |
| 1198 | } |
| 1199 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1200 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1201 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1202 | /* Turn off tap power management. */ |
| 1203 | if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5401_PHY_ID) { |
| 1204 | LM_WritePhy (pDevice, BCM5401_AUX_CTRL, 0x0c20); |
| 1205 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x0012); |
| 1206 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x1804); |
| 1207 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x0013); |
| 1208 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x1204); |
| 1209 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x8006); |
| 1210 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x0132); |
| 1211 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x8006); |
| 1212 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x0232); |
| 1213 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x201f); |
| 1214 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x0a20); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1215 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1216 | MM_Wait (40); |
| 1217 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1218 | #if INCLUDE_TBI_SUPPORT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1219 | pDevice->IgnoreTbiLinkChange = FALSE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1220 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1221 | if (pDevice->EnableTbi) { |
| 1222 | pDevice->WakeUpModeCap = LM_WAKE_UP_MODE_NONE; |
| 1223 | pDevice->PhyIntMode = T3_PHY_INT_MODE_LINK_READY; |
| 1224 | if ((pDevice->PollTbiLink == BAD_DEFAULT_VALUE) || |
| 1225 | pDevice->DisableAutoNeg) { |
| 1226 | pDevice->PollTbiLink = FALSE; |
| 1227 | } |
| 1228 | } else { |
| 1229 | pDevice->PollTbiLink = FALSE; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1230 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1231 | #endif /* INCLUDE_TBI_SUPPORT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1232 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1233 | /* UseTaggedStatus is only valid for 5701 and later. */ |
| 1234 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 1235 | pDevice->UseTaggedStatus = FALSE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1236 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1237 | pDevice->CoalesceMode = 0; |
| 1238 | } else { |
| 1239 | pDevice->CoalesceMode = |
| 1240 | HOST_COALESCE_CLEAR_TICKS_ON_RX_BD_EVENT | |
| 1241 | HOST_COALESCE_CLEAR_TICKS_ON_TX_BD_EVENT; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1242 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1243 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1244 | /* Set the status block size. */ |
| 1245 | if (T3_CHIP_REV (pDevice->ChipRevId) != T3_CHIP_REV_5700_AX && |
| 1246 | T3_CHIP_REV (pDevice->ChipRevId) != T3_CHIP_REV_5700_BX) { |
| 1247 | pDevice->CoalesceMode |= HOST_COALESCE_32_BYTE_STATUS_MODE; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1248 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1249 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1250 | /* Check the DURING_INT coalescing ticks parameters. */ |
| 1251 | if (pDevice->UseTaggedStatus) { |
| 1252 | if (pDevice->RxCoalescingTicksDuringInt == BAD_DEFAULT_VALUE) { |
| 1253 | pDevice->RxCoalescingTicksDuringInt = |
| 1254 | DEFAULT_RX_COALESCING_TICKS_DURING_INT; |
| 1255 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1256 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1257 | if (pDevice->TxCoalescingTicksDuringInt == BAD_DEFAULT_VALUE) { |
| 1258 | pDevice->TxCoalescingTicksDuringInt = |
| 1259 | DEFAULT_TX_COALESCING_TICKS_DURING_INT; |
| 1260 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1261 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1262 | if (pDevice->RxMaxCoalescedFramesDuringInt == BAD_DEFAULT_VALUE) { |
| 1263 | pDevice->RxMaxCoalescedFramesDuringInt = |
| 1264 | DEFAULT_RX_MAX_COALESCED_FRAMES_DURING_INT; |
| 1265 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1266 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1267 | if (pDevice->TxMaxCoalescedFramesDuringInt == BAD_DEFAULT_VALUE) { |
| 1268 | pDevice->TxMaxCoalescedFramesDuringInt = |
| 1269 | DEFAULT_TX_MAX_COALESCED_FRAMES_DURING_INT; |
| 1270 | } |
| 1271 | } else { |
| 1272 | if (pDevice->RxCoalescingTicksDuringInt == BAD_DEFAULT_VALUE) { |
| 1273 | pDevice->RxCoalescingTicksDuringInt = 0; |
| 1274 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1275 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1276 | if (pDevice->TxCoalescingTicksDuringInt == BAD_DEFAULT_VALUE) { |
| 1277 | pDevice->TxCoalescingTicksDuringInt = 0; |
| 1278 | } |
| 1279 | |
| 1280 | if (pDevice->RxMaxCoalescedFramesDuringInt == BAD_DEFAULT_VALUE) { |
| 1281 | pDevice->RxMaxCoalescedFramesDuringInt = 0; |
| 1282 | } |
| 1283 | |
| 1284 | if (pDevice->TxMaxCoalescedFramesDuringInt == BAD_DEFAULT_VALUE) { |
| 1285 | pDevice->TxMaxCoalescedFramesDuringInt = 0; |
| 1286 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1287 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1288 | |
| 1289 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1290 | if (pDevice->RxMtu <= (MAX_STD_RCV_BUFFER_SIZE - 8 /* CRC */ )) { |
| 1291 | pDevice->RxJumboDescCnt = 0; |
| 1292 | if (pDevice->RxMtu <= MAX_ETHERNET_PACKET_SIZE_NO_CRC) { |
| 1293 | pDevice->RxMtu = MAX_ETHERNET_PACKET_SIZE_NO_CRC; |
| 1294 | } |
| 1295 | } else { |
| 1296 | pDevice->RxJumboBufferSize = |
| 1297 | (pDevice->RxMtu + 8 /* CRC + VLAN */ + |
| 1298 | COMMON_CACHE_LINE_SIZE - 1) & ~COMMON_CACHE_LINE_MASK; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1299 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1300 | if (pDevice->RxJumboBufferSize > MAX_JUMBO_RCV_BUFFER_SIZE) { |
| 1301 | pDevice->RxJumboBufferSize = |
| 1302 | DEFAULT_JUMBO_RCV_BUFFER_SIZE; |
| 1303 | pDevice->RxMtu = |
| 1304 | pDevice->RxJumboBufferSize - 8 /* CRC + VLAN */ ; |
| 1305 | } |
| 1306 | pDevice->TxMtu = pDevice->RxMtu; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1307 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1308 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1309 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1310 | pDevice->RxMtu = MAX_ETHERNET_PACKET_SIZE_NO_CRC; |
| 1311 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1312 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1313 | pDevice->RxPacketDescCnt = |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1314 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1315 | pDevice->RxJumboDescCnt + |
| 1316 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
| 1317 | pDevice->RxStdDescCnt; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1318 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1319 | if (pDevice->TxMtu < MAX_ETHERNET_PACKET_SIZE_NO_CRC) { |
| 1320 | pDevice->TxMtu = MAX_ETHERNET_PACKET_SIZE_NO_CRC; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1321 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1322 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1323 | if (pDevice->TxMtu > MAX_JUMBO_TX_BUFFER_SIZE) { |
| 1324 | pDevice->TxMtu = MAX_JUMBO_TX_BUFFER_SIZE; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1325 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1326 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1327 | /* Configure the proper ways to get link change interrupt. */ |
| 1328 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO) { |
| 1329 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 1330 | pDevice->PhyIntMode = T3_PHY_INT_MODE_MI_INTERRUPT; |
| 1331 | } else { |
| 1332 | pDevice->PhyIntMode = T3_PHY_INT_MODE_LINK_READY; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1333 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1334 | } else if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO_POLLING) { |
| 1335 | /* Auto-polling does not work on 5700_AX and 5700_BX. */ |
| 1336 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 1337 | pDevice->PhyIntMode = T3_PHY_INT_MODE_MI_INTERRUPT; |
| 1338 | } |
| 1339 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1340 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1341 | /* Determine the method to get link change status. */ |
| 1342 | if (pDevice->LinkChngMode == T3_LINK_CHNG_MODE_AUTO) { |
| 1343 | /* The link status bit in the status block does not work on 5700_AX */ |
| 1344 | /* and 5700_BX chips. */ |
| 1345 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 1346 | pDevice->LinkChngMode = |
| 1347 | T3_LINK_CHNG_MODE_USE_STATUS_REG; |
| 1348 | } else { |
| 1349 | pDevice->LinkChngMode = |
| 1350 | T3_LINK_CHNG_MODE_USE_STATUS_BLOCK; |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_MI_INTERRUPT || |
| 1355 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1356 | pDevice->LinkChngMode = T3_LINK_CHNG_MODE_USE_STATUS_REG; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1357 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1358 | |
| 1359 | /* Configure PHY led mode. */ |
| 1360 | if (pDevice->LedMode == LED_MODE_AUTO) { |
| 1361 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 1362 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 1363 | if (pDevice->SubsystemVendorId == T3_SVID_DELL) { |
| 1364 | pDevice->LedMode = LED_MODE_LINK10; |
| 1365 | } else { |
| 1366 | pDevice->LedMode = LED_MODE_THREE_LINK; |
| 1367 | |
| 1368 | if (EeSigFound && EePhyLedMode != LED_MODE_AUTO) { |
| 1369 | pDevice->LedMode = EePhyLedMode; |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | /* bug? 5701 in LINK10 mode does not seem to work when */ |
| 1374 | /* PhyIntMode is LINK_READY. */ |
| 1375 | if (T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5700 |
| 1376 | && |
| 1377 | #if INCLUDE_TBI_SUPPORT |
| 1378 | pDevice->EnableTbi == FALSE && |
| 1379 | #endif |
| 1380 | pDevice->LedMode == LED_MODE_LINK10) { |
| 1381 | pDevice->PhyIntMode = |
| 1382 | T3_PHY_INT_MODE_MI_INTERRUPT; |
| 1383 | pDevice->LinkChngMode = |
| 1384 | T3_LINK_CHNG_MODE_USE_STATUS_REG; |
| 1385 | } |
| 1386 | |
| 1387 | if (pDevice->EnableTbi) { |
| 1388 | pDevice->LedMode = LED_MODE_THREE_LINK; |
| 1389 | } |
| 1390 | } else { |
| 1391 | if (EeSigFound && EePhyLedMode != LED_MODE_AUTO) { |
| 1392 | pDevice->LedMode = EePhyLedMode; |
| 1393 | } else { |
| 1394 | pDevice->LedMode = LED_MODE_OPEN_DRAIN; |
| 1395 | } |
| 1396 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1397 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1398 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1399 | /* Enable OneDmaAtOnce. */ |
| 1400 | if (pDevice->OneDmaAtOnce == BAD_DEFAULT_VALUE) { |
| 1401 | pDevice->OneDmaAtOnce = FALSE; |
| 1402 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1403 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1404 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 1405 | pDevice->ChipRevId == T3_CHIP_ID_5701_A0 || |
| 1406 | pDevice->ChipRevId == T3_CHIP_ID_5701_B0 || |
| 1407 | pDevice->ChipRevId == T3_CHIP_ID_5701_B2) { |
| 1408 | pDevice->WolSpeed = WOL_SPEED_10MB; |
| 1409 | } else { |
| 1410 | pDevice->WolSpeed = WOL_SPEED_100MB; |
| 1411 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1412 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1413 | /* Offloadings. */ |
| 1414 | pDevice->TaskToOffload = LM_TASK_OFFLOAD_NONE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1415 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1416 | /* Turn off task offloading on Ax. */ |
| 1417 | if (pDevice->ChipRevId == T3_CHIP_ID_5700_B0) { |
| 1418 | pDevice->TaskOffloadCap &= ~(LM_TASK_OFFLOAD_TX_TCP_CHECKSUM | |
| 1419 | LM_TASK_OFFLOAD_TX_UDP_CHECKSUM); |
| 1420 | } |
| 1421 | pDevice->PciState = REG_RD (pDevice, PciCfg.PciState); |
| 1422 | LM_ReadVPD (pDevice); |
| 1423 | LM_ReadBootCodeVersion (pDevice); |
| 1424 | LM_GetBusSpeed (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1425 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1426 | return LM_STATUS_SUCCESS; |
| 1427 | } /* LM_GetAdapterInfo */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1428 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1429 | STATIC PLM_ADAPTER_INFO LM_GetAdapterInfoBySsid (LM_UINT16 Svid, LM_UINT16 Ssid) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1430 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1431 | static LM_ADAPTER_INFO AdapterArr[] = { |
| 1432 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95700A6, |
| 1433 | PHY_BCM5401_PHY_ID, 0}, |
| 1434 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95701A5, |
| 1435 | PHY_BCM5701_PHY_ID, 0}, |
| 1436 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95700T6, |
| 1437 | PHY_BCM8002_PHY_ID, 1}, |
| 1438 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95700A9, 0, 1}, |
| 1439 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95701T1, |
| 1440 | PHY_BCM5701_PHY_ID, 0}, |
| 1441 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95701T8, |
| 1442 | PHY_BCM5701_PHY_ID, 0}, |
| 1443 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95701A7, 0, 1}, |
| 1444 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95701A10, |
| 1445 | PHY_BCM5701_PHY_ID, 0}, |
| 1446 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95701A12, |
| 1447 | PHY_BCM5701_PHY_ID, 0}, |
| 1448 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95703Ax1, |
| 1449 | PHY_BCM5701_PHY_ID, 0}, |
| 1450 | {T3_SVID_BROADCOM, T3_SSID_BROADCOM_BCM95703Ax2, |
| 1451 | PHY_BCM5701_PHY_ID, 0}, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1452 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1453 | {T3_SVID_3COM, T3_SSID_3COM_3C996T, PHY_BCM5401_PHY_ID, 0}, |
| 1454 | {T3_SVID_3COM, T3_SSID_3COM_3C996BT, PHY_BCM5701_PHY_ID, 0}, |
| 1455 | {T3_SVID_3COM, T3_SSID_3COM_3C996SX, 0, 1}, |
| 1456 | {T3_SVID_3COM, T3_SSID_3COM_3C1000T, PHY_BCM5701_PHY_ID, 0}, |
| 1457 | {T3_SVID_3COM, T3_SSID_3COM_3C940BR01, PHY_BCM5701_PHY_ID, 0}, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1458 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1459 | {T3_SVID_DELL, T3_SSID_DELL_VIPER, PHY_BCM5401_PHY_ID, 0}, |
| 1460 | {T3_SVID_DELL, T3_SSID_DELL_JAGUAR, PHY_BCM5401_PHY_ID, 0}, |
| 1461 | {T3_SVID_DELL, T3_SSID_DELL_MERLOT, PHY_BCM5411_PHY_ID, 0}, |
| 1462 | {T3_SVID_DELL, T3_SSID_DELL_SLIM_MERLOT, PHY_BCM5411_PHY_ID, 0}, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1463 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1464 | {T3_SVID_COMPAQ, T3_SSID_COMPAQ_BANSHEE, PHY_BCM5701_PHY_ID, 0}, |
| 1465 | {T3_SVID_COMPAQ, T3_SSID_COMPAQ_BANSHEE_2, PHY_BCM5701_PHY_ID, |
| 1466 | 0}, |
| 1467 | {T3_SVID_COMPAQ, T3_SSID_COMPAQ_CHANGELING, 0, 1}, |
| 1468 | {T3_SVID_COMPAQ, T3_SSID_COMPAQ_NC7780, PHY_BCM5701_PHY_ID, 0}, |
| 1469 | {T3_SVID_COMPAQ, T3_SSID_COMPAQ_NC7780_2, PHY_BCM5701_PHY_ID, |
| 1470 | 0}, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1471 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1472 | }; |
| 1473 | LM_UINT32 j; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1474 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1475 | for (j = 0; j < sizeof (AdapterArr) / sizeof (LM_ADAPTER_INFO); j++) { |
| 1476 | if (AdapterArr[j].Svid == Svid && AdapterArr[j].Ssid == Ssid) { |
| 1477 | return &AdapterArr[j]; |
| 1478 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1479 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1480 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1481 | return NULL; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1482 | } |
| 1483 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1484 | /******************************************************************************/ |
| 1485 | /* Description: */ |
| 1486 | /* This routine sets up receive/transmit buffer descriptions queues. */ |
| 1487 | /* */ |
| 1488 | /* Return: */ |
| 1489 | /* LM_STATUS_SUCCESS */ |
| 1490 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1491 | LM_STATUS LM_InitializeAdapter (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1492 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1493 | LM_PHYSICAL_ADDRESS MemPhy; |
| 1494 | PLM_UINT8 pMemVirt; |
| 1495 | PLM_PACKET pPacket; |
| 1496 | LM_STATUS Status; |
| 1497 | LM_UINT32 Size; |
| 1498 | LM_UINT32 j; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1499 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1500 | /* Set power state to D0. */ |
| 1501 | LM_SetPowerState (pDevice, LM_POWER_STATE_D0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1502 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1503 | /* Intialize the queues. */ |
| 1504 | QQ_InitQueue (&pDevice->RxPacketReceivedQ.Container, |
| 1505 | MAX_RX_PACKET_DESC_COUNT); |
| 1506 | QQ_InitQueue (&pDevice->RxPacketFreeQ.Container, |
| 1507 | MAX_RX_PACKET_DESC_COUNT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1508 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1509 | QQ_InitQueue (&pDevice->TxPacketFreeQ.Container, |
| 1510 | MAX_TX_PACKET_DESC_COUNT); |
| 1511 | QQ_InitQueue (&pDevice->TxPacketActiveQ.Container, |
| 1512 | MAX_TX_PACKET_DESC_COUNT); |
| 1513 | QQ_InitQueue (&pDevice->TxPacketXmittedQ.Container, |
| 1514 | MAX_TX_PACKET_DESC_COUNT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1515 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1516 | /* Allocate shared memory for: status block, the buffers for receive */ |
| 1517 | /* rings -- standard, mini, jumbo, and return rings. */ |
| 1518 | Size = T3_STATUS_BLOCK_SIZE + sizeof (T3_STATS_BLOCK) + |
| 1519 | T3_STD_RCV_RCB_ENTRY_COUNT * sizeof (T3_RCV_BD) + |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1520 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1521 | T3_JUMBO_RCV_RCB_ENTRY_COUNT * sizeof (T3_RCV_BD) + |
| 1522 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
| 1523 | T3_RCV_RETURN_RCB_ENTRY_COUNT * sizeof (T3_RCV_BD); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1524 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1525 | /* Memory for host based Send BD. */ |
| 1526 | if (pDevice->NicSendBd == FALSE) { |
| 1527 | Size += sizeof (T3_SND_BD) * T3_SEND_RCB_ENTRY_COUNT; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1528 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1529 | |
| 1530 | /* Allocate the memory block. */ |
| 1531 | Status = |
| 1532 | MM_AllocateSharedMemory (pDevice, Size, (PLM_VOID) & pMemVirt, |
| 1533 | &MemPhy, FALSE); |
| 1534 | if (Status != LM_STATUS_SUCCESS) { |
| 1535 | return Status; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1536 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1537 | |
| 1538 | /* Program DMA Read/Write */ |
| 1539 | if (pDevice->PciState & T3_PCI_STATE_NOT_PCI_X_BUS) { |
| 1540 | pDevice->DmaReadWriteCtrl = 0x763f000f; |
| 1541 | } else { |
| 1542 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5704) { |
| 1543 | pDevice->DmaReadWriteCtrl = 0x761f0000; |
| 1544 | } else { |
| 1545 | pDevice->DmaReadWriteCtrl = 0x761b000f; |
| 1546 | } |
| 1547 | if (pDevice->ChipRevId == T3_CHIP_ID_5703_A1 || |
| 1548 | pDevice->ChipRevId == T3_CHIP_ID_5703_A2) { |
| 1549 | pDevice->OneDmaAtOnce = TRUE; |
| 1550 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1551 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1552 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5703) { |
| 1553 | pDevice->DmaReadWriteCtrl &= 0xfffffff0; |
| 1554 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1555 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1556 | if (pDevice->OneDmaAtOnce) { |
| 1557 | pDevice->DmaReadWriteCtrl |= DMA_CTRL_WRITE_ONE_DMA_AT_ONCE; |
| 1558 | } |
| 1559 | REG_WR (pDevice, PciCfg.DmaReadWriteCtrl, pDevice->DmaReadWriteCtrl); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1560 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1561 | if (LM_DmaTest (pDevice, pMemVirt, MemPhy, 0x400) != LM_STATUS_SUCCESS) { |
| 1562 | return LM_STATUS_FAILURE; |
| 1563 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1564 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1565 | /* Status block. */ |
| 1566 | pDevice->pStatusBlkVirt = (PT3_STATUS_BLOCK) pMemVirt; |
| 1567 | pDevice->StatusBlkPhy = MemPhy; |
| 1568 | pMemVirt += T3_STATUS_BLOCK_SIZE; |
| 1569 | LM_INC_PHYSICAL_ADDRESS (&MemPhy, T3_STATUS_BLOCK_SIZE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1570 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1571 | /* Statistics block. */ |
| 1572 | pDevice->pStatsBlkVirt = (PT3_STATS_BLOCK) pMemVirt; |
| 1573 | pDevice->StatsBlkPhy = MemPhy; |
| 1574 | pMemVirt += sizeof (T3_STATS_BLOCK); |
| 1575 | LM_INC_PHYSICAL_ADDRESS (&MemPhy, sizeof (T3_STATS_BLOCK)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1576 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1577 | /* Receive standard BD buffer. */ |
| 1578 | pDevice->pRxStdBdVirt = (PT3_RCV_BD) pMemVirt; |
| 1579 | pDevice->RxStdBdPhy = MemPhy; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1580 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1581 | pMemVirt += T3_STD_RCV_RCB_ENTRY_COUNT * sizeof (T3_RCV_BD); |
| 1582 | LM_INC_PHYSICAL_ADDRESS (&MemPhy, |
| 1583 | T3_STD_RCV_RCB_ENTRY_COUNT * |
| 1584 | sizeof (T3_RCV_BD)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1585 | |
| 1586 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1587 | /* Receive jumbo BD buffer. */ |
| 1588 | pDevice->pRxJumboBdVirt = (PT3_RCV_BD) pMemVirt; |
| 1589 | pDevice->RxJumboBdPhy = MemPhy; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1590 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1591 | pMemVirt += T3_JUMBO_RCV_RCB_ENTRY_COUNT * sizeof (T3_RCV_BD); |
| 1592 | LM_INC_PHYSICAL_ADDRESS (&MemPhy, |
| 1593 | T3_JUMBO_RCV_RCB_ENTRY_COUNT * |
| 1594 | sizeof (T3_RCV_BD)); |
| 1595 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1596 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1597 | /* Receive return BD buffer. */ |
| 1598 | pDevice->pRcvRetBdVirt = (PT3_RCV_BD) pMemVirt; |
| 1599 | pDevice->RcvRetBdPhy = MemPhy; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1600 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1601 | pMemVirt += T3_RCV_RETURN_RCB_ENTRY_COUNT * sizeof (T3_RCV_BD); |
| 1602 | LM_INC_PHYSICAL_ADDRESS (&MemPhy, |
| 1603 | T3_RCV_RETURN_RCB_ENTRY_COUNT * |
| 1604 | sizeof (T3_RCV_BD)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1605 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1606 | /* Set up Send BD. */ |
| 1607 | if (pDevice->NicSendBd == FALSE) { |
| 1608 | pDevice->pSendBdVirt = (PT3_SND_BD) pMemVirt; |
| 1609 | pDevice->SendBdPhy = MemPhy; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1610 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1611 | pMemVirt += sizeof (T3_SND_BD) * T3_SEND_RCB_ENTRY_COUNT; |
| 1612 | LM_INC_PHYSICAL_ADDRESS (&MemPhy, |
| 1613 | sizeof (T3_SND_BD) * |
| 1614 | T3_SEND_RCB_ENTRY_COUNT); |
| 1615 | } else { |
| 1616 | pDevice->pSendBdVirt = (PT3_SND_BD) |
| 1617 | pDevice->pMemView->uIntMem.First32k.BufferDesc; |
| 1618 | pDevice->SendBdPhy.High = 0; |
| 1619 | pDevice->SendBdPhy.Low = T3_NIC_SND_BUFFER_DESC_ADDR; |
| 1620 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1621 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1622 | /* Allocate memory for packet descriptors. */ |
| 1623 | Size = (pDevice->RxPacketDescCnt + |
| 1624 | pDevice->TxPacketDescCnt) * MM_PACKET_DESC_SIZE; |
| 1625 | Status = MM_AllocateMemory (pDevice, Size, (PLM_VOID *) & pPacket); |
| 1626 | if (Status != LM_STATUS_SUCCESS) { |
| 1627 | return Status; |
| 1628 | } |
| 1629 | pDevice->pPacketDescBase = (PLM_VOID) pPacket; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1630 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1631 | /* Create transmit packet descriptors from the memory block and add them */ |
| 1632 | /* to the TxPacketFreeQ for each send ring. */ |
| 1633 | for (j = 0; j < pDevice->TxPacketDescCnt; j++) { |
| 1634 | /* Ring index. */ |
| 1635 | pPacket->Flags = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1636 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1637 | /* Queue the descriptor in the TxPacketFreeQ of the 'k' ring. */ |
| 1638 | QQ_PushTail (&pDevice->TxPacketFreeQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1639 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1640 | /* Get the pointer to the next descriptor. MM_PACKET_DESC_SIZE */ |
| 1641 | /* is the total size of the packet descriptor including the */ |
| 1642 | /* os-specific extensions in the UM_PACKET structure. */ |
| 1643 | pPacket = |
| 1644 | (PLM_PACKET) ((PLM_UINT8) pPacket + MM_PACKET_DESC_SIZE); |
| 1645 | } /* for(j.. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1646 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1647 | /* Create receive packet descriptors from the memory block and add them */ |
| 1648 | /* to the RxPacketFreeQ. Create the Standard packet descriptors. */ |
| 1649 | for (j = 0; j < pDevice->RxStdDescCnt; j++) { |
| 1650 | /* Receive producer ring. */ |
| 1651 | pPacket->u.Rx.RcvProdRing = T3_STD_RCV_PROD_RING; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1652 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1653 | /* Receive buffer size. */ |
| 1654 | pPacket->u.Rx.RxBufferSize = MAX_STD_RCV_BUFFER_SIZE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1655 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1656 | /* Add the descriptor to RxPacketFreeQ. */ |
| 1657 | QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1658 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1659 | /* Get the pointer to the next descriptor. MM_PACKET_DESC_SIZE */ |
| 1660 | /* is the total size of the packet descriptor including the */ |
| 1661 | /* os-specific extensions in the UM_PACKET structure. */ |
| 1662 | pPacket = |
| 1663 | (PLM_PACKET) ((PLM_UINT8) pPacket + MM_PACKET_DESC_SIZE); |
| 1664 | } /* for */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1665 | |
| 1666 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1667 | /* Create the Jumbo packet descriptors. */ |
| 1668 | for (j = 0; j < pDevice->RxJumboDescCnt; j++) { |
| 1669 | /* Receive producer ring. */ |
| 1670 | pPacket->u.Rx.RcvProdRing = T3_JUMBO_RCV_PROD_RING; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1671 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1672 | /* Receive buffer size. */ |
| 1673 | pPacket->u.Rx.RxBufferSize = pDevice->RxJumboBufferSize; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1674 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1675 | /* Add the descriptor to RxPacketFreeQ. */ |
| 1676 | QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1677 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1678 | /* Get the pointer to the next descriptor. MM_PACKET_DESC_SIZE */ |
| 1679 | /* is the total size of the packet descriptor including the */ |
| 1680 | /* os-specific extensions in the UM_PACKET structure. */ |
| 1681 | pPacket = |
| 1682 | (PLM_PACKET) ((PLM_UINT8) pPacket + MM_PACKET_DESC_SIZE); |
| 1683 | } /* for */ |
| 1684 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1685 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1686 | /* Initialize the rest of the packet descriptors. */ |
| 1687 | Status = MM_InitializeUmPackets (pDevice); |
| 1688 | if (Status != LM_STATUS_SUCCESS) { |
| 1689 | return Status; |
| 1690 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1691 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1692 | /* if */ |
| 1693 | /* Default receive mask. */ |
| 1694 | pDevice->ReceiveMask = LM_ACCEPT_MULTICAST | LM_ACCEPT_BROADCAST | |
| 1695 | LM_ACCEPT_UNICAST; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1696 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1697 | /* Make sure we are in the first 32k memory window or NicSendBd. */ |
| 1698 | REG_WR (pDevice, PciCfg.MemWindowBaseAddr, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1699 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1700 | /* Initialize the hardware. */ |
| 1701 | Status = LM_ResetAdapter (pDevice); |
| 1702 | if (Status != LM_STATUS_SUCCESS) { |
| 1703 | return Status; |
| 1704 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1705 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1706 | /* We are done with initialization. */ |
| 1707 | pDevice->InitDone = TRUE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1708 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1709 | return LM_STATUS_SUCCESS; |
| 1710 | } /* LM_InitializeAdapter */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1711 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1712 | /******************************************************************************/ |
| 1713 | /* Description: */ |
| 1714 | /* This function Enables/Disables a given block. */ |
| 1715 | /* */ |
| 1716 | /* Return: */ |
| 1717 | /* LM_STATUS_SUCCESS */ |
| 1718 | /******************************************************************************/ |
| 1719 | LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1720 | LM_CntrlBlock (PLM_DEVICE_BLOCK pDevice, LM_UINT32 mask, LM_UINT32 cntrl) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1721 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1722 | LM_UINT32 j, i, data; |
| 1723 | LM_UINT32 MaxWaitCnt; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1724 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1725 | MaxWaitCnt = 2; |
| 1726 | j = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1727 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1728 | for (i = 0; i < 32; i++) { |
| 1729 | if (!(mask & (1 << i))) |
| 1730 | continue; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1731 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1732 | switch (1 << i) { |
| 1733 | case T3_BLOCK_DMA_RD: |
| 1734 | data = REG_RD (pDevice, DmaRead.Mode); |
| 1735 | if (cntrl == LM_DISABLE) { |
| 1736 | data &= ~DMA_READ_MODE_ENABLE; |
| 1737 | REG_WR (pDevice, DmaRead.Mode, data); |
| 1738 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1739 | if (! |
| 1740 | (REG_RD (pDevice, DmaRead.Mode) & |
| 1741 | DMA_READ_MODE_ENABLE)) |
| 1742 | break; |
| 1743 | MM_Wait (10); |
| 1744 | } |
| 1745 | } else |
| 1746 | REG_WR (pDevice, DmaRead.Mode, |
| 1747 | data | DMA_READ_MODE_ENABLE); |
| 1748 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1749 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1750 | case T3_BLOCK_DMA_COMP: |
| 1751 | data = REG_RD (pDevice, DmaComp.Mode); |
| 1752 | if (cntrl == LM_DISABLE) { |
| 1753 | data &= ~DMA_COMP_MODE_ENABLE; |
| 1754 | REG_WR (pDevice, DmaComp.Mode, data); |
| 1755 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1756 | if (! |
| 1757 | (REG_RD (pDevice, DmaComp.Mode) & |
| 1758 | DMA_COMP_MODE_ENABLE)) |
| 1759 | break; |
| 1760 | MM_Wait (10); |
| 1761 | } |
| 1762 | } else |
| 1763 | REG_WR (pDevice, DmaComp.Mode, |
| 1764 | data | DMA_COMP_MODE_ENABLE); |
| 1765 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1766 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1767 | case T3_BLOCK_RX_BD_INITIATOR: |
| 1768 | data = REG_RD (pDevice, RcvBdIn.Mode); |
| 1769 | if (cntrl == LM_DISABLE) { |
| 1770 | data &= ~RCV_BD_IN_MODE_ENABLE; |
| 1771 | REG_WR (pDevice, RcvBdIn.Mode, data); |
| 1772 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1773 | if (! |
| 1774 | (REG_RD (pDevice, RcvBdIn.Mode) & |
| 1775 | RCV_BD_IN_MODE_ENABLE)) |
| 1776 | break; |
| 1777 | MM_Wait (10); |
| 1778 | } |
| 1779 | } else |
| 1780 | REG_WR (pDevice, RcvBdIn.Mode, |
| 1781 | data | RCV_BD_IN_MODE_ENABLE); |
| 1782 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1783 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1784 | case T3_BLOCK_RX_BD_COMP: |
| 1785 | data = REG_RD (pDevice, RcvBdComp.Mode); |
| 1786 | if (cntrl == LM_DISABLE) { |
| 1787 | data &= ~RCV_BD_COMP_MODE_ENABLE; |
| 1788 | REG_WR (pDevice, RcvBdComp.Mode, data); |
| 1789 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1790 | if (! |
| 1791 | (REG_RD (pDevice, RcvBdComp.Mode) & |
| 1792 | RCV_BD_COMP_MODE_ENABLE)) |
| 1793 | break; |
| 1794 | MM_Wait (10); |
| 1795 | } |
| 1796 | } else |
| 1797 | REG_WR (pDevice, RcvBdComp.Mode, |
| 1798 | data | RCV_BD_COMP_MODE_ENABLE); |
| 1799 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1800 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1801 | case T3_BLOCK_DMA_WR: |
| 1802 | data = REG_RD (pDevice, DmaWrite.Mode); |
| 1803 | if (cntrl == LM_DISABLE) { |
| 1804 | data &= ~DMA_WRITE_MODE_ENABLE; |
| 1805 | REG_WR (pDevice, DmaWrite.Mode, data); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1806 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1807 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1808 | if (! |
| 1809 | (REG_RD (pDevice, DmaWrite.Mode) & |
| 1810 | DMA_WRITE_MODE_ENABLE)) |
| 1811 | break; |
| 1812 | MM_Wait (10); |
| 1813 | } |
| 1814 | } else |
| 1815 | REG_WR (pDevice, DmaWrite.Mode, |
| 1816 | data | DMA_WRITE_MODE_ENABLE); |
| 1817 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1818 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1819 | case T3_BLOCK_MSI_HANDLER: |
| 1820 | data = REG_RD (pDevice, Msi.Mode); |
| 1821 | if (cntrl == LM_DISABLE) { |
| 1822 | data &= ~MSI_MODE_ENABLE; |
| 1823 | REG_WR (pDevice, Msi.Mode, data); |
| 1824 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1825 | if (! |
| 1826 | (REG_RD (pDevice, Msi.Mode) & |
| 1827 | MSI_MODE_ENABLE)) |
| 1828 | break; |
| 1829 | MM_Wait (10); |
| 1830 | } |
| 1831 | } else |
| 1832 | REG_WR (pDevice, Msi.Mode, |
| 1833 | data | MSI_MODE_ENABLE); |
| 1834 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1835 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1836 | case T3_BLOCK_RX_LIST_PLMT: |
| 1837 | data = REG_RD (pDevice, RcvListPlmt.Mode); |
| 1838 | if (cntrl == LM_DISABLE) { |
| 1839 | data &= ~RCV_LIST_PLMT_MODE_ENABLE; |
| 1840 | REG_WR (pDevice, RcvListPlmt.Mode, data); |
| 1841 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1842 | if (! |
| 1843 | (REG_RD (pDevice, RcvListPlmt.Mode) |
| 1844 | & RCV_LIST_PLMT_MODE_ENABLE)) |
| 1845 | break; |
| 1846 | MM_Wait (10); |
| 1847 | } |
| 1848 | } else |
| 1849 | REG_WR (pDevice, RcvListPlmt.Mode, |
| 1850 | data | RCV_LIST_PLMT_MODE_ENABLE); |
| 1851 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1852 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1853 | case T3_BLOCK_RX_LIST_SELECTOR: |
| 1854 | data = REG_RD (pDevice, RcvListSel.Mode); |
| 1855 | if (cntrl == LM_DISABLE) { |
| 1856 | data &= ~RCV_LIST_SEL_MODE_ENABLE; |
| 1857 | REG_WR (pDevice, RcvListSel.Mode, data); |
| 1858 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1859 | if (! |
| 1860 | (REG_RD (pDevice, RcvListSel.Mode) & |
| 1861 | RCV_LIST_SEL_MODE_ENABLE)) |
| 1862 | break; |
| 1863 | MM_Wait (10); |
| 1864 | } |
| 1865 | } else |
| 1866 | REG_WR (pDevice, RcvListSel.Mode, |
| 1867 | data | RCV_LIST_SEL_MODE_ENABLE); |
| 1868 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1869 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1870 | case T3_BLOCK_RX_DATA_INITIATOR: |
| 1871 | data = REG_RD (pDevice, RcvDataBdIn.Mode); |
| 1872 | if (cntrl == LM_DISABLE) { |
| 1873 | data &= ~RCV_DATA_BD_IN_MODE_ENABLE; |
| 1874 | REG_WR (pDevice, RcvDataBdIn.Mode, data); |
| 1875 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1876 | if (! |
| 1877 | (REG_RD (pDevice, RcvDataBdIn.Mode) |
| 1878 | & RCV_DATA_BD_IN_MODE_ENABLE)) |
| 1879 | break; |
| 1880 | MM_Wait (10); |
| 1881 | } |
| 1882 | } else |
| 1883 | REG_WR (pDevice, RcvDataBdIn.Mode, |
| 1884 | data | RCV_DATA_BD_IN_MODE_ENABLE); |
| 1885 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1886 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1887 | case T3_BLOCK_RX_DATA_COMP: |
| 1888 | data = REG_RD (pDevice, RcvDataComp.Mode); |
| 1889 | if (cntrl == LM_DISABLE) { |
| 1890 | data &= ~RCV_DATA_COMP_MODE_ENABLE; |
| 1891 | REG_WR (pDevice, RcvDataComp.Mode, data); |
| 1892 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1893 | if (! |
| 1894 | (REG_RD (pDevice, RcvDataBdIn.Mode) |
| 1895 | & RCV_DATA_COMP_MODE_ENABLE)) |
| 1896 | break; |
| 1897 | MM_Wait (10); |
| 1898 | } |
| 1899 | } else |
| 1900 | REG_WR (pDevice, RcvDataComp.Mode, |
| 1901 | data | RCV_DATA_COMP_MODE_ENABLE); |
| 1902 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1903 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1904 | case T3_BLOCK_HOST_COALESING: |
| 1905 | data = REG_RD (pDevice, HostCoalesce.Mode); |
| 1906 | if (cntrl == LM_DISABLE) { |
| 1907 | data &= ~HOST_COALESCE_ENABLE; |
| 1908 | REG_WR (pDevice, HostCoalesce.Mode, data); |
| 1909 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1910 | if (! |
| 1911 | (REG_RD (pDevice, SndBdIn.Mode) & |
| 1912 | HOST_COALESCE_ENABLE)) |
| 1913 | break; |
| 1914 | MM_Wait (10); |
| 1915 | } |
| 1916 | } else |
| 1917 | REG_WR (pDevice, HostCoalesce.Mode, |
| 1918 | data | HOST_COALESCE_ENABLE); |
| 1919 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1920 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1921 | case T3_BLOCK_MAC_RX_ENGINE: |
| 1922 | if (cntrl == LM_DISABLE) { |
| 1923 | pDevice->RxMode &= ~RX_MODE_ENABLE; |
| 1924 | REG_WR (pDevice, MacCtrl.RxMode, |
| 1925 | pDevice->RxMode); |
| 1926 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1927 | if (! |
| 1928 | (REG_RD (pDevice, MacCtrl.RxMode) & |
| 1929 | RX_MODE_ENABLE)) { |
| 1930 | break; |
| 1931 | } |
| 1932 | MM_Wait (10); |
| 1933 | } |
| 1934 | } else { |
| 1935 | pDevice->RxMode |= RX_MODE_ENABLE; |
| 1936 | REG_WR (pDevice, MacCtrl.RxMode, |
| 1937 | pDevice->RxMode); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1938 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1939 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1940 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1941 | case T3_BLOCK_MBUF_CLUSTER_FREE: |
| 1942 | data = REG_RD (pDevice, MbufClusterFree.Mode); |
| 1943 | if (cntrl == LM_DISABLE) { |
| 1944 | data &= ~MBUF_CLUSTER_FREE_MODE_ENABLE; |
| 1945 | REG_WR (pDevice, MbufClusterFree.Mode, data); |
| 1946 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1947 | if (! |
| 1948 | (REG_RD |
| 1949 | (pDevice, |
| 1950 | MbufClusterFree. |
| 1951 | Mode) & |
| 1952 | MBUF_CLUSTER_FREE_MODE_ENABLE)) |
| 1953 | break; |
| 1954 | MM_Wait (10); |
| 1955 | } |
| 1956 | } else |
| 1957 | REG_WR (pDevice, MbufClusterFree.Mode, |
| 1958 | data | MBUF_CLUSTER_FREE_MODE_ENABLE); |
| 1959 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1960 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1961 | case T3_BLOCK_SEND_BD_INITIATOR: |
| 1962 | data = REG_RD (pDevice, SndBdIn.Mode); |
| 1963 | if (cntrl == LM_DISABLE) { |
| 1964 | data &= ~SND_BD_IN_MODE_ENABLE; |
| 1965 | REG_WR (pDevice, SndBdIn.Mode, data); |
| 1966 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1967 | if (! |
| 1968 | (REG_RD (pDevice, SndBdIn.Mode) & |
| 1969 | SND_BD_IN_MODE_ENABLE)) |
| 1970 | break; |
| 1971 | MM_Wait (10); |
| 1972 | } |
| 1973 | } else |
| 1974 | REG_WR (pDevice, SndBdIn.Mode, |
| 1975 | data | SND_BD_IN_MODE_ENABLE); |
| 1976 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1977 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1978 | case T3_BLOCK_SEND_BD_COMP: |
| 1979 | data = REG_RD (pDevice, SndBdComp.Mode); |
| 1980 | if (cntrl == LM_DISABLE) { |
| 1981 | data &= ~SND_BD_COMP_MODE_ENABLE; |
| 1982 | REG_WR (pDevice, SndBdComp.Mode, data); |
| 1983 | for (j = 0; j < MaxWaitCnt; j++) { |
| 1984 | if (! |
| 1985 | (REG_RD (pDevice, SndBdComp.Mode) & |
| 1986 | SND_BD_COMP_MODE_ENABLE)) |
| 1987 | break; |
| 1988 | MM_Wait (10); |
| 1989 | } |
| 1990 | } else |
| 1991 | REG_WR (pDevice, SndBdComp.Mode, |
| 1992 | data | SND_BD_COMP_MODE_ENABLE); |
| 1993 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1994 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 1995 | case T3_BLOCK_SEND_BD_SELECTOR: |
| 1996 | data = REG_RD (pDevice, SndBdSel.Mode); |
| 1997 | if (cntrl == LM_DISABLE) { |
| 1998 | data &= ~SND_BD_SEL_MODE_ENABLE; |
| 1999 | REG_WR (pDevice, SndBdSel.Mode, data); |
| 2000 | for (j = 0; j < MaxWaitCnt; j++) { |
| 2001 | if (! |
| 2002 | (REG_RD (pDevice, SndBdSel.Mode) & |
| 2003 | SND_BD_SEL_MODE_ENABLE)) |
| 2004 | break; |
| 2005 | MM_Wait (10); |
| 2006 | } |
| 2007 | } else |
| 2008 | REG_WR (pDevice, SndBdSel.Mode, |
| 2009 | data | SND_BD_SEL_MODE_ENABLE); |
| 2010 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2011 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2012 | case T3_BLOCK_SEND_DATA_INITIATOR: |
| 2013 | data = REG_RD (pDevice, SndDataIn.Mode); |
| 2014 | if (cntrl == LM_DISABLE) { |
| 2015 | data &= ~T3_SND_DATA_IN_MODE_ENABLE; |
| 2016 | REG_WR (pDevice, SndDataIn.Mode, data); |
| 2017 | for (j = 0; j < MaxWaitCnt; j++) { |
| 2018 | if (! |
| 2019 | (REG_RD (pDevice, SndDataIn.Mode) & |
| 2020 | T3_SND_DATA_IN_MODE_ENABLE)) |
| 2021 | break; |
| 2022 | MM_Wait (10); |
| 2023 | } |
| 2024 | } else |
| 2025 | REG_WR (pDevice, SndDataIn.Mode, |
| 2026 | data | T3_SND_DATA_IN_MODE_ENABLE); |
| 2027 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2028 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2029 | case T3_BLOCK_SEND_DATA_COMP: |
| 2030 | data = REG_RD (pDevice, SndDataComp.Mode); |
| 2031 | if (cntrl == LM_DISABLE) { |
| 2032 | data &= ~SND_DATA_COMP_MODE_ENABLE; |
| 2033 | REG_WR (pDevice, SndDataComp.Mode, data); |
| 2034 | for (j = 0; j < MaxWaitCnt; j++) { |
| 2035 | if (! |
| 2036 | (REG_RD (pDevice, SndDataComp.Mode) |
| 2037 | & SND_DATA_COMP_MODE_ENABLE)) |
| 2038 | break; |
| 2039 | MM_Wait (10); |
| 2040 | } |
| 2041 | } else |
| 2042 | REG_WR (pDevice, SndDataComp.Mode, |
| 2043 | data | SND_DATA_COMP_MODE_ENABLE); |
| 2044 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2045 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2046 | case T3_BLOCK_MAC_TX_ENGINE: |
| 2047 | if (cntrl == LM_DISABLE) { |
| 2048 | pDevice->TxMode &= ~TX_MODE_ENABLE; |
| 2049 | REG_WR (pDevice, MacCtrl.TxMode, |
| 2050 | pDevice->TxMode); |
| 2051 | for (j = 0; j < MaxWaitCnt; j++) { |
| 2052 | if (! |
| 2053 | (REG_RD (pDevice, MacCtrl.TxMode) & |
| 2054 | TX_MODE_ENABLE)) |
| 2055 | break; |
| 2056 | MM_Wait (10); |
| 2057 | } |
| 2058 | } else { |
| 2059 | pDevice->TxMode |= TX_MODE_ENABLE; |
| 2060 | REG_WR (pDevice, MacCtrl.TxMode, |
| 2061 | pDevice->TxMode); |
| 2062 | } |
| 2063 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2064 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2065 | case T3_BLOCK_MEM_ARBITOR: |
| 2066 | data = REG_RD (pDevice, MemArbiter.Mode); |
| 2067 | if (cntrl == LM_DISABLE) { |
| 2068 | data &= ~T3_MEM_ARBITER_MODE_ENABLE; |
| 2069 | REG_WR (pDevice, MemArbiter.Mode, data); |
| 2070 | for (j = 0; j < MaxWaitCnt; j++) { |
| 2071 | if (! |
| 2072 | (REG_RD (pDevice, MemArbiter.Mode) & |
| 2073 | T3_MEM_ARBITER_MODE_ENABLE)) |
| 2074 | break; |
| 2075 | MM_Wait (10); |
| 2076 | } |
| 2077 | } else |
| 2078 | REG_WR (pDevice, MemArbiter.Mode, |
| 2079 | data | T3_MEM_ARBITER_MODE_ENABLE); |
| 2080 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2081 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2082 | case T3_BLOCK_MBUF_MANAGER: |
| 2083 | data = REG_RD (pDevice, BufMgr.Mode); |
| 2084 | if (cntrl == LM_DISABLE) { |
| 2085 | data &= ~BUFMGR_MODE_ENABLE; |
| 2086 | REG_WR (pDevice, BufMgr.Mode, data); |
| 2087 | for (j = 0; j < MaxWaitCnt; j++) { |
| 2088 | if (! |
| 2089 | (REG_RD (pDevice, BufMgr.Mode) & |
| 2090 | BUFMGR_MODE_ENABLE)) |
| 2091 | break; |
| 2092 | MM_Wait (10); |
| 2093 | } |
| 2094 | } else |
| 2095 | REG_WR (pDevice, BufMgr.Mode, |
| 2096 | data | BUFMGR_MODE_ENABLE); |
| 2097 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2098 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2099 | case T3_BLOCK_MAC_GLOBAL: |
| 2100 | if (cntrl == LM_DISABLE) { |
| 2101 | pDevice->MacMode &= ~(MAC_MODE_ENABLE_TDE | |
| 2102 | MAC_MODE_ENABLE_RDE | |
| 2103 | MAC_MODE_ENABLE_FHDE); |
| 2104 | } else { |
| 2105 | pDevice->MacMode |= (MAC_MODE_ENABLE_TDE | |
| 2106 | MAC_MODE_ENABLE_RDE | |
| 2107 | MAC_MODE_ENABLE_FHDE); |
| 2108 | } |
| 2109 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode); |
| 2110 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2111 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2112 | default: |
| 2113 | return LM_STATUS_FAILURE; |
| 2114 | } /* switch */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2115 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2116 | if (j >= MaxWaitCnt) { |
| 2117 | return LM_STATUS_FAILURE; |
| 2118 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2119 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2120 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2121 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2122 | } |
| 2123 | |
| 2124 | /******************************************************************************/ |
| 2125 | /* Description: */ |
| 2126 | /* This function reinitializes the adapter. */ |
| 2127 | /* */ |
| 2128 | /* Return: */ |
| 2129 | /* LM_STATUS_SUCCESS */ |
| 2130 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2131 | LM_STATUS LM_ResetAdapter (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2132 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2133 | LM_UINT32 Value32; |
| 2134 | LM_UINT16 Value16; |
| 2135 | LM_UINT32 j, k; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2136 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2137 | /* Disable interrupt. */ |
| 2138 | LM_DisableInterrupt (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2139 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2140 | /* May get a spurious interrupt */ |
| 2141 | pDevice->pStatusBlkVirt->Status = STATUS_BLOCK_UPDATED; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2142 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2143 | /* Disable transmit and receive DMA engines. Abort all pending requests. */ |
| 2144 | if (pDevice->InitDone) { |
| 2145 | LM_Abort (pDevice); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2146 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2147 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2148 | pDevice->ShuttingDown = FALSE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2149 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2150 | LM_ResetChip (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2151 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2152 | /* Bug: Athlon fix for B3 silicon only. This bit does not do anything */ |
| 2153 | /* in other chip revisions. */ |
| 2154 | if (pDevice->DelayPciGrant) { |
| 2155 | Value32 = REG_RD (pDevice, PciCfg.ClockCtrl); |
| 2156 | REG_WR (pDevice, PciCfg.ClockCtrl, Value32 | BIT_31); |
| 2157 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2158 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2159 | if (pDevice->ChipRevId == T3_CHIP_ID_5704_A0) { |
| 2160 | if (!(pDevice->PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE)) { |
| 2161 | Value32 = REG_RD (pDevice, PciCfg.PciState); |
| 2162 | Value32 |= T3_PCI_STATE_RETRY_SAME_DMA; |
| 2163 | REG_WR (pDevice, PciCfg.PciState, Value32); |
| 2164 | } |
| 2165 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2166 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2167 | /* Enable TaggedStatus mode. */ |
| 2168 | if (pDevice->UseTaggedStatus) { |
| 2169 | pDevice->MiscHostCtrl |= |
| 2170 | MISC_HOST_CTRL_ENABLE_TAGGED_STATUS_MODE; |
| 2171 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2172 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2173 | /* Restore PCI configuration registers. */ |
| 2174 | MM_WriteConfig32 (pDevice, PCI_CACHE_LINE_SIZE_REG, |
| 2175 | pDevice->SavedCacheLineReg); |
| 2176 | MM_WriteConfig32 (pDevice, PCI_SUBSYSTEM_VENDOR_ID_REG, |
| 2177 | (pDevice->SubsystemId << 16) | pDevice-> |
| 2178 | SubsystemVendorId); |
| 2179 | |
| 2180 | /* Clear the statistics block. */ |
| 2181 | for (j = 0x0300; j < 0x0b00; j++) { |
| 2182 | MEM_WR_OFFSET (pDevice, j, 0); |
| 2183 | } |
| 2184 | |
| 2185 | /* Initialize the statistis Block */ |
| 2186 | pDevice->pStatusBlkVirt->Status = 0; |
| 2187 | pDevice->pStatusBlkVirt->RcvStdConIdx = 0; |
| 2188 | pDevice->pStatusBlkVirt->RcvJumboConIdx = 0; |
| 2189 | pDevice->pStatusBlkVirt->RcvMiniConIdx = 0; |
| 2190 | |
| 2191 | for (j = 0; j < 16; j++) { |
| 2192 | pDevice->pStatusBlkVirt->Idx[j].RcvProdIdx = 0; |
| 2193 | pDevice->pStatusBlkVirt->Idx[j].SendConIdx = 0; |
| 2194 | } |
| 2195 | |
| 2196 | for (k = 0; k < T3_STD_RCV_RCB_ENTRY_COUNT; k++) { |
| 2197 | pDevice->pRxStdBdVirt[k].HostAddr.High = 0; |
| 2198 | pDevice->pRxStdBdVirt[k].HostAddr.Low = 0; |
| 2199 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2200 | |
| 2201 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2202 | /* Receive jumbo BD buffer. */ |
| 2203 | for (k = 0; k < T3_JUMBO_RCV_RCB_ENTRY_COUNT; k++) { |
| 2204 | pDevice->pRxJumboBdVirt[k].HostAddr.High = 0; |
| 2205 | pDevice->pRxJumboBdVirt[k].HostAddr.Low = 0; |
| 2206 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2207 | #endif |
| 2208 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2209 | REG_WR (pDevice, PciCfg.DmaReadWriteCtrl, pDevice->DmaReadWriteCtrl); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2210 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2211 | /* GRC mode control register. */ |
| 2212 | #ifdef BIG_ENDIAN_PCI /* Jimmy, this ifdef block deleted in new code! */ |
| 2213 | Value32 = |
| 2214 | GRC_MODE_WORD_SWAP_DATA | |
| 2215 | GRC_MODE_WORD_SWAP_NON_FRAME_DATA | |
| 2216 | GRC_MODE_INT_ON_MAC_ATTN | GRC_MODE_HOST_STACK_UP; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2217 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2218 | /* No CPU Swap modes for PCI IO */ |
| 2219 | Value32 = |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2220 | #ifdef BIG_ENDIAN_HOST |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2221 | GRC_MODE_BYTE_SWAP_NON_FRAME_DATA | |
| 2222 | GRC_MODE_WORD_SWAP_NON_FRAME_DATA | |
| 2223 | GRC_MODE_BYTE_SWAP_DATA | GRC_MODE_WORD_SWAP_DATA | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2224 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2225 | GRC_MODE_WORD_SWAP_NON_FRAME_DATA | |
| 2226 | GRC_MODE_BYTE_SWAP_DATA | GRC_MODE_WORD_SWAP_DATA | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2227 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2228 | GRC_MODE_INT_ON_MAC_ATTN | GRC_MODE_HOST_STACK_UP; |
| 2229 | #endif /* !BIG_ENDIAN_PCI */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2230 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2231 | /* Configure send BD mode. */ |
| 2232 | if (pDevice->NicSendBd == FALSE) { |
| 2233 | Value32 |= GRC_MODE_HOST_SEND_BDS; |
| 2234 | } else { |
| 2235 | Value32 |= GRC_MODE_4X_NIC_BASED_SEND_RINGS; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2236 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2237 | |
| 2238 | /* Configure pseudo checksum mode. */ |
| 2239 | if (pDevice->NoTxPseudoHdrChksum) { |
| 2240 | Value32 |= GRC_MODE_TX_NO_PSEUDO_HEADER_CHKSUM; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2241 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2242 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2243 | if (pDevice->NoRxPseudoHdrChksum) { |
| 2244 | Value32 |= GRC_MODE_RX_NO_PSEUDO_HEADER_CHKSUM; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2245 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2246 | |
| 2247 | REG_WR (pDevice, Grc.Mode, Value32); |
| 2248 | |
| 2249 | /* Setup the timer prescalar register. */ |
Wolfgang Denk | 8ed44d9 | 2008-10-19 02:35:50 +0200 | [diff] [blame] | 2250 | REG_WR (pDevice, Grc.MiscCfg, 65 << 1); /* Clock is alwasy 66MHz. */ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2251 | |
| 2252 | /* Set up the MBUF pool base address and size. */ |
| 2253 | REG_WR (pDevice, BufMgr.MbufPoolAddr, pDevice->MbufBase); |
| 2254 | REG_WR (pDevice, BufMgr.MbufPoolSize, pDevice->MbufSize); |
| 2255 | |
| 2256 | /* Set up the DMA descriptor pool base address and size. */ |
| 2257 | REG_WR (pDevice, BufMgr.DmaDescPoolAddr, T3_NIC_DMA_DESC_POOL_ADDR); |
| 2258 | REG_WR (pDevice, BufMgr.DmaDescPoolSize, T3_NIC_DMA_DESC_POOL_SIZE); |
| 2259 | |
| 2260 | /* Configure MBUF and Threshold watermarks */ |
| 2261 | /* Configure the DMA read MBUF low water mark. */ |
| 2262 | if (pDevice->DmaMbufLowMark) { |
| 2263 | REG_WR (pDevice, BufMgr.MbufReadDmaLowWaterMark, |
| 2264 | pDevice->DmaMbufLowMark); |
| 2265 | } else { |
| 2266 | if (pDevice->TxMtu < MAX_ETHERNET_PACKET_BUFFER_SIZE) { |
| 2267 | REG_WR (pDevice, BufMgr.MbufReadDmaLowWaterMark, |
| 2268 | T3_DEF_DMA_MBUF_LOW_WMARK); |
| 2269 | } else { |
| 2270 | REG_WR (pDevice, BufMgr.MbufReadDmaLowWaterMark, |
| 2271 | T3_DEF_DMA_MBUF_LOW_WMARK_JUMBO); |
| 2272 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2273 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2274 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2275 | /* Configure the MAC Rx MBUF low water mark. */ |
| 2276 | if (pDevice->RxMacMbufLowMark) { |
| 2277 | REG_WR (pDevice, BufMgr.MbufMacRxLowWaterMark, |
| 2278 | pDevice->RxMacMbufLowMark); |
| 2279 | } else { |
| 2280 | if (pDevice->TxMtu < MAX_ETHERNET_PACKET_BUFFER_SIZE) { |
| 2281 | REG_WR (pDevice, BufMgr.MbufMacRxLowWaterMark, |
| 2282 | T3_DEF_RX_MAC_MBUF_LOW_WMARK); |
| 2283 | } else { |
| 2284 | REG_WR (pDevice, BufMgr.MbufMacRxLowWaterMark, |
| 2285 | T3_DEF_RX_MAC_MBUF_LOW_WMARK_JUMBO); |
| 2286 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2287 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2288 | |
| 2289 | /* Configure the MBUF high water mark. */ |
| 2290 | if (pDevice->MbufHighMark) { |
| 2291 | REG_WR (pDevice, BufMgr.MbufHighWaterMark, |
| 2292 | pDevice->MbufHighMark); |
| 2293 | } else { |
| 2294 | if (pDevice->TxMtu < MAX_ETHERNET_PACKET_BUFFER_SIZE) { |
| 2295 | REG_WR (pDevice, BufMgr.MbufHighWaterMark, |
| 2296 | T3_DEF_MBUF_HIGH_WMARK); |
| 2297 | } else { |
| 2298 | REG_WR (pDevice, BufMgr.MbufHighWaterMark, |
| 2299 | T3_DEF_MBUF_HIGH_WMARK_JUMBO); |
| 2300 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2301 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2302 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2303 | REG_WR (pDevice, BufMgr.DmaLowWaterMark, T3_DEF_DMA_DESC_LOW_WMARK); |
| 2304 | REG_WR (pDevice, BufMgr.DmaHighWaterMark, T3_DEF_DMA_DESC_HIGH_WMARK); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2305 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2306 | /* Enable buffer manager. */ |
| 2307 | REG_WR (pDevice, BufMgr.Mode, |
| 2308 | BUFMGR_MODE_ENABLE | BUFMGR_MODE_ATTN_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2309 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2310 | for (j = 0; j < 2000; j++) { |
| 2311 | if (REG_RD (pDevice, BufMgr.Mode) & BUFMGR_MODE_ENABLE) |
| 2312 | break; |
| 2313 | MM_Wait (10); |
| 2314 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2315 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2316 | if (j >= 2000) { |
| 2317 | return LM_STATUS_FAILURE; |
| 2318 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2319 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2320 | /* Enable the FTQs. */ |
| 2321 | REG_WR (pDevice, Ftq.Reset, 0xffffffff); |
| 2322 | REG_WR (pDevice, Ftq.Reset, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2323 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2324 | /* Wait until FTQ is ready */ |
| 2325 | for (j = 0; j < 2000; j++) { |
| 2326 | if (REG_RD (pDevice, Ftq.Reset) == 0) |
| 2327 | break; |
| 2328 | MM_Wait (10); |
| 2329 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2330 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2331 | if (j >= 2000) { |
| 2332 | return LM_STATUS_FAILURE; |
| 2333 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2334 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2335 | /* Initialize the Standard Receive RCB. */ |
| 2336 | REG_WR (pDevice, RcvDataBdIn.StdRcvRcb.HostRingAddr.High, |
| 2337 | pDevice->RxStdBdPhy.High); |
| 2338 | REG_WR (pDevice, RcvDataBdIn.StdRcvRcb.HostRingAddr.Low, |
| 2339 | pDevice->RxStdBdPhy.Low); |
| 2340 | REG_WR (pDevice, RcvDataBdIn.StdRcvRcb.u.MaxLen_Flags, |
| 2341 | MAX_STD_RCV_BUFFER_SIZE << 16); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2342 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2343 | /* Initialize the Jumbo Receive RCB. */ |
| 2344 | REG_WR (pDevice, RcvDataBdIn.JumboRcvRcb.u.MaxLen_Flags, |
| 2345 | T3_RCB_FLAG_RING_DISABLED); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2346 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2347 | REG_WR (pDevice, RcvDataBdIn.JumboRcvRcb.HostRingAddr.High, |
| 2348 | pDevice->RxJumboBdPhy.High); |
| 2349 | REG_WR (pDevice, RcvDataBdIn.JumboRcvRcb.HostRingAddr.Low, |
| 2350 | pDevice->RxJumboBdPhy.Low); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2351 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2352 | REG_WR (pDevice, RcvDataBdIn.JumboRcvRcb.u.MaxLen_Flags, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2353 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2354 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2355 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2356 | /* Initialize the Mini Receive RCB. */ |
| 2357 | REG_WR (pDevice, RcvDataBdIn.MiniRcvRcb.u.MaxLen_Flags, |
| 2358 | T3_RCB_FLAG_RING_DISABLED); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2359 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2360 | { |
| 2361 | REG_WR (pDevice, RcvDataBdIn.StdRcvRcb.NicRingAddr, |
| 2362 | (LM_UINT32) T3_NIC_STD_RCV_BUFFER_DESC_ADDR); |
| 2363 | REG_WR (pDevice, RcvDataBdIn.JumboRcvRcb.NicRingAddr, |
| 2364 | (LM_UINT32) T3_NIC_JUMBO_RCV_BUFFER_DESC_ADDR); |
| 2365 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2366 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2367 | /* Receive BD Ring replenish threshold. */ |
| 2368 | REG_WR (pDevice, RcvBdIn.StdRcvThreshold, pDevice->RxStdDescCnt / 8); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2369 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2370 | REG_WR (pDevice, RcvBdIn.JumboRcvThreshold, |
| 2371 | pDevice->RxJumboDescCnt / 8); |
| 2372 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2373 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2374 | /* Disable all the unused rings. */ |
| 2375 | for (j = 0; j < T3_MAX_SEND_RCB_COUNT; j++) { |
| 2376 | MEM_WR (pDevice, SendRcb[j].u.MaxLen_Flags, |
| 2377 | T3_RCB_FLAG_RING_DISABLED); |
| 2378 | } /* for */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2379 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2380 | /* Initialize the indices. */ |
| 2381 | pDevice->SendProdIdx = 0; |
| 2382 | pDevice->SendConIdx = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2383 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2384 | MB_REG_WR (pDevice, Mailbox.SendHostProdIdx[0].Low, 0); |
| 2385 | MB_REG_WR (pDevice, Mailbox.SendNicProdIdx[0].Low, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2386 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2387 | /* Set up host or NIC based send RCB. */ |
| 2388 | if (pDevice->NicSendBd == FALSE) { |
| 2389 | MEM_WR (pDevice, SendRcb[0].HostRingAddr.High, |
| 2390 | pDevice->SendBdPhy.High); |
| 2391 | MEM_WR (pDevice, SendRcb[0].HostRingAddr.Low, |
| 2392 | pDevice->SendBdPhy.Low); |
| 2393 | |
| 2394 | /* Set up the NIC ring address in the RCB. */ |
| 2395 | MEM_WR (pDevice, SendRcb[0].NicRingAddr, |
| 2396 | T3_NIC_SND_BUFFER_DESC_ADDR); |
| 2397 | |
| 2398 | /* Setup the RCB. */ |
| 2399 | MEM_WR (pDevice, SendRcb[0].u.MaxLen_Flags, |
| 2400 | T3_SEND_RCB_ENTRY_COUNT << 16); |
| 2401 | |
| 2402 | for (k = 0; k < T3_SEND_RCB_ENTRY_COUNT; k++) { |
| 2403 | pDevice->pSendBdVirt[k].HostAddr.High = 0; |
| 2404 | pDevice->pSendBdVirt[k].HostAddr.Low = 0; |
| 2405 | } |
| 2406 | } else { |
| 2407 | MEM_WR (pDevice, SendRcb[0].HostRingAddr.High, 0); |
| 2408 | MEM_WR (pDevice, SendRcb[0].HostRingAddr.Low, 0); |
| 2409 | MEM_WR (pDevice, SendRcb[0].NicRingAddr, |
| 2410 | pDevice->SendBdPhy.Low); |
| 2411 | |
| 2412 | for (k = 0; k < T3_SEND_RCB_ENTRY_COUNT; k++) { |
| 2413 | __raw_writel (0, |
| 2414 | &(pDevice->pSendBdVirt[k].HostAddr.High)); |
| 2415 | __raw_writel (0, |
| 2416 | &(pDevice->pSendBdVirt[k].HostAddr.Low)); |
| 2417 | __raw_writel (0, |
| 2418 | &(pDevice->pSendBdVirt[k].u1.Len_Flags)); |
| 2419 | pDevice->ShadowSendBd[k].HostAddr.High = 0; |
| 2420 | pDevice->ShadowSendBd[k].u1.Len_Flags = 0; |
| 2421 | } |
| 2422 | } |
| 2423 | atomic_set (&pDevice->SendBdLeft, T3_SEND_RCB_ENTRY_COUNT - 1); |
| 2424 | |
| 2425 | /* Configure the receive return rings. */ |
| 2426 | for (j = 0; j < T3_MAX_RCV_RETURN_RCB_COUNT; j++) { |
| 2427 | MEM_WR (pDevice, RcvRetRcb[j].u.MaxLen_Flags, |
| 2428 | T3_RCB_FLAG_RING_DISABLED); |
| 2429 | } |
| 2430 | |
| 2431 | pDevice->RcvRetConIdx = 0; |
| 2432 | |
| 2433 | MEM_WR (pDevice, RcvRetRcb[0].HostRingAddr.High, |
| 2434 | pDevice->RcvRetBdPhy.High); |
| 2435 | MEM_WR (pDevice, RcvRetRcb[0].HostRingAddr.Low, |
| 2436 | pDevice->RcvRetBdPhy.Low); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2437 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2438 | /* Set up the NIC ring address in the RCB. */ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2439 | /* Not very clear from the spec. I am guessing that for Receive */ |
| 2440 | /* Return Ring, NicRingAddr is not used. */ |
| 2441 | MEM_WR (pDevice, RcvRetRcb[0].NicRingAddr, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2442 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2443 | /* Setup the RCB. */ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2444 | MEM_WR (pDevice, RcvRetRcb[0].u.MaxLen_Flags, |
| 2445 | T3_RCV_RETURN_RCB_ENTRY_COUNT << 16); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2446 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2447 | /* Reinitialize RX ring producer index */ |
| 2448 | MB_REG_WR (pDevice, Mailbox.RcvStdProdIdx.Low, 0); |
| 2449 | MB_REG_WR (pDevice, Mailbox.RcvJumboProdIdx.Low, 0); |
| 2450 | MB_REG_WR (pDevice, Mailbox.RcvMiniProdIdx.Low, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2451 | |
| 2452 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2453 | pDevice->RxJumboProdIdx = 0; |
| 2454 | pDevice->RxJumboQueuedCnt = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2455 | #endif |
| 2456 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2457 | /* Reinitialize our copy of the indices. */ |
| 2458 | pDevice->RxStdProdIdx = 0; |
| 2459 | pDevice->RxStdQueuedCnt = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2460 | |
| 2461 | #if T3_JUMBO_RCV_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2462 | pDevice->RxJumboProdIdx = 0; |
| 2463 | #endif /* T3_JUMBO_RCV_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2464 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2465 | /* Configure the MAC address. */ |
| 2466 | LM_SetMacAddress (pDevice, pDevice->NodeAddress); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2467 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2468 | /* Initialize the transmit random backoff seed. */ |
| 2469 | Value32 = (pDevice->NodeAddress[0] + pDevice->NodeAddress[1] + |
| 2470 | pDevice->NodeAddress[2] + pDevice->NodeAddress[3] + |
| 2471 | pDevice->NodeAddress[4] + pDevice->NodeAddress[5]) & |
| 2472 | MAC_TX_BACKOFF_SEED_MASK; |
| 2473 | REG_WR (pDevice, MacCtrl.TxBackoffSeed, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2474 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2475 | /* Receive MTU. Frames larger than the MTU is marked as oversized. */ |
| 2476 | REG_WR (pDevice, MacCtrl.MtuSize, pDevice->RxMtu + 8); /* CRC + VLAN. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2477 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2478 | /* Configure Time slot/IPG per 802.3 */ |
| 2479 | REG_WR (pDevice, MacCtrl.TxLengths, 0x2620); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2480 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2481 | /* |
| 2482 | * Configure Receive Rules so that packets don't match |
| 2483 | * Programmble rule will be queued to Return Ring 1 |
| 2484 | */ |
| 2485 | REG_WR (pDevice, MacCtrl.RcvRuleCfg, RX_RULE_DEFAULT_CLASS); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2486 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2487 | /* |
| 2488 | * Configure to have 16 Classes of Services (COS) and one |
| 2489 | * queue per class. Bad frames are queued to RRR#1. |
| 2490 | * And frames don't match rules are also queued to COS#1. |
| 2491 | */ |
| 2492 | REG_WR (pDevice, RcvListPlmt.Config, 0x181); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2493 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2494 | /* Enable Receive Placement Statistics */ |
| 2495 | REG_WR (pDevice, RcvListPlmt.StatsEnableMask, 0xffffff); |
| 2496 | REG_WR (pDevice, RcvListPlmt.StatsCtrl, RCV_LIST_STATS_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2497 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2498 | /* Enable Send Data Initator Statistics */ |
| 2499 | REG_WR (pDevice, SndDataIn.StatsEnableMask, 0xffffff); |
| 2500 | REG_WR (pDevice, SndDataIn.StatsCtrl, |
| 2501 | T3_SND_DATA_IN_STATS_CTRL_ENABLE | |
| 2502 | T3_SND_DATA_IN_STATS_CTRL_FASTER_UPDATE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2503 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2504 | /* Disable the host coalescing state machine before configuring it's */ |
| 2505 | /* parameters. */ |
| 2506 | REG_WR (pDevice, HostCoalesce.Mode, 0); |
| 2507 | for (j = 0; j < 2000; j++) { |
| 2508 | Value32 = REG_RD (pDevice, HostCoalesce.Mode); |
| 2509 | if (!(Value32 & HOST_COALESCE_ENABLE)) { |
| 2510 | break; |
| 2511 | } |
| 2512 | MM_Wait (10); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2513 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2514 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2515 | /* Host coalescing configurations. */ |
| 2516 | REG_WR (pDevice, HostCoalesce.RxCoalescingTicks, |
| 2517 | pDevice->RxCoalescingTicks); |
| 2518 | REG_WR (pDevice, HostCoalesce.TxCoalescingTicks, |
| 2519 | pDevice->TxCoalescingTicks); |
| 2520 | REG_WR (pDevice, HostCoalesce.RxMaxCoalescedFrames, |
| 2521 | pDevice->RxMaxCoalescedFrames); |
| 2522 | REG_WR (pDevice, HostCoalesce.TxMaxCoalescedFrames, |
| 2523 | pDevice->TxMaxCoalescedFrames); |
| 2524 | REG_WR (pDevice, HostCoalesce.RxCoalescedTickDuringInt, |
| 2525 | pDevice->RxCoalescingTicksDuringInt); |
| 2526 | REG_WR (pDevice, HostCoalesce.TxCoalescedTickDuringInt, |
| 2527 | pDevice->TxCoalescingTicksDuringInt); |
| 2528 | REG_WR (pDevice, HostCoalesce.RxMaxCoalescedFramesDuringInt, |
| 2529 | pDevice->RxMaxCoalescedFramesDuringInt); |
| 2530 | REG_WR (pDevice, HostCoalesce.TxMaxCoalescedFramesDuringInt, |
| 2531 | pDevice->TxMaxCoalescedFramesDuringInt); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2532 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2533 | /* Initialize the address of the status block. The NIC will DMA */ |
| 2534 | /* the status block to this memory which resides on the host. */ |
| 2535 | REG_WR (pDevice, HostCoalesce.StatusBlkHostAddr.High, |
| 2536 | pDevice->StatusBlkPhy.High); |
| 2537 | REG_WR (pDevice, HostCoalesce.StatusBlkHostAddr.Low, |
| 2538 | pDevice->StatusBlkPhy.Low); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2539 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2540 | /* Initialize the address of the statistics block. The NIC will DMA */ |
| 2541 | /* the statistics to this block of memory. */ |
| 2542 | REG_WR (pDevice, HostCoalesce.StatsBlkHostAddr.High, |
| 2543 | pDevice->StatsBlkPhy.High); |
| 2544 | REG_WR (pDevice, HostCoalesce.StatsBlkHostAddr.Low, |
| 2545 | pDevice->StatsBlkPhy.Low); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2546 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2547 | REG_WR (pDevice, HostCoalesce.StatsCoalescingTicks, |
| 2548 | pDevice->StatsCoalescingTicks); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2549 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2550 | REG_WR (pDevice, HostCoalesce.StatsBlkNicAddr, 0x300); |
| 2551 | REG_WR (pDevice, HostCoalesce.StatusBlkNicAddr, 0xb00); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2552 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2553 | /* Enable Host Coalesing state machine */ |
| 2554 | REG_WR (pDevice, HostCoalesce.Mode, HOST_COALESCE_ENABLE | |
| 2555 | pDevice->CoalesceMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2556 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2557 | /* Enable the Receive BD Completion state machine. */ |
| 2558 | REG_WR (pDevice, RcvBdComp.Mode, RCV_BD_COMP_MODE_ENABLE | |
| 2559 | RCV_BD_COMP_MODE_ATTN_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2560 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2561 | /* Enable the Receive List Placement state machine. */ |
| 2562 | REG_WR (pDevice, RcvListPlmt.Mode, RCV_LIST_PLMT_MODE_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2563 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2564 | /* Enable the Receive List Selector state machine. */ |
| 2565 | REG_WR (pDevice, RcvListSel.Mode, RCV_LIST_SEL_MODE_ENABLE | |
| 2566 | RCV_LIST_SEL_MODE_ATTN_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2567 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2568 | /* Enable transmit DMA, clear statistics. */ |
| 2569 | pDevice->MacMode = MAC_MODE_ENABLE_TX_STATISTICS | |
| 2570 | MAC_MODE_ENABLE_RX_STATISTICS | MAC_MODE_ENABLE_TDE | |
| 2571 | MAC_MODE_ENABLE_RDE | MAC_MODE_ENABLE_FHDE; |
| 2572 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode | |
| 2573 | MAC_MODE_CLEAR_RX_STATISTICS | MAC_MODE_CLEAR_TX_STATISTICS); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2574 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2575 | /* GRC miscellaneous local control register. */ |
| 2576 | pDevice->GrcLocalCtrl = GRC_MISC_LOCAL_CTRL_INT_ON_ATTN | |
| 2577 | GRC_MISC_LOCAL_CTRL_AUTO_SEEPROM; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2578 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2579 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 2580 | pDevice->GrcLocalCtrl |= GRC_MISC_LOCAL_CTRL_GPIO_OE1 | |
| 2581 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT1; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2582 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2583 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2584 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl); |
| 2585 | MM_Wait (40); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2586 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2587 | /* Reset RX counters. */ |
| 2588 | for (j = 0; j < sizeof (LM_RX_COUNTERS); j++) { |
| 2589 | ((PLM_UINT8) & pDevice->RxCounters)[j] = 0; |
| 2590 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2591 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2592 | /* Reset TX counters. */ |
| 2593 | for (j = 0; j < sizeof (LM_TX_COUNTERS); j++) { |
| 2594 | ((PLM_UINT8) & pDevice->TxCounters)[j] = 0; |
| 2595 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2596 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2597 | MB_REG_WR (pDevice, Mailbox.Interrupt[0].Low, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2598 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2599 | /* Enable the DMA Completion state machine. */ |
| 2600 | REG_WR (pDevice, DmaComp.Mode, DMA_COMP_MODE_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2601 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2602 | /* Enable the DMA Write state machine. */ |
| 2603 | Value32 = DMA_WRITE_MODE_ENABLE | |
| 2604 | DMA_WRITE_MODE_TARGET_ABORT_ATTN_ENABLE | |
| 2605 | DMA_WRITE_MODE_MASTER_ABORT_ATTN_ENABLE | |
| 2606 | DMA_WRITE_MODE_PARITY_ERROR_ATTN_ENABLE | |
| 2607 | DMA_WRITE_MODE_ADDR_OVERFLOW_ATTN_ENABLE | |
| 2608 | DMA_WRITE_MODE_FIFO_OVERRUN_ATTN_ENABLE | |
| 2609 | DMA_WRITE_MODE_FIFO_UNDERRUN_ATTN_ENABLE | |
| 2610 | DMA_WRITE_MODE_FIFO_OVERREAD_ATTN_ENABLE | |
| 2611 | DMA_WRITE_MODE_LONG_READ_ATTN_ENABLE; |
| 2612 | REG_WR (pDevice, DmaWrite.Mode, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2613 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2614 | if (!(pDevice->PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE)) { |
| 2615 | if (pDevice->ChipRevId == T3_CHIP_ID_5704_A0) { |
| 2616 | Value16 = REG_RD (pDevice, PciCfg.PciXCommand); |
| 2617 | Value16 &= |
| 2618 | ~(PCIX_CMD_MAX_SPLIT_MASK | |
| 2619 | PCIX_CMD_MAX_BURST_MASK); |
| 2620 | Value16 |= |
| 2621 | ((PCIX_CMD_MAX_BURST_CPIOB << |
| 2622 | PCIX_CMD_MAX_BURST_SHL) & |
| 2623 | PCIX_CMD_MAX_BURST_MASK); |
| 2624 | if (pDevice->SplitModeEnable == SPLIT_MODE_ENABLE) { |
| 2625 | Value16 |= |
| 2626 | (pDevice-> |
| 2627 | SplitModeMaxReq << PCIX_CMD_MAX_SPLIT_SHL) |
| 2628 | & PCIX_CMD_MAX_SPLIT_MASK; |
| 2629 | } |
| 2630 | REG_WR (pDevice, PciCfg.PciXCommand, Value16); |
| 2631 | } |
| 2632 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2633 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2634 | /* Enable the Read DMA state machine. */ |
| 2635 | Value32 = DMA_READ_MODE_ENABLE | |
| 2636 | DMA_READ_MODE_TARGET_ABORT_ATTN_ENABLE | |
| 2637 | DMA_READ_MODE_MASTER_ABORT_ATTN_ENABLE | |
| 2638 | DMA_READ_MODE_PARITY_ERROR_ATTN_ENABLE | |
| 2639 | DMA_READ_MODE_ADDR_OVERFLOW_ATTN_ENABLE | |
| 2640 | DMA_READ_MODE_FIFO_OVERRUN_ATTN_ENABLE | |
| 2641 | DMA_READ_MODE_FIFO_UNDERRUN_ATTN_ENABLE | |
| 2642 | DMA_READ_MODE_FIFO_OVERREAD_ATTN_ENABLE | |
| 2643 | DMA_READ_MODE_LONG_READ_ATTN_ENABLE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2644 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2645 | if (pDevice->SplitModeEnable == SPLIT_MODE_ENABLE) { |
| 2646 | Value32 |= DMA_READ_MODE_SPLIT_ENABLE; |
| 2647 | } |
| 2648 | REG_WR (pDevice, DmaRead.Mode, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2649 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2650 | /* Enable the Receive Data Completion state machine. */ |
| 2651 | REG_WR (pDevice, RcvDataComp.Mode, RCV_DATA_COMP_MODE_ENABLE | |
| 2652 | RCV_DATA_COMP_MODE_ATTN_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2653 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2654 | /* Enable the Mbuf Cluster Free state machine. */ |
| 2655 | REG_WR (pDevice, MbufClusterFree.Mode, MBUF_CLUSTER_FREE_MODE_ENABLE); |
| 2656 | |
| 2657 | /* Enable the Send Data Completion state machine. */ |
| 2658 | REG_WR (pDevice, SndDataComp.Mode, SND_DATA_COMP_MODE_ENABLE); |
| 2659 | |
| 2660 | /* Enable the Send BD Completion state machine. */ |
| 2661 | REG_WR (pDevice, SndBdComp.Mode, SND_BD_COMP_MODE_ENABLE | |
| 2662 | SND_BD_COMP_MODE_ATTN_ENABLE); |
| 2663 | |
| 2664 | /* Enable the Receive BD Initiator state machine. */ |
| 2665 | REG_WR (pDevice, RcvBdIn.Mode, RCV_BD_IN_MODE_ENABLE | |
| 2666 | RCV_BD_IN_MODE_BD_IN_DIABLED_RCB_ATTN_ENABLE); |
| 2667 | |
| 2668 | /* Enable the Receive Data and Receive BD Initiator state machine. */ |
| 2669 | REG_WR (pDevice, RcvDataBdIn.Mode, RCV_DATA_BD_IN_MODE_ENABLE | |
| 2670 | RCV_DATA_BD_IN_MODE_INVALID_RING_SIZE); |
| 2671 | |
| 2672 | /* Enable the Send Data Initiator state machine. */ |
| 2673 | REG_WR (pDevice, SndDataIn.Mode, T3_SND_DATA_IN_MODE_ENABLE); |
| 2674 | |
| 2675 | /* Enable the Send BD Initiator state machine. */ |
| 2676 | REG_WR (pDevice, SndBdIn.Mode, SND_BD_IN_MODE_ENABLE | |
| 2677 | SND_BD_IN_MODE_ATTN_ENABLE); |
| 2678 | |
| 2679 | /* Enable the Send BD Selector state machine. */ |
| 2680 | REG_WR (pDevice, SndBdSel.Mode, SND_BD_SEL_MODE_ENABLE | |
| 2681 | SND_BD_SEL_MODE_ATTN_ENABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2682 | |
| 2683 | #if INCLUDE_5701_AX_FIX |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2684 | /* Load the firmware for the 5701_A0 workaround. */ |
| 2685 | if (pDevice->ChipRevId == T3_CHIP_ID_5701_A0) { |
| 2686 | LM_LoadRlsFirmware (pDevice); |
| 2687 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2688 | #endif |
| 2689 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2690 | /* Enable the transmitter. */ |
| 2691 | pDevice->TxMode = TX_MODE_ENABLE; |
| 2692 | REG_WR (pDevice, MacCtrl.TxMode, pDevice->TxMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2693 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2694 | /* Enable the receiver. */ |
| 2695 | pDevice->RxMode = RX_MODE_ENABLE; |
| 2696 | REG_WR (pDevice, MacCtrl.RxMode, pDevice->RxMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2697 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2698 | if (pDevice->RestoreOnWakeUp) { |
| 2699 | pDevice->RestoreOnWakeUp = FALSE; |
| 2700 | pDevice->DisableAutoNeg = pDevice->WakeUpDisableAutoNeg; |
| 2701 | pDevice->RequestedMediaType = pDevice->WakeUpRequestedMediaType; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2702 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2703 | |
| 2704 | /* Disable auto polling. */ |
| 2705 | pDevice->MiMode = 0xc0000; |
| 2706 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode); |
| 2707 | |
| 2708 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 2709 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 2710 | Value32 = LED_CTRL_PHY_MODE_1; |
| 2711 | } else { |
| 2712 | if (pDevice->LedMode == LED_MODE_OUTPUT) { |
| 2713 | Value32 = LED_CTRL_PHY_MODE_2; |
| 2714 | } else { |
| 2715 | Value32 = LED_CTRL_PHY_MODE_1; |
| 2716 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2717 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2718 | REG_WR (pDevice, MacCtrl.LedCtrl, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2719 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2720 | /* Activate Link to enable MAC state machine */ |
| 2721 | REG_WR (pDevice, MacCtrl.MiStatus, MI_STATUS_ENABLE_LINK_STATUS_ATTN); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2722 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2723 | if (pDevice->EnableTbi) { |
| 2724 | REG_WR (pDevice, MacCtrl.RxMode, RX_MODE_RESET); |
| 2725 | MM_Wait (10); |
| 2726 | REG_WR (pDevice, MacCtrl.RxMode, pDevice->RxMode); |
| 2727 | if (pDevice->ChipRevId == T3_CHIP_ID_5703_A1) { |
| 2728 | REG_WR (pDevice, MacCtrl.SerdesCfg, 0x616000); |
| 2729 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2730 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2731 | /* Setup the phy chip. */ |
| 2732 | LM_SetupPhy (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2733 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2734 | if (!pDevice->EnableTbi) { |
| 2735 | /* Clear CRC stats */ |
| 2736 | LM_ReadPhy (pDevice, 0x1e, &Value32); |
| 2737 | LM_WritePhy (pDevice, 0x1e, Value32 | 0x8000); |
| 2738 | LM_ReadPhy (pDevice, 0x14, &Value32); |
| 2739 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2740 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2741 | /* Set up the receive mask. */ |
| 2742 | LM_SetReceiveMask (pDevice, pDevice->ReceiveMask); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2743 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2744 | /* Queue Rx packet buffers. */ |
| 2745 | if (pDevice->QueueRxPackets) { |
| 2746 | LM_QueueRxPackets (pDevice); |
| 2747 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2748 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2749 | /* Enable interrupt to the host. */ |
| 2750 | if (pDevice->InitDone) { |
| 2751 | LM_EnableInterrupt (pDevice); |
| 2752 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2753 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2754 | return LM_STATUS_SUCCESS; |
| 2755 | } /* LM_ResetAdapter */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2756 | |
| 2757 | /******************************************************************************/ |
| 2758 | /* Description: */ |
| 2759 | /* This routine disables the adapter from generating interrupts. */ |
| 2760 | /* */ |
| 2761 | /* Return: */ |
| 2762 | /* LM_STATUS_SUCCESS */ |
| 2763 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2764 | LM_STATUS LM_DisableInterrupt (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2765 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2766 | REG_WR (pDevice, PciCfg.MiscHostCtrl, pDevice->MiscHostCtrl | |
| 2767 | MISC_HOST_CTRL_MASK_PCI_INT); |
| 2768 | MB_REG_WR (pDevice, Mailbox.Interrupt[0].Low, 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2769 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2770 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2771 | } |
| 2772 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2773 | /******************************************************************************/ |
| 2774 | /* Description: */ |
| 2775 | /* This routine enables the adapter to generate interrupts. */ |
| 2776 | /* */ |
| 2777 | /* Return: */ |
| 2778 | /* LM_STATUS_SUCCESS */ |
| 2779 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2780 | LM_STATUS LM_EnableInterrupt (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2781 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2782 | REG_WR (pDevice, PciCfg.MiscHostCtrl, pDevice->MiscHostCtrl & |
| 2783 | ~MISC_HOST_CTRL_MASK_PCI_INT); |
| 2784 | MB_REG_WR (pDevice, Mailbox.Interrupt[0].Low, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2785 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2786 | if (pDevice->pStatusBlkVirt->Status & STATUS_BLOCK_UPDATED) { |
| 2787 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl | |
| 2788 | GRC_MISC_LOCAL_CTRL_SET_INT); |
| 2789 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2790 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2791 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2792 | } |
| 2793 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2794 | /******************************************************************************/ |
| 2795 | /* Description: */ |
| 2796 | /* This routine puts a packet on the wire if there is a transmit DMA */ |
| 2797 | /* descriptor available; otherwise the packet is queued for later */ |
| 2798 | /* transmission. If the second argue is NULL, this routine will put */ |
| 2799 | /* the queued packet on the wire if possible. */ |
| 2800 | /* */ |
| 2801 | /* Return: */ |
| 2802 | /* LM_STATUS_SUCCESS */ |
| 2803 | /******************************************************************************/ |
| 2804 | #if 0 |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2805 | LM_STATUS LM_SendPacket (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2806 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2807 | LM_UINT32 FragCount; |
| 2808 | PT3_SND_BD pSendBd; |
| 2809 | PT3_SND_BD pShadowSendBd; |
| 2810 | LM_UINT32 Value32, Len; |
| 2811 | LM_UINT32 Idx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2812 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2813 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 2814 | return LM_5700SendPacket (pDevice, pPacket); |
| 2815 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2816 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2817 | /* Update the SendBdLeft count. */ |
| 2818 | atomic_sub (pPacket->u.Tx.FragCount, &pDevice->SendBdLeft); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2819 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2820 | /* Initalize the send buffer descriptors. */ |
| 2821 | Idx = pDevice->SendProdIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2822 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2823 | pSendBd = &pDevice->pSendBdVirt[Idx]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2824 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2825 | /* Next producer index. */ |
| 2826 | if (pDevice->NicSendBd == TRUE) { |
| 2827 | T3_64BIT_HOST_ADDR paddr; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2828 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2829 | pShadowSendBd = &pDevice->ShadowSendBd[Idx]; |
| 2830 | for (FragCount = 0;;) { |
| 2831 | MM_MapTxDma (pDevice, pPacket, &paddr, &Len, FragCount); |
| 2832 | /* Initialize the pointer to the send buffer fragment. */ |
| 2833 | if (paddr.High != pShadowSendBd->HostAddr.High) { |
| 2834 | __raw_writel (paddr.High, |
| 2835 | &(pSendBd->HostAddr.High)); |
| 2836 | pShadowSendBd->HostAddr.High = paddr.High; |
| 2837 | } |
| 2838 | __raw_writel (paddr.Low, &(pSendBd->HostAddr.Low)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2839 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2840 | /* Setup the control flags and send buffer size. */ |
| 2841 | Value32 = (Len << 16) | pPacket->Flags; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2842 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2843 | Idx = (Idx + 1) & T3_SEND_RCB_ENTRY_COUNT_MASK; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2844 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2845 | FragCount++; |
| 2846 | if (FragCount >= pPacket->u.Tx.FragCount) { |
| 2847 | Value32 |= SND_BD_FLAG_END; |
| 2848 | if (Value32 != pShadowSendBd->u1.Len_Flags) { |
| 2849 | __raw_writel (Value32, |
| 2850 | &(pSendBd->u1.Len_Flags)); |
| 2851 | pShadowSendBd->u1.Len_Flags = Value32; |
| 2852 | } |
| 2853 | if (pPacket->Flags & SND_BD_FLAG_VLAN_TAG) { |
| 2854 | __raw_writel (pPacket->VlanTag, |
| 2855 | &(pSendBd->u2.VlanTag)); |
| 2856 | } |
| 2857 | break; |
| 2858 | } else { |
| 2859 | if (Value32 != pShadowSendBd->u1.Len_Flags) { |
| 2860 | __raw_writel (Value32, |
| 2861 | &(pSendBd->u1.Len_Flags)); |
| 2862 | pShadowSendBd->u1.Len_Flags = Value32; |
| 2863 | } |
| 2864 | if (pPacket->Flags & SND_BD_FLAG_VLAN_TAG) { |
| 2865 | __raw_writel (pPacket->VlanTag, |
| 2866 | &(pSendBd->u2.VlanTag)); |
| 2867 | } |
| 2868 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2869 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2870 | pSendBd++; |
| 2871 | pShadowSendBd++; |
| 2872 | if (Idx == 0) { |
| 2873 | pSendBd = &pDevice->pSendBdVirt[0]; |
| 2874 | pShadowSendBd = &pDevice->ShadowSendBd[0]; |
| 2875 | } |
| 2876 | } /* for */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2877 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2878 | /* Put the packet descriptor in the ActiveQ. */ |
| 2879 | QQ_PushTail (&pDevice->TxPacketActiveQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2880 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2881 | wmb (); |
| 2882 | MB_REG_WR (pDevice, Mailbox.SendNicProdIdx[0].Low, Idx); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2883 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2884 | } else { |
| 2885 | for (FragCount = 0;;) { |
| 2886 | /* Initialize the pointer to the send buffer fragment. */ |
| 2887 | MM_MapTxDma (pDevice, pPacket, &pSendBd->HostAddr, &Len, |
| 2888 | FragCount); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2889 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2890 | pSendBd->u2.VlanTag = pPacket->VlanTag; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2891 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2892 | /* Setup the control flags and send buffer size. */ |
| 2893 | Value32 = (Len << 16) | pPacket->Flags; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2894 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2895 | Idx = (Idx + 1) & T3_SEND_RCB_ENTRY_COUNT_MASK; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2896 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2897 | FragCount++; |
| 2898 | if (FragCount >= pPacket->u.Tx.FragCount) { |
| 2899 | pSendBd->u1.Len_Flags = |
| 2900 | Value32 | SND_BD_FLAG_END; |
| 2901 | break; |
| 2902 | } else { |
| 2903 | pSendBd->u1.Len_Flags = Value32; |
| 2904 | } |
| 2905 | pSendBd++; |
| 2906 | if (Idx == 0) { |
| 2907 | pSendBd = &pDevice->pSendBdVirt[0]; |
| 2908 | } |
| 2909 | } /* for */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2910 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2911 | /* Put the packet descriptor in the ActiveQ. */ |
| 2912 | QQ_PushTail (&pDevice->TxPacketActiveQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2913 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2914 | wmb (); |
| 2915 | MB_REG_WR (pDevice, Mailbox.SendHostProdIdx[0].Low, Idx); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2916 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2917 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2918 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2919 | /* Update the producer index. */ |
| 2920 | pDevice->SendProdIdx = Idx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2921 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2922 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2923 | } |
| 2924 | #endif |
| 2925 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2926 | LM_STATUS LM_SendPacket (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2927 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2928 | LM_UINT32 FragCount; |
| 2929 | PT3_SND_BD pSendBd, pTmpSendBd, pShadowSendBd; |
| 2930 | T3_SND_BD NicSendBdArr[MAX_FRAGMENT_COUNT]; |
| 2931 | LM_UINT32 StartIdx, Idx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2932 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2933 | while (1) { |
| 2934 | /* Initalize the send buffer descriptors. */ |
| 2935 | StartIdx = Idx = pDevice->SendProdIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2936 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2937 | if (pDevice->NicSendBd) { |
| 2938 | pTmpSendBd = pSendBd = &NicSendBdArr[0]; |
| 2939 | } else { |
| 2940 | pTmpSendBd = pSendBd = &pDevice->pSendBdVirt[Idx]; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2941 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2942 | |
| 2943 | /* Next producer index. */ |
| 2944 | for (FragCount = 0;;) { |
| 2945 | LM_UINT32 Value32, Len; |
| 2946 | |
| 2947 | /* Initialize the pointer to the send buffer fragment. */ |
| 2948 | MM_MapTxDma (pDevice, pPacket, &pSendBd->HostAddr, &Len, |
| 2949 | FragCount); |
| 2950 | |
| 2951 | pSendBd->u2.VlanTag = pPacket->VlanTag; |
| 2952 | |
| 2953 | /* Setup the control flags and send buffer size. */ |
| 2954 | Value32 = (Len << 16) | pPacket->Flags; |
| 2955 | |
| 2956 | Idx = (Idx + 1) & T3_SEND_RCB_ENTRY_COUNT_MASK; |
| 2957 | |
| 2958 | FragCount++; |
| 2959 | if (FragCount >= pPacket->u.Tx.FragCount) { |
| 2960 | pSendBd->u1.Len_Flags = |
| 2961 | Value32 | SND_BD_FLAG_END; |
| 2962 | break; |
| 2963 | } else { |
| 2964 | pSendBd->u1.Len_Flags = Value32; |
| 2965 | } |
| 2966 | pSendBd++; |
| 2967 | if ((Idx == 0) && !pDevice->NicSendBd) { |
| 2968 | pSendBd = &pDevice->pSendBdVirt[0]; |
| 2969 | } |
| 2970 | } /* for */ |
| 2971 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 2972 | if (LM_Test4GBoundary (pDevice, pPacket, pTmpSendBd) == |
| 2973 | LM_STATUS_SUCCESS) { |
| 2974 | if (MM_CoalesceTxBuffer (pDevice, pPacket) != |
| 2975 | LM_STATUS_SUCCESS) { |
| 2976 | QQ_PushHead (&pDevice->TxPacketFreeQ. |
| 2977 | Container, pPacket); |
| 2978 | return LM_STATUS_FAILURE; |
| 2979 | } |
| 2980 | continue; |
| 2981 | } |
| 2982 | } |
| 2983 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 2984 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2985 | /* Put the packet descriptor in the ActiveQ. */ |
| 2986 | QQ_PushTail (&pDevice->TxPacketActiveQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2987 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2988 | if (pDevice->NicSendBd) { |
| 2989 | pSendBd = &pDevice->pSendBdVirt[StartIdx]; |
| 2990 | pShadowSendBd = &pDevice->ShadowSendBd[StartIdx]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2991 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2992 | while (StartIdx != Idx) { |
| 2993 | LM_UINT32 Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2994 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 2995 | if ((Value32 = pTmpSendBd->HostAddr.High) != |
| 2996 | pShadowSendBd->HostAddr.High) { |
| 2997 | __raw_writel (Value32, |
| 2998 | &(pSendBd->HostAddr.High)); |
| 2999 | pShadowSendBd->HostAddr.High = Value32; |
| 3000 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3001 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3002 | __raw_writel (pTmpSendBd->HostAddr.Low, |
| 3003 | &(pSendBd->HostAddr.Low)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3004 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3005 | if ((Value32 = pTmpSendBd->u1.Len_Flags) != |
| 3006 | pShadowSendBd->u1.Len_Flags) { |
| 3007 | __raw_writel (Value32, |
| 3008 | &(pSendBd->u1.Len_Flags)); |
| 3009 | pShadowSendBd->u1.Len_Flags = Value32; |
| 3010 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3011 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3012 | if (pPacket->Flags & SND_BD_FLAG_VLAN_TAG) { |
| 3013 | __raw_writel (pTmpSendBd->u2.VlanTag, |
| 3014 | &(pSendBd->u2.VlanTag)); |
| 3015 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3016 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3017 | StartIdx = |
| 3018 | (StartIdx + 1) & T3_SEND_RCB_ENTRY_COUNT_MASK; |
| 3019 | if (StartIdx == 0) |
| 3020 | pSendBd = &pDevice->pSendBdVirt[0]; |
| 3021 | else |
| 3022 | pSendBd++; |
| 3023 | pTmpSendBd++; |
| 3024 | } |
| 3025 | wmb (); |
| 3026 | MB_REG_WR (pDevice, Mailbox.SendNicProdIdx[0].Low, Idx); |
| 3027 | |
| 3028 | if (T3_CHIP_REV (pDevice->ChipRevId) == T3_CHIP_REV_5700_BX) { |
| 3029 | MB_REG_WR (pDevice, Mailbox.SendNicProdIdx[0].Low, Idx); |
| 3030 | } |
| 3031 | } else { |
| 3032 | wmb (); |
| 3033 | MB_REG_WR (pDevice, Mailbox.SendHostProdIdx[0].Low, Idx); |
| 3034 | |
| 3035 | if (T3_CHIP_REV (pDevice->ChipRevId) == T3_CHIP_REV_5700_BX) { |
| 3036 | MB_REG_WR (pDevice, Mailbox.SendHostProdIdx[0].Low, |
| 3037 | Idx); |
| 3038 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3039 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3040 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3041 | /* Update the SendBdLeft count. */ |
| 3042 | atomic_sub (pPacket->u.Tx.FragCount, &pDevice->SendBdLeft); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3043 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3044 | /* Update the producer index. */ |
| 3045 | pDevice->SendProdIdx = Idx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3046 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3047 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3048 | } |
| 3049 | |
| 3050 | STATIC LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3051 | LM_Test4GBoundary (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket, |
| 3052 | PT3_SND_BD pSendBd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3053 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3054 | int FragCount; |
| 3055 | LM_UINT32 Idx, Base, Len; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3056 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3057 | Idx = pDevice->SendProdIdx; |
| 3058 | for (FragCount = 0;;) { |
| 3059 | Len = pSendBd->u1.Len_Flags >> 16; |
| 3060 | if (((Base = pSendBd->HostAddr.Low) > 0xffffdcc0) && |
| 3061 | (pSendBd->HostAddr.High == 0) && |
| 3062 | ((Base + 8 + Len) < Base)) { |
| 3063 | return LM_STATUS_SUCCESS; |
| 3064 | } |
| 3065 | FragCount++; |
| 3066 | if (FragCount >= pPacket->u.Tx.FragCount) { |
| 3067 | break; |
| 3068 | } |
| 3069 | pSendBd++; |
| 3070 | if (!pDevice->NicSendBd) { |
| 3071 | Idx = (Idx + 1) & T3_SEND_RCB_ENTRY_COUNT_MASK; |
| 3072 | if (Idx == 0) { |
| 3073 | pSendBd = &pDevice->pSendBdVirt[0]; |
| 3074 | } |
| 3075 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3076 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3077 | return LM_STATUS_FAILURE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3078 | } |
| 3079 | |
| 3080 | /******************************************************************************/ |
| 3081 | /* Description: */ |
| 3082 | /* */ |
| 3083 | /* Return: */ |
| 3084 | /******************************************************************************/ |
| 3085 | __inline static unsigned long |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3086 | ComputeCrc32 (unsigned char *pBuffer, unsigned long BufferSize) |
| 3087 | { |
| 3088 | unsigned long Reg; |
| 3089 | unsigned long Tmp; |
| 3090 | unsigned long j, k; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3091 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3092 | Reg = 0xffffffff; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3093 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3094 | for (j = 0; j < BufferSize; j++) { |
| 3095 | Reg ^= pBuffer[j]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3096 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3097 | for (k = 0; k < 8; k++) { |
| 3098 | Tmp = Reg & 0x01; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3099 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3100 | Reg >>= 1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3101 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3102 | if (Tmp) { |
| 3103 | Reg ^= 0xedb88320; |
| 3104 | } |
| 3105 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3106 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3107 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3108 | return ~Reg; |
| 3109 | } /* ComputeCrc32 */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3110 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3111 | /******************************************************************************/ |
| 3112 | /* Description: */ |
| 3113 | /* This routine sets the receive control register according to ReceiveMask */ |
| 3114 | /* */ |
| 3115 | /* Return: */ |
| 3116 | /* LM_STATUS_SUCCESS */ |
| 3117 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3118 | LM_STATUS LM_SetReceiveMask (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Mask) |
| 3119 | { |
| 3120 | LM_UINT32 ReceiveMask; |
| 3121 | LM_UINT32 RxMode; |
| 3122 | LM_UINT32 j, k; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3123 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3124 | ReceiveMask = Mask; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3125 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3126 | RxMode = pDevice->RxMode; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3127 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3128 | if (Mask & LM_ACCEPT_UNICAST) { |
| 3129 | Mask &= ~LM_ACCEPT_UNICAST; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3130 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3131 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3132 | if (Mask & LM_ACCEPT_MULTICAST) { |
| 3133 | Mask &= ~LM_ACCEPT_MULTICAST; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3134 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3135 | |
| 3136 | if (Mask & LM_ACCEPT_ALL_MULTICAST) { |
| 3137 | Mask &= ~LM_ACCEPT_ALL_MULTICAST; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3138 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3139 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3140 | if (Mask & LM_ACCEPT_BROADCAST) { |
| 3141 | Mask &= ~LM_ACCEPT_BROADCAST; |
| 3142 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3143 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3144 | RxMode &= ~RX_MODE_PROMISCUOUS_MODE; |
| 3145 | if (Mask & LM_PROMISCUOUS_MODE) { |
| 3146 | RxMode |= RX_MODE_PROMISCUOUS_MODE; |
| 3147 | Mask &= ~LM_PROMISCUOUS_MODE; |
| 3148 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3149 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3150 | RxMode &= ~(RX_MODE_ACCEPT_RUNTS | RX_MODE_ACCEPT_OVERSIZED); |
| 3151 | if (Mask & LM_ACCEPT_ERROR_PACKET) { |
| 3152 | RxMode |= RX_MODE_ACCEPT_RUNTS | RX_MODE_ACCEPT_OVERSIZED; |
| 3153 | Mask &= ~LM_ACCEPT_ERROR_PACKET; |
| 3154 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3155 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3156 | /* Make sure all the bits are valid before committing changes. */ |
| 3157 | if (Mask) { |
| 3158 | return LM_STATUS_FAILURE; |
| 3159 | } |
| 3160 | |
| 3161 | /* Commit the new filter. */ |
| 3162 | pDevice->RxMode = RxMode; |
| 3163 | REG_WR (pDevice, MacCtrl.RxMode, RxMode); |
| 3164 | |
| 3165 | pDevice->ReceiveMask = ReceiveMask; |
| 3166 | |
| 3167 | /* Set up the MC hash table. */ |
| 3168 | if (ReceiveMask & LM_ACCEPT_ALL_MULTICAST) { |
| 3169 | for (k = 0; k < 4; k++) { |
| 3170 | REG_WR (pDevice, MacCtrl.HashReg[k], 0xffffffff); |
| 3171 | } |
| 3172 | } else if (ReceiveMask & LM_ACCEPT_MULTICAST) { |
| 3173 | LM_UINT32 HashReg[4]; |
| 3174 | |
| 3175 | HashReg[0] = 0; |
| 3176 | HashReg[1] = 0; |
| 3177 | HashReg[2] = 0; |
| 3178 | HashReg[3] = 0; |
| 3179 | for (j = 0; j < pDevice->McEntryCount; j++) { |
| 3180 | LM_UINT32 RegIndex; |
| 3181 | LM_UINT32 Bitpos; |
| 3182 | LM_UINT32 Crc32; |
| 3183 | |
| 3184 | Crc32 = |
| 3185 | ComputeCrc32 (pDevice->McTable[j], |
| 3186 | ETHERNET_ADDRESS_SIZE); |
| 3187 | |
| 3188 | /* The most significant 7 bits of the CRC32 (no inversion), */ |
| 3189 | /* are used to index into one of the possible 128 bit positions. */ |
| 3190 | Bitpos = ~Crc32 & 0x7f; |
| 3191 | |
| 3192 | /* Hash register index. */ |
| 3193 | RegIndex = (Bitpos & 0x60) >> 5; |
| 3194 | |
| 3195 | /* Bit to turn on within a hash register. */ |
| 3196 | Bitpos &= 0x1f; |
| 3197 | |
| 3198 | /* Enable the multicast bit. */ |
| 3199 | HashReg[RegIndex] |= (1 << Bitpos); |
| 3200 | } |
| 3201 | |
| 3202 | /* REV_AX has problem with multicast filtering where it uses both */ |
| 3203 | /* DA and SA to perform hashing. */ |
| 3204 | for (k = 0; k < 4; k++) { |
| 3205 | REG_WR (pDevice, MacCtrl.HashReg[k], HashReg[k]); |
| 3206 | } |
| 3207 | } else { |
| 3208 | /* Reject all multicast frames. */ |
| 3209 | for (j = 0; j < 4; j++) { |
| 3210 | REG_WR (pDevice, MacCtrl.HashReg[j], 0); |
| 3211 | } |
| 3212 | } |
| 3213 | |
| 3214 | /* By default, Tigon3 will accept broadcast frames. We need to setup */ |
| 3215 | if (ReceiveMask & LM_ACCEPT_BROADCAST) { |
| 3216 | REG_WR (pDevice, |
| 3217 | MacCtrl.RcvRules[RCV_RULE1_REJECT_BROADCAST_IDX].Rule, |
| 3218 | REJECT_BROADCAST_RULE1_RULE & RCV_DISABLE_RULE_MASK); |
| 3219 | REG_WR (pDevice, |
| 3220 | MacCtrl.RcvRules[RCV_RULE1_REJECT_BROADCAST_IDX].Value, |
| 3221 | REJECT_BROADCAST_RULE1_VALUE & RCV_DISABLE_RULE_MASK); |
| 3222 | REG_WR (pDevice, |
| 3223 | MacCtrl.RcvRules[RCV_RULE2_REJECT_BROADCAST_IDX].Rule, |
| 3224 | REJECT_BROADCAST_RULE1_RULE & RCV_DISABLE_RULE_MASK); |
| 3225 | REG_WR (pDevice, |
| 3226 | MacCtrl.RcvRules[RCV_RULE2_REJECT_BROADCAST_IDX].Value, |
| 3227 | REJECT_BROADCAST_RULE1_VALUE & RCV_DISABLE_RULE_MASK); |
| 3228 | } else { |
| 3229 | REG_WR (pDevice, |
| 3230 | MacCtrl.RcvRules[RCV_RULE1_REJECT_BROADCAST_IDX].Rule, |
| 3231 | REJECT_BROADCAST_RULE1_RULE); |
| 3232 | REG_WR (pDevice, |
| 3233 | MacCtrl.RcvRules[RCV_RULE1_REJECT_BROADCAST_IDX].Value, |
| 3234 | REJECT_BROADCAST_RULE1_VALUE); |
| 3235 | REG_WR (pDevice, |
| 3236 | MacCtrl.RcvRules[RCV_RULE2_REJECT_BROADCAST_IDX].Rule, |
| 3237 | REJECT_BROADCAST_RULE2_RULE); |
| 3238 | REG_WR (pDevice, |
| 3239 | MacCtrl.RcvRules[RCV_RULE2_REJECT_BROADCAST_IDX].Value, |
| 3240 | REJECT_BROADCAST_RULE2_VALUE); |
| 3241 | } |
| 3242 | |
| 3243 | /* disable the rest of the rules. */ |
| 3244 | for (j = RCV_LAST_RULE_IDX; j < 16; j++) { |
| 3245 | REG_WR (pDevice, MacCtrl.RcvRules[j].Rule, 0); |
| 3246 | REG_WR (pDevice, MacCtrl.RcvRules[j].Value, 0); |
| 3247 | } |
| 3248 | |
| 3249 | return LM_STATUS_SUCCESS; |
| 3250 | } /* LM_SetReceiveMask */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3251 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3252 | /******************************************************************************/ |
| 3253 | /* Description: */ |
| 3254 | /* Disable the interrupt and put the transmitter and receiver engines in */ |
| 3255 | /* an idle state. Also aborts all pending send requests and receive */ |
| 3256 | /* buffers. */ |
| 3257 | /* */ |
| 3258 | /* Return: */ |
| 3259 | /* LM_STATUS_SUCCESS */ |
| 3260 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3261 | LM_STATUS LM_Abort (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3262 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3263 | PLM_PACKET pPacket; |
| 3264 | LM_UINT Idx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3265 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3266 | LM_DisableInterrupt (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3267 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3268 | /* Disable all the state machines. */ |
| 3269 | LM_CntrlBlock (pDevice, T3_BLOCK_MAC_RX_ENGINE, LM_DISABLE); |
| 3270 | LM_CntrlBlock (pDevice, T3_BLOCK_RX_BD_INITIATOR, LM_DISABLE); |
| 3271 | LM_CntrlBlock (pDevice, T3_BLOCK_RX_LIST_PLMT, LM_DISABLE); |
| 3272 | LM_CntrlBlock (pDevice, T3_BLOCK_RX_LIST_SELECTOR, LM_DISABLE); |
| 3273 | LM_CntrlBlock (pDevice, T3_BLOCK_RX_DATA_INITIATOR, LM_DISABLE); |
| 3274 | LM_CntrlBlock (pDevice, T3_BLOCK_RX_DATA_COMP, LM_DISABLE); |
| 3275 | LM_CntrlBlock (pDevice, T3_BLOCK_RX_BD_COMP, LM_DISABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3276 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3277 | LM_CntrlBlock (pDevice, T3_BLOCK_SEND_BD_SELECTOR, LM_DISABLE); |
| 3278 | LM_CntrlBlock (pDevice, T3_BLOCK_SEND_BD_INITIATOR, LM_DISABLE); |
| 3279 | LM_CntrlBlock (pDevice, T3_BLOCK_SEND_DATA_INITIATOR, LM_DISABLE); |
| 3280 | LM_CntrlBlock (pDevice, T3_BLOCK_DMA_RD, LM_DISABLE); |
| 3281 | LM_CntrlBlock (pDevice, T3_BLOCK_SEND_DATA_COMP, LM_DISABLE); |
| 3282 | LM_CntrlBlock (pDevice, T3_BLOCK_DMA_COMP, LM_DISABLE); |
| 3283 | LM_CntrlBlock (pDevice, T3_BLOCK_SEND_BD_COMP, LM_DISABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3284 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3285 | /* Clear TDE bit */ |
| 3286 | pDevice->MacMode &= ~MAC_MODE_ENABLE_TDE; |
| 3287 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3288 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3289 | LM_CntrlBlock (pDevice, T3_BLOCK_MAC_TX_ENGINE, LM_DISABLE); |
| 3290 | LM_CntrlBlock (pDevice, T3_BLOCK_HOST_COALESING, LM_DISABLE); |
| 3291 | LM_CntrlBlock (pDevice, T3_BLOCK_DMA_WR, LM_DISABLE); |
| 3292 | LM_CntrlBlock (pDevice, T3_BLOCK_MBUF_CLUSTER_FREE, LM_DISABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3293 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3294 | /* Reset all FTQs */ |
| 3295 | REG_WR (pDevice, Ftq.Reset, 0xffffffff); |
| 3296 | REG_WR (pDevice, Ftq.Reset, 0x0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3297 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3298 | LM_CntrlBlock (pDevice, T3_BLOCK_MBUF_MANAGER, LM_DISABLE); |
| 3299 | LM_CntrlBlock (pDevice, T3_BLOCK_MEM_ARBITOR, LM_DISABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3300 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3301 | MM_ACQUIRE_INT_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3302 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3303 | /* Abort packets that have already queued to go out. */ |
| 3304 | pPacket = (PLM_PACKET) QQ_PopHead (&pDevice->TxPacketActiveQ.Container); |
| 3305 | while (pPacket) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3306 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3307 | pPacket->PacketStatus = LM_STATUS_TRANSMIT_ABORTED; |
| 3308 | pDevice->TxCounters.TxPacketAbortedCnt++; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3309 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3310 | atomic_add (pPacket->u.Tx.FragCount, &pDevice->SendBdLeft); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3311 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3312 | QQ_PushTail (&pDevice->TxPacketXmittedQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3313 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3314 | pPacket = (PLM_PACKET) |
| 3315 | QQ_PopHead (&pDevice->TxPacketActiveQ.Container); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3316 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3317 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3318 | /* Cleanup the receive return rings. */ |
| 3319 | LM_ServiceRxInterrupt (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3320 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3321 | /* Don't want to indicate rx packets in Ndis miniport shutdown context. */ |
| 3322 | /* Doing so may cause system crash. */ |
| 3323 | if (!pDevice->ShuttingDown) { |
| 3324 | /* Indicate packets to the protocol. */ |
| 3325 | MM_IndicateTxPackets (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3326 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3327 | /* Indicate received packets to the protocols. */ |
| 3328 | MM_IndicateRxPackets (pDevice); |
| 3329 | } else { |
| 3330 | /* Move the receive packet descriptors in the ReceivedQ to the */ |
| 3331 | /* free queue. */ |
| 3332 | for (;;) { |
| 3333 | pPacket = |
| 3334 | (PLM_PACKET) QQ_PopHead (&pDevice-> |
| 3335 | RxPacketReceivedQ. |
| 3336 | Container); |
| 3337 | if (pPacket == NULL) { |
| 3338 | break; |
| 3339 | } |
| 3340 | QQ_PushTail (&pDevice->RxPacketFreeQ.Container, |
| 3341 | pPacket); |
| 3342 | } |
| 3343 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3344 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3345 | /* Clean up the Std Receive Producer ring. */ |
| 3346 | Idx = pDevice->pStatusBlkVirt->RcvStdConIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3347 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3348 | while (Idx != pDevice->RxStdProdIdx) { |
| 3349 | pPacket = (PLM_PACKET) (MM_UINT_PTR (pDevice->pPacketDescBase) + |
| 3350 | MM_UINT_PTR (pDevice->pRxStdBdVirt[Idx]. |
| 3351 | Opaque)); |
| 3352 | |
| 3353 | QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket); |
| 3354 | |
| 3355 | Idx = (Idx + 1) & T3_STD_RCV_RCB_ENTRY_COUNT_MASK; |
| 3356 | } /* while */ |
| 3357 | |
| 3358 | /* Reinitialize our copy of the indices. */ |
| 3359 | pDevice->RxStdProdIdx = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3360 | |
| 3361 | #if T3_JUMBO_RCV_RCB_ENTRY_COUNT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3362 | /* Clean up the Jumbo Receive Producer ring. */ |
| 3363 | Idx = pDevice->pStatusBlkVirt->RcvJumboConIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3364 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3365 | while (Idx != pDevice->RxJumboProdIdx) { |
| 3366 | pPacket = (PLM_PACKET) (MM_UINT_PTR (pDevice->pPacketDescBase) + |
| 3367 | MM_UINT_PTR (pDevice-> |
| 3368 | pRxJumboBdVirt[Idx]. |
| 3369 | Opaque)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3370 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3371 | QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3372 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3373 | Idx = (Idx + 1) & T3_JUMBO_RCV_RCB_ENTRY_COUNT_MASK; |
| 3374 | } /* while */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3375 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3376 | /* Reinitialize our copy of the indices. */ |
| 3377 | pDevice->RxJumboProdIdx = 0; |
| 3378 | #endif /* T3_JUMBO_RCV_RCB_ENTRY_COUNT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3379 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3380 | MM_RELEASE_INT_LOCK (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3381 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3382 | /* Initialize the statistis Block */ |
| 3383 | pDevice->pStatusBlkVirt->Status = 0; |
| 3384 | pDevice->pStatusBlkVirt->RcvStdConIdx = 0; |
| 3385 | pDevice->pStatusBlkVirt->RcvJumboConIdx = 0; |
| 3386 | pDevice->pStatusBlkVirt->RcvMiniConIdx = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3387 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3388 | return LM_STATUS_SUCCESS; |
| 3389 | } /* LM_Abort */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3390 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3391 | /******************************************************************************/ |
| 3392 | /* Description: */ |
| 3393 | /* Disable the interrupt and put the transmitter and receiver engines in */ |
| 3394 | /* an idle state. Aborts all pending send requests and receive buffers. */ |
| 3395 | /* Also free all the receive buffers. */ |
| 3396 | /* */ |
| 3397 | /* Return: */ |
| 3398 | /* LM_STATUS_SUCCESS */ |
| 3399 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3400 | LM_STATUS LM_Halt (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3401 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3402 | PLM_PACKET pPacket; |
| 3403 | LM_UINT32 EntryCnt; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3404 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3405 | LM_Abort (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3406 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3407 | /* Get the number of entries in the queue. */ |
| 3408 | EntryCnt = QQ_GetEntryCnt (&pDevice->RxPacketFreeQ.Container); |
| 3409 | |
| 3410 | /* Make sure all the packets have been accounted for. */ |
| 3411 | for (EntryCnt = 0; EntryCnt < pDevice->RxPacketDescCnt; EntryCnt++) { |
| 3412 | pPacket = |
| 3413 | (PLM_PACKET) QQ_PopHead (&pDevice->RxPacketFreeQ.Container); |
| 3414 | if (pPacket == 0) |
| 3415 | break; |
| 3416 | |
| 3417 | MM_FreeRxBuffer (pDevice, pPacket); |
| 3418 | |
| 3419 | QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3420 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3421 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3422 | LM_ResetChip (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3423 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3424 | /* Restore PCI configuration registers. */ |
| 3425 | MM_WriteConfig32 (pDevice, PCI_CACHE_LINE_SIZE_REG, |
| 3426 | pDevice->SavedCacheLineReg); |
| 3427 | LM_RegWrInd (pDevice, PCI_SUBSYSTEM_VENDOR_ID_REG, |
| 3428 | (pDevice->SubsystemId << 16) | pDevice->SubsystemVendorId); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3429 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3430 | /* Reprogram the MAC address. */ |
| 3431 | LM_SetMacAddress (pDevice, pDevice->NodeAddress); |
| 3432 | |
| 3433 | return LM_STATUS_SUCCESS; |
| 3434 | } /* LM_Halt */ |
| 3435 | |
| 3436 | STATIC LM_STATUS LM_ResetChip (PLM_DEVICE_BLOCK pDevice) |
| 3437 | { |
| 3438 | LM_UINT32 Value32; |
| 3439 | LM_UINT32 j; |
| 3440 | |
| 3441 | /* Wait for access to the nvram interface before resetting. This is */ |
| 3442 | /* a workaround to prevent EEPROM corruption. */ |
| 3443 | if (T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5700 && |
| 3444 | T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5701) { |
| 3445 | /* Request access to the flash interface. */ |
| 3446 | REG_WR (pDevice, Nvram.SwArb, SW_ARB_REQ_SET1); |
| 3447 | |
| 3448 | for (j = 0; j < 100000; j++) { |
| 3449 | Value32 = REG_RD (pDevice, Nvram.SwArb); |
| 3450 | if (Value32 & SW_ARB_GNT1) { |
| 3451 | break; |
| 3452 | } |
| 3453 | MM_Wait (10); |
| 3454 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3455 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3456 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3457 | /* Global reset. */ |
| 3458 | REG_WR (pDevice, Grc.MiscCfg, GRC_MISC_CFG_CORE_CLOCK_RESET); |
| 3459 | MM_Wait (40); |
| 3460 | MM_Wait (40); |
| 3461 | MM_Wait (40); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3462 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3463 | /* make sure we re-enable indirect accesses */ |
| 3464 | MM_WriteConfig32 (pDevice, T3_PCI_MISC_HOST_CTRL_REG, |
| 3465 | pDevice->MiscHostCtrl); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3466 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3467 | /* Set MAX PCI retry to zero. */ |
| 3468 | Value32 = |
| 3469 | T3_PCI_STATE_PCI_ROM_ENABLE | T3_PCI_STATE_PCI_ROM_RETRY_ENABLE; |
| 3470 | if (pDevice->ChipRevId == T3_CHIP_ID_5704_A0) { |
| 3471 | if (!(pDevice->PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE)) { |
| 3472 | Value32 |= T3_PCI_STATE_RETRY_SAME_DMA; |
| 3473 | } |
| 3474 | } |
| 3475 | MM_WriteConfig32 (pDevice, T3_PCI_STATE_REG, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3476 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3477 | /* Restore PCI command register. */ |
| 3478 | MM_WriteConfig32 (pDevice, PCI_COMMAND_REG, |
| 3479 | pDevice->PciCommandStatusWords); |
| 3480 | |
| 3481 | /* Disable PCI-X relaxed ordering bit. */ |
| 3482 | MM_ReadConfig32 (pDevice, PCIX_CAP_REG, &Value32); |
| 3483 | Value32 &= ~PCIX_ENABLE_RELAXED_ORDERING; |
| 3484 | MM_WriteConfig32 (pDevice, PCIX_CAP_REG, Value32); |
| 3485 | |
| 3486 | /* Enable memory arbiter. */ |
| 3487 | REG_WR (pDevice, MemArbiter.Mode, T3_MEM_ARBITER_MODE_ENABLE); |
| 3488 | |
| 3489 | #ifdef BIG_ENDIAN_PCI /* This from jfd */ |
| 3490 | Value32 = GRC_MODE_WORD_SWAP_DATA | GRC_MODE_WORD_SWAP_NON_FRAME_DATA; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3491 | #else |
| 3492 | #ifdef BIG_ENDIAN_HOST |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3493 | /* Reconfigure the mode register. */ |
| 3494 | Value32 = GRC_MODE_BYTE_SWAP_NON_FRAME_DATA | |
| 3495 | GRC_MODE_WORD_SWAP_NON_FRAME_DATA | |
| 3496 | GRC_MODE_BYTE_SWAP_DATA | GRC_MODE_WORD_SWAP_DATA; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3497 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3498 | /* Reconfigure the mode register. */ |
| 3499 | Value32 = GRC_MODE_BYTE_SWAP_NON_FRAME_DATA | GRC_MODE_BYTE_SWAP_DATA; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3500 | #endif |
| 3501 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3502 | REG_WR (pDevice, Grc.Mode, Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3503 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3504 | /* Prevent PXE from restarting. */ |
| 3505 | MEM_WR_OFFSET (pDevice, 0x0b50, T3_MAGIC_NUM); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3506 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3507 | if (pDevice->EnableTbi) { |
| 3508 | pDevice->MacMode = MAC_MODE_PORT_MODE_TBI; |
| 3509 | REG_WR (pDevice, MacCtrl.Mode, MAC_MODE_PORT_MODE_TBI); |
| 3510 | } else { |
| 3511 | REG_WR (pDevice, MacCtrl.Mode, 0); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3512 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3513 | |
| 3514 | /* Wait for the firmware to finish initialization. */ |
| 3515 | for (j = 0; j < 100000; j++) { |
| 3516 | MM_Wait (10); |
| 3517 | |
| 3518 | Value32 = MEM_RD_OFFSET (pDevice, 0x0b50); |
| 3519 | if (Value32 == ~T3_MAGIC_NUM) { |
| 3520 | break; |
| 3521 | } |
| 3522 | } |
| 3523 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3524 | } |
| 3525 | |
| 3526 | /******************************************************************************/ |
| 3527 | /* Description: */ |
| 3528 | /* */ |
| 3529 | /* Return: */ |
| 3530 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3531 | __inline static void LM_ServiceTxInterrupt (PLM_DEVICE_BLOCK pDevice) |
| 3532 | { |
| 3533 | PLM_PACKET pPacket; |
| 3534 | LM_UINT32 HwConIdx; |
| 3535 | LM_UINT32 SwConIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3536 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3537 | HwConIdx = pDevice->pStatusBlkVirt->Idx[0].SendConIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3538 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3539 | /* Get our copy of the consumer index. The buffer descriptors */ |
| 3540 | /* that are in between the consumer indices are freed. */ |
| 3541 | SwConIdx = pDevice->SendConIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3542 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3543 | /* Move the packets from the TxPacketActiveQ that are sent out to */ |
| 3544 | /* the TxPacketXmittedQ. Packets that are sent use the */ |
| 3545 | /* descriptors that are between SwConIdx and HwConIdx. */ |
| 3546 | while (SwConIdx != HwConIdx) { |
| 3547 | /* Get the packet that was sent from the TxPacketActiveQ. */ |
| 3548 | pPacket = |
| 3549 | (PLM_PACKET) QQ_PopHead (&pDevice->TxPacketActiveQ. |
| 3550 | Container); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3551 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3552 | /* Set the return status. */ |
| 3553 | pPacket->PacketStatus = LM_STATUS_SUCCESS; |
| 3554 | |
| 3555 | /* Put the packet in the TxPacketXmittedQ for indication later. */ |
| 3556 | QQ_PushTail (&pDevice->TxPacketXmittedQ.Container, pPacket); |
| 3557 | |
| 3558 | /* Move to the next packet's BD. */ |
| 3559 | SwConIdx = (SwConIdx + pPacket->u.Tx.FragCount) & |
| 3560 | T3_SEND_RCB_ENTRY_COUNT_MASK; |
| 3561 | |
| 3562 | /* Update the number of unused BDs. */ |
| 3563 | atomic_add (pPacket->u.Tx.FragCount, &pDevice->SendBdLeft); |
| 3564 | |
| 3565 | /* Get the new updated HwConIdx. */ |
| 3566 | HwConIdx = pDevice->pStatusBlkVirt->Idx[0].SendConIdx; |
| 3567 | } /* while */ |
| 3568 | |
| 3569 | /* Save the new SwConIdx. */ |
| 3570 | pDevice->SendConIdx = SwConIdx; |
| 3571 | |
| 3572 | } /* LM_ServiceTxInterrupt */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3573 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3574 | /******************************************************************************/ |
| 3575 | /* Description: */ |
| 3576 | /* */ |
| 3577 | /* Return: */ |
| 3578 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3579 | __inline static void LM_ServiceRxInterrupt (PLM_DEVICE_BLOCK pDevice) |
| 3580 | { |
| 3581 | PLM_PACKET pPacket; |
| 3582 | PT3_RCV_BD pRcvBd; |
| 3583 | LM_UINT32 HwRcvRetProdIdx; |
| 3584 | LM_UINT32 SwRcvRetConIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3585 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3586 | /* Loop thru the receive return rings for received packets. */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3587 | HwRcvRetProdIdx = pDevice->pStatusBlkVirt->Idx[0].RcvProdIdx; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3588 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3589 | SwRcvRetConIdx = pDevice->RcvRetConIdx; |
| 3590 | while (SwRcvRetConIdx != HwRcvRetProdIdx) { |
| 3591 | pRcvBd = &pDevice->pRcvRetBdVirt[SwRcvRetConIdx]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3592 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3593 | /* Get the received packet descriptor. */ |
| 3594 | pPacket = (PLM_PACKET) (MM_UINT_PTR (pDevice->pPacketDescBase) + |
| 3595 | MM_UINT_PTR (pRcvBd->Opaque)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3596 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3597 | /* Check the error flag. */ |
| 3598 | if (pRcvBd->ErrorFlag && |
| 3599 | pRcvBd->ErrorFlag != RCV_BD_ERR_ODD_NIBBLED_RCVD_MII) { |
| 3600 | pPacket->PacketStatus = LM_STATUS_FAILURE; |
| 3601 | |
| 3602 | pDevice->RxCounters.RxPacketErrCnt++; |
| 3603 | |
| 3604 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_BAD_CRC) { |
| 3605 | pDevice->RxCounters.RxErrCrcCnt++; |
| 3606 | } |
| 3607 | |
| 3608 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_COLL_DETECT) { |
| 3609 | pDevice->RxCounters.RxErrCollCnt++; |
| 3610 | } |
| 3611 | |
| 3612 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_LINK_LOST_DURING_PKT) { |
| 3613 | pDevice->RxCounters.RxErrLinkLostCnt++; |
| 3614 | } |
| 3615 | |
| 3616 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_PHY_DECODE_ERR) { |
| 3617 | pDevice->RxCounters.RxErrPhyDecodeCnt++; |
| 3618 | } |
| 3619 | |
| 3620 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_ODD_NIBBLED_RCVD_MII) { |
| 3621 | pDevice->RxCounters.RxErrOddNibbleCnt++; |
| 3622 | } |
| 3623 | |
| 3624 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_MAC_ABORT) { |
| 3625 | pDevice->RxCounters.RxErrMacAbortCnt++; |
| 3626 | } |
| 3627 | |
| 3628 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_LEN_LT_64) { |
| 3629 | pDevice->RxCounters.RxErrShortPacketCnt++; |
| 3630 | } |
| 3631 | |
| 3632 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_TRUNC_NO_RESOURCES) { |
| 3633 | pDevice->RxCounters.RxErrNoResourceCnt++; |
| 3634 | } |
| 3635 | |
| 3636 | if (pRcvBd->ErrorFlag & RCV_BD_ERR_GIANT_FRAME_RCVD) { |
| 3637 | pDevice->RxCounters.RxErrLargePacketCnt++; |
| 3638 | } |
| 3639 | } else { |
| 3640 | pPacket->PacketStatus = LM_STATUS_SUCCESS; |
| 3641 | pPacket->PacketSize = pRcvBd->Len - 4; |
| 3642 | |
| 3643 | pPacket->Flags = pRcvBd->Flags; |
| 3644 | if (pRcvBd->Flags & RCV_BD_FLAG_VLAN_TAG) { |
| 3645 | pPacket->VlanTag = pRcvBd->VlanTag; |
| 3646 | } |
| 3647 | |
| 3648 | pPacket->u.Rx.TcpUdpChecksum = pRcvBd->TcpUdpCksum; |
| 3649 | } |
| 3650 | |
| 3651 | /* Put the packet descriptor containing the received packet */ |
| 3652 | /* buffer in the RxPacketReceivedQ for indication later. */ |
| 3653 | QQ_PushTail (&pDevice->RxPacketReceivedQ.Container, pPacket); |
| 3654 | |
| 3655 | /* Go to the next buffer descriptor. */ |
| 3656 | SwRcvRetConIdx = (SwRcvRetConIdx + 1) & |
| 3657 | T3_RCV_RETURN_RCB_ENTRY_COUNT_MASK; |
| 3658 | |
| 3659 | /* Get the updated HwRcvRetProdIdx. */ |
| 3660 | HwRcvRetProdIdx = pDevice->pStatusBlkVirt->Idx[0].RcvProdIdx; |
| 3661 | } /* while */ |
| 3662 | |
| 3663 | pDevice->RcvRetConIdx = SwRcvRetConIdx; |
| 3664 | |
| 3665 | /* Update the receive return ring consumer index. */ |
| 3666 | MB_REG_WR (pDevice, Mailbox.RcvRetConIdx[0].Low, SwRcvRetConIdx); |
| 3667 | } /* LM_ServiceRxInterrupt */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3668 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3669 | /******************************************************************************/ |
| 3670 | /* Description: */ |
| 3671 | /* This is the interrupt event handler routine. It acknowledges all */ |
| 3672 | /* pending interrupts and process all pending events. */ |
| 3673 | /* */ |
| 3674 | /* Return: */ |
| 3675 | /* LM_STATUS_SUCCESS */ |
| 3676 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3677 | LM_STATUS LM_ServiceInterrupts (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3678 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3679 | LM_UINT32 Value32; |
| 3680 | int ServicePhyInt = FALSE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3681 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3682 | /* Setup the phy chip whenever the link status changes. */ |
| 3683 | if (pDevice->LinkChngMode == T3_LINK_CHNG_MODE_USE_STATUS_REG) { |
| 3684 | Value32 = REG_RD (pDevice, MacCtrl.Status); |
| 3685 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_MI_INTERRUPT) { |
| 3686 | if (Value32 & MAC_STATUS_MI_INTERRUPT) { |
| 3687 | ServicePhyInt = TRUE; |
| 3688 | } |
| 3689 | } else if (Value32 & MAC_STATUS_LINK_STATE_CHANGED) { |
| 3690 | ServicePhyInt = TRUE; |
| 3691 | } |
| 3692 | } else { |
| 3693 | if (pDevice->pStatusBlkVirt-> |
| 3694 | Status & STATUS_BLOCK_LINK_CHANGED_STATUS) { |
| 3695 | pDevice->pStatusBlkVirt->Status = |
| 3696 | STATUS_BLOCK_UPDATED | (pDevice->pStatusBlkVirt-> |
| 3697 | Status & |
| 3698 | ~STATUS_BLOCK_LINK_CHANGED_STATUS); |
| 3699 | ServicePhyInt = TRUE; |
| 3700 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3701 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3702 | #if INCLUDE_TBI_SUPPORT |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3703 | if (pDevice->IgnoreTbiLinkChange == TRUE) { |
| 3704 | ServicePhyInt = FALSE; |
| 3705 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3706 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3707 | if (ServicePhyInt == TRUE) { |
| 3708 | LM_SetupPhy (pDevice); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3709 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3710 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3711 | /* Service receive and transmit interrupts. */ |
| 3712 | LM_ServiceRxInterrupt (pDevice); |
| 3713 | LM_ServiceTxInterrupt (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3714 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3715 | /* No spinlock for this queue since this routine is serialized. */ |
| 3716 | if (!QQ_Empty (&pDevice->RxPacketReceivedQ.Container)) { |
| 3717 | /* Indicate receive packets. */ |
| 3718 | MM_IndicateRxPackets (pDevice); |
| 3719 | /* LM_QueueRxPackets(pDevice); */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3720 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3721 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3722 | /* No spinlock for this queue since this routine is serialized. */ |
| 3723 | if (!QQ_Empty (&pDevice->TxPacketXmittedQ.Container)) { |
| 3724 | MM_IndicateTxPackets (pDevice); |
| 3725 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3726 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3727 | return LM_STATUS_SUCCESS; |
| 3728 | } /* LM_ServiceInterrupts */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3729 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3730 | /******************************************************************************/ |
| 3731 | /* Description: */ |
| 3732 | /* */ |
| 3733 | /* Return: */ |
| 3734 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3735 | LM_STATUS LM_MulticastAdd (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMcAddress) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3736 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3737 | PLM_UINT8 pEntry; |
| 3738 | LM_UINT32 j; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3739 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3740 | pEntry = pDevice->McTable[0]; |
| 3741 | for (j = 0; j < pDevice->McEntryCount; j++) { |
| 3742 | if (IS_ETH_ADDRESS_EQUAL (pEntry, pMcAddress)) { |
| 3743 | /* Found a match, increment the instance count. */ |
| 3744 | pEntry[LM_MC_INSTANCE_COUNT_INDEX] += 1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3745 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3746 | return LM_STATUS_SUCCESS; |
| 3747 | } |
| 3748 | |
| 3749 | pEntry += LM_MC_ENTRY_SIZE; |
| 3750 | } |
| 3751 | |
| 3752 | if (pDevice->McEntryCount >= LM_MAX_MC_TABLE_SIZE) { |
| 3753 | return LM_STATUS_FAILURE; |
| 3754 | } |
| 3755 | |
| 3756 | pEntry = pDevice->McTable[pDevice->McEntryCount]; |
| 3757 | |
| 3758 | COPY_ETH_ADDRESS (pMcAddress, pEntry); |
| 3759 | pEntry[LM_MC_INSTANCE_COUNT_INDEX] = 1; |
| 3760 | |
| 3761 | pDevice->McEntryCount++; |
| 3762 | |
| 3763 | LM_SetReceiveMask (pDevice, pDevice->ReceiveMask | LM_ACCEPT_MULTICAST); |
| 3764 | |
| 3765 | return LM_STATUS_SUCCESS; |
| 3766 | } /* LM_MulticastAdd */ |
| 3767 | |
| 3768 | /******************************************************************************/ |
| 3769 | /* Description: */ |
| 3770 | /* */ |
| 3771 | /* Return: */ |
| 3772 | /******************************************************************************/ |
| 3773 | LM_STATUS LM_MulticastDel (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMcAddress) |
| 3774 | { |
| 3775 | PLM_UINT8 pEntry; |
| 3776 | LM_UINT32 j; |
| 3777 | |
| 3778 | pEntry = pDevice->McTable[0]; |
| 3779 | for (j = 0; j < pDevice->McEntryCount; j++) { |
| 3780 | if (IS_ETH_ADDRESS_EQUAL (pEntry, pMcAddress)) { |
| 3781 | /* Found a match, decrement the instance count. */ |
| 3782 | pEntry[LM_MC_INSTANCE_COUNT_INDEX] -= 1; |
| 3783 | |
| 3784 | /* No more instance left, remove the address from the table. */ |
| 3785 | /* Move the last entry in the table to the delete slot. */ |
| 3786 | if (pEntry[LM_MC_INSTANCE_COUNT_INDEX] == 0 && |
| 3787 | pDevice->McEntryCount > 1) { |
| 3788 | |
| 3789 | COPY_ETH_ADDRESS (pDevice-> |
| 3790 | McTable[pDevice-> |
| 3791 | McEntryCount - 1], |
| 3792 | pEntry); |
| 3793 | pEntry[LM_MC_INSTANCE_COUNT_INDEX] = |
| 3794 | pDevice->McTable[pDevice->McEntryCount - 1] |
| 3795 | [LM_MC_INSTANCE_COUNT_INDEX]; |
| 3796 | } |
| 3797 | pDevice->McEntryCount--; |
| 3798 | |
| 3799 | /* Update the receive mask if the table is empty. */ |
| 3800 | if (pDevice->McEntryCount == 0) { |
| 3801 | LM_SetReceiveMask (pDevice, |
| 3802 | pDevice-> |
| 3803 | ReceiveMask & |
| 3804 | ~LM_ACCEPT_MULTICAST); |
| 3805 | } |
| 3806 | |
| 3807 | return LM_STATUS_SUCCESS; |
| 3808 | } |
| 3809 | |
| 3810 | pEntry += LM_MC_ENTRY_SIZE; |
| 3811 | } |
| 3812 | |
| 3813 | return LM_STATUS_FAILURE; |
| 3814 | } /* LM_MulticastDel */ |
| 3815 | |
| 3816 | /******************************************************************************/ |
| 3817 | /* Description: */ |
| 3818 | /* */ |
| 3819 | /* Return: */ |
| 3820 | /******************************************************************************/ |
| 3821 | LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice) |
| 3822 | { |
| 3823 | pDevice->McEntryCount = 0; |
| 3824 | |
| 3825 | LM_SetReceiveMask (pDevice, |
| 3826 | pDevice->ReceiveMask & ~LM_ACCEPT_MULTICAST); |
| 3827 | |
| 3828 | return LM_STATUS_SUCCESS; |
| 3829 | } /* LM_MulticastClear */ |
| 3830 | |
| 3831 | /******************************************************************************/ |
| 3832 | /* Description: */ |
| 3833 | /* */ |
| 3834 | /* Return: */ |
| 3835 | /******************************************************************************/ |
| 3836 | LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pMacAddress) |
| 3837 | { |
| 3838 | LM_UINT32 j; |
| 3839 | |
| 3840 | for (j = 0; j < 4; j++) { |
| 3841 | REG_WR (pDevice, MacCtrl.MacAddr[j].High, |
| 3842 | (pMacAddress[0] << 8) | pMacAddress[1]); |
| 3843 | REG_WR (pDevice, MacCtrl.MacAddr[j].Low, |
| 3844 | (pMacAddress[2] << 24) | (pMacAddress[3] << 16) | |
| 3845 | (pMacAddress[4] << 8) | pMacAddress[5]); |
| 3846 | } |
| 3847 | |
| 3848 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3849 | } |
| 3850 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3851 | /******************************************************************************/ |
| 3852 | /* Description: */ |
| 3853 | /* Sets up the default line speed, and duplex modes based on the requested */ |
| 3854 | /* media type. */ |
| 3855 | /* */ |
| 3856 | /* Return: */ |
| 3857 | /* None. */ |
| 3858 | /******************************************************************************/ |
| 3859 | static LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3860 | LM_TranslateRequestedMediaType (LM_REQUESTED_MEDIA_TYPE RequestedMediaType, |
| 3861 | PLM_MEDIA_TYPE pMediaType, |
| 3862 | PLM_LINE_SPEED pLineSpeed, |
| 3863 | PLM_DUPLEX_MODE pDuplexMode) |
| 3864 | { |
| 3865 | *pMediaType = LM_MEDIA_TYPE_AUTO; |
| 3866 | *pLineSpeed = LM_LINE_SPEED_UNKNOWN; |
| 3867 | *pDuplexMode = LM_DUPLEX_MODE_UNKNOWN; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3868 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3869 | /* determine media type */ |
| 3870 | switch (RequestedMediaType) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3871 | case LM_REQUESTED_MEDIA_TYPE_BNC: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3872 | *pMediaType = LM_MEDIA_TYPE_BNC; |
| 3873 | *pLineSpeed = LM_LINE_SPEED_10MBPS; |
| 3874 | *pDuplexMode = LM_DUPLEX_MODE_HALF; |
| 3875 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3876 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3877 | case LM_REQUESTED_MEDIA_TYPE_UTP_AUTO: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3878 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3879 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3880 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3881 | case LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3882 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3883 | *pLineSpeed = LM_LINE_SPEED_10MBPS; |
| 3884 | *pDuplexMode = LM_DUPLEX_MODE_HALF; |
| 3885 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3886 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3887 | case LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS_FULL_DUPLEX: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3888 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3889 | *pLineSpeed = LM_LINE_SPEED_10MBPS; |
| 3890 | *pDuplexMode = LM_DUPLEX_MODE_FULL; |
| 3891 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3892 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3893 | case LM_REQUESTED_MEDIA_TYPE_UTP_100MBPS: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3894 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3895 | *pLineSpeed = LM_LINE_SPEED_100MBPS; |
| 3896 | *pDuplexMode = LM_DUPLEX_MODE_HALF; |
| 3897 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3898 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3899 | case LM_REQUESTED_MEDIA_TYPE_UTP_100MBPS_FULL_DUPLEX: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3900 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3901 | *pLineSpeed = LM_LINE_SPEED_100MBPS; |
| 3902 | *pDuplexMode = LM_DUPLEX_MODE_FULL; |
| 3903 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3904 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3905 | case LM_REQUESTED_MEDIA_TYPE_UTP_1000MBPS: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3906 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3907 | *pLineSpeed = LM_LINE_SPEED_1000MBPS; |
| 3908 | *pDuplexMode = LM_DUPLEX_MODE_HALF; |
| 3909 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3910 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3911 | case LM_REQUESTED_MEDIA_TYPE_UTP_1000MBPS_FULL_DUPLEX: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3912 | *pMediaType = LM_MEDIA_TYPE_UTP; |
| 3913 | *pLineSpeed = LM_LINE_SPEED_1000MBPS; |
| 3914 | *pDuplexMode = LM_DUPLEX_MODE_FULL; |
| 3915 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3916 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3917 | case LM_REQUESTED_MEDIA_TYPE_FIBER_100MBPS: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3918 | *pMediaType = LM_MEDIA_TYPE_FIBER; |
| 3919 | *pLineSpeed = LM_LINE_SPEED_100MBPS; |
| 3920 | *pDuplexMode = LM_DUPLEX_MODE_HALF; |
| 3921 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3922 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3923 | case LM_REQUESTED_MEDIA_TYPE_FIBER_100MBPS_FULL_DUPLEX: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3924 | *pMediaType = LM_MEDIA_TYPE_FIBER; |
| 3925 | *pLineSpeed = LM_LINE_SPEED_100MBPS; |
| 3926 | *pDuplexMode = LM_DUPLEX_MODE_FULL; |
| 3927 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3928 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3929 | case LM_REQUESTED_MEDIA_TYPE_FIBER_1000MBPS: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3930 | *pMediaType = LM_MEDIA_TYPE_FIBER; |
| 3931 | *pLineSpeed = LM_LINE_SPEED_1000MBPS; |
| 3932 | *pDuplexMode = LM_DUPLEX_MODE_HALF; |
| 3933 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3934 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3935 | case LM_REQUESTED_MEDIA_TYPE_FIBER_1000MBPS_FULL_DUPLEX: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3936 | *pMediaType = LM_MEDIA_TYPE_FIBER; |
| 3937 | *pLineSpeed = LM_LINE_SPEED_1000MBPS; |
| 3938 | *pDuplexMode = LM_DUPLEX_MODE_FULL; |
| 3939 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3940 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3941 | default: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3942 | break; |
| 3943 | } /* switch */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3944 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3945 | return LM_STATUS_SUCCESS; |
| 3946 | } /* LM_TranslateRequestedMediaType */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3947 | |
| 3948 | /******************************************************************************/ |
| 3949 | /* Description: */ |
| 3950 | /* */ |
| 3951 | /* Return: */ |
| 3952 | /* LM_STATUS_LINK_ACTIVE */ |
| 3953 | /* LM_STATUS_LINK_DOWN */ |
| 3954 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3955 | static LM_STATUS LM_InitBcm540xPhy (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3956 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3957 | LM_LINE_SPEED CurrentLineSpeed; |
| 3958 | LM_DUPLEX_MODE CurrentDuplexMode; |
| 3959 | LM_STATUS CurrentLinkStatus; |
| 3960 | LM_UINT32 Value32; |
| 3961 | LM_UINT32 j; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3962 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3963 | #if 1 /* jmb: bugfix -- moved here, out of code that sets initial pwr state */ |
| 3964 | LM_WritePhy (pDevice, BCM5401_AUX_CTRL, 0x2); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3965 | #endif |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3966 | if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5401_PHY_ID) { |
| 3967 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 3968 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3969 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3970 | if (!pDevice->InitDone) { |
| 3971 | Value32 = 0; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 3972 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3973 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3974 | if (!(Value32 & PHY_STATUS_LINK_PASS)) { |
| 3975 | LM_WritePhy (pDevice, BCM5401_AUX_CTRL, 0x0c20); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3976 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 3977 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x0012); |
| 3978 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x1804); |
| 3979 | |
| 3980 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x0013); |
| 3981 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x1204); |
| 3982 | |
| 3983 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x8006); |
| 3984 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x0132); |
| 3985 | |
| 3986 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x8006); |
| 3987 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x0232); |
| 3988 | |
| 3989 | LM_WritePhy (pDevice, BCM540X_DSP_ADDRESS_REG, 0x201f); |
| 3990 | LM_WritePhy (pDevice, BCM540X_DSP_RW_PORT, 0x0a20); |
| 3991 | |
| 3992 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 3993 | for (j = 0; j < 1000; j++) { |
| 3994 | MM_Wait (10); |
| 3995 | |
| 3996 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 3997 | if (Value32 & PHY_STATUS_LINK_PASS) { |
| 3998 | MM_Wait (40); |
| 3999 | break; |
| 4000 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4001 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4002 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4003 | if ((pDevice->PhyId & PHY_ID_REV_MASK) == |
| 4004 | PHY_BCM5401_B0_REV) { |
| 4005 | if (!(Value32 & PHY_STATUS_LINK_PASS) |
| 4006 | && (pDevice->OldLineSpeed == |
| 4007 | LM_LINE_SPEED_1000MBPS)) { |
| 4008 | LM_WritePhy (pDevice, PHY_CTRL_REG, |
| 4009 | PHY_CTRL_PHY_RESET); |
| 4010 | for (j = 0; j < 100; j++) { |
| 4011 | MM_Wait (10); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4012 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4013 | LM_ReadPhy (pDevice, |
| 4014 | PHY_CTRL_REG, |
| 4015 | &Value32); |
| 4016 | if (! |
| 4017 | (Value32 & |
| 4018 | PHY_CTRL_PHY_RESET)) { |
| 4019 | MM_Wait (40); |
| 4020 | break; |
| 4021 | } |
| 4022 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4023 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4024 | LM_WritePhy (pDevice, BCM5401_AUX_CTRL, |
| 4025 | 0x0c20); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4026 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4027 | LM_WritePhy (pDevice, |
| 4028 | BCM540X_DSP_ADDRESS_REG, |
| 4029 | 0x0012); |
| 4030 | LM_WritePhy (pDevice, |
| 4031 | BCM540X_DSP_RW_PORT, |
| 4032 | 0x1804); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4033 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4034 | LM_WritePhy (pDevice, |
| 4035 | BCM540X_DSP_ADDRESS_REG, |
| 4036 | 0x0013); |
| 4037 | LM_WritePhy (pDevice, |
| 4038 | BCM540X_DSP_RW_PORT, |
| 4039 | 0x1204); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4040 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4041 | LM_WritePhy (pDevice, |
| 4042 | BCM540X_DSP_ADDRESS_REG, |
| 4043 | 0x8006); |
| 4044 | LM_WritePhy (pDevice, |
| 4045 | BCM540X_DSP_RW_PORT, |
| 4046 | 0x0132); |
| 4047 | |
| 4048 | LM_WritePhy (pDevice, |
| 4049 | BCM540X_DSP_ADDRESS_REG, |
| 4050 | 0x8006); |
| 4051 | LM_WritePhy (pDevice, |
| 4052 | BCM540X_DSP_RW_PORT, |
| 4053 | 0x0232); |
| 4054 | |
| 4055 | LM_WritePhy (pDevice, |
| 4056 | BCM540X_DSP_ADDRESS_REG, |
| 4057 | 0x201f); |
| 4058 | LM_WritePhy (pDevice, |
| 4059 | BCM540X_DSP_RW_PORT, |
| 4060 | 0x0a20); |
| 4061 | } |
| 4062 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4063 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4064 | } else if (pDevice->ChipRevId == T3_CHIP_ID_5701_A0 || |
| 4065 | pDevice->ChipRevId == T3_CHIP_ID_5701_B0) { |
| 4066 | /* Bug: 5701 A0, B0 TX CRC workaround. */ |
| 4067 | LM_WritePhy (pDevice, 0x15, 0x0a75); |
| 4068 | LM_WritePhy (pDevice, 0x1c, 0x8c68); |
| 4069 | LM_WritePhy (pDevice, 0x1c, 0x8d68); |
| 4070 | LM_WritePhy (pDevice, 0x1c, 0x8c68); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4071 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4072 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4073 | /* Acknowledge interrupts. */ |
| 4074 | LM_ReadPhy (pDevice, BCM540X_INT_STATUS_REG, &Value32); |
| 4075 | LM_ReadPhy (pDevice, BCM540X_INT_STATUS_REG, &Value32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4076 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4077 | /* Configure the interrupt mask. */ |
| 4078 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_MI_INTERRUPT) { |
| 4079 | LM_WritePhy (pDevice, BCM540X_INT_MASK_REG, |
| 4080 | ~BCM540X_INT_LINK_CHANGE); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4081 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4082 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4083 | /* Configure PHY led mode. */ |
| 4084 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701 || |
| 4085 | (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700)) { |
| 4086 | if (pDevice->LedMode == LED_MODE_THREE_LINK) { |
| 4087 | LM_WritePhy (pDevice, BCM540X_EXT_CTRL_REG, |
| 4088 | BCM540X_EXT_CTRL_LINK3_LED_MODE); |
| 4089 | } else { |
| 4090 | LM_WritePhy (pDevice, BCM540X_EXT_CTRL_REG, 0); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4091 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4092 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4093 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4094 | CurrentLinkStatus = LM_STATUS_LINK_DOWN; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4095 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4096 | /* Get current link and duplex mode. */ |
| 4097 | for (j = 0; j < 100; j++) { |
| 4098 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 4099 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 4100 | |
| 4101 | if (Value32 & PHY_STATUS_LINK_PASS) { |
| 4102 | break; |
| 4103 | } |
| 4104 | MM_Wait (40); |
| 4105 | } |
| 4106 | |
| 4107 | if (Value32 & PHY_STATUS_LINK_PASS) { |
| 4108 | |
| 4109 | /* Determine the current line and duplex settings. */ |
| 4110 | LM_ReadPhy (pDevice, BCM540X_AUX_STATUS_REG, &Value32); |
| 4111 | for (j = 0; j < 2000; j++) { |
| 4112 | MM_Wait (10); |
| 4113 | |
| 4114 | LM_ReadPhy (pDevice, BCM540X_AUX_STATUS_REG, &Value32); |
| 4115 | if (Value32) { |
| 4116 | break; |
| 4117 | } |
| 4118 | } |
| 4119 | |
| 4120 | switch (Value32 & BCM540X_AUX_SPEED_MASK) { |
| 4121 | case BCM540X_AUX_10BASET_HD: |
| 4122 | CurrentLineSpeed = LM_LINE_SPEED_10MBPS; |
| 4123 | CurrentDuplexMode = LM_DUPLEX_MODE_HALF; |
| 4124 | break; |
| 4125 | |
| 4126 | case BCM540X_AUX_10BASET_FD: |
| 4127 | CurrentLineSpeed = LM_LINE_SPEED_10MBPS; |
| 4128 | CurrentDuplexMode = LM_DUPLEX_MODE_FULL; |
| 4129 | break; |
| 4130 | |
| 4131 | case BCM540X_AUX_100BASETX_HD: |
| 4132 | CurrentLineSpeed = LM_LINE_SPEED_100MBPS; |
| 4133 | CurrentDuplexMode = LM_DUPLEX_MODE_HALF; |
| 4134 | break; |
| 4135 | |
| 4136 | case BCM540X_AUX_100BASETX_FD: |
| 4137 | CurrentLineSpeed = LM_LINE_SPEED_100MBPS; |
| 4138 | CurrentDuplexMode = LM_DUPLEX_MODE_FULL; |
| 4139 | break; |
| 4140 | |
| 4141 | case BCM540X_AUX_100BASET_HD: |
| 4142 | CurrentLineSpeed = LM_LINE_SPEED_1000MBPS; |
| 4143 | CurrentDuplexMode = LM_DUPLEX_MODE_HALF; |
| 4144 | break; |
| 4145 | |
| 4146 | case BCM540X_AUX_100BASET_FD: |
| 4147 | CurrentLineSpeed = LM_LINE_SPEED_1000MBPS; |
| 4148 | CurrentDuplexMode = LM_DUPLEX_MODE_FULL; |
| 4149 | break; |
| 4150 | |
| 4151 | default: |
| 4152 | |
| 4153 | CurrentLineSpeed = LM_LINE_SPEED_UNKNOWN; |
| 4154 | CurrentDuplexMode = LM_DUPLEX_MODE_UNKNOWN; |
| 4155 | break; |
| 4156 | } |
| 4157 | |
| 4158 | /* Make sure we are in auto-neg mode. */ |
| 4159 | for (j = 0; j < 200; j++) { |
| 4160 | LM_ReadPhy (pDevice, PHY_CTRL_REG, &Value32); |
| 4161 | if (Value32 && Value32 != 0x7fff) { |
| 4162 | break; |
| 4163 | } |
| 4164 | |
| 4165 | if (Value32 == 0 && pDevice->RequestedMediaType == |
| 4166 | LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS) { |
| 4167 | break; |
| 4168 | } |
| 4169 | |
| 4170 | MM_Wait (10); |
| 4171 | } |
| 4172 | |
| 4173 | /* Use the current line settings for "auto" mode. */ |
| 4174 | if (pDevice->RequestedMediaType == LM_REQUESTED_MEDIA_TYPE_AUTO |
| 4175 | || pDevice->RequestedMediaType == |
| 4176 | LM_REQUESTED_MEDIA_TYPE_UTP_AUTO) { |
| 4177 | if (Value32 & PHY_CTRL_AUTO_NEG_ENABLE) { |
| 4178 | CurrentLinkStatus = LM_STATUS_LINK_ACTIVE; |
| 4179 | |
| 4180 | /* We may be exiting low power mode and the link is in */ |
| 4181 | /* 10mb. In this case, we need to restart autoneg. */ |
| 4182 | LM_ReadPhy (pDevice, BCM540X_1000BASET_CTRL_REG, |
| 4183 | &Value32); |
| 4184 | pDevice->advertising1000 = Value32; |
| 4185 | /* 5702FE supports 10/100Mb only. */ |
| 4186 | if (T3_ASIC_REV (pDevice->ChipRevId) != |
| 4187 | T3_ASIC_REV_5703 |
| 4188 | || pDevice->BondId != |
| 4189 | GRC_MISC_BD_ID_5702FE) { |
| 4190 | if (! |
| 4191 | (Value32 & |
| 4192 | (BCM540X_AN_AD_1000BASET_HALF | |
| 4193 | BCM540X_AN_AD_1000BASET_FULL))) { |
| 4194 | CurrentLinkStatus = |
| 4195 | LM_STATUS_LINK_SETTING_MISMATCH; |
| 4196 | } |
| 4197 | } |
| 4198 | } else { |
| 4199 | CurrentLinkStatus = |
| 4200 | LM_STATUS_LINK_SETTING_MISMATCH; |
| 4201 | } |
| 4202 | } else { |
| 4203 | /* Force line settings. */ |
| 4204 | /* Use the current setting if it matches the user's requested */ |
| 4205 | /* setting. */ |
| 4206 | LM_ReadPhy (pDevice, PHY_CTRL_REG, &Value32); |
| 4207 | if ((pDevice->LineSpeed == CurrentLineSpeed) && |
| 4208 | (pDevice->DuplexMode == CurrentDuplexMode)) { |
| 4209 | if ((pDevice->DisableAutoNeg && |
| 4210 | !(Value32 & PHY_CTRL_AUTO_NEG_ENABLE)) || |
| 4211 | (!pDevice->DisableAutoNeg && |
| 4212 | (Value32 & PHY_CTRL_AUTO_NEG_ENABLE))) { |
| 4213 | CurrentLinkStatus = |
| 4214 | LM_STATUS_LINK_ACTIVE; |
| 4215 | } else { |
| 4216 | CurrentLinkStatus = |
| 4217 | LM_STATUS_LINK_SETTING_MISMATCH; |
| 4218 | } |
| 4219 | } else { |
| 4220 | CurrentLinkStatus = |
| 4221 | LM_STATUS_LINK_SETTING_MISMATCH; |
| 4222 | } |
| 4223 | } |
| 4224 | |
| 4225 | /* Save line settings. */ |
| 4226 | pDevice->LineSpeed = CurrentLineSpeed; |
| 4227 | pDevice->DuplexMode = CurrentDuplexMode; |
| 4228 | pDevice->MediaType = LM_MEDIA_TYPE_UTP; |
| 4229 | } |
| 4230 | |
| 4231 | return CurrentLinkStatus; |
| 4232 | } /* LM_InitBcm540xPhy */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4233 | |
| 4234 | /******************************************************************************/ |
| 4235 | /* Description: */ |
| 4236 | /* */ |
| 4237 | /* Return: */ |
| 4238 | /******************************************************************************/ |
| 4239 | LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4240 | LM_SetFlowControl (PLM_DEVICE_BLOCK pDevice, |
| 4241 | LM_UINT32 LocalPhyAd, LM_UINT32 RemotePhyAd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4242 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4243 | LM_FLOW_CONTROL FlowCap; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4244 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4245 | /* Resolve flow control. */ |
| 4246 | FlowCap = LM_FLOW_CONTROL_NONE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4247 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4248 | /* See Table 28B-3 of 802.3ab-1999 spec. */ |
| 4249 | if (pDevice->FlowControlCap & LM_FLOW_CONTROL_AUTO_PAUSE) { |
| 4250 | if (LocalPhyAd & PHY_AN_AD_PAUSE_CAPABLE) { |
| 4251 | if (LocalPhyAd & PHY_AN_AD_ASYM_PAUSE) { |
| 4252 | if (RemotePhyAd & |
| 4253 | PHY_LINK_PARTNER_PAUSE_CAPABLE) { |
| 4254 | FlowCap = |
| 4255 | LM_FLOW_CONTROL_TRANSMIT_PAUSE | |
| 4256 | LM_FLOW_CONTROL_RECEIVE_PAUSE; |
| 4257 | } else if (RemotePhyAd & |
| 4258 | PHY_LINK_PARTNER_ASYM_PAUSE) { |
| 4259 | FlowCap = LM_FLOW_CONTROL_RECEIVE_PAUSE; |
| 4260 | } |
| 4261 | } else { |
| 4262 | if (RemotePhyAd & |
| 4263 | PHY_LINK_PARTNER_PAUSE_CAPABLE) { |
| 4264 | FlowCap = |
| 4265 | LM_FLOW_CONTROL_TRANSMIT_PAUSE | |
| 4266 | LM_FLOW_CONTROL_RECEIVE_PAUSE; |
| 4267 | } |
| 4268 | } |
| 4269 | } else if (LocalPhyAd & PHY_AN_AD_ASYM_PAUSE) { |
| 4270 | if ((RemotePhyAd & PHY_LINK_PARTNER_PAUSE_CAPABLE) && |
| 4271 | (RemotePhyAd & PHY_LINK_PARTNER_ASYM_PAUSE)) { |
| 4272 | FlowCap = LM_FLOW_CONTROL_TRANSMIT_PAUSE; |
| 4273 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4274 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4275 | } else { |
| 4276 | FlowCap = pDevice->FlowControlCap; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4277 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4278 | |
| 4279 | /* Enable/disable rx PAUSE. */ |
| 4280 | pDevice->RxMode &= ~RX_MODE_ENABLE_FLOW_CONTROL; |
| 4281 | if (FlowCap & LM_FLOW_CONTROL_RECEIVE_PAUSE && |
| 4282 | (pDevice->FlowControlCap == LM_FLOW_CONTROL_AUTO_PAUSE || |
| 4283 | pDevice->FlowControlCap & LM_FLOW_CONTROL_RECEIVE_PAUSE)) { |
| 4284 | pDevice->FlowControl |= LM_FLOW_CONTROL_RECEIVE_PAUSE; |
| 4285 | pDevice->RxMode |= RX_MODE_ENABLE_FLOW_CONTROL; |
| 4286 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4287 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4288 | REG_WR (pDevice, MacCtrl.RxMode, pDevice->RxMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4289 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4290 | /* Enable/disable tx PAUSE. */ |
| 4291 | pDevice->TxMode &= ~TX_MODE_ENABLE_FLOW_CONTROL; |
| 4292 | if (FlowCap & LM_FLOW_CONTROL_TRANSMIT_PAUSE && |
| 4293 | (pDevice->FlowControlCap == LM_FLOW_CONTROL_AUTO_PAUSE || |
| 4294 | pDevice->FlowControlCap & LM_FLOW_CONTROL_TRANSMIT_PAUSE)) { |
| 4295 | pDevice->FlowControl |= LM_FLOW_CONTROL_TRANSMIT_PAUSE; |
| 4296 | pDevice->TxMode |= TX_MODE_ENABLE_FLOW_CONTROL; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4297 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4298 | } |
| 4299 | REG_WR (pDevice, MacCtrl.TxMode, pDevice->TxMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4300 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4301 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4302 | } |
| 4303 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4304 | #if INCLUDE_TBI_SUPPORT |
| 4305 | /******************************************************************************/ |
| 4306 | /* Description: */ |
| 4307 | /* */ |
| 4308 | /* Return: */ |
| 4309 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4310 | STATIC LM_STATUS LM_InitBcm800xPhy (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4311 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4312 | LM_UINT32 Value32; |
| 4313 | LM_UINT32 j; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4314 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4315 | Value32 = REG_RD (pDevice, MacCtrl.Status); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4316 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4317 | /* Reset the SERDES during init and when we have link. */ |
| 4318 | if (!pDevice->InitDone || Value32 & MAC_STATUS_PCS_SYNCED) { |
| 4319 | /* Set PLL lock range. */ |
| 4320 | LM_WritePhy (pDevice, 0x16, 0x8007); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4321 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4322 | /* Software reset. */ |
| 4323 | LM_WritePhy (pDevice, 0x00, 0x8000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4324 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4325 | /* Wait for reset to complete. */ |
| 4326 | for (j = 0; j < 500; j++) { |
| 4327 | MM_Wait (10); |
| 4328 | } |
| 4329 | |
| 4330 | /* Config mode; seletct PMA/Ch 1 regs. */ |
| 4331 | LM_WritePhy (pDevice, 0x10, 0x8411); |
| 4332 | |
| 4333 | /* Enable auto-lock and comdet, select txclk for tx. */ |
| 4334 | LM_WritePhy (pDevice, 0x11, 0x0a10); |
| 4335 | |
| 4336 | LM_WritePhy (pDevice, 0x18, 0x00a0); |
| 4337 | LM_WritePhy (pDevice, 0x16, 0x41ff); |
| 4338 | |
| 4339 | /* Assert and deassert POR. */ |
| 4340 | LM_WritePhy (pDevice, 0x13, 0x0400); |
| 4341 | MM_Wait (40); |
| 4342 | LM_WritePhy (pDevice, 0x13, 0x0000); |
| 4343 | |
| 4344 | LM_WritePhy (pDevice, 0x11, 0x0a50); |
| 4345 | MM_Wait (40); |
| 4346 | LM_WritePhy (pDevice, 0x11, 0x0a10); |
| 4347 | |
| 4348 | /* Delay for signal to stabilize. */ |
| 4349 | for (j = 0; j < 15000; j++) { |
| 4350 | MM_Wait (10); |
| 4351 | } |
| 4352 | |
| 4353 | /* Deselect the channel register so we can read the PHY id later. */ |
| 4354 | LM_WritePhy (pDevice, 0x10, 0x8011); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4355 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4356 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4357 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4358 | } |
| 4359 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4360 | /******************************************************************************/ |
| 4361 | /* Description: */ |
| 4362 | /* */ |
| 4363 | /* Return: */ |
| 4364 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4365 | STATIC LM_STATUS LM_SetupFiberPhy (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4366 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4367 | LM_STATUS CurrentLinkStatus; |
| 4368 | AUTONEG_STATUS AnStatus = 0; |
| 4369 | LM_UINT32 Value32; |
| 4370 | LM_UINT32 Cnt; |
| 4371 | LM_UINT32 j, k; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4372 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4373 | pDevice->MacMode &= ~(MAC_MODE_HALF_DUPLEX | MAC_MODE_PORT_MODE_MASK); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4374 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4375 | /* Initialize the send_config register. */ |
| 4376 | REG_WR (pDevice, MacCtrl.TxAutoNeg, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4377 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4378 | /* Enable TBI and full duplex mode. */ |
| 4379 | pDevice->MacMode |= MAC_MODE_PORT_MODE_TBI; |
| 4380 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4381 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4382 | /* Initialize the BCM8002 SERDES PHY. */ |
| 4383 | switch (pDevice->PhyId & PHY_ID_MASK) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4384 | case PHY_BCM8002_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4385 | LM_InitBcm800xPhy (pDevice); |
| 4386 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4387 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4388 | default: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4389 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4390 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4391 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4392 | /* Enable link change interrupt. */ |
| 4393 | REG_WR (pDevice, MacCtrl.MacEvent, |
| 4394 | MAC_EVENT_ENABLE_LINK_STATE_CHANGED_ATTN); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4395 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4396 | /* Default to link down. */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4397 | CurrentLinkStatus = LM_STATUS_LINK_DOWN; |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4398 | |
| 4399 | /* Get the link status. */ |
| 4400 | Value32 = REG_RD (pDevice, MacCtrl.Status); |
| 4401 | if (Value32 & MAC_STATUS_PCS_SYNCED) { |
| 4402 | if ((pDevice->RequestedMediaType == |
| 4403 | LM_REQUESTED_MEDIA_TYPE_AUTO) |
| 4404 | || (pDevice->DisableAutoNeg == FALSE)) { |
| 4405 | /* auto-negotiation mode. */ |
| 4406 | /* Initialize the autoneg default capaiblities. */ |
| 4407 | AutonegInit (&pDevice->AnInfo); |
| 4408 | |
| 4409 | /* Set the context pointer to point to the main device structure. */ |
| 4410 | pDevice->AnInfo.pContext = pDevice; |
| 4411 | |
| 4412 | /* Setup flow control advertisement register. */ |
| 4413 | Value32 = GetPhyAdFlowCntrlSettings (pDevice); |
| 4414 | if (Value32 & PHY_AN_AD_PAUSE_CAPABLE) { |
| 4415 | pDevice->AnInfo.mr_adv_sym_pause = 1; |
| 4416 | } else { |
| 4417 | pDevice->AnInfo.mr_adv_sym_pause = 0; |
| 4418 | } |
| 4419 | |
| 4420 | if (Value32 & PHY_AN_AD_ASYM_PAUSE) { |
| 4421 | pDevice->AnInfo.mr_adv_asym_pause = 1; |
| 4422 | } else { |
| 4423 | pDevice->AnInfo.mr_adv_asym_pause = 0; |
| 4424 | } |
| 4425 | |
| 4426 | /* Try to autoneg up to six times. */ |
| 4427 | if (pDevice->IgnoreTbiLinkChange) { |
| 4428 | Cnt = 1; |
| 4429 | } else { |
| 4430 | Cnt = 6; |
| 4431 | } |
| 4432 | for (j = 0; j < Cnt; j++) { |
| 4433 | REG_WR (pDevice, MacCtrl.TxAutoNeg, 0); |
| 4434 | |
| 4435 | Value32 = |
| 4436 | pDevice->MacMode & ~MAC_MODE_PORT_MODE_MASK; |
| 4437 | REG_WR (pDevice, MacCtrl.Mode, Value32); |
| 4438 | MM_Wait (20); |
| 4439 | |
| 4440 | REG_WR (pDevice, MacCtrl.Mode, |
| 4441 | pDevice-> |
| 4442 | MacMode | MAC_MODE_SEND_CONFIGS); |
| 4443 | |
| 4444 | MM_Wait (20); |
| 4445 | |
| 4446 | pDevice->AnInfo.State = AN_STATE_UNKNOWN; |
| 4447 | pDevice->AnInfo.CurrentTime_us = 0; |
| 4448 | |
| 4449 | REG_WR (pDevice, Grc.Timer, 0); |
| 4450 | for (k = 0; |
| 4451 | (pDevice->AnInfo.CurrentTime_us < 75000) |
| 4452 | && (k < 75000); k++) { |
| 4453 | AnStatus = |
| 4454 | Autoneg8023z (&pDevice->AnInfo); |
| 4455 | |
| 4456 | if ((AnStatus == AUTONEG_STATUS_DONE) || |
| 4457 | (AnStatus == AUTONEG_STATUS_FAILED)) |
| 4458 | { |
| 4459 | break; |
| 4460 | } |
| 4461 | |
| 4462 | pDevice->AnInfo.CurrentTime_us = |
| 4463 | REG_RD (pDevice, Grc.Timer); |
| 4464 | |
| 4465 | } |
| 4466 | if ((AnStatus == AUTONEG_STATUS_DONE) || |
| 4467 | (AnStatus == AUTONEG_STATUS_FAILED)) { |
| 4468 | break; |
| 4469 | } |
| 4470 | if (j >= 1) { |
| 4471 | if (!(REG_RD (pDevice, MacCtrl.Status) & |
| 4472 | MAC_STATUS_PCS_SYNCED)) { |
| 4473 | break; |
| 4474 | } |
| 4475 | } |
| 4476 | } |
| 4477 | |
| 4478 | /* Stop sending configs. */ |
| 4479 | MM_AnTxIdle (&pDevice->AnInfo); |
| 4480 | |
| 4481 | /* Resolve flow control settings. */ |
| 4482 | if ((AnStatus == AUTONEG_STATUS_DONE) && |
| 4483 | pDevice->AnInfo.mr_an_complete |
| 4484 | && pDevice->AnInfo.mr_link_ok |
| 4485 | && pDevice->AnInfo.mr_lp_adv_full_duplex) { |
| 4486 | LM_UINT32 RemotePhyAd; |
| 4487 | LM_UINT32 LocalPhyAd; |
| 4488 | |
| 4489 | LocalPhyAd = 0; |
| 4490 | if (pDevice->AnInfo.mr_adv_sym_pause) { |
| 4491 | LocalPhyAd |= PHY_AN_AD_PAUSE_CAPABLE; |
| 4492 | } |
| 4493 | |
| 4494 | if (pDevice->AnInfo.mr_adv_asym_pause) { |
| 4495 | LocalPhyAd |= PHY_AN_AD_ASYM_PAUSE; |
| 4496 | } |
| 4497 | |
| 4498 | RemotePhyAd = 0; |
| 4499 | if (pDevice->AnInfo.mr_lp_adv_sym_pause) { |
| 4500 | RemotePhyAd |= |
| 4501 | PHY_LINK_PARTNER_PAUSE_CAPABLE; |
| 4502 | } |
| 4503 | |
| 4504 | if (pDevice->AnInfo.mr_lp_adv_asym_pause) { |
| 4505 | RemotePhyAd |= |
| 4506 | PHY_LINK_PARTNER_ASYM_PAUSE; |
| 4507 | } |
| 4508 | |
| 4509 | LM_SetFlowControl (pDevice, LocalPhyAd, |
| 4510 | RemotePhyAd); |
| 4511 | |
| 4512 | CurrentLinkStatus = LM_STATUS_LINK_ACTIVE; |
| 4513 | } |
| 4514 | for (j = 0; j < 30; j++) { |
| 4515 | MM_Wait (20); |
| 4516 | REG_WR (pDevice, MacCtrl.Status, |
| 4517 | MAC_STATUS_SYNC_CHANGED | |
| 4518 | MAC_STATUS_CFG_CHANGED); |
| 4519 | MM_Wait (20); |
| 4520 | if ((REG_RD (pDevice, MacCtrl.Status) & |
| 4521 | (MAC_STATUS_SYNC_CHANGED | |
| 4522 | MAC_STATUS_CFG_CHANGED)) == 0) |
| 4523 | break; |
| 4524 | } |
| 4525 | if (pDevice->PollTbiLink) { |
| 4526 | Value32 = REG_RD (pDevice, MacCtrl.Status); |
| 4527 | if (Value32 & MAC_STATUS_RECEIVING_CFG) { |
| 4528 | pDevice->IgnoreTbiLinkChange = TRUE; |
| 4529 | } else { |
| 4530 | pDevice->IgnoreTbiLinkChange = FALSE; |
| 4531 | } |
| 4532 | } |
| 4533 | Value32 = REG_RD (pDevice, MacCtrl.Status); |
| 4534 | if (CurrentLinkStatus == LM_STATUS_LINK_DOWN && |
| 4535 | (Value32 & MAC_STATUS_PCS_SYNCED) && |
| 4536 | ((Value32 & MAC_STATUS_RECEIVING_CFG) == 0)) { |
| 4537 | CurrentLinkStatus = LM_STATUS_LINK_ACTIVE; |
| 4538 | } |
| 4539 | } else { |
| 4540 | /* We are forcing line speed. */ |
| 4541 | pDevice->FlowControlCap &= ~LM_FLOW_CONTROL_AUTO_PAUSE; |
| 4542 | LM_SetFlowControl (pDevice, 0, 0); |
| 4543 | |
| 4544 | CurrentLinkStatus = LM_STATUS_LINK_ACTIVE; |
| 4545 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode | |
| 4546 | MAC_MODE_SEND_CONFIGS); |
| 4547 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4548 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4549 | /* Set the link polarity bit. */ |
| 4550 | pDevice->MacMode &= ~MAC_MODE_LINK_POLARITY; |
| 4551 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4552 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4553 | pDevice->pStatusBlkVirt->Status = STATUS_BLOCK_UPDATED | |
| 4554 | (pDevice->pStatusBlkVirt-> |
| 4555 | Status & ~STATUS_BLOCK_LINK_CHANGED_STATUS); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4556 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4557 | for (j = 0; j < 100; j++) { |
| 4558 | REG_WR (pDevice, MacCtrl.Status, MAC_STATUS_SYNC_CHANGED | |
| 4559 | MAC_STATUS_CFG_CHANGED); |
| 4560 | MM_Wait (5); |
| 4561 | if ((REG_RD (pDevice, MacCtrl.Status) & |
| 4562 | (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED)) == 0) |
| 4563 | break; |
| 4564 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4565 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4566 | Value32 = REG_RD (pDevice, MacCtrl.Status); |
| 4567 | if ((Value32 & MAC_STATUS_PCS_SYNCED) == 0) { |
| 4568 | CurrentLinkStatus = LM_STATUS_LINK_DOWN; |
| 4569 | if (pDevice->DisableAutoNeg == FALSE) { |
| 4570 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode | |
| 4571 | MAC_MODE_SEND_CONFIGS); |
| 4572 | MM_Wait (1); |
| 4573 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode); |
| 4574 | } |
| 4575 | } |
| 4576 | |
| 4577 | /* Initialize the current link status. */ |
| 4578 | if (CurrentLinkStatus == LM_STATUS_LINK_ACTIVE) { |
| 4579 | pDevice->LineSpeed = LM_LINE_SPEED_1000MBPS; |
| 4580 | pDevice->DuplexMode = LM_DUPLEX_MODE_FULL; |
| 4581 | REG_WR (pDevice, MacCtrl.LedCtrl, LED_CTRL_OVERRIDE_LINK_LED | |
| 4582 | LED_CTRL_1000MBPS_LED_ON); |
| 4583 | } else { |
| 4584 | pDevice->LineSpeed = LM_LINE_SPEED_UNKNOWN; |
| 4585 | pDevice->DuplexMode = LM_DUPLEX_MODE_UNKNOWN; |
| 4586 | REG_WR (pDevice, MacCtrl.LedCtrl, LED_CTRL_OVERRIDE_LINK_LED | |
| 4587 | LED_CTRL_OVERRIDE_TRAFFIC_LED); |
| 4588 | } |
| 4589 | |
| 4590 | /* Indicate link status. */ |
| 4591 | if (pDevice->LinkStatus != CurrentLinkStatus) { |
| 4592 | pDevice->LinkStatus = CurrentLinkStatus; |
| 4593 | MM_IndicateStatus (pDevice, CurrentLinkStatus); |
| 4594 | } |
| 4595 | |
| 4596 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4597 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4598 | #endif /* INCLUDE_TBI_SUPPORT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4599 | |
| 4600 | /******************************************************************************/ |
| 4601 | /* Description: */ |
| 4602 | /* */ |
| 4603 | /* Return: */ |
| 4604 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4605 | LM_STATUS LM_SetupCopperPhy (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4606 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4607 | LM_STATUS CurrentLinkStatus; |
| 4608 | LM_UINT32 Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4609 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4610 | /* Assume there is not link first. */ |
| 4611 | CurrentLinkStatus = LM_STATUS_LINK_DOWN; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4612 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4613 | /* Disable phy link change attention. */ |
| 4614 | REG_WR (pDevice, MacCtrl.MacEvent, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4615 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4616 | /* Clear link change attention. */ |
| 4617 | REG_WR (pDevice, MacCtrl.Status, MAC_STATUS_SYNC_CHANGED | |
| 4618 | MAC_STATUS_CFG_CHANGED); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4619 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4620 | /* Disable auto-polling for the moment. */ |
| 4621 | pDevice->MiMode = 0xc0000; |
| 4622 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode); |
| 4623 | MM_Wait (40); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4624 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4625 | /* Determine the requested line speed and duplex. */ |
| 4626 | pDevice->OldLineSpeed = pDevice->LineSpeed; |
| 4627 | LM_TranslateRequestedMediaType (pDevice->RequestedMediaType, |
| 4628 | &pDevice->MediaType, |
| 4629 | &pDevice->LineSpeed, |
| 4630 | &pDevice->DuplexMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4631 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4632 | /* Initialize the phy chip. */ |
| 4633 | switch (pDevice->PhyId & PHY_ID_MASK) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4634 | case PHY_BCM5400_PHY_ID: |
| 4635 | case PHY_BCM5401_PHY_ID: |
| 4636 | case PHY_BCM5411_PHY_ID: |
| 4637 | case PHY_BCM5701_PHY_ID: |
| 4638 | case PHY_BCM5703_PHY_ID: |
| 4639 | case PHY_BCM5704_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4640 | CurrentLinkStatus = LM_InitBcm540xPhy (pDevice); |
| 4641 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4642 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4643 | default: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4644 | break; |
| 4645 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4646 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4647 | if (CurrentLinkStatus == LM_STATUS_LINK_SETTING_MISMATCH) { |
| 4648 | CurrentLinkStatus = LM_STATUS_LINK_DOWN; |
| 4649 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4650 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4651 | /* Setup flow control. */ |
| 4652 | pDevice->FlowControl = LM_FLOW_CONTROL_NONE; |
| 4653 | if (CurrentLinkStatus == LM_STATUS_LINK_ACTIVE) { |
| 4654 | LM_FLOW_CONTROL FlowCap; /* Flow control capability. */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4655 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4656 | FlowCap = LM_FLOW_CONTROL_NONE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4657 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4658 | if (pDevice->DuplexMode == LM_DUPLEX_MODE_FULL) { |
| 4659 | if (pDevice->DisableAutoNeg == FALSE || |
| 4660 | pDevice->RequestedMediaType == |
| 4661 | LM_REQUESTED_MEDIA_TYPE_AUTO |
| 4662 | || pDevice->RequestedMediaType == |
| 4663 | LM_REQUESTED_MEDIA_TYPE_UTP_AUTO) { |
| 4664 | LM_UINT32 ExpectedPhyAd; |
| 4665 | LM_UINT32 LocalPhyAd; |
| 4666 | LM_UINT32 RemotePhyAd; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4667 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4668 | LM_ReadPhy (pDevice, PHY_AN_AD_REG, |
| 4669 | &LocalPhyAd); |
| 4670 | pDevice->advertising = LocalPhyAd; |
| 4671 | LocalPhyAd &= |
| 4672 | (PHY_AN_AD_ASYM_PAUSE | |
| 4673 | PHY_AN_AD_PAUSE_CAPABLE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4674 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4675 | ExpectedPhyAd = |
| 4676 | GetPhyAdFlowCntrlSettings (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4677 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4678 | if (LocalPhyAd != ExpectedPhyAd) { |
| 4679 | CurrentLinkStatus = LM_STATUS_LINK_DOWN; |
| 4680 | } else { |
| 4681 | LM_ReadPhy (pDevice, |
| 4682 | PHY_LINK_PARTNER_ABILITY_REG, |
| 4683 | &RemotePhyAd); |
| 4684 | |
| 4685 | LM_SetFlowControl (pDevice, LocalPhyAd, |
| 4686 | RemotePhyAd); |
| 4687 | } |
| 4688 | } else { |
| 4689 | pDevice->FlowControlCap &= |
| 4690 | ~LM_FLOW_CONTROL_AUTO_PAUSE; |
| 4691 | LM_SetFlowControl (pDevice, 0, 0); |
| 4692 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4693 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4694 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4695 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4696 | if (CurrentLinkStatus == LM_STATUS_LINK_DOWN) { |
| 4697 | LM_ForceAutoNeg (pDevice, pDevice->RequestedMediaType); |
| 4698 | |
| 4699 | /* If we force line speed, we make get link right away. */ |
| 4700 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 4701 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 4702 | if (Value32 & PHY_STATUS_LINK_PASS) { |
| 4703 | CurrentLinkStatus = LM_STATUS_LINK_ACTIVE; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4704 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4705 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4706 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4707 | /* GMII interface. */ |
| 4708 | pDevice->MacMode &= ~MAC_MODE_PORT_MODE_MASK; |
| 4709 | if (CurrentLinkStatus == LM_STATUS_LINK_ACTIVE) { |
| 4710 | if (pDevice->LineSpeed == LM_LINE_SPEED_100MBPS || |
| 4711 | pDevice->LineSpeed == LM_LINE_SPEED_10MBPS) { |
| 4712 | pDevice->MacMode |= MAC_MODE_PORT_MODE_MII; |
| 4713 | } else { |
| 4714 | pDevice->MacMode |= MAC_MODE_PORT_MODE_GMII; |
| 4715 | } |
| 4716 | } else { |
| 4717 | pDevice->MacMode |= MAC_MODE_PORT_MODE_GMII; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4718 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4719 | |
| 4720 | /* Set the MAC to operate in the appropriate duplex mode. */ |
| 4721 | pDevice->MacMode &= ~MAC_MODE_HALF_DUPLEX; |
| 4722 | if (pDevice->DuplexMode == LM_DUPLEX_MODE_HALF) { |
| 4723 | pDevice->MacMode |= MAC_MODE_HALF_DUPLEX; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4724 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4725 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4726 | /* Set the link polarity bit. */ |
| 4727 | pDevice->MacMode &= ~MAC_MODE_LINK_POLARITY; |
| 4728 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 4729 | if ((pDevice->LedMode == LED_MODE_LINK10) || |
| 4730 | (CurrentLinkStatus == LM_STATUS_LINK_ACTIVE && |
| 4731 | pDevice->LineSpeed == LM_LINE_SPEED_10MBPS)) { |
| 4732 | pDevice->MacMode |= MAC_MODE_LINK_POLARITY; |
| 4733 | } |
| 4734 | } else { |
| 4735 | if (CurrentLinkStatus == LM_STATUS_LINK_ACTIVE) { |
| 4736 | pDevice->MacMode |= MAC_MODE_LINK_POLARITY; |
| 4737 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4738 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4739 | /* Set LED mode. */ |
| 4740 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 4741 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 4742 | Value32 = LED_CTRL_PHY_MODE_1; |
| 4743 | } else { |
| 4744 | if (pDevice->LedMode == LED_MODE_OUTPUT) { |
| 4745 | Value32 = LED_CTRL_PHY_MODE_2; |
| 4746 | } else { |
| 4747 | Value32 = LED_CTRL_PHY_MODE_1; |
| 4748 | } |
| 4749 | } |
| 4750 | REG_WR (pDevice, MacCtrl.LedCtrl, Value32); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4751 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4752 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4753 | REG_WR (pDevice, MacCtrl.Mode, pDevice->MacMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4754 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4755 | /* Enable auto polling. */ |
| 4756 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO_POLLING) { |
| 4757 | pDevice->MiMode |= MI_MODE_AUTO_POLLING_ENABLE; |
| 4758 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4759 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4760 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4761 | /* Enable phy link change attention. */ |
| 4762 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_MI_INTERRUPT) { |
| 4763 | REG_WR (pDevice, MacCtrl.MacEvent, |
| 4764 | MAC_EVENT_ENABLE_MI_INTERRUPT); |
| 4765 | } else { |
| 4766 | REG_WR (pDevice, MacCtrl.MacEvent, |
| 4767 | MAC_EVENT_ENABLE_LINK_STATE_CHANGED_ATTN); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4768 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4769 | if ((T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) && |
| 4770 | (CurrentLinkStatus == LM_STATUS_LINK_ACTIVE) && |
| 4771 | (pDevice->LineSpeed == LM_LINE_SPEED_1000MBPS) && |
| 4772 | (((pDevice->PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE) && |
| 4773 | (pDevice->PciState & T3_PCI_STATE_BUS_SPEED_HIGH)) || |
| 4774 | !(pDevice->PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE))) { |
| 4775 | MM_Wait (120); |
| 4776 | REG_WR (pDevice, MacCtrl.Status, MAC_STATUS_SYNC_CHANGED | |
| 4777 | MAC_STATUS_CFG_CHANGED); |
| 4778 | MEM_WR_OFFSET (pDevice, T3_FIRMWARE_MAILBOX, |
| 4779 | T3_MAGIC_NUM_DISABLE_DMAW_ON_LINK_CHANGE); |
| 4780 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4781 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4782 | /* Indicate link status. */ |
| 4783 | if (pDevice->LinkStatus != CurrentLinkStatus) { |
| 4784 | pDevice->LinkStatus = CurrentLinkStatus; |
| 4785 | MM_IndicateStatus (pDevice, CurrentLinkStatus); |
| 4786 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4787 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4788 | return LM_STATUS_SUCCESS; |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4789 | } /* LM_SetupCopperPhy */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4790 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4791 | /******************************************************************************/ |
| 4792 | /* Description: */ |
| 4793 | /* */ |
| 4794 | /* Return: */ |
| 4795 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4796 | LM_STATUS LM_SetupPhy (PLM_DEVICE_BLOCK pDevice) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4797 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4798 | LM_STATUS LmStatus; |
| 4799 | LM_UINT32 Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4800 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4801 | #if INCLUDE_TBI_SUPPORT |
| 4802 | if (pDevice->EnableTbi) { |
| 4803 | LmStatus = LM_SetupFiberPhy (pDevice); |
| 4804 | } else |
| 4805 | #endif /* INCLUDE_TBI_SUPPORT */ |
| 4806 | { |
| 4807 | LmStatus = LM_SetupCopperPhy (pDevice); |
| 4808 | } |
| 4809 | if (pDevice->ChipRevId == T3_CHIP_ID_5704_A0) { |
| 4810 | if (!(pDevice->PciState & T3_PCI_STATE_CONVENTIONAL_PCI_MODE)) { |
| 4811 | Value32 = REG_RD (pDevice, PciCfg.PciState); |
| 4812 | REG_WR (pDevice, PciCfg.PciState, |
| 4813 | Value32 | T3_PCI_STATE_RETRY_SAME_DMA); |
| 4814 | } |
| 4815 | } |
| 4816 | if ((pDevice->LineSpeed == LM_LINE_SPEED_1000MBPS) && |
| 4817 | (pDevice->DuplexMode == LM_DUPLEX_MODE_HALF)) { |
| 4818 | REG_WR (pDevice, MacCtrl.TxLengths, 0x26ff); |
| 4819 | } else { |
| 4820 | REG_WR (pDevice, MacCtrl.TxLengths, 0x2620); |
| 4821 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4822 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4823 | return LmStatus; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 4824 | } |
| 4825 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 4826 | /******************************************************************************/ |
| 4827 | /* Description: */ |
| 4828 | /* */ |
| 4829 | /* Return: */ |
| 4830 | /******************************************************************************/ |
| 4831 | LM_VOID |
| 4832 | LM_ReadPhy (PLM_DEVICE_BLOCK pDevice, LM_UINT32 PhyReg, PLM_UINT32 pData32) |
| 4833 | { |
| 4834 | LM_UINT32 Value32; |
| 4835 | LM_UINT32 j; |
| 4836 | |
| 4837 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO_POLLING) { |
| 4838 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode & |
| 4839 | ~MI_MODE_AUTO_POLLING_ENABLE); |
| 4840 | MM_Wait (40); |
| 4841 | } |
| 4842 | |
| 4843 | Value32 = (pDevice->PhyAddr << MI_COM_FIRST_PHY_ADDR_BIT) | |
| 4844 | ((PhyReg & MI_COM_PHY_REG_ADDR_MASK) << |
| 4845 | MI_COM_FIRST_PHY_REG_ADDR_BIT) | MI_COM_CMD_READ | MI_COM_START; |
| 4846 | |
| 4847 | REG_WR (pDevice, MacCtrl.MiCom, Value32); |
| 4848 | |
| 4849 | for (j = 0; j < 20; j++) { |
| 4850 | MM_Wait (25); |
| 4851 | |
| 4852 | Value32 = REG_RD (pDevice, MacCtrl.MiCom); |
| 4853 | |
| 4854 | if (!(Value32 & MI_COM_BUSY)) { |
| 4855 | MM_Wait (5); |
| 4856 | Value32 = REG_RD (pDevice, MacCtrl.MiCom); |
| 4857 | Value32 &= MI_COM_PHY_DATA_MASK; |
| 4858 | break; |
| 4859 | } |
| 4860 | } |
| 4861 | |
| 4862 | if (Value32 & MI_COM_BUSY) { |
| 4863 | Value32 = 0; |
| 4864 | } |
| 4865 | |
| 4866 | *pData32 = Value32; |
| 4867 | |
| 4868 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO_POLLING) { |
| 4869 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode); |
| 4870 | MM_Wait (40); |
| 4871 | } |
| 4872 | } /* LM_ReadPhy */ |
| 4873 | |
| 4874 | /******************************************************************************/ |
| 4875 | /* Description: */ |
| 4876 | /* */ |
| 4877 | /* Return: */ |
| 4878 | /******************************************************************************/ |
| 4879 | LM_VOID |
| 4880 | LM_WritePhy (PLM_DEVICE_BLOCK pDevice, LM_UINT32 PhyReg, LM_UINT32 Data32) |
| 4881 | { |
| 4882 | LM_UINT32 Value32; |
| 4883 | LM_UINT32 j; |
| 4884 | |
| 4885 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO_POLLING) { |
| 4886 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode & |
| 4887 | ~MI_MODE_AUTO_POLLING_ENABLE); |
| 4888 | MM_Wait (40); |
| 4889 | } |
| 4890 | |
| 4891 | Value32 = (pDevice->PhyAddr << MI_COM_FIRST_PHY_ADDR_BIT) | |
| 4892 | ((PhyReg & MI_COM_PHY_REG_ADDR_MASK) << |
| 4893 | MI_COM_FIRST_PHY_REG_ADDR_BIT) | (Data32 & MI_COM_PHY_DATA_MASK) | |
| 4894 | MI_COM_CMD_WRITE | MI_COM_START; |
| 4895 | |
| 4896 | REG_WR (pDevice, MacCtrl.MiCom, Value32); |
| 4897 | |
| 4898 | for (j = 0; j < 20; j++) { |
| 4899 | MM_Wait (25); |
| 4900 | |
| 4901 | Value32 = REG_RD (pDevice, MacCtrl.MiCom); |
| 4902 | |
| 4903 | if (!(Value32 & MI_COM_BUSY)) { |
| 4904 | MM_Wait (5); |
| 4905 | break; |
| 4906 | } |
| 4907 | } |
| 4908 | |
| 4909 | if (pDevice->PhyIntMode == T3_PHY_INT_MODE_AUTO_POLLING) { |
| 4910 | REG_WR (pDevice, MacCtrl.MiMode, pDevice->MiMode); |
| 4911 | MM_Wait (40); |
| 4912 | } |
| 4913 | } /* LM_WritePhy */ |
| 4914 | |
| 4915 | /******************************************************************************/ |
| 4916 | /* Description: */ |
| 4917 | /* */ |
| 4918 | /* Return: */ |
| 4919 | /******************************************************************************/ |
| 4920 | LM_STATUS LM_SetPowerState (PLM_DEVICE_BLOCK pDevice, LM_POWER_STATE PowerLevel) |
| 4921 | { |
| 4922 | LM_UINT32 PmeSupport; |
| 4923 | LM_UINT32 Value32; |
| 4924 | LM_UINT32 PmCtrl; |
| 4925 | |
| 4926 | /* make sureindirect accesses are enabled */ |
| 4927 | MM_WriteConfig32 (pDevice, T3_PCI_MISC_HOST_CTRL_REG, |
| 4928 | pDevice->MiscHostCtrl); |
| 4929 | |
| 4930 | /* Clear the PME_ASSERT bit and the power state bits. Also enable */ |
| 4931 | /* the PME bit. */ |
| 4932 | MM_ReadConfig32 (pDevice, T3_PCI_PM_STATUS_CTRL_REG, &PmCtrl); |
| 4933 | |
| 4934 | PmCtrl |= T3_PM_PME_ASSERTED; |
| 4935 | PmCtrl &= ~T3_PM_POWER_STATE_MASK; |
| 4936 | |
| 4937 | /* Set the appropriate power state. */ |
| 4938 | if (PowerLevel == LM_POWER_STATE_D0) { |
| 4939 | |
| 4940 | /* Bring the card out of low power mode. */ |
| 4941 | PmCtrl |= T3_PM_POWER_STATE_D0; |
| 4942 | MM_WriteConfig32 (pDevice, T3_PCI_PM_STATUS_CTRL_REG, PmCtrl); |
| 4943 | |
| 4944 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl); |
| 4945 | MM_Wait (40); |
| 4946 | #if 0 /* Bugfix by jmb...can't call WritePhy here because pDevice not fully initialized */ |
| 4947 | LM_WritePhy (pDevice, BCM5401_AUX_CTRL, 0x02); |
| 4948 | #endif |
| 4949 | |
| 4950 | return LM_STATUS_SUCCESS; |
| 4951 | } else if (PowerLevel == LM_POWER_STATE_D1) { |
| 4952 | PmCtrl |= T3_PM_POWER_STATE_D1; |
| 4953 | } else if (PowerLevel == LM_POWER_STATE_D2) { |
| 4954 | PmCtrl |= T3_PM_POWER_STATE_D2; |
| 4955 | } else if (PowerLevel == LM_POWER_STATE_D3) { |
| 4956 | PmCtrl |= T3_PM_POWER_STATE_D3; |
| 4957 | } else { |
| 4958 | return LM_STATUS_FAILURE; |
| 4959 | } |
| 4960 | PmCtrl |= T3_PM_PME_ENABLE; |
| 4961 | |
| 4962 | /* Mask out all interrupts so LM_SetupPhy won't be called while we are */ |
| 4963 | /* setting new line speed. */ |
| 4964 | Value32 = REG_RD (pDevice, PciCfg.MiscHostCtrl); |
| 4965 | REG_WR (pDevice, PciCfg.MiscHostCtrl, |
| 4966 | Value32 | MISC_HOST_CTRL_MASK_PCI_INT); |
| 4967 | |
| 4968 | if (!pDevice->RestoreOnWakeUp) { |
| 4969 | pDevice->RestoreOnWakeUp = TRUE; |
| 4970 | pDevice->WakeUpDisableAutoNeg = pDevice->DisableAutoNeg; |
| 4971 | pDevice->WakeUpRequestedMediaType = pDevice->RequestedMediaType; |
| 4972 | } |
| 4973 | |
| 4974 | /* Force auto-negotiation to 10 line speed. */ |
| 4975 | pDevice->DisableAutoNeg = FALSE; |
| 4976 | pDevice->RequestedMediaType = LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS; |
| 4977 | LM_SetupPhy (pDevice); |
| 4978 | |
| 4979 | /* Put the driver in the initial state, and go through the power down */ |
| 4980 | /* sequence. */ |
| 4981 | LM_Halt (pDevice); |
| 4982 | |
| 4983 | MM_ReadConfig32 (pDevice, T3_PCI_PM_CAP_REG, &PmeSupport); |
| 4984 | |
| 4985 | if (pDevice->WakeUpModeCap != LM_WAKE_UP_MODE_NONE) { |
| 4986 | |
| 4987 | /* Enable WOL. */ |
| 4988 | LM_WritePhy (pDevice, BCM5401_AUX_CTRL, 0x5a); |
| 4989 | MM_Wait (40); |
| 4990 | |
| 4991 | /* Set LED mode. */ |
| 4992 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 4993 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 4994 | Value32 = LED_CTRL_PHY_MODE_1; |
| 4995 | } else { |
| 4996 | if (pDevice->LedMode == LED_MODE_OUTPUT) { |
| 4997 | Value32 = LED_CTRL_PHY_MODE_2; |
| 4998 | } else { |
| 4999 | Value32 = LED_CTRL_PHY_MODE_1; |
| 5000 | } |
| 5001 | } |
| 5002 | |
| 5003 | Value32 = MAC_MODE_PORT_MODE_MII; |
| 5004 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700) { |
| 5005 | if (pDevice->LedMode == LED_MODE_LINK10 || |
| 5006 | pDevice->WolSpeed == WOL_SPEED_10MB) { |
| 5007 | Value32 |= MAC_MODE_LINK_POLARITY; |
| 5008 | } |
| 5009 | } else { |
| 5010 | Value32 |= MAC_MODE_LINK_POLARITY; |
| 5011 | } |
| 5012 | REG_WR (pDevice, MacCtrl.Mode, Value32); |
| 5013 | MM_Wait (40); |
| 5014 | MM_Wait (40); |
| 5015 | MM_Wait (40); |
| 5016 | |
| 5017 | /* Always enable magic packet wake-up if we have vaux. */ |
| 5018 | if ((PmeSupport & T3_PCI_PM_CAP_PME_D3COLD) && |
| 5019 | (pDevice->WakeUpModeCap & LM_WAKE_UP_MODE_MAGIC_PACKET)) { |
| 5020 | Value32 |= MAC_MODE_DETECT_MAGIC_PACKET_ENABLE; |
| 5021 | } |
| 5022 | |
| 5023 | REG_WR (pDevice, MacCtrl.Mode, Value32); |
| 5024 | |
| 5025 | /* Enable the receiver. */ |
| 5026 | REG_WR (pDevice, MacCtrl.RxMode, RX_MODE_ENABLE); |
| 5027 | } |
| 5028 | |
| 5029 | /* Disable tx/rx clocks, and seletect an alternate clock. */ |
| 5030 | if (pDevice->WolSpeed == WOL_SPEED_100MB) { |
| 5031 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 5032 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 5033 | Value32 = |
| 5034 | T3_PCI_DISABLE_RX_CLOCK | T3_PCI_DISABLE_TX_CLOCK | |
| 5035 | T3_PCI_SELECT_ALTERNATE_CLOCK; |
| 5036 | } else { |
| 5037 | Value32 = T3_PCI_SELECT_ALTERNATE_CLOCK; |
| 5038 | } |
| 5039 | REG_WR (pDevice, PciCfg.ClockCtrl, Value32); |
| 5040 | |
| 5041 | MM_Wait (40); |
| 5042 | |
| 5043 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 5044 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 5045 | Value32 = |
| 5046 | T3_PCI_DISABLE_RX_CLOCK | T3_PCI_DISABLE_TX_CLOCK | |
| 5047 | T3_PCI_SELECT_ALTERNATE_CLOCK | |
| 5048 | T3_PCI_44MHZ_CORE_CLOCK; |
| 5049 | } else { |
| 5050 | Value32 = T3_PCI_SELECT_ALTERNATE_CLOCK | |
| 5051 | T3_PCI_44MHZ_CORE_CLOCK; |
| 5052 | } |
| 5053 | |
| 5054 | REG_WR (pDevice, PciCfg.ClockCtrl, Value32); |
| 5055 | |
| 5056 | MM_Wait (40); |
| 5057 | |
| 5058 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 5059 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 5060 | Value32 = |
| 5061 | T3_PCI_DISABLE_RX_CLOCK | T3_PCI_DISABLE_TX_CLOCK | |
| 5062 | T3_PCI_44MHZ_CORE_CLOCK; |
| 5063 | } else { |
| 5064 | Value32 = T3_PCI_44MHZ_CORE_CLOCK; |
| 5065 | } |
| 5066 | |
| 5067 | REG_WR (pDevice, PciCfg.ClockCtrl, Value32); |
| 5068 | } else { |
| 5069 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 5070 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 5071 | Value32 = |
| 5072 | T3_PCI_DISABLE_RX_CLOCK | T3_PCI_DISABLE_TX_CLOCK | |
| 5073 | T3_PCI_SELECT_ALTERNATE_CLOCK | |
| 5074 | T3_PCI_POWER_DOWN_PCI_PLL133; |
| 5075 | } else { |
| 5076 | Value32 = T3_PCI_SELECT_ALTERNATE_CLOCK | |
| 5077 | T3_PCI_POWER_DOWN_PCI_PLL133; |
| 5078 | } |
| 5079 | |
| 5080 | REG_WR (pDevice, PciCfg.ClockCtrl, Value32); |
| 5081 | } |
| 5082 | |
| 5083 | MM_Wait (40); |
| 5084 | |
| 5085 | if (!pDevice->EepromWp |
| 5086 | && (pDevice->WakeUpModeCap != LM_WAKE_UP_MODE_NONE)) { |
| 5087 | /* Switch adapter to auxilliary power. */ |
| 5088 | if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5700 || |
| 5089 | T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) { |
| 5090 | /* GPIO0 = 1, GPIO1 = 1, GPIO2 = 0. */ |
| 5091 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl | |
| 5092 | GRC_MISC_LOCAL_CTRL_GPIO_OE0 | |
| 5093 | GRC_MISC_LOCAL_CTRL_GPIO_OE1 | |
| 5094 | GRC_MISC_LOCAL_CTRL_GPIO_OE2 | |
| 5095 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT0 | |
| 5096 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT1); |
| 5097 | MM_Wait (40); |
| 5098 | } else { |
| 5099 | /* GPIO0 = 0, GPIO1 = 1, GPIO2 = 1. */ |
| 5100 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl | |
| 5101 | GRC_MISC_LOCAL_CTRL_GPIO_OE0 | |
| 5102 | GRC_MISC_LOCAL_CTRL_GPIO_OE1 | |
| 5103 | GRC_MISC_LOCAL_CTRL_GPIO_OE2 | |
| 5104 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT1 | |
| 5105 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT2); |
| 5106 | MM_Wait (40); |
| 5107 | |
| 5108 | /* GPIO0 = 1, GPIO1 = 1, GPIO2 = 1. */ |
| 5109 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl | |
| 5110 | GRC_MISC_LOCAL_CTRL_GPIO_OE0 | |
| 5111 | GRC_MISC_LOCAL_CTRL_GPIO_OE1 | |
| 5112 | GRC_MISC_LOCAL_CTRL_GPIO_OE2 | |
| 5113 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT0 | |
| 5114 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT1 | |
| 5115 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT2); |
| 5116 | MM_Wait (40); |
| 5117 | |
| 5118 | /* GPIO0 = 1, GPIO1 = 1, GPIO2 = 0. */ |
| 5119 | REG_WR (pDevice, Grc.LocalCtrl, pDevice->GrcLocalCtrl | |
| 5120 | GRC_MISC_LOCAL_CTRL_GPIO_OE0 | |
| 5121 | GRC_MISC_LOCAL_CTRL_GPIO_OE1 | |
| 5122 | GRC_MISC_LOCAL_CTRL_GPIO_OE2 | |
| 5123 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT0 | |
| 5124 | GRC_MISC_LOCAL_CTRL_GPIO_OUTPUT1); |
| 5125 | MM_Wait (40); |
| 5126 | } |
| 5127 | } |
| 5128 | |
| 5129 | /* Set the phy to low power mode. */ |
| 5130 | /* Put the the hardware in low power mode. */ |
| 5131 | MM_WriteConfig32 (pDevice, T3_PCI_PM_STATUS_CTRL_REG, PmCtrl); |
| 5132 | |
| 5133 | return LM_STATUS_SUCCESS; |
| 5134 | } /* LM_SetPowerState */ |
| 5135 | |
| 5136 | /******************************************************************************/ |
| 5137 | /* Description: */ |
| 5138 | /* */ |
| 5139 | /* Return: */ |
| 5140 | /******************************************************************************/ |
| 5141 | static LM_UINT32 GetPhyAdFlowCntrlSettings (PLM_DEVICE_BLOCK pDevice) |
| 5142 | { |
| 5143 | LM_UINT32 Value32; |
| 5144 | |
| 5145 | Value32 = 0; |
| 5146 | |
| 5147 | /* Auto negotiation flow control only when autonegotiation is enabled. */ |
| 5148 | if (pDevice->DisableAutoNeg == FALSE || |
| 5149 | pDevice->RequestedMediaType == LM_REQUESTED_MEDIA_TYPE_AUTO || |
| 5150 | pDevice->RequestedMediaType == LM_REQUESTED_MEDIA_TYPE_UTP_AUTO) { |
| 5151 | /* Please refer to Table 28B-3 of the 802.3ab-1999 spec. */ |
| 5152 | if ((pDevice->FlowControlCap == LM_FLOW_CONTROL_AUTO_PAUSE) || |
| 5153 | ((pDevice->FlowControlCap & LM_FLOW_CONTROL_RECEIVE_PAUSE) |
| 5154 | && (pDevice-> |
| 5155 | FlowControlCap & LM_FLOW_CONTROL_TRANSMIT_PAUSE))) { |
| 5156 | Value32 |= PHY_AN_AD_PAUSE_CAPABLE; |
| 5157 | } else if (pDevice-> |
| 5158 | FlowControlCap & LM_FLOW_CONTROL_TRANSMIT_PAUSE) { |
| 5159 | Value32 |= PHY_AN_AD_ASYM_PAUSE; |
| 5160 | } else if (pDevice-> |
| 5161 | FlowControlCap & LM_FLOW_CONTROL_RECEIVE_PAUSE) { |
| 5162 | Value32 |= |
| 5163 | PHY_AN_AD_PAUSE_CAPABLE | PHY_AN_AD_ASYM_PAUSE; |
| 5164 | } |
| 5165 | } |
| 5166 | |
| 5167 | return Value32; |
| 5168 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5169 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5170 | /******************************************************************************/ |
| 5171 | /* Description: */ |
| 5172 | /* */ |
| 5173 | /* Return: */ |
| 5174 | /* LM_STATUS_FAILURE */ |
| 5175 | /* LM_STATUS_SUCCESS */ |
| 5176 | /* */ |
| 5177 | /******************************************************************************/ |
| 5178 | static LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5179 | LM_ForceAutoNegBcm540xPhy (PLM_DEVICE_BLOCK pDevice, |
| 5180 | LM_REQUESTED_MEDIA_TYPE RequestedMediaType) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5181 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5182 | LM_MEDIA_TYPE MediaType; |
| 5183 | LM_LINE_SPEED LineSpeed; |
| 5184 | LM_DUPLEX_MODE DuplexMode; |
| 5185 | LM_UINT32 NewPhyCtrl; |
| 5186 | LM_UINT32 Value32; |
| 5187 | LM_UINT32 Cnt; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5188 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5189 | /* Get the interface type, line speed, and duplex mode. */ |
| 5190 | LM_TranslateRequestedMediaType (RequestedMediaType, &MediaType, |
| 5191 | &LineSpeed, &DuplexMode); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5192 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5193 | if (pDevice->RestoreOnWakeUp) { |
| 5194 | LM_WritePhy (pDevice, BCM540X_1000BASET_CTRL_REG, 0); |
| 5195 | pDevice->advertising1000 = 0; |
| 5196 | Value32 = PHY_AN_AD_10BASET_FULL | PHY_AN_AD_10BASET_HALF; |
| 5197 | if (pDevice->WolSpeed == WOL_SPEED_100MB) { |
| 5198 | Value32 |= |
| 5199 | PHY_AN_AD_100BASETX_FULL | PHY_AN_AD_100BASETX_HALF; |
| 5200 | } |
| 5201 | Value32 |= PHY_AN_AD_PROTOCOL_802_3_CSMA_CD; |
| 5202 | Value32 |= GetPhyAdFlowCntrlSettings (pDevice); |
| 5203 | LM_WritePhy (pDevice, PHY_AN_AD_REG, Value32); |
| 5204 | pDevice->advertising = Value32; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5205 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5206 | /* Setup the auto-negotiation advertisement register. */ |
| 5207 | else if (LineSpeed == LM_LINE_SPEED_UNKNOWN) { |
| 5208 | /* Setup the 10/100 Mbps auto-negotiation advertisement register. */ |
| 5209 | Value32 = PHY_AN_AD_PROTOCOL_802_3_CSMA_CD | |
| 5210 | PHY_AN_AD_10BASET_HALF | PHY_AN_AD_10BASET_FULL | |
| 5211 | PHY_AN_AD_100BASETX_FULL | PHY_AN_AD_100BASETX_HALF; |
| 5212 | Value32 |= GetPhyAdFlowCntrlSettings (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5213 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5214 | LM_WritePhy (pDevice, PHY_AN_AD_REG, Value32); |
| 5215 | pDevice->advertising = Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5216 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5217 | /* Advertise 1000Mbps */ |
| 5218 | Value32 = |
| 5219 | BCM540X_AN_AD_1000BASET_HALF | BCM540X_AN_AD_1000BASET_FULL; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5220 | |
| 5221 | #if INCLUDE_5701_AX_FIX |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5222 | /* Bug: workaround for CRC error in gigabit mode when we are in */ |
| 5223 | /* slave mode. This will force the PHY to operate in */ |
| 5224 | /* master mode. */ |
| 5225 | if (pDevice->ChipRevId == T3_CHIP_ID_5701_A0 || |
| 5226 | pDevice->ChipRevId == T3_CHIP_ID_5701_B0) { |
| 5227 | Value32 |= BCM540X_CONFIG_AS_MASTER | |
| 5228 | BCM540X_ENABLE_CONFIG_AS_MASTER; |
| 5229 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5230 | #endif |
| 5231 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5232 | LM_WritePhy (pDevice, BCM540X_1000BASET_CTRL_REG, Value32); |
| 5233 | pDevice->advertising1000 = Value32; |
| 5234 | } else { |
| 5235 | if (LineSpeed == LM_LINE_SPEED_1000MBPS) { |
| 5236 | Value32 = PHY_AN_AD_PROTOCOL_802_3_CSMA_CD; |
| 5237 | Value32 |= GetPhyAdFlowCntrlSettings (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5238 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5239 | LM_WritePhy (pDevice, PHY_AN_AD_REG, Value32); |
| 5240 | pDevice->advertising = Value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5241 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5242 | if (DuplexMode != LM_DUPLEX_MODE_FULL) { |
| 5243 | Value32 = BCM540X_AN_AD_1000BASET_HALF; |
| 5244 | } else { |
| 5245 | Value32 = BCM540X_AN_AD_1000BASET_FULL; |
| 5246 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5247 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5248 | LM_WritePhy (pDevice, BCM540X_1000BASET_CTRL_REG, |
| 5249 | Value32); |
| 5250 | pDevice->advertising1000 = Value32; |
| 5251 | } else if (LineSpeed == LM_LINE_SPEED_100MBPS) { |
| 5252 | LM_WritePhy (pDevice, BCM540X_1000BASET_CTRL_REG, 0); |
| 5253 | pDevice->advertising1000 = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5254 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5255 | if (DuplexMode != LM_DUPLEX_MODE_FULL) { |
| 5256 | Value32 = PHY_AN_AD_100BASETX_HALF; |
| 5257 | } else { |
| 5258 | Value32 = PHY_AN_AD_100BASETX_FULL; |
| 5259 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5260 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5261 | Value32 |= PHY_AN_AD_PROTOCOL_802_3_CSMA_CD; |
| 5262 | Value32 |= GetPhyAdFlowCntrlSettings (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5263 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5264 | LM_WritePhy (pDevice, PHY_AN_AD_REG, Value32); |
| 5265 | pDevice->advertising = Value32; |
| 5266 | } else if (LineSpeed == LM_LINE_SPEED_10MBPS) { |
| 5267 | LM_WritePhy (pDevice, BCM540X_1000BASET_CTRL_REG, 0); |
| 5268 | pDevice->advertising1000 = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5269 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5270 | if (DuplexMode != LM_DUPLEX_MODE_FULL) { |
| 5271 | Value32 = PHY_AN_AD_10BASET_HALF; |
| 5272 | } else { |
| 5273 | Value32 = PHY_AN_AD_10BASET_FULL; |
| 5274 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5275 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5276 | Value32 |= PHY_AN_AD_PROTOCOL_802_3_CSMA_CD; |
| 5277 | Value32 |= GetPhyAdFlowCntrlSettings (pDevice); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5278 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5279 | LM_WritePhy (pDevice, PHY_AN_AD_REG, Value32); |
| 5280 | pDevice->advertising = Value32; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5281 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5282 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5283 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5284 | /* Force line speed if auto-negotiation is disabled. */ |
| 5285 | if (pDevice->DisableAutoNeg && LineSpeed != LM_LINE_SPEED_UNKNOWN) { |
| 5286 | /* This code path is executed only when there is link. */ |
| 5287 | pDevice->MediaType = MediaType; |
| 5288 | pDevice->LineSpeed = LineSpeed; |
| 5289 | pDevice->DuplexMode = DuplexMode; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5290 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5291 | /* Force line seepd. */ |
| 5292 | NewPhyCtrl = 0; |
| 5293 | switch (LineSpeed) { |
| 5294 | case LM_LINE_SPEED_10MBPS: |
| 5295 | NewPhyCtrl |= PHY_CTRL_SPEED_SELECT_10MBPS; |
| 5296 | break; |
| 5297 | case LM_LINE_SPEED_100MBPS: |
| 5298 | NewPhyCtrl |= PHY_CTRL_SPEED_SELECT_100MBPS; |
| 5299 | break; |
| 5300 | case LM_LINE_SPEED_1000MBPS: |
| 5301 | NewPhyCtrl |= PHY_CTRL_SPEED_SELECT_1000MBPS; |
| 5302 | break; |
| 5303 | default: |
| 5304 | NewPhyCtrl |= PHY_CTRL_SPEED_SELECT_1000MBPS; |
| 5305 | break; |
| 5306 | } |
| 5307 | |
| 5308 | if (DuplexMode == LM_DUPLEX_MODE_FULL) { |
| 5309 | NewPhyCtrl |= PHY_CTRL_FULL_DUPLEX_MODE; |
| 5310 | } |
| 5311 | |
| 5312 | /* Don't do anything if the PHY_CTRL is already what we wanted. */ |
| 5313 | LM_ReadPhy (pDevice, PHY_CTRL_REG, &Value32); |
| 5314 | if (Value32 != NewPhyCtrl) { |
| 5315 | /* Temporary bring the link down before forcing line speed. */ |
| 5316 | LM_WritePhy (pDevice, PHY_CTRL_REG, |
| 5317 | PHY_CTRL_LOOPBACK_MODE); |
| 5318 | |
| 5319 | /* Wait for link to go down. */ |
| 5320 | for (Cnt = 0; Cnt < 15000; Cnt++) { |
| 5321 | MM_Wait (10); |
| 5322 | |
| 5323 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 5324 | LM_ReadPhy (pDevice, PHY_STATUS_REG, &Value32); |
| 5325 | |
| 5326 | if (!(Value32 & PHY_STATUS_LINK_PASS)) { |
| 5327 | MM_Wait (40); |
| 5328 | break; |
| 5329 | } |
| 5330 | } |
| 5331 | |
| 5332 | LM_WritePhy (pDevice, PHY_CTRL_REG, NewPhyCtrl); |
| 5333 | MM_Wait (40); |
| 5334 | } |
| 5335 | } else { |
| 5336 | LM_WritePhy (pDevice, PHY_CTRL_REG, PHY_CTRL_AUTO_NEG_ENABLE | |
| 5337 | PHY_CTRL_RESTART_AUTO_NEG); |
| 5338 | } |
| 5339 | |
| 5340 | return LM_STATUS_SUCCESS; |
| 5341 | } /* LM_ForceAutoNegBcm540xPhy */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5342 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5343 | /******************************************************************************/ |
| 5344 | /* Description: */ |
| 5345 | /* */ |
| 5346 | /* Return: */ |
| 5347 | /******************************************************************************/ |
| 5348 | static LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5349 | LM_ForceAutoNeg (PLM_DEVICE_BLOCK pDevice, |
| 5350 | LM_REQUESTED_MEDIA_TYPE RequestedMediaType) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5351 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5352 | LM_STATUS LmStatus; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5353 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5354 | /* Initialize the phy chip. */ |
| 5355 | switch (pDevice->PhyId & PHY_ID_MASK) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5356 | case PHY_BCM5400_PHY_ID: |
| 5357 | case PHY_BCM5401_PHY_ID: |
| 5358 | case PHY_BCM5411_PHY_ID: |
| 5359 | case PHY_BCM5701_PHY_ID: |
| 5360 | case PHY_BCM5703_PHY_ID: |
| 5361 | case PHY_BCM5704_PHY_ID: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5362 | LmStatus = |
| 5363 | LM_ForceAutoNegBcm540xPhy (pDevice, RequestedMediaType); |
| 5364 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5365 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5366 | default: |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5367 | LmStatus = LM_STATUS_FAILURE; |
| 5368 | break; |
| 5369 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5370 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5371 | return LmStatus; |
| 5372 | } /* LM_ForceAutoNeg */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5373 | |
| 5374 | /******************************************************************************/ |
| 5375 | /* Description: */ |
| 5376 | /* */ |
| 5377 | /* Return: */ |
| 5378 | /******************************************************************************/ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5379 | LM_STATUS LM_LoadFirmware (PLM_DEVICE_BLOCK pDevice, |
| 5380 | PT3_FWIMG_INFO pFwImg, |
| 5381 | LM_UINT32 LoadCpu, LM_UINT32 StartCpu) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5382 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5383 | LM_UINT32 i; |
| 5384 | LM_UINT32 address; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5385 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5386 | if (LoadCpu & T3_RX_CPU_ID) { |
| 5387 | if (LM_HaltCpu (pDevice, T3_RX_CPU_ID) != LM_STATUS_SUCCESS) { |
| 5388 | return LM_STATUS_FAILURE; |
| 5389 | } |
| 5390 | |
| 5391 | /* First of all clear scrach pad memory */ |
| 5392 | for (i = 0; i < T3_RX_CPU_SPAD_SIZE; i += 4) { |
| 5393 | LM_RegWrInd (pDevice, T3_RX_CPU_SPAD_ADDR + i, 0); |
| 5394 | } |
| 5395 | |
| 5396 | /* Copy code first */ |
| 5397 | address = T3_RX_CPU_SPAD_ADDR + (pFwImg->Text.Offset & 0xffff); |
| 5398 | for (i = 0; i <= pFwImg->Text.Length; i += 4) { |
| 5399 | LM_RegWrInd (pDevice, address + i, |
| 5400 | ((LM_UINT32 *) pFwImg->Text.Buffer)[i / |
| 5401 | 4]); |
| 5402 | } |
| 5403 | |
| 5404 | address = |
| 5405 | T3_RX_CPU_SPAD_ADDR + (pFwImg->ROnlyData.Offset & 0xffff); |
| 5406 | for (i = 0; i <= pFwImg->ROnlyData.Length; i += 4) { |
| 5407 | LM_RegWrInd (pDevice, address + i, |
| 5408 | ((LM_UINT32 *) pFwImg->ROnlyData. |
| 5409 | Buffer)[i / 4]); |
| 5410 | } |
| 5411 | |
| 5412 | address = T3_RX_CPU_SPAD_ADDR + (pFwImg->Data.Offset & 0xffff); |
| 5413 | for (i = 0; i <= pFwImg->Data.Length; i += 4) { |
| 5414 | LM_RegWrInd (pDevice, address + i, |
| 5415 | ((LM_UINT32 *) pFwImg->Data.Buffer)[i / |
| 5416 | 4]); |
| 5417 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5418 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5419 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5420 | if (LoadCpu & T3_TX_CPU_ID) { |
| 5421 | if (LM_HaltCpu (pDevice, T3_TX_CPU_ID) != LM_STATUS_SUCCESS) { |
| 5422 | return LM_STATUS_FAILURE; |
| 5423 | } |
| 5424 | |
| 5425 | /* First of all clear scrach pad memory */ |
| 5426 | for (i = 0; i < T3_TX_CPU_SPAD_SIZE; i += 4) { |
| 5427 | LM_RegWrInd (pDevice, T3_TX_CPU_SPAD_ADDR + i, 0); |
| 5428 | } |
| 5429 | |
| 5430 | /* Copy code first */ |
| 5431 | address = T3_TX_CPU_SPAD_ADDR + (pFwImg->Text.Offset & 0xffff); |
| 5432 | for (i = 0; i <= pFwImg->Text.Length; i += 4) { |
| 5433 | LM_RegWrInd (pDevice, address + i, |
| 5434 | ((LM_UINT32 *) pFwImg->Text.Buffer)[i / |
| 5435 | 4]); |
| 5436 | } |
| 5437 | |
| 5438 | address = |
| 5439 | T3_TX_CPU_SPAD_ADDR + (pFwImg->ROnlyData.Offset & 0xffff); |
| 5440 | for (i = 0; i <= pFwImg->ROnlyData.Length; i += 4) { |
| 5441 | LM_RegWrInd (pDevice, address + i, |
| 5442 | ((LM_UINT32 *) pFwImg->ROnlyData. |
| 5443 | Buffer)[i / 4]); |
| 5444 | } |
| 5445 | |
| 5446 | address = T3_TX_CPU_SPAD_ADDR + (pFwImg->Data.Offset & 0xffff); |
| 5447 | for (i = 0; i <= pFwImg->Data.Length; i += 4) { |
| 5448 | LM_RegWrInd (pDevice, address + i, |
| 5449 | ((LM_UINT32 *) pFwImg->Data.Buffer)[i / |
| 5450 | 4]); |
| 5451 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5452 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5453 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5454 | if (StartCpu & T3_RX_CPU_ID) { |
| 5455 | /* Start Rx CPU */ |
| 5456 | REG_WR (pDevice, rxCpu.reg.state, 0xffffffff); |
| 5457 | REG_WR (pDevice, rxCpu.reg.PC, pFwImg->StartAddress); |
| 5458 | for (i = 0; i < 5; i++) { |
| 5459 | if (pFwImg->StartAddress == |
| 5460 | REG_RD (pDevice, rxCpu.reg.PC)) |
| 5461 | break; |
| 5462 | |
| 5463 | REG_WR (pDevice, rxCpu.reg.state, 0xffffffff); |
| 5464 | REG_WR (pDevice, rxCpu.reg.mode, CPU_MODE_HALT); |
| 5465 | REG_WR (pDevice, rxCpu.reg.PC, pFwImg->StartAddress); |
| 5466 | MM_Wait (1000); |
| 5467 | } |
| 5468 | |
| 5469 | REG_WR (pDevice, rxCpu.reg.state, 0xffffffff); |
| 5470 | REG_WR (pDevice, rxCpu.reg.mode, 0); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5471 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5472 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5473 | if (StartCpu & T3_TX_CPU_ID) { |
| 5474 | /* Start Tx CPU */ |
| 5475 | REG_WR (pDevice, txCpu.reg.state, 0xffffffff); |
| 5476 | REG_WR (pDevice, txCpu.reg.PC, pFwImg->StartAddress); |
| 5477 | for (i = 0; i < 5; i++) { |
| 5478 | if (pFwImg->StartAddress == |
| 5479 | REG_RD (pDevice, txCpu.reg.PC)) |
| 5480 | break; |
| 5481 | |
| 5482 | REG_WR (pDevice, txCpu.reg.state, 0xffffffff); |
| 5483 | REG_WR (pDevice, txCpu.reg.mode, CPU_MODE_HALT); |
| 5484 | REG_WR (pDevice, txCpu.reg.PC, pFwImg->StartAddress); |
| 5485 | MM_Wait (1000); |
| 5486 | } |
| 5487 | |
| 5488 | REG_WR (pDevice, txCpu.reg.state, 0xffffffff); |
| 5489 | REG_WR (pDevice, txCpu.reg.mode, 0); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5490 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5491 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5492 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5493 | } |
| 5494 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5495 | STATIC LM_STATUS LM_HaltCpu (PLM_DEVICE_BLOCK pDevice, LM_UINT32 cpu_number) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5496 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5497 | LM_UINT32 i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5498 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5499 | if (cpu_number == T3_RX_CPU_ID) { |
| 5500 | for (i = 0; i < 10000; i++) { |
| 5501 | REG_WR (pDevice, rxCpu.reg.state, 0xffffffff); |
| 5502 | REG_WR (pDevice, rxCpu.reg.mode, CPU_MODE_HALT); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5503 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5504 | if (REG_RD (pDevice, rxCpu.reg.mode) & CPU_MODE_HALT) |
| 5505 | break; |
| 5506 | } |
| 5507 | |
| 5508 | REG_WR (pDevice, rxCpu.reg.state, 0xffffffff); |
| 5509 | REG_WR (pDevice, rxCpu.reg.mode, CPU_MODE_HALT); |
| 5510 | MM_Wait (10); |
| 5511 | } else { |
| 5512 | for (i = 0; i < 10000; i++) { |
| 5513 | REG_WR (pDevice, txCpu.reg.state, 0xffffffff); |
| 5514 | REG_WR (pDevice, txCpu.reg.mode, CPU_MODE_HALT); |
| 5515 | |
| 5516 | if (REG_RD (pDevice, txCpu.reg.mode) & CPU_MODE_HALT) |
| 5517 | break; |
| 5518 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5519 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5520 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5521 | return ((i == 10000) ? LM_STATUS_FAILURE : LM_STATUS_SUCCESS); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5522 | } |
| 5523 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5524 | int LM_BlinkLED (PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlinkDurationSec) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5525 | { |
| 5526 | LM_UINT32 Oldcfg; |
| 5527 | int j; |
| 5528 | int ret = 0; |
| 5529 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5530 | if (BlinkDurationSec == 0) { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5531 | return 0; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5532 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5533 | if (BlinkDurationSec > 120) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5534 | BlinkDurationSec = 120; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5535 | } |
| 5536 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5537 | Oldcfg = REG_RD (pDevice, MacCtrl.LedCtrl); |
| 5538 | for (j = 0; j < BlinkDurationSec * 2; j++) { |
| 5539 | if (j % 2) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5540 | /* Turn on the LEDs. */ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5541 | REG_WR (pDevice, MacCtrl.LedCtrl, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5542 | LED_CTRL_OVERRIDE_LINK_LED | |
| 5543 | LED_CTRL_1000MBPS_LED_ON | |
| 5544 | LED_CTRL_100MBPS_LED_ON | |
| 5545 | LED_CTRL_10MBPS_LED_ON | |
| 5546 | LED_CTRL_OVERRIDE_TRAFFIC_LED | |
| 5547 | LED_CTRL_BLINK_TRAFFIC_LED | |
| 5548 | LED_CTRL_TRAFFIC_LED); |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5549 | } else { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5550 | /* Turn off the LEDs. */ |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5551 | REG_WR (pDevice, MacCtrl.LedCtrl, |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5552 | LED_CTRL_OVERRIDE_LINK_LED | |
| 5553 | LED_CTRL_OVERRIDE_TRAFFIC_LED); |
| 5554 | } |
| 5555 | |
| 5556 | #ifndef EMBEDDED |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5557 | current->state = TASK_INTERRUPTIBLE; |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5558 | if (schedule_timeout (HZ / 2) != 0) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5559 | ret = -EINTR; |
| 5560 | break; |
| 5561 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5562 | #else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5563 | udelay (100000); /* 1s sleep */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5564 | #endif |
| 5565 | } |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5566 | REG_WR (pDevice, MacCtrl.LedCtrl, Oldcfg); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5567 | return ret; |
| 5568 | } |
| 5569 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5570 | int t3_do_dma (PLM_DEVICE_BLOCK pDevice, |
| 5571 | LM_PHYSICAL_ADDRESS host_addr_phy, int length, int dma_read) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5572 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5573 | T3_DMA_DESC dma_desc; |
| 5574 | int i; |
| 5575 | LM_UINT32 dma_desc_addr; |
| 5576 | LM_UINT32 value32; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5577 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5578 | REG_WR (pDevice, BufMgr.Mode, 0); |
| 5579 | REG_WR (pDevice, Ftq.Reset, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5580 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5581 | dma_desc.host_addr.High = host_addr_phy.High; |
| 5582 | dma_desc.host_addr.Low = host_addr_phy.Low; |
| 5583 | dma_desc.nic_mbuf = 0x2100; |
| 5584 | dma_desc.len = length; |
| 5585 | dma_desc.flags = 0x00000004; /* Generate Rx-CPU event */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5586 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5587 | if (dma_read) { |
| 5588 | dma_desc.cqid_sqid = (T3_QID_RX_BD_COMP << 8) | |
| 5589 | T3_QID_DMA_HIGH_PRI_READ; |
| 5590 | REG_WR (pDevice, DmaRead.Mode, DMA_READ_MODE_ENABLE); |
| 5591 | } else { |
| 5592 | dma_desc.cqid_sqid = (T3_QID_RX_DATA_COMP << 8) | |
| 5593 | T3_QID_DMA_HIGH_PRI_WRITE; |
| 5594 | REG_WR (pDevice, DmaWrite.Mode, DMA_WRITE_MODE_ENABLE); |
| 5595 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5596 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5597 | dma_desc_addr = T3_NIC_DMA_DESC_POOL_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5598 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5599 | /* Writing this DMA descriptor to DMA memory */ |
| 5600 | for (i = 0; i < sizeof (T3_DMA_DESC); i += 4) { |
| 5601 | value32 = *((PLM_UINT32) (((PLM_UINT8) & dma_desc) + i)); |
| 5602 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_ADDR_REG, |
| 5603 | dma_desc_addr + i); |
| 5604 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_DATA_REG, |
| 5605 | cpu_to_le32 (value32)); |
| 5606 | } |
| 5607 | MM_WriteConfig32 (pDevice, T3_PCI_MEM_WIN_ADDR_REG, 0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5608 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5609 | if (dma_read) |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5610 | REG_WR (pDevice, Ftq.DmaHighReadFtqFifoEnqueueDequeue, |
| 5611 | dma_desc_addr); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5612 | else |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5613 | REG_WR (pDevice, Ftq.DmaHighWriteFtqFifoEnqueueDequeue, |
| 5614 | dma_desc_addr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5615 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5616 | for (i = 0; i < 40; i++) { |
| 5617 | if (dma_read) |
| 5618 | value32 = |
| 5619 | REG_RD (pDevice, |
| 5620 | Ftq.RcvBdCompFtqFifoEnqueueDequeue); |
| 5621 | else |
| 5622 | value32 = |
| 5623 | REG_RD (pDevice, |
| 5624 | Ftq.RcvDataCompFtqFifoEnqueueDequeue); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5625 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5626 | if ((value32 & 0xffff) == dma_desc_addr) |
| 5627 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5628 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5629 | MM_Wait (10); |
| 5630 | } |
| 5631 | |
| 5632 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5633 | } |
| 5634 | |
| 5635 | STATIC LM_STATUS |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5636 | LM_DmaTest (PLM_DEVICE_BLOCK pDevice, PLM_UINT8 pBufferVirt, |
| 5637 | LM_PHYSICAL_ADDRESS BufferPhy, LM_UINT32 BufferSize) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5638 | { |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5639 | int j; |
| 5640 | LM_UINT32 *ptr; |
| 5641 | int dma_success = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5642 | |
Vadim Bendebury | f539edc | 2007-05-24 15:52:25 -0700 | [diff] [blame] | 5643 | if (T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5700 && |
| 5644 | T3_ASIC_REV (pDevice->ChipRevId) != T3_ASIC_REV_5701) { |
| 5645 | return LM_STATUS_SUCCESS; |
| 5646 | } |
| 5647 | while (!dma_success) { |
| 5648 | /* Fill data with incremental patterns */ |
| 5649 | ptr = (LM_UINT32 *) pBufferVirt; |
| 5650 | for (j = 0; j < BufferSize / 4; j++) |
| 5651 | *ptr++ = j; |
| 5652 | |
| 5653 | if (t3_do_dma (pDevice, BufferPhy, BufferSize, 1) == |
| 5654 | LM_STATUS_FAILURE) { |
| 5655 | return LM_STATUS_FAILURE; |
| 5656 | } |
| 5657 | |
| 5658 | MM_Wait (40); |
| 5659 | ptr = (LM_UINT32 *) pBufferVirt; |
| 5660 | /* Fill data with zero */ |
| 5661 | for (j = 0; j < BufferSize / 4; j++) |
| 5662 | *ptr++ = 0; |
| 5663 | |
| 5664 | if (t3_do_dma (pDevice, BufferPhy, BufferSize, 0) == |
| 5665 | LM_STATUS_FAILURE) { |
| 5666 | return LM_STATUS_FAILURE; |
| 5667 | } |
| 5668 | |
| 5669 | MM_Wait (40); |
| 5670 | /* Check for data */ |
| 5671 | ptr = (LM_UINT32 *) pBufferVirt; |
| 5672 | for (j = 0; j < BufferSize / 4; j++) { |
| 5673 | if (*ptr++ != j) { |
| 5674 | if ((pDevice-> |
| 5675 | DmaReadWriteCtrl & |
| 5676 | DMA_CTRL_WRITE_BOUNDARY_MASK) |
| 5677 | == DMA_CTRL_WRITE_BOUNDARY_DISABLE) { |
| 5678 | pDevice->DmaReadWriteCtrl = |
| 5679 | (pDevice-> |
| 5680 | DmaReadWriteCtrl & |
| 5681 | ~DMA_CTRL_WRITE_BOUNDARY_MASK) | |
| 5682 | DMA_CTRL_WRITE_BOUNDARY_16; |
| 5683 | REG_WR (pDevice, |
| 5684 | PciCfg.DmaReadWriteCtrl, |
| 5685 | pDevice->DmaReadWriteCtrl); |
| 5686 | break; |
| 5687 | } else { |
| 5688 | return LM_STATUS_FAILURE; |
| 5689 | } |
| 5690 | } |
| 5691 | } |
| 5692 | if (j == (BufferSize / 4)) |
| 5693 | dma_success = 1; |
| 5694 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 5695 | return LM_STATUS_SUCCESS; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5696 | } |