Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Agere Systems Inc. |
| 3 | * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs |
| 4 | * |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 5 | * Copyright © 2005 Agere Systems Inc. |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * http://www.agere.com |
| 8 | * |
| 9 | *------------------------------------------------------------------------------ |
| 10 | * |
| 11 | * et131x_initpci.c - Routines and data used to register the driver with the |
| 12 | * PCI (and PCI Express) subsystem, as well as basic driver |
| 13 | * init and startup. |
| 14 | * |
| 15 | *------------------------------------------------------------------------------ |
| 16 | * |
| 17 | * SOFTWARE LICENSE |
| 18 | * |
| 19 | * This software is provided subject to the following terms and conditions, |
| 20 | * which you should read carefully before using the software. Using this |
| 21 | * software indicates your acceptance of these terms and conditions. If you do |
| 22 | * not agree with these terms and conditions, do not use the software. |
| 23 | * |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 24 | * Copyright © 2005 Agere Systems Inc. |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 25 | * All rights reserved. |
| 26 | * |
| 27 | * Redistribution and use in source or binary forms, with or without |
| 28 | * modifications, are permitted provided that the following conditions are met: |
| 29 | * |
| 30 | * . Redistributions of source code must retain the above copyright notice, this |
| 31 | * list of conditions and the following Disclaimer as comments in the code as |
| 32 | * well as in the documentation and/or other materials provided with the |
| 33 | * distribution. |
| 34 | * |
| 35 | * . Redistributions in binary form must reproduce the above copyright notice, |
| 36 | * this list of conditions and the following Disclaimer in the documentation |
| 37 | * and/or other materials provided with the distribution. |
| 38 | * |
| 39 | * . Neither the name of Agere Systems Inc. nor the names of the contributors |
| 40 | * may be used to endorse or promote products derived from this software |
| 41 | * without specific prior written permission. |
| 42 | * |
| 43 | * Disclaimer |
| 44 | * |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 45 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 46 | * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF |
| 47 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY |
| 48 | * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN |
| 49 | * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY |
| 50 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 51 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 52 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 53 | * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT |
| 54 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 55 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 56 | * DAMAGE. |
| 57 | * |
| 58 | */ |
| 59 | |
| 60 | #include "et131x_version.h" |
| 61 | #include "et131x_debug.h" |
| 62 | #include "et131x_defs.h" |
| 63 | |
| 64 | #include <linux/pci.h> |
| 65 | #include <linux/init.h> |
| 66 | #include <linux/module.h> |
| 67 | #include <linux/types.h> |
| 68 | #include <linux/kernel.h> |
| 69 | |
| 70 | #include <linux/sched.h> |
| 71 | #include <linux/ptrace.h> |
| 72 | #include <linux/slab.h> |
| 73 | #include <linux/ctype.h> |
| 74 | #include <linux/string.h> |
| 75 | #include <linux/timer.h> |
| 76 | #include <linux/interrupt.h> |
| 77 | #include <linux/in.h> |
| 78 | #include <linux/delay.h> |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 79 | #include <linux/io.h> |
| 80 | #include <linux/bitops.h> |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 81 | #include <asm/system.h> |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 82 | |
| 83 | #include <linux/netdevice.h> |
| 84 | #include <linux/etherdevice.h> |
| 85 | #include <linux/skbuff.h> |
| 86 | #include <linux/if_arp.h> |
| 87 | #include <linux/ioport.h> |
| 88 | #include <linux/random.h> |
| 89 | |
| 90 | #include "et1310_phy.h" |
| 91 | #include "et1310_pm.h" |
| 92 | #include "et1310_jagcore.h" |
| 93 | |
| 94 | #include "et131x_adapter.h" |
| 95 | #include "et131x_netdev.h" |
| 96 | #include "et131x_config.h" |
| 97 | #include "et131x_isr.h" |
| 98 | |
| 99 | #include "et1310_address_map.h" |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 100 | #include "et1310_tx.h" |
| 101 | #include "et1310_rx.h" |
| 102 | #include "et1310_mac.h" |
| 103 | #include "et1310_eeprom.h" |
| 104 | |
| 105 | |
| 106 | int __devinit et131x_pci_setup(struct pci_dev *pdev, |
| 107 | const struct pci_device_id *ent); |
| 108 | void __devexit et131x_pci_remove(struct pci_dev *pdev); |
| 109 | |
| 110 | |
| 111 | /* Modinfo parameters (filled out using defines from et131x_version.h) */ |
| 112 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 113 | MODULE_DESCRIPTION(DRIVER_INFO); |
| 114 | MODULE_LICENSE(DRIVER_LICENSE); |
| 115 | |
| 116 | /* Module Parameters and related data for debugging facilities */ |
| 117 | #ifdef CONFIG_ET131X_DEBUG |
| 118 | static u32 et131x_debug_level = DBG_LVL; |
| 119 | static u32 et131x_debug_flags = DBG_DEFAULTS; |
| 120 | |
| 121 | /* |
| 122 | et131x_debug_level : |
| 123 | Level of debugging desired (0-7) |
| 124 | 7 : DBG_RX_ON | DBG_TX_ON |
| 125 | 6 : DBG_PARAM_ON |
| 126 | 5 : DBG_VERBOSE_ON |
| 127 | 4 : DBG_TRACE_ON |
| 128 | 3 : DBG_NOTICE_ON |
| 129 | 2 : no debug info |
| 130 | 1 : no debug info |
| 131 | 0 : no debug info |
| 132 | */ |
| 133 | |
| 134 | module_param(et131x_debug_level, uint, 0); |
| 135 | module_param(et131x_debug_flags, uint, 0); |
| 136 | |
| 137 | MODULE_PARM_DESC(et131x_debug_level, "Level of debugging desired (0-7)"); |
| 138 | |
| 139 | static dbg_info_t et131x_info = { DRIVER_NAME_EXT, 0, 0 }; |
| 140 | dbg_info_t *et131x_dbginfo = &et131x_info; |
| 141 | #endif /* CONFIG_ET131X_DEBUG */ |
| 142 | |
Alan Cox | 8c5f20f | 2009-08-27 11:00:24 +0100 | [diff] [blame] | 143 | /* Defines for Parameter Default/Min/Max vaules */ |
| 144 | #define PARM_SPEED_DUPLEX_MIN 0 |
| 145 | #define PARM_SPEED_DUPLEX_MAX 5 |
| 146 | |
| 147 | /* Module parameter for disabling NMI |
| 148 | * et131x_nmi_disable : |
| 149 | * Disable NMI (0-2) [0] |
| 150 | * 0 : |
| 151 | * 1 : |
| 152 | * 2 : |
| 153 | */ |
| 154 | static u32 et131x_nmi_disable; /* 0-2 */ |
| 155 | module_param(et131x_nmi_disable, uint, 0); |
| 156 | MODULE_PARM_DESC(et131x_nmi_disable, "Disable NMI (0-2) [0]"); |
| 157 | |
| 158 | /* Module parameter for manual speed setting |
| 159 | * Set Link speed and dublex manually (0-5) [0] |
| 160 | * 1 : 10Mb Half-Duplex |
| 161 | * 2 : 10Mb Full-Duplex |
| 162 | * 3 : 100Mb Half-Duplex |
| 163 | * 4 : 100Mb Full-Duplex |
| 164 | * 5 : 1000Mb Full-Duplex |
| 165 | * 0 : Auto Speed Auto Duplex // default |
| 166 | */ |
| 167 | static u32 et131x_speed_set; |
| 168 | module_param(et131x_speed_set, uint, 0); |
| 169 | MODULE_PARM_DESC(et131x_speed_set, |
| 170 | "Set Link speed and dublex manually (0-5) [0] \n 1 : 10Mb Half-Duplex \n 2 : 10Mb Full-Duplex \n 3 : 100Mb Half-Duplex \n 4 : 100Mb Full-Duplex \n 5 : 1000Mb Full-Duplex \n 0 : Auto Speed Auto Dublex"); |
| 171 | |
| 172 | |
| 173 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 174 | static struct pci_device_id et131x_pci_table[] __devinitdata = { |
| 175 | {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID, |
| 176 | PCI_ANY_ID, 0, 0, 0UL}, |
| 177 | {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID, |
| 178 | PCI_ANY_ID, 0, 0, 0UL}, |
| 179 | {0,} |
| 180 | }; |
| 181 | |
| 182 | MODULE_DEVICE_TABLE(pci, et131x_pci_table); |
| 183 | |
| 184 | static struct pci_driver et131x_driver = { |
| 185 | .name = DRIVER_NAME, |
| 186 | .id_table = et131x_pci_table, |
| 187 | .probe = et131x_pci_setup, |
| 188 | .remove = __devexit_p(et131x_pci_remove), |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 189 | .suspend = NULL, /* et131x_pci_suspend */ |
| 190 | .resume = NULL, /* et131x_pci_resume */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | |
| 194 | /** |
| 195 | * et131x_init_module - The "main" entry point called on driver initialization |
| 196 | * |
| 197 | * Returns 0 on success, errno on failure (as defined in errno.h) |
| 198 | */ |
| 199 | int et131x_init_module(void) |
| 200 | { |
| 201 | int result; |
| 202 | |
| 203 | #ifdef CONFIG_ET131X_DEBUG |
| 204 | /* Set the level of debug messages displayed using the module |
| 205 | * parameter |
| 206 | */ |
| 207 | et131x_dbginfo->dbgFlags = et131x_debug_flags; |
| 208 | |
| 209 | switch (et131x_debug_level) { |
| 210 | case 7: |
| 211 | et131x_dbginfo->dbgFlags |= (DBG_RX_ON | DBG_TX_ON); |
| 212 | |
| 213 | case 6: |
| 214 | et131x_dbginfo->dbgFlags |= DBG_PARAM_ON; |
| 215 | |
| 216 | case 5: |
| 217 | et131x_dbginfo->dbgFlags |= DBG_VERBOSE_ON; |
| 218 | |
| 219 | case 4: |
| 220 | et131x_dbginfo->dbgFlags |= DBG_TRACE_ON; |
| 221 | |
| 222 | case 3: |
| 223 | et131x_dbginfo->dbgFlags |= DBG_NOTICE_ON; |
| 224 | |
| 225 | case 2: |
| 226 | case 1: |
| 227 | case 0: |
| 228 | default: |
| 229 | break; |
| 230 | } |
| 231 | #endif /* CONFIG_ET131X_DEBUG */ |
| 232 | |
| 233 | DBG_ENTER(et131x_dbginfo); |
| 234 | DBG_PRINT("%s\n", DRIVER_INFO); |
| 235 | |
Alan Cox | 8c5f20f | 2009-08-27 11:00:24 +0100 | [diff] [blame] | 236 | if (et131x_speed_set < PARM_SPEED_DUPLEX_MIN || |
| 237 | et131x_speed_set > PARM_SPEED_DUPLEX_MAX) { |
| 238 | printk(KERN_WARNING "et131x: invalid speed setting ignored.\n"); |
| 239 | et131x_speed_set = 0; |
| 240 | } |
| 241 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 242 | result = pci_register_driver(&et131x_driver); |
| 243 | |
| 244 | DBG_LEAVE(et131x_dbginfo); |
| 245 | return result; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * et131x_cleanup_module - The entry point called on driver cleanup |
| 250 | */ |
| 251 | void et131x_cleanup_module(void) |
| 252 | { |
| 253 | DBG_ENTER(et131x_dbginfo); |
| 254 | |
| 255 | pci_unregister_driver(&et131x_driver); |
| 256 | |
| 257 | DBG_LEAVE(et131x_dbginfo); |
| 258 | } |
| 259 | |
| 260 | /* |
| 261 | * These macros map the driver-specific init_module() and cleanup_module() |
| 262 | * routines so they can be called by the kernel. |
| 263 | */ |
| 264 | module_init(et131x_init_module); |
| 265 | module_exit(et131x_cleanup_module); |
| 266 | |
| 267 | |
| 268 | /** |
| 269 | * et131x_find_adapter - Find the adapter and get all the assigned resources |
| 270 | * @adapter: pointer to our private adapter structure |
| 271 | * |
| 272 | * Returns 0 on success, errno on failure (as defined in errno.h) |
| 273 | */ |
| 274 | int et131x_find_adapter(struct et131x_adapter *adapter, struct pci_dev *pdev) |
| 275 | { |
| 276 | int result; |
| 277 | uint8_t eepromStat; |
| 278 | uint8_t maxPayload = 0; |
| 279 | uint8_t read_size_reg; |
Alan Cox | 5ec3487 | 2009-08-27 10:59:13 +0100 | [diff] [blame] | 280 | u8 rev; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 281 | |
| 282 | DBG_ENTER(et131x_dbginfo); |
| 283 | |
| 284 | /* Allow disabling of Non-Maskable Interrupts in I/O space, to |
| 285 | * support validation. |
| 286 | */ |
| 287 | if (adapter->RegistryNMIDisable) { |
| 288 | uint8_t RegisterVal; |
| 289 | |
| 290 | RegisterVal = inb(ET1310_NMI_DISABLE); |
| 291 | RegisterVal &= 0xf3; |
| 292 | |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 293 | if (adapter->RegistryNMIDisable == 2) |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 294 | RegisterVal |= 0xc; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 295 | |
| 296 | outb(ET1310_NMI_DISABLE, RegisterVal); |
| 297 | } |
| 298 | |
| 299 | /* We first need to check the EEPROM Status code located at offset |
| 300 | * 0xB2 of config space |
| 301 | */ |
| 302 | result = pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, |
| 303 | &eepromStat); |
| 304 | |
| 305 | /* THIS IS A WORKAROUND: |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 306 | * I need to call this function twice to get my card in a |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 307 | * LG M1 Express Dual running. I tried also a msleep before this |
| 308 | * function, because I thougth there could be some time condidions |
| 309 | * but it didn't work. Call the whole function twice also work. |
| 310 | */ |
| 311 | result = pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, |
| 312 | &eepromStat); |
| 313 | if (result != PCIBIOS_SUCCESSFUL) { |
| 314 | DBG_ERROR(et131x_dbginfo, "Could not read PCI config space for " |
| 315 | "EEPROM Status\n"); |
| 316 | DBG_LEAVE(et131x_dbginfo); |
| 317 | return -EIO; |
| 318 | } |
| 319 | |
| 320 | /* Determine if the error(s) we care about are present. If they are |
| 321 | * present, we need to fail. |
| 322 | */ |
| 323 | if (eepromStat & 0x4C) { |
Alan Cox | 5ec3487 | 2009-08-27 10:59:13 +0100 | [diff] [blame] | 324 | result = pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 325 | if (result != PCIBIOS_SUCCESSFUL) { |
| 326 | DBG_ERROR(et131x_dbginfo, |
| 327 | "Could not read PCI config space for " |
| 328 | "Revision ID\n"); |
| 329 | DBG_LEAVE(et131x_dbginfo); |
| 330 | return -EIO; |
Alan Cox | 5ec3487 | 2009-08-27 10:59:13 +0100 | [diff] [blame] | 331 | } else if (rev == 0x01) { |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 332 | int32_t nLoop; |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 333 | uint8_t temp[4] = { 0xFE, 0x13, 0x10, 0xFF }; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 334 | |
| 335 | /* Re-write the first 4 bytes if we have an eeprom |
| 336 | * present and the revision id is 1, this fixes the |
| 337 | * corruption seen with 1310 B Silicon |
| 338 | */ |
| 339 | for (nLoop = 0; nLoop < 3; nLoop++) { |
Alan Cox | 13071fd | 2009-08-27 11:01:04 +0100 | [diff] [blame] | 340 | EepromWriteByte(adapter, nLoop, temp[nLoop]); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
| 344 | DBG_ERROR(et131x_dbginfo, |
| 345 | "Fatal EEPROM Status Error - 0x%04x\n", eepromStat); |
| 346 | |
| 347 | /* This error could mean that there was an error reading the |
| 348 | * eeprom or that the eeprom doesn't exist. We will treat |
| 349 | * each case the same and not try to gather additional |
| 350 | * information that normally would come from the eeprom, like |
| 351 | * MAC Address |
| 352 | */ |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 353 | adapter->has_eeprom = 0; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 354 | |
| 355 | DBG_LEAVE(et131x_dbginfo); |
| 356 | return -EIO; |
| 357 | } else { |
| 358 | DBG_TRACE(et131x_dbginfo, "EEPROM Status Code - 0x%04x\n", |
| 359 | eepromStat); |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 360 | adapter->has_eeprom = 1; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | /* Read the EEPROM for information regarding LED behavior. Refer to |
| 364 | * ET1310_phy.c, et131x_xcvr_init(), for its use. |
| 365 | */ |
Alan Cox | 13071fd | 2009-08-27 11:01:04 +0100 | [diff] [blame] | 366 | EepromReadByte(adapter, 0x70, &adapter->eepromData[0]); |
| 367 | EepromReadByte(adapter, 0x71, &adapter->eepromData[1]); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 368 | |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 369 | if (adapter->eepromData[0] != 0xcd) |
| 370 | /* Disable all optional features */ |
| 371 | adapter->eepromData[1] = 0x00; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 372 | |
| 373 | /* Let's set up the PORT LOGIC Register. First we need to know what |
| 374 | * the max_payload_size is |
| 375 | */ |
| 376 | result = pci_read_config_byte(pdev, ET1310_PCI_MAX_PYLD, &maxPayload); |
| 377 | if (result != PCIBIOS_SUCCESSFUL) { |
| 378 | DBG_ERROR(et131x_dbginfo, "Could not read PCI config space for " |
| 379 | "Max Payload Size\n"); |
| 380 | DBG_LEAVE(et131x_dbginfo); |
| 381 | return -EIO; |
| 382 | } |
| 383 | |
| 384 | /* Program the Ack/Nak latency and replay timers */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 385 | maxPayload &= 0x07; /* Only the lower 3 bits are valid */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 386 | |
| 387 | if (maxPayload < 2) { |
| 388 | const uint16_t AckNak[2] = { 0x76, 0xD0 }; |
| 389 | const uint16_t Replay[2] = { 0x1E0, 0x2ED }; |
| 390 | |
| 391 | result = pci_write_config_word(pdev, ET1310_PCI_ACK_NACK, |
| 392 | AckNak[maxPayload]); |
| 393 | if (result != PCIBIOS_SUCCESSFUL) { |
| 394 | DBG_ERROR(et131x_dbginfo, |
| 395 | "Could not write PCI config space " |
| 396 | "for ACK/NAK\n"); |
| 397 | DBG_LEAVE(et131x_dbginfo); |
| 398 | return -EIO; |
| 399 | } |
| 400 | |
| 401 | result = pci_write_config_word(pdev, ET1310_PCI_REPLAY, |
| 402 | Replay[maxPayload]); |
| 403 | if (result != PCIBIOS_SUCCESSFUL) { |
| 404 | DBG_ERROR(et131x_dbginfo, |
| 405 | "Could not write PCI config space " |
| 406 | "for Replay Timer\n"); |
| 407 | DBG_LEAVE(et131x_dbginfo); |
| 408 | return -EIO; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | /* l0s and l1 latency timers. We are using default values. |
| 413 | * Representing 001 for L0s and 010 for L1 |
| 414 | */ |
| 415 | result = pci_write_config_byte(pdev, ET1310_PCI_L0L1LATENCY, 0x11); |
| 416 | if (result != PCIBIOS_SUCCESSFUL) { |
| 417 | DBG_ERROR(et131x_dbginfo, |
| 418 | "Could not write PCI config space for " |
| 419 | "Latency Timers\n"); |
| 420 | DBG_LEAVE(et131x_dbginfo); |
| 421 | return -EIO; |
| 422 | } |
| 423 | |
| 424 | /* Change the max read size to 2k */ |
| 425 | result = pci_read_config_byte(pdev, 0x51, &read_size_reg); |
| 426 | if (result != PCIBIOS_SUCCESSFUL) { |
| 427 | DBG_ERROR(et131x_dbginfo, |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 428 | "Could not read PCI config space for Max read size\n"); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 429 | DBG_LEAVE(et131x_dbginfo); |
| 430 | return -EIO; |
| 431 | } |
| 432 | |
| 433 | read_size_reg &= 0x8f; |
| 434 | read_size_reg |= 0x40; |
| 435 | |
| 436 | result = pci_write_config_byte(pdev, 0x51, read_size_reg); |
| 437 | if (result != PCIBIOS_SUCCESSFUL) { |
| 438 | DBG_ERROR(et131x_dbginfo, |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 439 | "Could not write PCI config space for Max read size\n"); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 440 | DBG_LEAVE(et131x_dbginfo); |
| 441 | return -EIO; |
| 442 | } |
| 443 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 444 | /* Get MAC address from config space if an eeprom exists, otherwise |
| 445 | * the MAC address there will not be valid |
| 446 | */ |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 447 | if (adapter->has_eeprom) { |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 448 | int i; |
| 449 | |
| 450 | for (i = 0; i < ETH_ALEN; i++) { |
| 451 | result = pci_read_config_byte( |
| 452 | pdev, ET1310_PCI_MAC_ADDRESS + i, |
| 453 | adapter->PermanentAddress + i); |
| 454 | if (result != PCIBIOS_SUCCESSFUL) { |
| 455 | DBG_ERROR(et131x_dbginfo, |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 456 | "Could not read PCI config space for MAC address\n"); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 457 | DBG_LEAVE(et131x_dbginfo); |
| 458 | return -EIO; |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | DBG_LEAVE(et131x_dbginfo); |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * et131x_error_timer_handler |
| 469 | * @data: timer-specific variable; here a pointer to our adapter structure |
| 470 | * |
| 471 | * The routine called when the error timer expires, to track the number of |
| 472 | * recurring errors. |
| 473 | */ |
| 474 | void et131x_error_timer_handler(unsigned long data) |
| 475 | { |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 476 | struct et131x_adapter *etdev = (struct et131x_adapter *) data; |
Alan Cox | f2c98d2 | 2009-08-27 11:01:49 +0100 | [diff] [blame] | 477 | u32 pm_csr; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 478 | |
Alan Cox | f2c98d2 | 2009-08-27 11:01:49 +0100 | [diff] [blame] | 479 | pm_csr = readl(&etdev->regs->global.pm_csr); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 480 | |
Alan Cox | f2c98d2 | 2009-08-27 11:01:49 +0100 | [diff] [blame] | 481 | if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) |
Alan Cox | 9483146 | 2009-08-27 11:00:06 +0100 | [diff] [blame] | 482 | UpdateMacStatHostCounters(etdev); |
| 483 | else |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 484 | DBG_VERBOSE(et131x_dbginfo, |
| 485 | "No interrupts, in PHY coma, pm_csr = 0x%x\n", |
Alan Cox | f2c98d2 | 2009-08-27 11:01:49 +0100 | [diff] [blame] | 486 | pm_csr); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 487 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 488 | if (!etdev->Bmsr.bits.link_status && |
| 489 | etdev->RegistryPhyComa && |
| 490 | etdev->PoMgmt.TransPhyComaModeOnBoot < 11) { |
| 491 | etdev->PoMgmt.TransPhyComaModeOnBoot++; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 494 | if (etdev->PoMgmt.TransPhyComaModeOnBoot == 10) { |
| 495 | if (!etdev->Bmsr.bits.link_status |
| 496 | && etdev->RegistryPhyComa) { |
Alan Cox | f2c98d2 | 2009-08-27 11:01:49 +0100 | [diff] [blame] | 497 | if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 498 | /* NOTE - This was originally a 'sync with |
| 499 | * interrupt'. How to do that under Linux? |
| 500 | */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 501 | et131x_enable_interrupts(etdev); |
| 502 | EnablePhyComa(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | /* This is a periodic timer, so reschedule */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 508 | mod_timer(&etdev->ErrorTimer, jiffies + |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 509 | TX_ERROR_PERIOD * HZ / 1000); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | /** |
| 513 | * et131x_link_detection_handler |
| 514 | * |
| 515 | * Timer function for link up at driver load time |
| 516 | */ |
| 517 | void et131x_link_detection_handler(unsigned long data) |
| 518 | { |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 519 | struct et131x_adapter *etdev = (struct et131x_adapter *) data; |
Alan Cox | 3762860 | 2009-08-19 18:21:50 +0100 | [diff] [blame] | 520 | unsigned long flags; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 521 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 522 | if (etdev->MediaState == 0) { |
Alan Cox | 3762860 | 2009-08-19 18:21:50 +0100 | [diff] [blame] | 523 | spin_lock_irqsave(&etdev->Lock, flags); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 524 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 525 | etdev->MediaState = NETIF_STATUS_MEDIA_DISCONNECT; |
Alan Cox | f6b35d6 | 2009-08-27 11:02:05 +0100 | [diff] [blame] | 526 | etdev->Flags &= ~fMP_ADAPTER_LINK_DETECTION; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 527 | |
Alan Cox | 3762860 | 2009-08-19 18:21:50 +0100 | [diff] [blame] | 528 | spin_unlock_irqrestore(&etdev->Lock, flags); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 529 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 530 | netif_carrier_off(etdev->netdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
| 534 | /** |
Alan Cox | b8c4cc4 | 2009-08-27 11:02:25 +0100 | [diff] [blame^] | 535 | * et131x_configure_global_regs - configure JAGCore global regs |
| 536 | * @etdev: pointer to our adapter structure |
| 537 | * |
| 538 | * Used to configure the global registers on the JAGCore |
| 539 | */ |
| 540 | void ConfigGlobalRegs(struct et131x_adapter *etdev) |
| 541 | { |
| 542 | struct _GLOBAL_t __iomem *pGbl = &etdev->regs->global; |
| 543 | |
| 544 | DBG_ENTER(et131x_dbginfo); |
| 545 | |
| 546 | if (etdev->RegistryPhyLoopbk == false) { |
| 547 | if (etdev->RegistryJumboPacket < 2048) { |
| 548 | /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word |
| 549 | * block of RAM that the driver can split between Tx |
| 550 | * and Rx as it desires. Our default is to split it |
| 551 | * 50/50: |
| 552 | */ |
| 553 | writel(0, &pGbl->rxq_start_addr); |
| 554 | writel(PARM_RX_MEM_END_DEF, &pGbl->rxq_end_addr); |
| 555 | writel(PARM_RX_MEM_END_DEF + 1, &pGbl->txq_start_addr); |
| 556 | writel(INTERNAL_MEM_SIZE - 1, &pGbl->txq_end_addr); |
| 557 | } else if (etdev->RegistryJumboPacket < 8192) { |
| 558 | /* For jumbo packets > 2k but < 8k, split 50-50. */ |
| 559 | writel(0, &pGbl->rxq_start_addr); |
| 560 | writel(INTERNAL_MEM_RX_OFFSET, &pGbl->rxq_end_addr); |
| 561 | writel(INTERNAL_MEM_RX_OFFSET + 1, &pGbl->txq_start_addr); |
| 562 | writel(INTERNAL_MEM_SIZE - 1, &pGbl->txq_end_addr); |
| 563 | } else { |
| 564 | /* 9216 is the only packet size greater than 8k that |
| 565 | * is available. The Tx buffer has to be big enough |
| 566 | * for one whole packet on the Tx side. We'll make |
| 567 | * the Tx 9408, and give the rest to Rx |
| 568 | */ |
| 569 | writel(0x0000, &pGbl->rxq_start_addr); |
| 570 | writel(0x01b3, &pGbl->rxq_end_addr); |
| 571 | writel(0x01b4, &pGbl->txq_start_addr); |
| 572 | writel(INTERNAL_MEM_SIZE - 1,&pGbl->txq_end_addr); |
| 573 | } |
| 574 | |
| 575 | /* Initialize the loopback register. Disable all loopbacks. */ |
| 576 | writel(0, &pGbl->loopback.value); |
| 577 | } else { |
| 578 | /* For PHY Line loopback, the memory is configured as if Tx |
| 579 | * and Rx both have all the memory. This is because the |
| 580 | * RxMAC will write data into the space, and the TxMAC will |
| 581 | * read it out. |
| 582 | */ |
| 583 | writel(0, &pGbl->rxq_start_addr); |
| 584 | writel(INTERNAL_MEM_SIZE - 1, &pGbl->rxq_end_addr); |
| 585 | writel(0, &pGbl->txq_start_addr); |
| 586 | writel(INTERNAL_MEM_SIZE - 1, &pGbl->txq_end_addr); |
| 587 | |
| 588 | /* Initialize the loopback register (MAC loopback). */ |
| 589 | writel(1, &pGbl->loopback); |
| 590 | } |
| 591 | |
| 592 | /* MSI Register */ |
| 593 | writel(0, &pGbl->msi_config.value); |
| 594 | |
| 595 | /* By default, disable the watchdog timer. It will be enabled when |
| 596 | * a packet is queued. |
| 597 | */ |
| 598 | writel(0, &pGbl->watchdog_timer); |
| 599 | |
| 600 | DBG_LEAVE(et131x_dbginfo); |
| 601 | } |
| 602 | |
| 603 | |
| 604 | /** |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 605 | * et131x_adapter_setup - Set the adapter up as per cassini+ documentation |
| 606 | * @adapter: pointer to our private adapter structure |
| 607 | * |
| 608 | * Returns 0 on success, errno on failure (as defined in errno.h) |
| 609 | */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 610 | int et131x_adapter_setup(struct et131x_adapter *etdev) |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 611 | { |
| 612 | int status = 0; |
| 613 | |
| 614 | DBG_ENTER(et131x_dbginfo); |
| 615 | |
| 616 | /* Configure the JAGCore */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 617 | ConfigGlobalRegs(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 618 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 619 | ConfigMACRegs1(etdev); |
Alan Cox | b8c4cc4 | 2009-08-27 11:02:25 +0100 | [diff] [blame^] | 620 | |
| 621 | /* Configure the MMC registers */ |
| 622 | /* All we need to do is initialize the Memory Control Register */ |
| 623 | writel(ET_MMC_ENABLE, &etdev->regs->mmc.mmc_ctrl); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 624 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 625 | ConfigRxMacRegs(etdev); |
| 626 | ConfigTxMacRegs(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 627 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 628 | ConfigRxDmaRegs(etdev); |
| 629 | ConfigTxDmaRegs(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 630 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 631 | ConfigMacStatRegs(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 632 | |
| 633 | /* Move the following code to Timer function?? */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 634 | status = et131x_xcvr_find(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 635 | |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 636 | if (status != 0) |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 637 | DBG_WARNING(et131x_dbginfo, "Could not find the xcvr\n"); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 638 | |
| 639 | /* Prepare the TRUEPHY library. */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 640 | ET1310_PhyInit(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 641 | |
| 642 | /* Reset the phy now so changes take place */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 643 | ET1310_PhyReset(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 644 | |
| 645 | /* Power down PHY */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 646 | ET1310_PhyPowerDown(etdev, 1); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 647 | |
| 648 | /* |
| 649 | * We need to turn off 1000 base half dulplex, the mac does not |
| 650 | * support it. For the 10/100 part, turn off all gig advertisement |
| 651 | */ |
Alan Cox | 5ec3487 | 2009-08-27 10:59:13 +0100 | [diff] [blame] | 652 | if (etdev->pdev->device != ET131X_PCI_DEVICE_ID_FAST) |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 653 | ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL); |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 654 | else |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 655 | ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 656 | |
| 657 | /* Power up PHY */ |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 658 | ET1310_PhyPowerDown(etdev, 0); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 659 | |
Alan Cox | 25ad00b | 2009-08-19 18:21:44 +0100 | [diff] [blame] | 660 | et131x_setphy_normal(etdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 661 | |
| 662 | DBG_LEAVE(et131x_dbginfo); |
| 663 | return status; |
| 664 | } |
| 665 | |
| 666 | /** |
| 667 | * et131x_setup_hardware_properties - set up the MAC Address on the ET1310 |
| 668 | * @adapter: pointer to our private adapter structure |
| 669 | */ |
| 670 | void et131x_setup_hardware_properties(struct et131x_adapter *adapter) |
| 671 | { |
| 672 | DBG_ENTER(et131x_dbginfo); |
| 673 | |
| 674 | /* If have our default mac from registry and no mac address from |
| 675 | * EEPROM then we need to generate the last octet and set it on the |
| 676 | * device |
| 677 | */ |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 678 | if (adapter->PermanentAddress[0] == 0x00 && |
| 679 | adapter->PermanentAddress[1] == 0x00 && |
| 680 | adapter->PermanentAddress[2] == 0x00 && |
| 681 | adapter->PermanentAddress[3] == 0x00 && |
| 682 | adapter->PermanentAddress[4] == 0x00 && |
| 683 | adapter->PermanentAddress[5] == 0x00) { |
| 684 | /* |
| 685 | * We need to randomly generate the last octet so we |
| 686 | * decrease our chances of setting the mac address to |
| 687 | * same as another one of our cards in the system |
| 688 | */ |
| 689 | get_random_bytes(&adapter->CurrentAddress[5], 1); |
| 690 | /* |
| 691 | * We have the default value in the register we are |
| 692 | * working with so we need to copy the current |
| 693 | * address into the permanent address |
| 694 | */ |
| 695 | memcpy(adapter->PermanentAddress, |
| 696 | adapter->CurrentAddress, ETH_ALEN); |
| 697 | } else { |
| 698 | /* We do not have an override address, so set the |
| 699 | * current address to the permanent address and add |
| 700 | * it to the device |
| 701 | */ |
| 702 | memcpy(adapter->CurrentAddress, |
| 703 | adapter->PermanentAddress, ETH_ALEN); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | DBG_LEAVE(et131x_dbginfo); |
| 707 | } |
| 708 | |
| 709 | /** |
| 710 | * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 |
| 711 | * @adapter: pointer to our private adapter structure |
| 712 | */ |
| 713 | void et131x_soft_reset(struct et131x_adapter *adapter) |
| 714 | { |
| 715 | DBG_ENTER(et131x_dbginfo); |
| 716 | |
| 717 | /* Disable MAC Core */ |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 718 | writel(0xc00f0000, &adapter->regs->mac.cfg1.value); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 719 | |
| 720 | /* Set everything to a reset value */ |
Alan Cox | b8c4cc4 | 2009-08-27 11:02:25 +0100 | [diff] [blame^] | 721 | writel(0x7F, &adapter->regs->global.sw_reset); |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 722 | writel(0x000f0000, &adapter->regs->mac.cfg1.value); |
| 723 | writel(0x00000000, &adapter->regs->mac.cfg1.value); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 724 | |
| 725 | DBG_LEAVE(et131x_dbginfo); |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * et131x_align_allocated_memory - Align allocated memory on a given boundary |
| 730 | * @adapter: pointer to our adapter structure |
| 731 | * @phys_addr: pointer to Physical address |
| 732 | * @offset: pointer to the offset variable |
| 733 | * @mask: correct mask |
| 734 | */ |
| 735 | void et131x_align_allocated_memory(struct et131x_adapter *adapter, |
| 736 | uint64_t *phys_addr, |
| 737 | uint64_t *offset, uint64_t mask) |
| 738 | { |
| 739 | uint64_t new_addr; |
| 740 | |
| 741 | DBG_ENTER(et131x_dbginfo); |
| 742 | |
| 743 | *offset = 0; |
| 744 | |
| 745 | new_addr = *phys_addr & ~mask; |
| 746 | |
| 747 | if (new_addr != *phys_addr) { |
| 748 | /* Move to next aligned block */ |
| 749 | new_addr += mask + 1; |
| 750 | /* Return offset for adjusting virt addr */ |
| 751 | *offset = new_addr - *phys_addr; |
| 752 | /* Return new physical address */ |
| 753 | *phys_addr = new_addr; |
| 754 | } |
| 755 | |
| 756 | DBG_LEAVE(et131x_dbginfo); |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * et131x_adapter_memory_alloc |
| 761 | * @adapter: pointer to our private adapter structure |
| 762 | * |
| 763 | * Returns 0 on success, errno on failure (as defined in errno.h). |
| 764 | * |
| 765 | * Allocate all the memory blocks for send, receive and others. |
| 766 | */ |
| 767 | int et131x_adapter_memory_alloc(struct et131x_adapter *adapter) |
| 768 | { |
| 769 | int status = 0; |
| 770 | |
| 771 | DBG_ENTER(et131x_dbginfo); |
| 772 | |
| 773 | do { |
| 774 | /* Allocate memory for the Tx Ring */ |
| 775 | status = et131x_tx_dma_memory_alloc(adapter); |
| 776 | if (status != 0) { |
| 777 | DBG_ERROR(et131x_dbginfo, |
| 778 | "et131x_tx_dma_memory_alloc FAILED\n"); |
| 779 | break; |
| 780 | } |
| 781 | |
| 782 | /* Receive buffer memory allocation */ |
| 783 | status = et131x_rx_dma_memory_alloc(adapter); |
| 784 | if (status != 0) { |
| 785 | DBG_ERROR(et131x_dbginfo, |
| 786 | "et131x_rx_dma_memory_alloc FAILED\n"); |
| 787 | et131x_tx_dma_memory_free(adapter); |
| 788 | break; |
| 789 | } |
| 790 | |
| 791 | /* Init receive data structures */ |
| 792 | status = et131x_init_recv(adapter); |
| 793 | if (status != 0) { |
| 794 | DBG_ERROR(et131x_dbginfo, "et131x_init_recv FAILED\n"); |
| 795 | et131x_tx_dma_memory_free(adapter); |
| 796 | et131x_rx_dma_memory_free(adapter); |
| 797 | break; |
| 798 | } |
| 799 | } while (0); |
| 800 | |
| 801 | DBG_LEAVE(et131x_dbginfo); |
| 802 | return status; |
| 803 | } |
| 804 | |
| 805 | /** |
| 806 | * et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx |
| 807 | * @adapter: pointer to our private adapter structure |
| 808 | */ |
| 809 | void et131x_adapter_memory_free(struct et131x_adapter *adapter) |
| 810 | { |
| 811 | DBG_ENTER(et131x_dbginfo); |
| 812 | |
| 813 | /* Free DMA memory */ |
| 814 | et131x_tx_dma_memory_free(adapter); |
| 815 | et131x_rx_dma_memory_free(adapter); |
| 816 | |
| 817 | DBG_LEAVE(et131x_dbginfo); |
| 818 | } |
| 819 | |
| 820 | /** |
| 821 | * et131x_pci_remove |
| 822 | * @pdev: a pointer to the device's pci_dev structure |
| 823 | * |
| 824 | * Registered in the pci_driver structure, this function is called when the |
| 825 | * PCI subsystem detects that a PCI device which matches the information |
| 826 | * contained in the pci_device_id table has been removed. |
| 827 | */ |
| 828 | void __devexit et131x_pci_remove(struct pci_dev *pdev) |
| 829 | { |
| 830 | struct net_device *netdev; |
| 831 | struct et131x_adapter *adapter; |
| 832 | |
| 833 | DBG_ENTER(et131x_dbginfo); |
| 834 | |
| 835 | /* Retrieve the net_device pointer from the pci_dev struct, as well |
| 836 | * as the private adapter struct |
| 837 | */ |
| 838 | netdev = (struct net_device *) pci_get_drvdata(pdev); |
| 839 | adapter = netdev_priv(netdev); |
| 840 | |
| 841 | /* Perform device cleanup */ |
| 842 | unregister_netdev(netdev); |
| 843 | et131x_adapter_memory_free(adapter); |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 844 | iounmap(adapter->regs); |
Alan Cox | 6ae5604 | 2009-08-27 10:59:21 +0100 | [diff] [blame] | 845 | pci_dev_put(adapter->pdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 846 | free_netdev(netdev); |
| 847 | pci_release_regions(pdev); |
| 848 | pci_disable_device(pdev); |
| 849 | |
| 850 | DBG_LEAVE(et131x_dbginfo); |
| 851 | } |
| 852 | |
| 853 | /** |
Alan Cox | 8c5f20f | 2009-08-27 11:00:24 +0100 | [diff] [blame] | 854 | * et131x_config_parse |
| 855 | * @etdev: pointer to the private adapter struct |
| 856 | * |
| 857 | * Parses a configuration from some location (module parameters, for example) |
| 858 | * into the private adapter struct. This really has no sensible analogy in |
| 859 | * Linux as sysfs parameters are dynamic. Several things that were hee could |
| 860 | * go into sysfs, but other stuff like speed handling is part of the mii |
| 861 | * interfaces/ethtool. |
| 862 | */ |
| 863 | void et131x_config_parse(struct et131x_adapter *etdev) |
| 864 | { |
| 865 | static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 }; |
| 866 | static const u8 duplex[] = { 0, 1, 2, 1, 2, 2 }; |
| 867 | static const u16 speed[] = { 0, 10, 10, 100, 100, 1000 }; |
| 868 | |
| 869 | DBG_ENTER(et131x_dbginfo); |
| 870 | |
| 871 | if (et131x_speed_set) |
| 872 | DBG_VERBOSE(et131x_dbginfo, "Speed set manually to : %d \n", |
| 873 | et131x_speed_set); |
| 874 | |
| 875 | etdev->SpeedDuplex = et131x_speed_set; |
| 876 | etdev->RegistryJumboPacket = 1514; /* 1514-9216 */ |
| 877 | |
| 878 | etdev->RegistryNMIDisable = et131x_nmi_disable; |
| 879 | |
| 880 | /* Set the MAC address to a default */ |
| 881 | memcpy(etdev->CurrentAddress, default_mac, ETH_ALEN); |
| 882 | |
| 883 | /* Decode SpeedDuplex |
| 884 | * |
| 885 | * Set up as if we are auto negotiating always and then change if we |
| 886 | * go into force mode |
| 887 | * |
| 888 | * If we are the 10/100 device, and gigabit is somehow requested then |
| 889 | * knock it down to 100 full. |
| 890 | */ |
| 891 | if (etdev->pdev->device == ET131X_PCI_DEVICE_ID_FAST && |
| 892 | etdev->SpeedDuplex == 5) |
| 893 | etdev->SpeedDuplex = 4; |
| 894 | |
| 895 | etdev->AiForceSpeed = speed[etdev->SpeedDuplex]; |
| 896 | etdev->AiForceDpx = duplex[etdev->SpeedDuplex]; /* Auto FDX */ |
| 897 | |
| 898 | DBG_LEAVE(et131x_dbginfo); |
| 899 | } |
| 900 | |
| 901 | |
| 902 | /** |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 903 | * et131x_pci_setup - Perform device initialization |
| 904 | * @pdev: a pointer to the device's pci_dev structure |
| 905 | * @ent: this device's entry in the pci_device_id table |
| 906 | * |
| 907 | * Returns 0 on success, errno on failure (as defined in errno.h) |
| 908 | * |
| 909 | * Registered in the pci_driver structure, this function is called when the |
| 910 | * PCI subsystem finds a new PCI device which matches the information |
| 911 | * contained in the pci_device_id table. This routine is the equivalent to |
| 912 | * a device insertion routine. |
| 913 | */ |
| 914 | int __devinit et131x_pci_setup(struct pci_dev *pdev, |
| 915 | const struct pci_device_id *ent) |
| 916 | { |
| 917 | int result = 0; |
| 918 | int pm_cap; |
| 919 | bool pci_using_dac; |
| 920 | struct net_device *netdev = NULL; |
| 921 | struct et131x_adapter *adapter = NULL; |
| 922 | |
| 923 | DBG_ENTER(et131x_dbginfo); |
| 924 | |
| 925 | /* Enable the device via the PCI subsystem */ |
| 926 | result = pci_enable_device(pdev); |
| 927 | if (result != 0) { |
| 928 | DBG_ERROR(et131x_dbginfo, "pci_enable_device() failed\n"); |
| 929 | goto out; |
| 930 | } |
| 931 | |
| 932 | /* Perform some basic PCI checks */ |
| 933 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { |
| 934 | DBG_ERROR(et131x_dbginfo, |
| 935 | "Can't find PCI device's base address\n"); |
| 936 | result = -ENODEV; |
| 937 | goto out; |
| 938 | } |
| 939 | |
| 940 | result = pci_request_regions(pdev, DRIVER_NAME); |
| 941 | if (result != 0) { |
| 942 | DBG_ERROR(et131x_dbginfo, "Can't get PCI resources\n"); |
| 943 | goto err_disable; |
| 944 | } |
| 945 | |
| 946 | /* Enable PCI bus mastering */ |
| 947 | DBG_TRACE(et131x_dbginfo, "Setting PCI Bus Mastering...\n"); |
| 948 | pci_set_master(pdev); |
| 949 | |
| 950 | /* Query PCI for Power Mgmt Capabilities |
| 951 | * |
| 952 | * NOTE: Now reading PowerMgmt in another location; is this still |
| 953 | * needed? |
| 954 | */ |
| 955 | pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); |
| 956 | if (pm_cap == 0) { |
| 957 | DBG_ERROR(et131x_dbginfo, |
| 958 | "Cannot find Power Management capabilities\n"); |
| 959 | result = -EIO; |
| 960 | goto err_release_res; |
| 961 | } |
| 962 | |
| 963 | /* Check the DMA addressing support of this device */ |
| 964 | if (!pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) { |
| 965 | DBG_TRACE(et131x_dbginfo, "64-bit DMA addressing supported\n"); |
| 966 | pci_using_dac = true; |
| 967 | |
| 968 | result = |
| 969 | pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL); |
| 970 | if (result != 0) { |
| 971 | DBG_ERROR(et131x_dbginfo, |
| 972 | "Unable to obtain 64 bit DMA for consistent allocations\n"); |
| 973 | goto err_release_res; |
| 974 | } |
| 975 | } else if (!pci_set_dma_mask(pdev, 0xffffffffULL)) { |
| 976 | DBG_TRACE(et131x_dbginfo, |
| 977 | "64-bit DMA addressing NOT supported\n"); |
| 978 | DBG_TRACE(et131x_dbginfo, |
| 979 | "32-bit DMA addressing will be used\n"); |
| 980 | pci_using_dac = false; |
| 981 | } else { |
| 982 | DBG_ERROR(et131x_dbginfo, "No usable DMA addressing method\n"); |
| 983 | result = -EIO; |
| 984 | goto err_release_res; |
| 985 | } |
| 986 | |
| 987 | /* Allocate netdev and private adapter structs */ |
| 988 | DBG_TRACE(et131x_dbginfo, |
| 989 | "Allocate netdev and private adapter structs...\n"); |
| 990 | netdev = et131x_device_alloc(); |
| 991 | if (netdev == NULL) { |
| 992 | DBG_ERROR(et131x_dbginfo, "Couldn't alloc netdev struct\n"); |
| 993 | result = -ENOMEM; |
| 994 | goto err_release_res; |
| 995 | } |
| 996 | |
| 997 | /* Setup the fundamental net_device and private adapter structure elements */ |
| 998 | DBG_TRACE(et131x_dbginfo, "Setting fundamental net_device info...\n"); |
| 999 | SET_NETDEV_DEV(netdev, &pdev->dev); |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1000 | /* |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1001 | if (pci_using_dac) { |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1002 | netdev->features |= NETIF_F_HIGHDMA; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1003 | } |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1004 | */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1005 | |
| 1006 | /* |
| 1007 | * NOTE - Turn this on when we're ready to deal with SG-DMA |
| 1008 | * |
| 1009 | * NOTE: According to "Linux Device Drivers", 3rd ed, Rubini et al, |
| 1010 | * if checksumming is not performed in HW, then the kernel will not |
| 1011 | * use SG. |
| 1012 | * From pp 510-511: |
| 1013 | * |
| 1014 | * "Note that the kernel does not perform scatter/gather I/O to your |
| 1015 | * device if it does not also provide some form of checksumming as |
| 1016 | * well. The reason is that, if the kernel has to make a pass over a |
| 1017 | * fragmented ("nonlinear") packet to calculate the checksum, it |
| 1018 | * might as well copy the data and coalesce the packet at the same |
| 1019 | * time." |
| 1020 | * |
| 1021 | * This has been verified by setting the flags below and still not |
| 1022 | * receiving a scattered buffer from the network stack, so leave it |
| 1023 | * off until checksums are calculated in HW. |
| 1024 | */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1025 | /* netdev->features |= NETIF_F_SG; */ |
| 1026 | /* netdev->features |= NETIF_F_NO_CSUM; */ |
| 1027 | /* netdev->features |= NETIF_F_LLTX; */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1028 | |
| 1029 | /* Allocate private adapter struct and copy in relevant information */ |
| 1030 | adapter = netdev_priv(netdev); |
Alan Cox | 6ae5604 | 2009-08-27 10:59:21 +0100 | [diff] [blame] | 1031 | adapter->pdev = pci_dev_get(pdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1032 | adapter->netdev = netdev; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1033 | |
| 1034 | /* Do the same for the netdev struct */ |
| 1035 | netdev->irq = pdev->irq; |
| 1036 | netdev->base_addr = pdev->resource[0].start; |
| 1037 | |
| 1038 | /* Initialize spinlocks here */ |
| 1039 | DBG_TRACE(et131x_dbginfo, "Initialize spinlocks...\n"); |
| 1040 | |
| 1041 | spin_lock_init(&adapter->Lock); |
| 1042 | spin_lock_init(&adapter->TCBSendQLock); |
| 1043 | spin_lock_init(&adapter->TCBReadyQLock); |
| 1044 | spin_lock_init(&adapter->SendHWLock); |
| 1045 | spin_lock_init(&adapter->SendWaitLock); |
| 1046 | spin_lock_init(&adapter->RcvLock); |
| 1047 | spin_lock_init(&adapter->RcvPendLock); |
| 1048 | spin_lock_init(&adapter->FbrLock); |
| 1049 | spin_lock_init(&adapter->PHYLock); |
| 1050 | |
| 1051 | /* Parse configuration parameters into the private adapter struct */ |
| 1052 | et131x_config_parse(adapter); |
| 1053 | |
| 1054 | /* Find the physical adapter |
| 1055 | * |
| 1056 | * NOTE: This is the equivalent of the MpFindAdapter() routine; can we |
| 1057 | * lump it's init with the device specific init below into a |
| 1058 | * single init function? |
| 1059 | */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1060 | /* while (et131x_find_adapter(adapter, pdev) != 0); */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1061 | et131x_find_adapter(adapter, pdev); |
| 1062 | |
| 1063 | /* Map the bus-relative registers to system virtual memory */ |
| 1064 | DBG_TRACE(et131x_dbginfo, |
| 1065 | "Mapping bus-relative registers to virtual memory...\n"); |
| 1066 | |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 1067 | adapter->regs = ioremap_nocache(pci_resource_start(pdev, 0), |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1068 | pci_resource_len(pdev, 0)); |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 1069 | if (adapter->regs == NULL) { |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1070 | DBG_ERROR(et131x_dbginfo, "Cannot map device registers\n"); |
| 1071 | result = -ENOMEM; |
| 1072 | goto err_free_dev; |
| 1073 | } |
| 1074 | |
| 1075 | /* Perform device-specific initialization here (See code below) */ |
| 1076 | |
| 1077 | /* If Phy COMA mode was enabled when we went down, disable it here. */ |
Alan Cox | f2c98d2 | 2009-08-27 11:01:49 +0100 | [diff] [blame] | 1078 | writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1079 | |
| 1080 | /* Issue a global reset to the et1310 */ |
| 1081 | DBG_TRACE(et131x_dbginfo, "Issuing soft reset...\n"); |
| 1082 | et131x_soft_reset(adapter); |
| 1083 | |
| 1084 | /* Disable all interrupts (paranoid) */ |
| 1085 | DBG_TRACE(et131x_dbginfo, "Disable device interrupts...\n"); |
| 1086 | et131x_disable_interrupts(adapter); |
| 1087 | |
| 1088 | /* Allocate DMA memory */ |
| 1089 | result = et131x_adapter_memory_alloc(adapter); |
| 1090 | if (result != 0) { |
| 1091 | DBG_ERROR(et131x_dbginfo, |
| 1092 | "Could not alloc adapater memory (DMA)\n"); |
| 1093 | goto err_iounmap; |
| 1094 | } |
| 1095 | |
| 1096 | /* Init send data structures */ |
| 1097 | DBG_TRACE(et131x_dbginfo, "Init send data structures...\n"); |
| 1098 | et131x_init_send(adapter); |
| 1099 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1100 | /* Register the interrupt |
| 1101 | * |
| 1102 | * NOTE - This is being done in the open routine, where most other |
| 1103 | * Linux drivers setup IRQ handlers. Make sure device |
| 1104 | * interrupts are not turned on before the IRQ is registered!! |
| 1105 | * |
| 1106 | * What we will do here is setup the task structure for the |
| 1107 | * ISR's deferred handler |
| 1108 | */ |
| 1109 | INIT_WORK(&adapter->task, et131x_isr_handler); |
| 1110 | |
| 1111 | /* Determine MAC Address, and copy into the net_device struct */ |
| 1112 | DBG_TRACE(et131x_dbginfo, "Retrieve MAC address...\n"); |
| 1113 | et131x_setup_hardware_properties(adapter); |
| 1114 | |
| 1115 | memcpy(netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN); |
| 1116 | |
| 1117 | /* Setup et1310 as per the documentation */ |
| 1118 | DBG_TRACE(et131x_dbginfo, "Setup the adapter...\n"); |
| 1119 | et131x_adapter_setup(adapter); |
| 1120 | |
| 1121 | /* Create a timer to count errors received by the NIC */ |
| 1122 | init_timer(&adapter->ErrorTimer); |
| 1123 | |
| 1124 | adapter->ErrorTimer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000; |
| 1125 | adapter->ErrorTimer.function = et131x_error_timer_handler; |
| 1126 | adapter->ErrorTimer.data = (unsigned long)adapter; |
| 1127 | |
| 1128 | /* Initialize link state */ |
| 1129 | et131x_link_detection_handler((unsigned long)adapter); |
| 1130 | |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1131 | /* Intialize variable for counting how long we do not have |
| 1132 | link status */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1133 | adapter->PoMgmt.TransPhyComaModeOnBoot = 0; |
| 1134 | |
| 1135 | /* We can enable interrupts now |
| 1136 | * |
| 1137 | * NOTE - Because registration of interrupt handler is done in the |
| 1138 | * device's open(), defer enabling device interrupts to that |
| 1139 | * point |
| 1140 | */ |
| 1141 | |
| 1142 | /* Register the net_device struct with the Linux network layer */ |
| 1143 | DBG_TRACE(et131x_dbginfo, "Registering net_device...\n"); |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 1144 | result = register_netdev(netdev); |
| 1145 | if (result != 0) { |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1146 | DBG_ERROR(et131x_dbginfo, "register_netdev() failed\n"); |
| 1147 | goto err_mem_free; |
| 1148 | } |
| 1149 | |
| 1150 | /* Register the net_device struct with the PCI subsystem. Save a copy |
| 1151 | * of the PCI config space for this device now that the device has |
| 1152 | * been initialized, just in case it needs to be quickly restored. |
| 1153 | */ |
| 1154 | pci_set_drvdata(pdev, netdev); |
| 1155 | |
| 1156 | pci_save_state(adapter->pdev); |
| 1157 | |
| 1158 | out: |
| 1159 | DBG_LEAVE(et131x_dbginfo); |
| 1160 | return result; |
| 1161 | |
| 1162 | err_mem_free: |
| 1163 | et131x_adapter_memory_free(adapter); |
| 1164 | err_iounmap: |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 1165 | iounmap(adapter->regs); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1166 | err_free_dev: |
Alan Cox | 6ae5604 | 2009-08-27 10:59:21 +0100 | [diff] [blame] | 1167 | pci_dev_put(pdev); |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1168 | free_netdev(netdev); |
| 1169 | err_release_res: |
| 1170 | pci_release_regions(pdev); |
| 1171 | err_disable: |
| 1172 | pci_disable_device(pdev); |
| 1173 | goto out; |
| 1174 | } |