34 #include <linux/kernel.h>
35 #include <linux/module.h>
36 #include <linux/types.h>
37 #include <linux/fcntl.h>
43 #include <linux/string.h>
45 #include <linux/nubus.h>
46 #include <linux/errno.h>
47 #include <linux/netdevice.h>
53 #include <linux/slab.h>
55 #include <asm/bootinfo.h>
56 #include <asm/pgtable.h>
64 static char mac_sonic_string[] =
"macsonic";
71 #define SONIC_READ(reg) (nubus_readw(dev->base_addr + (reg * 4) \
73 #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
78 static unsigned int sonic_debug = SONIC_DEBUG;
80 static unsigned int sonic_debug = 1;
83 static int sonic_version_printed;
86 #define ONBOARD_SONIC_REGISTERS 0x50F0A000
87 #define ONBOARD_SONIC_PROM_BASE 0x50f08000
98 #define DUODOCK_SONIC_REGISTERS 0xe10000
99 #define DUODOCK_SONIC_PROM_BASE 0xe12000
102 #define APPLE_SONIC_REGISTERS 0
103 #define APPLE_SONIC_PROM_BASE 0x40000
106 #define DAYNALINK_PROM_BASE 0x400000
109 #define DAYNA_SONIC_REGISTERS 0x180000
113 #define DAYNA_SONIC_MAC_ADDR 0xffe004
115 #define SONIC_READ_PROM(addr) nubus_readb(prom_addr+addr)
121 static inline void bit_reverse_addr(
unsigned char addr[6])
125 for(i = 0; i < 6; i++)
126 addr[i] = bitrev8(addr[i]);
135 result = sonic_interrupt(irq, dev_id);
154 if (dev->
irq == IRQ_AUTO_3) {
163 retval = sonic_open(dev);
169 if (dev->
irq == IRQ_AUTO_3)
177 static int macsonic_close(
struct net_device* dev)
180 err = sonic_close(dev);
182 if (dev->
irq == IRQ_AUTO_3)
188 .ndo_open = macsonic_open,
189 .ndo_stop = macsonic_close,
190 .ndo_start_xmit = sonic_send_packet,
191 .ndo_set_rx_mode = sonic_multicast_list,
192 .ndo_tx_timeout = sonic_tx_timeout,
193 .ndo_get_stats = sonic_get_stats,
208 printk(
KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n",
243 #define INVALID_MAC(mac) (memcmp(mac, "\x08\x00\x07", 3) && \
244 memcmp(mac, "\x00\xA0\x40", 3) && \
245 memcmp(mac, "\x00\x80\x19", 3) && \
246 memcmp(mac, "\x00\x05\x02", 3))
262 for (i = 0; i < 6; i++)
281 "to be invalid, trying CAM\n");
284 "PROM, trying CAM\n");
308 "seems invalid, will use a random MAC\n");
309 eth_hw_addr_random(dev);
321 printk(
KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
351 dev->
irq = IRQ_AUTO_3;
355 if (!sonic_version_printed) {
357 sonic_version_printed = 1;
367 }
else if (commslot) {
377 if (sr == 0x0004 || sr == 0x0006 || sr == 0x0100 || sr == 0x0101)
392 "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
417 mac_onboard_sonic_ethernet_addr(dev);
420 return macsonic_init(dev);
424 unsigned long prom_addr,
428 for(i = 0; i < 6; i++)
468 unsigned long base_addr, prom_addr;
478 if (slots & (1<<ndev->
board->slot))
480 slots |= 1<<ndev->
board->slot;
483 if ((
id = macsonic_ident(ndev)) != -1)
542 if (!sonic_version_printed) {
544 sonic_version_printed = 1;
548 printk(
KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
569 if (mac_nubus_sonic_ethernet_addr(dev, prom_addr,
id) != 0)
573 return macsonic_init(dev);
586 lp = netdev_priv(dev);
589 platform_set_drvdata(pdev, dev);
592 err = mac_onboard_sonic_probe(dev);
597 err = mac_nubus_sonic_probe(dev);
624 struct net_device *dev = platform_get_drvdata(pdev);
636 .probe = mac_sonic_probe,
639 .name = mac_sonic_string,