Lines 10-19
Link Here
|
10 |
* - Get rid of all those nasty mdelay's and replace them |
10 |
* - Get rid of all those nasty mdelay's and replace them |
11 |
* with schedule_timeout. |
11 |
* with schedule_timeout. |
12 |
* - Implement WOL |
12 |
* - Implement WOL |
13 |
* - Currently, forced Gb mode is only supported on bcm54xx |
|
|
14 |
* PHY for which I use the SPD2 bit of the control register. |
15 |
* On m1011 PHY, I can't force as I don't have the specs, but |
16 |
* I can at least detect gigabit with autoneg. |
17 |
*/ |
13 |
*/ |
18 |
|
14 |
|
19 |
#include <linux/config.h> |
15 |
#include <linux/config.h> |
Lines 63-74
Link Here
|
63 |
#include <asm/pmac_feature.h> |
59 |
#include <asm/pmac_feature.h> |
64 |
#endif |
60 |
#endif |
65 |
|
61 |
|
|
|
62 |
#include "sungem_phy.h" |
66 |
#include "sungem.h" |
63 |
#include "sungem.h" |
67 |
|
64 |
|
|
|
65 |
/* Stripping FCS is causing problems, disabled for now */ |
66 |
#undef STRIP_FCS |
67 |
|
68 |
#define DEFAULT_MSG (NETIF_MSG_DRV | \ |
68 |
#define DEFAULT_MSG (NETIF_MSG_DRV | \ |
69 |
NETIF_MSG_PROBE | \ |
69 |
NETIF_MSG_PROBE | \ |
70 |
NETIF_MSG_LINK) |
70 |
NETIF_MSG_LINK) |
71 |
|
71 |
|
|
|
72 |
#define ADVERTISE_MASK (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | \ |
73 |
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \ |
74 |
SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full) |
75 |
|
72 |
#define DRV_NAME "sungem" |
76 |
#define DRV_NAME "sungem" |
73 |
#define DRV_VERSION "0.97" |
77 |
#define DRV_VERSION "0.97" |
74 |
#define DRV_RELDATE "3/20/02" |
78 |
#define DRV_RELDATE "3/20/02" |
Lines 81-104
Link Here
|
81 |
MODULE_DESCRIPTION("Sun GEM Gbit ethernet driver"); |
85 |
MODULE_DESCRIPTION("Sun GEM Gbit ethernet driver"); |
82 |
MODULE_LICENSE("GPL"); |
86 |
MODULE_LICENSE("GPL"); |
83 |
|
87 |
|
84 |
MODULE_PARM(gem_debug, "i"); |
|
|
85 |
MODULE_PARM_DESC(gem_debug, "bitmapped message enable number"); |
86 |
MODULE_PARM(link_mode, "i"); |
87 |
MODULE_PARM_DESC(link_mode, "default link mode"); |
88 |
|
89 |
int gem_debug = -1; |
90 |
static int link_mode; |
91 |
|
92 |
static u16 link_modes[] __devinitdata = { |
93 |
BMCR_ANENABLE, /* 0 : autoneg */ |
94 |
0, /* 1 : 10bt half duplex */ |
95 |
BMCR_SPEED100, /* 2 : 100bt half duplex */ |
96 |
BMCR_SPD2, /* bcm54xx only */ /* 3 : 1000bt half duplex */ |
97 |
BMCR_FULLDPLX, /* 4 : 10bt full duplex */ |
98 |
BMCR_SPEED100|BMCR_FULLDPLX, /* 5 : 100bt full duplex */ |
99 |
BMCR_SPD2|BMCR_FULLDPLX /* 6 : 1000bt full duplex */ |
100 |
}; |
101 |
|
102 |
#define GEM_MODULE_NAME "gem" |
88 |
#define GEM_MODULE_NAME "gem" |
103 |
#define PFX GEM_MODULE_NAME ": " |
89 |
#define PFX GEM_MODULE_NAME ": " |
104 |
|
90 |
|
Lines 119-130
Link Here
|
119 |
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
105 |
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
120 |
{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMACP, |
106 |
{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMACP, |
121 |
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
107 |
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
|
|
108 |
{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMAC2, |
109 |
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, |
122 |
{0, } |
110 |
{0, } |
123 |
}; |
111 |
}; |
124 |
|
112 |
|
125 |
MODULE_DEVICE_TABLE(pci, gem_pci_tbl); |
113 |
MODULE_DEVICE_TABLE(pci, gem_pci_tbl); |
126 |
|
114 |
|
127 |
static u16 __phy_read(struct gem *gp, int reg, int phy_addr) |
115 |
static u16 __phy_read(struct gem *gp, int phy_addr, int reg) |
128 |
{ |
116 |
{ |
129 |
u32 cmd; |
117 |
u32 cmd; |
130 |
int limit = 10000; |
118 |
int limit = 10000; |
Lines 150-161
Link Here
|
150 |
return cmd & MIF_FRAME_DATA; |
138 |
return cmd & MIF_FRAME_DATA; |
151 |
} |
139 |
} |
152 |
|
140 |
|
|
|
141 |
static inline int _phy_read(struct net_device *dev, int mii_id, int reg) |
142 |
{ |
143 |
struct gem *gp = dev->priv; |
144 |
return __phy_read(gp, mii_id, reg); |
145 |
} |
146 |
|
153 |
static inline u16 phy_read(struct gem *gp, int reg) |
147 |
static inline u16 phy_read(struct gem *gp, int reg) |
154 |
{ |
148 |
{ |
155 |
return __phy_read(gp, reg, gp->mii_phy_addr); |
149 |
return __phy_read(gp, gp->mii_phy_addr, reg); |
156 |
} |
150 |
} |
157 |
|
151 |
|
158 |
static void __phy_write(struct gem *gp, int reg, u16 val, int phy_addr) |
152 |
static void __phy_write(struct gem *gp, int phy_addr, int reg, u16 val) |
159 |
{ |
153 |
{ |
160 |
u32 cmd; |
154 |
u32 cmd; |
161 |
int limit = 10000; |
155 |
int limit = 10000; |
Lines 177-185
Link Here
|
177 |
} |
171 |
} |
178 |
} |
172 |
} |
179 |
|
173 |
|
|
|
174 |
static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val) |
175 |
{ |
176 |
struct gem *gp = dev->priv; |
177 |
__phy_write(gp, mii_id, reg, val & 0xffff); |
178 |
} |
179 |
|
180 |
static inline void phy_write(struct gem *gp, int reg, u16 val) |
180 |
static inline void phy_write(struct gem *gp, int reg, u16 val) |
181 |
{ |
181 |
{ |
182 |
__phy_write(gp, reg, val, gp->mii_phy_addr); |
182 |
__phy_write(gp, gp->mii_phy_addr, reg, val); |
183 |
} |
183 |
} |
184 |
|
184 |
|
185 |
static void gem_handle_mif_event(struct gem *gp, u32 reg_val, u32 changed_bits) |
185 |
static void gem_handle_mif_event(struct gem *gp, u32 reg_val, u32 changed_bits) |
Lines 228-237
Link Here
|
228 |
if (pcs_miistat & PCS_MIISTAT_LS) { |
228 |
if (pcs_miistat & PCS_MIISTAT_LS) { |
229 |
printk(KERN_INFO "%s: PCS link is now up.\n", |
229 |
printk(KERN_INFO "%s: PCS link is now up.\n", |
230 |
dev->name); |
230 |
dev->name); |
|
|
231 |
netif_carrier_on(gp->dev); |
231 |
} else { |
232 |
} else { |
232 |
printk(KERN_INFO "%s: PCS link is now down.\n", |
233 |
printk(KERN_INFO "%s: PCS link is now down.\n", |
233 |
dev->name); |
234 |
dev->name); |
234 |
|
235 |
netif_carrier_off(gp->dev); |
235 |
/* If this happens and the link timer is not running, |
236 |
/* If this happens and the link timer is not running, |
236 |
* reset so we re-negotiate. |
237 |
* reset so we re-negotiate. |
237 |
*/ |
238 |
*/ |
Lines 359-364
Link Here
|
359 |
|
360 |
|
360 |
rxd->status_word = cpu_to_le64(RXDCTRL_FRESH(gp)); |
361 |
rxd->status_word = cpu_to_le64(RXDCTRL_FRESH(gp)); |
361 |
} |
362 |
} |
|
|
363 |
mb(); |
362 |
gp->rx_new = gp->rx_old = 0; |
364 |
gp->rx_new = gp->rx_old = 0; |
363 |
|
365 |
|
364 |
/* Now we must reprogram the rest of RX unit. */ |
366 |
/* Now we must reprogram the rest of RX unit. */ |
Lines 400-405
Link Here
|
400 |
gp->dev->name, rxmac_stat); |
402 |
gp->dev->name, rxmac_stat); |
401 |
|
403 |
|
402 |
if (rxmac_stat & MAC_RXSTAT_OFLW) { |
404 |
if (rxmac_stat & MAC_RXSTAT_OFLW) { |
|
|
405 |
u32 smac = readl(gp->regs + MAC_SMACHINE); |
406 |
|
407 |
printk(KERN_ERR "%s: RX MAC fifo overflow smac[%08x].\n", |
408 |
dev->name, smac); |
403 |
gp->net_stats.rx_over_errors++; |
409 |
gp->net_stats.rx_over_errors++; |
404 |
gp->net_stats.rx_fifo_errors++; |
410 |
gp->net_stats.rx_fifo_errors++; |
405 |
|
411 |
|
Lines 667-672
Link Here
|
667 |
count = 0; |
673 |
count = 0; |
668 |
} |
674 |
} |
669 |
} |
675 |
} |
|
|
676 |
mb(); |
670 |
if (kick >= 0) |
677 |
if (kick >= 0) |
671 |
writel(kick, gp->regs + RXDMA_KICK); |
678 |
writel(kick, gp->regs + RXDMA_KICK); |
672 |
} |
679 |
} |
Lines 893-899
Link Here
|
893 |
/* We must give this initial chunk to the device last. |
900 |
/* We must give this initial chunk to the device last. |
894 |
* Otherwise we could race with the device. |
901 |
* Otherwise we could race with the device. |
895 |
*/ |
902 |
*/ |
896 |
first_len = skb->len - skb->data_len; |
903 |
first_len = skb_headlen(skb); |
897 |
first_mapping = pci_map_page(gp->pdev, virt_to_page(skb->data), |
904 |
first_mapping = pci_map_page(gp->pdev, virt_to_page(skb->data), |
898 |
((unsigned long) skb->data & ~PAGE_MASK), |
905 |
((unsigned long) skb->data & ~PAGE_MASK), |
899 |
first_len, PCI_DMA_TODEVICE); |
906 |
first_len, PCI_DMA_TODEVICE); |
Lines 936-941
Link Here
|
936 |
if (netif_msg_tx_queued(gp)) |
943 |
if (netif_msg_tx_queued(gp)) |
937 |
printk(KERN_DEBUG "%s: tx queued, slot %d, skblen %d\n", |
944 |
printk(KERN_DEBUG "%s: tx queued, slot %d, skblen %d\n", |
938 |
dev->name, entry, skb->len); |
945 |
dev->name, entry, skb->len); |
|
|
946 |
mb(); |
939 |
writel(gp->tx_new, gp->regs + TXDMA_KICK); |
947 |
writel(gp->tx_new, gp->regs + TXDMA_KICK); |
940 |
spin_unlock_irq(&gp->lock); |
948 |
spin_unlock_irq(&gp->lock); |
941 |
|
949 |
|
Lines 1003-1009
Link Here
|
1003 |
} while (val & (GREG_SWRST_TXRST | GREG_SWRST_RXRST)); |
1011 |
} while (val & (GREG_SWRST_TXRST | GREG_SWRST_RXRST)); |
1004 |
|
1012 |
|
1005 |
if (limit <= 0) |
1013 |
if (limit <= 0) |
1006 |
printk(KERN_ERR "gem: SW reset is ghetto.\n"); |
1014 |
printk(KERN_ERR "%s: SW reset is ghetto.\n", gp->dev->name); |
1007 |
} |
1015 |
} |
1008 |
|
1016 |
|
1009 |
/* Must be invoked under gp->lock. */ |
1017 |
/* Must be invoked under gp->lock. */ |
Lines 1030-1165
Link Here
|
1030 |
|
1038 |
|
1031 |
} |
1039 |
} |
1032 |
|
1040 |
|
1033 |
/* Link modes of the BCM5400 PHY */ |
|
|
1034 |
static int phy_BCM5400_link_table[8][3] = { |
1035 |
{ 0, 0, 0 }, /* No link */ |
1036 |
{ 0, 0, 0 }, /* 10BT Half Duplex */ |
1037 |
{ 1, 0, 0 }, /* 10BT Full Duplex */ |
1038 |
{ 0, 1, 0 }, /* 100BT Half Duplex */ |
1039 |
{ 0, 1, 0 }, /* 100BT Half Duplex */ |
1040 |
{ 1, 1, 0 }, /* 100BT Full Duplex*/ |
1041 |
{ 1, 0, 1 }, /* 1000BT */ |
1042 |
{ 1, 0, 1 }, /* 1000BT */ |
1043 |
}; |
1044 |
|
1041 |
|
1045 |
/* Must be invoked under gp->lock. */ |
1042 |
/* Must be invoked under gp->lock. */ |
|
|
1043 |
// XXX dbl check what that function should do when called on PCS PHY |
1046 |
static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep) |
1044 |
static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep) |
1047 |
{ |
1045 |
{ |
1048 |
u16 ctl; |
1046 |
u32 advertise, features; |
|
|
1047 |
int autoneg; |
1048 |
int speed; |
1049 |
int duplex; |
1050 |
|
1051 |
if (gp->phy_type != phy_mii_mdio0 && |
1052 |
gp->phy_type != phy_mii_mdio1) |
1053 |
goto non_mii; |
1054 |
|
1055 |
/* Setup advertise */ |
1056 |
if (found_mii_phy(gp)) |
1057 |
features = gp->phy_mii.def->features; |
1058 |
else |
1059 |
features = 0; |
1060 |
|
1061 |
advertise = features & ADVERTISE_MASK; |
1062 |
if (gp->phy_mii.advertising != 0) |
1063 |
advertise &= gp->phy_mii.advertising; |
1064 |
|
1065 |
autoneg = gp->want_autoneg; |
1066 |
speed = gp->phy_mii.speed; |
1067 |
duplex = gp->phy_mii.duplex; |
1049 |
|
1068 |
|
1050 |
/* Setup link parameters */ |
1069 |
/* Setup link parameters */ |
1051 |
if (!ep) |
1070 |
if (!ep) |
1052 |
goto start_aneg; |
1071 |
goto start_aneg; |
1053 |
if (ep->autoneg == AUTONEG_ENABLE) { |
1072 |
if (ep->autoneg == AUTONEG_ENABLE) { |
1054 |
/* TODO: parse ep->advertising */ |
1073 |
advertise = ep->advertising; |
1055 |
gp->link_advertise |= (ADVERTISE_10HALF | ADVERTISE_10FULL); |
1074 |
autoneg = 1; |
1056 |
gp->link_advertise |= (ADVERTISE_100HALF | ADVERTISE_100FULL); |
|
|
1057 |
/* Can I advertise gigabit here ? I'd need BCM PHY docs... */ |
1058 |
gp->link_cntl = BMCR_ANENABLE; |
1059 |
} else { |
1075 |
} else { |
1060 |
gp->link_cntl = 0; |
1076 |
autoneg = 0; |
1061 |
if (ep->speed == SPEED_100) |
1077 |
speed = ep->speed; |
1062 |
gp->link_cntl |= BMCR_SPEED100; |
1078 |
duplex = ep->duplex; |
1063 |
else if (ep->speed == SPEED_1000 && gp->gigabit_capable) |
|
|
1064 |
/* Hrm... check if this is right... */ |
1065 |
gp->link_cntl |= BMCR_SPD2; |
1066 |
if (ep->duplex == DUPLEX_FULL) |
1067 |
gp->link_cntl |= BMCR_FULLDPLX; |
1068 |
} |
1079 |
} |
1069 |
|
1080 |
|
1070 |
start_aneg: |
1081 |
start_aneg: |
1071 |
if (!gp->hw_running) |
1082 |
/* Sanitize settings based on PHY capabilities */ |
|
|
1083 |
if ((features & SUPPORTED_Autoneg) == 0) |
1084 |
autoneg = 0; |
1085 |
if (speed == SPEED_1000 && |
1086 |
!(features & (SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full))) |
1087 |
speed = SPEED_100; |
1088 |
if (speed == SPEED_100 && |
1089 |
!(features & (SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full))) |
1090 |
speed = SPEED_10; |
1091 |
if (duplex == DUPLEX_FULL && |
1092 |
!(features & (SUPPORTED_1000baseT_Full | |
1093 |
SUPPORTED_100baseT_Full | |
1094 |
SUPPORTED_10baseT_Full))) |
1095 |
duplex = DUPLEX_HALF; |
1096 |
if (speed == 0) |
1097 |
speed = SPEED_10; |
1098 |
|
1099 |
/* If HW is down, we don't try to actually setup the PHY, we |
1100 |
* just store the settings |
1101 |
*/ |
1102 |
if (!gp->hw_running) { |
1103 |
gp->phy_mii.autoneg = gp->want_autoneg = autoneg; |
1104 |
gp->phy_mii.speed = speed; |
1105 |
gp->phy_mii.duplex = duplex; |
1072 |
return; |
1106 |
return; |
|
|
1107 |
} |
1073 |
|
1108 |
|
1074 |
/* Configure PHY & start aneg */ |
1109 |
/* Configure PHY & start aneg */ |
1075 |
ctl = phy_read(gp, MII_BMCR); |
1110 |
gp->want_autoneg = autoneg; |
1076 |
ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_ANENABLE); |
1111 |
if (autoneg) { |
1077 |
ctl |= gp->link_cntl; |
1112 |
if (found_mii_phy(gp)) |
1078 |
if (ctl & BMCR_ANENABLE) { |
1113 |
gp->phy_mii.def->ops->setup_aneg(&gp->phy_mii, advertise); |
1079 |
ctl |= BMCR_ANRESTART; |
|
|
1080 |
gp->lstate = link_aneg; |
1114 |
gp->lstate = link_aneg; |
1081 |
} else { |
1115 |
} else { |
|
|
1116 |
if (found_mii_phy(gp)) |
1117 |
gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, speed, duplex); |
1082 |
gp->lstate = link_force_ok; |
1118 |
gp->lstate = link_force_ok; |
1083 |
} |
1119 |
} |
1084 |
phy_write(gp, MII_BMCR, ctl); |
|
|
1085 |
|
1120 |
|
|
|
1121 |
non_mii: |
1086 |
gp->timer_ticks = 0; |
1122 |
gp->timer_ticks = 0; |
1087 |
mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10)); |
1123 |
mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10)); |
1088 |
} |
1124 |
} |
1089 |
|
1125 |
|
1090 |
/* Must be invoked under gp->lock. */ |
|
|
1091 |
static void gem_read_mii_link_mode(struct gem *gp, int *fd, int *spd, int *pause) |
1092 |
{ |
1093 |
u32 val; |
1094 |
|
1095 |
*fd = 0; |
1096 |
*spd = 10; |
1097 |
*pause = 0; |
1098 |
|
1099 |
if (gp->phy_mod == phymod_bcm5400 || |
1100 |
gp->phy_mod == phymod_bcm5401 || |
1101 |
gp->phy_mod == phymod_bcm5411) { |
1102 |
int link_mode; |
1103 |
|
1104 |
val = phy_read(gp, MII_BCM5400_AUXSTATUS); |
1105 |
link_mode = ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >> |
1106 |
MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT); |
1107 |
*fd = phy_BCM5400_link_table[link_mode][0]; |
1108 |
*spd = phy_BCM5400_link_table[link_mode][2] ? |
1109 |
1000 : |
1110 |
(phy_BCM5400_link_table[link_mode][1] ? 100 : 10); |
1111 |
val = phy_read(gp, MII_LPA); |
1112 |
if (val & LPA_PAUSE) |
1113 |
*pause = 1; |
1114 |
} else { |
1115 |
val = phy_read(gp, MII_LPA); |
1116 |
|
1117 |
if (val & (LPA_10FULL | LPA_100FULL)) |
1118 |
*fd = 1; |
1119 |
if (val & (LPA_100FULL | LPA_100HALF)) |
1120 |
*spd = 100; |
1121 |
|
1122 |
if (gp->phy_mod == phymod_m1011) { |
1123 |
val = phy_read(gp, 0x0a); |
1124 |
if (val & 0xc00) |
1125 |
*spd = 1000; |
1126 |
if (val & 0x800) |
1127 |
*fd = 1; |
1128 |
} |
1129 |
} |
1130 |
} |
1131 |
|
1132 |
/* A link-up condition has occurred, initialize and enable the |
1126 |
/* A link-up condition has occurred, initialize and enable the |
1133 |
* rest of the chip. |
1127 |
* rest of the chip. |
1134 |
* |
1128 |
* |
1135 |
* Must be invoked under gp->lock. |
1129 |
* Must be invoked under gp->lock. |
1136 |
*/ |
1130 |
*/ |
1137 |
static void gem_set_link_modes(struct gem *gp) |
1131 |
static int gem_set_link_modes(struct gem *gp) |
1138 |
{ |
1132 |
{ |
1139 |
u32 val; |
1133 |
u32 val; |
1140 |
int full_duplex, speed, pause; |
1134 |
int full_duplex, speed, pause; |
1141 |
|
1135 |
|
1142 |
full_duplex = 0; |
1136 |
full_duplex = 0; |
1143 |
speed = 10; |
1137 |
speed = SPEED_10; |
1144 |
pause = 0; |
1138 |
pause = 0; |
1145 |
|
1139 |
|
1146 |
if (gp->phy_type == phy_mii_mdio0 || |
1140 |
if (found_mii_phy(gp)) { |
1147 |
gp->phy_type == phy_mii_mdio1) { |
1141 |
if (gp->phy_mii.def->ops->read_link(&gp->phy_mii)) |
1148 |
val = phy_read(gp, MII_BMCR); |
1142 |
return 1; |
1149 |
if (val & BMCR_ANENABLE) |
1143 |
full_duplex = (gp->phy_mii.duplex == DUPLEX_FULL); |
1150 |
gem_read_mii_link_mode(gp, &full_duplex, &speed, &pause); |
1144 |
speed = gp->phy_mii.speed; |
1151 |
else { |
1145 |
pause = gp->phy_mii.pause; |
1152 |
if (val & BMCR_FULLDPLX) |
1146 |
} else if (gp->phy_type == phy_serialink || |
1153 |
full_duplex = 1; |
1147 |
gp->phy_type == phy_serdes) { |
1154 |
if (val & BMCR_SPEED100) |
|
|
1155 |
speed = 100; |
1156 |
} |
1157 |
} else { |
1158 |
u32 pcs_lpa = readl(gp->regs + PCS_MIILP); |
1148 |
u32 pcs_lpa = readl(gp->regs + PCS_MIILP); |
1159 |
|
1149 |
|
1160 |
if (pcs_lpa & PCS_MIIADV_FD) |
1150 |
if (pcs_lpa & PCS_MIIADV_FD) |
1161 |
full_duplex = 1; |
1151 |
full_duplex = 1; |
1162 |
speed = 1000; |
1152 |
speed = SPEED_1000; |
1163 |
} |
1153 |
} |
1164 |
|
1154 |
|
1165 |
if (netif_msg_link(gp)) |
1155 |
if (netif_msg_link(gp)) |
Lines 1183-1189
Link Here
|
1183 |
val |= MAC_XIFCFG_FLED; |
1173 |
val |= MAC_XIFCFG_FLED; |
1184 |
} |
1174 |
} |
1185 |
|
1175 |
|
1186 |
if (speed == 1000) |
1176 |
if (speed == SPEED_1000) |
1187 |
val |= (MAC_XIFCFG_GMII); |
1177 |
val |= (MAC_XIFCFG_GMII); |
1188 |
|
1178 |
|
1189 |
writel(val, gp->regs + MAC_XIFCFG); |
1179 |
writel(val, gp->regs + MAC_XIFCFG); |
Lines 1191-1197
Link Here
|
1191 |
/* If gigabit and half-duplex, enable carrier extension |
1181 |
/* If gigabit and half-duplex, enable carrier extension |
1192 |
* mode. Else, disable it. |
1182 |
* mode. Else, disable it. |
1193 |
*/ |
1183 |
*/ |
1194 |
if (speed == 1000 && !full_duplex) { |
1184 |
if (speed == SPEED_1000 && !full_duplex) { |
1195 |
val = readl(gp->regs + MAC_TXCFG); |
1185 |
val = readl(gp->regs + MAC_TXCFG); |
1196 |
writel(val | MAC_TXCFG_TCE, gp->regs + MAC_TXCFG); |
1186 |
writel(val | MAC_TXCFG_TCE, gp->regs + MAC_TXCFG); |
1197 |
|
1187 |
|
Lines 1239-1288
Link Here
|
1239 |
writel(val, gp->regs + MAC_MCCFG); |
1229 |
writel(val, gp->regs + MAC_MCCFG); |
1240 |
|
1230 |
|
1241 |
gem_start_dma(gp); |
1231 |
gem_start_dma(gp); |
|
|
1232 |
|
1233 |
return 0; |
1242 |
} |
1234 |
} |
1243 |
|
1235 |
|
1244 |
/* Must be invoked under gp->lock. */ |
1236 |
/* Must be invoked under gp->lock. */ |
1245 |
static int gem_mdio_link_not_up(struct gem *gp) |
1237 |
static int gem_mdio_link_not_up(struct gem *gp) |
1246 |
{ |
1238 |
{ |
1247 |
u16 val; |
1239 |
switch (gp->lstate) { |
1248 |
|
1240 |
case link_force_ret: |
1249 |
if (gp->lstate == link_force_ret) { |
|
|
1250 |
if (netif_msg_link(gp)) |
1241 |
if (netif_msg_link(gp)) |
1251 |
printk(KERN_INFO "%s: Autoneg failed again, keeping" |
1242 |
printk(KERN_INFO "%s: Autoneg failed again, keeping" |
1252 |
" forced mode\n", gp->dev->name); |
1243 |
" forced mode\n", gp->dev->name); |
1253 |
phy_write(gp, MII_BMCR, gp->link_fcntl); |
1244 |
gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, |
|
|
1245 |
gp->last_forced_speed, DUPLEX_HALF); |
1254 |
gp->timer_ticks = 5; |
1246 |
gp->timer_ticks = 5; |
1255 |
gp->lstate = link_force_ok; |
1247 |
gp->lstate = link_force_ok; |
1256 |
} else if (gp->lstate == link_aneg) { |
1248 |
return 0; |
1257 |
val = phy_read(gp, MII_BMCR); |
1249 |
case link_aneg: |
1258 |
|
|
|
1259 |
if (netif_msg_link(gp)) |
1250 |
if (netif_msg_link(gp)) |
1260 |
printk(KERN_INFO "%s: switching to forced 100bt\n", |
1251 |
printk(KERN_INFO "%s: switching to forced 100bt\n", |
1261 |
gp->dev->name); |
1252 |
gp->dev->name); |
1262 |
/* Try forced modes. */ |
1253 |
/* Try forced modes. */ |
1263 |
val &= ~(BMCR_ANRESTART | BMCR_ANENABLE); |
1254 |
gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, SPEED_100, |
1264 |
val &= ~(BMCR_FULLDPLX); |
1255 |
DUPLEX_HALF); |
1265 |
val |= BMCR_SPEED100; |
|
|
1266 |
phy_write(gp, MII_BMCR, val); |
1267 |
gp->timer_ticks = 5; |
1256 |
gp->timer_ticks = 5; |
1268 |
gp->lstate = link_force_try; |
1257 |
gp->lstate = link_force_try; |
1269 |
} else { |
1258 |
return 0; |
|
|
1259 |
case link_force_try: |
1270 |
/* Downgrade from 100 to 10 Mbps if necessary. |
1260 |
/* Downgrade from 100 to 10 Mbps if necessary. |
1271 |
* If already at 10Mbps, warn user about the |
1261 |
* If already at 10Mbps, warn user about the |
1272 |
* situation every 10 ticks. |
1262 |
* situation every 10 ticks. |
1273 |
*/ |
1263 |
*/ |
1274 |
val = phy_read(gp, MII_BMCR); |
1264 |
if (gp->phy_mii.speed == SPEED_100) { |
1275 |
if (val & BMCR_SPEED100) { |
1265 |
gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, SPEED_10, |
1276 |
val &= ~BMCR_SPEED100; |
1266 |
DUPLEX_HALF); |
1277 |
phy_write(gp, MII_BMCR, val); |
|
|
1278 |
gp->timer_ticks = 5; |
1267 |
gp->timer_ticks = 5; |
1279 |
if (netif_msg_link(gp)) |
1268 |
if (netif_msg_link(gp)) |
1280 |
printk(KERN_INFO "%s: switching to forced 10bt\n", |
1269 |
printk(KERN_INFO "%s: switching to forced 10bt\n", |
1281 |
gp->dev->name); |
1270 |
gp->dev->name); |
|
|
1271 |
return 0; |
1282 |
} else |
1272 |
} else |
1283 |
return 1; |
1273 |
return 1; |
|
|
1274 |
default: |
1275 |
return 0; |
1284 |
} |
1276 |
} |
1285 |
return 0; |
|
|
1286 |
} |
1277 |
} |
1287 |
|
1278 |
|
1288 |
static void gem_init_rings(struct gem *); |
1279 |
static void gem_init_rings(struct gem *); |
Lines 1322-1328
Link Here
|
1322 |
static void gem_link_timer(unsigned long data) |
1313 |
static void gem_link_timer(unsigned long data) |
1323 |
{ |
1314 |
{ |
1324 |
struct gem *gp = (struct gem *) data; |
1315 |
struct gem *gp = (struct gem *) data; |
1325 |
|
1316 |
int restart_aneg = 0; |
|
|
1317 |
|
1326 |
if (!gp->hw_running) |
1318 |
if (!gp->hw_running) |
1327 |
return; |
1319 |
return; |
1328 |
|
1320 |
|
Lines 1334-1395
Link Here
|
1334 |
if (gp->reset_task_pending) |
1326 |
if (gp->reset_task_pending) |
1335 |
goto restart; |
1327 |
goto restart; |
1336 |
|
1328 |
|
1337 |
if (gp->phy_type == phy_mii_mdio0 || |
1329 |
if (gp->phy_type == phy_serialink || |
1338 |
gp->phy_type == phy_mii_mdio1) { |
1330 |
gp->phy_type == phy_serdes) { |
1339 |
u16 val = phy_read(gp, MII_BMSR); |
|
|
1340 |
u16 cntl = phy_read(gp, MII_BMCR); |
1341 |
int up; |
1342 |
|
1343 |
/* When using autoneg, we really wait for ANEGCOMPLETE or we may |
1344 |
* get a "transcient" incorrect link state |
1345 |
*/ |
1346 |
if (cntl & BMCR_ANENABLE) |
1347 |
up = (val & (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)) == (BMSR_ANEGCOMPLETE | BMSR_LSTATUS); |
1348 |
else |
1349 |
up = (val & BMSR_LSTATUS) != 0; |
1350 |
if (up) { |
1351 |
/* Ok, here we got a link. If we had it due to a forced |
1352 |
* fallback, and we were configured for autoneg, we do |
1353 |
* retry a short autoneg pass. If you know your hub is |
1354 |
* broken, use ethtool ;) |
1355 |
*/ |
1356 |
if (gp->lstate == link_force_try && (gp->link_cntl & BMCR_ANENABLE)) { |
1357 |
gp->lstate = link_force_ret; |
1358 |
gp->link_fcntl = phy_read(gp, MII_BMCR); |
1359 |
gp->timer_ticks = 5; |
1360 |
if (netif_msg_link(gp)) |
1361 |
printk(KERN_INFO "%s: Got link after fallback, retrying" |
1362 |
" autoneg once...\n", gp->dev->name); |
1363 |
phy_write(gp, MII_BMCR, |
1364 |
gp->link_fcntl | BMCR_ANENABLE | BMCR_ANRESTART); |
1365 |
} else if (gp->lstate != link_up) { |
1366 |
gp->lstate = link_up; |
1367 |
if (gp->opened) |
1368 |
gem_set_link_modes(gp); |
1369 |
} |
1370 |
} else { |
1371 |
int restart = 0; |
1372 |
|
1373 |
/* If the link was previously up, we restart the |
1374 |
* whole process |
1375 |
*/ |
1376 |
if (gp->lstate == link_up) { |
1377 |
gp->lstate = link_down; |
1378 |
if (netif_msg_link(gp)) |
1379 |
printk(KERN_INFO "%s: Link down\n", |
1380 |
gp->dev->name); |
1381 |
gp->reset_task_pending = 2; |
1382 |
schedule_task(&gp->reset_task); |
1383 |
restart = 1; |
1384 |
} else if (++gp->timer_ticks > 10) |
1385 |
restart = gem_mdio_link_not_up(gp); |
1386 |
|
1387 |
if (restart) { |
1388 |
gem_begin_auto_negotiation(gp, NULL); |
1389 |
goto out_unlock; |
1390 |
} |
1391 |
} |
1392 |
} else { |
1393 |
u32 val = readl(gp->regs + PCS_MIISTAT); |
1331 |
u32 val = readl(gp->regs + PCS_MIISTAT); |
1394 |
|
1332 |
|
1395 |
if (!(val & PCS_MIISTAT_LS)) |
1333 |
if (!(val & PCS_MIISTAT_LS)) |
Lines 1397-1407
Link Here
|
1397 |
|
1335 |
|
1398 |
if ((val & PCS_MIISTAT_LS) != 0) { |
1336 |
if ((val & PCS_MIISTAT_LS) != 0) { |
1399 |
gp->lstate = link_up; |
1337 |
gp->lstate = link_up; |
|
|
1338 |
netif_carrier_on(gp->dev); |
1400 |
if (gp->opened) |
1339 |
if (gp->opened) |
1401 |
gem_set_link_modes(gp); |
1340 |
(void)gem_set_link_modes(gp); |
1402 |
} |
1341 |
} |
|
|
1342 |
goto restart; |
1343 |
} |
1344 |
if (found_mii_phy(gp) && gp->phy_mii.def->ops->poll_link(&gp->phy_mii)) { |
1345 |
/* Ok, here we got a link. If we had it due to a forced |
1346 |
* fallback, and we were configured for autoneg, we do |
1347 |
* retry a short autoneg pass. If you know your hub is |
1348 |
* broken, use ethtool ;) |
1349 |
*/ |
1350 |
if (gp->lstate == link_force_try && gp->want_autoneg) { |
1351 |
gp->lstate = link_force_ret; |
1352 |
gp->last_forced_speed = gp->phy_mii.speed; |
1353 |
gp->timer_ticks = 5; |
1354 |
if (netif_msg_link(gp)) |
1355 |
printk(KERN_INFO "%s: Got link after fallback, retrying" |
1356 |
" autoneg once...\n", gp->dev->name); |
1357 |
gp->phy_mii.def->ops->setup_aneg(&gp->phy_mii, gp->phy_mii.advertising); |
1358 |
} else if (gp->lstate != link_up) { |
1359 |
gp->lstate = link_up; |
1360 |
netif_carrier_on(gp->dev); |
1361 |
if (gp->opened && gem_set_link_modes(gp)) |
1362 |
restart_aneg = 1; |
1363 |
} |
1364 |
} else { |
1365 |
/* If the link was previously up, we restart the |
1366 |
* whole process |
1367 |
*/ |
1368 |
if (gp->lstate == link_up) { |
1369 |
gp->lstate = link_down; |
1370 |
if (netif_msg_link(gp)) |
1371 |
printk(KERN_INFO "%s: Link down\n", |
1372 |
gp->dev->name); |
1373 |
netif_carrier_off(gp->dev); |
1374 |
gp->reset_task_pending = 2; |
1375 |
schedule_task(&gp->reset_task); |
1376 |
restart_aneg = 1; |
1377 |
} else if (++gp->timer_ticks > 10) { |
1378 |
if (found_mii_phy(gp)) |
1379 |
restart_aneg = gem_mdio_link_not_up(gp); |
1380 |
else |
1381 |
restart_aneg = 1; |
1382 |
} |
1383 |
} |
1384 |
if (restart_aneg) { |
1385 |
gem_begin_auto_negotiation(gp, NULL); |
1386 |
goto out_unlock; |
1403 |
} |
1387 |
} |
1404 |
|
|
|
1405 |
restart: |
1388 |
restart: |
1406 |
mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10)); |
1389 |
mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10)); |
1407 |
out_unlock: |
1390 |
out_unlock: |
Lines 1501-1653
Link Here
|
1501 |
txd->control_word = 0; |
1484 |
txd->control_word = 0; |
1502 |
txd->buffer = 0; |
1485 |
txd->buffer = 0; |
1503 |
} |
1486 |
} |
1504 |
} |
1487 |
mb(); |
1505 |
|
|
|
1506 |
/* Must be invoked under gp->lock. */ |
1507 |
static int gem_reset_one_mii_phy(struct gem *gp, int phy_addr) |
1508 |
{ |
1509 |
u16 val; |
1510 |
int limit = 10000; |
1511 |
|
1512 |
val = __phy_read(gp, MII_BMCR, phy_addr); |
1513 |
val &= ~BMCR_ISOLATE; |
1514 |
val |= BMCR_RESET; |
1515 |
__phy_write(gp, MII_BMCR, val, phy_addr); |
1516 |
|
1517 |
udelay(100); |
1518 |
|
1519 |
while (limit--) { |
1520 |
val = __phy_read(gp, MII_BMCR, phy_addr); |
1521 |
if ((val & BMCR_RESET) == 0) |
1522 |
break; |
1523 |
udelay(10); |
1524 |
} |
1525 |
if ((val & BMCR_ISOLATE) && limit > 0) |
1526 |
__phy_write(gp, MII_BMCR, val & ~BMCR_ISOLATE, phy_addr); |
1527 |
|
1528 |
return (limit <= 0); |
1529 |
} |
1530 |
|
1531 |
/* Must be invoked under gp->lock. */ |
1532 |
static void gem_init_bcm5201_phy(struct gem *gp) |
1533 |
{ |
1534 |
u16 data; |
1535 |
|
1536 |
data = phy_read(gp, MII_BCM5201_MULTIPHY); |
1537 |
data &= ~MII_BCM5201_MULTIPHY_SUPERISOLATE; |
1538 |
phy_write(gp, MII_BCM5201_MULTIPHY, data); |
1539 |
} |
1540 |
|
1541 |
/* Must be invoked under gp->lock. */ |
1542 |
static void gem_init_bcm5400_phy(struct gem *gp) |
1543 |
{ |
1544 |
u16 data; |
1545 |
|
1546 |
/* Configure for gigabit full duplex */ |
1547 |
data = phy_read(gp, MII_BCM5400_AUXCONTROL); |
1548 |
data |= MII_BCM5400_AUXCONTROL_PWR10BASET; |
1549 |
phy_write(gp, MII_BCM5400_AUXCONTROL, data); |
1550 |
|
1551 |
data = phy_read(gp, MII_BCM5400_GB_CONTROL); |
1552 |
data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; |
1553 |
phy_write(gp, MII_BCM5400_GB_CONTROL, data); |
1554 |
|
1555 |
mdelay(10); |
1556 |
|
1557 |
/* Reset and configure cascaded 10/100 PHY */ |
1558 |
gem_reset_one_mii_phy(gp, 0x1f); |
1559 |
|
1560 |
data = __phy_read(gp, MII_BCM5201_MULTIPHY, 0x1f); |
1561 |
data |= MII_BCM5201_MULTIPHY_SERIALMODE; |
1562 |
__phy_write(gp, MII_BCM5201_MULTIPHY, data, 0x1f); |
1563 |
|
1564 |
data = phy_read(gp, MII_BCM5400_AUXCONTROL); |
1565 |
data &= ~MII_BCM5400_AUXCONTROL_PWR10BASET; |
1566 |
phy_write(gp, MII_BCM5400_AUXCONTROL, data); |
1567 |
} |
1568 |
|
1569 |
/* Must be invoked under gp->lock. */ |
1570 |
static void gem_init_bcm5401_phy(struct gem *gp) |
1571 |
{ |
1572 |
u16 data; |
1573 |
int rev; |
1574 |
|
1575 |
rev = phy_read(gp, MII_PHYSID2) & 0x000f; |
1576 |
if (rev == 0 || rev == 3) { |
1577 |
/* Some revisions of 5401 appear to need this |
1578 |
* initialisation sequence to disable, according |
1579 |
* to OF, "tap power management" |
1580 |
* |
1581 |
* WARNING ! OF and Darwin don't agree on the |
1582 |
* register addresses. OF seem to interpret the |
1583 |
* register numbers below as decimal |
1584 |
* |
1585 |
* Note: This should (and does) match tg3_init_5401phy_dsp |
1586 |
* in the tg3.c driver. -DaveM |
1587 |
*/ |
1588 |
phy_write(gp, 0x18, 0x0c20); |
1589 |
phy_write(gp, 0x17, 0x0012); |
1590 |
phy_write(gp, 0x15, 0x1804); |
1591 |
phy_write(gp, 0x17, 0x0013); |
1592 |
phy_write(gp, 0x15, 0x1204); |
1593 |
phy_write(gp, 0x17, 0x8006); |
1594 |
phy_write(gp, 0x15, 0x0132); |
1595 |
phy_write(gp, 0x17, 0x8006); |
1596 |
phy_write(gp, 0x15, 0x0232); |
1597 |
phy_write(gp, 0x17, 0x201f); |
1598 |
phy_write(gp, 0x15, 0x0a20); |
1599 |
} |
1600 |
|
1601 |
/* Configure for gigabit full duplex */ |
1602 |
data = phy_read(gp, MII_BCM5400_GB_CONTROL); |
1603 |
data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; |
1604 |
phy_write(gp, MII_BCM5400_GB_CONTROL, data); |
1605 |
|
1606 |
mdelay(1); |
1607 |
|
1608 |
/* Reset and configure cascaded 10/100 PHY */ |
1609 |
gem_reset_one_mii_phy(gp, 0x1f); |
1610 |
|
1611 |
data = __phy_read(gp, MII_BCM5201_MULTIPHY, 0x1f); |
1612 |
data |= MII_BCM5201_MULTIPHY_SERIALMODE; |
1613 |
__phy_write(gp, MII_BCM5201_MULTIPHY, data, 0x1f); |
1614 |
} |
1615 |
|
1616 |
/* Must be invoked under gp->lock. */ |
1617 |
static void gem_init_bcm5411_phy(struct gem *gp) |
1618 |
{ |
1619 |
u16 data; |
1620 |
|
1621 |
/* Here's some more Apple black magic to setup |
1622 |
* some voltage stuffs. |
1623 |
*/ |
1624 |
phy_write(gp, 0x1c, 0x8c23); |
1625 |
phy_write(gp, 0x1c, 0x8ca3); |
1626 |
phy_write(gp, 0x1c, 0x8c23); |
1627 |
|
1628 |
/* Here, Apple seems to want to reset it, do |
1629 |
* it as well |
1630 |
*/ |
1631 |
phy_write(gp, MII_BMCR, BMCR_RESET); |
1632 |
|
1633 |
/* Start autoneg */ |
1634 |
phy_write(gp, MII_BMCR, |
1635 |
(BMCR_ANENABLE | BMCR_FULLDPLX | |
1636 |
BMCR_ANRESTART | BMCR_SPD2)); |
1637 |
|
1638 |
data = phy_read(gp, MII_BCM5400_GB_CONTROL); |
1639 |
data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; |
1640 |
phy_write(gp, MII_BCM5400_GB_CONTROL, data); |
1641 |
} |
1488 |
} |
1642 |
|
1489 |
|
1643 |
/* Must be invoked under gp->lock. */ |
1490 |
/* Must be invoked under gp->lock. */ |
1644 |
static void gem_init_phy(struct gem *gp) |
1491 |
static void gem_init_phy(struct gem *gp) |
1645 |
{ |
1492 |
{ |
1646 |
u32 mifcfg; |
1493 |
u32 mifcfg; |
1647 |
|
1494 |
|
1648 |
if (!gp->wake_on_lan && gp->phy_mod == phymod_bcm5201) |
|
|
1649 |
phy_write(gp, MII_BCM5201_INTERRUPT, 0); |
1650 |
|
1651 |
/* Revert MIF CFG setting done on stop_phy */ |
1495 |
/* Revert MIF CFG setting done on stop_phy */ |
1652 |
mifcfg = readl(gp->regs + MIF_CFG); |
1496 |
mifcfg = readl(gp->regs + MIF_CFG); |
1653 |
mifcfg &= ~MIF_CFG_BBMODE; |
1497 |
mifcfg &= ~MIF_CFG_BBMODE; |
Lines 1655-1673
Link Here
|
1655 |
|
1499 |
|
1656 |
#ifdef CONFIG_ALL_PPC |
1500 |
#ifdef CONFIG_ALL_PPC |
1657 |
if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) { |
1501 |
if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) { |
1658 |
int i; |
1502 |
int i, j; |
1659 |
|
1503 |
|
|
|
1504 |
/* Those delay sucks, the HW seem to love them though, I'll |
1505 |
* serisouly consider breaking some locks here to be able |
1506 |
* to schedule instead |
1507 |
*/ |
1660 |
pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0); |
1508 |
pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0); |
1661 |
for (i = 0; i < 32; i++) { |
1509 |
mdelay(10); |
1662 |
gp->mii_phy_addr = i; |
1510 |
for (j = 0; j < 3; j++) { |
1663 |
if (phy_read(gp, MII_BMCR) != 0xffff) |
1511 |
/* Some PHYs used by apple have problem getting back to us, |
|
|
1512 |
* we _know_ it's actually at addr 0, that's a hack, but |
1513 |
* it helps to do that reset now. I suspect some motherboards |
1514 |
* don't wire the PHY reset line properly, thus the PHY doesn't |
1515 |
* come back with the above pmac_call_feature. |
1516 |
*/ |
1517 |
gp->mii_phy_addr = 0; |
1518 |
phy_write(gp, MII_BMCR, BMCR_RESET); |
1519 |
/* We should probably break some locks here and schedule... */ |
1520 |
mdelay(10); |
1521 |
for (i = 0; i < 32; i++) { |
1522 |
gp->mii_phy_addr = i; |
1523 |
if (phy_read(gp, MII_BMCR) != 0xffff) |
1524 |
break; |
1525 |
} |
1526 |
if (i == 32) { |
1527 |
printk(KERN_WARNING "%s: GMAC PHY not responding !\n", |
1528 |
gp->dev->name); |
1529 |
gp->mii_phy_addr = 0; |
1530 |
} else |
1664 |
break; |
1531 |
break; |
1665 |
} |
1532 |
} |
1666 |
if (i == 32) { |
|
|
1667 |
printk(KERN_WARNING "%s: GMAC PHY not responding !\n", |
1668 |
gp->dev->name); |
1669 |
return; |
1670 |
} |
1671 |
} |
1533 |
} |
1672 |
#endif /* CONFIG_ALL_PPC */ |
1534 |
#endif /* CONFIG_ALL_PPC */ |
1673 |
|
1535 |
|
Lines 1690-1768
Link Here
|
1690 |
|
1552 |
|
1691 |
if (gp->phy_type == phy_mii_mdio0 || |
1553 |
if (gp->phy_type == phy_mii_mdio0 || |
1692 |
gp->phy_type == phy_mii_mdio1) { |
1554 |
gp->phy_type == phy_mii_mdio1) { |
1693 |
u32 phy_id; |
1555 |
// XXX check for errors |
1694 |
u16 val; |
1556 |
mii_phy_probe(&gp->phy_mii, gp->mii_phy_addr); |
1695 |
|
|
|
1696 |
/* Take PHY out of isloate mode and reset it. */ |
1697 |
gem_reset_one_mii_phy(gp, gp->mii_phy_addr); |
1698 |
|
1699 |
phy_id = (phy_read(gp, MII_PHYSID1) << 16 | phy_read(gp, MII_PHYSID2)) |
1700 |
& 0xfffffff0; |
1701 |
printk(KERN_INFO "%s: MII PHY ID: %x ", gp->dev->name, phy_id); |
1702 |
switch(phy_id) { |
1703 |
case 0x406210: |
1704 |
gp->phy_mod = phymod_bcm5201; |
1705 |
gem_init_bcm5201_phy(gp); |
1706 |
printk("BCM 5201\n"); |
1707 |
break; |
1708 |
|
1709 |
case 0x4061e0: |
1710 |
printk("BCM 5221\n"); |
1711 |
gp->phy_mod = phymod_bcm5221; |
1712 |
break; |
1713 |
|
1714 |
case 0x206040: |
1715 |
printk("BCM 5400\n"); |
1716 |
gp->phy_mod = phymod_bcm5400; |
1717 |
gem_init_bcm5400_phy(gp); |
1718 |
gp->gigabit_capable = 1; |
1719 |
break; |
1720 |
|
1721 |
case 0x206050: |
1722 |
printk("BCM 5401\n"); |
1723 |
gp->phy_mod = phymod_bcm5401; |
1724 |
gem_init_bcm5401_phy(gp); |
1725 |
gp->gigabit_capable = 1; |
1726 |
break; |
1727 |
|
1728 |
case 0x206070: |
1729 |
printk("BCM 5411\n"); |
1730 |
gp->phy_mod = phymod_bcm5411; |
1731 |
gem_init_bcm5411_phy(gp); |
1732 |
gp->gigabit_capable = 1; |
1733 |
break; |
1734 |
case 0x1410c60: |
1735 |
printk("M1011 (Marvel ?)\n"); |
1736 |
gp->phy_mod = phymod_m1011; |
1737 |
gp->gigabit_capable = 1; |
1738 |
break; |
1739 |
|
1740 |
case 0x18074c0: |
1741 |
printk("Lucent\n"); |
1742 |
gp->phy_mod = phymod_generic; |
1743 |
break; |
1744 |
|
1745 |
case 0x437420: |
1746 |
printk("Enable Semiconductor\n"); |
1747 |
gp->phy_mod = phymod_generic; |
1748 |
break; |
1749 |
|
1750 |
default: |
1751 |
printk("Unknown (Using generic mode)\n"); |
1752 |
gp->phy_mod = phymod_generic; |
1753 |
break; |
1754 |
}; |
1755 |
|
1557 |
|
1756 |
/* Init advertisement and enable autonegotiation. */ |
1558 |
/* Init PHY */ |
1757 |
val = phy_read(gp, MII_BMCR); |
1559 |
if (gp->phy_mii.def && gp->phy_mii.def->ops->init) |
1758 |
val &= ~BMCR_ANENABLE; |
1560 |
gp->phy_mii.def->ops->init(&gp->phy_mii); |
1759 |
phy_write(gp, MII_BMCR, val); |
|
|
1760 |
udelay(10); |
1761 |
|
1762 |
phy_write(gp, MII_ADVERTISE, |
1763 |
phy_read(gp, MII_ADVERTISE) | |
1764 |
(ADVERTISE_10HALF | ADVERTISE_10FULL | |
1765 |
ADVERTISE_100HALF | ADVERTISE_100FULL)); |
1766 |
} else { |
1561 |
} else { |
1767 |
u32 val; |
1562 |
u32 val; |
1768 |
int limit; |
1563 |
int limit; |
Lines 1819-1831
Link Here
|
1819 |
else |
1614 |
else |
1820 |
val |= PCS_SCTRL_LOOP; |
1615 |
val |= PCS_SCTRL_LOOP; |
1821 |
writel(val, gp->regs + PCS_SCTRL); |
1616 |
writel(val, gp->regs + PCS_SCTRL); |
1822 |
gp->gigabit_capable = 1; |
|
|
1823 |
} |
1617 |
} |
1824 |
|
|
|
1825 |
/* BMCR_SPD2 is a broadcom 54xx specific thing afaik */ |
1826 |
if (gp->phy_mod != phymod_bcm5400 && gp->phy_mod != phymod_bcm5401 && |
1827 |
gp->phy_mod != phymod_bcm5411) |
1828 |
gp->link_cntl &= ~BMCR_SPD2; |
1829 |
} |
1618 |
} |
1830 |
|
1619 |
|
1831 |
/* Must be invoked under gp->lock. */ |
1620 |
/* Must be invoked under gp->lock. */ |
Lines 1914-1922
Link Here
|
1914 |
{ |
1703 |
{ |
1915 |
unsigned char *e = &gp->dev->dev_addr[0]; |
1704 |
unsigned char *e = &gp->dev->dev_addr[0]; |
1916 |
|
1705 |
|
1917 |
if (gp->pdev->vendor == PCI_VENDOR_ID_SUN && |
1706 |
writel(0x1bf0, gp->regs + MAC_SNDPAUSE); |
1918 |
gp->pdev->device == PCI_DEVICE_ID_SUN_GEM) |
|
|
1919 |
writel(0x1bf0, gp->regs + MAC_SNDPAUSE); |
1920 |
|
1707 |
|
1921 |
writel(0x00, gp->regs + MAC_IPG0); |
1708 |
writel(0x00, gp->regs + MAC_IPG0); |
1922 |
writel(0x08, gp->regs + MAC_IPG1); |
1709 |
writel(0x08, gp->regs + MAC_IPG1); |
Lines 1953-1959
Link Here
|
1953 |
writel(0, gp->regs + MAC_AF0MSK); |
1740 |
writel(0, gp->regs + MAC_AF0MSK); |
1954 |
|
1741 |
|
1955 |
gp->mac_rx_cfg = gem_setup_multicast(gp); |
1742 |
gp->mac_rx_cfg = gem_setup_multicast(gp); |
1956 |
|
1743 |
#ifdef STRIP_FCS |
|
|
1744 |
gp->mac_rx_cfg |= MAC_RXCFG_SFCS; |
1745 |
#endif |
1957 |
writel(0, gp->regs + MAC_NCOLL); |
1746 |
writel(0, gp->regs + MAC_NCOLL); |
1958 |
writel(0, gp->regs + MAC_FASUCC); |
1747 |
writel(0, gp->regs + MAC_FASUCC); |
1959 |
writel(0, gp->regs + MAC_ECOLL); |
1748 |
writel(0, gp->regs + MAC_ECOLL); |
Lines 2129-2140
Link Here
|
2129 |
/* Default aneg parameters */ |
1918 |
/* Default aneg parameters */ |
2130 |
gp->timer_ticks = 0; |
1919 |
gp->timer_ticks = 0; |
2131 |
gp->lstate = link_down; |
1920 |
gp->lstate = link_down; |
|
|
1921 |
netif_carrier_off(gp->dev); |
2132 |
|
1922 |
|
2133 |
/* Can I advertise gigabit here ? I'd need BCM PHY docs... */ |
1923 |
/* Can I advertise gigabit here ? I'd need BCM PHY docs... */ |
2134 |
gem_begin_auto_negotiation(gp, NULL); |
1924 |
gem_begin_auto_negotiation(gp, NULL); |
2135 |
} else { |
1925 |
} else { |
2136 |
if (gp->lstate == link_up) |
1926 |
if (gp->lstate == link_up) { |
|
|
1927 |
netif_carrier_on(gp->dev); |
2137 |
gem_set_link_modes(gp); |
1928 |
gem_set_link_modes(gp); |
|
|
1929 |
} |
2138 |
} |
1930 |
} |
2139 |
} |
1931 |
} |
2140 |
|
1932 |
|
Lines 2184-2192
Link Here
|
2184 |
{ |
1976 |
{ |
2185 |
u32 mifcfg; |
1977 |
u32 mifcfg; |
2186 |
|
1978 |
|
2187 |
if (!gp->wake_on_lan && gp->phy_mod == phymod_bcm5201) |
|
|
2188 |
phy_write(gp, MII_BCM5201_INTERRUPT, 0); |
2189 |
|
2190 |
/* Make sure we aren't polling PHY status change. We |
1979 |
/* Make sure we aren't polling PHY status change. We |
2191 |
* don't currently use that feature though |
1980 |
* don't currently use that feature though |
2192 |
*/ |
1981 |
*/ |
Lines 2194-2202
Link Here
|
2194 |
mifcfg &= ~MIF_CFG_POLL; |
1983 |
mifcfg &= ~MIF_CFG_POLL; |
2195 |
writel(mifcfg, gp->regs + MIF_CFG); |
1984 |
writel(mifcfg, gp->regs + MIF_CFG); |
2196 |
|
1985 |
|
2197 |
/* Here's a strange hack used by both MacOS 9 and X */ |
|
|
2198 |
phy_write(gp, MII_LPA, phy_read(gp, MII_LPA)); |
2199 |
|
2200 |
if (gp->wake_on_lan) { |
1986 |
if (gp->wake_on_lan) { |
2201 |
/* Setup wake-on-lan */ |
1987 |
/* Setup wake-on-lan */ |
2202 |
} else |
1988 |
} else |
Lines 2210-2230
Link Here
|
2210 |
gem_stop(gp); |
1996 |
gem_stop(gp); |
2211 |
writel(MAC_TXRST_CMD, gp->regs + MAC_TXRST); |
1997 |
writel(MAC_TXRST_CMD, gp->regs + MAC_TXRST); |
2212 |
writel(MAC_RXRST_CMD, gp->regs + MAC_RXRST); |
1998 |
writel(MAC_RXRST_CMD, gp->regs + MAC_RXRST); |
2213 |
if (gp->phy_mod == phymod_bcm5400 || gp->phy_mod == phymod_bcm5401 || |
1999 |
} |
2214 |
gp->phy_mod == phymod_bcm5411) { |
|
|
2215 |
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */ |
2216 |
phy_write(gp, MII_BMCR, BMCR_PDOWN); |
2217 |
#endif |
2218 |
} else if (gp->phy_mod == phymod_bcm5201 || gp->phy_mod == phymod_bcm5221) { |
2219 |
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */ |
2220 |
u16 val = phy_read(gp, MII_BCM5201_AUXMODE2) |
2221 |
phy_write(gp, MII_BCM5201_AUXMODE2, |
2222 |
val & ~MII_BCM5201_AUXMODE2_LOWPOWER); |
2223 |
#endif |
2224 |
phy_write(gp, MII_BCM5201_MULTIPHY, MII_BCM5201_MULTIPHY_SUPERISOLATE); |
2225 |
} else if (gp->phy_mod == phymod_m1011) |
2226 |
phy_write(gp, MII_BMCR, BMCR_PDOWN); |
2227 |
|
2000 |
|
|
|
2001 |
if (found_mii_phy(gp) && gp->phy_mii.def->ops->suspend) |
2002 |
gp->phy_mii.def->ops->suspend(&gp->phy_mii, 0 /* wake on lan options */); |
2003 |
|
2004 |
if (!gp->wake_on_lan) { |
2228 |
/* According to Apple, we must set the MDIO pins to this begnign |
2005 |
/* According to Apple, we must set the MDIO pins to this begnign |
2229 |
* state or we may 1) eat more current, 2) damage some PHYs |
2006 |
* state or we may 1) eat more current, 2) damage some PHYs |
2230 |
*/ |
2007 |
*/ |
Lines 2330-2344
Link Here
|
2330 |
gp->hw_running = 1; |
2107 |
gp->hw_running = 1; |
2331 |
} |
2108 |
} |
2332 |
|
2109 |
|
2333 |
spin_lock_irq(&gp->lock); |
|
|
2334 |
|
2335 |
/* We can now request the interrupt as we know it's masked |
2110 |
/* We can now request the interrupt as we know it's masked |
2336 |
* on the controller |
2111 |
* on the controller |
2337 |
*/ |
2112 |
*/ |
2338 |
if (request_irq(gp->pdev->irq, gem_interrupt, |
2113 |
if (request_irq(gp->pdev->irq, gem_interrupt, |
2339 |
SA_SHIRQ, dev->name, (void *)dev)) { |
2114 |
SA_SHIRQ, dev->name, (void *)dev)) { |
2340 |
spin_unlock_irq(&gp->lock); |
|
|
2341 |
|
2342 |
printk(KERN_ERR "%s: failed to request irq !\n", gp->dev->name); |
2115 |
printk(KERN_ERR "%s: failed to request irq !\n", gp->dev->name); |
2343 |
|
2116 |
|
2344 |
#ifdef CONFIG_ALL_PPC |
2117 |
#ifdef CONFIG_ALL_PPC |
Lines 2349-2358
Link Here
|
2349 |
gp->pm_timer.expires = jiffies + 10*HZ; |
2122 |
gp->pm_timer.expires = jiffies + 10*HZ; |
2350 |
add_timer(&gp->pm_timer); |
2123 |
add_timer(&gp->pm_timer); |
2351 |
up(&gp->pm_sem); |
2124 |
up(&gp->pm_sem); |
|
|
2125 |
spin_unlock_irq(&gp->lock); |
2352 |
|
2126 |
|
2353 |
return -EAGAIN; |
2127 |
return -EAGAIN; |
2354 |
} |
2128 |
} |
2355 |
|
2129 |
|
|
|
2130 |
spin_lock_irq(&gp->lock); |
2131 |
|
2356 |
/* Allocate & setup ring buffers */ |
2132 |
/* Allocate & setup ring buffers */ |
2357 |
gem_init_rings(gp); |
2133 |
gem_init_rings(gp); |
2358 |
|
2134 |
|
Lines 2526-2532
Link Here
|
2526 |
netif_stop_queue(dev); |
2302 |
netif_stop_queue(dev); |
2527 |
|
2303 |
|
2528 |
rxcfg = readl(gp->regs + MAC_RXCFG); |
2304 |
rxcfg = readl(gp->regs + MAC_RXCFG); |
2529 |
gp->mac_rx_cfg = rxcfg_new = gem_setup_multicast(gp); |
2305 |
rxcfg_new = gem_setup_multicast(gp); |
|
|
2306 |
#ifdef STRIP_FCS |
2307 |
rxcfg_new |= MAC_RXCFG_SFCS; |
2308 |
#endif |
2309 |
gp->mac_rx_cfg = rxcfg_new; |
2530 |
|
2310 |
|
2531 |
writel(rxcfg & ~MAC_RXCFG_ENAB, gp->regs + MAC_RXCFG); |
2311 |
writel(rxcfg & ~MAC_RXCFG_ENAB, gp->regs + MAC_RXCFG); |
2532 |
while (readl(gp->regs + MAC_RXCFG) & MAC_RXCFG_ENAB) { |
2312 |
while (readl(gp->regs + MAC_RXCFG) & MAC_RXCFG_ENAB) { |
Lines 2551-2558
Link Here
|
2551 |
static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user) |
2331 |
static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user) |
2552 |
{ |
2332 |
{ |
2553 |
struct gem *gp = dev->priv; |
2333 |
struct gem *gp = dev->priv; |
2554 |
u16 bmcr; |
|
|
2555 |
int full_duplex, speed, pause; |
2556 |
struct ethtool_cmd ecmd; |
2334 |
struct ethtool_cmd ecmd; |
2557 |
|
2335 |
|
2558 |
if (copy_from_user(&ecmd, ep_user, sizeof(ecmd))) |
2336 |
if (copy_from_user(&ecmd, ep_user, sizeof(ecmd))) |
Lines 2560-2566
Link Here
|
2560 |
|
2338 |
|
2561 |
switch(ecmd.cmd) { |
2339 |
switch(ecmd.cmd) { |
2562 |
case ETHTOOL_GDRVINFO: { |
2340 |
case ETHTOOL_GDRVINFO: { |
2563 |
struct ethtool_drvinfo info = { cmd: ETHTOOL_GDRVINFO }; |
2341 |
struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO }; |
2564 |
|
2342 |
|
2565 |
strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN); |
2343 |
strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN); |
2566 |
strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN); |
2344 |
strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN); |
Lines 2575-2615
Link Here
|
2575 |
} |
2353 |
} |
2576 |
|
2354 |
|
2577 |
case ETHTOOL_GSET: |
2355 |
case ETHTOOL_GSET: |
2578 |
ecmd.supported = |
2356 |
if (gp->phy_type == phy_mii_mdio0 || |
|
|
2357 |
gp->phy_type == phy_mii_mdio1) { |
2358 |
if (gp->phy_mii.def) |
2359 |
ecmd.supported = gp->phy_mii.def->features; |
2360 |
else |
2361 |
ecmd.supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full; |
2362 |
|
2363 |
/* XXX hardcoded stuff for now */ |
2364 |
ecmd.port = PORT_MII; |
2365 |
ecmd.transceiver = XCVR_EXTERNAL; |
2366 |
ecmd.phy_address = 0; /* XXX fixed PHYAD */ |
2367 |
|
2368 |
/* Return current PHY settings */ |
2369 |
spin_lock_irq(&gp->lock); |
2370 |
ecmd.autoneg = gp->want_autoneg; |
2371 |
ecmd.speed = gp->phy_mii.speed; |
2372 |
ecmd.duplex = gp->phy_mii.duplex; |
2373 |
ecmd.advertising = gp->phy_mii.advertising; |
2374 |
/* If we started with a forced mode, we don't have a default |
2375 |
* advertise set, we need to return something sensible so |
2376 |
* userland can re-enable autoneg properly */ |
2377 |
if (ecmd.advertising == 0) |
2378 |
ecmd.advertising = ecmd.supported; |
2379 |
spin_unlock_irq(&gp->lock); |
2380 |
} else { // XXX PCS ? |
2381 |
ecmd.supported = |
2579 |
(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | |
2382 |
(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | |
2580 |
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | |
2383 |
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | |
2581 |
SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII); |
2384 |
SUPPORTED_Autoneg); |
2582 |
|
2385 |
ecmd.advertising = ecmd.supported; |
2583 |
if (gp->gigabit_capable) |
|
|
2584 |
ecmd.supported |= |
2585 |
(SUPPORTED_1000baseT_Half | |
2586 |
SUPPORTED_1000baseT_Full); |
2587 |
|
2588 |
/* XXX hardcoded stuff for now */ |
2589 |
ecmd.port = PORT_MII; |
2590 |
ecmd.transceiver = XCVR_EXTERNAL; |
2591 |
ecmd.phy_address = 0; /* XXX fixed PHYAD */ |
2592 |
|
2593 |
/* Record PHY settings if HW is on. */ |
2594 |
spin_lock_irq(&gp->lock); |
2595 |
if (gp->hw_running) { |
2596 |
bmcr = phy_read(gp, MII_BMCR); |
2597 |
gem_read_mii_link_mode(gp, &full_duplex, &speed, &pause); |
2598 |
} else |
2599 |
bmcr = 0; |
2600 |
spin_unlock_irq(&gp->lock); |
2601 |
if (bmcr & BMCR_ANENABLE) { |
2602 |
ecmd.autoneg = AUTONEG_ENABLE; |
2603 |
ecmd.speed = speed == 10 ? SPEED_10 : (speed == 1000 ? SPEED_1000 : SPEED_100); |
2604 |
ecmd.duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF; |
2605 |
} else { |
2606 |
ecmd.autoneg = AUTONEG_DISABLE; |
2607 |
ecmd.speed = |
2608 |
(bmcr & BMCR_SPEED100) ? |
2609 |
SPEED_100 : SPEED_10; |
2610 |
ecmd.duplex = |
2611 |
(bmcr & BMCR_FULLDPLX) ? |
2612 |
DUPLEX_FULL : DUPLEX_HALF; |
2613 |
} |
2386 |
} |
2614 |
if (copy_to_user(ep_user, &ecmd, sizeof(ecmd))) |
2387 |
if (copy_to_user(ep_user, &ecmd, sizeof(ecmd))) |
2615 |
return -EFAULT; |
2388 |
return -EFAULT; |
Lines 2621-2633
Link Here
|
2621 |
ecmd.autoneg != AUTONEG_DISABLE) |
2394 |
ecmd.autoneg != AUTONEG_DISABLE) |
2622 |
return -EINVAL; |
2395 |
return -EINVAL; |
2623 |
|
2396 |
|
|
|
2397 |
if (ecmd.autoneg == AUTONEG_ENABLE && |
2398 |
ecmd.advertising == 0) |
2399 |
return -EINVAL; |
2400 |
|
2624 |
if (ecmd.autoneg == AUTONEG_DISABLE && |
2401 |
if (ecmd.autoneg == AUTONEG_DISABLE && |
2625 |
((ecmd.speed != SPEED_100 && |
2402 |
((ecmd.speed != SPEED_1000 && |
|
|
2403 |
ecmd.speed != SPEED_100 && |
2626 |
ecmd.speed != SPEED_10) || |
2404 |
ecmd.speed != SPEED_10) || |
2627 |
(ecmd.duplex != DUPLEX_HALF && |
2405 |
(ecmd.duplex != DUPLEX_HALF && |
2628 |
ecmd.duplex != DUPLEX_FULL))) |
2406 |
ecmd.duplex != DUPLEX_FULL))) |
2629 |
return -EINVAL; |
2407 |
return -EINVAL; |
2630 |
|
2408 |
|
2631 |
/* Apply settings and restart link process. */ |
2409 |
/* Apply settings and restart link process. */ |
2632 |
spin_lock_irq(&gp->lock); |
2410 |
spin_lock_irq(&gp->lock); |
2633 |
gem_begin_auto_negotiation(gp, &ecmd); |
2411 |
gem_begin_auto_negotiation(gp, &ecmd); |
Lines 2636-2642
Link Here
|
2636 |
return 0; |
2414 |
return 0; |
2637 |
|
2415 |
|
2638 |
case ETHTOOL_NWAY_RST: |
2416 |
case ETHTOOL_NWAY_RST: |
2639 |
if ((gp->link_cntl & BMCR_ANENABLE) == 0) |
2417 |
if (!gp->want_autoneg) |
2640 |
return -EINVAL; |
2418 |
return -EINVAL; |
2641 |
|
2419 |
|
2642 |
/* Restart link process. */ |
2420 |
/* Restart link process. */ |
Lines 2652-2658
Link Here
|
2652 |
|
2430 |
|
2653 |
/* get link status */ |
2431 |
/* get link status */ |
2654 |
case ETHTOOL_GLINK: { |
2432 |
case ETHTOOL_GLINK: { |
2655 |
struct ethtool_value edata = { cmd: ETHTOOL_GLINK }; |
2433 |
struct ethtool_value edata = { .cmd = ETHTOOL_GLINK }; |
2656 |
|
2434 |
|
2657 |
edata.data = (gp->lstate == link_up); |
2435 |
edata.data = (gp->lstate == link_up); |
2658 |
if (copy_to_user(ep_user, &edata, sizeof(edata))) |
2436 |
if (copy_to_user(ep_user, &edata, sizeof(edata))) |
Lines 2662-2668
Link Here
|
2662 |
|
2440 |
|
2663 |
/* get message-level */ |
2441 |
/* get message-level */ |
2664 |
case ETHTOOL_GMSGLVL: { |
2442 |
case ETHTOOL_GMSGLVL: { |
2665 |
struct ethtool_value edata = { cmd: ETHTOOL_GMSGLVL }; |
2443 |
struct ethtool_value edata = { .cmd = ETHTOOL_GMSGLVL }; |
2666 |
|
2444 |
|
2667 |
edata.data = gp->msg_enable; |
2445 |
edata.data = gp->msg_enable; |
2668 |
if (copy_to_user(ep_user, &edata, sizeof(edata))) |
2446 |
if (copy_to_user(ep_user, &edata, sizeof(edata))) |
Lines 2740-2754
Link Here
|
2740 |
/* Fallthrough... */ |
2518 |
/* Fallthrough... */ |
2741 |
|
2519 |
|
2742 |
case SIOCGMIIREG: /* Read MII PHY register. */ |
2520 |
case SIOCGMIIREG: /* Read MII PHY register. */ |
2743 |
data->val_out = __phy_read(gp, data->reg_num & 0x1f, data->phy_id & 0x1f); |
2521 |
if (!gp->hw_running) |
2744 |
rc = 0; |
2522 |
rc = -EIO; |
|
|
2523 |
else { |
2524 |
data->val_out = __phy_read(gp, data->phy_id & 0x1f, data->reg_num & 0x1f); |
2525 |
rc = 0; |
2526 |
} |
2745 |
break; |
2527 |
break; |
2746 |
|
2528 |
|
2747 |
case SIOCSMIIREG: /* Write MII PHY register. */ |
2529 |
case SIOCSMIIREG: /* Write MII PHY register. */ |
2748 |
if (!capable(CAP_NET_ADMIN)) { |
2530 |
if (!capable(CAP_NET_ADMIN)) |
2749 |
rc = -EPERM; |
2531 |
rc = -EPERM; |
2750 |
} else { |
2532 |
else if (!gp->hw_running) |
2751 |
__phy_write(gp, data->reg_num & 0x1f, data->val_in, data->phy_id & 0x1f); |
2533 |
rc = -EIO; |
|
|
2534 |
else { |
2535 |
__phy_write(gp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in); |
2752 |
rc = 0; |
2536 |
rc = 0; |
2753 |
} |
2537 |
} |
2754 |
break; |
2538 |
break; |
Lines 2894-2900
Link Here
|
2894 |
*/ |
2678 |
*/ |
2895 |
if (pdev->vendor == PCI_VENDOR_ID_SUN && |
2679 |
if (pdev->vendor == PCI_VENDOR_ID_SUN && |
2896 |
pdev->device == PCI_DEVICE_ID_SUN_GEM && |
2680 |
pdev->device == PCI_DEVICE_ID_SUN_GEM && |
2897 |
!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff)) { |
2681 |
!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) { |
2898 |
pci_using_dac = 1; |
2682 |
pci_using_dac = 1; |
2899 |
} else { |
2683 |
} else { |
2900 |
err = pci_set_dma_mask(pdev, (u64) 0xffffffff); |
2684 |
err = pci_set_dma_mask(pdev, (u64) 0xffffffff); |
Lines 2934-2940
Link Here
|
2934 |
dev->base_addr = (long) pdev; |
2718 |
dev->base_addr = (long) pdev; |
2935 |
gp->dev = dev; |
2719 |
gp->dev = dev; |
2936 |
|
2720 |
|
2937 |
gp->msg_enable = (gem_debug < 0 ? DEFAULT_MSG : gem_debug); |
2721 |
gp->msg_enable = DEFAULT_MSG; |
2938 |
|
2722 |
|
2939 |
spin_lock_init(&gp->lock); |
2723 |
spin_lock_init(&gp->lock); |
2940 |
init_MUTEX(&gp->pm_sem); |
2724 |
init_MUTEX(&gp->pm_sem); |
Lines 2950-2962
Link Here
|
2950 |
INIT_TQUEUE(&gp->pm_task, gem_pm_task, gp); |
2734 |
INIT_TQUEUE(&gp->pm_task, gem_pm_task, gp); |
2951 |
INIT_TQUEUE(&gp->reset_task, gem_reset_task, gp); |
2735 |
INIT_TQUEUE(&gp->reset_task, gem_reset_task, gp); |
2952 |
|
2736 |
|
2953 |
/* Default link parameters */ |
|
|
2954 |
if (link_mode >= 0 && link_mode <= 6) |
2955 |
gp->link_cntl = link_modes[link_mode]; |
2956 |
else |
2957 |
gp->link_cntl = BMCR_ANENABLE; |
2958 |
gp->lstate = link_down; |
2737 |
gp->lstate = link_down; |
2959 |
gp->timer_ticks = 0; |
2738 |
gp->timer_ticks = 0; |
|
|
2739 |
netif_carrier_off(dev); |
2960 |
|
2740 |
|
2961 |
gp->regs = (unsigned long) ioremap(gemreg_base, gemreg_len); |
2741 |
gp->regs = (unsigned long) ioremap(gemreg_base, gemreg_len); |
2962 |
if (gp->regs == 0UL) { |
2742 |
if (gp->regs == 0UL) { |
Lines 2977-2992
Link Here
|
2977 |
gem_stop(gp); |
2757 |
gem_stop(gp); |
2978 |
spin_unlock_irq(&gp->lock); |
2758 |
spin_unlock_irq(&gp->lock); |
2979 |
|
2759 |
|
|
|
2760 |
/* Fill up the mii_phy structure (even if we won't use it) */ |
2761 |
gp->phy_mii.dev = dev; |
2762 |
gp->phy_mii.mdio_read = _phy_read; |
2763 |
gp->phy_mii.mdio_write = _phy_write; |
2764 |
|
2765 |
/* By default, we start with autoneg */ |
2766 |
gp->want_autoneg = 1; |
2767 |
|
2980 |
if (gem_check_invariants(gp)) |
2768 |
if (gem_check_invariants(gp)) |
2981 |
goto err_out_iounmap; |
2769 |
goto err_out_iounmap; |
2982 |
|
2770 |
|
2983 |
spin_lock_irq(&gp->lock); |
2771 |
/* It is guaranteed that the returned buffer will be at least |
2984 |
gp->hw_running = 1; |
|
|
2985 |
gem_init_phy(gp); |
2986 |
gem_begin_auto_negotiation(gp, NULL); |
2987 |
spin_unlock_irq(&gp->lock); |
2988 |
|
2989 |
/* It is guarenteed that the returned buffer will be at least |
2990 |
* PAGE_SIZE aligned. |
2772 |
* PAGE_SIZE aligned. |
2991 |
*/ |
2773 |
*/ |
2992 |
gp->init_block = (struct gem_init_block *) |
2774 |
gp->init_block = (struct gem_init_block *) |
Lines 3012-3023
Link Here
|
3012 |
|
2794 |
|
3013 |
printk(KERN_INFO "%s: Sun GEM (PCI) 10/100/1000BaseT Ethernet ", |
2795 |
printk(KERN_INFO "%s: Sun GEM (PCI) 10/100/1000BaseT Ethernet ", |
3014 |
dev->name); |
2796 |
dev->name); |
3015 |
|
|
|
3016 |
for (i = 0; i < 6; i++) |
2797 |
for (i = 0; i < 6; i++) |
3017 |
printk("%2.2x%c", dev->dev_addr[i], |
2798 |
printk("%2.2x%c", dev->dev_addr[i], |
3018 |
i == 5 ? ' ' : ':'); |
2799 |
i == 5 ? ' ' : ':'); |
3019 |
printk("\n"); |
2800 |
printk("\n"); |
3020 |
|
2801 |
|
|
|
2802 |
/* Detect & init PHY, start autoneg */ |
2803 |
spin_lock_irq(&gp->lock); |
2804 |
gp->hw_running = 1; |
2805 |
gem_init_phy(gp); |
2806 |
gem_begin_auto_negotiation(gp, NULL); |
2807 |
spin_unlock_irq(&gp->lock); |
2808 |
|
2809 |
if (gp->phy_type == phy_mii_mdio0 || |
2810 |
gp->phy_type == phy_mii_mdio1) |
2811 |
printk(KERN_INFO "%s: Found %s PHY\n", dev->name, |
2812 |
gp->phy_mii.def ? gp->phy_mii.def->name : "no"); |
2813 |
|
3021 |
pci_set_drvdata(pdev, dev); |
2814 |
pci_set_drvdata(pdev, dev); |
3022 |
|
2815 |
|
3023 |
dev->open = gem_open; |
2816 |
dev->open = gem_open; |