From 61dbcecef568450de954115180881bf2f68511bc Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 20 Nov 2007 14:50:46 +1100 Subject: ibm_newemac: Fix possible lockup on close It's a bad idea to call flush_scheduled_work from within a netdev->stop because the linkwatch will occasionally take the rtnl lock from a workqueue context, and thus that can deadlock. This reworks things a bit in that area to avoid the problem. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 31 ++++++++++++++++++++----------- drivers/net/ibm_newemac/core.h | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 0de3aa2a2e4..eb0718b441b 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -642,9 +642,11 @@ static void emac_reset_work(struct work_struct *work) DBG(dev, "reset_work" NL); mutex_lock(&dev->link_lock); - emac_netif_stop(dev); - emac_full_tx_reset(dev); - emac_netif_start(dev); + if (dev->opened) { + emac_netif_stop(dev); + emac_full_tx_reset(dev); + emac_netif_start(dev); + } mutex_unlock(&dev->link_lock); } @@ -1063,10 +1065,9 @@ static int emac_open(struct net_device *ndev) dev->rx_sg_skb = NULL; mutex_lock(&dev->link_lock); + dev->opened = 1; - /* XXX Start PHY polling now. Shouldn't wr do like sungem instead and - * always poll the PHY even when the iface is down ? That would allow - * things like laptop-net to work. --BenH + /* Start PHY polling now. */ if (dev->phy.address >= 0) { int link_poll_interval; @@ -1145,9 +1146,11 @@ static void emac_link_timer(struct work_struct *work) int link_poll_interval; mutex_lock(&dev->link_lock); - DBG2(dev, "link timer" NL); + if (!dev->opened) + goto bail; + if (dev->phy.def->ops->poll_link(&dev->phy)) { if (!netif_carrier_ok(dev->ndev)) { /* Get new link parameters */ @@ -1170,13 +1173,14 @@ static void emac_link_timer(struct work_struct *work) link_poll_interval = PHY_POLL_LINK_OFF; } schedule_delayed_work(&dev->link_work, link_poll_interval); - + bail: mutex_unlock(&dev->link_lock); } static void emac_force_link_update(struct emac_instance *dev) { netif_carrier_off(dev->ndev); + smp_rmb(); if (dev->link_polling) { cancel_rearming_delayed_work(&dev->link_work); if (dev->link_polling) @@ -1191,11 +1195,14 @@ static int emac_close(struct net_device *ndev) DBG(dev, "close" NL); - if (dev->phy.address >= 0) + if (dev->phy.address >= 0) { + dev->link_polling = 0; cancel_rearming_delayed_work(&dev->link_work); - + } + mutex_lock(&dev->link_lock); emac_netif_stop(dev); - flush_scheduled_work(); + dev->opened = 0; + mutex_unlock(&dev->link_lock); emac_rx_disable(dev); emac_tx_disable(dev); @@ -2756,6 +2763,8 @@ static int __devexit emac_remove(struct of_device *ofdev) unregister_netdev(dev->ndev); + flush_scheduled_work(); + if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) tah_detach(dev->tah_dev, dev->tah_port); if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h index 4011803117c..a010b2463fd 100644 --- a/drivers/net/ibm_newemac/core.h +++ b/drivers/net/ibm_newemac/core.h @@ -258,6 +258,7 @@ struct emac_instance { int stop_timeout; /* in us */ int no_mcast; int mcast_pending; + int opened; struct work_struct reset_work; spinlock_t lock; }; -- cgit v1.2.3 From f1f304f2e8fbc6ca80d5ef90132bd0772048f0ef Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 5 Dec 2007 11:14:25 +1100 Subject: ibm_newemac: Add BCM5248 and Marvell 88E1111 PHY support This patch adds BCM5248 and Marvell 88E1111 PHY support to NEW EMAC driver. These PHY chips are used on PowerPC 440EPx boards. The PHY code is based on the previous work by Stefan Roese Signed-off-by: Stefan Roese Signed-off-by: Valentine Barshak Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/phy.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/phy.c b/drivers/net/ibm_newemac/phy.c index aa1f0ddf1e3..a5e89c55abd 100644 --- a/drivers/net/ibm_newemac/phy.c +++ b/drivers/net/ibm_newemac/phy.c @@ -306,8 +306,47 @@ static struct mii_phy_def cis8201_phy_def = { .ops = &cis8201_phy_ops }; +static struct mii_phy_def bcm5248_phy_def = { + + .phy_id = 0x0143bc00, + .phy_id_mask = 0x0ffffff0, + .name = "BCM5248 10/100 SMII Ethernet", + .ops = &generic_phy_ops +}; + +static int m88e1111_init(struct mii_phy *phy) +{ + pr_debug("%s: Marvell 88E1111 Ethernet\n", __FUNCTION__); + phy_write(phy, 0x14, 0x0ce3); + phy_write(phy, 0x18, 0x4101); + phy_write(phy, 0x09, 0x0e00); + phy_write(phy, 0x04, 0x01e1); + phy_write(phy, 0x00, 0x9140); + phy_write(phy, 0x00, 0x1140); + + return 0; +} + +static struct mii_phy_ops m88e1111_phy_ops = { + .init = m88e1111_init, + .setup_aneg = genmii_setup_aneg, + .setup_forced = genmii_setup_forced, + .poll_link = genmii_poll_link, + .read_link = genmii_read_link +}; + +static struct mii_phy_def m88e1111_phy_def = { + + .phy_id = 0x01410CC0, + .phy_id_mask = 0x0ffffff0, + .name = "Marvell 88E1111 Ethernet", + .ops = &m88e1111_phy_ops, +}; + static struct mii_phy_def *mii_phy_table[] = { &cis8201_phy_def, + &bcm5248_phy_def, + &m88e1111_phy_def, &genmii_phy_def, NULL }; -- cgit v1.2.3 From 8df4538e21f7313a29fa6c5af78c08a135d44738 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 5 Dec 2007 11:14:26 +1100 Subject: ibm_newemac: Add ET1011c PHY support This adds support for the Agere ET1011c PHY as found on the AMCC Taishan board. Signed-off-by: Stefan Roese Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/phy.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/phy.c b/drivers/net/ibm_newemac/phy.c index a5e89c55abd..9308fad76d5 100644 --- a/drivers/net/ibm_newemac/phy.c +++ b/drivers/net/ibm_newemac/phy.c @@ -327,6 +327,42 @@ static int m88e1111_init(struct mii_phy *phy) return 0; } +static int et1011c_init(struct mii_phy *phy) +{ + u16 reg_short; + + reg_short = (u16)(phy_read(phy, 0x16)); + reg_short &= ~(0x7); + reg_short |= 0x6; /* RGMII Trace Delay*/ + phy_write(phy, 0x16, reg_short); + + reg_short = (u16)(phy_read(phy, 0x17)); + reg_short &= ~(0x40); + phy_write(phy, 0x17, reg_short); + + phy_write(phy, 0x1c, 0x74f0); + return 0; +} + +static struct mii_phy_ops et1011c_phy_ops = { + .init = et1011c_init, + .setup_aneg = genmii_setup_aneg, + .setup_forced = genmii_setup_forced, + .poll_link = genmii_poll_link, + .read_link = genmii_read_link +}; + +static struct mii_phy_def et1011c_phy_def = { + .phy_id = 0x0282f000, + .phy_id_mask = 0x0fffff00, + .name = "ET1011C Gigabit Ethernet", + .ops = &et1011c_phy_ops +}; + + + + + static struct mii_phy_ops m88e1111_phy_ops = { .init = m88e1111_init, .setup_aneg = genmii_setup_aneg, @@ -344,6 +380,7 @@ static struct mii_phy_def m88e1111_phy_def = { }; static struct mii_phy_def *mii_phy_table[] = { + &et1011c_phy_def, &cis8201_phy_def, &bcm5248_phy_def, &m88e1111_phy_def, -- cgit v1.2.3 From 968530643a0685caced9dfd6f72f20d5e7bc8fbb Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 5 Dec 2007 11:14:27 +1100 Subject: ibm_newemac: Fix ZMII refcounting bug When using ZMII for MDIO only (such as 440GX with RGMII for data and ZMII for MDIO), the ZMII code would fail to properly refcount, thus triggering a BUG_ON(). Signed-off-by: Benjamin Herrenschmidt Acked-by: Stefan Roese Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/zmii.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/zmii.c b/drivers/net/ibm_newemac/zmii.c index 2219ec2740e..0f8cfbc0c61 100644 --- a/drivers/net/ibm_newemac/zmii.c +++ b/drivers/net/ibm_newemac/zmii.c @@ -83,12 +83,14 @@ int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode) ZMII_DBG(dev, "init(%d, %d)" NL, input, *mode); - if (!zmii_valid_mode(*mode)) + if (!zmii_valid_mode(*mode)) { /* Probably an EMAC connected to RGMII, * but it still may need ZMII for MDIO so * we don't fail here. */ + dev->users++; return 0; + } mutex_lock(&dev->lock); -- cgit v1.2.3 From 911b237d7d327db5371a762f4d8d8cd9ea763662 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 5 Dec 2007 11:14:27 +1100 Subject: ibm_newemac: Workaround reset timeout when no link With some PHYs, when the link goes away, the EMAC reset fails due to the loss of the RX clock I believe. The old EMAC driver worked around that using some internal chip-specific clock force bits that are different on various 44x implementations. This is an attempt at doing it differently, by avoiding the reset when there is no link, but forcing loopback mode instead. It seems to work on my Taishan 440GX based board so far. Signed-off-by: Benjamin Herrenschmidt Acked-by: Stefan Roese Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index eb0718b441b..e0eae09febf 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -464,26 +464,34 @@ static int emac_configure(struct emac_instance *dev) { struct emac_regs __iomem *p = dev->emacp; struct net_device *ndev = dev->ndev; - int tx_size, rx_size; + int tx_size, rx_size, link = netif_carrier_ok(dev->ndev); u32 r, mr1 = 0; DBG(dev, "configure" NL); - if (emac_reset(dev) < 0) + if (!link) { + out_be32(&p->mr1, in_be32(&p->mr1) + | EMAC_MR1_FDE | EMAC_MR1_ILE); + udelay(100); + } else if (emac_reset(dev) < 0) return -ETIMEDOUT; if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) tah_reset(dev->tah_dev); - DBG(dev, " duplex = %d, pause = %d, asym_pause = %d\n", - dev->phy.duplex, dev->phy.pause, dev->phy.asym_pause); + DBG(dev, " link = %d duplex = %d, pause = %d, asym_pause = %d\n", + link, dev->phy.duplex, dev->phy.pause, dev->phy.asym_pause); /* Default fifo sizes */ tx_size = dev->tx_fifo_size; rx_size = dev->rx_fifo_size; + /* No link, force loopback */ + if (!link) + mr1 = EMAC_MR1_FDE | EMAC_MR1_ILE; + /* Check for full duplex */ - if (dev->phy.duplex == DUPLEX_FULL) + else if (dev->phy.duplex == DUPLEX_FULL) mr1 |= EMAC_MR1_FDE | EMAC_MR1_MWSW_001; /* Adjust fifo sizes, mr1 and timeouts based on link speed */ @@ -1165,9 +1173,9 @@ static void emac_link_timer(struct work_struct *work) link_poll_interval = PHY_POLL_LINK_ON; } else { if (netif_carrier_ok(dev->ndev)) { - emac_reinitialize(dev); netif_carrier_off(dev->ndev); netif_tx_disable(dev->ndev); + emac_reinitialize(dev); emac_print_link_status(dev); } link_poll_interval = PHY_POLL_LINK_OFF; -- cgit v1.2.3 From 1f57877a39105ec4d99d63d02058f6db6ca6abe0 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 5 Dec 2007 11:14:28 +1100 Subject: ibm_newemac: Cleanup/Fix RGMII MDIO support detection More than just "AXON" version of EMAC RGMII supports MDIO, so replace the current test with a generic property in the device-tree that indicates such support. Signed-off-by: Benjamin Herrenschmidt Acked-by: Stefan Roese Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/rgmii.c | 20 +++++++++++--------- drivers/net/ibm_newemac/rgmii.h | 5 +++-- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c index de416951a43..32872697858 100644 --- a/drivers/net/ibm_newemac/rgmii.c +++ b/drivers/net/ibm_newemac/rgmii.c @@ -140,7 +140,7 @@ void rgmii_get_mdio(struct of_device *ofdev, int input) RGMII_DBG2(dev, "get_mdio(%d)" NL, input); - if (dev->type != RGMII_AXON) + if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) return; mutex_lock(&dev->lock); @@ -161,7 +161,7 @@ void rgmii_put_mdio(struct of_device *ofdev, int input) RGMII_DBG2(dev, "put_mdio(%d)" NL, input); - if (dev->type != RGMII_AXON) + if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) return; fer = in_be32(&p->fer); @@ -250,11 +250,13 @@ static int __devinit rgmii_probe(struct of_device *ofdev, goto err_free; } - /* Check for RGMII type */ + /* Check for RGMII flags */ + if (of_get_property(ofdev->node, "has-mdio", NULL)) + dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; + + /* CAB lacks the right properties, fix this up */ if (of_device_is_compatible(ofdev->node, "ibm,rgmii-axon")) - dev->type = RGMII_AXON; - else - dev->type = RGMII_STANDARD; + dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); @@ -263,9 +265,9 @@ static int __devinit rgmii_probe(struct of_device *ofdev, out_be32(&dev->base->fer, 0); printk(KERN_INFO - "RGMII %s %s initialized\n", - dev->type == RGMII_STANDARD ? "standard" : "axon", - ofdev->node->full_name); + "RGMII %s initialized with%s MDIO support\n", + ofdev->node->full_name, + (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); wmb(); dev_set_drvdata(&ofdev->dev, dev); diff --git a/drivers/net/ibm_newemac/rgmii.h b/drivers/net/ibm_newemac/rgmii.h index 57806833121..44a0f201064 100644 --- a/drivers/net/ibm_newemac/rgmii.h +++ b/drivers/net/ibm_newemac/rgmii.h @@ -35,8 +35,9 @@ struct rgmii_regs { struct rgmii_instance { struct rgmii_regs __iomem *base; - /* Type of RGMII bridge */ - int type; + /* RGMII bridge flags */ + int flags; +#define EMAC_RGMII_FLAG_HAS_MDIO 0x00000001 /* Only one EMAC whacks us at a time */ struct mutex lock; -- cgit v1.2.3 From bff713b562d495658093f1716a80c6ad76920e8b Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 5 Dec 2007 11:14:29 +1100 Subject: ibm_newemac: Cleanup/fix support for STACR register variants There are a few variants of the STACR register that affect more than just the "AXON" version of EMAC. Replace the current test of various chip models with tests for generic properties in the device-tree. Signed-off-by: Benjamin Herrenschmidt Acked-by: Stefan Roese Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 23 +++++++++++++---------- drivers/net/ibm_newemac/core.h | 6 +++--- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index e0eae09febf..ac9fd46509c 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -711,7 +711,7 @@ static int __emac_mdio_read(struct emac_instance *dev, u8 id, u8 reg) r = EMAC_STACR_BASE(dev->opb_bus_freq); if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT)) r |= EMAC_STACR_OC; - if (emac_has_feature(dev, EMAC_FTR_HAS_AXON_STACR)) + if (emac_has_feature(dev, EMAC_FTR_HAS_NEW_STACR)) r |= EMACX_STACR_STAC_READ; else r |= EMAC_STACR_STAC_READ; @@ -783,7 +783,7 @@ static void __emac_mdio_write(struct emac_instance *dev, u8 id, u8 reg, r = EMAC_STACR_BASE(dev->opb_bus_freq); if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT)) r |= EMAC_STACR_OC; - if (emac_has_feature(dev, EMAC_FTR_HAS_AXON_STACR)) + if (emac_has_feature(dev, EMAC_FTR_HAS_NEW_STACR)) r |= EMACX_STACR_STAC_WRITE; else r |= EMAC_STACR_STAC_WRITE; @@ -2480,16 +2480,19 @@ static int __devinit emac_init_config(struct emac_instance *dev) /* Check EMAC version */ if (of_device_is_compatible(np, "ibm,emac4")) dev->features |= EMAC_FTR_EMAC4; - if (of_device_is_compatible(np, "ibm,emac-axon") - || of_device_is_compatible(np, "ibm,emac-440epx")) - dev->features |= EMAC_FTR_HAS_AXON_STACR - | EMAC_FTR_STACR_OC_INVERT; - if (of_device_is_compatible(np, "ibm,emac-440spe")) + + /* Fixup some feature bits based on the device tree */ + if (of_get_property(np, "has-inverted-stacr-oc", NULL)) dev->features |= EMAC_FTR_STACR_OC_INVERT; + if (of_get_property(np, "has-new-stacr-staopc", NULL)) + dev->features |= EMAC_FTR_HAS_NEW_STACR; - /* Fixup some feature bits based on the device tree and verify - * we have support for them compiled in - */ + /* CAB lacks the appropriate properties */ + if (of_device_is_compatible(np, "ibm,emac-axon")) + dev->features |= EMAC_FTR_HAS_NEW_STACR | + EMAC_FTR_STACR_OC_INVERT; + + /* Enable TAH/ZMII/RGMII features as found */ if (dev->tah_ph != 0) { #ifdef CONFIG_IBM_NEW_EMAC_TAH dev->features |= EMAC_FTR_HAS_TAH; diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h index a010b2463fd..04105f939cf 100644 --- a/drivers/net/ibm_newemac/core.h +++ b/drivers/net/ibm_newemac/core.h @@ -293,9 +293,9 @@ struct emac_instance { */ #define EMAC_FTR_HAS_RGMII 0x00000020 /* - * Set if we have axon-type STACR + * Set if we have new type STACR with STAOPC */ -#define EMAC_FTR_HAS_AXON_STACR 0x00000040 +#define EMAC_FTR_HAS_NEW_STACR 0x00000040 /* Right now, we don't quite handle the always/possible masks on the @@ -307,7 +307,7 @@ enum { EMAC_FTRS_POSSIBLE = #ifdef CONFIG_IBM_NEW_EMAC_EMAC4 - EMAC_FTR_EMAC4 | EMAC_FTR_HAS_AXON_STACR | + EMAC_FTR_EMAC4 | EMAC_FTR_HAS_NEW_STACR | EMAC_FTR_STACR_OC_INVERT | #endif #ifdef CONFIG_IBM_NEW_EMAC_TAH -- cgit v1.2.3 From 3d722562d734834282bccd97e0badd213ec311e9 Mon Sep 17 00:00:00 2001 From: Hugh Blemings Date: Wed, 5 Dec 2007 11:14:30 +1100 Subject: ibm_newemac: Skip EMACs that are marked unused by the firmware Depending on how the 44x processors are wired, some EMAC cells might not be useable (and not connected to a PHY). However, some device-trees may choose to still expose them (since their registers are present in the MMIO space) but with an "unused" property in them. Signed-off-by: Hugh Blemings Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index ac9fd46509c..a77207f1967 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -2550,6 +2550,10 @@ static int __devinit emac_probe(struct of_device *ofdev, struct device_node **blist = NULL; int err, i; + /* Skip unused/unwired EMACS */ + if (of_get_property(np, "unused", NULL)) + return -ENODEV; + /* Find ourselves in the bootlist if we are there */ for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++) if (emac_boot_list[i] == np) -- cgit v1.2.3 From 4696c3c406a8b32112f8e1f70b3db1114950dcb1 Mon Sep 17 00:00:00 2001 From: Valentine Barshak Date: Wed, 5 Dec 2007 11:14:31 +1100 Subject: ibm_newemac: Correct opb_bus_freq value The EMAC4_MR1_OBCI(freq) macro expects freg in MHz, while opb_bus_freq is kept in Hz. Correct this. Signed-off-by: Valentine Barshak Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index a77207f1967..9642931c66e 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -402,7 +402,7 @@ static u32 __emac_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_s static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_size) { u32 ret = EMAC_MR1_VLE | EMAC_MR1_IST | EMAC4_MR1_TR | - EMAC4_MR1_OBCI(dev->opb_bus_freq); + EMAC4_MR1_OBCI(dev->opb_bus_freq / 1000000); DBG2(dev, "__emac4_calc_base_mr1" NL); -- cgit v1.2.3 From 63b6cad795e0a34e8670291943df8a6f653c1931 Mon Sep 17 00:00:00 2001 From: Valentine Barshak Date: Wed, 5 Dec 2007 11:14:31 +1100 Subject: ibm_newemac: Fix typo reading TAH channel info This patch fixes a typo in ibm_newemac/core.c (tah_port should be used instead of tah_ph) Signed-off-by: Valentine Barshak Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 9642931c66e..7a620e5aaf3 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -2442,7 +2442,7 @@ static int __devinit emac_init_config(struct emac_instance *dev) if (emac_read_uint_prop(np, "tah-device", &dev->tah_ph, 0)) dev->tah_ph = 0; if (emac_read_uint_prop(np, "tah-channel", &dev->tah_port, 0)) - dev->tah_ph = 0; + dev->tah_port = 0; if (emac_read_uint_prop(np, "mdio-device", &dev->mdio_ph, 0)) dev->mdio_ph = 0; if (emac_read_uint_prop(np, "zmii-device", &dev->zmii_ph, 0)) -- cgit v1.2.3 From d09e18bc194c3fa8ae880df4567c719c36a73e9e Mon Sep 17 00:00:00 2001 From: Valentine Barshak Date: Wed, 5 Dec 2007 11:14:32 +1100 Subject: ibm_newemac: Call dev_set_drvdata() before tah_reset() The patch moves dev_set_drvdata(&ofdev->dev, dev) up before tah_reset(ofdev) is called to avoid a NULL pointer dereference, since tah_reset uses drvdata. Signed-off-by: Valentine Barshak Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/tah.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/tah.c b/drivers/net/ibm_newemac/tah.c index f161fb100e8..6e35cbe1593 100644 --- a/drivers/net/ibm_newemac/tah.c +++ b/drivers/net/ibm_newemac/tah.c @@ -116,13 +116,14 @@ static int __devinit tah_probe(struct of_device *ofdev, goto err_free; } + dev_set_drvdata(&ofdev->dev, dev); + /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ tah_reset(ofdev); printk(KERN_INFO "TAH %s initialized\n", ofdev->node->full_name); wmb(); - dev_set_drvdata(&ofdev->dev, dev); return 0; -- cgit v1.2.3 From 17cf803a57c89c5afe6d5299ac9416683c3240dd Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 5 Dec 2007 11:14:33 +1100 Subject: ibm_newemac: Update file headers copyright notices This updates the copyright notices of the new EMAC driver to avoid confusion as who is to be blamed for new bugs. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 5 +++++ drivers/net/ibm_newemac/core.h | 5 +++++ drivers/net/ibm_newemac/debug.c | 5 +++++ drivers/net/ibm_newemac/debug.h | 5 +++++ drivers/net/ibm_newemac/emac.h | 5 +++++ drivers/net/ibm_newemac/mal.c | 5 +++++ drivers/net/ibm_newemac/mal.h | 5 +++++ drivers/net/ibm_newemac/phy.c | 5 +++++ drivers/net/ibm_newemac/phy.h | 5 +++++ drivers/net/ibm_newemac/rgmii.c | 5 +++++ drivers/net/ibm_newemac/rgmii.h | 5 +++++ drivers/net/ibm_newemac/tah.c | 5 +++++ drivers/net/ibm_newemac/tah.h | 5 +++++ drivers/net/ibm_newemac/zmii.c | 5 +++++ drivers/net/ibm_newemac/zmii.h | 5 +++++ 15 files changed, 75 insertions(+) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 7a620e5aaf3..cb06280dced 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h index 04105f939cf..4e74d8287c6 100644 --- a/drivers/net/ibm_newemac/core.h +++ b/drivers/net/ibm_newemac/core.h @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/debug.c b/drivers/net/ibm_newemac/debug.c index 170524ee0f1..a2fc660ca5d 100644 --- a/drivers/net/ibm_newemac/debug.c +++ b/drivers/net/ibm_newemac/debug.c @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/debug.h b/drivers/net/ibm_newemac/debug.h index 1dd2dcbc157..b631842ec8d 100644 --- a/drivers/net/ibm_newemac/debug.h +++ b/drivers/net/ibm_newemac/debug.h @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/emac.h b/drivers/net/ibm_newemac/emac.h index bef92efeead..91cb096ab40 100644 --- a/drivers/net/ibm_newemac/emac.h +++ b/drivers/net/ibm_newemac/emac.h @@ -3,6 +3,11 @@ * * Register definitions for PowerPC 4xx on-chip ethernet contoller * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c index 9a88f71db00..6869f08c9dc 100644 --- a/drivers/net/ibm_newemac/mal.c +++ b/drivers/net/ibm_newemac/mal.c @@ -3,6 +3,11 @@ * * Memory Access Layer (MAL) support * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/mal.h b/drivers/net/ibm_newemac/mal.h index 784edb8ea82..eaa7262dc07 100644 --- a/drivers/net/ibm_newemac/mal.h +++ b/drivers/net/ibm_newemac/mal.h @@ -3,6 +3,11 @@ * * Memory Access Layer (MAL) support * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/phy.c b/drivers/net/ibm_newemac/phy.c index 9308fad76d5..37bfeea8788 100644 --- a/drivers/net/ibm_newemac/phy.c +++ b/drivers/net/ibm_newemac/phy.c @@ -8,6 +8,11 @@ * This file should be shared with other drivers or eventually * merged as the "low level" part of miilib * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * (c) 2003, Benjamin Herrenscmidt (benh@kernel.crashing.org) * (c) 2004-2005, Eugene Surovegin * diff --git a/drivers/net/ibm_newemac/phy.h b/drivers/net/ibm_newemac/phy.h index 6feca26afed..1b65c81f655 100644 --- a/drivers/net/ibm_newemac/phy.h +++ b/drivers/net/ibm_newemac/phy.h @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, PHY support * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Benjamin Herrenschmidt * February 2003 * diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c index 32872697858..9bc1132fa78 100644 --- a/drivers/net/ibm_newemac/rgmii.c +++ b/drivers/net/ibm_newemac/rgmii.c @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/rgmii.h b/drivers/net/ibm_newemac/rgmii.h index 44a0f201064..c4a4b358a27 100644 --- a/drivers/net/ibm_newemac/rgmii.h +++ b/drivers/net/ibm_newemac/rgmii.h @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Based on ocp_zmii.h/ibm_emac_zmii.h * Armin Kuster akuster@mvista.com * diff --git a/drivers/net/ibm_newemac/tah.c b/drivers/net/ibm_newemac/tah.c index 6e35cbe1593..96417adec32 100644 --- a/drivers/net/ibm_newemac/tah.c +++ b/drivers/net/ibm_newemac/tah.c @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright 2004 MontaVista Software, Inc. * Matt Porter * diff --git a/drivers/net/ibm_newemac/tah.h b/drivers/net/ibm_newemac/tah.h index bc41853b6e2..a068b5658da 100644 --- a/drivers/net/ibm_newemac/tah.h +++ b/drivers/net/ibm_newemac/tah.h @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright 2004 MontaVista Software, Inc. * Matt Porter * diff --git a/drivers/net/ibm_newemac/zmii.c b/drivers/net/ibm_newemac/zmii.c index 0f8cfbc0c61..2ea472aeab0 100644 --- a/drivers/net/ibm_newemac/zmii.c +++ b/drivers/net/ibm_newemac/zmii.c @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * diff --git a/drivers/net/ibm_newemac/zmii.h b/drivers/net/ibm_newemac/zmii.h index 82a9968b1f7..6c9beba0c4b 100644 --- a/drivers/net/ibm_newemac/zmii.h +++ b/drivers/net/ibm_newemac/zmii.h @@ -3,6 +3,11 @@ * * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. * + * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. + * + * + * Based on the arch/ppc version of the driver: + * * Copyright (c) 2004, 2005 Zultys Technologies. * Eugene Surovegin or * -- cgit v1.2.3 From 470738758db2c209481fdf92ca09f60e690a62d3 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 13 Dec 2007 16:02:57 -0800 Subject: Net: ibm_newemac, remove SPIN_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED is deprecated, use DEFINE_SPINLOCK instead Signed-off-by: Jiri Slaby Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/debug.c b/drivers/net/ibm_newemac/debug.c index a2fc660ca5d..86b756a3078 100644 --- a/drivers/net/ibm_newemac/debug.c +++ b/drivers/net/ibm_newemac/debug.c @@ -26,7 +26,7 @@ #include "core.h" -static spinlock_t emac_dbg_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(emac_dbg_lock); static void emac_desc_dump(struct emac_instance *p) { -- cgit v1.2.3 From 283029d16a882539ab0027afd94ac52858d050b2 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Wed, 9 Jan 2008 06:20:40 +1100 Subject: [POWERPC] Add of_find_matching_node() helper function Similar to of_find_compatible_node(), of_find_matching_node() and for_each_matching_node() allow you to iterate over the device tree looking for specific nodes, except that they take of_device_id tables instead of strings. This also moves of_match_node() from driver/of/device.c to driver/of/base.c to colocate it with the of_find_matching_node which depends on it. Signed-off-by: Grant Likely Signed-off-by: Paul Mackerras --- drivers/net/ibm_newemac/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index cb06280dced..fced441face 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From ee63d22b8953fd0dde22f52c0bc17a304ae50403 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 16 Jan 2008 08:11:15 +0100 Subject: net: NEWEMAC: Fix problem with mtu > 4080 on non TAH equipped 4xx PPC's Currently, all non TAH equipped 4xx PPC's call emac_start_xmit() upon xmit. This routine doesn't check if the frame length exceeds the max. MAL buffer size. This patch now changes the driver to call emac_start_xmit_sg() on all GigE platforms and not only the TAH equipped ones (440GX). This enables an MTU of 9000 instead 4080. Signed-off-by: Stefan Roese Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'drivers/net/ibm_newemac') diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index cb06280dced..b24bd2dfb72 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -1297,7 +1297,6 @@ static int emac_start_xmit(struct sk_buff *skb, struct net_device *ndev) return emac_xmit_finish(dev, len); } -#ifdef CONFIG_IBM_NEW_EMAC_TAH static inline int emac_xmit_split(struct emac_instance *dev, int slot, u32 pd, int len, int last, u16 base_ctrl) { @@ -1410,9 +1409,6 @@ static int emac_start_xmit_sg(struct sk_buff *skb, struct net_device *ndev) DBG2(dev, "stopped TX queue" NL); return 1; } -#else -# define emac_start_xmit_sg emac_start_xmit -#endif /* !defined(CONFIG_IBM_NEW_EMAC_TAH) */ /* Tx lock BHs */ static void emac_parse_tx_error(struct emac_instance *dev, u16 ctrl) @@ -2683,13 +2679,8 @@ static int __devinit emac_probe(struct of_device *ofdev, /* Fill in the driver function table */ ndev->open = &emac_open; -#ifdef CONFIG_IBM_NEW_EMAC_TAH - if (dev->tah_dev) { - ndev->hard_start_xmit = &emac_start_xmit_sg; + if (dev->tah_dev) ndev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; - } else -#endif - ndev->hard_start_xmit = &emac_start_xmit; ndev->tx_timeout = &emac_tx_timeout; ndev->watchdog_timeo = 5 * HZ; ndev->stop = &emac_close; @@ -2697,8 +2688,11 @@ static int __devinit emac_probe(struct of_device *ofdev, ndev->set_multicast_list = &emac_set_multicast_list; ndev->do_ioctl = &emac_ioctl; if (emac_phy_supports_gige(dev->phy_mode)) { + ndev->hard_start_xmit = &emac_start_xmit_sg; ndev->change_mtu = &emac_change_mtu; dev->commac.ops = &emac_commac_sg_ops; + } else { + ndev->hard_start_xmit = &emac_start_xmit; } SET_ETHTOOL_OPS(ndev, &emac_ethtool_ops); -- cgit v1.2.3