提交 cb31232a 编写于 作者: D David S. Miller

Merge branch 'sonic-ethernet-cleanups'

Finn Thain says:

====================
Fixes, cleanup and modernization for SONIC ethernet drivers

Changes since v4 of combined patch series:
- Removed redundant and non-portable MACH_IS_MAC tests.
- Omitted patches unrelated to SONIC drivers.
- Dropped changes to the 'version_printed' logic and debug message text.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -60,14 +60,6 @@ do { \ ...@@ -60,14 +60,6 @@ do { \
*((volatile unsigned int *)dev->base_addr+(reg)) = (val); \ *((volatile unsigned int *)dev->base_addr+(reg)) = (val); \
} while (0) } while (0)
/* use 0 for production, 1 for verification, >1 for debug */
#ifdef SONIC_DEBUG
static unsigned int sonic_debug = SONIC_DEBUG;
#else
static unsigned int sonic_debug = 1;
#endif
/* /*
* We cannot use station (ethernet) address prefixes to detect the * We cannot use station (ethernet) address prefixes to detect the
* sonic controller since these are board manufacturer depended. * sonic controller since these are board manufacturer depended.
...@@ -117,7 +109,6 @@ static const struct net_device_ops sonic_netdev_ops = { ...@@ -117,7 +109,6 @@ static const struct net_device_ops sonic_netdev_ops = {
static int sonic_probe1(struct net_device *dev) static int sonic_probe1(struct net_device *dev)
{ {
static unsigned version_printed;
unsigned int silicon_revision; unsigned int silicon_revision;
unsigned int val; unsigned int val;
struct sonic_local *lp = netdev_priv(dev); struct sonic_local *lp = netdev_priv(dev);
...@@ -133,26 +124,17 @@ static int sonic_probe1(struct net_device *dev) ...@@ -133,26 +124,17 @@ static int sonic_probe1(struct net_device *dev)
* the expected location. * the expected location.
*/ */
silicon_revision = SONIC_READ(SONIC_SR); silicon_revision = SONIC_READ(SONIC_SR);
if (sonic_debug > 1)
printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
i = 0; i = 0;
while (known_revisions[i] != 0xffff && while (known_revisions[i] != 0xffff &&
known_revisions[i] != silicon_revision) known_revisions[i] != silicon_revision)
i++; i++;
if (known_revisions[i] == 0xffff) { if (known_revisions[i] == 0xffff) {
printk("SONIC ethernet controller not found (0x%4x)\n", pr_info("SONIC ethernet controller not found (0x%4x)\n",
silicon_revision); silicon_revision);
goto out; goto out;
} }
if (sonic_debug && version_printed++ == 0)
printk(version);
printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ",
dev_name(lp->device), dev->base_addr);
/* /*
* Put the sonic into software reset, then * Put the sonic into software reset, then
* retrieve and print the ethernet address. * retrieve and print the ethernet address.
...@@ -245,12 +227,16 @@ static int jazz_sonic_probe(struct platform_device *pdev) ...@@ -245,12 +227,16 @@ static int jazz_sonic_probe(struct platform_device *pdev)
err = sonic_probe1(dev); err = sonic_probe1(dev);
if (err) if (err)
goto out; goto out;
pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
dev->base_addr, dev->dev_addr, dev->irq);
sonic_msg_init(dev);
err = register_netdev(dev); err = register_netdev(dev);
if (err) if (err)
goto out1; goto out1;
printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
return 0; return 0;
out1: out1:
...@@ -262,8 +248,6 @@ static int jazz_sonic_probe(struct platform_device *pdev) ...@@ -262,8 +248,6 @@ static int jazz_sonic_probe(struct platform_device *pdev)
} }
MODULE_DESCRIPTION("Jazz SONIC ethernet driver"); MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
module_param(sonic_debug, int, 0);
MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
MODULE_ALIAS("platform:jazzsonic"); MODULE_ALIAS("platform:jazzsonic");
#include "sonic.c" #include "sonic.c"
......
...@@ -60,8 +60,6 @@ ...@@ -60,8 +60,6 @@
#include <asm/macints.h> #include <asm/macints.h>
#include <asm/mac_via.h> #include <asm/mac_via.h>
static char mac_sonic_string[] = "macsonic";
#include "sonic.h" #include "sonic.h"
/* These should basically be bus-size and endian independent (since /* These should basically be bus-size and endian independent (since
...@@ -72,15 +70,6 @@ static char mac_sonic_string[] = "macsonic"; ...@@ -72,15 +70,6 @@ static char mac_sonic_string[] = "macsonic";
#define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \ #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
+ lp->reg_offset)) + lp->reg_offset))
/* use 0 for production, 1 for verification, >1 for debug */
#ifdef SONIC_DEBUG
static unsigned int sonic_debug = SONIC_DEBUG;
#else
static unsigned int sonic_debug = 1;
#endif
static int sonic_version_printed;
/* For onboard SONIC */ /* For onboard SONIC */
#define ONBOARD_SONIC_REGISTERS 0x50F0A000 #define ONBOARD_SONIC_REGISTERS 0x50F0A000
#define ONBOARD_SONIC_PROM_BASE 0x50f08000 #define ONBOARD_SONIC_PROM_BASE 0x50f08000
...@@ -313,11 +302,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev) ...@@ -313,11 +302,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
int sr; int sr;
bool commslot = macintosh_config->expansion_type == MAC_EXP_PDS_COMM; bool commslot = macintosh_config->expansion_type == MAC_EXP_PDS_COMM;
if (!MACH_IS_MAC)
return -ENODEV;
printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
/* Bogus probing, on the models which may or may not have /* Bogus probing, on the models which may or may not have
Ethernet (BTW, the Ethernet *is* always at the same Ethernet (BTW, the Ethernet *is* always at the same
address, and nothing else lives there, at least if Apple's address, and nothing else lives there, at least if Apple's
...@@ -327,13 +311,11 @@ static int mac_onboard_sonic_probe(struct net_device *dev) ...@@ -327,13 +311,11 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS); card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
if (!card_present) { if (!card_present) {
printk("none.\n"); pr_info("Onboard/comm-slot SONIC not found\n");
return -ENODEV; return -ENODEV;
} }
} }
printk("yes\n");
/* Danger! My arms are flailing wildly! You *must* set lp->reg_offset /* Danger! My arms are flailing wildly! You *must* set lp->reg_offset
* and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */ * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
dev->base_addr = ONBOARD_SONIC_REGISTERS; dev->base_addr = ONBOARD_SONIC_REGISTERS;
...@@ -342,18 +324,10 @@ static int mac_onboard_sonic_probe(struct net_device *dev) ...@@ -342,18 +324,10 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
else else
dev->irq = IRQ_NUBUS_9; 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",
dev_name(lp->device), dev->base_addr);
/* The PowerBook's SONIC is 16 bit always. */ /* The PowerBook's SONIC is 16 bit always. */
if (macintosh_config->ident == MAC_MODEL_PB520) { if (macintosh_config->ident == MAC_MODEL_PB520) {
lp->reg_offset = 0; lp->reg_offset = 0;
lp->dma_bitmode = SONIC_BITMODE16; lp->dma_bitmode = SONIC_BITMODE16;
sr = SONIC_READ(SONIC_SR);
} else if (commslot) { } else if (commslot) {
/* Some of the comm-slot cards are 16 bit. But some /* Some of the comm-slot cards are 16 bit. But some
of them are not. The 32-bit cards use offset 2 and of them are not. The 32-bit cards use offset 2 and
...@@ -370,22 +344,21 @@ static int mac_onboard_sonic_probe(struct net_device *dev) ...@@ -370,22 +344,21 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
else { else {
lp->dma_bitmode = SONIC_BITMODE16; lp->dma_bitmode = SONIC_BITMODE16;
lp->reg_offset = 0; lp->reg_offset = 0;
sr = SONIC_READ(SONIC_SR);
} }
} else { } else {
/* All onboard cards are at offset 2 with 32 bit DMA. */ /* All onboard cards are at offset 2 with 32 bit DMA. */
lp->reg_offset = 2; lp->reg_offset = 2;
lp->dma_bitmode = SONIC_BITMODE32; lp->dma_bitmode = SONIC_BITMODE32;
sr = SONIC_READ(SONIC_SR);
} }
printk(KERN_INFO
"%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
dev_name(lp->device), sr, lp->dma_bitmode?32:16, lp->reg_offset);
#if 0 /* This is sometimes useful to find out how MacOS configured the card. */ pr_info("Onboard/comm-slot SONIC, revision 0x%04x, %d bit DMA, register offset %d\n",
printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", dev_name(lp->device), SONIC_READ(SONIC_SR), lp->dma_bitmode ? 32 : 16,
SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff); lp->reg_offset);
#endif
/* This is sometimes useful to find out how MacOS configured the card */
pr_debug("%s: DCR=0x%04x, DCR2=0x%04x\n", __func__,
SONIC_READ(SONIC_DCR) & 0xffff,
SONIC_READ(SONIC_DCR2) & 0xffff);
/* Software reset, then initialize control registers. */ /* Software reset, then initialize control registers. */
SONIC_WRITE(SONIC_CMD, SONIC_CR_RST); SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
...@@ -406,11 +379,14 @@ static int mac_onboard_sonic_probe(struct net_device *dev) ...@@ -406,11 +379,14 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
/* Now look for the MAC address. */ /* Now look for the MAC address. */
mac_onboard_sonic_ethernet_addr(dev); mac_onboard_sonic_ethernet_addr(dev);
pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
dev->base_addr, dev->dev_addr, dev->irq);
/* Shared init code */ /* Shared init code */
return macsonic_init(dev); return macsonic_init(dev);
} }
static int mac_nubus_sonic_ethernet_addr(struct net_device *dev, static int mac_sonic_nubus_ethernet_addr(struct net_device *dev,
unsigned long prom_addr, int id) unsigned long prom_addr, int id)
{ {
int i; int i;
...@@ -449,70 +425,49 @@ static int macsonic_ident(struct nubus_rsrc *fres) ...@@ -449,70 +425,49 @@ static int macsonic_ident(struct nubus_rsrc *fres)
return -1; return -1;
} }
static int mac_nubus_sonic_probe(struct net_device *dev) static int mac_sonic_nubus_probe_board(struct nubus_board *board, int id,
struct net_device *dev)
{ {
static int slots;
struct nubus_rsrc *ndev = NULL;
struct sonic_local* lp = netdev_priv(dev); struct sonic_local* lp = netdev_priv(dev);
unsigned long base_addr, prom_addr; unsigned long base_addr, prom_addr;
u16 sonic_dcr; u16 sonic_dcr;
int id = -1;
int reg_offset, dma_bitmode; int reg_offset, dma_bitmode;
/* Find the first SONIC that hasn't been initialized already */
for_each_func_rsrc(ndev) {
if (ndev->category != NUBUS_CAT_NETWORK ||
ndev->type != NUBUS_TYPE_ETHERNET)
continue;
/* 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) { switch (id) {
case MACSONIC_DUODOCK: case MACSONIC_DUODOCK:
base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS; base_addr = board->slot_addr + DUODOCK_SONIC_REGISTERS;
prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE; prom_addr = board->slot_addr + DUODOCK_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 | sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 |
SONIC_DCR_TFT0; SONIC_DCR_TFT0;
reg_offset = 2; reg_offset = 2;
dma_bitmode = SONIC_BITMODE32; dma_bitmode = SONIC_BITMODE32;
break; break;
case MACSONIC_APPLE: case MACSONIC_APPLE:
base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS; base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE; prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0; sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
reg_offset = 0; reg_offset = 0;
dma_bitmode = SONIC_BITMODE32; dma_bitmode = SONIC_BITMODE32;
break; break;
case MACSONIC_APPLE16: case MACSONIC_APPLE16:
base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS; base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE; prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
SONIC_DCR_PO1 | SONIC_DCR_BMS; SONIC_DCR_PO1 | SONIC_DCR_BMS;
reg_offset = 0; reg_offset = 0;
dma_bitmode = SONIC_BITMODE16; dma_bitmode = SONIC_BITMODE16;
break; break;
case MACSONIC_DAYNALINK: case MACSONIC_DAYNALINK:
base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS; base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE; prom_addr = board->slot_addr + DAYNALINK_PROM_BASE;
sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
SONIC_DCR_PO1 | SONIC_DCR_BMS; SONIC_DCR_PO1 | SONIC_DCR_BMS;
reg_offset = 0; reg_offset = 0;
dma_bitmode = SONIC_BITMODE16; dma_bitmode = SONIC_BITMODE16;
break; break;
case MACSONIC_DAYNA: case MACSONIC_DAYNA:
base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS; base_addr = board->slot_addr + DAYNA_SONIC_REGISTERS;
prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR; prom_addr = board->slot_addr + DAYNA_SONIC_MAC_ADDR;
sonic_dcr = SONIC_DCR_BMS | sonic_dcr = SONIC_DCR_BMS |
SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1; SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
reg_offset = 0; reg_offset = 0;
...@@ -528,21 +483,16 @@ static int mac_nubus_sonic_probe(struct net_device *dev) ...@@ -528,21 +483,16 @@ static int mac_nubus_sonic_probe(struct net_device *dev)
dev->base_addr = base_addr; dev->base_addr = base_addr;
lp->reg_offset = reg_offset; lp->reg_offset = reg_offset;
lp->dma_bitmode = dma_bitmode; lp->dma_bitmode = dma_bitmode;
dev->irq = SLOT2IRQ(ndev->board->slot); dev->irq = SLOT2IRQ(board->slot);
if (!sonic_version_printed) { dev_info(&board->dev, "%s, revision 0x%04x, %d bit DMA, register offset %d\n",
printk(KERN_INFO "%s", version); board->name, SONIC_READ(SONIC_SR),
sonic_version_printed = 1; lp->dma_bitmode ? 32 : 16, lp->reg_offset);
}
printk(KERN_INFO "%s: %s in slot %X\n",
dev_name(lp->device), ndev->board->name, ndev->board->slot);
printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
dev_name(lp->device), SONIC_READ(SONIC_SR), dma_bitmode?32:16, reg_offset);
#if 0 /* This is sometimes useful to find out how MacOS configured the card. */ /* This is sometimes useful to find out how MacOS configured the card */
printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", dev_name(lp->device), dev_dbg(&board->dev, "%s: DCR=0x%04x, DCR2=0x%04x\n", __func__,
SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff); SONIC_READ(SONIC_DCR) & 0xffff,
#endif SONIC_READ(SONIC_DCR2) & 0xffff);
/* Software reset, then initialize control registers. */ /* Software reset, then initialize control registers. */
SONIC_WRITE(SONIC_CMD, SONIC_CR_RST); SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
...@@ -557,14 +507,17 @@ static int mac_nubus_sonic_probe(struct net_device *dev) ...@@ -557,14 +507,17 @@ static int mac_nubus_sonic_probe(struct net_device *dev)
SONIC_WRITE(SONIC_ISR, 0x7fff); SONIC_WRITE(SONIC_ISR, 0x7fff);
/* Now look for the MAC address. */ /* Now look for the MAC address. */
if (mac_nubus_sonic_ethernet_addr(dev, prom_addr, id) != 0) if (mac_sonic_nubus_ethernet_addr(dev, prom_addr, id) != 0)
return -ENODEV; return -ENODEV;
dev_info(&board->dev, "SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
dev->base_addr, dev->dev_addr, dev->irq);
/* Shared init code */ /* Shared init code */
return macsonic_init(dev); return macsonic_init(dev);
} }
static int mac_sonic_probe(struct platform_device *pdev) static int mac_sonic_platform_probe(struct platform_device *pdev)
{ {
struct net_device *dev; struct net_device *dev;
struct sonic_local *lp; struct sonic_local *lp;
...@@ -579,22 +532,16 @@ static int mac_sonic_probe(struct platform_device *pdev) ...@@ -579,22 +532,16 @@ static int mac_sonic_probe(struct platform_device *pdev)
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
/* This will catch fatal stuff like -ENOMEM as well as success */
err = mac_onboard_sonic_probe(dev); err = mac_onboard_sonic_probe(dev);
if (err == 0)
goto found;
if (err != -ENODEV)
goto out;
err = mac_nubus_sonic_probe(dev);
if (err) if (err)
goto out; goto out;
found:
sonic_msg_init(dev);
err = register_netdev(dev); err = register_netdev(dev);
if (err) if (err)
goto out; goto out;
printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
return 0; return 0;
out: out:
...@@ -604,13 +551,11 @@ static int mac_sonic_probe(struct platform_device *pdev) ...@@ -604,13 +551,11 @@ static int mac_sonic_probe(struct platform_device *pdev)
} }
MODULE_DESCRIPTION("Macintosh SONIC ethernet driver"); MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
module_param(sonic_debug, int, 0);
MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
MODULE_ALIAS("platform:macsonic"); MODULE_ALIAS("platform:macsonic");
#include "sonic.c" #include "sonic.c"
static int mac_sonic_device_remove(struct platform_device *pdev) static int mac_sonic_platform_remove(struct platform_device *pdev)
{ {
struct net_device *dev = platform_get_drvdata(pdev); struct net_device *dev = platform_get_drvdata(pdev);
struct sonic_local* lp = netdev_priv(dev); struct sonic_local* lp = netdev_priv(dev);
...@@ -623,12 +568,105 @@ static int mac_sonic_device_remove(struct platform_device *pdev) ...@@ -623,12 +568,105 @@ static int mac_sonic_device_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct platform_driver mac_sonic_driver = { static struct platform_driver mac_sonic_platform_driver = {
.probe = mac_sonic_probe, .probe = mac_sonic_platform_probe,
.remove = mac_sonic_device_remove, .remove = mac_sonic_platform_remove,
.driver = { .driver = {
.name = mac_sonic_string, .name = "macsonic",
},
};
static int mac_sonic_nubus_probe(struct nubus_board *board)
{
struct net_device *ndev;
struct sonic_local *lp;
struct nubus_rsrc *fres;
int id = -1;
int err;
/* The platform driver will handle a PDS or Comm Slot card (even if
* it has a pseudoslot declaration ROM).
*/
if (macintosh_config->expansion_type == MAC_EXP_PDS_COMM)
return -ENODEV;
for_each_board_func_rsrc(board, fres) {
if (fres->category != NUBUS_CAT_NETWORK ||
fres->type != NUBUS_TYPE_ETHERNET)
continue;
id = macsonic_ident(fres);
if (id != -1)
break;
}
if (!fres)
return -ENODEV;
ndev = alloc_etherdev(sizeof(struct sonic_local));
if (!ndev)
return -ENOMEM;
lp = netdev_priv(ndev);
lp->device = &board->dev;
SET_NETDEV_DEV(ndev, &board->dev);
err = mac_sonic_nubus_probe_board(board, id, ndev);
if (err)
goto out;
sonic_msg_init(ndev);
err = register_netdev(ndev);
if (err)
goto out;
nubus_set_drvdata(board, ndev);
return 0;
out:
free_netdev(ndev);
return err;
}
static int mac_sonic_nubus_remove(struct nubus_board *board)
{
struct net_device *ndev = nubus_get_drvdata(board);
struct sonic_local *lp = netdev_priv(ndev);
unregister_netdev(ndev);
dma_free_coherent(lp->device,
SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
lp->descriptors, lp->descriptors_laddr);
free_netdev(ndev);
return 0;
}
static struct nubus_driver mac_sonic_nubus_driver = {
.probe = mac_sonic_nubus_probe,
.remove = mac_sonic_nubus_remove,
.driver = {
.name = "macsonic-nubus",
.owner = THIS_MODULE,
}, },
}; };
module_platform_driver(mac_sonic_driver); static int perr, nerr;
static int __init mac_sonic_init(void)
{
perr = platform_driver_register(&mac_sonic_platform_driver);
nerr = nubus_driver_register(&mac_sonic_nubus_driver);
return 0;
}
module_init(mac_sonic_init);
static void __exit mac_sonic_exit(void)
{
if (!perr)
platform_driver_unregister(&mac_sonic_platform_driver);
if (!nerr)
nubus_driver_unregister(&mac_sonic_nubus_driver);
}
module_exit(mac_sonic_exit);
...@@ -33,7 +33,21 @@ ...@@ -33,7 +33,21 @@
* the NetBSD file "sys/arch/mac68k/dev/if_sn.c". * the NetBSD file "sys/arch/mac68k/dev/if_sn.c".
*/ */
static unsigned int version_printed;
static int sonic_debug = -1;
module_param(sonic_debug, int, 0);
MODULE_PARM_DESC(sonic_debug, "debug message level");
static void sonic_msg_init(struct net_device *dev)
{
struct sonic_local *lp = netdev_priv(dev);
lp->msg_enable = netif_msg_init(sonic_debug, 0);
if (version_printed++ == 0)
netif_dbg(lp, drv, dev, "%s", version);
}
/* /*
* Open/initialize the SONIC controller. * Open/initialize the SONIC controller.
...@@ -47,8 +61,7 @@ static int sonic_open(struct net_device *dev) ...@@ -47,8 +61,7 @@ static int sonic_open(struct net_device *dev)
struct sonic_local *lp = netdev_priv(dev); struct sonic_local *lp = netdev_priv(dev);
int i; int i;
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: initializing sonic driver\n", __func__);
printk("sonic_open: initializing sonic driver.\n");
for (i = 0; i < SONIC_NUM_RRS; i++) { for (i = 0; i < SONIC_NUM_RRS; i++) {
struct sk_buff *skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); struct sk_buff *skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2);
...@@ -95,8 +108,7 @@ static int sonic_open(struct net_device *dev) ...@@ -95,8 +108,7 @@ static int sonic_open(struct net_device *dev)
netif_start_queue(dev); netif_start_queue(dev);
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: Initialization done\n", __func__);
printk("sonic_open: Initialization done.\n");
return 0; return 0;
} }
...@@ -110,8 +122,7 @@ static int sonic_close(struct net_device *dev) ...@@ -110,8 +122,7 @@ static int sonic_close(struct net_device *dev)
struct sonic_local *lp = netdev_priv(dev); struct sonic_local *lp = netdev_priv(dev);
int i; int i;
if (sonic_debug > 2) netif_dbg(lp, ifdown, dev, "%s\n", __func__);
printk("sonic_close\n");
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -205,8 +216,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -205,8 +216,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
int length; int length;
int entry = lp->next_tx; int entry = lp->next_tx;
if (sonic_debug > 2) netif_dbg(lp, tx_queued, dev, "%s: skb=%p\n", __func__, skb);
printk("sonic_send_packet: skb=%p, dev=%p\n", skb, dev);
length = skb->len; length = skb->len;
if (length < ETH_ZLEN) { if (length < ETH_ZLEN) {
...@@ -252,14 +262,12 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -252,14 +262,12 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
lp->next_tx = (entry + 1) & SONIC_TDS_MASK; lp->next_tx = (entry + 1) & SONIC_TDS_MASK;
if (lp->tx_skb[lp->next_tx] != NULL) { if (lp->tx_skb[lp->next_tx] != NULL) {
/* The ring is full, the ISR has yet to process the next TD. */ /* The ring is full, the ISR has yet to process the next TD. */
if (sonic_debug > 3) netif_dbg(lp, tx_queued, dev, "%s: stopping queue\n", __func__);
printk("%s: stopping queue\n", dev->name);
netif_stop_queue(dev); netif_stop_queue(dev);
/* after this packet, wait for ISR to free up some TDAs */ /* after this packet, wait for ISR to free up some TDAs */
} else netif_start_queue(dev); } else netif_start_queue(dev);
if (sonic_debug > 2) netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
printk("sonic_send_packet: issuing Tx command\n");
SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP); SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
...@@ -281,8 +289,7 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) ...@@ -281,8 +289,7 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id)
do { do {
if (status & SONIC_INT_PKTRX) { if (status & SONIC_INT_PKTRX) {
if (sonic_debug > 2) netif_dbg(lp, intr, dev, "%s: packet rx\n", __func__);
printk("%s: packet rx\n", dev->name);
sonic_rx(dev); /* got packet(s) */ sonic_rx(dev); /* got packet(s) */
SONIC_WRITE(SONIC_ISR, SONIC_INT_PKTRX); /* clear the interrupt */ SONIC_WRITE(SONIC_ISR, SONIC_INT_PKTRX); /* clear the interrupt */
} }
...@@ -299,8 +306,7 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) ...@@ -299,8 +306,7 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id)
* still being allocated by sonic_send_packet (status clear & tx_skb[entry] clear) * still being allocated by sonic_send_packet (status clear & tx_skb[entry] clear)
*/ */
if (sonic_debug > 2) netif_dbg(lp, intr, dev, "%s: tx done\n", __func__);
printk("%s: tx done\n", dev->name);
while (lp->tx_skb[entry] != NULL) { while (lp->tx_skb[entry] != NULL) {
if ((td_status = sonic_tda_get(dev, entry, SONIC_TD_STATUS)) == 0) if ((td_status = sonic_tda_get(dev, entry, SONIC_TD_STATUS)) == 0)
...@@ -346,20 +352,20 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) ...@@ -346,20 +352,20 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id)
* check error conditions * check error conditions
*/ */
if (status & SONIC_INT_RFO) { if (status & SONIC_INT_RFO) {
if (sonic_debug > 1) netif_dbg(lp, rx_err, dev, "%s: rx fifo overrun\n",
printk("%s: rx fifo overrun\n", dev->name); __func__);
lp->stats.rx_fifo_errors++; lp->stats.rx_fifo_errors++;
SONIC_WRITE(SONIC_ISR, SONIC_INT_RFO); /* clear the interrupt */ SONIC_WRITE(SONIC_ISR, SONIC_INT_RFO); /* clear the interrupt */
} }
if (status & SONIC_INT_RDE) { if (status & SONIC_INT_RDE) {
if (sonic_debug > 1) netif_dbg(lp, rx_err, dev, "%s: rx descriptors exhausted\n",
printk("%s: rx descriptors exhausted\n", dev->name); __func__);
lp->stats.rx_dropped++; lp->stats.rx_dropped++;
SONIC_WRITE(SONIC_ISR, SONIC_INT_RDE); /* clear the interrupt */ SONIC_WRITE(SONIC_ISR, SONIC_INT_RDE); /* clear the interrupt */
} }
if (status & SONIC_INT_RBAE) { if (status & SONIC_INT_RBAE) {
if (sonic_debug > 1) netif_dbg(lp, rx_err, dev, "%s: rx buffer area exceeded\n",
printk("%s: rx buffer area exceeded\n", dev->name); __func__);
lp->stats.rx_dropped++; lp->stats.rx_dropped++;
SONIC_WRITE(SONIC_ISR, SONIC_INT_RBAE); /* clear the interrupt */ SONIC_WRITE(SONIC_ISR, SONIC_INT_RBAE); /* clear the interrupt */
} }
...@@ -380,8 +386,9 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) ...@@ -380,8 +386,9 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id)
/* transmit error */ /* transmit error */
if (status & SONIC_INT_TXER) { if (status & SONIC_INT_TXER) {
if ((SONIC_READ(SONIC_TCR) & SONIC_TCR_FU) && (sonic_debug > 2)) if (SONIC_READ(SONIC_TCR) & SONIC_TCR_FU)
printk(KERN_ERR "%s: tx fifo underrun\n", dev->name); netif_dbg(lp, tx_err, dev, "%s: tx fifo underrun\n",
__func__);
SONIC_WRITE(SONIC_ISR, SONIC_INT_TXER); /* clear the interrupt */ SONIC_WRITE(SONIC_ISR, SONIC_INT_TXER); /* clear the interrupt */
} }
...@@ -475,8 +482,8 @@ static void sonic_rx(struct net_device *dev) ...@@ -475,8 +482,8 @@ static void sonic_rx(struct net_device *dev)
if (lp->cur_rwp >= lp->rra_end) lp->cur_rwp = lp->rra_laddr & 0xffff; if (lp->cur_rwp >= lp->rra_end) lp->cur_rwp = lp->rra_laddr & 0xffff;
SONIC_WRITE(SONIC_RWP, lp->cur_rwp); SONIC_WRITE(SONIC_RWP, lp->cur_rwp);
if (SONIC_READ(SONIC_ISR) & SONIC_INT_RBE) { if (SONIC_READ(SONIC_ISR) & SONIC_INT_RBE) {
if (sonic_debug > 2) netif_dbg(lp, rx_err, dev, "%s: rx buffer exhausted\n",
printk("%s: rx buffer exhausted\n", dev->name); __func__);
SONIC_WRITE(SONIC_ISR, SONIC_INT_RBE); /* clear the flag */ SONIC_WRITE(SONIC_ISR, SONIC_INT_RBE); /* clear the flag */
} }
} else } else
...@@ -542,9 +549,8 @@ static void sonic_multicast_list(struct net_device *dev) ...@@ -542,9 +549,8 @@ static void sonic_multicast_list(struct net_device *dev)
(netdev_mc_count(dev) > 15)) { (netdev_mc_count(dev) > 15)) {
rcr |= SONIC_RCR_AMC; rcr |= SONIC_RCR_AMC;
} else { } else {
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: mc_count %d\n", __func__,
printk("sonic_multicast_list: mc_count %d\n", netdev_mc_count(dev));
netdev_mc_count(dev));
sonic_set_cam_enable(dev, 1); /* always enable our own address */ sonic_set_cam_enable(dev, 1); /* always enable our own address */
i = 1; i = 1;
netdev_for_each_mc_addr(ha, dev) { netdev_for_each_mc_addr(ha, dev) {
...@@ -562,8 +568,7 @@ static void sonic_multicast_list(struct net_device *dev) ...@@ -562,8 +568,7 @@ static void sonic_multicast_list(struct net_device *dev)
} }
} }
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: setting RCR=%x\n", __func__, rcr);
printk("sonic_multicast_list: setting RCR=%x\n", rcr);
SONIC_WRITE(SONIC_RCR, rcr); SONIC_WRITE(SONIC_RCR, rcr);
} }
...@@ -596,8 +601,8 @@ static int sonic_init(struct net_device *dev) ...@@ -596,8 +601,8 @@ static int sonic_init(struct net_device *dev)
/* /*
* initialize the receive resource area * initialize the receive resource area
*/ */
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: initialize receive resource area\n",
printk("sonic_init: initialize receive resource area\n"); __func__);
for (i = 0; i < SONIC_NUM_RRS; i++) { for (i = 0; i < SONIC_NUM_RRS; i++) {
u16 bufadr_l = (unsigned long)lp->rx_laddr[i] & 0xffff; u16 bufadr_l = (unsigned long)lp->rx_laddr[i] & 0xffff;
...@@ -622,8 +627,7 @@ static int sonic_init(struct net_device *dev) ...@@ -622,8 +627,7 @@ static int sonic_init(struct net_device *dev)
SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE >> 1) - (lp->dma_bitmode ? 2 : 1)); SONIC_WRITE(SONIC_EOBC, (SONIC_RBSIZE >> 1) - (lp->dma_bitmode ? 2 : 1));
/* load the resource pointers */ /* load the resource pointers */
if (sonic_debug > 3) netif_dbg(lp, ifup, dev, "%s: issuing RRRA command\n", __func__);
printk("sonic_init: issuing RRRA command\n");
SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA); SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA);
i = 0; i = 0;
...@@ -632,16 +636,17 @@ static int sonic_init(struct net_device *dev) ...@@ -632,16 +636,17 @@ static int sonic_init(struct net_device *dev)
break; break;
} }
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: status=%x, i=%d\n", __func__,
printk("sonic_init: status=%x i=%d\n", SONIC_READ(SONIC_CMD), i); SONIC_READ(SONIC_CMD), i);
/* /*
* Initialize the receive descriptors so that they * Initialize the receive descriptors so that they
* become a circular linked list, ie. let the last * become a circular linked list, ie. let the last
* descriptor point to the first again. * descriptor point to the first again.
*/ */
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: initialize receive descriptors\n",
printk("sonic_init: initialize receive descriptors\n"); __func__);
for (i=0; i<SONIC_NUM_RDS; i++) { for (i=0; i<SONIC_NUM_RDS; i++) {
sonic_rda_put(dev, i, SONIC_RD_STATUS, 0); sonic_rda_put(dev, i, SONIC_RD_STATUS, 0);
sonic_rda_put(dev, i, SONIC_RD_PKTLEN, 0); sonic_rda_put(dev, i, SONIC_RD_PKTLEN, 0);
...@@ -664,8 +669,9 @@ static int sonic_init(struct net_device *dev) ...@@ -664,8 +669,9 @@ static int sonic_init(struct net_device *dev)
/* /*
* initialize transmit descriptors * initialize transmit descriptors
*/ */
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: initialize transmit descriptors\n",
printk("sonic_init: initialize transmit descriptors\n"); __func__);
for (i = 0; i < SONIC_NUM_TDS; i++) { for (i = 0; i < SONIC_NUM_TDS; i++) {
sonic_tda_put(dev, i, SONIC_TD_STATUS, 0); sonic_tda_put(dev, i, SONIC_TD_STATUS, 0);
sonic_tda_put(dev, i, SONIC_TD_CONFIG, 0); sonic_tda_put(dev, i, SONIC_TD_CONFIG, 0);
...@@ -712,10 +718,8 @@ static int sonic_init(struct net_device *dev) ...@@ -712,10 +718,8 @@ static int sonic_init(struct net_device *dev)
if (SONIC_READ(SONIC_ISR) & SONIC_INT_LCD) if (SONIC_READ(SONIC_ISR) & SONIC_INT_LCD)
break; break;
} }
if (sonic_debug > 2) { netif_dbg(lp, ifup, dev, "%s: CMD=%x, ISR=%x, i=%d\n", __func__,
printk("sonic_init: CMD=%x, ISR=%x\n, i=%d", SONIC_READ(SONIC_CMD), SONIC_READ(SONIC_ISR), i);
SONIC_READ(SONIC_CMD), SONIC_READ(SONIC_ISR), i);
}
/* /*
* enable receiver, disable loopback * enable receiver, disable loopback
...@@ -731,9 +735,8 @@ static int sonic_init(struct net_device *dev) ...@@ -731,9 +735,8 @@ static int sonic_init(struct net_device *dev)
if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0) if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0)
printk(KERN_ERR "sonic_init: failed, status=%x\n", cmd); printk(KERN_ERR "sonic_init: failed, status=%x\n", cmd);
if (sonic_debug > 2) netif_dbg(lp, ifup, dev, "%s: new status=%x\n", __func__,
printk("sonic_init: new status=%x\n", SONIC_READ(SONIC_CMD));
SONIC_READ(SONIC_CMD));
return 0; return 0;
} }
......
...@@ -319,6 +319,7 @@ struct sonic_local { ...@@ -319,6 +319,7 @@ struct sonic_local {
unsigned int eol_rx; unsigned int eol_rx;
unsigned int eol_tx; /* last unacked transmit packet */ unsigned int eol_tx; /* last unacked transmit packet */
unsigned int next_tx; /* next free TD */ unsigned int next_tx; /* next free TD */
int msg_enable;
struct device *device; /* generic device */ struct device *device; /* generic device */
struct net_device_stats stats; struct net_device_stats stats;
}; };
...@@ -336,6 +337,7 @@ static struct net_device_stats *sonic_get_stats(struct net_device *dev); ...@@ -336,6 +337,7 @@ static struct net_device_stats *sonic_get_stats(struct net_device *dev);
static void sonic_multicast_list(struct net_device *dev); static void sonic_multicast_list(struct net_device *dev);
static int sonic_init(struct net_device *dev); static int sonic_init(struct net_device *dev);
static void sonic_tx_timeout(struct net_device *dev); static void sonic_tx_timeout(struct net_device *dev);
static void sonic_msg_init(struct net_device *dev);
/* Internal inlines for reading/writing DMA buffers. Note that bus /* Internal inlines for reading/writing DMA buffers. Note that bus
size and endianness matter here, whereas they don't for registers, size and endianness matter here, whereas they don't for registers,
......
...@@ -73,14 +73,6 @@ extern void xtboard_get_ether_addr(unsigned char *buf); ...@@ -73,14 +73,6 @@ extern void xtboard_get_ether_addr(unsigned char *buf);
#define SONIC_WRITE(reg,val) \ #define SONIC_WRITE(reg,val) \
*((volatile unsigned int *)dev->base_addr+reg) = val *((volatile unsigned int *)dev->base_addr+reg) = val
/* Use 0 for production, 1 for verification, and >2 for debug */
#ifdef SONIC_DEBUG
static unsigned int sonic_debug = SONIC_DEBUG;
#else
static unsigned int sonic_debug = 1;
#endif
/* /*
* We cannot use station (ethernet) address prefixes to detect the * We cannot use station (ethernet) address prefixes to detect the
* sonic controller since these are board manufacturer depended. * sonic controller since these are board manufacturer depended.
...@@ -130,7 +122,6 @@ static const struct net_device_ops xtsonic_netdev_ops = { ...@@ -130,7 +122,6 @@ static const struct net_device_ops xtsonic_netdev_ops = {
static int __init sonic_probe1(struct net_device *dev) static int __init sonic_probe1(struct net_device *dev)
{ {
static unsigned version_printed = 0;
unsigned int silicon_revision; unsigned int silicon_revision;
struct sonic_local *lp = netdev_priv(dev); struct sonic_local *lp = netdev_priv(dev);
unsigned int base_addr = dev->base_addr; unsigned int base_addr = dev->base_addr;
...@@ -146,23 +137,17 @@ static int __init sonic_probe1(struct net_device *dev) ...@@ -146,23 +137,17 @@ static int __init sonic_probe1(struct net_device *dev)
* the expected location. * the expected location.
*/ */
silicon_revision = SONIC_READ(SONIC_SR); silicon_revision = SONIC_READ(SONIC_SR);
if (sonic_debug > 1)
printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
i = 0; i = 0;
while ((known_revisions[i] != 0xffff) && while ((known_revisions[i] != 0xffff) &&
(known_revisions[i] != silicon_revision)) (known_revisions[i] != silicon_revision))
i++; i++;
if (known_revisions[i] == 0xffff) { if (known_revisions[i] == 0xffff) {
printk("SONIC ethernet controller not found (0x%4x)\n", pr_info("SONIC ethernet controller not found (0x%4x)\n",
silicon_revision); silicon_revision);
return -ENODEV; return -ENODEV;
} }
if (sonic_debug && version_printed++ == 0)
printk(version);
/* /*
* Put the sonic into software reset, then retrieve ethernet address. * Put the sonic into software reset, then retrieve ethernet address.
* Note: we are assuming that the boot-loader has initialized the cam. * Note: we are assuming that the boot-loader has initialized the cam.
...@@ -273,12 +258,15 @@ int xtsonic_probe(struct platform_device *pdev) ...@@ -273,12 +258,15 @@ int xtsonic_probe(struct platform_device *pdev)
if ((err = sonic_probe1(dev))) if ((err = sonic_probe1(dev)))
goto out; goto out;
pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
dev->base_addr, dev->dev_addr, dev->irq);
sonic_msg_init(dev);
if ((err = register_netdev(dev))) if ((err = register_netdev(dev)))
goto out1; goto out1;
printk("%s: SONIC ethernet @%08lx, MAC %pM, IRQ %d\n", dev->name,
dev->base_addr, dev->dev_addr, dev->irq);
return 0; return 0;
out1: out1:
...@@ -290,8 +278,6 @@ int xtsonic_probe(struct platform_device *pdev) ...@@ -290,8 +278,6 @@ int xtsonic_probe(struct platform_device *pdev)
} }
MODULE_DESCRIPTION("Xtensa XT2000 SONIC ethernet driver"); MODULE_DESCRIPTION("Xtensa XT2000 SONIC ethernet driver");
module_param(sonic_debug, int, 0);
MODULE_PARM_DESC(sonic_debug, "xtsonic debug level (1-4)");
#include "sonic.c" #include "sonic.c"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册