Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
Jim Lieb | 612822f | 2009-08-12 14:54:03 -0700 | [diff] [blame] | 19 | * |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 20 | * File: mac.c |
| 21 | * |
| 22 | * Purpose: MAC routines |
| 23 | * |
| 24 | * Author: Tevin Chen |
| 25 | * |
| 26 | * Date: May 21, 1996 |
| 27 | * |
| 28 | * Functions: |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 29 | * MACbIsRegBitsOn - Test if All test Bits On |
| 30 | * MACbIsRegBitsOff - Test if All test Bits Off |
| 31 | * MACbIsIntDisable - Test if MAC interrupt disable |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 32 | * MACvSetShortRetryLimit - Set 802.11 Short Retry limit |
| 33 | * MACvGetShortRetryLimit - Get 802.11 Short Retry limit |
| 34 | * MACvSetLongRetryLimit - Set 802.11 Long Retry limit |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 35 | * MACvSetLoopbackMode - Set MAC Loopback Mode |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 36 | * MACvSaveContext - Save Context of MAC Registers |
| 37 | * MACvRestoreContext - Restore Context of MAC Registers |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 38 | * MACbSoftwareReset - Software Reset MAC |
| 39 | * MACbSafeRxOff - Turn Off MAC Rx |
| 40 | * MACbSafeTxOff - Turn Off MAC Tx |
| 41 | * MACbSafeStop - Stop MAC function |
| 42 | * MACbShutdown - Shut down MAC |
| 43 | * MACvInitialize - Initialize MAC |
Justin P. Mattock | 789d1ae | 2012-08-20 08:43:13 -0700 | [diff] [blame] | 44 | * MACvSetCurrRxDescAddr - Set Rx Descriptors Address |
| 45 | * MACvSetCurrTx0DescAddr - Set Tx0 Descriptors Address |
| 46 | * MACvSetCurrTx1DescAddr - Set Tx1 Descriptors Address |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 47 | * MACvTimer0MicroSDelay - Micro Second Delay Loop by MAC |
| 48 | * |
| 49 | * Revision History: |
| 50 | * 08-22-2003 Kyle Hsu : Porting MAC functions from sim53 |
| 51 | * 09-03-2003 Bryan YC Fan : Add MACvClearBusSusInd()& MACvEnableBusSusEn() |
| 52 | * 09-18-2003 Jerry Chen : Add MACvSetKeyEntry & MACvDisableKeyEntry |
| 53 | * |
| 54 | */ |
| 55 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 56 | #include "tmacro.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 57 | #include "mac.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 58 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 59 | /* |
| 60 | * Description: |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 61 | * Test if all test bits on |
| 62 | * |
| 63 | * Parameters: |
| 64 | * In: |
| 65 | * dwIoBase - Base Address for MAC |
| 66 | * byRegOfs - Offset of MAC Register |
| 67 | * byTestBits - Test bits |
| 68 | * Out: |
| 69 | * none |
| 70 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 71 | * Return Value: true if all test bits On; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 72 | * |
| 73 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 74 | bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 75 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 76 | unsigned char byData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 77 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 78 | VNSvInPortB(dwIoBase + byRegOfs, &byData); |
| 79 | return (byData & byTestBits) == byTestBits; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /* |
| 83 | * Description: |
| 84 | * Test if all test bits off |
| 85 | * |
| 86 | * Parameters: |
| 87 | * In: |
| 88 | * dwIoBase - Base Address for MAC |
| 89 | * byRegOfs - Offset of MAC Register |
| 90 | * byTestBits - Test bits |
| 91 | * Out: |
| 92 | * none |
| 93 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 94 | * Return Value: true if all test bits Off; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 95 | * |
| 96 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 97 | bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 98 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 99 | unsigned char byData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 100 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 101 | VNSvInPortB(dwIoBase + byRegOfs, &byData); |
| 102 | return !(byData & byTestBits); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /* |
| 106 | * Description: |
| 107 | * Test if MAC interrupt disable |
| 108 | * |
| 109 | * Parameters: |
| 110 | * In: |
| 111 | * dwIoBase - Base Address for MAC |
| 112 | * Out: |
| 113 | * none |
| 114 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 115 | * Return Value: true if interrupt is disable; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 116 | * |
| 117 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 118 | bool MACbIsIntDisable(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 119 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 120 | unsigned long dwData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 121 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 122 | VNSvInPortD(dwIoBase + MAC_REG_IMR, &dwData); |
| 123 | if (dwData != 0) |
| 124 | return false; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 125 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 126 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /* |
| 130 | * Description: |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 131 | * Set 802.11 Short Retry Limit |
| 132 | * |
| 133 | * Parameters: |
| 134 | * In: |
| 135 | * dwIoBase - Base Address for MAC |
| 136 | * byRetryLimit- Retry Limit |
| 137 | * Out: |
| 138 | * none |
| 139 | * |
| 140 | * Return Value: none |
| 141 | * |
| 142 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 143 | void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 144 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 145 | // set SRT |
| 146 | VNSvOutPortB(dwIoBase + MAC_REG_SRT, byRetryLimit); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /* |
| 150 | * Description: |
| 151 | * Get 802.11 Short Retry Limit |
| 152 | * |
| 153 | * Parameters: |
| 154 | * In: |
| 155 | * dwIoBase - Base Address for MAC |
| 156 | * Out: |
| 157 | * pbyRetryLimit - Retry Limit Get |
| 158 | * |
| 159 | * Return Value: none |
| 160 | * |
| 161 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 162 | void MACvGetShortRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 163 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 164 | // get SRT |
| 165 | VNSvInPortB(dwIoBase + MAC_REG_SRT, pbyRetryLimit); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /* |
| 169 | * Description: |
| 170 | * Set 802.11 Long Retry Limit |
| 171 | * |
| 172 | * Parameters: |
| 173 | * In: |
| 174 | * dwIoBase - Base Address for MAC |
| 175 | * byRetryLimit- Retry Limit |
| 176 | * Out: |
| 177 | * none |
| 178 | * |
| 179 | * Return Value: none |
| 180 | * |
| 181 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 182 | void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 183 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 184 | // set LRT |
| 185 | VNSvOutPortB(dwIoBase + MAC_REG_LRT, byRetryLimit); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /* |
| 189 | * Description: |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 190 | * Set MAC Loopback mode |
| 191 | * |
| 192 | * Parameters: |
| 193 | * In: |
| 194 | * dwIoBase - Base Address for MAC |
| 195 | * byLoopbackMode - Loopback Mode |
| 196 | * Out: |
| 197 | * none |
| 198 | * |
| 199 | * Return Value: none |
| 200 | * |
| 201 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 202 | void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 203 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 204 | unsigned char byOrgValue; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 205 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 206 | ASSERT(byLoopbackMode < 3); |
| 207 | byLoopbackMode <<= 6; |
| 208 | // set TCR |
| 209 | VNSvInPortB(dwIoBase + MAC_REG_TEST, &byOrgValue); |
| 210 | byOrgValue = byOrgValue & 0x3F; |
| 211 | byOrgValue = byOrgValue | byLoopbackMode; |
| 212 | VNSvOutPortB(dwIoBase + MAC_REG_TEST, byOrgValue); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /* |
| 216 | * Description: |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 217 | * Save MAC registers to context buffer |
| 218 | * |
| 219 | * Parameters: |
| 220 | * In: |
| 221 | * dwIoBase - Base Address for MAC |
| 222 | * Out: |
| 223 | * pbyCxtBuf - Context buffer |
| 224 | * |
| 225 | * Return Value: none |
| 226 | * |
| 227 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 228 | void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 229 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 230 | int ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 231 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 232 | // read page0 register |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 233 | for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 234 | VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + ii)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 235 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 236 | MACvSelectPage1(dwIoBase); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 237 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 238 | // read page1 register |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 239 | for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 240 | VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 241 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 242 | MACvSelectPage0(dwIoBase); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /* |
| 246 | * Description: |
| 247 | * Restore MAC registers from context buffer |
| 248 | * |
| 249 | * Parameters: |
| 250 | * In: |
| 251 | * dwIoBase - Base Address for MAC |
| 252 | * pbyCxtBuf - Context buffer |
| 253 | * Out: |
| 254 | * none |
| 255 | * |
| 256 | * Return Value: none |
| 257 | * |
| 258 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 259 | void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 260 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 261 | int ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 262 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 263 | MACvSelectPage1(dwIoBase); |
| 264 | // restore page1 |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 265 | for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 266 | VNSvOutPortB((dwIoBase + ii), *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 267 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 268 | MACvSelectPage0(dwIoBase); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 269 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 270 | // restore RCR,TCR,IMR... |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 271 | for (ii = MAC_REG_RCR; ii < MAC_REG_ISR; ii++) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 272 | VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 273 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 274 | // restore MAC Config. |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 275 | for (ii = MAC_REG_LRT; ii < MAC_REG_PAGE1SEL; ii++) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 276 | VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii)); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 277 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 278 | VNSvOutPortB(dwIoBase + MAC_REG_CFG, *(pbyCxtBuf + MAC_REG_CFG)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 279 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 280 | // restore PS Config. |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 281 | for (ii = MAC_REG_PSCFG; ii < MAC_REG_BBREGCTL; ii++) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 282 | VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 283 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 284 | // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR |
| 285 | VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)); |
| 286 | VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)); |
| 287 | VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 288 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 289 | VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 290 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 291 | VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /* |
| 295 | * Description: |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 296 | * Software Reset MAC |
| 297 | * |
| 298 | * Parameters: |
| 299 | * In: |
| 300 | * dwIoBase - Base Address for MAC |
| 301 | * Out: |
| 302 | * none |
| 303 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 304 | * Return Value: true if Reset Success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 305 | * |
| 306 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 307 | bool MACbSoftwareReset(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 308 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 309 | unsigned char byData; |
| 310 | unsigned short ww; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 311 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 312 | // turn on HOSTCR_SOFTRST, just write 0x01 to reset |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 313 | VNSvOutPortB(dwIoBase + MAC_REG_HOSTCR, 0x01); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 314 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 315 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 316 | VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData); |
| 317 | if (!(byData & HOSTCR_SOFTRST)) |
| 318 | break; |
| 319 | } |
| 320 | if (ww == W_MAX_TIMEOUT) |
| 321 | return false; |
| 322 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | /* |
| 326 | * Description: |
| 327 | * save some important register's value, then do reset, then restore register's value |
| 328 | * |
| 329 | * Parameters: |
| 330 | * In: |
| 331 | * dwIoBase - Base Address for MAC |
| 332 | * Out: |
| 333 | * none |
| 334 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 335 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 336 | * |
| 337 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 338 | bool MACbSafeSoftwareReset(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 339 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 340 | unsigned char abyTmpRegData[MAC_MAX_CONTEXT_SIZE_PAGE0+MAC_MAX_CONTEXT_SIZE_PAGE1]; |
| 341 | bool bRetVal; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 342 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 343 | // PATCH.... |
| 344 | // save some important register's value, then do |
| 345 | // reset, then restore register's value |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 346 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 347 | // save MAC context |
| 348 | MACvSaveContext(dwIoBase, abyTmpRegData); |
| 349 | // do reset |
| 350 | bRetVal = MACbSoftwareReset(dwIoBase); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 351 | // restore MAC context, except CR0 |
| 352 | MACvRestoreContext(dwIoBase, abyTmpRegData); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 353 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 354 | return bRetVal; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | /* |
| 358 | * Description: |
| 359 | * Trun Off MAC Rx |
| 360 | * |
| 361 | * Parameters: |
| 362 | * In: |
| 363 | * dwIoBase - Base Address for MAC |
| 364 | * Out: |
| 365 | * none |
| 366 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 367 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 368 | * |
| 369 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 370 | bool MACbSafeRxOff(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 371 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 372 | unsigned short ww; |
| 373 | unsigned long dwData; |
| 374 | unsigned char byData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 375 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 376 | // turn off wow temp for turn off Rx safely |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 377 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 378 | // Clear RX DMA0,1 |
| 379 | VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_CLRRUN); |
| 380 | VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_CLRRUN); |
| 381 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 382 | VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL0, &dwData); |
| 383 | if (!(dwData & DMACTL_RUN)) |
| 384 | break; |
| 385 | } |
| 386 | if (ww == W_MAX_TIMEOUT) { |
| 387 | DBG_PORT80(0x10); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 388 | pr_debug(" DBG_PORT80(0x10)\n"); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 389 | return false; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 390 | } |
| 391 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 392 | VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL1, &dwData); |
| 393 | if (!(dwData & DMACTL_RUN)) |
| 394 | break; |
| 395 | } |
| 396 | if (ww == W_MAX_TIMEOUT) { |
| 397 | DBG_PORT80(0x11); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 398 | pr_debug(" DBG_PORT80(0x11)\n"); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 399 | return false; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 400 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 401 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 402 | // try to safe shutdown RX |
| 403 | MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_RXON); |
| 404 | // W_MAX_TIMEOUT is the timeout period |
| 405 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 406 | VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData); |
| 407 | if (!(byData & HOSTCR_RXONST)) |
| 408 | break; |
| 409 | } |
| 410 | if (ww == W_MAX_TIMEOUT) { |
| 411 | DBG_PORT80(0x12); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 412 | pr_debug(" DBG_PORT80(0x12)\n"); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 413 | return false; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 414 | } |
| 415 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /* |
| 419 | * Description: |
| 420 | * Trun Off MAC Tx |
| 421 | * |
| 422 | * Parameters: |
| 423 | * In: |
| 424 | * dwIoBase - Base Address for MAC |
| 425 | * Out: |
| 426 | * none |
| 427 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 428 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 429 | * |
| 430 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 431 | bool MACbSafeTxOff(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 432 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 433 | unsigned short ww; |
| 434 | unsigned long dwData; |
| 435 | unsigned char byData; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 436 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 437 | // Clear TX DMA |
| 438 | //Tx0 |
| 439 | VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_CLRRUN); |
| 440 | //AC0 |
| 441 | VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_CLRRUN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 442 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 443 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 444 | VNSvInPortD(dwIoBase + MAC_REG_TXDMACTL0, &dwData); |
| 445 | if (!(dwData & DMACTL_RUN)) |
| 446 | break; |
| 447 | } |
| 448 | if (ww == W_MAX_TIMEOUT) { |
| 449 | DBG_PORT80(0x20); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 450 | pr_debug(" DBG_PORT80(0x20)\n"); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 451 | return false; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 452 | } |
| 453 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 454 | VNSvInPortD(dwIoBase + MAC_REG_AC0DMACTL, &dwData); |
| 455 | if (!(dwData & DMACTL_RUN)) |
| 456 | break; |
| 457 | } |
| 458 | if (ww == W_MAX_TIMEOUT) { |
| 459 | DBG_PORT80(0x21); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 460 | pr_debug(" DBG_PORT80(0x21)\n"); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 461 | return false; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 462 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 463 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 464 | // try to safe shutdown TX |
| 465 | MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_TXON); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 466 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 467 | // W_MAX_TIMEOUT is the timeout period |
| 468 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 469 | VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData); |
| 470 | if (!(byData & HOSTCR_TXONST)) |
| 471 | break; |
| 472 | } |
| 473 | if (ww == W_MAX_TIMEOUT) { |
| 474 | DBG_PORT80(0x24); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 475 | pr_debug(" DBG_PORT80(0x24)\n"); |
Joe Perches | a4ef27a | 2013-03-18 20:55:38 -0700 | [diff] [blame] | 476 | return false; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 477 | } |
| 478 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | /* |
| 482 | * Description: |
| 483 | * Stop MAC function |
| 484 | * |
| 485 | * Parameters: |
| 486 | * In: |
| 487 | * dwIoBase - Base Address for MAC |
| 488 | * Out: |
| 489 | * none |
| 490 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 491 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 492 | * |
| 493 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 494 | bool MACbSafeStop(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 495 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 496 | MACvRegBitsOff(dwIoBase, MAC_REG_TCR, TCR_AUTOBCNTX); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 497 | |
Teodora Baluta | 1208f14 | 2013-11-10 17:12:42 +0200 | [diff] [blame] | 498 | if (!MACbSafeRxOff(dwIoBase)) { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 499 | DBG_PORT80(0xA1); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 500 | pr_debug(" MACbSafeRxOff == false)\n"); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 501 | MACbSafeSoftwareReset(dwIoBase); |
| 502 | return false; |
| 503 | } |
Teodora Baluta | 1208f14 | 2013-11-10 17:12:42 +0200 | [diff] [blame] | 504 | if (!MACbSafeTxOff(dwIoBase)) { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 505 | DBG_PORT80(0xA2); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 506 | pr_debug(" MACbSafeTxOff == false)\n"); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 507 | MACbSafeSoftwareReset(dwIoBase); |
| 508 | return false; |
| 509 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 510 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 511 | MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_MACEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 512 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 513 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | /* |
| 517 | * Description: |
| 518 | * Shut Down MAC |
| 519 | * |
| 520 | * Parameters: |
| 521 | * In: |
| 522 | * dwIoBase - Base Address for MAC |
| 523 | * Out: |
| 524 | * none |
| 525 | * |
Charles Clément | 5a5a2a6 | 2010-08-01 17:15:49 +0200 | [diff] [blame] | 526 | * Return Value: true if success; otherwise false |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 527 | * |
| 528 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 529 | bool MACbShutdown(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 530 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 531 | // disable MAC IMR |
| 532 | MACvIntDisable(dwIoBase); |
| 533 | MACvSetLoopbackMode(dwIoBase, MAC_LB_INTERNAL); |
| 534 | // stop the adapter |
| 535 | if (!MACbSafeStop(dwIoBase)) { |
| 536 | MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE); |
| 537 | return false; |
| 538 | } |
| 539 | MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE); |
| 540 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | /* |
| 544 | * Description: |
| 545 | * Initialize MAC |
| 546 | * |
| 547 | * Parameters: |
| 548 | * In: |
| 549 | * dwIoBase - Base Address for MAC |
| 550 | * Out: |
| 551 | * none |
| 552 | * |
| 553 | * Return Value: none |
| 554 | * |
| 555 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 556 | void MACvInitialize(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 557 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 558 | // clear sticky bits |
| 559 | MACvClearStckDS(dwIoBase); |
| 560 | // disable force PME-enable |
| 561 | VNSvOutPortB(dwIoBase + MAC_REG_PMC1, PME_OVR); |
| 562 | // only 3253 A |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 563 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 564 | // do reset |
| 565 | MACbSoftwareReset(dwIoBase); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 566 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 567 | // reset TSF counter |
| 568 | VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); |
| 569 | // enable TSF counter |
| 570 | VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | /* |
| 574 | * Description: |
| 575 | * Set the chip with current rx descriptor address |
| 576 | * |
| 577 | * Parameters: |
| 578 | * In: |
| 579 | * dwIoBase - Base Address for MAC |
| 580 | * dwCurrDescAddr - Descriptor Address |
| 581 | * Out: |
| 582 | * none |
| 583 | * |
| 584 | * Return Value: none |
| 585 | * |
| 586 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 587 | void MACvSetCurrRx0DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 588 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 589 | unsigned short ww; |
| 590 | unsigned char byData; |
| 591 | unsigned char byOrgDMACtl; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 592 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 593 | VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL0, &byOrgDMACtl); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 594 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 595 | VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL0+2, DMACTL_RUN); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 596 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 597 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 598 | VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL0, &byData); |
| 599 | if (!(byData & DMACTL_RUN)) |
| 600 | break; |
| 601 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 602 | |
| 603 | if (ww == W_MAX_TIMEOUT) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 604 | DBG_PORT80(0x13); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 605 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 606 | VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, dwCurrDescAddr); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 607 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 608 | VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_RUN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /* |
| 612 | * Description: |
| 613 | * Set the chip with current rx descriptor address |
| 614 | * |
| 615 | * Parameters: |
| 616 | * In: |
| 617 | * dwIoBase - Base Address for MAC |
| 618 | * dwCurrDescAddr - Descriptor Address |
| 619 | * Out: |
| 620 | * none |
| 621 | * |
| 622 | * Return Value: none |
| 623 | * |
| 624 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 625 | void MACvSetCurrRx1DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 626 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 627 | unsigned short ww; |
| 628 | unsigned char byData; |
| 629 | unsigned char byOrgDMACtl; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 630 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 631 | VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL1, &byOrgDMACtl); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 632 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 633 | VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL1+2, DMACTL_RUN); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 634 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 635 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 636 | VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL1, &byData); |
| 637 | if (!(byData & DMACTL_RUN)) |
| 638 | break; |
| 639 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 640 | if (ww == W_MAX_TIMEOUT) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 641 | DBG_PORT80(0x14); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 642 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 643 | VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, dwCurrDescAddr); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 644 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 645 | VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_RUN); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 646 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* |
| 650 | * Description: |
| 651 | * Set the chip with current tx0 descriptor address |
| 652 | * |
| 653 | * Parameters: |
| 654 | * In: |
| 655 | * dwIoBase - Base Address for MAC |
| 656 | * dwCurrDescAddr - Descriptor Address |
| 657 | * Out: |
| 658 | * none |
| 659 | * |
| 660 | * Return Value: none |
| 661 | * |
| 662 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 663 | void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 664 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 665 | unsigned short ww; |
| 666 | unsigned char byData; |
| 667 | unsigned char byOrgDMACtl; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 668 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 669 | VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byOrgDMACtl); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 670 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 671 | VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0+2, DMACTL_RUN); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 672 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 673 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 674 | VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byData); |
| 675 | if (!(byData & DMACTL_RUN)) |
| 676 | break; |
| 677 | } |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 678 | if (ww == W_MAX_TIMEOUT) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 679 | DBG_PORT80(0x25); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 680 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 681 | VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, dwCurrDescAddr); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 682 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 683 | VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_RUN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | /* |
| 687 | * Description: |
| 688 | * Set the chip with current AC0 descriptor address |
| 689 | * |
| 690 | * Parameters: |
| 691 | * In: |
| 692 | * dwIoBase - Base Address for MAC |
| 693 | * dwCurrDescAddr - Descriptor Address |
| 694 | * Out: |
| 695 | * none |
| 696 | * |
| 697 | * Return Value: none |
| 698 | * |
| 699 | */ |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 700 | //TxDMA1 = AC0DMA |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 701 | void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 702 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 703 | unsigned short ww; |
| 704 | unsigned char byData; |
| 705 | unsigned char byOrgDMACtl; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 706 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 707 | VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byOrgDMACtl); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 708 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 709 | VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL+2, DMACTL_RUN); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 710 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 711 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 712 | VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byData); |
| 713 | if (!(byData & DMACTL_RUN)) |
| 714 | break; |
| 715 | } |
| 716 | if (ww == W_MAX_TIMEOUT) { |
| 717 | DBG_PORT80(0x26); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 718 | pr_debug(" DBG_PORT80(0x26)\n"); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 719 | } |
| 720 | VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, dwCurrDescAddr); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 721 | if (byOrgDMACtl & DMACTL_RUN) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 722 | VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 723 | } |
| 724 | |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 725 | void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, unsigned long dwCurrDescAddr) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 726 | { |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 727 | if (iTxType == TYPE_AC0DMA) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 728 | MACvSetCurrAC0DescAddrEx(dwIoBase, dwCurrDescAddr); |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 729 | else if (iTxType == TYPE_TXDMA0) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 730 | MACvSetCurrTx0DescAddrEx(dwIoBase, dwCurrDescAddr); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | /* |
| 734 | * Description: |
| 735 | * Micro Second Delay via MAC |
| 736 | * |
| 737 | * Parameters: |
| 738 | * In: |
| 739 | * dwIoBase - Base Address for MAC |
| 740 | * uDelay - Delay time (timer resolution is 4 us) |
| 741 | * Out: |
| 742 | * none |
| 743 | * |
| 744 | * Return Value: none |
| 745 | * |
| 746 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 747 | void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 748 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 749 | unsigned char byValue; |
| 750 | unsigned int uu, ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 751 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 752 | VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); |
| 753 | VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelay); |
| 754 | VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, (TMCTL_TMD | TMCTL_TE)); |
| 755 | for (ii = 0; ii < 66; ii++) { // assume max PCI clock is 66Mhz |
| 756 | for (uu = 0; uu < uDelay; uu++) { |
| 757 | VNSvInPortB(dwIoBase + MAC_REG_TMCTL0, &byValue); |
| 758 | if ((byValue == 0) || |
| 759 | (byValue & TMCTL_TSUSP)) { |
| 760 | VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); |
| 761 | return; |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | /* |
| 769 | * Description: |
| 770 | * Micro Second One shot timer via MAC |
| 771 | * |
| 772 | * Parameters: |
| 773 | * In: |
| 774 | * dwIoBase - Base Address for MAC |
| 775 | * uDelay - Delay time |
| 776 | * Out: |
| 777 | * none |
| 778 | * |
| 779 | * Return Value: none |
| 780 | * |
| 781 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 782 | void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 783 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 784 | VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, 0); |
| 785 | VNSvOutPortD(dwIoBase + MAC_REG_TMDATA1, uDelayTime); |
| 786 | VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, (TMCTL_TMD | TMCTL_TE)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 787 | } |
| 788 | |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 789 | void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 790 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 791 | if (wOffset > 273) |
| 792 | return; |
| 793 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); |
| 794 | VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); |
| 795 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 796 | } |
| 797 | |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 798 | bool MACbPSWakeup(void __iomem *dwIoBase) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 799 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 800 | unsigned char byOrgValue; |
| 801 | unsigned int ww; |
| 802 | // Read PSCTL |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 803 | if (MACbIsRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PS)) |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 804 | return true; |
Guido Martínez | bc5cf65 | 2014-04-19 16:45:00 -0300 | [diff] [blame] | 805 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 806 | // Disable PS |
| 807 | MACvRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PSEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 808 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 809 | // Check if SyncFlushOK |
| 810 | for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { |
| 811 | VNSvInPortB(dwIoBase + MAC_REG_PSCTL , &byOrgValue); |
| 812 | if (byOrgValue & PSCTL_WAKEDONE) |
| 813 | break; |
| 814 | } |
| 815 | if (ww == W_MAX_TIMEOUT) { |
| 816 | DBG_PORT80(0x36); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 817 | pr_debug(" DBG_PORT80(0x33)\n"); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 818 | return false; |
| 819 | } |
| 820 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | /* |
| 824 | * Description: |
| 825 | * Set the Key by MISCFIFO |
| 826 | * |
| 827 | * Parameters: |
| 828 | * In: |
| 829 | * dwIoBase - Base Address for MAC |
| 830 | * |
| 831 | * Out: |
| 832 | * none |
| 833 | * |
| 834 | * Return Value: none |
| 835 | * |
| 836 | */ |
| 837 | |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 838 | void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, |
Malcolm Priestley | 4dbc77c | 2014-03-06 22:44:22 +0000 | [diff] [blame] | 839 | unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 840 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 841 | unsigned short wOffset; |
Malcolm Priestley | 4dbc77c | 2014-03-06 22:44:22 +0000 | [diff] [blame] | 842 | u32 dwData; |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 843 | int ii; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 844 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 845 | if (byLocalID <= 1) |
| 846 | return; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 847 | |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 848 | pr_debug("MACvSetKeyEntry\n"); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 849 | wOffset = MISCFIFO_KEYETRY0; |
| 850 | wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 851 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 852 | dwData = 0; |
| 853 | dwData |= wKeyCtl; |
| 854 | dwData <<= 16; |
| 855 | dwData |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5)); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 856 | pr_debug("1. wOffset: %d, Data: %X, KeyCtl:%X\n", |
| 857 | wOffset, dwData, wKeyCtl); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 858 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 859 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); |
| 860 | VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); |
| 861 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); |
| 862 | wOffset++; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 863 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 864 | dwData = 0; |
| 865 | dwData |= *(pbyAddr+3); |
| 866 | dwData <<= 8; |
| 867 | dwData |= *(pbyAddr+2); |
| 868 | dwData <<= 8; |
| 869 | dwData |= *(pbyAddr+1); |
| 870 | dwData <<= 8; |
| 871 | dwData |= *(pbyAddr+0); |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 872 | pr_debug("2. wOffset: %d, Data: %X\n", wOffset, dwData); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 873 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 874 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); |
| 875 | VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); |
| 876 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); |
| 877 | wOffset++; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 878 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 879 | wOffset += (uKeyIdx * 4); |
| 880 | for (ii = 0; ii < 4; ii++) { |
| 881 | // always push 128 bits |
Joe Perches | 48caf5a | 2014-08-17 09:17:04 -0700 | [diff] [blame] | 882 | pr_debug("3.(%d) wOffset: %d, Data: %X\n", |
| 883 | ii, wOffset+ii, *pdwKey); |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 884 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii); |
| 885 | VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, *pdwKey++); |
| 886 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); |
| 887 | } |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 888 | } |
| 889 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 890 | /* |
| 891 | * Description: |
| 892 | * Disable the Key Entry by MISCFIFO |
| 893 | * |
| 894 | * Parameters: |
| 895 | * In: |
| 896 | * dwIoBase - Base Address for MAC |
| 897 | * |
| 898 | * Out: |
| 899 | * none |
| 900 | * |
| 901 | * Return Value: none |
| 902 | * |
| 903 | */ |
Guillaume Clement | 1683440 | 2014-07-22 22:08:26 +0200 | [diff] [blame] | 904 | void MACvDisableKeyEntry(void __iomem *dwIoBase, unsigned int uEntryIdx) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 905 | { |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 906 | unsigned short wOffset; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 907 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 908 | wOffset = MISCFIFO_KEYETRY0; |
| 909 | wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 910 | |
Joe Perches | c3504bf | 2013-03-18 10:44:55 -0700 | [diff] [blame] | 911 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset); |
| 912 | VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, 0); |
| 913 | VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 914 | } |