aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pasemi_mac.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2007-11-28 21:58:25 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:04:27 -0500
commitb0cd2f9016f75eb8a9fdc45d32f9b41fb16d48c9 (patch)
tree16d46e44b7509b239ac3f3000e1b14c4dbebb6b8 /drivers/net/pasemi_mac.c
parent8304b633c5e8c9ba34d3cc7f24f52434d3a3b93b (diff)
pasemi_mac: Don't enable RX/TX without a link (if possible)
pasemi_mac: Don't enable RX/TX without a link (if possible) Don't enable RX/TX of packets until we have a link, since there's a chance we'll just get RX frame errors, etc. The case where we don't have a PHY we can't do much about: Just enable it and deal with errors as they come in. Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/pasemi_mac.c')
-rw-r--r--drivers/net/pasemi_mac.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 7345a81bb2c6..bb88a41b7591 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -874,6 +874,24 @@ static irqreturn_t pasemi_mac_tx_intr(int irq, void *data)
874 return IRQ_HANDLED; 874 return IRQ_HANDLED;
875} 875}
876 876
877static void pasemi_mac_intf_disable(struct pasemi_mac *mac)
878{
879 unsigned int flags;
880
881 flags = read_mac_reg(mac, PAS_MAC_CFG_PCFG);
882 flags &= ~PAS_MAC_CFG_PCFG_PE;
883 write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags);
884}
885
886static void pasemi_mac_intf_enable(struct pasemi_mac *mac)
887{
888 unsigned int flags;
889
890 flags = read_mac_reg(mac, PAS_MAC_CFG_PCFG);
891 flags |= PAS_MAC_CFG_PCFG_PE;
892 write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags);
893}
894
877static void pasemi_adjust_link(struct net_device *dev) 895static void pasemi_adjust_link(struct net_device *dev)
878{ 896{
879 struct pasemi_mac *mac = netdev_priv(dev); 897 struct pasemi_mac *mac = netdev_priv(dev);
@@ -889,11 +907,14 @@ static void pasemi_adjust_link(struct net_device *dev)
889 printk(KERN_INFO "%s: Link is down.\n", dev->name); 907 printk(KERN_INFO "%s: Link is down.\n", dev->name);
890 908
891 netif_carrier_off(dev); 909 netif_carrier_off(dev);
910 pasemi_mac_intf_disable(mac);
892 mac->link = 0; 911 mac->link = 0;
893 912
894 return; 913 return;
895 } else 914 } else {
915 pasemi_mac_intf_enable(mac);
896 netif_carrier_on(dev); 916 netif_carrier_on(dev);
917 }
897 918
898 flags = read_mac_reg(mac, PAS_MAC_CFG_PCFG); 919 flags = read_mac_reg(mac, PAS_MAC_CFG_PCFG);
899 new_flags = flags & ~(PAS_MAC_CFG_PCFG_HD | PAS_MAC_CFG_PCFG_SPD_M | 920 new_flags = flags & ~(PAS_MAC_CFG_PCFG_HD | PAS_MAC_CFG_PCFG_SPD_M |
@@ -1052,8 +1073,7 @@ static int pasemi_mac_open(struct net_device *dev)
1052 pasemi_mac_restart_rx_intr(mac); 1073 pasemi_mac_restart_rx_intr(mac);
1053 pasemi_mac_restart_tx_intr(mac); 1074 pasemi_mac_restart_tx_intr(mac);
1054 1075
1055 flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE | 1076 flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;
1056 PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;
1057 1077
1058 if (mac->type == MAC_TYPE_GMAC) 1078 if (mac->type == MAC_TYPE_GMAC)
1059 flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G; 1079 flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G;
@@ -1064,11 +1084,16 @@ static int pasemi_mac_open(struct net_device *dev)
1064 write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags); 1084 write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags);
1065 1085
1066 ret = pasemi_mac_phy_init(dev); 1086 ret = pasemi_mac_phy_init(dev);
1067 /* Warn for missing PHY on SGMII (1Gig) ports. 1087 if (ret) {
1068 */ 1088 /* Since we won't get link notification, just enable RX */
1069 if (ret && mac->type == MAC_TYPE_GMAC) { 1089 pasemi_mac_intf_enable(mac);
1070 dev_warn(&mac->pdev->dev, "PHY init failed: %d.\n", ret); 1090 if (mac->type == MAC_TYPE_GMAC) {
1071 dev_warn(&mac->pdev->dev, "Defaulting to 1Gbit full duplex\n"); 1091 /* Warn for missing PHY on SGMII (1Gig) ports */
1092 dev_warn(&mac->pdev->dev,
1093 "PHY init failed: %d.\n", ret);
1094 dev_warn(&mac->pdev->dev,
1095 "Defaulting to 1Gbit full duplex\n");
1096 }
1072 } 1097 }
1073 1098
1074 netif_start_queue(dev); 1099 netif_start_queue(dev);