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