blob: 7b1e912f3ab2bab2410f529eafdcf914a7a4a184 [file] [log] [blame]
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -07001/*
2 * Agere Systems Inc.
3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4 *
Alan Cox64f93032009-06-10 17:30:41 +01005 * Copyright © 2005 Agere Systems Inc.
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -07006 * 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 Cox64f93032009-06-10 17:30:41 +010024 * Copyright © 2005 Agere Systems Inc.
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070025 * 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 Cox64f93032009-06-10 17:30:41 +010045 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070046 * 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"
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070061#include "et131x_defs.h"
62
63#include <linux/pci.h>
64#include <linux/init.h>
65#include <linux/module.h>
66#include <linux/types.h>
67#include <linux/kernel.h>
68
69#include <linux/sched.h>
70#include <linux/ptrace.h>
71#include <linux/slab.h>
72#include <linux/ctype.h>
73#include <linux/string.h>
74#include <linux/timer.h>
75#include <linux/interrupt.h>
76#include <linux/in.h>
77#include <linux/delay.h>
Alan Cox64f93032009-06-10 17:30:41 +010078#include <linux/io.h>
79#include <linux/bitops.h>
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070080#include <asm/system.h>
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070081
82#include <linux/netdevice.h>
83#include <linux/etherdevice.h>
84#include <linux/skbuff.h>
85#include <linux/if_arp.h>
86#include <linux/ioport.h>
87#include <linux/random.h>
88
89#include "et1310_phy.h"
90#include "et1310_pm.h"
91#include "et1310_jagcore.h"
92
93#include "et131x_adapter.h"
94#include "et131x_netdev.h"
95#include "et131x_config.h"
96#include "et131x_isr.h"
97
98#include "et1310_address_map.h"
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070099#include "et1310_tx.h"
100#include "et1310_rx.h"
101#include "et1310_mac.h"
102#include "et1310_eeprom.h"
103
104
Alan Cox8c5f20f2009-08-27 11:00:24 +0100105/* Defines for Parameter Default/Min/Max vaules */
106#define PARM_SPEED_DUPLEX_MIN 0
107#define PARM_SPEED_DUPLEX_MAX 5
108
109/* Module parameter for disabling NMI
110 * et131x_nmi_disable :
111 * Disable NMI (0-2) [0]
112 * 0 :
113 * 1 :
114 * 2 :
115 */
116static u32 et131x_nmi_disable; /* 0-2 */
117module_param(et131x_nmi_disable, uint, 0);
118MODULE_PARM_DESC(et131x_nmi_disable, "Disable NMI (0-2) [0]");
119
120/* Module parameter for manual speed setting
121 * Set Link speed and dublex manually (0-5) [0]
122 * 1 : 10Mb Half-Duplex
123 * 2 : 10Mb Full-Duplex
124 * 3 : 100Mb Half-Duplex
125 * 4 : 100Mb Full-Duplex
126 * 5 : 1000Mb Full-Duplex
127 * 0 : Auto Speed Auto Duplex // default
128 */
129static u32 et131x_speed_set;
130module_param(et131x_speed_set, uint, 0);
131MODULE_PARM_DESC(et131x_speed_set,
132 "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");
133
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700134/**
Alan Coxc431e3c2009-10-06 15:47:41 +0100135 * et131x_hwaddr_init - set up the MAC Address on the ET1310
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700136 * @adapter: pointer to our private adapter structure
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700137 */
Alan Coxc431e3c2009-10-06 15:47:41 +0100138void et131x_hwaddr_init(struct et131x_adapter *adapter)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700139{
Alan Coxc431e3c2009-10-06 15:47:41 +0100140 /* If have our default mac from init and no mac address from
141 * EEPROM then we need to generate the last octet and set it on the
142 * device
143 */
144 if (adapter->PermanentAddress[0] == 0x00 &&
145 adapter->PermanentAddress[1] == 0x00 &&
146 adapter->PermanentAddress[2] == 0x00 &&
147 adapter->PermanentAddress[3] == 0x00 &&
148 adapter->PermanentAddress[4] == 0x00 &&
149 adapter->PermanentAddress[5] == 0x00) {
150 /*
151 * We need to randomly generate the last octet so we
152 * decrease our chances of setting the mac address to
153 * same as another one of our cards in the system
154 */
155 get_random_bytes(&adapter->CurrentAddress[5], 1);
156 /*
157 * We have the default value in the register we are
158 * working with so we need to copy the current
159 * address into the permanent address
160 */
161 memcpy(adapter->PermanentAddress,
162 adapter->CurrentAddress, ETH_ALEN);
163 } else {
164 /* We do not have an override address, so set the
165 * current address to the permanent address and add
166 * it to the device
167 */
168 memcpy(adapter->CurrentAddress,
169 adapter->PermanentAddress, ETH_ALEN);
170 }
171}
172
173
174/**
175 * et131x_pci_init - initial PCI setup
176 * @adapter: pointer to our private adapter structure
177 * @pdev: our PCI device
178 *
179 * Perform the initial setup of PCI registers and if possible initialise
180 * the MAC address. At this point the I/O registers have yet to be mapped
181 */
182
183static int et131x_pci_init(struct et131x_adapter *adapter,
184 struct pci_dev *pdev)
185{
186 int i;
187 u8 max_payload;
188 u8 read_size_reg;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700189
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700190 /* Allow disabling of Non-Maskable Interrupts in I/O space, to
191 * support validation.
192 */
193 if (adapter->RegistryNMIDisable) {
194 uint8_t RegisterVal;
195
196 RegisterVal = inb(ET1310_NMI_DISABLE);
197 RegisterVal &= 0xf3;
198
Alan Cox64f93032009-06-10 17:30:41 +0100199 if (adapter->RegistryNMIDisable == 2)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700200 RegisterVal |= 0xc;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700201
202 outb(ET1310_NMI_DISABLE, RegisterVal);
203 }
204
Alan Cox4e02b4b2009-10-06 15:47:22 +0100205 if (et131x_init_eeprom(adapter) < 0)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700206 return -EIO;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700207
208 /* Let's set up the PORT LOGIC Register. First we need to know what
209 * the max_payload_size is
210 */
Alan Coxc431e3c2009-10-06 15:47:41 +0100211 if (pci_read_config_byte(pdev, ET1310_PCI_MAX_PYLD, &max_payload)) {
Alan Cox15700032009-08-27 11:03:09 +0100212 dev_err(&pdev->dev,
213 "Could not read PCI config space for Max Payload Size\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700214 return -EIO;
215 }
216
217 /* Program the Ack/Nak latency and replay timers */
Alan Coxc431e3c2009-10-06 15:47:41 +0100218 max_payload &= 0x07; /* Only the lower 3 bits are valid */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700219
Alan Coxc431e3c2009-10-06 15:47:41 +0100220 if (max_payload < 2) {
221 static const u16 AckNak[2] = { 0x76, 0xD0 };
222 static const u16 Replay[2] = { 0x1E0, 0x2ED };
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700223
Alan Coxc431e3c2009-10-06 15:47:41 +0100224 if (pci_write_config_word(pdev, ET1310_PCI_ACK_NACK,
225 AckNak[max_payload])) {
Alan Cox15700032009-08-27 11:03:09 +0100226 dev_err(&pdev->dev,
227 "Could not write PCI config space for ACK/NAK\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700228 return -EIO;
229 }
Alan Coxc431e3c2009-10-06 15:47:41 +0100230 if (pci_write_config_word(pdev, ET1310_PCI_REPLAY,
231 Replay[max_payload])) {
Alan Cox15700032009-08-27 11:03:09 +0100232 dev_err(&pdev->dev,
233 "Could not write PCI config space for Replay Timer\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700234 return -EIO;
235 }
236 }
237
238 /* l0s and l1 latency timers. We are using default values.
239 * Representing 001 for L0s and 010 for L1
240 */
Alan Coxc431e3c2009-10-06 15:47:41 +0100241 if (pci_write_config_byte(pdev, ET1310_PCI_L0L1LATENCY, 0x11)) {
Alan Cox15700032009-08-27 11:03:09 +0100242 dev_err(&pdev->dev,
243 "Could not write PCI config space for Latency Timers\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700244 return -EIO;
245 }
246
247 /* Change the max read size to 2k */
Alan Coxc431e3c2009-10-06 15:47:41 +0100248 if (pci_read_config_byte(pdev, 0x51, &read_size_reg)) {
Alan Cox15700032009-08-27 11:03:09 +0100249 dev_err(&pdev->dev,
Alan Cox64f93032009-06-10 17:30:41 +0100250 "Could not read PCI config space for Max read size\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700251 return -EIO;
252 }
253
254 read_size_reg &= 0x8f;
255 read_size_reg |= 0x40;
256
Alan Coxc431e3c2009-10-06 15:47:41 +0100257 if (pci_write_config_byte(pdev, 0x51, read_size_reg)) {
Alan Cox15700032009-08-27 11:03:09 +0100258 dev_err(&pdev->dev,
Alan Cox64f93032009-06-10 17:30:41 +0100259 "Could not write PCI config space for Max read size\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700260 return -EIO;
261 }
262
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700263 /* Get MAC address from config space if an eeprom exists, otherwise
264 * the MAC address there will not be valid
265 */
Alan Coxc431e3c2009-10-06 15:47:41 +0100266 if (!adapter->has_eeprom) {
267 et131x_hwaddr_init(adapter);
268 return 0;
269 }
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700270
Alan Coxc431e3c2009-10-06 15:47:41 +0100271 for (i = 0; i < ETH_ALEN; i++) {
272 if (pci_read_config_byte(pdev, ET1310_PCI_MAC_ADDRESS + i,
273 adapter->PermanentAddress + i)) {
274 dev_err(&pdev->dev, "Could not read PCI config space for MAC address\n");
275 return -EIO;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700276 }
277 }
Alan Coxc431e3c2009-10-06 15:47:41 +0100278 memcpy(adapter->CurrentAddress, adapter->PermanentAddress, ETH_ALEN);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700279 return 0;
280}
281
282/**
283 * et131x_error_timer_handler
284 * @data: timer-specific variable; here a pointer to our adapter structure
285 *
286 * The routine called when the error timer expires, to track the number of
287 * recurring errors.
288 */
289void et131x_error_timer_handler(unsigned long data)
290{
Alan Cox25ad00b2009-08-19 18:21:44 +0100291 struct et131x_adapter *etdev = (struct et131x_adapter *) data;
Alan Coxf2c98d22009-08-27 11:01:49 +0100292 u32 pm_csr;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700293
Alan Coxf2c98d22009-08-27 11:01:49 +0100294 pm_csr = readl(&etdev->regs->global.pm_csr);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700295
Alan Coxf2c98d22009-08-27 11:01:49 +0100296 if ((pm_csr & ET_PM_PHY_SW_COMA) == 0)
Alan Cox94831462009-08-27 11:00:06 +0100297 UpdateMacStatHostCounters(etdev);
298 else
Alan Cox15700032009-08-27 11:03:09 +0100299 dev_err(&etdev->pdev->dev,
300 "No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700301
Alan Cox25ad00b2009-08-19 18:21:44 +0100302 if (!etdev->Bmsr.bits.link_status &&
303 etdev->RegistryPhyComa &&
304 etdev->PoMgmt.TransPhyComaModeOnBoot < 11) {
305 etdev->PoMgmt.TransPhyComaModeOnBoot++;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700306 }
307
Alan Cox25ad00b2009-08-19 18:21:44 +0100308 if (etdev->PoMgmt.TransPhyComaModeOnBoot == 10) {
309 if (!etdev->Bmsr.bits.link_status
310 && etdev->RegistryPhyComa) {
Alan Coxf2c98d22009-08-27 11:01:49 +0100311 if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) {
Alan Cox64f93032009-06-10 17:30:41 +0100312 /* NOTE - This was originally a 'sync with
313 * interrupt'. How to do that under Linux?
314 */
Alan Cox25ad00b2009-08-19 18:21:44 +0100315 et131x_enable_interrupts(etdev);
316 EnablePhyComa(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700317 }
318 }
319 }
320
321 /* This is a periodic timer, so reschedule */
Alan Cox25ad00b2009-08-19 18:21:44 +0100322 mod_timer(&etdev->ErrorTimer, jiffies +
Alan Cox64f93032009-06-10 17:30:41 +0100323 TX_ERROR_PERIOD * HZ / 1000);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700324}
325
326/**
327 * et131x_link_detection_handler
328 *
329 * Timer function for link up at driver load time
330 */
331void et131x_link_detection_handler(unsigned long data)
332{
Alan Cox25ad00b2009-08-19 18:21:44 +0100333 struct et131x_adapter *etdev = (struct et131x_adapter *) data;
Alan Cox37628602009-08-19 18:21:50 +0100334 unsigned long flags;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700335
Alan Cox25ad00b2009-08-19 18:21:44 +0100336 if (etdev->MediaState == 0) {
Alan Cox37628602009-08-19 18:21:50 +0100337 spin_lock_irqsave(&etdev->Lock, flags);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700338
Alan Cox25ad00b2009-08-19 18:21:44 +0100339 etdev->MediaState = NETIF_STATUS_MEDIA_DISCONNECT;
Alan Coxf6b35d62009-08-27 11:02:05 +0100340 etdev->Flags &= ~fMP_ADAPTER_LINK_DETECTION;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700341
Alan Cox37628602009-08-19 18:21:50 +0100342 spin_unlock_irqrestore(&etdev->Lock, flags);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700343
Alan Cox25ad00b2009-08-19 18:21:44 +0100344 netif_carrier_off(etdev->netdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700345 }
346}
347
348/**
Alan Coxb8c4cc42009-08-27 11:02:25 +0100349 * et131x_configure_global_regs - configure JAGCore global regs
350 * @etdev: pointer to our adapter structure
351 *
352 * Used to configure the global registers on the JAGCore
353 */
354void ConfigGlobalRegs(struct et131x_adapter *etdev)
355{
Alan Coxe266b202009-08-27 11:02:34 +0100356 struct _GLOBAL_t __iomem *regs = &etdev->regs->global;
Alan Coxb8c4cc42009-08-27 11:02:25 +0100357
Alan Coxb8c4cc42009-08-27 11:02:25 +0100358 if (etdev->RegistryPhyLoopbk == false) {
359 if (etdev->RegistryJumboPacket < 2048) {
360 /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word
361 * block of RAM that the driver can split between Tx
362 * and Rx as it desires. Our default is to split it
363 * 50/50:
364 */
Alan Coxe266b202009-08-27 11:02:34 +0100365 writel(0, &regs->rxq_start_addr);
366 writel(PARM_RX_MEM_END_DEF, &regs->rxq_end_addr);
367 writel(PARM_RX_MEM_END_DEF + 1, &regs->txq_start_addr);
368 writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100369 } else if (etdev->RegistryJumboPacket < 8192) {
370 /* For jumbo packets > 2k but < 8k, split 50-50. */
Alan Coxe266b202009-08-27 11:02:34 +0100371 writel(0, &regs->rxq_start_addr);
372 writel(INTERNAL_MEM_RX_OFFSET, &regs->rxq_end_addr);
373 writel(INTERNAL_MEM_RX_OFFSET + 1, &regs->txq_start_addr);
374 writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100375 } else {
376 /* 9216 is the only packet size greater than 8k that
377 * is available. The Tx buffer has to be big enough
378 * for one whole packet on the Tx side. We'll make
379 * the Tx 9408, and give the rest to Rx
380 */
Alan Coxe266b202009-08-27 11:02:34 +0100381 writel(0x0000, &regs->rxq_start_addr);
382 writel(0x01b3, &regs->rxq_end_addr);
383 writel(0x01b4, &regs->txq_start_addr);
384 writel(INTERNAL_MEM_SIZE - 1,&regs->txq_end_addr);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100385 }
386
387 /* Initialize the loopback register. Disable all loopbacks. */
Alan Coxbc7f9c52009-08-27 11:02:43 +0100388 writel(0, &regs->loopback);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100389 } else {
390 /* For PHY Line loopback, the memory is configured as if Tx
391 * and Rx both have all the memory. This is because the
392 * RxMAC will write data into the space, and the TxMAC will
393 * read it out.
394 */
Alan Coxe266b202009-08-27 11:02:34 +0100395 writel(0, &regs->rxq_start_addr);
396 writel(INTERNAL_MEM_SIZE - 1, &regs->rxq_end_addr);
397 writel(0, &regs->txq_start_addr);
398 writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100399
400 /* Initialize the loopback register (MAC loopback). */
Alan Coxbc7f9c52009-08-27 11:02:43 +0100401 writel(ET_LOOP_MAC, &regs->loopback);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100402 }
403
404 /* MSI Register */
Alan Coxe266b202009-08-27 11:02:34 +0100405 writel(0, &regs->msi_config);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100406
407 /* By default, disable the watchdog timer. It will be enabled when
408 * a packet is queued.
409 */
Alan Coxe266b202009-08-27 11:02:34 +0100410 writel(0, &regs->watchdog_timer);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100411}
412
413
414/**
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700415 * et131x_adapter_setup - Set the adapter up as per cassini+ documentation
416 * @adapter: pointer to our private adapter structure
417 *
418 * Returns 0 on success, errno on failure (as defined in errno.h)
419 */
Alan Cox25ad00b2009-08-19 18:21:44 +0100420int et131x_adapter_setup(struct et131x_adapter *etdev)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700421{
422 int status = 0;
423
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700424 /* Configure the JAGCore */
Alan Cox25ad00b2009-08-19 18:21:44 +0100425 ConfigGlobalRegs(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700426
Alan Cox25ad00b2009-08-19 18:21:44 +0100427 ConfigMACRegs1(etdev);
Alan Coxb8c4cc42009-08-27 11:02:25 +0100428
429 /* Configure the MMC registers */
430 /* All we need to do is initialize the Memory Control Register */
431 writel(ET_MMC_ENABLE, &etdev->regs->mmc.mmc_ctrl);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700432
Alan Cox25ad00b2009-08-19 18:21:44 +0100433 ConfigRxMacRegs(etdev);
434 ConfigTxMacRegs(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700435
Alan Cox25ad00b2009-08-19 18:21:44 +0100436 ConfigRxDmaRegs(etdev);
437 ConfigTxDmaRegs(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700438
Alan Cox25ad00b2009-08-19 18:21:44 +0100439 ConfigMacStatRegs(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700440
441 /* Move the following code to Timer function?? */
Alan Cox25ad00b2009-08-19 18:21:44 +0100442 status = et131x_xcvr_find(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700443
Alan Cox64f93032009-06-10 17:30:41 +0100444 if (status != 0)
Alan Cox15700032009-08-27 11:03:09 +0100445 dev_warn(&etdev->pdev->dev, "Could not find the xcvr\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700446
447 /* Prepare the TRUEPHY library. */
Alan Cox25ad00b2009-08-19 18:21:44 +0100448 ET1310_PhyInit(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700449
450 /* Reset the phy now so changes take place */
Alan Cox25ad00b2009-08-19 18:21:44 +0100451 ET1310_PhyReset(etdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700452
453 /* Power down PHY */
Alan Cox25ad00b2009-08-19 18:21:44 +0100454 ET1310_PhyPowerDown(etdev, 1);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700455
456 /*
457 * We need to turn off 1000 base half dulplex, the mac does not
458 * support it. For the 10/100 part, turn off all gig advertisement
459 */
Alan Cox5ec34872009-08-27 10:59:13 +0100460 if (etdev->pdev->device != ET131X_PCI_DEVICE_ID_FAST)
Alan Cox25ad00b2009-08-19 18:21:44 +0100461 ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_FULL);
Alan Cox64f93032009-06-10 17:30:41 +0100462 else
Alan Cox25ad00b2009-08-19 18:21:44 +0100463 ET1310_PhyAdvertise1000BaseT(etdev, TRUEPHY_ADV_DUPLEX_NONE);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700464
465 /* Power up PHY */
Alan Cox25ad00b2009-08-19 18:21:44 +0100466 ET1310_PhyPowerDown(etdev, 0);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700467
Alan Cox25ad00b2009-08-19 18:21:44 +0100468 et131x_setphy_normal(etdev);
Alan Cox15700032009-08-27 11:03:09 +0100469; return status;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700470}
471
472/**
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700473 * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
474 * @adapter: pointer to our private adapter structure
475 */
476void et131x_soft_reset(struct et131x_adapter *adapter)
477{
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700478 /* Disable MAC Core */
Alan Coxf3f415a2009-08-27 10:59:30 +0100479 writel(0xc00f0000, &adapter->regs->mac.cfg1.value);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700480
481 /* Set everything to a reset value */
Alan Coxb8c4cc42009-08-27 11:02:25 +0100482 writel(0x7F, &adapter->regs->global.sw_reset);
Alan Coxf3f415a2009-08-27 10:59:30 +0100483 writel(0x000f0000, &adapter->regs->mac.cfg1.value);
484 writel(0x00000000, &adapter->regs->mac.cfg1.value);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700485}
486
487/**
488 * et131x_align_allocated_memory - Align allocated memory on a given boundary
489 * @adapter: pointer to our adapter structure
490 * @phys_addr: pointer to Physical address
491 * @offset: pointer to the offset variable
492 * @mask: correct mask
493 */
494void et131x_align_allocated_memory(struct et131x_adapter *adapter,
495 uint64_t *phys_addr,
496 uint64_t *offset, uint64_t mask)
497{
498 uint64_t new_addr;
499
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700500 *offset = 0;
501
502 new_addr = *phys_addr & ~mask;
503
504 if (new_addr != *phys_addr) {
505 /* Move to next aligned block */
506 new_addr += mask + 1;
507 /* Return offset for adjusting virt addr */
508 *offset = new_addr - *phys_addr;
509 /* Return new physical address */
510 *phys_addr = new_addr;
511 }
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700512}
513
514/**
515 * et131x_adapter_memory_alloc
516 * @adapter: pointer to our private adapter structure
517 *
518 * Returns 0 on success, errno on failure (as defined in errno.h).
519 *
520 * Allocate all the memory blocks for send, receive and others.
521 */
522int et131x_adapter_memory_alloc(struct et131x_adapter *adapter)
523{
Alan Coxc431e3c2009-10-06 15:47:41 +0100524 int status;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700525
Alan Coxc431e3c2009-10-06 15:47:41 +0100526 /* Allocate memory for the Tx Ring */
527 status = et131x_tx_dma_memory_alloc(adapter);
528 if (status != 0) {
529 dev_err(&adapter->pdev->dev,
530 "et131x_tx_dma_memory_alloc FAILED\n");
531 return status;
532 }
533 /* Receive buffer memory allocation */
534 status = et131x_rx_dma_memory_alloc(adapter);
535 if (status != 0) {
536 dev_err(&adapter->pdev->dev,
537 "et131x_rx_dma_memory_alloc FAILED\n");
538 et131x_tx_dma_memory_free(adapter);
539 return status;
540 }
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700541
Alan Coxc431e3c2009-10-06 15:47:41 +0100542 /* Init receive data structures */
543 status = et131x_init_recv(adapter);
544 if (status != 0) {
545 dev_err(&adapter->pdev->dev,
546 "et131x_init_recv FAILED\n");
547 et131x_tx_dma_memory_free(adapter);
548 et131x_rx_dma_memory_free(adapter);
549 }
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700550 return status;
551}
552
553/**
554 * et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx
555 * @adapter: pointer to our private adapter structure
556 */
557void et131x_adapter_memory_free(struct et131x_adapter *adapter)
558{
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700559 /* Free DMA memory */
560 et131x_tx_dma_memory_free(adapter);
561 et131x_rx_dma_memory_free(adapter);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700562}
563
Alan Coxc431e3c2009-10-06 15:47:41 +0100564
565
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700566/**
Alan Coxc431e3c2009-10-06 15:47:41 +0100567 * et131x_adapter_init
Alan Cox8c5f20f2009-08-27 11:00:24 +0100568 * @etdev: pointer to the private adapter struct
Alan Coxc431e3c2009-10-06 15:47:41 +0100569 * @pdev: pointer to the PCI device
Alan Cox8c5f20f2009-08-27 11:00:24 +0100570 *
Alan Coxc431e3c2009-10-06 15:47:41 +0100571 * Initialize the data structures for the et131x_adapter object and link
572 * them together with the platform provided device structures.
Alan Cox8c5f20f2009-08-27 11:00:24 +0100573 */
Alan Coxc431e3c2009-10-06 15:47:41 +0100574
575
576static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,
577 struct pci_dev *pdev)
Alan Cox8c5f20f2009-08-27 11:00:24 +0100578{
579 static const u8 default_mac[] = { 0x00, 0x05, 0x3d, 0x00, 0x02, 0x00 };
580 static const u8 duplex[] = { 0, 1, 2, 1, 2, 2 };
581 static const u16 speed[] = { 0, 10, 10, 100, 100, 1000 };
582
Alan Coxc431e3c2009-10-06 15:47:41 +0100583 struct et131x_adapter *etdev;
584
585 /* Setup the fundamental net_device and private adapter structure elements */
586 SET_NETDEV_DEV(netdev, &pdev->dev);
587
588 /* Allocate private adapter struct and copy in relevant information */
589 etdev = netdev_priv(netdev);
590 etdev->pdev = pci_dev_get(pdev);
591 etdev->netdev = netdev;
592
593 /* Do the same for the netdev struct */
594 netdev->irq = pdev->irq;
595 netdev->base_addr = pci_resource_start(pdev, 0);
596
597 /* Initialize spinlocks here */
598 spin_lock_init(&etdev->Lock);
599 spin_lock_init(&etdev->TCBSendQLock);
600 spin_lock_init(&etdev->TCBReadyQLock);
601 spin_lock_init(&etdev->SendHWLock);
602 spin_lock_init(&etdev->SendWaitLock);
603 spin_lock_init(&etdev->RcvLock);
604 spin_lock_init(&etdev->RcvPendLock);
605 spin_lock_init(&etdev->FbrLock);
606 spin_lock_init(&etdev->PHYLock);
607
608 /* Parse configuration parameters into the private adapter struct */
Alan Cox8c5f20f2009-08-27 11:00:24 +0100609 if (et131x_speed_set)
Alan Cox15700032009-08-27 11:03:09 +0100610 dev_info(&etdev->pdev->dev,
611 "Speed set manually to : %d \n", et131x_speed_set);
Alan Cox8c5f20f2009-08-27 11:00:24 +0100612
613 etdev->SpeedDuplex = et131x_speed_set;
614 etdev->RegistryJumboPacket = 1514; /* 1514-9216 */
615
616 etdev->RegistryNMIDisable = et131x_nmi_disable;
617
618 /* Set the MAC address to a default */
619 memcpy(etdev->CurrentAddress, default_mac, ETH_ALEN);
620
621 /* Decode SpeedDuplex
622 *
623 * Set up as if we are auto negotiating always and then change if we
624 * go into force mode
625 *
626 * If we are the 10/100 device, and gigabit is somehow requested then
627 * knock it down to 100 full.
628 */
629 if (etdev->pdev->device == ET131X_PCI_DEVICE_ID_FAST &&
630 etdev->SpeedDuplex == 5)
631 etdev->SpeedDuplex = 4;
632
633 etdev->AiForceSpeed = speed[etdev->SpeedDuplex];
634 etdev->AiForceDpx = duplex[etdev->SpeedDuplex]; /* Auto FDX */
Alan Coxc431e3c2009-10-06 15:47:41 +0100635
636 return etdev;
Alan Cox8c5f20f2009-08-27 11:00:24 +0100637}
638
Alan Cox7ca5d422009-08-27 11:03:21 +0100639/**
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700640 * et131x_pci_setup - Perform device initialization
641 * @pdev: a pointer to the device's pci_dev structure
642 * @ent: this device's entry in the pci_device_id table
643 *
644 * Returns 0 on success, errno on failure (as defined in errno.h)
645 *
646 * Registered in the pci_driver structure, this function is called when the
647 * PCI subsystem finds a new PCI device which matches the information
648 * contained in the pci_device_id table. This routine is the equivalent to
649 * a device insertion routine.
650 */
Alan Cox7ca5d422009-08-27 11:03:21 +0100651
Alan Coxc431e3c2009-10-06 15:47:41 +0100652static int __devinit et131x_pci_setup(struct pci_dev *pdev,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700653 const struct pci_device_id *ent)
654{
Alan Coxc431e3c2009-10-06 15:47:41 +0100655 int result = -EBUSY;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700656 int pm_cap;
657 bool pci_using_dac;
Alan Coxc431e3c2009-10-06 15:47:41 +0100658 struct net_device *netdev;
659 struct et131x_adapter *adapter;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700660
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700661 /* Enable the device via the PCI subsystem */
Alan Coxc431e3c2009-10-06 15:47:41 +0100662 if (pci_enable_device(pdev) != 0) {
663 dev_err(&pdev->dev,
Alan Cox15700032009-08-27 11:03:09 +0100664 "pci_enable_device() failed\n");
Alan Coxc431e3c2009-10-06 15:47:41 +0100665 return -EIO;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700666 }
667
668 /* Perform some basic PCI checks */
669 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
Alan Coxc431e3c2009-10-06 15:47:41 +0100670 dev_err(&pdev->dev,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700671 "Can't find PCI device's base address\n");
Alan Coxc431e3c2009-10-06 15:47:41 +0100672 goto err_disable;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700673 }
674
Alan Coxc431e3c2009-10-06 15:47:41 +0100675 if (pci_request_regions(pdev, DRIVER_NAME)) {
676 dev_err(&pdev->dev,
Alan Cox15700032009-08-27 11:03:09 +0100677 "Can't get PCI resources\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700678 goto err_disable;
679 }
680
681 /* Enable PCI bus mastering */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700682 pci_set_master(pdev);
683
684 /* Query PCI for Power Mgmt Capabilities
685 *
686 * NOTE: Now reading PowerMgmt in another location; is this still
687 * needed?
688 */
689 pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
690 if (pm_cap == 0) {
Alan Coxc431e3c2009-10-06 15:47:41 +0100691 dev_err(&pdev->dev,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700692 "Cannot find Power Management capabilities\n");
693 result = -EIO;
694 goto err_release_res;
695 }
696
697 /* Check the DMA addressing support of this device */
Alan Coxc431e3c2009-10-06 15:47:41 +0100698 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700699 pci_using_dac = true;
700
Alan Coxc431e3c2009-10-06 15:47:41 +0100701 result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700702 if (result != 0) {
Alan Cox15700032009-08-27 11:03:09 +0100703 dev_err(&pdev->dev,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700704 "Unable to obtain 64 bit DMA for consistent allocations\n");
705 goto err_release_res;
706 }
Alan Coxc431e3c2009-10-06 15:47:41 +0100707 } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700708 pci_using_dac = false;
709 } else {
Alan Coxc431e3c2009-10-06 15:47:41 +0100710 dev_err(&pdev->dev,
Alan Cox15700032009-08-27 11:03:09 +0100711 "No usable DMA addressing method\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700712 result = -EIO;
713 goto err_release_res;
714 }
715
716 /* Allocate netdev and private adapter structs */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700717 netdev = et131x_device_alloc();
718 if (netdev == NULL) {
Alan Coxc431e3c2009-10-06 15:47:41 +0100719 dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700720 result = -ENOMEM;
721 goto err_release_res;
722 }
Alan Coxc431e3c2009-10-06 15:47:41 +0100723 adapter = et131x_adapter_init(netdev, pdev);
724 /* Initialise the PCI setup for the device */
725 et131x_pci_init(adapter, pdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700726
727 /* Map the bus-relative registers to system virtual memory */
Alan Coxc431e3c2009-10-06 15:47:41 +0100728 adapter->regs = pci_ioremap_bar(pdev, 0);
Alan Coxf3f415a2009-08-27 10:59:30 +0100729 if (adapter->regs == NULL) {
Alan Cox15700032009-08-27 11:03:09 +0100730 dev_err(&pdev->dev, "Cannot map device registers\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700731 result = -ENOMEM;
732 goto err_free_dev;
733 }
734
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700735 /* If Phy COMA mode was enabled when we went down, disable it here. */
Alan Coxf2c98d22009-08-27 11:01:49 +0100736 writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700737
738 /* Issue a global reset to the et1310 */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700739 et131x_soft_reset(adapter);
740
741 /* Disable all interrupts (paranoid) */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700742 et131x_disable_interrupts(adapter);
743
744 /* Allocate DMA memory */
745 result = et131x_adapter_memory_alloc(adapter);
746 if (result != 0) {
Alan Cox15700032009-08-27 11:03:09 +0100747 dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700748 goto err_iounmap;
749 }
750
751 /* Init send data structures */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700752 et131x_init_send(adapter);
753
Alan Coxc431e3c2009-10-06 15:47:41 +0100754 /*
755 * Set up the task structure for the ISR's deferred handler
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700756 */
757 INIT_WORK(&adapter->task, et131x_isr_handler);
758
Alan Coxc431e3c2009-10-06 15:47:41 +0100759 /* Copy address into the net_device struct */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700760 memcpy(netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN);
761
762 /* Setup et1310 as per the documentation */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700763 et131x_adapter_setup(adapter);
764
765 /* Create a timer to count errors received by the NIC */
766 init_timer(&adapter->ErrorTimer);
767
768 adapter->ErrorTimer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000;
769 adapter->ErrorTimer.function = et131x_error_timer_handler;
770 adapter->ErrorTimer.data = (unsigned long)adapter;
771
772 /* Initialize link state */
773 et131x_link_detection_handler((unsigned long)adapter);
774
Alan Cox64f93032009-06-10 17:30:41 +0100775 /* Intialize variable for counting how long we do not have
776 link status */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700777 adapter->PoMgmt.TransPhyComaModeOnBoot = 0;
778
779 /* We can enable interrupts now
780 *
781 * NOTE - Because registration of interrupt handler is done in the
782 * device's open(), defer enabling device interrupts to that
783 * point
784 */
785
786 /* Register the net_device struct with the Linux network layer */
Alan Cox64f93032009-06-10 17:30:41 +0100787 result = register_netdev(netdev);
788 if (result != 0) {
Alan Cox15700032009-08-27 11:03:09 +0100789 dev_err(&pdev->dev, "register_netdev() failed\n");
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700790 goto err_mem_free;
791 }
792
793 /* Register the net_device struct with the PCI subsystem. Save a copy
794 * of the PCI config space for this device now that the device has
795 * been initialized, just in case it needs to be quickly restored.
796 */
797 pci_set_drvdata(pdev, netdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700798 pci_save_state(adapter->pdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700799 return result;
800
801err_mem_free:
802 et131x_adapter_memory_free(adapter);
803err_iounmap:
Alan Coxf3f415a2009-08-27 10:59:30 +0100804 iounmap(adapter->regs);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700805err_free_dev:
Alan Cox6ae56042009-08-27 10:59:21 +0100806 pci_dev_put(pdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700807 free_netdev(netdev);
808err_release_res:
809 pci_release_regions(pdev);
810err_disable:
811 pci_disable_device(pdev);
Alan Coxc431e3c2009-10-06 15:47:41 +0100812 return result;
813}
814
815/**
816 * et131x_pci_remove
817 * @pdev: a pointer to the device's pci_dev structure
818 *
819 * Registered in the pci_driver structure, this function is called when the
820 * PCI subsystem detects that a PCI device which matches the information
821 * contained in the pci_device_id table has been removed.
822 */
823
824static void __devexit et131x_pci_remove(struct pci_dev *pdev)
825{
826 struct net_device *netdev;
827 struct et131x_adapter *adapter;
828
829 /* Retrieve the net_device pointer from the pci_dev struct, as well
830 * as the private adapter struct
831 */
832 netdev = (struct net_device *) pci_get_drvdata(pdev);
833 adapter = netdev_priv(netdev);
834
835 /* Perform device cleanup */
836 unregister_netdev(netdev);
837 et131x_adapter_memory_free(adapter);
838 iounmap(adapter->regs);
839 pci_dev_put(adapter->pdev);
840 free_netdev(netdev);
841 pci_release_regions(pdev);
842 pci_disable_device(pdev);
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700843}
Alan Cox7ca5d422009-08-27 11:03:21 +0100844
845static struct pci_device_id et131x_pci_table[] __devinitdata = {
846 {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID,
847 PCI_ANY_ID, 0, 0, 0UL},
848 {ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID,
849 PCI_ANY_ID, 0, 0, 0UL},
850 {0,}
851};
852
853MODULE_DEVICE_TABLE(pci, et131x_pci_table);
854
855static struct pci_driver et131x_driver = {
856 .name = DRIVER_NAME,
857 .id_table = et131x_pci_table,
858 .probe = et131x_pci_setup,
859 .remove = __devexit_p(et131x_pci_remove),
860 .suspend = NULL, /* et131x_pci_suspend */
861 .resume = NULL, /* et131x_pci_resume */
862};
863
864
865/**
866 * et131x_init_module - The "main" entry point called on driver initialization
867 *
868 * Returns 0 on success, errno on failure (as defined in errno.h)
869 */
Peter Huewe3c0d4462009-09-29 01:34:14 +0200870static int __init et131x_init_module(void)
Alan Cox7ca5d422009-08-27 11:03:21 +0100871{
872 if (et131x_speed_set < PARM_SPEED_DUPLEX_MIN ||
873 et131x_speed_set > PARM_SPEED_DUPLEX_MAX) {
874 printk(KERN_WARNING "et131x: invalid speed setting ignored.\n");
875 et131x_speed_set = 0;
876 }
877 return pci_register_driver(&et131x_driver);
878}
879
880/**
881 * et131x_cleanup_module - The entry point called on driver cleanup
882 */
Peter Huewe3c0d4462009-09-29 01:34:14 +0200883static void __exit et131x_cleanup_module(void)
Alan Cox7ca5d422009-08-27 11:03:21 +0100884{
885 pci_unregister_driver(&et131x_driver);
886}
887
888module_init(et131x_init_module);
889module_exit(et131x_cleanup_module);
890
Alan Cox7ca5d422009-08-27 11:03:21 +0100891/* Modinfo parameters (filled out using defines from et131x_version.h) */
892MODULE_AUTHOR(DRIVER_AUTHOR);
893MODULE_DESCRIPTION(DRIVER_INFO);
894MODULE_LICENSE(DRIVER_LICENSE);