2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* macsonic.c
|
|
|
|
*
|
2005-08-20 13:53:22 +08:00
|
|
|
* (C) 2005 Finn Thain
|
|
|
|
*
|
|
|
|
* Converted to DMA API, converted to unified driver model, made it work as
|
|
|
|
* a module again, and from the mac68k project, introduced more 32-bit cards
|
|
|
|
* and dhd's support for 16-bit cards.
|
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* (C) 1998 Alan Cox
|
|
|
|
*
|
|
|
|
* Debugging Andreas Ehliar, Michael Schmitz
|
|
|
|
*
|
|
|
|
* Based on code
|
|
|
|
* (C) 1996 by Thomas Bogendoerfer (tsbogend@bigbug.franken.de)
|
2006-09-14 01:24:59 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* This driver is based on work from Andreas Busse, but most of
|
|
|
|
* the code is rewritten.
|
2006-09-14 01:24:59 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* (C) 1995 by Andreas Busse (andy@waldorf-gmbh.de)
|
|
|
|
*
|
|
|
|
* A driver for the Mac onboard Sonic ethernet chip.
|
|
|
|
*
|
2006-09-14 01:24:59 +08:00
|
|
|
* 98/12/21 MSch: judged from tests on Q800, it's basically working,
|
2005-04-17 06:20:36 +08:00
|
|
|
* but eating up both receive and transmit resources
|
|
|
|
* and duplicating packets. Needs more testing.
|
|
|
|
*
|
|
|
|
* 99/01/03 MSch: upgraded to version 0.92 of the core driver, fixed.
|
2006-09-14 01:24:59 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* 00/10/31 sammy@oh.verio.com: Updated driver for 2.4 kernels, fixed problems
|
|
|
|
* on centris.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2005-08-20 13:53:22 +08:00
|
|
|
#include <linux/module.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/fcntl.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/gfp.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/nubus.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
2005-10-30 02:07:23 +08:00
|
|
|
#include <linux/platform_device.h>
|
2005-08-20 13:53:22 +08:00
|
|
|
#include <linux/dma-mapping.h>
|
2007-02-10 00:05:22 +08:00
|
|
|
#include <linux/bitrev.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/hwtest.h>
|
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/macintosh.h>
|
|
|
|
#include <asm/macints.h>
|
|
|
|
#include <asm/mac_via.h>
|
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
static char mac_sonic_string[] = "macsonic";
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "sonic.h"
|
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
/* These should basically be bus-size and endian independent (since
|
|
|
|
the SONIC is at least smart enough that it uses the same endianness
|
|
|
|
as the host, unlike certain less enlightened Macintosh NICs) */
|
|
|
|
#define SONIC_READ(reg) (nubus_readw(dev->base_addr + (reg * 4) \
|
|
|
|
+ lp->reg_offset))
|
|
|
|
#define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
|
|
|
|
+ lp->reg_offset))
|
|
|
|
|
|
|
|
/* use 0 for production, 1 for verification, >1 for debug */
|
|
|
|
#ifdef SONIC_DEBUG
|
|
|
|
static unsigned int sonic_debug = SONIC_DEBUG;
|
2006-09-14 01:24:59 +08:00
|
|
|
#else
|
2005-08-20 13:53:22 +08:00
|
|
|
static unsigned int sonic_debug = 1;
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int sonic_version_printed;
|
|
|
|
|
|
|
|
/* For onboard SONIC */
|
|
|
|
#define ONBOARD_SONIC_REGISTERS 0x50F0A000
|
|
|
|
#define ONBOARD_SONIC_PROM_BASE 0x50f08000
|
|
|
|
|
|
|
|
enum macsonic_type {
|
|
|
|
MACSONIC_DUODOCK,
|
|
|
|
MACSONIC_APPLE,
|
|
|
|
MACSONIC_APPLE16,
|
|
|
|
MACSONIC_DAYNA,
|
|
|
|
MACSONIC_DAYNALINK
|
|
|
|
};
|
|
|
|
|
|
|
|
/* For the built-in SONIC in the Duo Dock */
|
|
|
|
#define DUODOCK_SONIC_REGISTERS 0xe10000
|
|
|
|
#define DUODOCK_SONIC_PROM_BASE 0xe12000
|
|
|
|
|
|
|
|
/* For Apple-style NuBus SONIC */
|
|
|
|
#define APPLE_SONIC_REGISTERS 0
|
|
|
|
#define APPLE_SONIC_PROM_BASE 0x40000
|
|
|
|
|
|
|
|
/* Daynalink LC SONIC */
|
|
|
|
#define DAYNALINK_PROM_BASE 0x400000
|
|
|
|
|
|
|
|
/* For Dayna-style NuBus SONIC (haven't seen one yet) */
|
|
|
|
#define DAYNA_SONIC_REGISTERS 0x180000
|
|
|
|
/* This is what OpenBSD says. However, this is definitely in NuBus
|
|
|
|
ROM space so we should be able to get it by walking the NuBus
|
|
|
|
resource directories */
|
|
|
|
#define DAYNA_SONIC_MAC_ADDR 0xffe004
|
|
|
|
|
|
|
|
#define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For reversing the PROM address
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void bit_reverse_addr(unsigned char addr[6])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < 6; i++)
|
2006-12-20 05:09:08 +08:00
|
|
|
addr[i] = bitrev8(addr[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-02 10:55:56 +08:00
|
|
|
static irqreturn_t macsonic_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
irqreturn_t result;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
result = sonic_interrupt(irq, dev_id);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int macsonic_open(struct net_device* dev)
|
|
|
|
{
|
2010-07-10 09:39:06 +08:00
|
|
|
int retval;
|
|
|
|
|
2011-07-14 04:33:13 +08:00
|
|
|
retval = request_irq(dev->irq, sonic_interrupt, 0, "sonic", dev);
|
2010-07-10 09:39:06 +08:00
|
|
|
if (retval) {
|
|
|
|
printk(KERN_ERR "%s: unable to get IRQ %d.\n",
|
|
|
|
dev->name, dev->irq);
|
|
|
|
goto err;
|
2007-05-02 10:55:56 +08:00
|
|
|
}
|
|
|
|
/* Under the A/UX interrupt scheme, the onboard SONIC interrupt comes
|
|
|
|
* in at priority level 3. However, we sometimes get the level 2 inter-
|
|
|
|
* rupt as well, which must prevent re-entrance of the sonic handler.
|
|
|
|
*/
|
2010-07-10 09:39:06 +08:00
|
|
|
if (dev->irq == IRQ_AUTO_3) {
|
2011-07-14 04:33:13 +08:00
|
|
|
retval = request_irq(IRQ_NUBUS_9, macsonic_interrupt, 0,
|
|
|
|
"sonic", dev);
|
2010-07-10 09:39:06 +08:00
|
|
|
if (retval) {
|
|
|
|
printk(KERN_ERR "%s: unable to get IRQ %d.\n",
|
|
|
|
dev->name, IRQ_NUBUS_9);
|
|
|
|
goto err_irq;
|
2007-05-02 10:55:56 +08:00
|
|
|
}
|
2010-07-10 09:39:06 +08:00
|
|
|
}
|
|
|
|
retval = sonic_open(dev);
|
|
|
|
if (retval)
|
|
|
|
goto err_irq_nubus;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_irq_nubus:
|
|
|
|
if (dev->irq == IRQ_AUTO_3)
|
|
|
|
free_irq(IRQ_NUBUS_9, dev);
|
|
|
|
err_irq:
|
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
err:
|
|
|
|
return retval;
|
2007-05-02 10:55:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int macsonic_close(struct net_device* dev)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
err = sonic_close(dev);
|
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
if (dev->irq == IRQ_AUTO_3)
|
|
|
|
free_irq(IRQ_NUBUS_9, dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-04-11 15:41:28 +08:00
|
|
|
static const struct net_device_ops macsonic_netdev_ops = {
|
|
|
|
.ndo_open = macsonic_open,
|
|
|
|
.ndo_stop = macsonic_close,
|
|
|
|
.ndo_start_xmit = sonic_send_packet,
|
2011-08-16 14:29:01 +08:00
|
|
|
.ndo_set_rx_mode = sonic_multicast_list,
|
2009-04-11 15:41:28 +08:00
|
|
|
.ndo_tx_timeout = sonic_tx_timeout,
|
|
|
|
.ndo_get_stats = sonic_get_stats,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
.ndo_change_mtu = eth_change_mtu,
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
};
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int macsonic_init(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-20 13:53:22 +08:00
|
|
|
struct sonic_local* lp = netdev_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Allocate the entire chunk of memory for the descriptors.
|
|
|
|
Note that this cannot cross a 64K boundary. */
|
2013-03-14 21:07:21 +08:00
|
|
|
lp->descriptors = dma_alloc_coherent(lp->device,
|
|
|
|
SIZEOF_SONIC_DESC *
|
|
|
|
SONIC_BUS_SCALE(lp->dma_bitmode),
|
|
|
|
&lp->descriptors_laddr,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (lp->descriptors == NULL)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* Now set up the pointers to point to the appropriate places */
|
2005-08-20 13:53:22 +08:00
|
|
|
lp->cda = lp->descriptors;
|
|
|
|
lp->tda = lp->cda + (SIZEOF_SONIC_CDA
|
|
|
|
* SONIC_BUS_SCALE(lp->dma_bitmode));
|
2005-04-17 06:20:36 +08:00
|
|
|
lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
|
2005-08-20 13:53:22 +08:00
|
|
|
* SONIC_BUS_SCALE(lp->dma_bitmode));
|
2005-04-17 06:20:36 +08:00
|
|
|
lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
|
2005-08-20 13:53:22 +08:00
|
|
|
* SONIC_BUS_SCALE(lp->dma_bitmode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
lp->cda_laddr = lp->descriptors_laddr;
|
|
|
|
lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA
|
|
|
|
* SONIC_BUS_SCALE(lp->dma_bitmode));
|
|
|
|
lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS
|
|
|
|
* SONIC_BUS_SCALE(lp->dma_bitmode));
|
|
|
|
lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS
|
|
|
|
* SONIC_BUS_SCALE(lp->dma_bitmode));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-04-11 15:41:28 +08:00
|
|
|
dev->netdev_ops = &macsonic_netdev_ops;
|
2005-08-20 13:53:22 +08:00
|
|
|
dev->watchdog_timeo = TX_TIMEOUT;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* clear tally counter
|
|
|
|
*/
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_WRITE(SONIC_CRCT, 0xffff);
|
|
|
|
SONIC_WRITE(SONIC_FAET, 0xffff);
|
|
|
|
SONIC_WRITE(SONIC_MPT, 0xffff);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-03 11:42:40 +08:00
|
|
|
#define INVALID_MAC(mac) (memcmp(mac, "\x08\x00\x07", 3) && \
|
|
|
|
memcmp(mac, "\x00\xA0\x40", 3) && \
|
|
|
|
memcmp(mac, "\x00\x80\x19", 3) && \
|
|
|
|
memcmp(mac, "\x00\x05\x02", 3))
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static void mac_onboard_sonic_ethernet_addr(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-20 13:53:22 +08:00
|
|
|
struct sonic_local *lp = netdev_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
const int prom_addr = ONBOARD_SONIC_PROM_BASE;
|
2009-11-03 11:42:40 +08:00
|
|
|
unsigned short val;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-11-03 11:42:40 +08:00
|
|
|
/*
|
|
|
|
* On NuBus boards we can sometimes look in the ROM resources.
|
|
|
|
* No such luck for comm-slot/onboard.
|
|
|
|
* On the PowerBook 520, the PROM base address is a mystery.
|
|
|
|
*/
|
|
|
|
if (hwreg_present((void *)prom_addr)) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
dev->dev_addr[i] = SONIC_READ_PROM(i);
|
|
|
|
if (!INVALID_MAC(dev->dev_addr))
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-11-03 11:42:40 +08:00
|
|
|
/*
|
|
|
|
* Most of the time, the address is bit-reversed. The NetBSD
|
|
|
|
* source has a rather long and detailed historical account of
|
|
|
|
* why this is so.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
bit_reverse_addr(dev->dev_addr);
|
2009-11-03 11:42:40 +08:00
|
|
|
if (!INVALID_MAC(dev->dev_addr))
|
|
|
|
return;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2009-11-03 11:42:40 +08:00
|
|
|
* If we still have what seems to be a bogus address, we'll
|
|
|
|
* look in the CAM. The top entry should be ours.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2009-11-03 11:42:40 +08:00
|
|
|
printk(KERN_WARNING "macsonic: MAC address in PROM seems "
|
|
|
|
"to be invalid, trying CAM\n");
|
|
|
|
} else {
|
|
|
|
printk(KERN_WARNING "macsonic: cannot read MAC address from "
|
|
|
|
"PROM, trying CAM\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This only works if MacOS has already initialized the card. */
|
|
|
|
|
|
|
|
SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
|
|
|
|
SONIC_WRITE(SONIC_CEP, 15);
|
|
|
|
|
|
|
|
val = SONIC_READ(SONIC_CAP2);
|
|
|
|
dev->dev_addr[5] = val >> 8;
|
|
|
|
dev->dev_addr[4] = val & 0xff;
|
|
|
|
val = SONIC_READ(SONIC_CAP1);
|
|
|
|
dev->dev_addr[3] = val >> 8;
|
|
|
|
dev->dev_addr[2] = val & 0xff;
|
|
|
|
val = SONIC_READ(SONIC_CAP0);
|
|
|
|
dev->dev_addr[1] = val >> 8;
|
|
|
|
dev->dev_addr[0] = val & 0xff;
|
|
|
|
|
|
|
|
if (!INVALID_MAC(dev->dev_addr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Still nonsense ... messed up someplace! */
|
|
|
|
|
|
|
|
printk(KERN_WARNING "macsonic: MAC address in CAM entry 15 "
|
|
|
|
"seems invalid, will use a random MAC\n");
|
2012-02-15 14:45:39 +08:00
|
|
|
eth_hw_addr_random(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int mac_onboard_sonic_probe(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-20 13:53:22 +08:00
|
|
|
struct sonic_local* lp = netdev_priv(dev);
|
|
|
|
int sr;
|
|
|
|
int commslot = 0;
|
2006-09-14 01:24:59 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!MACH_IS_MAC)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
|
2006-09-14 01:24:59 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Bogus probing, on the models which may or may not have
|
|
|
|
Ethernet (BTW, the Ethernet *is* always at the same
|
|
|
|
address, and nothing else lives there, at least if Apple's
|
|
|
|
documentation is to be believed) */
|
|
|
|
if (macintosh_config->ident == MAC_MODEL_Q630 ||
|
|
|
|
macintosh_config->ident == MAC_MODEL_P588 ||
|
2005-08-20 13:53:22 +08:00
|
|
|
macintosh_config->ident == MAC_MODEL_P575 ||
|
2005-04-17 06:20:36 +08:00
|
|
|
macintosh_config->ident == MAC_MODEL_C610) {
|
|
|
|
unsigned long flags;
|
|
|
|
int card_present;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
|
|
|
if (!card_present) {
|
|
|
|
printk("none.\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2005-08-20 13:53:22 +08:00
|
|
|
commslot = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-09-14 01:24:59 +08:00
|
|
|
printk("yes\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
/* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
|
|
|
|
* and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->base_addr = ONBOARD_SONIC_REGISTERS;
|
|
|
|
if (via_alt_mapping)
|
|
|
|
dev->irq = IRQ_AUTO_3;
|
|
|
|
else
|
|
|
|
dev->irq = IRQ_NUBUS_9;
|
|
|
|
|
|
|
|
if (!sonic_version_printed) {
|
|
|
|
printk(KERN_INFO "%s", version);
|
|
|
|
sonic_version_printed = 1;
|
|
|
|
}
|
|
|
|
printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
|
2009-03-25 07:38:22 +08:00
|
|
|
dev_name(lp->device), dev->base_addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* The PowerBook's SONIC is 16 bit always. */
|
|
|
|
if (macintosh_config->ident == MAC_MODEL_PB520) {
|
2005-08-20 13:53:22 +08:00
|
|
|
lp->reg_offset = 0;
|
|
|
|
lp->dma_bitmode = SONIC_BITMODE16;
|
|
|
|
sr = SONIC_READ(SONIC_SR);
|
|
|
|
} else if (commslot) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Some of the comm-slot cards are 16 bit. But some
|
2005-08-20 13:53:22 +08:00
|
|
|
of them are not. The 32-bit cards use offset 2 and
|
|
|
|
have known revisions, we try reading the revision
|
|
|
|
register at offset 2, if we don't get a known revision
|
|
|
|
we assume 16 bit at offset 0. */
|
|
|
|
lp->reg_offset = 2;
|
|
|
|
lp->dma_bitmode = SONIC_BITMODE16;
|
|
|
|
|
|
|
|
sr = SONIC_READ(SONIC_SR);
|
2006-09-14 01:24:59 +08:00
|
|
|
if (sr == 0x0004 || sr == 0x0006 || sr == 0x0100 || sr == 0x0101)
|
2005-08-20 13:53:22 +08:00
|
|
|
/* 83932 is 0x0004 or 0x0006, 83934 is 0x0100 or 0x0101 */
|
|
|
|
lp->dma_bitmode = SONIC_BITMODE32;
|
|
|
|
else {
|
|
|
|
lp->dma_bitmode = SONIC_BITMODE16;
|
|
|
|
lp->reg_offset = 0;
|
|
|
|
sr = SONIC_READ(SONIC_SR);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-08-20 13:53:22 +08:00
|
|
|
} else {
|
|
|
|
/* All onboard cards are at offset 2 with 32 bit DMA. */
|
|
|
|
lp->reg_offset = 2;
|
|
|
|
lp->dma_bitmode = SONIC_BITMODE32;
|
|
|
|
sr = SONIC_READ(SONIC_SR);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-08-20 13:53:22 +08:00
|
|
|
printk(KERN_INFO
|
|
|
|
"%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
|
2009-03-25 07:38:22 +08:00
|
|
|
dev_name(lp->device), sr, lp->dma_bitmode?32:16, lp->reg_offset);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
#if 0 /* This is sometimes useful to find out how MacOS configured the card. */
|
2009-03-25 07:38:22 +08:00
|
|
|
printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", dev_name(lp->device),
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Software reset, then initialize control registers. */
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
|
|
|
|
|
|
|
|
SONIC_WRITE(SONIC_DCR, SONIC_DCR_EXBUS | SONIC_DCR_BMS |
|
|
|
|
SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
|
|
|
|
(lp->dma_bitmode ? SONIC_DCR_DW : 0));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* This *must* be written back to in order to restore the
|
2005-08-20 13:53:22 +08:00
|
|
|
* extended programmable output bits, as it may not have been
|
|
|
|
* initialised since the hardware reset. */
|
|
|
|
SONIC_WRITE(SONIC_DCR2, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Clear *and* disable interrupts to be on the safe side */
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_WRITE(SONIC_IMR, 0);
|
|
|
|
SONIC_WRITE(SONIC_ISR, 0x7fff);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Now look for the MAC address. */
|
2009-11-03 11:42:40 +08:00
|
|
|
mac_onboard_sonic_ethernet_addr(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Shared init code */
|
|
|
|
return macsonic_init(dev);
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int mac_nubus_sonic_ethernet_addr(struct net_device *dev,
|
2012-12-06 22:30:56 +08:00
|
|
|
unsigned long prom_addr, int id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < 6; i++)
|
|
|
|
dev->dev_addr[i] = SONIC_READ_PROM(i);
|
2005-08-20 13:53:22 +08:00
|
|
|
|
|
|
|
/* Some of the addresses are bit-reversed */
|
|
|
|
if (id != MACSONIC_DAYNA)
|
|
|
|
bit_reverse_addr(dev->dev_addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int macsonic_ident(struct nubus_dev *ndev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-14 01:24:59 +08:00
|
|
|
if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC &&
|
2005-04-17 06:20:36 +08:00
|
|
|
ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
|
|
|
|
return MACSONIC_DAYNALINK;
|
|
|
|
if (ndev->dr_hw == NUBUS_DRHW_SONIC &&
|
|
|
|
ndev->dr_sw == NUBUS_DRSW_APPLE) {
|
|
|
|
/* There has to be a better way to do this... */
|
|
|
|
if (strstr(ndev->board->name, "DuoDock"))
|
|
|
|
return MACSONIC_DUODOCK;
|
|
|
|
else
|
|
|
|
return MACSONIC_APPLE;
|
|
|
|
}
|
2006-09-14 01:24:59 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
if (ndev->dr_hw == NUBUS_DRHW_SMC9194 &&
|
|
|
|
ndev->dr_sw == NUBUS_DRSW_DAYNA)
|
|
|
|
return MACSONIC_DAYNA;
|
2006-09-14 01:24:59 +08:00
|
|
|
|
2007-05-02 04:32:53 +08:00
|
|
|
if (ndev->dr_hw == NUBUS_DRHW_APPLE_SONIC_LC &&
|
2005-08-20 13:53:22 +08:00
|
|
|
ndev->dr_sw == 0) { /* huh? */
|
|
|
|
return MACSONIC_APPLE16;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int mac_nubus_sonic_probe(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
static int slots;
|
|
|
|
struct nubus_dev* ndev = NULL;
|
2005-08-20 13:53:22 +08:00
|
|
|
struct sonic_local* lp = netdev_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long base_addr, prom_addr;
|
|
|
|
u16 sonic_dcr;
|
2005-08-20 13:53:22 +08:00
|
|
|
int id = -1;
|
|
|
|
int reg_offset, dma_bitmode;
|
2006-09-14 01:24:59 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Find the first SONIC that hasn't been initialized already */
|
|
|
|
while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK,
|
|
|
|
NUBUS_TYPE_ETHERNET, ndev)) != NULL)
|
|
|
|
{
|
|
|
|
/* Have we seen it already? */
|
|
|
|
if (slots & (1<<ndev->board->slot))
|
|
|
|
continue;
|
|
|
|
slots |= 1<<ndev->board->slot;
|
|
|
|
|
|
|
|
/* Is it one of ours? */
|
|
|
|
if ((id = macsonic_ident(ndev)) != -1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ndev == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case MACSONIC_DUODOCK:
|
|
|
|
base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
|
|
|
|
prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
|
2005-08-20 13:53:22 +08:00
|
|
|
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 |
|
|
|
|
SONIC_DCR_TFT0;
|
2005-04-17 06:20:36 +08:00
|
|
|
reg_offset = 2;
|
2005-08-20 13:53:22 +08:00
|
|
|
dma_bitmode = SONIC_BITMODE32;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case MACSONIC_APPLE:
|
|
|
|
base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
|
|
|
|
prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
|
|
|
|
sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
|
|
|
|
reg_offset = 0;
|
2005-08-20 13:53:22 +08:00
|
|
|
dma_bitmode = SONIC_BITMODE32;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case MACSONIC_APPLE16:
|
|
|
|
base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
|
|
|
|
prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
|
2005-08-20 13:53:22 +08:00
|
|
|
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
|
2006-09-14 01:24:59 +08:00
|
|
|
SONIC_DCR_PO1 | SONIC_DCR_BMS;
|
2005-04-17 06:20:36 +08:00
|
|
|
reg_offset = 0;
|
2005-08-20 13:53:22 +08:00
|
|
|
dma_bitmode = SONIC_BITMODE16;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case MACSONIC_DAYNALINK:
|
|
|
|
base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
|
|
|
|
prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
|
2005-08-20 13:53:22 +08:00
|
|
|
sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
|
2006-09-14 01:24:59 +08:00
|
|
|
SONIC_DCR_PO1 | SONIC_DCR_BMS;
|
2005-04-17 06:20:36 +08:00
|
|
|
reg_offset = 0;
|
2005-08-20 13:53:22 +08:00
|
|
|
dma_bitmode = SONIC_BITMODE16;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case MACSONIC_DAYNA:
|
|
|
|
base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
|
|
|
|
prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
|
2005-08-20 13:53:22 +08:00
|
|
|
sonic_dcr = SONIC_DCR_BMS |
|
|
|
|
SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
|
2005-04-17 06:20:36 +08:00
|
|
|
reg_offset = 0;
|
2005-08-20 13:53:22 +08:00
|
|
|
dma_bitmode = SONIC_BITMODE16;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "macsonic: WTF, id is %d\n", id);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
/* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
|
|
|
|
* and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->base_addr = base_addr;
|
2005-08-20 13:53:22 +08:00
|
|
|
lp->reg_offset = reg_offset;
|
|
|
|
lp->dma_bitmode = dma_bitmode;
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->irq = SLOT2IRQ(ndev->board->slot);
|
|
|
|
|
|
|
|
if (!sonic_version_printed) {
|
|
|
|
printk(KERN_INFO "%s", version);
|
|
|
|
sonic_version_printed = 1;
|
|
|
|
}
|
|
|
|
printk(KERN_INFO "%s: %s in slot %X\n",
|
2009-03-25 07:38:22 +08:00
|
|
|
dev_name(lp->device), ndev->board->name, ndev->board->slot);
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
|
2009-03-25 07:38:22 +08:00
|
|
|
dev_name(lp->device), SONIC_READ(SONIC_SR), dma_bitmode?32:16, reg_offset);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
#if 0 /* This is sometimes useful to find out how MacOS configured the card. */
|
2009-03-25 07:38:22 +08:00
|
|
|
printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", dev_name(lp->device),
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Software reset, then initialize control registers. */
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
|
|
|
|
SONIC_WRITE(SONIC_DCR, sonic_dcr | (dma_bitmode ? SONIC_DCR_DW : 0));
|
|
|
|
/* This *must* be written back to in order to restore the
|
|
|
|
* extended programmable output bits, since it may not have been
|
|
|
|
* initialised since the hardware reset. */
|
|
|
|
SONIC_WRITE(SONIC_DCR2, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Clear *and* disable interrupts to be on the safe side */
|
2005-08-20 13:53:22 +08:00
|
|
|
SONIC_WRITE(SONIC_IMR, 0);
|
|
|
|
SONIC_WRITE(SONIC_ISR, 0x7fff);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Now look for the MAC address. */
|
|
|
|
if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
/* Shared init code */
|
|
|
|
return macsonic_init(dev);
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int mac_sonic_probe(struct platform_device *pdev)
|
2005-08-20 13:53:22 +08:00
|
|
|
{
|
|
|
|
struct net_device *dev;
|
|
|
|
struct sonic_local *lp;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
dev = alloc_etherdev(sizeof(struct sonic_local));
|
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
lp = netdev_priv(dev);
|
2007-05-02 04:33:02 +08:00
|
|
|
lp->device = &pdev->dev;
|
|
|
|
SET_NETDEV_DEV(dev, &pdev->dev);
|
2009-07-22 03:21:49 +08:00
|
|
|
platform_set_drvdata(pdev, dev);
|
2005-08-20 13:53:22 +08:00
|
|
|
|
|
|
|
/* This will catch fatal stuff like -ENOMEM as well as success */
|
|
|
|
err = mac_onboard_sonic_probe(dev);
|
|
|
|
if (err == 0)
|
|
|
|
goto found;
|
|
|
|
if (err != -ENODEV)
|
|
|
|
goto out;
|
|
|
|
err = mac_nubus_sonic_probe(dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
found:
|
|
|
|
err = register_netdev(dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
2008-10-28 06:59:26 +08:00
|
|
|
printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
out:
|
|
|
|
free_netdev(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
|
|
|
|
module_param(sonic_debug, int, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
|
2009-11-03 21:42:02 +08:00
|
|
|
MODULE_ALIAS("platform:macsonic");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-20 13:53:22 +08:00
|
|
|
#include "sonic.c"
|
|
|
|
|
2012-12-03 22:23:17 +08:00
|
|
|
static int mac_sonic_device_remove(struct platform_device *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-02 04:33:02 +08:00
|
|
|
struct net_device *dev = platform_get_drvdata(pdev);
|
2005-08-20 13:53:22 +08:00
|
|
|
struct sonic_local* lp = netdev_priv(dev);
|
|
|
|
|
2007-05-02 04:33:02 +08:00
|
|
|
unregister_netdev(dev);
|
2005-08-20 13:53:22 +08:00
|
|
|
dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
|
|
|
|
lp->descriptors, lp->descriptors_laddr);
|
2007-05-02 04:33:02 +08:00
|
|
|
free_netdev(dev);
|
2005-08-20 13:53:22 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-10 06:32:44 +08:00
|
|
|
static struct platform_driver mac_sonic_driver = {
|
2005-08-20 13:53:22 +08:00
|
|
|
.probe = mac_sonic_probe,
|
2012-12-03 22:23:17 +08:00
|
|
|
.remove = mac_sonic_device_remove,
|
2005-11-10 06:32:44 +08:00
|
|
|
.driver = {
|
2009-11-03 21:42:02 +08:00
|
|
|
.name = mac_sonic_string,
|
|
|
|
.owner = THIS_MODULE,
|
2005-11-10 06:32:44 +08:00
|
|
|
},
|
2005-08-20 13:53:22 +08:00
|
|
|
};
|
|
|
|
|
2011-11-28 00:44:17 +08:00
|
|
|
module_platform_driver(mac_sonic_driver);
|