aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrew Victor <avictor.za@gmail.com>2012-04-25 20:30:42 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-28 21:48:37 -0400
commitc5f0f83c3be4c965c40c78d52000db30c0ceab5d (patch)
tree0e3dbeef02ae0b78325ca1da997ee3507255110e /drivers
parentcb75a36c8a1ab68e2dbfbe172f12c792b0c6dba8 (diff)
AT91: Remove fixed mapping for AT91RM9200 ethernet
The AT91RM9200 Ethernet controller still has a fixed IO mapping. So: * Remove the fixed IO mapping and AT91_VA_BASE_EMAC definition. * Pass the physical base-address via platform-resources to the driver. * Convert at91_ether.c driver to perform an ioremap(). * Ethernet PHY detection needs to be performed during the driver initialization process, it can no longer be done first. Signed-off-by: Andrew Victor <linux@maxim.org.za> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.c527
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.h1
2 files changed, 285 insertions, 243 deletions
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 906117016fc4..62761e19e210 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -30,6 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/gfp.h> 32#include <linux/gfp.h>
33#include <linux/phy.h>
33 34
34#include <asm/io.h> 35#include <asm/io.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
@@ -51,21 +52,17 @@
51/* 52/*
52 * Read from a EMAC register. 53 * Read from a EMAC register.
53 */ 54 */
54static inline unsigned long at91_emac_read(unsigned int reg) 55static inline unsigned long at91_emac_read(struct at91_private *lp, unsigned int reg)
55{ 56{
56 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC; 57 return __raw_readl(lp->emac_base + reg);
57
58 return __raw_readl(emac_base + reg);
59} 58}
60 59
61/* 60/*
62 * Write to a EMAC register. 61 * Write to a EMAC register.
63 */ 62 */
64static inline void at91_emac_write(unsigned int reg, unsigned long value) 63static inline void at91_emac_write(struct at91_private *lp, unsigned int reg, unsigned long value)
65{ 64{
66 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC; 65 __raw_writel(value, lp->emac_base + reg);
67
68 __raw_writel(value, emac_base + reg);
69} 66}
70 67
71/* ........................... PHY INTERFACE ........................... */ 68/* ........................... PHY INTERFACE ........................... */
@@ -75,32 +72,33 @@ static inline void at91_emac_write(unsigned int reg, unsigned long value)
75 * When not called from an interrupt-handler, access to the PHY must be 72 * When not called from an interrupt-handler, access to the PHY must be
76 * protected by a spinlock. 73 * protected by a spinlock.
77 */ 74 */
78static void enable_mdi(void) 75static void enable_mdi(struct at91_private *lp)
79{ 76{
80 unsigned long ctl; 77 unsigned long ctl;
81 78
82 ctl = at91_emac_read(AT91_EMAC_CTL); 79 ctl = at91_emac_read(lp, AT91_EMAC_CTL);
83 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_MPE); /* enable management port */ 80 at91_emac_write(lp, AT91_EMAC_CTL, ctl | AT91_EMAC_MPE); /* enable management port */
84} 81}
85 82
86/* 83/*
87 * Disable the MDIO bit in the MAC control register 84 * Disable the MDIO bit in the MAC control register
88 */ 85 */
89static void disable_mdi(void) 86static void disable_mdi(struct at91_private *lp)
90{ 87{
91 unsigned long ctl; 88 unsigned long ctl;
92 89
93 ctl = at91_emac_read(AT91_EMAC_CTL); 90 ctl = at91_emac_read(lp, AT91_EMAC_CTL);
94 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_MPE); /* disable management port */ 91 at91_emac_write(lp, AT91_EMAC_CTL, ctl & ~AT91_EMAC_MPE); /* disable management port */
95} 92}
96 93
97/* 94/*
98 * Wait until the PHY operation is complete. 95 * Wait until the PHY operation is complete.
99 */ 96 */
100static inline void at91_phy_wait(void) { 97static inline void at91_phy_wait(struct at91_private *lp)
98{
101 unsigned long timeout = jiffies + 2; 99 unsigned long timeout = jiffies + 2;
102 100
103 while (!(at91_emac_read(AT91_EMAC_SR) & AT91_EMAC_SR_IDLE)) { 101 while (!(at91_emac_read(lp, AT91_EMAC_SR) & AT91_EMAC_SR_IDLE)) {
104 if (time_after(jiffies, timeout)) { 102 if (time_after(jiffies, timeout)) {
105 printk("at91_ether: MIO timeout\n"); 103 printk("at91_ether: MIO timeout\n");
106 break; 104 break;
@@ -113,28 +111,28 @@ static inline void at91_phy_wait(void) {
113 * Write value to the a PHY register 111 * Write value to the a PHY register
114 * Note: MDI interface is assumed to already have been enabled. 112 * Note: MDI interface is assumed to already have been enabled.
115 */ 113 */
116static void write_phy(unsigned char phy_addr, unsigned char address, unsigned int value) 114static void write_phy(struct at91_private *lp, unsigned char phy_addr, unsigned char address, unsigned int value)
117{ 115{
118 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_W 116 at91_emac_write(lp, AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_W
119 | ((phy_addr & 0x1f) << 23) | (address << 18) | (value & AT91_EMAC_DATA)); 117 | ((phy_addr & 0x1f) << 23) | (address << 18) | (value & AT91_EMAC_DATA));
120 118
121 /* Wait until IDLE bit in Network Status register is cleared */ 119 /* Wait until IDLE bit in Network Status register is cleared */
122 at91_phy_wait(); 120 at91_phy_wait(lp);
123} 121}
124 122
125/* 123/*
126 * Read value stored in a PHY register. 124 * Read value stored in a PHY register.
127 * Note: MDI interface is assumed to already have been enabled. 125 * Note: MDI interface is assumed to already have been enabled.
128 */ 126 */
129static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int *value) 127static void read_phy(struct at91_private *lp, unsigned char phy_addr, unsigned char address, unsigned int *value)
130{ 128{
131 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_R 129 at91_emac_write(lp, AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_R
132 | ((phy_addr & 0x1f) << 23) | (address << 18)); 130 | ((phy_addr & 0x1f) << 23) | (address << 18));
133 131
134 /* Wait until IDLE bit in Network Status register is cleared */ 132 /* Wait until IDLE bit in Network Status register is cleared */
135 at91_phy_wait(); 133 at91_phy_wait(lp);
136 134
137 *value = at91_emac_read(AT91_EMAC_MAN) & AT91_EMAC_DATA; 135 *value = at91_emac_read(lp, AT91_EMAC_MAN) & AT91_EMAC_DATA;
138} 136}
139 137
140/* ........................... PHY MANAGEMENT .......................... */ 138/* ........................... PHY MANAGEMENT .......................... */
@@ -158,13 +156,13 @@ static void update_linkspeed(struct net_device *dev, int silent)
158 } 156 }
159 157
160 /* Link up, or auto-negotiation still in progress */ 158 /* Link up, or auto-negotiation still in progress */
161 read_phy(lp->phy_address, MII_BMSR, &bmsr); 159 read_phy(lp, lp->phy_address, MII_BMSR, &bmsr);
162 read_phy(lp->phy_address, MII_BMCR, &bmcr); 160 read_phy(lp, lp->phy_address, MII_BMCR, &bmcr);
163 if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */ 161 if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
164 if (!(bmsr & BMSR_ANEGCOMPLETE)) 162 if (!(bmsr & BMSR_ANEGCOMPLETE))
165 return; /* Do nothing - another interrupt generated when negotiation complete */ 163 return; /* Do nothing - another interrupt generated when negotiation complete */
166 164
167 read_phy(lp->phy_address, MII_LPA, &lpa); 165 read_phy(lp, lp->phy_address, MII_LPA, &lpa);
168 if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100; 166 if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
169 else speed = SPEED_10; 167 else speed = SPEED_10;
170 if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL; 168 if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL;
@@ -175,7 +173,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
175 } 173 }
176 174
177 /* Update the MAC */ 175 /* Update the MAC */
178 mac_cfg = at91_emac_read(AT91_EMAC_CFG) & ~(AT91_EMAC_SPD | AT91_EMAC_FD); 176 mac_cfg = at91_emac_read(lp, AT91_EMAC_CFG) & ~(AT91_EMAC_SPD | AT91_EMAC_FD);
179 if (speed == SPEED_100) { 177 if (speed == SPEED_100) {
180 if (duplex == DUPLEX_FULL) /* 100 Full Duplex */ 178 if (duplex == DUPLEX_FULL) /* 100 Full Duplex */
181 mac_cfg |= AT91_EMAC_SPD | AT91_EMAC_FD; 179 mac_cfg |= AT91_EMAC_SPD | AT91_EMAC_FD;
@@ -186,7 +184,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
186 mac_cfg |= AT91_EMAC_FD; 184 mac_cfg |= AT91_EMAC_FD;
187 else {} /* 10 Half Duplex */ 185 else {} /* 10 Half Duplex */
188 } 186 }
189 at91_emac_write(AT91_EMAC_CFG, mac_cfg); 187 at91_emac_write(lp, AT91_EMAC_CFG, mac_cfg);
190 188
191 if (!silent) 189 if (!silent)
192 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex"); 190 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
@@ -207,34 +205,34 @@ static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
207 * level-triggering. We therefore have to check if the PHY actually has 205 * level-triggering. We therefore have to check if the PHY actually has
208 * an IRQ pending. 206 * an IRQ pending.
209 */ 207 */
210 enable_mdi(); 208 enable_mdi(lp);
211 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { 209 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
212 read_phy(lp->phy_address, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */ 210 read_phy(lp, lp->phy_address, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */
213 if (!(phy & (1 << 0))) 211 if (!(phy & (1 << 0)))
214 goto done; 212 goto done;
215 } 213 }
216 else if (lp->phy_type == MII_LXT971A_ID) { 214 else if (lp->phy_type == MII_LXT971A_ID) {
217 read_phy(lp->phy_address, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */ 215 read_phy(lp, lp->phy_address, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */
218 if (!(phy & (1 << 2))) 216 if (!(phy & (1 << 2)))
219 goto done; 217 goto done;
220 } 218 }
221 else if (lp->phy_type == MII_BCM5221_ID) { 219 else if (lp->phy_type == MII_BCM5221_ID) {
222 read_phy(lp->phy_address, MII_BCMINTR_REG, &phy); /* ack interrupt in Broadcom PHY */ 220 read_phy(lp, lp->phy_address, MII_BCMINTR_REG, &phy); /* ack interrupt in Broadcom PHY */
223 if (!(phy & (1 << 0))) 221 if (!(phy & (1 << 0)))
224 goto done; 222 goto done;
225 } 223 }
226 else if (lp->phy_type == MII_KS8721_ID) { 224 else if (lp->phy_type == MII_KS8721_ID) {
227 read_phy(lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */ 225 read_phy(lp, lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */
228 if (!(phy & ((1 << 2) | 1))) 226 if (!(phy & ((1 << 2) | 1)))
229 goto done; 227 goto done;
230 } 228 }
231 else if (lp->phy_type == MII_T78Q21x3_ID) { /* ack interrupt in Teridian PHY */ 229 else if (lp->phy_type == MII_T78Q21x3_ID) { /* ack interrupt in Teridian PHY */
232 read_phy(lp->phy_address, MII_T78Q21INT_REG, &phy); 230 read_phy(lp, lp->phy_address, MII_T78Q21INT_REG, &phy);
233 if (!(phy & ((1 << 2) | 1))) 231 if (!(phy & ((1 << 2) | 1)))
234 goto done; 232 goto done;
235 } 233 }
236 else if (lp->phy_type == MII_DP83848_ID) { 234 else if (lp->phy_type == MII_DP83848_ID) {
237 read_phy(lp->phy_address, MII_DPPHYSTS_REG, &phy); /* ack interrupt in DP83848 PHY */ 235 read_phy(lp, lp->phy_address, MII_DPPHYSTS_REG, &phy); /* ack interrupt in DP83848 PHY */
238 if (!(phy & (1 << 7))) 236 if (!(phy & (1 << 7)))
239 goto done; 237 goto done;
240 } 238 }
@@ -242,7 +240,7 @@ static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
242 update_linkspeed(dev, 0); 240 update_linkspeed(dev, 0);
243 241
244done: 242done:
245 disable_mdi(); 243 disable_mdi(lp);
246 244
247 return IRQ_HANDLED; 245 return IRQ_HANDLED;
248} 246}
@@ -273,41 +271,41 @@ static void enable_phyirq(struct net_device *dev)
273 } 271 }
274 272
275 spin_lock_irq(&lp->lock); 273 spin_lock_irq(&lp->lock);
276 enable_mdi(); 274 enable_mdi(lp);
277 275
278 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */ 276 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
279 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr); 277 read_phy(lp, lp->phy_address, MII_DSINTR_REG, &dsintr);
280 dsintr = dsintr & ~0xf00; /* clear bits 8..11 */ 278 dsintr = dsintr & ~0xf00; /* clear bits 8..11 */
281 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr); 279 write_phy(lp, lp->phy_address, MII_DSINTR_REG, dsintr);
282 } 280 }
283 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */ 281 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
284 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr); 282 read_phy(lp, lp->phy_address, MII_ISINTE_REG, &dsintr);
285 dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */ 283 dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */
286 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr); 284 write_phy(lp, lp->phy_address, MII_ISINTE_REG, dsintr);
287 } 285 }
288 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */ 286 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
289 dsintr = (1 << 15) | ( 1 << 14); 287 dsintr = (1 << 15) | ( 1 << 14);
290 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr); 288 write_phy(lp, lp->phy_address, MII_BCMINTR_REG, dsintr);
291 } 289 }
292 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */ 290 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
293 dsintr = (1 << 10) | ( 1 << 8); 291 dsintr = (1 << 10) | ( 1 << 8);
294 write_phy(lp->phy_address, MII_TPISTATUS, dsintr); 292 write_phy(lp, lp->phy_address, MII_TPISTATUS, dsintr);
295 } 293 }
296 else if (lp->phy_type == MII_T78Q21x3_ID) { /* for Teridian PHY */ 294 else if (lp->phy_type == MII_T78Q21x3_ID) { /* for Teridian PHY */
297 read_phy(lp->phy_address, MII_T78Q21INT_REG, &dsintr); 295 read_phy(lp, lp->phy_address, MII_T78Q21INT_REG, &dsintr);
298 dsintr = dsintr | 0x500; /* set bits 8, 10 */ 296 dsintr = dsintr | 0x500; /* set bits 8, 10 */
299 write_phy(lp->phy_address, MII_T78Q21INT_REG, dsintr); 297 write_phy(lp, lp->phy_address, MII_T78Q21INT_REG, dsintr);
300 } 298 }
301 else if (lp->phy_type == MII_DP83848_ID) { /* National Semiconductor DP83848 PHY */ 299 else if (lp->phy_type == MII_DP83848_ID) { /* National Semiconductor DP83848 PHY */
302 read_phy(lp->phy_address, MII_DPMISR_REG, &dsintr); 300 read_phy(lp, lp->phy_address, MII_DPMISR_REG, &dsintr);
303 dsintr = dsintr | 0x3c; /* set bits 2..5 */ 301 dsintr = dsintr | 0x3c; /* set bits 2..5 */
304 write_phy(lp->phy_address, MII_DPMISR_REG, dsintr); 302 write_phy(lp, lp->phy_address, MII_DPMISR_REG, dsintr);
305 read_phy(lp->phy_address, MII_DPMICR_REG, &dsintr); 303 read_phy(lp, lp->phy_address, MII_DPMICR_REG, &dsintr);
306 dsintr = dsintr | 0x3; /* set bits 0,1 */ 304 dsintr = dsintr | 0x3; /* set bits 0,1 */
307 write_phy(lp->phy_address, MII_DPMICR_REG, dsintr); 305 write_phy(lp, lp->phy_address, MII_DPMICR_REG, dsintr);
308 } 306 }
309 307
310 disable_mdi(); 308 disable_mdi(lp);
311 spin_unlock_irq(&lp->lock); 309 spin_unlock_irq(&lp->lock);
312} 310}
313 311
@@ -326,43 +324,43 @@ static void disable_phyirq(struct net_device *dev)
326 } 324 }
327 325
328 spin_lock_irq(&lp->lock); 326 spin_lock_irq(&lp->lock);
329 enable_mdi(); 327 enable_mdi(lp);
330 328
331 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */ 329 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
332 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr); 330 read_phy(lp, lp->phy_address, MII_DSINTR_REG, &dsintr);
333 dsintr = dsintr | 0xf00; /* set bits 8..11 */ 331 dsintr = dsintr | 0xf00; /* set bits 8..11 */
334 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr); 332 write_phy(lp, lp->phy_address, MII_DSINTR_REG, dsintr);
335 } 333 }
336 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */ 334 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
337 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr); 335 read_phy(lp, lp->phy_address, MII_ISINTE_REG, &dsintr);
338 dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */ 336 dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */
339 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr); 337 write_phy(lp, lp->phy_address, MII_ISINTE_REG, dsintr);
340 } 338 }
341 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */ 339 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
342 read_phy(lp->phy_address, MII_BCMINTR_REG, &dsintr); 340 read_phy(lp, lp->phy_address, MII_BCMINTR_REG, &dsintr);
343 dsintr = ~(1 << 14); 341 dsintr = ~(1 << 14);
344 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr); 342 write_phy(lp, lp->phy_address, MII_BCMINTR_REG, dsintr);
345 } 343 }
346 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */ 344 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
347 read_phy(lp->phy_address, MII_TPISTATUS, &dsintr); 345 read_phy(lp, lp->phy_address, MII_TPISTATUS, &dsintr);
348 dsintr = ~((1 << 10) | (1 << 8)); 346 dsintr = ~((1 << 10) | (1 << 8));
349 write_phy(lp->phy_address, MII_TPISTATUS, dsintr); 347 write_phy(lp, lp->phy_address, MII_TPISTATUS, dsintr);
350 } 348 }
351 else if (lp->phy_type == MII_T78Q21x3_ID) { /* for Teridian PHY */ 349 else if (lp->phy_type == MII_T78Q21x3_ID) { /* for Teridian PHY */
352 read_phy(lp->phy_address, MII_T78Q21INT_REG, &dsintr); 350 read_phy(lp, lp->phy_address, MII_T78Q21INT_REG, &dsintr);
353 dsintr = dsintr & ~0x500; /* clear bits 8, 10 */ 351 dsintr = dsintr & ~0x500; /* clear bits 8, 10 */
354 write_phy(lp->phy_address, MII_T78Q21INT_REG, dsintr); 352 write_phy(lp, lp->phy_address, MII_T78Q21INT_REG, dsintr);
355 } 353 }
356 else if (lp->phy_type == MII_DP83848_ID) { /* National Semiconductor DP83848 PHY */ 354 else if (lp->phy_type == MII_DP83848_ID) { /* National Semiconductor DP83848 PHY */
357 read_phy(lp->phy_address, MII_DPMICR_REG, &dsintr); 355 read_phy(lp, lp->phy_address, MII_DPMICR_REG, &dsintr);
358 dsintr = dsintr & ~0x3; /* clear bits 0, 1 */ 356 dsintr = dsintr & ~0x3; /* clear bits 0, 1 */
359 write_phy(lp->phy_address, MII_DPMICR_REG, dsintr); 357 write_phy(lp, lp->phy_address, MII_DPMICR_REG, dsintr);
360 read_phy(lp->phy_address, MII_DPMISR_REG, &dsintr); 358 read_phy(lp, lp->phy_address, MII_DPMISR_REG, &dsintr);
361 dsintr = dsintr & ~0x3c; /* clear bits 2..5 */ 359 dsintr = dsintr & ~0x3c; /* clear bits 2..5 */
362 write_phy(lp->phy_address, MII_DPMISR_REG, dsintr); 360 write_phy(lp, lp->phy_address, MII_DPMISR_REG, dsintr);
363 } 361 }
364 362
365 disable_mdi(); 363 disable_mdi(lp);
366 spin_unlock_irq(&lp->lock); 364 spin_unlock_irq(&lp->lock);
367 365
368 irq_number = lp->board_data.phy_irq_pin; 366 irq_number = lp->board_data.phy_irq_pin;
@@ -379,17 +377,17 @@ static void reset_phy(struct net_device *dev)
379 unsigned int bmcr; 377 unsigned int bmcr;
380 378
381 spin_lock_irq(&lp->lock); 379 spin_lock_irq(&lp->lock);
382 enable_mdi(); 380 enable_mdi(lp);
383 381
384 /* Perform PHY reset */ 382 /* Perform PHY reset */
385 write_phy(lp->phy_address, MII_BMCR, BMCR_RESET); 383 write_phy(lp, lp->phy_address, MII_BMCR, BMCR_RESET);
386 384
387 /* Wait until PHY reset is complete */ 385 /* Wait until PHY reset is complete */
388 do { 386 do {
389 read_phy(lp->phy_address, MII_BMCR, &bmcr); 387 read_phy(lp, lp->phy_address, MII_BMCR, &bmcr);
390 } while (!(bmcr & BMCR_RESET)); 388 } while (!(bmcr & BMCR_RESET));
391 389
392 disable_mdi(); 390 disable_mdi(lp);
393 spin_unlock_irq(&lp->lock); 391 spin_unlock_irq(&lp->lock);
394} 392}
395#endif 393#endif
@@ -399,13 +397,37 @@ static void at91ether_check_link(unsigned long dev_id)
399 struct net_device *dev = (struct net_device *) dev_id; 397 struct net_device *dev = (struct net_device *) dev_id;
400 struct at91_private *lp = netdev_priv(dev); 398 struct at91_private *lp = netdev_priv(dev);
401 399
402 enable_mdi(); 400 enable_mdi(lp);
403 update_linkspeed(dev, 1); 401 update_linkspeed(dev, 1);
404 disable_mdi(); 402 disable_mdi(lp);
405 403
406 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL); 404 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
407} 405}
408 406
407/*
408 * Perform any PHY-specific initialization.
409 */
410static void __init initialize_phy(struct at91_private *lp)
411{
412 unsigned int val;
413
414 spin_lock_irq(&lp->lock);
415 enable_mdi(lp);
416
417 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
418 read_phy(lp, lp->phy_address, MII_DSCR_REG, &val);
419 if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */
420 lp->phy_media = PORT_FIBRE;
421 } else if (machine_is_csb337()) {
422 /* mix link activity status into LED2 link state */
423 write_phy(lp, lp->phy_address, MII_LEDCTRL_REG, 0x0d22);
424 } else if (machine_is_ecbat91())
425 write_phy(lp, lp->phy_address, MII_LEDCTRL_REG, 0x156A);
426
427 disable_mdi(lp);
428 spin_unlock_irq(&lp->lock);
429}
430
409/* ......................... ADDRESS MANAGEMENT ........................ */ 431/* ......................... ADDRESS MANAGEMENT ........................ */
410 432
411/* 433/*
@@ -454,17 +476,19 @@ static short __init unpack_mac_address(struct net_device *dev, unsigned int hi,
454 */ 476 */
455static void __init get_mac_address(struct net_device *dev) 477static void __init get_mac_address(struct net_device *dev)
456{ 478{
479 struct at91_private *lp = netdev_priv(dev);
480
457 /* Check Specific-Address 1 */ 481 /* Check Specific-Address 1 */
458 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA1H), at91_emac_read(AT91_EMAC_SA1L))) 482 if (unpack_mac_address(dev, at91_emac_read(lp, AT91_EMAC_SA1H), at91_emac_read(lp, AT91_EMAC_SA1L)))
459 return; 483 return;
460 /* Check Specific-Address 2 */ 484 /* Check Specific-Address 2 */
461 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA2H), at91_emac_read(AT91_EMAC_SA2L))) 485 if (unpack_mac_address(dev, at91_emac_read(lp, AT91_EMAC_SA2H), at91_emac_read(lp, AT91_EMAC_SA2L)))
462 return; 486 return;
463 /* Check Specific-Address 3 */ 487 /* Check Specific-Address 3 */
464 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA3H), at91_emac_read(AT91_EMAC_SA3L))) 488 if (unpack_mac_address(dev, at91_emac_read(lp, AT91_EMAC_SA3H), at91_emac_read(lp, AT91_EMAC_SA3L)))
465 return; 489 return;
466 /* Check Specific-Address 4 */ 490 /* Check Specific-Address 4 */
467 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA4H), at91_emac_read(AT91_EMAC_SA4L))) 491 if (unpack_mac_address(dev, at91_emac_read(lp, AT91_EMAC_SA4H), at91_emac_read(lp, AT91_EMAC_SA4L)))
468 return; 492 return;
469 493
470 printk(KERN_ERR "at91_ether: Your bootloader did not configure a MAC address.\n"); 494 printk(KERN_ERR "at91_ether: Your bootloader did not configure a MAC address.\n");
@@ -475,11 +499,13 @@ static void __init get_mac_address(struct net_device *dev)
475 */ 499 */
476static void update_mac_address(struct net_device *dev) 500static void update_mac_address(struct net_device *dev)
477{ 501{
478 at91_emac_write(AT91_EMAC_SA1L, (dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) | (dev->dev_addr[1] << 8) | (dev->dev_addr[0])); 502 struct at91_private *lp = netdev_priv(dev);
479 at91_emac_write(AT91_EMAC_SA1H, (dev->dev_addr[5] << 8) | (dev->dev_addr[4]));
480 503
481 at91_emac_write(AT91_EMAC_SA2L, 0); 504 at91_emac_write(lp, AT91_EMAC_SA1L, (dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) | (dev->dev_addr[1] << 8) | (dev->dev_addr[0]));
482 at91_emac_write(AT91_EMAC_SA2H, 0); 505 at91_emac_write(lp, AT91_EMAC_SA1H, (dev->dev_addr[5] << 8) | (dev->dev_addr[4]));
506
507 at91_emac_write(lp, AT91_EMAC_SA2L, 0);
508 at91_emac_write(lp, AT91_EMAC_SA2H, 0);
483} 509}
484 510
485/* 511/*
@@ -559,6 +585,7 @@ static int hash_get_index(__u8 *addr)
559 */ 585 */
560static void at91ether_sethashtable(struct net_device *dev) 586static void at91ether_sethashtable(struct net_device *dev)
561{ 587{
588 struct at91_private *lp = netdev_priv(dev);
562 struct netdev_hw_addr *ha; 589 struct netdev_hw_addr *ha;
563 unsigned long mc_filter[2]; 590 unsigned long mc_filter[2];
564 unsigned int bitnr; 591 unsigned int bitnr;
@@ -570,8 +597,8 @@ static void at91ether_sethashtable(struct net_device *dev)
570 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 597 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
571 } 598 }
572 599
573 at91_emac_write(AT91_EMAC_HSL, mc_filter[0]); 600 at91_emac_write(lp, AT91_EMAC_HSL, mc_filter[0]);
574 at91_emac_write(AT91_EMAC_HSH, mc_filter[1]); 601 at91_emac_write(lp, AT91_EMAC_HSH, mc_filter[1]);
575} 602}
576 603
577/* 604/*
@@ -579,9 +606,10 @@ static void at91ether_sethashtable(struct net_device *dev)
579 */ 606 */
580static void at91ether_set_multicast_list(struct net_device *dev) 607static void at91ether_set_multicast_list(struct net_device *dev)
581{ 608{
609 struct at91_private *lp = netdev_priv(dev);
582 unsigned long cfg; 610 unsigned long cfg;
583 611
584 cfg = at91_emac_read(AT91_EMAC_CFG); 612 cfg = at91_emac_read(lp, AT91_EMAC_CFG);
585 613
586 if (dev->flags & IFF_PROMISC) /* Enable promiscuous mode */ 614 if (dev->flags & IFF_PROMISC) /* Enable promiscuous mode */
587 cfg |= AT91_EMAC_CAF; 615 cfg |= AT91_EMAC_CAF;
@@ -589,34 +617,37 @@ static void at91ether_set_multicast_list(struct net_device *dev)
589 cfg &= ~AT91_EMAC_CAF; 617 cfg &= ~AT91_EMAC_CAF;
590 618
591 if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */ 619 if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */
592 at91_emac_write(AT91_EMAC_HSH, -1); 620 at91_emac_write(lp, AT91_EMAC_HSH, -1);
593 at91_emac_write(AT91_EMAC_HSL, -1); 621 at91_emac_write(lp, AT91_EMAC_HSL, -1);
594 cfg |= AT91_EMAC_MTI; 622 cfg |= AT91_EMAC_MTI;
595 } else if (!netdev_mc_empty(dev)) { /* Enable specific multicasts */ 623 } else if (!netdev_mc_empty(dev)) { /* Enable specific multicasts */
596 at91ether_sethashtable(dev); 624 at91ether_sethashtable(dev);
597 cfg |= AT91_EMAC_MTI; 625 cfg |= AT91_EMAC_MTI;
598 } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */ 626 } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
599 at91_emac_write(AT91_EMAC_HSH, 0); 627 at91_emac_write(lp, AT91_EMAC_HSH, 0);
600 at91_emac_write(AT91_EMAC_HSL, 0); 628 at91_emac_write(lp, AT91_EMAC_HSL, 0);
601 cfg &= ~AT91_EMAC_MTI; 629 cfg &= ~AT91_EMAC_MTI;
602 } 630 }
603 631
604 at91_emac_write(AT91_EMAC_CFG, cfg); 632 at91_emac_write(lp, AT91_EMAC_CFG, cfg);
605} 633}
606 634
607/* ......................... ETHTOOL SUPPORT ........................... */ 635/* ......................... ETHTOOL SUPPORT ........................... */
608 636
609static int mdio_read(struct net_device *dev, int phy_id, int location) 637static int mdio_read(struct net_device *dev, int phy_id, int location)
610{ 638{
639 struct at91_private *lp = netdev_priv(dev);
611 unsigned int value; 640 unsigned int value;
612 641
613 read_phy(phy_id, location, &value); 642 read_phy(lp, phy_id, location, &value);
614 return value; 643 return value;
615} 644}
616 645
617static void mdio_write(struct net_device *dev, int phy_id, int location, int value) 646static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
618{ 647{
619 write_phy(phy_id, location, value); 648 struct at91_private *lp = netdev_priv(dev);
649
650 write_phy(lp, phy_id, location, value);
620} 651}
621 652
622static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 653static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -625,11 +656,11 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm
625 int ret; 656 int ret;
626 657
627 spin_lock_irq(&lp->lock); 658 spin_lock_irq(&lp->lock);
628 enable_mdi(); 659 enable_mdi(lp);
629 660
630 ret = mii_ethtool_gset(&lp->mii, cmd); 661 ret = mii_ethtool_gset(&lp->mii, cmd);
631 662
632 disable_mdi(); 663 disable_mdi(lp);
633 spin_unlock_irq(&lp->lock); 664 spin_unlock_irq(&lp->lock);
634 665
635 if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */ 666 if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */
@@ -646,11 +677,11 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm
646 int ret; 677 int ret;
647 678
648 spin_lock_irq(&lp->lock); 679 spin_lock_irq(&lp->lock);
649 enable_mdi(); 680 enable_mdi(lp);
650 681
651 ret = mii_ethtool_sset(&lp->mii, cmd); 682 ret = mii_ethtool_sset(&lp->mii, cmd);
652 683
653 disable_mdi(); 684 disable_mdi(lp);
654 spin_unlock_irq(&lp->lock); 685 spin_unlock_irq(&lp->lock);
655 686
656 return ret; 687 return ret;
@@ -662,11 +693,11 @@ static int at91ether_nwayreset(struct net_device *dev)
662 int ret; 693 int ret;
663 694
664 spin_lock_irq(&lp->lock); 695 spin_lock_irq(&lp->lock);
665 enable_mdi(); 696 enable_mdi(lp);
666 697
667 ret = mii_nway_restart(&lp->mii); 698 ret = mii_nway_restart(&lp->mii);
668 699
669 disable_mdi(); 700 disable_mdi(lp);
670 spin_unlock_irq(&lp->lock); 701 spin_unlock_irq(&lp->lock);
671 702
672 return ret; 703 return ret;
@@ -696,9 +727,9 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
696 return -EINVAL; 727 return -EINVAL;
697 728
698 spin_lock_irq(&lp->lock); 729 spin_lock_irq(&lp->lock);
699 enable_mdi(); 730 enable_mdi(lp);
700 res = generic_mii_ioctl(&lp->mii, if_mii(rq), cmd, NULL); 731 res = generic_mii_ioctl(&lp->mii, if_mii(rq), cmd, NULL);
701 disable_mdi(); 732 disable_mdi(lp);
702 spin_unlock_irq(&lp->lock); 733 spin_unlock_irq(&lp->lock);
703 734
704 return res; 735 return res;
@@ -731,11 +762,11 @@ static void at91ether_start(struct net_device *dev)
731 lp->rxBuffIndex = 0; 762 lp->rxBuffIndex = 0;
732 763
733 /* Program address of descriptor list in Rx Buffer Queue register */ 764 /* Program address of descriptor list in Rx Buffer Queue register */
734 at91_emac_write(AT91_EMAC_RBQP, (unsigned long) dlist_phys); 765 at91_emac_write(lp, AT91_EMAC_RBQP, (unsigned long) dlist_phys);
735 766
736 /* Enable Receive and Transmit */ 767 /* Enable Receive and Transmit */
737 ctl = at91_emac_read(AT91_EMAC_CTL); 768 ctl = at91_emac_read(lp, AT91_EMAC_CTL);
738 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE | AT91_EMAC_TE); 769 at91_emac_write(lp, AT91_EMAC_CTL, ctl | AT91_EMAC_RE | AT91_EMAC_TE);
739} 770}
740 771
741/* 772/*
@@ -752,8 +783,8 @@ static int at91ether_open(struct net_device *dev)
752 clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */ 783 clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */
753 784
754 /* Clear internal statistics */ 785 /* Clear internal statistics */
755 ctl = at91_emac_read(AT91_EMAC_CTL); 786 ctl = at91_emac_read(lp, AT91_EMAC_CTL);
756 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_CSR); 787 at91_emac_write(lp, AT91_EMAC_CTL, ctl | AT91_EMAC_CSR);
757 788
758 /* Update the MAC address (incase user has changed it) */ 789 /* Update the MAC address (incase user has changed it) */
759 update_mac_address(dev); 790 update_mac_address(dev);
@@ -762,15 +793,15 @@ static int at91ether_open(struct net_device *dev)
762 enable_phyirq(dev); 793 enable_phyirq(dev);
763 794
764 /* Enable MAC interrupts */ 795 /* Enable MAC interrupts */
765 at91_emac_write(AT91_EMAC_IER, AT91_EMAC_RCOM | AT91_EMAC_RBNA 796 at91_emac_write(lp, AT91_EMAC_IER, AT91_EMAC_RCOM | AT91_EMAC_RBNA
766 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM 797 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
767 | AT91_EMAC_ROVR | AT91_EMAC_ABT); 798 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
768 799
769 /* Determine current link speed */ 800 /* Determine current link speed */
770 spin_lock_irq(&lp->lock); 801 spin_lock_irq(&lp->lock);
771 enable_mdi(); 802 enable_mdi(lp);
772 update_linkspeed(dev, 0); 803 update_linkspeed(dev, 0);
773 disable_mdi(); 804 disable_mdi(lp);
774 spin_unlock_irq(&lp->lock); 805 spin_unlock_irq(&lp->lock);
775 806
776 at91ether_start(dev); 807 at91ether_start(dev);
@@ -787,14 +818,14 @@ static int at91ether_close(struct net_device *dev)
787 unsigned long ctl; 818 unsigned long ctl;
788 819
789 /* Disable Receiver and Transmitter */ 820 /* Disable Receiver and Transmitter */
790 ctl = at91_emac_read(AT91_EMAC_CTL); 821 ctl = at91_emac_read(lp, AT91_EMAC_CTL);
791 at91_emac_write(AT91_EMAC_CTL, ctl & ~(AT91_EMAC_TE | AT91_EMAC_RE)); 822 at91_emac_write(lp, AT91_EMAC_CTL, ctl & ~(AT91_EMAC_TE | AT91_EMAC_RE));
792 823
793 /* Disable PHY interrupt */ 824 /* Disable PHY interrupt */
794 disable_phyirq(dev); 825 disable_phyirq(dev);
795 826
796 /* Disable MAC interrupts */ 827 /* Disable MAC interrupts */
797 at91_emac_write(AT91_EMAC_IDR, AT91_EMAC_RCOM | AT91_EMAC_RBNA 828 at91_emac_write(lp, AT91_EMAC_IDR, AT91_EMAC_RCOM | AT91_EMAC_RBNA
798 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM 829 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
799 | AT91_EMAC_ROVR | AT91_EMAC_ABT); 830 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
800 831
@@ -812,7 +843,7 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
812{ 843{
813 struct at91_private *lp = netdev_priv(dev); 844 struct at91_private *lp = netdev_priv(dev);
814 845
815 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) { 846 if (at91_emac_read(lp, AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
816 netif_stop_queue(dev); 847 netif_stop_queue(dev);
817 848
818 /* Store packet information (to free when Tx completed) */ 849 /* Store packet information (to free when Tx completed) */
@@ -822,9 +853,9 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
822 dev->stats.tx_bytes += skb->len; 853 dev->stats.tx_bytes += skb->len;
823 854
824 /* Set address of the data in the Transmit Address register */ 855 /* Set address of the data in the Transmit Address register */
825 at91_emac_write(AT91_EMAC_TAR, lp->skb_physaddr); 856 at91_emac_write(lp, AT91_EMAC_TAR, lp->skb_physaddr);
826 /* Set length of the packet in the Transmit Control register */ 857 /* Set length of the packet in the Transmit Control register */
827 at91_emac_write(AT91_EMAC_TCR, skb->len); 858 at91_emac_write(lp, AT91_EMAC_TCR, skb->len);
828 859
829 } else { 860 } else {
830 printk(KERN_ERR "at91_ether.c: at91ether_start_xmit() called, but device is busy!\n"); 861 printk(KERN_ERR "at91_ether.c: at91ether_start_xmit() called, but device is busy!\n");
@@ -841,31 +872,32 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
841 */ 872 */
842static struct net_device_stats *at91ether_stats(struct net_device *dev) 873static struct net_device_stats *at91ether_stats(struct net_device *dev)
843{ 874{
875 struct at91_private *lp = netdev_priv(dev);
844 int ale, lenerr, seqe, lcol, ecol; 876 int ale, lenerr, seqe, lcol, ecol;
845 877
846 if (netif_running(dev)) { 878 if (netif_running(dev)) {
847 dev->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */ 879 dev->stats.rx_packets += at91_emac_read(lp, AT91_EMAC_OK); /* Good frames received */
848 ale = at91_emac_read(AT91_EMAC_ALE); 880 ale = at91_emac_read(lp, AT91_EMAC_ALE);
849 dev->stats.rx_frame_errors += ale; /* Alignment errors */ 881 dev->stats.rx_frame_errors += ale; /* Alignment errors */
850 lenerr = at91_emac_read(AT91_EMAC_ELR) + at91_emac_read(AT91_EMAC_USF); 882 lenerr = at91_emac_read(lp, AT91_EMAC_ELR) + at91_emac_read(lp, AT91_EMAC_USF);
851 dev->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */ 883 dev->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
852 seqe = at91_emac_read(AT91_EMAC_SEQE); 884 seqe = at91_emac_read(lp, AT91_EMAC_SEQE);
853 dev->stats.rx_crc_errors += seqe; /* CRC error */ 885 dev->stats.rx_crc_errors += seqe; /* CRC error */
854 dev->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */ 886 dev->stats.rx_fifo_errors += at91_emac_read(lp, AT91_EMAC_DRFC);/* Receive buffer not available */
855 dev->stats.rx_errors += (ale + lenerr + seqe 887 dev->stats.rx_errors += (ale + lenerr + seqe
856 + at91_emac_read(AT91_EMAC_CDE) + at91_emac_read(AT91_EMAC_RJB)); 888 + at91_emac_read(lp, AT91_EMAC_CDE) + at91_emac_read(lp, AT91_EMAC_RJB));
857 889
858 dev->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */ 890 dev->stats.tx_packets += at91_emac_read(lp, AT91_EMAC_FRA); /* Frames successfully transmitted */
859 dev->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */ 891 dev->stats.tx_fifo_errors += at91_emac_read(lp, AT91_EMAC_TUE); /* Transmit FIFO underruns */
860 dev->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */ 892 dev->stats.tx_carrier_errors += at91_emac_read(lp, AT91_EMAC_CSE); /* Carrier Sense errors */
861 dev->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */ 893 dev->stats.tx_heartbeat_errors += at91_emac_read(lp, AT91_EMAC_SQEE);/* Heartbeat error */
862 894
863 lcol = at91_emac_read(AT91_EMAC_LCOL); 895 lcol = at91_emac_read(lp, AT91_EMAC_LCOL);
864 ecol = at91_emac_read(AT91_EMAC_ECOL); 896 ecol = at91_emac_read(lp, AT91_EMAC_ECOL);
865 dev->stats.tx_window_errors += lcol; /* Late collisions */ 897 dev->stats.tx_window_errors += lcol; /* Late collisions */
866 dev->stats.tx_aborted_errors += ecol; /* 16 collisions */ 898 dev->stats.tx_aborted_errors += ecol; /* 16 collisions */
867 899
868 dev->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + lcol + ecol); 900 dev->stats.collisions += (at91_emac_read(lp, AT91_EMAC_SCOL) + at91_emac_read(lp, AT91_EMAC_MCOL) + lcol + ecol);
869 } 901 }
870 return &dev->stats; 902 return &dev->stats;
871} 903}
@@ -922,7 +954,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
922 954
923 /* MAC Interrupt Status register indicates what interrupts are pending. 955 /* MAC Interrupt Status register indicates what interrupts are pending.
924 It is automatically cleared once read. */ 956 It is automatically cleared once read. */
925 intstatus = at91_emac_read(AT91_EMAC_ISR); 957 intstatus = at91_emac_read(lp, AT91_EMAC_ISR);
926 958
927 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */ 959 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */
928 at91ether_rx(dev); 960 at91ether_rx(dev);
@@ -942,9 +974,9 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
942 974
943 /* Work-around for Errata #11 */ 975 /* Work-around for Errata #11 */
944 if (intstatus & AT91_EMAC_RBNA) { 976 if (intstatus & AT91_EMAC_RBNA) {
945 ctl = at91_emac_read(AT91_EMAC_CTL); 977 ctl = at91_emac_read(lp, AT91_EMAC_CTL);
946 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_RE); 978 at91_emac_write(lp, AT91_EMAC_CTL, ctl & ~AT91_EMAC_RE);
947 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE); 979 at91_emac_write(lp, AT91_EMAC_CTL, ctl | AT91_EMAC_RE);
948 } 980 }
949 981
950 if (intstatus & AT91_EMAC_ROVR) 982 if (intstatus & AT91_EMAC_ROVR)
@@ -980,189 +1012,199 @@ static const struct net_device_ops at91ether_netdev_ops = {
980}; 1012};
981 1013
982/* 1014/*
983 * Initialize the ethernet interface 1015 * Detect the PHY type, and its address.
984 */ 1016 */
985static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, 1017static int __init at91ether_phy_detect(struct at91_private *lp)
986 struct platform_device *pdev, struct clk *ether_clk) 1018{
1019 unsigned int phyid1, phyid2;
1020 unsigned long phy_id;
1021 unsigned short phy_address = 0;
1022
1023 while (phy_address < PHY_MAX_ADDR) {
1024 /* Read the PHY ID registers */
1025 enable_mdi(lp);
1026 read_phy(lp, phy_address, MII_PHYSID1, &phyid1);
1027 read_phy(lp, phy_address, MII_PHYSID2, &phyid2);
1028 disable_mdi(lp);
1029
1030 phy_id = (phyid1 << 16) | (phyid2 & 0xfff0);
1031 switch (phy_id) {
1032 case MII_DM9161_ID: /* Davicom 9161: PHY_ID1 = 0x181, PHY_ID2 = B881 */
1033 case MII_DM9161A_ID: /* Davicom 9161A: PHY_ID1 = 0x181, PHY_ID2 = B8A0 */
1034 case MII_LXT971A_ID: /* Intel LXT971A: PHY_ID1 = 0x13, PHY_ID2 = 78E0 */
1035 case MII_RTL8201_ID: /* Realtek RTL8201: PHY_ID1 = 0, PHY_ID2 = 0x8201 */
1036 case MII_BCM5221_ID: /* Broadcom BCM5221: PHY_ID1 = 0x40, PHY_ID2 = 0x61e0 */
1037 case MII_DP83847_ID: /* National Semiconductor DP83847: */
1038 case MII_DP83848_ID: /* National Semiconductor DP83848: */
1039 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
1040 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
1041 case MII_T78Q21x3_ID: /* Teridian 78Q21x3: PHY_ID1 = 0x0E, PHY_ID2 = 7237 */
1042 case MII_LAN83C185_ID: /* SMSC LAN83C185: PHY_ID1 = 0x0007, PHY_ID2 = 0xC0A1 */
1043 /* store detected values */
1044 lp->phy_type = phy_id; /* Type of PHY connected */
1045 lp->phy_address = phy_address; /* MDI address of PHY */
1046 return 1;
1047 }
1048
1049 phy_address++;
1050 }
1051
1052 return 0; /* not detected */
1053}
1054
1055
1056/*
1057 * Detect MAC & PHY and perform ethernet interface initialization
1058 */
1059static int __init at91ether_probe(struct platform_device *pdev)
987{ 1060{
988 struct macb_platform_data *board_data = pdev->dev.platform_data; 1061 struct macb_platform_data *board_data = pdev->dev.platform_data;
1062 struct resource *regs;
989 struct net_device *dev; 1063 struct net_device *dev;
990 struct at91_private *lp; 1064 struct at91_private *lp;
991 unsigned int val;
992 int res; 1065 int res;
993 1066
1067 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1068 if (!regs)
1069 return -ENOENT;
1070
994 dev = alloc_etherdev(sizeof(struct at91_private)); 1071 dev = alloc_etherdev(sizeof(struct at91_private));
995 if (!dev) 1072 if (!dev)
996 return -ENOMEM; 1073 return -ENOMEM;
997 1074
998 dev->base_addr = AT91_VA_BASE_EMAC; 1075 lp = netdev_priv(dev);
999 dev->irq = AT91RM9200_ID_EMAC; 1076 lp->board_data = *board_data;
1077 spin_lock_init(&lp->lock);
1078
1079 dev->base_addr = regs->start; /* physical base address */
1080 lp->emac_base = ioremap(regs->start, regs->end - regs->start + 1);
1081 if (!lp->emac_base) {
1082 res = -ENOMEM;
1083 goto err_free_dev;
1084 }
1085
1086 /* Clock */
1087 lp->ether_clk = clk_get(&pdev->dev, "ether_clk");
1088 if (IS_ERR(lp->ether_clk)) {
1089 res = -ENODEV;
1090 goto err_ioumap;
1091 }
1092 clk_enable(lp->ether_clk);
1000 1093
1001 /* Install the interrupt handler */ 1094 /* Install the interrupt handler */
1095 dev->irq = platform_get_irq(pdev, 0);
1002 if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) { 1096 if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) {
1003 free_netdev(dev); 1097 res = -EBUSY;
1004 return -EBUSY; 1098 goto err_disable_clock;
1005 } 1099 }
1006 1100
1007 /* Allocate memory for DMA Receive descriptors */ 1101 /* Allocate memory for DMA Receive descriptors */
1008 lp = netdev_priv(dev);
1009 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL); 1102 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
1010 if (lp->dlist == NULL) { 1103 if (lp->dlist == NULL) {
1011 free_irq(dev->irq, dev); 1104 res = -ENOMEM;
1012 free_netdev(dev); 1105 goto err_free_irq;
1013 return -ENOMEM;
1014 } 1106 }
1015 lp->board_data = *board_data;
1016 lp->ether_clk = ether_clk;
1017 platform_set_drvdata(pdev, dev);
1018
1019 spin_lock_init(&lp->lock);
1020 1107
1021 ether_setup(dev); 1108 ether_setup(dev);
1022 dev->netdev_ops = &at91ether_netdev_ops; 1109 dev->netdev_ops = &at91ether_netdev_ops;
1023 dev->ethtool_ops = &at91ether_ethtool_ops; 1110 dev->ethtool_ops = &at91ether_ethtool_ops;
1024 1111 platform_set_drvdata(pdev, dev);
1025 SET_NETDEV_DEV(dev, &pdev->dev); 1112 SET_NETDEV_DEV(dev, &pdev->dev);
1026 1113
1027 get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */ 1114 get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */
1028 update_mac_address(dev); /* Program ethernet address into MAC */ 1115 update_mac_address(dev); /* Program ethernet address into MAC */
1029 1116
1030 at91_emac_write(AT91_EMAC_CTL, 0); 1117 at91_emac_write(lp, AT91_EMAC_CTL, 0);
1031 1118
1032 if (lp->board_data.is_rmii) 1119 if (board_data->is_rmii)
1033 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG | AT91_EMAC_RMII); 1120 at91_emac_write(lp, AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG | AT91_EMAC_RMII);
1034 else 1121 else
1035 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG); 1122 at91_emac_write(lp, AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG);
1036 1123
1037 /* Perform PHY-specific initialization */ 1124 /* Detect PHY */
1038 spin_lock_irq(&lp->lock); 1125 if (!at91ether_phy_detect(lp)) {
1039 enable_mdi(); 1126 printk(KERN_ERR "at91_ether: Could not detect ethernet PHY\n");
1040 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { 1127 res = -ENODEV;
1041 read_phy(phy_address, MII_DSCR_REG, &val); 1128 goto err_free_dmamem;
1042 if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */ 1129 }
1043 lp->phy_media = PORT_FIBRE;
1044 } else if (machine_is_csb337()) {
1045 /* mix link activity status into LED2 link state */
1046 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
1047 } else if (machine_is_ecbat91())
1048 write_phy(phy_address, MII_LEDCTRL_REG, 0x156A);
1049 1130
1050 disable_mdi(); 1131 initialize_phy(lp);
1051 spin_unlock_irq(&lp->lock);
1052 1132
1053 lp->mii.dev = dev; /* Support for ethtool */ 1133 lp->mii.dev = dev; /* Support for ethtool */
1054 lp->mii.mdio_read = mdio_read; 1134 lp->mii.mdio_read = mdio_read;
1055 lp->mii.mdio_write = mdio_write; 1135 lp->mii.mdio_write = mdio_write;
1056 lp->mii.phy_id = phy_address; 1136 lp->mii.phy_id = lp->phy_address;
1057 lp->mii.phy_id_mask = 0x1f; 1137 lp->mii.phy_id_mask = 0x1f;
1058 lp->mii.reg_num_mask = 0x1f; 1138 lp->mii.reg_num_mask = 0x1f;
1059 1139
1060 lp->phy_type = phy_type; /* Type of PHY connected */
1061 lp->phy_address = phy_address; /* MDI address of PHY */
1062
1063 /* Register the network interface */ 1140 /* Register the network interface */
1064 res = register_netdev(dev); 1141 res = register_netdev(dev);
1065 if (res) { 1142 if (res)
1066 free_irq(dev->irq, dev); 1143 goto err_free_dmamem;
1067 free_netdev(dev);
1068 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1069 return res;
1070 }
1071 1144
1072 /* Determine current link speed */ 1145 /* Determine current link speed */
1073 spin_lock_irq(&lp->lock); 1146 spin_lock_irq(&lp->lock);
1074 enable_mdi(); 1147 enable_mdi(lp);
1075 update_linkspeed(dev, 0); 1148 update_linkspeed(dev, 0);
1076 disable_mdi(); 1149 disable_mdi(lp);
1077 spin_unlock_irq(&lp->lock); 1150 spin_unlock_irq(&lp->lock);
1078 netif_carrier_off(dev); /* will be enabled in open() */ 1151 netif_carrier_off(dev); /* will be enabled in open() */
1079 1152
1080 /* If board has no PHY IRQ, use a timer to poll the PHY */ 1153 /* If board has no PHY IRQ, use a timer to poll the PHY */
1081 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) { 1154 if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
1155 gpio_request(board_data->phy_irq_pin, "ethernet_phy");
1156 } else {
1157 /* If board has no PHY IRQ, use a timer to poll the PHY */
1082 init_timer(&lp->check_timer); 1158 init_timer(&lp->check_timer);
1083 lp->check_timer.data = (unsigned long)dev; 1159 lp->check_timer.data = (unsigned long)dev;
1084 lp->check_timer.function = at91ether_check_link; 1160 lp->check_timer.function = at91ether_check_link;
1085 } else if (lp->board_data.phy_irq_pin >= 32) 1161 }
1086 gpio_request(lp->board_data.phy_irq_pin, "ethernet_phy");
1087 1162
1088 /* Display ethernet banner */ 1163 /* Display ethernet banner */
1089 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%pM)\n", 1164 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%pM)\n",
1090 dev->name, (uint) dev->base_addr, dev->irq, 1165 dev->name, (uint) dev->base_addr, dev->irq,
1091 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-", 1166 at91_emac_read(lp, AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-",
1092 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex", 1167 at91_emac_read(lp, AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex",
1093 dev->dev_addr); 1168 dev->dev_addr);
1094 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) 1169 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
1095 printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); 1170 printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
1096 else if (phy_type == MII_LXT971A_ID) 1171 else if (lp->phy_type == MII_LXT971A_ID)
1097 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); 1172 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
1098 else if (phy_type == MII_RTL8201_ID) 1173 else if (lp->phy_type == MII_RTL8201_ID)
1099 printk(KERN_INFO "%s: Realtek RTL8201(B)L PHY\n", dev->name); 1174 printk(KERN_INFO "%s: Realtek RTL8201(B)L PHY\n", dev->name);
1100 else if (phy_type == MII_BCM5221_ID) 1175 else if (lp->phy_type == MII_BCM5221_ID)
1101 printk(KERN_INFO "%s: Broadcom BCM5221 PHY\n", dev->name); 1176 printk(KERN_INFO "%s: Broadcom BCM5221 PHY\n", dev->name);
1102 else if (phy_type == MII_DP83847_ID) 1177 else if (lp->phy_type == MII_DP83847_ID)
1103 printk(KERN_INFO "%s: National Semiconductor DP83847 PHY\n", dev->name); 1178 printk(KERN_INFO "%s: National Semiconductor DP83847 PHY\n", dev->name);
1104 else if (phy_type == MII_DP83848_ID) 1179 else if (lp->phy_type == MII_DP83848_ID)
1105 printk(KERN_INFO "%s: National Semiconductor DP83848 PHY\n", dev->name); 1180 printk(KERN_INFO "%s: National Semiconductor DP83848 PHY\n", dev->name);
1106 else if (phy_type == MII_AC101L_ID) 1181 else if (lp->phy_type == MII_AC101L_ID)
1107 printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name); 1182 printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name);
1108 else if (phy_type == MII_KS8721_ID) 1183 else if (lp->phy_type == MII_KS8721_ID)
1109 printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name); 1184 printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name);
1110 else if (phy_type == MII_T78Q21x3_ID) 1185 else if (lp->phy_type == MII_T78Q21x3_ID)
1111 printk(KERN_INFO "%s: Teridian 78Q21x3 PHY\n", dev->name); 1186 printk(KERN_INFO "%s: Teridian 78Q21x3 PHY\n", dev->name);
1112 else if (phy_type == MII_LAN83C185_ID) 1187 else if (lp->phy_type == MII_LAN83C185_ID)
1113 printk(KERN_INFO "%s: SMSC LAN83C185 PHY\n", dev->name); 1188 printk(KERN_INFO "%s: SMSC LAN83C185 PHY\n", dev->name);
1114 1189
1115 return 0; 1190 clk_disable(lp->ether_clk); /* Disable Peripheral clock */
1116}
1117
1118/*
1119 * Detect MAC and PHY and perform initialization
1120 */
1121static int __init at91ether_probe(struct platform_device *pdev)
1122{
1123 unsigned int phyid1, phyid2;
1124 int detected = -1;
1125 unsigned long phy_id;
1126 unsigned short phy_address = 0;
1127 struct clk *ether_clk;
1128
1129 ether_clk = clk_get(&pdev->dev, "ether_clk");
1130 if (IS_ERR(ether_clk)) {
1131 printk(KERN_ERR "at91_ether: no clock defined\n");
1132 return -ENODEV;
1133 }
1134 clk_enable(ether_clk); /* Enable Peripheral clock */
1135
1136 while ((detected != 0) && (phy_address < 32)) {
1137 /* Read the PHY ID registers */
1138 enable_mdi();
1139 read_phy(phy_address, MII_PHYSID1, &phyid1);
1140 read_phy(phy_address, MII_PHYSID2, &phyid2);
1141 disable_mdi();
1142
1143 phy_id = (phyid1 << 16) | (phyid2 & 0xfff0);
1144 switch (phy_id) {
1145 case MII_DM9161_ID: /* Davicom 9161: PHY_ID1 = 0x181, PHY_ID2 = B881 */
1146 case MII_DM9161A_ID: /* Davicom 9161A: PHY_ID1 = 0x181, PHY_ID2 = B8A0 */
1147 case MII_LXT971A_ID: /* Intel LXT971A: PHY_ID1 = 0x13, PHY_ID2 = 78E0 */
1148 case MII_RTL8201_ID: /* Realtek RTL8201: PHY_ID1 = 0, PHY_ID2 = 0x8201 */
1149 case MII_BCM5221_ID: /* Broadcom BCM5221: PHY_ID1 = 0x40, PHY_ID2 = 0x61e0 */
1150 case MII_DP83847_ID: /* National Semiconductor DP83847: */
1151 case MII_DP83848_ID: /* National Semiconductor DP83848: */
1152 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
1153 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
1154 case MII_T78Q21x3_ID: /* Teridian 78Q21x3: PHY_ID1 = 0x0E, PHY_ID2 = 7237 */
1155 case MII_LAN83C185_ID: /* SMSC LAN83C185: PHY_ID1 = 0x0007, PHY_ID2 = 0xC0A1 */
1156 detected = at91ether_setup(phy_id, phy_address, pdev, ether_clk);
1157 break;
1158 }
1159 1191
1160 phy_address++; 1192 return 0;
1161 }
1162 1193
1163 clk_disable(ether_clk); /* Disable Peripheral clock */
1164 1194
1165 return detected; 1195err_free_dmamem:
1196 platform_set_drvdata(pdev, NULL);
1197 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1198err_free_irq:
1199 free_irq(dev->irq, dev);
1200err_disable_clock:
1201 clk_disable(lp->ether_clk);
1202 clk_put(lp->ether_clk);
1203err_ioumap:
1204 iounmap(lp->emac_base);
1205err_free_dev:
1206 free_netdev(dev);
1207 return res;
1166} 1208}
1167 1209
1168static int __devexit at91ether_remove(struct platform_device *pdev) 1210static int __devexit at91ether_remove(struct platform_device *pdev)
@@ -1170,8 +1212,7 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1170 struct net_device *dev = platform_get_drvdata(pdev); 1212 struct net_device *dev = platform_get_drvdata(pdev);
1171 struct at91_private *lp = netdev_priv(dev); 1213 struct at91_private *lp = netdev_priv(dev);
1172 1214
1173 if (gpio_is_valid(lp->board_data.phy_irq_pin) && 1215 if (gpio_is_valid(lp->board_data.phy_irq_pin))
1174 lp->board_data.phy_irq_pin >= 32)
1175 gpio_free(lp->board_data.phy_irq_pin); 1216 gpio_free(lp->board_data.phy_irq_pin);
1176 1217
1177 unregister_netdev(dev); 1218 unregister_netdev(dev);
diff --git a/drivers/net/ethernet/cadence/at91_ether.h b/drivers/net/ethernet/cadence/at91_ether.h
index 3725fbb0defe..0ef6328fa7f8 100644
--- a/drivers/net/ethernet/cadence/at91_ether.h
+++ b/drivers/net/ethernet/cadence/at91_ether.h
@@ -88,6 +88,7 @@ struct at91_private
88 struct macb_platform_data board_data; /* board-specific 88 struct macb_platform_data board_data; /* board-specific
89 * configuration (shared with 89 * configuration (shared with
90 * macb for common data */ 90 * macb for common data */
91 void __iomem *emac_base; /* base register address */
91 struct clk *ether_clk; /* clock */ 92 struct clk *ether_clk; /* clock */
92 93
93 /* PHY */ 94 /* PHY */