From f877958879d413c37bfbeb7517614f3625cdea38 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Tue, 1 May 2007 22:32:53 +0200 Subject: NuBus header update Sync the nubus defines with the latest code in the mac68k repo. Some of these are needed for DP8390 driver update in the next patch. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/net/macsonic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/macsonic.c') diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c index 8ca57a0..a3d24a3 100644 --- a/drivers/net/macsonic.c +++ b/drivers/net/macsonic.c @@ -402,7 +402,7 @@ int __init macsonic_ident(struct nubus_dev* ndev) ndev->dr_sw == NUBUS_DRSW_DAYNA) return MACSONIC_DAYNA; - if (ndev->dr_hw == NUBUS_DRHW_SONIC_LC && + if (ndev->dr_hw == NUBUS_DRHW_APPLE_SONIC_LC && ndev->dr_sw == 0) { /* huh? */ return MACSONIC_APPLE16; } -- cgit v1.1 From d74472f0b2553e59eafb7feee0ff9558136a17e0 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Tue, 1 May 2007 22:33:02 +0200 Subject: SONIC: small fix and cleanup Fix a potential problem in the timeout handling: don't free the DMA buffers before resetting the chip. Also a trivial cleanup. Bring macsonic and jazzsonic into sync. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven Signed-off-by: Linus Torvalds --- drivers/net/macsonic.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/net/macsonic.c') diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c index a3d24a3..c78a7e2 100644 --- a/drivers/net/macsonic.c +++ b/drivers/net/macsonic.c @@ -522,7 +522,7 @@ int __init mac_nubus_sonic_probe(struct net_device* dev) return macsonic_init(dev); } -static int __init mac_sonic_probe(struct platform_device *device) +static int __init mac_sonic_probe(struct platform_device *pdev) { struct net_device *dev; struct sonic_local *lp; @@ -534,8 +534,8 @@ static int __init mac_sonic_probe(struct platform_device *device) return -ENOMEM; lp = netdev_priv(dev); - lp->device = &device->dev; - SET_NETDEV_DEV(dev, &device->dev); + lp->device = &pdev->dev; + SET_NETDEV_DEV(dev, &pdev->dev); SET_MODULE_OWNER(dev); /* This will catch fatal stuff like -ENOMEM as well as success */ @@ -576,15 +576,15 @@ MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); #include "sonic.c" -static int __devexit mac_sonic_device_remove (struct platform_device *device) +static int __devexit mac_sonic_device_remove (struct platform_device *pdev) { - struct net_device *dev = platform_get_drvdata(device); + struct net_device *dev = platform_get_drvdata(pdev); struct sonic_local* lp = netdev_priv(dev); - unregister_netdev (dev); + unregister_netdev(dev); dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), lp->descriptors, lp->descriptors_laddr); - free_netdev (dev); + free_netdev(dev); return 0; } @@ -607,9 +607,8 @@ static int __init mac_sonic_init_module(void) } mac_sonic_device = platform_device_alloc(mac_sonic_string, 0); - if (!mac_sonic_device) { + if (!mac_sonic_device) goto out_unregister; - } if (platform_device_add(mac_sonic_device)) { platform_device_put(mac_sonic_device); -- cgit v1.1 From f4d86754f956ab5ea73aa91759a0d89a2f0e3f2a Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 2 May 2007 12:55:56 +1000 Subject: SONIC interrupt handling Install the built-in macsonic interrupt handler on both IRQs when using via_alt_mapping. Otherwise the rare interrupt that still comes from the nubus slot will wedge the nubus. $ cat /proc/interrupts auto 2: 89176 via2 auto 3: 744367 sonic auto 4: 0 scc auto 6: 318363 via1 auto 7: 0 NMI mac 9: 119413 framebuffer vbl mac 10: 1971 ADB mac 14: 198517 timer mac 17: 89104 nubus mac 19: 72 Mac ESP SCSI mac 56: 629 sonic mac 62: 1142593 ide0 Version 1 of this patch had a bug where a nubus sonic card would register two interrupt handlers. Only a built-in sonic needs both. Versions 2 and 3 needed some cleanups, as Raylynn Knight and Christoph Hellwig pointed out (thanks). Signed-off-by: Finn Thain Signed-off-by: Linus Torvalds --- drivers/net/macsonic.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'drivers/net/macsonic.c') diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c index c78a7e2..e9ecdbf 100644 --- a/drivers/net/macsonic.c +++ b/drivers/net/macsonic.c @@ -130,6 +130,46 @@ static inline void bit_reverse_addr(unsigned char addr[6]) addr[i] = bitrev8(addr[i]); } +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) +{ + if (request_irq(dev->irq, &sonic_interrupt, IRQ_FLG_FAST, "sonic", dev)) { + printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq); + return -EAGAIN; + } + /* 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. + */ + if (dev->irq == IRQ_AUTO_3) + if (request_irq(IRQ_NUBUS_9, &macsonic_interrupt, IRQ_FLG_FAST, "sonic", dev)) { + printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, IRQ_NUBUS_9); + free_irq(dev->irq, dev); + return -EAGAIN; + } + return sonic_open(dev); +} + +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; +} + int __init macsonic_init(struct net_device* dev) { struct sonic_local* lp = netdev_priv(dev); @@ -160,8 +200,8 @@ int __init macsonic_init(struct net_device* dev) lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS * SONIC_BUS_SCALE(lp->dma_bitmode)); - dev->open = sonic_open; - dev->stop = sonic_close; + dev->open = macsonic_open; + dev->stop = macsonic_close; dev->hard_start_xmit = sonic_send_packet; dev->get_stats = sonic_get_stats; dev->set_multicast_list = &sonic_multicast_list; @@ -572,8 +612,6 @@ MODULE_DESCRIPTION("Macintosh SONIC ethernet driver"); module_param(sonic_debug, int, 0); MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); -#define SONIC_IRQ_FLAG IRQ_FLG_FAST - #include "sonic.c" static int __devexit mac_sonic_device_remove (struct platform_device *pdev) -- cgit v1.1