diff options
Diffstat (limited to 'drivers/net/fec.c')
-rw-r--r-- | drivers/net/fec.c | 650 |
1 files changed, 325 insertions, 325 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index cd0282d5d40f..885d8baff7d5 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -54,7 +54,7 @@ | |||
54 | 54 | ||
55 | #include "fec.h" | 55 | #include "fec.h" |
56 | 56 | ||
57 | #if defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28) | 57 | #if defined(CONFIG_ARM) |
58 | #define FEC_ALIGNMENT 0xf | 58 | #define FEC_ALIGNMENT 0xf |
59 | #else | 59 | #else |
60 | #define FEC_ALIGNMENT 0x3 | 60 | #define FEC_ALIGNMENT 0x3 |
@@ -148,8 +148,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address"); | |||
148 | * account when setting it. | 148 | * account when setting it. |
149 | */ | 149 | */ |
150 | #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ | 150 | #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ |
151 | defined(CONFIG_M520x) || defined(CONFIG_M532x) || \ | 151 | defined(CONFIG_M520x) || defined(CONFIG_M532x) || defined(CONFIG_ARM) |
152 | defined(CONFIG_ARCH_MXC) || defined(CONFIG_SOC_IMX28) | ||
153 | #define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) | 152 | #define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) |
154 | #else | 153 | #else |
155 | #define OPT_FRAME_SIZE 0 | 154 | #define OPT_FRAME_SIZE 0 |
@@ -184,7 +183,7 @@ struct fec_enet_private { | |||
184 | struct bufdesc *rx_bd_base; | 183 | struct bufdesc *rx_bd_base; |
185 | struct bufdesc *tx_bd_base; | 184 | struct bufdesc *tx_bd_base; |
186 | /* The next free ring entry */ | 185 | /* The next free ring entry */ |
187 | struct bufdesc *cur_rx, *cur_tx; | 186 | struct bufdesc *cur_rx, *cur_tx; |
188 | /* The ring entries to be free()ed */ | 187 | /* The ring entries to be free()ed */ |
189 | struct bufdesc *dirty_tx; | 188 | struct bufdesc *dirty_tx; |
190 | 189 | ||
@@ -192,28 +191,21 @@ struct fec_enet_private { | |||
192 | /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */ | 191 | /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */ |
193 | spinlock_t hw_lock; | 192 | spinlock_t hw_lock; |
194 | 193 | ||
195 | struct platform_device *pdev; | 194 | struct platform_device *pdev; |
196 | 195 | ||
197 | int opened; | 196 | int opened; |
198 | 197 | ||
199 | /* Phylib and MDIO interface */ | 198 | /* Phylib and MDIO interface */ |
200 | struct mii_bus *mii_bus; | 199 | struct mii_bus *mii_bus; |
201 | struct phy_device *phy_dev; | 200 | struct phy_device *phy_dev; |
202 | int mii_timeout; | 201 | int mii_timeout; |
203 | uint phy_speed; | 202 | uint phy_speed; |
204 | phy_interface_t phy_interface; | 203 | phy_interface_t phy_interface; |
205 | int link; | 204 | int link; |
206 | int full_duplex; | 205 | int full_duplex; |
207 | struct completion mdio_done; | 206 | struct completion mdio_done; |
208 | }; | 207 | }; |
209 | 208 | ||
210 | static irqreturn_t fec_enet_interrupt(int irq, void * dev_id); | ||
211 | static void fec_enet_tx(struct net_device *dev); | ||
212 | static void fec_enet_rx(struct net_device *dev); | ||
213 | static int fec_enet_close(struct net_device *dev); | ||
214 | static void fec_restart(struct net_device *dev, int duplex); | ||
215 | static void fec_stop(struct net_device *dev); | ||
216 | |||
217 | /* FEC MII MMFR bits definition */ | 209 | /* FEC MII MMFR bits definition */ |
218 | #define FEC_MMFR_ST (1 << 30) | 210 | #define FEC_MMFR_ST (1 << 30) |
219 | #define FEC_MMFR_OP_READ (2 << 28) | 211 | #define FEC_MMFR_OP_READ (2 << 28) |
@@ -240,9 +232,9 @@ static void *swap_buffer(void *bufaddr, int len) | |||
240 | } | 232 | } |
241 | 233 | ||
242 | static netdev_tx_t | 234 | static netdev_tx_t |
243 | fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | 235 | fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev) |
244 | { | 236 | { |
245 | struct fec_enet_private *fep = netdev_priv(dev); | 237 | struct fec_enet_private *fep = netdev_priv(ndev); |
246 | const struct platform_device_id *id_entry = | 238 | const struct platform_device_id *id_entry = |
247 | platform_get_device_id(fep->pdev); | 239 | platform_get_device_id(fep->pdev); |
248 | struct bufdesc *bdp; | 240 | struct bufdesc *bdp; |
@@ -263,9 +255,9 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
263 | 255 | ||
264 | if (status & BD_ENET_TX_READY) { | 256 | if (status & BD_ENET_TX_READY) { |
265 | /* Ooops. All transmit buffers are full. Bail out. | 257 | /* Ooops. All transmit buffers are full. Bail out. |
266 | * This should not happen, since dev->tbusy should be set. | 258 | * This should not happen, since ndev->tbusy should be set. |
267 | */ | 259 | */ |
268 | printk("%s: tx queue full!.\n", dev->name); | 260 | printk("%s: tx queue full!.\n", ndev->name); |
269 | spin_unlock_irqrestore(&fep->hw_lock, flags); | 261 | spin_unlock_irqrestore(&fep->hw_lock, flags); |
270 | return NETDEV_TX_BUSY; | 262 | return NETDEV_TX_BUSY; |
271 | } | 263 | } |
@@ -285,7 +277,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
285 | if (((unsigned long) bufaddr) & FEC_ALIGNMENT) { | 277 | if (((unsigned long) bufaddr) & FEC_ALIGNMENT) { |
286 | unsigned int index; | 278 | unsigned int index; |
287 | index = bdp - fep->tx_bd_base; | 279 | index = bdp - fep->tx_bd_base; |
288 | memcpy(fep->tx_bounce[index], (void *)skb->data, skb->len); | 280 | memcpy(fep->tx_bounce[index], skb->data, skb->len); |
289 | bufaddr = fep->tx_bounce[index]; | 281 | bufaddr = fep->tx_bounce[index]; |
290 | } | 282 | } |
291 | 283 | ||
@@ -300,13 +292,13 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
300 | /* Save skb pointer */ | 292 | /* Save skb pointer */ |
301 | fep->tx_skbuff[fep->skb_cur] = skb; | 293 | fep->tx_skbuff[fep->skb_cur] = skb; |
302 | 294 | ||
303 | dev->stats.tx_bytes += skb->len; | 295 | ndev->stats.tx_bytes += skb->len; |
304 | fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK; | 296 | fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK; |
305 | 297 | ||
306 | /* Push the data cache so the CPM does not get stale memory | 298 | /* Push the data cache so the CPM does not get stale memory |
307 | * data. | 299 | * data. |
308 | */ | 300 | */ |
309 | bdp->cbd_bufaddr = dma_map_single(&dev->dev, bufaddr, | 301 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr, |
310 | FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); | 302 | FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); |
311 | 303 | ||
312 | /* Send it on its way. Tell FEC it's ready, interrupt when done, | 304 | /* Send it on its way. Tell FEC it's ready, interrupt when done, |
@@ -327,7 +319,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
327 | 319 | ||
328 | if (bdp == fep->dirty_tx) { | 320 | if (bdp == fep->dirty_tx) { |
329 | fep->tx_full = 1; | 321 | fep->tx_full = 1; |
330 | netif_stop_queue(dev); | 322 | netif_stop_queue(ndev); |
331 | } | 323 | } |
332 | 324 | ||
333 | fep->cur_tx = bdp; | 325 | fep->cur_tx = bdp; |
@@ -337,62 +329,170 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
337 | return NETDEV_TX_OK; | 329 | return NETDEV_TX_OK; |
338 | } | 330 | } |
339 | 331 | ||
332 | /* This function is called to start or restart the FEC during a link | ||
333 | * change. This only happens when switching between half and full | ||
334 | * duplex. | ||
335 | */ | ||
340 | static void | 336 | static void |
341 | fec_timeout(struct net_device *dev) | 337 | fec_restart(struct net_device *ndev, int duplex) |
342 | { | 338 | { |
343 | struct fec_enet_private *fep = netdev_priv(dev); | 339 | struct fec_enet_private *fep = netdev_priv(ndev); |
340 | const struct platform_device_id *id_entry = | ||
341 | platform_get_device_id(fep->pdev); | ||
342 | int i; | ||
343 | u32 temp_mac[2]; | ||
344 | u32 rcntl = OPT_FRAME_SIZE | 0x04; | ||
344 | 345 | ||
345 | dev->stats.tx_errors++; | 346 | /* Whack a reset. We should wait for this. */ |
347 | writel(1, fep->hwp + FEC_ECNTRL); | ||
348 | udelay(10); | ||
346 | 349 | ||
347 | fec_restart(dev, fep->full_duplex); | 350 | /* |
348 | netif_wake_queue(dev); | 351 | * enet-mac reset will reset mac address registers too, |
349 | } | 352 | * so need to reconfigure it. |
353 | */ | ||
354 | if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { | ||
355 | memcpy(&temp_mac, ndev->dev_addr, ETH_ALEN); | ||
356 | writel(cpu_to_be32(temp_mac[0]), fep->hwp + FEC_ADDR_LOW); | ||
357 | writel(cpu_to_be32(temp_mac[1]), fep->hwp + FEC_ADDR_HIGH); | ||
358 | } | ||
350 | 359 | ||
351 | static irqreturn_t | 360 | /* Clear any outstanding interrupt. */ |
352 | fec_enet_interrupt(int irq, void * dev_id) | 361 | writel(0xffc00000, fep->hwp + FEC_IEVENT); |
353 | { | ||
354 | struct net_device *dev = dev_id; | ||
355 | struct fec_enet_private *fep = netdev_priv(dev); | ||
356 | uint int_events; | ||
357 | irqreturn_t ret = IRQ_NONE; | ||
358 | 362 | ||
359 | do { | 363 | /* Reset all multicast. */ |
360 | int_events = readl(fep->hwp + FEC_IEVENT); | 364 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); |
361 | writel(int_events, fep->hwp + FEC_IEVENT); | 365 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW); |
366 | #ifndef CONFIG_M5272 | ||
367 | writel(0, fep->hwp + FEC_HASH_TABLE_HIGH); | ||
368 | writel(0, fep->hwp + FEC_HASH_TABLE_LOW); | ||
369 | #endif | ||
362 | 370 | ||
363 | if (int_events & FEC_ENET_RXF) { | 371 | /* Set maximum receive buffer size. */ |
364 | ret = IRQ_HANDLED; | 372 | writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE); |
365 | fec_enet_rx(dev); | ||
366 | } | ||
367 | 373 | ||
368 | /* Transmit OK, or non-fatal error. Update the buffer | 374 | /* Set receive and transmit descriptor base. */ |
369 | * descriptors. FEC handles all errors, we just discover | 375 | writel(fep->bd_dma, fep->hwp + FEC_R_DES_START); |
370 | * them as part of the transmit process. | 376 | writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc) * RX_RING_SIZE, |
371 | */ | 377 | fep->hwp + FEC_X_DES_START); |
372 | if (int_events & FEC_ENET_TXF) { | 378 | |
373 | ret = IRQ_HANDLED; | 379 | fep->dirty_tx = fep->cur_tx = fep->tx_bd_base; |
374 | fec_enet_tx(dev); | 380 | fep->cur_rx = fep->rx_bd_base; |
381 | |||
382 | /* Reset SKB transmit buffers. */ | ||
383 | fep->skb_cur = fep->skb_dirty = 0; | ||
384 | for (i = 0; i <= TX_RING_MOD_MASK; i++) { | ||
385 | if (fep->tx_skbuff[i]) { | ||
386 | dev_kfree_skb_any(fep->tx_skbuff[i]); | ||
387 | fep->tx_skbuff[i] = NULL; | ||
375 | } | 388 | } |
389 | } | ||
376 | 390 | ||
377 | if (int_events & FEC_ENET_MII) { | 391 | /* Enable MII mode */ |
378 | ret = IRQ_HANDLED; | 392 | if (duplex) { |
379 | complete(&fep->mdio_done); | 393 | /* FD enable */ |
394 | writel(0x04, fep->hwp + FEC_X_CNTRL); | ||
395 | } else { | ||
396 | /* No Rcv on Xmit */ | ||
397 | rcntl |= 0x02; | ||
398 | writel(0x0, fep->hwp + FEC_X_CNTRL); | ||
399 | } | ||
400 | |||
401 | fep->full_duplex = duplex; | ||
402 | |||
403 | /* Set MII speed */ | ||
404 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); | ||
405 | |||
406 | /* | ||
407 | * The phy interface and speed need to get configured | ||
408 | * differently on enet-mac. | ||
409 | */ | ||
410 | if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { | ||
411 | /* Enable flow control and length check */ | ||
412 | rcntl |= 0x40000000 | 0x00000020; | ||
413 | |||
414 | /* MII or RMII */ | ||
415 | if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) | ||
416 | rcntl |= (1 << 8); | ||
417 | else | ||
418 | rcntl &= ~(1 << 8); | ||
419 | |||
420 | /* 10M or 100M */ | ||
421 | if (fep->phy_dev && fep->phy_dev->speed == SPEED_100) | ||
422 | rcntl &= ~(1 << 9); | ||
423 | else | ||
424 | rcntl |= (1 << 9); | ||
425 | |||
426 | } else { | ||
427 | #ifdef FEC_MIIGSK_ENR | ||
428 | if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) { | ||
429 | /* disable the gasket and wait */ | ||
430 | writel(0, fep->hwp + FEC_MIIGSK_ENR); | ||
431 | while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4) | ||
432 | udelay(1); | ||
433 | |||
434 | /* | ||
435 | * configure the gasket: | ||
436 | * RMII, 50 MHz, no loopback, no echo | ||
437 | */ | ||
438 | writel(1, fep->hwp + FEC_MIIGSK_CFGR); | ||
439 | |||
440 | /* re-enable the gasket */ | ||
441 | writel(2, fep->hwp + FEC_MIIGSK_ENR); | ||
380 | } | 442 | } |
381 | } while (int_events); | 443 | #endif |
444 | } | ||
445 | writel(rcntl, fep->hwp + FEC_R_CNTRL); | ||
382 | 446 | ||
383 | return ret; | 447 | /* And last, enable the transmit and receive processing */ |
448 | writel(2, fep->hwp + FEC_ECNTRL); | ||
449 | writel(0, fep->hwp + FEC_R_DES_ACTIVE); | ||
450 | |||
451 | /* Enable interrupts we wish to service */ | ||
452 | writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); | ||
453 | } | ||
454 | |||
455 | static void | ||
456 | fec_stop(struct net_device *ndev) | ||
457 | { | ||
458 | struct fec_enet_private *fep = netdev_priv(ndev); | ||
459 | |||
460 | /* We cannot expect a graceful transmit stop without link !!! */ | ||
461 | if (fep->link) { | ||
462 | writel(1, fep->hwp + FEC_X_CNTRL); /* Graceful transmit stop */ | ||
463 | udelay(10); | ||
464 | if (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_GRA)) | ||
465 | printk("fec_stop : Graceful transmit stop did not complete !\n"); | ||
466 | } | ||
467 | |||
468 | /* Whack a reset. We should wait for this. */ | ||
469 | writel(1, fep->hwp + FEC_ECNTRL); | ||
470 | udelay(10); | ||
471 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); | ||
472 | writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); | ||
384 | } | 473 | } |
385 | 474 | ||
386 | 475 | ||
387 | static void | 476 | static void |
388 | fec_enet_tx(struct net_device *dev) | 477 | fec_timeout(struct net_device *ndev) |
478 | { | ||
479 | struct fec_enet_private *fep = netdev_priv(ndev); | ||
480 | |||
481 | ndev->stats.tx_errors++; | ||
482 | |||
483 | fec_restart(ndev, fep->full_duplex); | ||
484 | netif_wake_queue(ndev); | ||
485 | } | ||
486 | |||
487 | static void | ||
488 | fec_enet_tx(struct net_device *ndev) | ||
389 | { | 489 | { |
390 | struct fec_enet_private *fep; | 490 | struct fec_enet_private *fep; |
391 | struct bufdesc *bdp; | 491 | struct bufdesc *bdp; |
392 | unsigned short status; | 492 | unsigned short status; |
393 | struct sk_buff *skb; | 493 | struct sk_buff *skb; |
394 | 494 | ||
395 | fep = netdev_priv(dev); | 495 | fep = netdev_priv(ndev); |
396 | spin_lock(&fep->hw_lock); | 496 | spin_lock(&fep->hw_lock); |
397 | bdp = fep->dirty_tx; | 497 | bdp = fep->dirty_tx; |
398 | 498 | ||
@@ -400,7 +500,8 @@ fec_enet_tx(struct net_device *dev) | |||
400 | if (bdp == fep->cur_tx && fep->tx_full == 0) | 500 | if (bdp == fep->cur_tx && fep->tx_full == 0) |
401 | break; | 501 | break; |
402 | 502 | ||
403 | dma_unmap_single(&dev->dev, bdp->cbd_bufaddr, FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); | 503 | dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, |
504 | FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); | ||
404 | bdp->cbd_bufaddr = 0; | 505 | bdp->cbd_bufaddr = 0; |
405 | 506 | ||
406 | skb = fep->tx_skbuff[fep->skb_dirty]; | 507 | skb = fep->tx_skbuff[fep->skb_dirty]; |
@@ -408,19 +509,19 @@ fec_enet_tx(struct net_device *dev) | |||
408 | if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | | 509 | if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | |
409 | BD_ENET_TX_RL | BD_ENET_TX_UN | | 510 | BD_ENET_TX_RL | BD_ENET_TX_UN | |
410 | BD_ENET_TX_CSL)) { | 511 | BD_ENET_TX_CSL)) { |
411 | dev->stats.tx_errors++; | 512 | ndev->stats.tx_errors++; |
412 | if (status & BD_ENET_TX_HB) /* No heartbeat */ | 513 | if (status & BD_ENET_TX_HB) /* No heartbeat */ |
413 | dev->stats.tx_heartbeat_errors++; | 514 | ndev->stats.tx_heartbeat_errors++; |
414 | if (status & BD_ENET_TX_LC) /* Late collision */ | 515 | if (status & BD_ENET_TX_LC) /* Late collision */ |
415 | dev->stats.tx_window_errors++; | 516 | ndev->stats.tx_window_errors++; |
416 | if (status & BD_ENET_TX_RL) /* Retrans limit */ | 517 | if (status & BD_ENET_TX_RL) /* Retrans limit */ |
417 | dev->stats.tx_aborted_errors++; | 518 | ndev->stats.tx_aborted_errors++; |
418 | if (status & BD_ENET_TX_UN) /* Underrun */ | 519 | if (status & BD_ENET_TX_UN) /* Underrun */ |
419 | dev->stats.tx_fifo_errors++; | 520 | ndev->stats.tx_fifo_errors++; |
420 | if (status & BD_ENET_TX_CSL) /* Carrier lost */ | 521 | if (status & BD_ENET_TX_CSL) /* Carrier lost */ |
421 | dev->stats.tx_carrier_errors++; | 522 | ndev->stats.tx_carrier_errors++; |
422 | } else { | 523 | } else { |
423 | dev->stats.tx_packets++; | 524 | ndev->stats.tx_packets++; |
424 | } | 525 | } |
425 | 526 | ||
426 | if (status & BD_ENET_TX_READY) | 527 | if (status & BD_ENET_TX_READY) |
@@ -430,7 +531,7 @@ fec_enet_tx(struct net_device *dev) | |||
430 | * but we eventually sent the packet OK. | 531 | * but we eventually sent the packet OK. |
431 | */ | 532 | */ |
432 | if (status & BD_ENET_TX_DEF) | 533 | if (status & BD_ENET_TX_DEF) |
433 | dev->stats.collisions++; | 534 | ndev->stats.collisions++; |
434 | 535 | ||
435 | /* Free the sk buffer associated with this last transmit */ | 536 | /* Free the sk buffer associated with this last transmit */ |
436 | dev_kfree_skb_any(skb); | 537 | dev_kfree_skb_any(skb); |
@@ -447,8 +548,8 @@ fec_enet_tx(struct net_device *dev) | |||
447 | */ | 548 | */ |
448 | if (fep->tx_full) { | 549 | if (fep->tx_full) { |
449 | fep->tx_full = 0; | 550 | fep->tx_full = 0; |
450 | if (netif_queue_stopped(dev)) | 551 | if (netif_queue_stopped(ndev)) |
451 | netif_wake_queue(dev); | 552 | netif_wake_queue(ndev); |
452 | } | 553 | } |
453 | } | 554 | } |
454 | fep->dirty_tx = bdp; | 555 | fep->dirty_tx = bdp; |
@@ -462,9 +563,9 @@ fec_enet_tx(struct net_device *dev) | |||
462 | * effectively tossing the packet. | 563 | * effectively tossing the packet. |
463 | */ | 564 | */ |
464 | static void | 565 | static void |
465 | fec_enet_rx(struct net_device *dev) | 566 | fec_enet_rx(struct net_device *ndev) |
466 | { | 567 | { |
467 | struct fec_enet_private *fep = netdev_priv(dev); | 568 | struct fec_enet_private *fep = netdev_priv(ndev); |
468 | const struct platform_device_id *id_entry = | 569 | const struct platform_device_id *id_entry = |
469 | platform_get_device_id(fep->pdev); | 570 | platform_get_device_id(fep->pdev); |
470 | struct bufdesc *bdp; | 571 | struct bufdesc *bdp; |
@@ -498,17 +599,17 @@ fec_enet_rx(struct net_device *dev) | |||
498 | /* Check for errors. */ | 599 | /* Check for errors. */ |
499 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | | 600 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | |
500 | BD_ENET_RX_CR | BD_ENET_RX_OV)) { | 601 | BD_ENET_RX_CR | BD_ENET_RX_OV)) { |
501 | dev->stats.rx_errors++; | 602 | ndev->stats.rx_errors++; |
502 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { | 603 | if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { |
503 | /* Frame too long or too short. */ | 604 | /* Frame too long or too short. */ |
504 | dev->stats.rx_length_errors++; | 605 | ndev->stats.rx_length_errors++; |
505 | } | 606 | } |
506 | if (status & BD_ENET_RX_NO) /* Frame alignment */ | 607 | if (status & BD_ENET_RX_NO) /* Frame alignment */ |
507 | dev->stats.rx_frame_errors++; | 608 | ndev->stats.rx_frame_errors++; |
508 | if (status & BD_ENET_RX_CR) /* CRC Error */ | 609 | if (status & BD_ENET_RX_CR) /* CRC Error */ |
509 | dev->stats.rx_crc_errors++; | 610 | ndev->stats.rx_crc_errors++; |
510 | if (status & BD_ENET_RX_OV) /* FIFO overrun */ | 611 | if (status & BD_ENET_RX_OV) /* FIFO overrun */ |
511 | dev->stats.rx_fifo_errors++; | 612 | ndev->stats.rx_fifo_errors++; |
512 | } | 613 | } |
513 | 614 | ||
514 | /* Report late collisions as a frame error. | 615 | /* Report late collisions as a frame error. |
@@ -516,19 +617,19 @@ fec_enet_rx(struct net_device *dev) | |||
516 | * have in the buffer. So, just drop this frame on the floor. | 617 | * have in the buffer. So, just drop this frame on the floor. |
517 | */ | 618 | */ |
518 | if (status & BD_ENET_RX_CL) { | 619 | if (status & BD_ENET_RX_CL) { |
519 | dev->stats.rx_errors++; | 620 | ndev->stats.rx_errors++; |
520 | dev->stats.rx_frame_errors++; | 621 | ndev->stats.rx_frame_errors++; |
521 | goto rx_processing_done; | 622 | goto rx_processing_done; |
522 | } | 623 | } |
523 | 624 | ||
524 | /* Process the incoming frame. */ | 625 | /* Process the incoming frame. */ |
525 | dev->stats.rx_packets++; | 626 | ndev->stats.rx_packets++; |
526 | pkt_len = bdp->cbd_datlen; | 627 | pkt_len = bdp->cbd_datlen; |
527 | dev->stats.rx_bytes += pkt_len; | 628 | ndev->stats.rx_bytes += pkt_len; |
528 | data = (__u8*)__va(bdp->cbd_bufaddr); | 629 | data = (__u8*)__va(bdp->cbd_bufaddr); |
529 | 630 | ||
530 | dma_unmap_single(NULL, bdp->cbd_bufaddr, bdp->cbd_datlen, | 631 | dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, |
531 | DMA_FROM_DEVICE); | 632 | FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE); |
532 | 633 | ||
533 | if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) | 634 | if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) |
534 | swap_buffer(data, pkt_len); | 635 | swap_buffer(data, pkt_len); |
@@ -542,18 +643,18 @@ fec_enet_rx(struct net_device *dev) | |||
542 | 643 | ||
543 | if (unlikely(!skb)) { | 644 | if (unlikely(!skb)) { |
544 | printk("%s: Memory squeeze, dropping packet.\n", | 645 | printk("%s: Memory squeeze, dropping packet.\n", |
545 | dev->name); | 646 | ndev->name); |
546 | dev->stats.rx_dropped++; | 647 | ndev->stats.rx_dropped++; |
547 | } else { | 648 | } else { |
548 | skb_reserve(skb, NET_IP_ALIGN); | 649 | skb_reserve(skb, NET_IP_ALIGN); |
549 | skb_put(skb, pkt_len - 4); /* Make room */ | 650 | skb_put(skb, pkt_len - 4); /* Make room */ |
550 | skb_copy_to_linear_data(skb, data, pkt_len - 4); | 651 | skb_copy_to_linear_data(skb, data, pkt_len - 4); |
551 | skb->protocol = eth_type_trans(skb, dev); | 652 | skb->protocol = eth_type_trans(skb, ndev); |
552 | netif_rx(skb); | 653 | netif_rx(skb); |
553 | } | 654 | } |
554 | 655 | ||
555 | bdp->cbd_bufaddr = dma_map_single(NULL, data, bdp->cbd_datlen, | 656 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, data, |
556 | DMA_FROM_DEVICE); | 657 | FEC_ENET_TX_FRSIZE, DMA_FROM_DEVICE); |
557 | rx_processing_done: | 658 | rx_processing_done: |
558 | /* Clear the status flags for this buffer */ | 659 | /* Clear the status flags for this buffer */ |
559 | status &= ~BD_ENET_RX_STATS; | 660 | status &= ~BD_ENET_RX_STATS; |
@@ -578,10 +679,47 @@ rx_processing_done: | |||
578 | spin_unlock(&fep->hw_lock); | 679 | spin_unlock(&fep->hw_lock); |
579 | } | 680 | } |
580 | 681 | ||
682 | static irqreturn_t | ||
683 | fec_enet_interrupt(int irq, void *dev_id) | ||
684 | { | ||
685 | struct net_device *ndev = dev_id; | ||
686 | struct fec_enet_private *fep = netdev_priv(ndev); | ||
687 | uint int_events; | ||
688 | irqreturn_t ret = IRQ_NONE; | ||
689 | |||
690 | do { | ||
691 | int_events = readl(fep->hwp + FEC_IEVENT); | ||
692 | writel(int_events, fep->hwp + FEC_IEVENT); | ||
693 | |||
694 | if (int_events & FEC_ENET_RXF) { | ||
695 | ret = IRQ_HANDLED; | ||
696 | fec_enet_rx(ndev); | ||
697 | } | ||
698 | |||
699 | /* Transmit OK, or non-fatal error. Update the buffer | ||
700 | * descriptors. FEC handles all errors, we just discover | ||
701 | * them as part of the transmit process. | ||
702 | */ | ||
703 | if (int_events & FEC_ENET_TXF) { | ||
704 | ret = IRQ_HANDLED; | ||
705 | fec_enet_tx(ndev); | ||
706 | } | ||
707 | |||
708 | if (int_events & FEC_ENET_MII) { | ||
709 | ret = IRQ_HANDLED; | ||
710 | complete(&fep->mdio_done); | ||
711 | } | ||
712 | } while (int_events); | ||
713 | |||
714 | return ret; | ||
715 | } | ||
716 | |||
717 | |||
718 | |||
581 | /* ------------------------------------------------------------------------- */ | 719 | /* ------------------------------------------------------------------------- */ |
582 | static void __inline__ fec_get_mac(struct net_device *dev) | 720 | static void __inline__ fec_get_mac(struct net_device *ndev) |
583 | { | 721 | { |
584 | struct fec_enet_private *fep = netdev_priv(dev); | 722 | struct fec_enet_private *fep = netdev_priv(ndev); |
585 | struct fec_platform_data *pdata = fep->pdev->dev.platform_data; | 723 | struct fec_platform_data *pdata = fep->pdev->dev.platform_data; |
586 | unsigned char *iap, tmpaddr[ETH_ALEN]; | 724 | unsigned char *iap, tmpaddr[ETH_ALEN]; |
587 | 725 | ||
@@ -617,11 +755,11 @@ static void __inline__ fec_get_mac(struct net_device *dev) | |||
617 | iap = &tmpaddr[0]; | 755 | iap = &tmpaddr[0]; |
618 | } | 756 | } |
619 | 757 | ||
620 | memcpy(dev->dev_addr, iap, ETH_ALEN); | 758 | memcpy(ndev->dev_addr, iap, ETH_ALEN); |
621 | 759 | ||
622 | /* Adjust MAC if using macaddr */ | 760 | /* Adjust MAC if using macaddr */ |
623 | if (iap == macaddr) | 761 | if (iap == macaddr) |
624 | dev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->pdev->id; | 762 | ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->pdev->id; |
625 | } | 763 | } |
626 | 764 | ||
627 | /* ------------------------------------------------------------------------- */ | 765 | /* ------------------------------------------------------------------------- */ |
@@ -629,9 +767,9 @@ static void __inline__ fec_get_mac(struct net_device *dev) | |||
629 | /* | 767 | /* |
630 | * Phy section | 768 | * Phy section |
631 | */ | 769 | */ |
632 | static void fec_enet_adjust_link(struct net_device *dev) | 770 | static void fec_enet_adjust_link(struct net_device *ndev) |
633 | { | 771 | { |
634 | struct fec_enet_private *fep = netdev_priv(dev); | 772 | struct fec_enet_private *fep = netdev_priv(ndev); |
635 | struct phy_device *phy_dev = fep->phy_dev; | 773 | struct phy_device *phy_dev = fep->phy_dev; |
636 | unsigned long flags; | 774 | unsigned long flags; |
637 | 775 | ||
@@ -648,7 +786,7 @@ static void fec_enet_adjust_link(struct net_device *dev) | |||
648 | /* Duplex link change */ | 786 | /* Duplex link change */ |
649 | if (phy_dev->link) { | 787 | if (phy_dev->link) { |
650 | if (fep->full_duplex != phy_dev->duplex) { | 788 | if (fep->full_duplex != phy_dev->duplex) { |
651 | fec_restart(dev, phy_dev->duplex); | 789 | fec_restart(ndev, phy_dev->duplex); |
652 | status_change = 1; | 790 | status_change = 1; |
653 | } | 791 | } |
654 | } | 792 | } |
@@ -657,9 +795,9 @@ static void fec_enet_adjust_link(struct net_device *dev) | |||
657 | if (phy_dev->link != fep->link) { | 795 | if (phy_dev->link != fep->link) { |
658 | fep->link = phy_dev->link; | 796 | fep->link = phy_dev->link; |
659 | if (phy_dev->link) | 797 | if (phy_dev->link) |
660 | fec_restart(dev, phy_dev->duplex); | 798 | fec_restart(ndev, phy_dev->duplex); |
661 | else | 799 | else |
662 | fec_stop(dev); | 800 | fec_stop(ndev); |
663 | status_change = 1; | 801 | status_change = 1; |
664 | } | 802 | } |
665 | 803 | ||
@@ -728,9 +866,9 @@ static int fec_enet_mdio_reset(struct mii_bus *bus) | |||
728 | return 0; | 866 | return 0; |
729 | } | 867 | } |
730 | 868 | ||
731 | static int fec_enet_mii_probe(struct net_device *dev) | 869 | static int fec_enet_mii_probe(struct net_device *ndev) |
732 | { | 870 | { |
733 | struct fec_enet_private *fep = netdev_priv(dev); | 871 | struct fec_enet_private *fep = netdev_priv(ndev); |
734 | struct phy_device *phy_dev = NULL; | 872 | struct phy_device *phy_dev = NULL; |
735 | char mdio_bus_id[MII_BUS_ID_SIZE]; | 873 | char mdio_bus_id[MII_BUS_ID_SIZE]; |
736 | char phy_name[MII_BUS_ID_SIZE + 3]; | 874 | char phy_name[MII_BUS_ID_SIZE + 3]; |
@@ -755,16 +893,16 @@ static int fec_enet_mii_probe(struct net_device *dev) | |||
755 | 893 | ||
756 | if (phy_id >= PHY_MAX_ADDR) { | 894 | if (phy_id >= PHY_MAX_ADDR) { |
757 | printk(KERN_INFO "%s: no PHY, assuming direct connection " | 895 | printk(KERN_INFO "%s: no PHY, assuming direct connection " |
758 | "to switch\n", dev->name); | 896 | "to switch\n", ndev->name); |
759 | strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); | 897 | strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); |
760 | phy_id = 0; | 898 | phy_id = 0; |
761 | } | 899 | } |
762 | 900 | ||
763 | snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); | 901 | snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); |
764 | phy_dev = phy_connect(dev, phy_name, &fec_enet_adjust_link, 0, | 902 | phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link, 0, |
765 | PHY_INTERFACE_MODE_MII); | 903 | PHY_INTERFACE_MODE_MII); |
766 | if (IS_ERR(phy_dev)) { | 904 | if (IS_ERR(phy_dev)) { |
767 | printk(KERN_ERR "%s: could not attach to PHY\n", dev->name); | 905 | printk(KERN_ERR "%s: could not attach to PHY\n", ndev->name); |
768 | return PTR_ERR(phy_dev); | 906 | return PTR_ERR(phy_dev); |
769 | } | 907 | } |
770 | 908 | ||
@@ -777,7 +915,7 @@ static int fec_enet_mii_probe(struct net_device *dev) | |||
777 | fep->full_duplex = 0; | 915 | fep->full_duplex = 0; |
778 | 916 | ||
779 | printk(KERN_INFO "%s: Freescale FEC PHY driver [%s] " | 917 | printk(KERN_INFO "%s: Freescale FEC PHY driver [%s] " |
780 | "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name, | 918 | "(mii_bus:phy_addr=%s, irq=%d)\n", ndev->name, |
781 | fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev), | 919 | fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev), |
782 | fep->phy_dev->irq); | 920 | fep->phy_dev->irq); |
783 | 921 | ||
@@ -787,8 +925,8 @@ static int fec_enet_mii_probe(struct net_device *dev) | |||
787 | static int fec_enet_mii_init(struct platform_device *pdev) | 925 | static int fec_enet_mii_init(struct platform_device *pdev) |
788 | { | 926 | { |
789 | static struct mii_bus *fec0_mii_bus; | 927 | static struct mii_bus *fec0_mii_bus; |
790 | struct net_device *dev = platform_get_drvdata(pdev); | 928 | struct net_device *ndev = platform_get_drvdata(pdev); |
791 | struct fec_enet_private *fep = netdev_priv(dev); | 929 | struct fec_enet_private *fep = netdev_priv(ndev); |
792 | const struct platform_device_id *id_entry = | 930 | const struct platform_device_id *id_entry = |
793 | platform_get_device_id(fep->pdev); | 931 | platform_get_device_id(fep->pdev); |
794 | int err = -ENXIO, i; | 932 | int err = -ENXIO, i; |
@@ -846,8 +984,6 @@ static int fec_enet_mii_init(struct platform_device *pdev) | |||
846 | for (i = 0; i < PHY_MAX_ADDR; i++) | 984 | for (i = 0; i < PHY_MAX_ADDR; i++) |
847 | fep->mii_bus->irq[i] = PHY_POLL; | 985 | fep->mii_bus->irq[i] = PHY_POLL; |
848 | 986 | ||
849 | platform_set_drvdata(dev, fep->mii_bus); | ||
850 | |||
851 | if (mdiobus_register(fep->mii_bus)) | 987 | if (mdiobus_register(fep->mii_bus)) |
852 | goto err_out_free_mdio_irq; | 988 | goto err_out_free_mdio_irq; |
853 | 989 | ||
@@ -874,10 +1010,10 @@ static void fec_enet_mii_remove(struct fec_enet_private *fep) | |||
874 | mdiobus_free(fep->mii_bus); | 1010 | mdiobus_free(fep->mii_bus); |
875 | } | 1011 | } |
876 | 1012 | ||
877 | static int fec_enet_get_settings(struct net_device *dev, | 1013 | static int fec_enet_get_settings(struct net_device *ndev, |
878 | struct ethtool_cmd *cmd) | 1014 | struct ethtool_cmd *cmd) |
879 | { | 1015 | { |
880 | struct fec_enet_private *fep = netdev_priv(dev); | 1016 | struct fec_enet_private *fep = netdev_priv(ndev); |
881 | struct phy_device *phydev = fep->phy_dev; | 1017 | struct phy_device *phydev = fep->phy_dev; |
882 | 1018 | ||
883 | if (!phydev) | 1019 | if (!phydev) |
@@ -886,10 +1022,10 @@ static int fec_enet_get_settings(struct net_device *dev, | |||
886 | return phy_ethtool_gset(phydev, cmd); | 1022 | return phy_ethtool_gset(phydev, cmd); |
887 | } | 1023 | } |
888 | 1024 | ||
889 | static int fec_enet_set_settings(struct net_device *dev, | 1025 | static int fec_enet_set_settings(struct net_device *ndev, |
890 | struct ethtool_cmd *cmd) | 1026 | struct ethtool_cmd *cmd) |
891 | { | 1027 | { |
892 | struct fec_enet_private *fep = netdev_priv(dev); | 1028 | struct fec_enet_private *fep = netdev_priv(ndev); |
893 | struct phy_device *phydev = fep->phy_dev; | 1029 | struct phy_device *phydev = fep->phy_dev; |
894 | 1030 | ||
895 | if (!phydev) | 1031 | if (!phydev) |
@@ -898,14 +1034,14 @@ static int fec_enet_set_settings(struct net_device *dev, | |||
898 | return phy_ethtool_sset(phydev, cmd); | 1034 | return phy_ethtool_sset(phydev, cmd); |
899 | } | 1035 | } |
900 | 1036 | ||
901 | static void fec_enet_get_drvinfo(struct net_device *dev, | 1037 | static void fec_enet_get_drvinfo(struct net_device *ndev, |
902 | struct ethtool_drvinfo *info) | 1038 | struct ethtool_drvinfo *info) |
903 | { | 1039 | { |
904 | struct fec_enet_private *fep = netdev_priv(dev); | 1040 | struct fec_enet_private *fep = netdev_priv(ndev); |
905 | 1041 | ||
906 | strcpy(info->driver, fep->pdev->dev.driver->name); | 1042 | strcpy(info->driver, fep->pdev->dev.driver->name); |
907 | strcpy(info->version, "Revision: 1.0"); | 1043 | strcpy(info->version, "Revision: 1.0"); |
908 | strcpy(info->bus_info, dev_name(&dev->dev)); | 1044 | strcpy(info->bus_info, dev_name(&ndev->dev)); |
909 | } | 1045 | } |
910 | 1046 | ||
911 | static struct ethtool_ops fec_enet_ethtool_ops = { | 1047 | static struct ethtool_ops fec_enet_ethtool_ops = { |
@@ -915,12 +1051,12 @@ static struct ethtool_ops fec_enet_ethtool_ops = { | |||
915 | .get_link = ethtool_op_get_link, | 1051 | .get_link = ethtool_op_get_link, |
916 | }; | 1052 | }; |
917 | 1053 | ||
918 | static int fec_enet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 1054 | static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) |
919 | { | 1055 | { |
920 | struct fec_enet_private *fep = netdev_priv(dev); | 1056 | struct fec_enet_private *fep = netdev_priv(ndev); |
921 | struct phy_device *phydev = fep->phy_dev; | 1057 | struct phy_device *phydev = fep->phy_dev; |
922 | 1058 | ||
923 | if (!netif_running(dev)) | 1059 | if (!netif_running(ndev)) |
924 | return -EINVAL; | 1060 | return -EINVAL; |
925 | 1061 | ||
926 | if (!phydev) | 1062 | if (!phydev) |
@@ -929,9 +1065,9 @@ static int fec_enet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
929 | return phy_mii_ioctl(phydev, rq, cmd); | 1065 | return phy_mii_ioctl(phydev, rq, cmd); |
930 | } | 1066 | } |
931 | 1067 | ||
932 | static void fec_enet_free_buffers(struct net_device *dev) | 1068 | static void fec_enet_free_buffers(struct net_device *ndev) |
933 | { | 1069 | { |
934 | struct fec_enet_private *fep = netdev_priv(dev); | 1070 | struct fec_enet_private *fep = netdev_priv(ndev); |
935 | int i; | 1071 | int i; |
936 | struct sk_buff *skb; | 1072 | struct sk_buff *skb; |
937 | struct bufdesc *bdp; | 1073 | struct bufdesc *bdp; |
@@ -941,7 +1077,7 @@ static void fec_enet_free_buffers(struct net_device *dev) | |||
941 | skb = fep->rx_skbuff[i]; | 1077 | skb = fep->rx_skbuff[i]; |
942 | 1078 | ||
943 | if (bdp->cbd_bufaddr) | 1079 | if (bdp->cbd_bufaddr) |
944 | dma_unmap_single(&dev->dev, bdp->cbd_bufaddr, | 1080 | dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, |
945 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); | 1081 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); |
946 | if (skb) | 1082 | if (skb) |
947 | dev_kfree_skb(skb); | 1083 | dev_kfree_skb(skb); |
@@ -953,9 +1089,9 @@ static void fec_enet_free_buffers(struct net_device *dev) | |||
953 | kfree(fep->tx_bounce[i]); | 1089 | kfree(fep->tx_bounce[i]); |
954 | } | 1090 | } |
955 | 1091 | ||
956 | static int fec_enet_alloc_buffers(struct net_device *dev) | 1092 | static int fec_enet_alloc_buffers(struct net_device *ndev) |
957 | { | 1093 | { |
958 | struct fec_enet_private *fep = netdev_priv(dev); | 1094 | struct fec_enet_private *fep = netdev_priv(ndev); |
959 | int i; | 1095 | int i; |
960 | struct sk_buff *skb; | 1096 | struct sk_buff *skb; |
961 | struct bufdesc *bdp; | 1097 | struct bufdesc *bdp; |
@@ -964,12 +1100,12 @@ static int fec_enet_alloc_buffers(struct net_device *dev) | |||
964 | for (i = 0; i < RX_RING_SIZE; i++) { | 1100 | for (i = 0; i < RX_RING_SIZE; i++) { |
965 | skb = dev_alloc_skb(FEC_ENET_RX_FRSIZE); | 1101 | skb = dev_alloc_skb(FEC_ENET_RX_FRSIZE); |
966 | if (!skb) { | 1102 | if (!skb) { |
967 | fec_enet_free_buffers(dev); | 1103 | fec_enet_free_buffers(ndev); |
968 | return -ENOMEM; | 1104 | return -ENOMEM; |
969 | } | 1105 | } |
970 | fep->rx_skbuff[i] = skb; | 1106 | fep->rx_skbuff[i] = skb; |
971 | 1107 | ||
972 | bdp->cbd_bufaddr = dma_map_single(&dev->dev, skb->data, | 1108 | bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, skb->data, |
973 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); | 1109 | FEC_ENET_RX_FRSIZE, DMA_FROM_DEVICE); |
974 | bdp->cbd_sc = BD_ENET_RX_EMPTY; | 1110 | bdp->cbd_sc = BD_ENET_RX_EMPTY; |
975 | bdp++; | 1111 | bdp++; |
@@ -996,45 +1132,47 @@ static int fec_enet_alloc_buffers(struct net_device *dev) | |||
996 | } | 1132 | } |
997 | 1133 | ||
998 | static int | 1134 | static int |
999 | fec_enet_open(struct net_device *dev) | 1135 | fec_enet_open(struct net_device *ndev) |
1000 | { | 1136 | { |
1001 | struct fec_enet_private *fep = netdev_priv(dev); | 1137 | struct fec_enet_private *fep = netdev_priv(ndev); |
1002 | int ret; | 1138 | int ret; |
1003 | 1139 | ||
1004 | /* I should reset the ring buffers here, but I don't yet know | 1140 | /* I should reset the ring buffers here, but I don't yet know |
1005 | * a simple way to do that. | 1141 | * a simple way to do that. |
1006 | */ | 1142 | */ |
1007 | 1143 | ||
1008 | ret = fec_enet_alloc_buffers(dev); | 1144 | ret = fec_enet_alloc_buffers(ndev); |
1009 | if (ret) | 1145 | if (ret) |
1010 | return ret; | 1146 | return ret; |
1011 | 1147 | ||
1012 | /* Probe and connect to PHY when open the interface */ | 1148 | /* Probe and connect to PHY when open the interface */ |
1013 | ret = fec_enet_mii_probe(dev); | 1149 | ret = fec_enet_mii_probe(ndev); |
1014 | if (ret) { | 1150 | if (ret) { |
1015 | fec_enet_free_buffers(dev); | 1151 | fec_enet_free_buffers(ndev); |
1016 | return ret; | 1152 | return ret; |
1017 | } | 1153 | } |
1018 | phy_start(fep->phy_dev); | 1154 | phy_start(fep->phy_dev); |
1019 | netif_start_queue(dev); | 1155 | netif_start_queue(ndev); |
1020 | fep->opened = 1; | 1156 | fep->opened = 1; |
1021 | return 0; | 1157 | return 0; |
1022 | } | 1158 | } |
1023 | 1159 | ||
1024 | static int | 1160 | static int |
1025 | fec_enet_close(struct net_device *dev) | 1161 | fec_enet_close(struct net_device *ndev) |
1026 | { | 1162 | { |
1027 | struct fec_enet_private *fep = netdev_priv(dev); | 1163 | struct fec_enet_private *fep = netdev_priv(ndev); |
1028 | 1164 | ||
1029 | /* Don't know what to do yet. */ | 1165 | /* Don't know what to do yet. */ |
1030 | fep->opened = 0; | 1166 | fep->opened = 0; |
1031 | netif_stop_queue(dev); | 1167 | netif_stop_queue(ndev); |
1032 | fec_stop(dev); | 1168 | fec_stop(ndev); |
1033 | 1169 | ||
1034 | if (fep->phy_dev) | 1170 | if (fep->phy_dev) { |
1171 | phy_stop(fep->phy_dev); | ||
1035 | phy_disconnect(fep->phy_dev); | 1172 | phy_disconnect(fep->phy_dev); |
1173 | } | ||
1036 | 1174 | ||
1037 | fec_enet_free_buffers(dev); | 1175 | fec_enet_free_buffers(ndev); |
1038 | 1176 | ||
1039 | return 0; | 1177 | return 0; |
1040 | } | 1178 | } |
@@ -1052,14 +1190,14 @@ fec_enet_close(struct net_device *dev) | |||
1052 | #define HASH_BITS 6 /* #bits in hash */ | 1190 | #define HASH_BITS 6 /* #bits in hash */ |
1053 | #define CRC32_POLY 0xEDB88320 | 1191 | #define CRC32_POLY 0xEDB88320 |
1054 | 1192 | ||
1055 | static void set_multicast_list(struct net_device *dev) | 1193 | static void set_multicast_list(struct net_device *ndev) |
1056 | { | 1194 | { |
1057 | struct fec_enet_private *fep = netdev_priv(dev); | 1195 | struct fec_enet_private *fep = netdev_priv(ndev); |
1058 | struct netdev_hw_addr *ha; | 1196 | struct netdev_hw_addr *ha; |
1059 | unsigned int i, bit, data, crc, tmp; | 1197 | unsigned int i, bit, data, crc, tmp; |
1060 | unsigned char hash; | 1198 | unsigned char hash; |
1061 | 1199 | ||
1062 | if (dev->flags & IFF_PROMISC) { | 1200 | if (ndev->flags & IFF_PROMISC) { |
1063 | tmp = readl(fep->hwp + FEC_R_CNTRL); | 1201 | tmp = readl(fep->hwp + FEC_R_CNTRL); |
1064 | tmp |= 0x8; | 1202 | tmp |= 0x8; |
1065 | writel(tmp, fep->hwp + FEC_R_CNTRL); | 1203 | writel(tmp, fep->hwp + FEC_R_CNTRL); |
@@ -1070,7 +1208,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1070 | tmp &= ~0x8; | 1208 | tmp &= ~0x8; |
1071 | writel(tmp, fep->hwp + FEC_R_CNTRL); | 1209 | writel(tmp, fep->hwp + FEC_R_CNTRL); |
1072 | 1210 | ||
1073 | if (dev->flags & IFF_ALLMULTI) { | 1211 | if (ndev->flags & IFF_ALLMULTI) { |
1074 | /* Catch all multicast addresses, so set the | 1212 | /* Catch all multicast addresses, so set the |
1075 | * filter to all 1's | 1213 | * filter to all 1's |
1076 | */ | 1214 | */ |
@@ -1085,7 +1223,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1085 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); | 1223 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); |
1086 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW); | 1224 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW); |
1087 | 1225 | ||
1088 | netdev_for_each_mc_addr(ha, dev) { | 1226 | netdev_for_each_mc_addr(ha, ndev) { |
1089 | /* Only support group multicast for now */ | 1227 | /* Only support group multicast for now */ |
1090 | if (!(ha->addr[0] & 1)) | 1228 | if (!(ha->addr[0] & 1)) |
1091 | continue; | 1229 | continue; |
@@ -1093,7 +1231,7 @@ static void set_multicast_list(struct net_device *dev) | |||
1093 | /* calculate crc32 value of mac address */ | 1231 | /* calculate crc32 value of mac address */ |
1094 | crc = 0xffffffff; | 1232 | crc = 0xffffffff; |
1095 | 1233 | ||
1096 | for (i = 0; i < dev->addr_len; i++) { | 1234 | for (i = 0; i < ndev->addr_len; i++) { |
1097 | data = ha->addr[i]; | 1235 | data = ha->addr[i]; |
1098 | for (bit = 0; bit < 8; bit++, data >>= 1) { | 1236 | for (bit = 0; bit < 8; bit++, data >>= 1) { |
1099 | crc = (crc >> 1) ^ | 1237 | crc = (crc >> 1) ^ |
@@ -1120,20 +1258,20 @@ static void set_multicast_list(struct net_device *dev) | |||
1120 | 1258 | ||
1121 | /* Set a MAC change in hardware. */ | 1259 | /* Set a MAC change in hardware. */ |
1122 | static int | 1260 | static int |
1123 | fec_set_mac_address(struct net_device *dev, void *p) | 1261 | fec_set_mac_address(struct net_device *ndev, void *p) |
1124 | { | 1262 | { |
1125 | struct fec_enet_private *fep = netdev_priv(dev); | 1263 | struct fec_enet_private *fep = netdev_priv(ndev); |
1126 | struct sockaddr *addr = p; | 1264 | struct sockaddr *addr = p; |
1127 | 1265 | ||
1128 | if (!is_valid_ether_addr(addr->sa_data)) | 1266 | if (!is_valid_ether_addr(addr->sa_data)) |
1129 | return -EADDRNOTAVAIL; | 1267 | return -EADDRNOTAVAIL; |
1130 | 1268 | ||
1131 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | 1269 | memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len); |
1132 | 1270 | ||
1133 | writel(dev->dev_addr[3] | (dev->dev_addr[2] << 8) | | 1271 | writel(ndev->dev_addr[3] | (ndev->dev_addr[2] << 8) | |
1134 | (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24), | 1272 | (ndev->dev_addr[1] << 16) | (ndev->dev_addr[0] << 24), |
1135 | fep->hwp + FEC_ADDR_LOW); | 1273 | fep->hwp + FEC_ADDR_LOW); |
1136 | writel((dev->dev_addr[5] << 16) | (dev->dev_addr[4] << 24), | 1274 | writel((ndev->dev_addr[5] << 16) | (ndev->dev_addr[4] << 24), |
1137 | fep->hwp + FEC_ADDR_HIGH); | 1275 | fep->hwp + FEC_ADDR_HIGH); |
1138 | return 0; | 1276 | return 0; |
1139 | } | 1277 | } |
@@ -1147,16 +1285,16 @@ static const struct net_device_ops fec_netdev_ops = { | |||
1147 | .ndo_validate_addr = eth_validate_addr, | 1285 | .ndo_validate_addr = eth_validate_addr, |
1148 | .ndo_tx_timeout = fec_timeout, | 1286 | .ndo_tx_timeout = fec_timeout, |
1149 | .ndo_set_mac_address = fec_set_mac_address, | 1287 | .ndo_set_mac_address = fec_set_mac_address, |
1150 | .ndo_do_ioctl = fec_enet_ioctl, | 1288 | .ndo_do_ioctl = fec_enet_ioctl, |
1151 | }; | 1289 | }; |
1152 | 1290 | ||
1153 | /* | 1291 | /* |
1154 | * XXX: We need to clean up on failure exits here. | 1292 | * XXX: We need to clean up on failure exits here. |
1155 | * | 1293 | * |
1156 | */ | 1294 | */ |
1157 | static int fec_enet_init(struct net_device *dev) | 1295 | static int fec_enet_init(struct net_device *ndev) |
1158 | { | 1296 | { |
1159 | struct fec_enet_private *fep = netdev_priv(dev); | 1297 | struct fec_enet_private *fep = netdev_priv(ndev); |
1160 | struct bufdesc *cbd_base; | 1298 | struct bufdesc *cbd_base; |
1161 | struct bufdesc *bdp; | 1299 | struct bufdesc *bdp; |
1162 | int i; | 1300 | int i; |
@@ -1171,20 +1309,19 @@ static int fec_enet_init(struct net_device *dev) | |||
1171 | 1309 | ||
1172 | spin_lock_init(&fep->hw_lock); | 1310 | spin_lock_init(&fep->hw_lock); |
1173 | 1311 | ||
1174 | fep->hwp = (void __iomem *)dev->base_addr; | 1312 | fep->netdev = ndev; |
1175 | fep->netdev = dev; | ||
1176 | 1313 | ||
1177 | /* Get the Ethernet address */ | 1314 | /* Get the Ethernet address */ |
1178 | fec_get_mac(dev); | 1315 | fec_get_mac(ndev); |
1179 | 1316 | ||
1180 | /* Set receive and transmit descriptor base. */ | 1317 | /* Set receive and transmit descriptor base. */ |
1181 | fep->rx_bd_base = cbd_base; | 1318 | fep->rx_bd_base = cbd_base; |
1182 | fep->tx_bd_base = cbd_base + RX_RING_SIZE; | 1319 | fep->tx_bd_base = cbd_base + RX_RING_SIZE; |
1183 | 1320 | ||
1184 | /* The FEC Ethernet specific entries in the device structure */ | 1321 | /* The FEC Ethernet specific entries in the device structure */ |
1185 | dev->watchdog_timeo = TX_TIMEOUT; | 1322 | ndev->watchdog_timeo = TX_TIMEOUT; |
1186 | dev->netdev_ops = &fec_netdev_ops; | 1323 | ndev->netdev_ops = &fec_netdev_ops; |
1187 | dev->ethtool_ops = &fec_enet_ethtool_ops; | 1324 | ndev->ethtool_ops = &fec_enet_ethtool_ops; |
1188 | 1325 | ||
1189 | /* Initialize the receive buffer descriptors. */ | 1326 | /* Initialize the receive buffer descriptors. */ |
1190 | bdp = fep->rx_bd_base; | 1327 | bdp = fep->rx_bd_base; |
@@ -1213,152 +1350,11 @@ static int fec_enet_init(struct net_device *dev) | |||
1213 | bdp--; | 1350 | bdp--; |
1214 | bdp->cbd_sc |= BD_SC_WRAP; | 1351 | bdp->cbd_sc |= BD_SC_WRAP; |
1215 | 1352 | ||
1216 | fec_restart(dev, 0); | 1353 | fec_restart(ndev, 0); |
1217 | 1354 | ||
1218 | return 0; | 1355 | return 0; |
1219 | } | 1356 | } |
1220 | 1357 | ||
1221 | /* This function is called to start or restart the FEC during a link | ||
1222 | * change. This only happens when switching between half and full | ||
1223 | * duplex. | ||
1224 | */ | ||
1225 | static void | ||
1226 | fec_restart(struct net_device *dev, int duplex) | ||
1227 | { | ||
1228 | struct fec_enet_private *fep = netdev_priv(dev); | ||
1229 | const struct platform_device_id *id_entry = | ||
1230 | platform_get_device_id(fep->pdev); | ||
1231 | int i; | ||
1232 | u32 val, temp_mac[2]; | ||
1233 | |||
1234 | /* Whack a reset. We should wait for this. */ | ||
1235 | writel(1, fep->hwp + FEC_ECNTRL); | ||
1236 | udelay(10); | ||
1237 | |||
1238 | /* | ||
1239 | * enet-mac reset will reset mac address registers too, | ||
1240 | * so need to reconfigure it. | ||
1241 | */ | ||
1242 | if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { | ||
1243 | memcpy(&temp_mac, dev->dev_addr, ETH_ALEN); | ||
1244 | writel(cpu_to_be32(temp_mac[0]), fep->hwp + FEC_ADDR_LOW); | ||
1245 | writel(cpu_to_be32(temp_mac[1]), fep->hwp + FEC_ADDR_HIGH); | ||
1246 | } | ||
1247 | |||
1248 | /* Clear any outstanding interrupt. */ | ||
1249 | writel(0xffc00000, fep->hwp + FEC_IEVENT); | ||
1250 | |||
1251 | /* Reset all multicast. */ | ||
1252 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); | ||
1253 | writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW); | ||
1254 | #ifndef CONFIG_M5272 | ||
1255 | writel(0, fep->hwp + FEC_HASH_TABLE_HIGH); | ||
1256 | writel(0, fep->hwp + FEC_HASH_TABLE_LOW); | ||
1257 | #endif | ||
1258 | |||
1259 | /* Set maximum receive buffer size. */ | ||
1260 | writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE); | ||
1261 | |||
1262 | /* Set receive and transmit descriptor base. */ | ||
1263 | writel(fep->bd_dma, fep->hwp + FEC_R_DES_START); | ||
1264 | writel((unsigned long)fep->bd_dma + sizeof(struct bufdesc) * RX_RING_SIZE, | ||
1265 | fep->hwp + FEC_X_DES_START); | ||
1266 | |||
1267 | fep->dirty_tx = fep->cur_tx = fep->tx_bd_base; | ||
1268 | fep->cur_rx = fep->rx_bd_base; | ||
1269 | |||
1270 | /* Reset SKB transmit buffers. */ | ||
1271 | fep->skb_cur = fep->skb_dirty = 0; | ||
1272 | for (i = 0; i <= TX_RING_MOD_MASK; i++) { | ||
1273 | if (fep->tx_skbuff[i]) { | ||
1274 | dev_kfree_skb_any(fep->tx_skbuff[i]); | ||
1275 | fep->tx_skbuff[i] = NULL; | ||
1276 | } | ||
1277 | } | ||
1278 | |||
1279 | /* Enable MII mode */ | ||
1280 | if (duplex) { | ||
1281 | /* MII enable / FD enable */ | ||
1282 | writel(OPT_FRAME_SIZE | 0x04, fep->hwp + FEC_R_CNTRL); | ||
1283 | writel(0x04, fep->hwp + FEC_X_CNTRL); | ||
1284 | } else { | ||
1285 | /* MII enable / No Rcv on Xmit */ | ||
1286 | writel(OPT_FRAME_SIZE | 0x06, fep->hwp + FEC_R_CNTRL); | ||
1287 | writel(0x0, fep->hwp + FEC_X_CNTRL); | ||
1288 | } | ||
1289 | fep->full_duplex = duplex; | ||
1290 | |||
1291 | /* Set MII speed */ | ||
1292 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); | ||
1293 | |||
1294 | /* | ||
1295 | * The phy interface and speed need to get configured | ||
1296 | * differently on enet-mac. | ||
1297 | */ | ||
1298 | if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) { | ||
1299 | val = readl(fep->hwp + FEC_R_CNTRL); | ||
1300 | |||
1301 | /* MII or RMII */ | ||
1302 | if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) | ||
1303 | val |= (1 << 8); | ||
1304 | else | ||
1305 | val &= ~(1 << 8); | ||
1306 | |||
1307 | /* 10M or 100M */ | ||
1308 | if (fep->phy_dev && fep->phy_dev->speed == SPEED_100) | ||
1309 | val &= ~(1 << 9); | ||
1310 | else | ||
1311 | val |= (1 << 9); | ||
1312 | |||
1313 | writel(val, fep->hwp + FEC_R_CNTRL); | ||
1314 | } else { | ||
1315 | #ifdef FEC_MIIGSK_ENR | ||
1316 | if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) { | ||
1317 | /* disable the gasket and wait */ | ||
1318 | writel(0, fep->hwp + FEC_MIIGSK_ENR); | ||
1319 | while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4) | ||
1320 | udelay(1); | ||
1321 | |||
1322 | /* | ||
1323 | * configure the gasket: | ||
1324 | * RMII, 50 MHz, no loopback, no echo | ||
1325 | */ | ||
1326 | writel(1, fep->hwp + FEC_MIIGSK_CFGR); | ||
1327 | |||
1328 | /* re-enable the gasket */ | ||
1329 | writel(2, fep->hwp + FEC_MIIGSK_ENR); | ||
1330 | } | ||
1331 | #endif | ||
1332 | } | ||
1333 | |||
1334 | /* And last, enable the transmit and receive processing */ | ||
1335 | writel(2, fep->hwp + FEC_ECNTRL); | ||
1336 | writel(0, fep->hwp + FEC_R_DES_ACTIVE); | ||
1337 | |||
1338 | /* Enable interrupts we wish to service */ | ||
1339 | writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); | ||
1340 | } | ||
1341 | |||
1342 | static void | ||
1343 | fec_stop(struct net_device *dev) | ||
1344 | { | ||
1345 | struct fec_enet_private *fep = netdev_priv(dev); | ||
1346 | |||
1347 | /* We cannot expect a graceful transmit stop without link !!! */ | ||
1348 | if (fep->link) { | ||
1349 | writel(1, fep->hwp + FEC_X_CNTRL); /* Graceful transmit stop */ | ||
1350 | udelay(10); | ||
1351 | if (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_GRA)) | ||
1352 | printk("fec_stop : Graceful transmit stop did not complete !\n"); | ||
1353 | } | ||
1354 | |||
1355 | /* Whack a reset. We should wait for this. */ | ||
1356 | writel(1, fep->hwp + FEC_ECNTRL); | ||
1357 | udelay(10); | ||
1358 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); | ||
1359 | writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK); | ||
1360 | } | ||
1361 | |||
1362 | static int __devinit | 1358 | static int __devinit |
1363 | fec_probe(struct platform_device *pdev) | 1359 | fec_probe(struct platform_device *pdev) |
1364 | { | 1360 | { |
@@ -1378,19 +1374,20 @@ fec_probe(struct platform_device *pdev) | |||
1378 | 1374 | ||
1379 | /* Init network device */ | 1375 | /* Init network device */ |
1380 | ndev = alloc_etherdev(sizeof(struct fec_enet_private)); | 1376 | ndev = alloc_etherdev(sizeof(struct fec_enet_private)); |
1381 | if (!ndev) | 1377 | if (!ndev) { |
1382 | return -ENOMEM; | 1378 | ret = -ENOMEM; |
1379 | goto failed_alloc_etherdev; | ||
1380 | } | ||
1383 | 1381 | ||
1384 | SET_NETDEV_DEV(ndev, &pdev->dev); | 1382 | SET_NETDEV_DEV(ndev, &pdev->dev); |
1385 | 1383 | ||
1386 | /* setup board info structure */ | 1384 | /* setup board info structure */ |
1387 | fep = netdev_priv(ndev); | 1385 | fep = netdev_priv(ndev); |
1388 | memset(fep, 0, sizeof(*fep)); | ||
1389 | 1386 | ||
1390 | ndev->base_addr = (unsigned long)ioremap(r->start, resource_size(r)); | 1387 | fep->hwp = ioremap(r->start, resource_size(r)); |
1391 | fep->pdev = pdev; | 1388 | fep->pdev = pdev; |
1392 | 1389 | ||
1393 | if (!ndev->base_addr) { | 1390 | if (!fep->hwp) { |
1394 | ret = -ENOMEM; | 1391 | ret = -ENOMEM; |
1395 | goto failed_ioremap; | 1392 | goto failed_ioremap; |
1396 | } | 1393 | } |
@@ -1408,10 +1405,9 @@ fec_probe(struct platform_device *pdev) | |||
1408 | break; | 1405 | break; |
1409 | ret = request_irq(irq, fec_enet_interrupt, IRQF_DISABLED, pdev->name, ndev); | 1406 | ret = request_irq(irq, fec_enet_interrupt, IRQF_DISABLED, pdev->name, ndev); |
1410 | if (ret) { | 1407 | if (ret) { |
1411 | while (i >= 0) { | 1408 | while (--i >= 0) { |
1412 | irq = platform_get_irq(pdev, i); | 1409 | irq = platform_get_irq(pdev, i); |
1413 | free_irq(irq, ndev); | 1410 | free_irq(irq, ndev); |
1414 | i--; | ||
1415 | } | 1411 | } |
1416 | goto failed_irq; | 1412 | goto failed_irq; |
1417 | } | 1413 | } |
@@ -1454,9 +1450,11 @@ failed_clk: | |||
1454 | free_irq(irq, ndev); | 1450 | free_irq(irq, ndev); |
1455 | } | 1451 | } |
1456 | failed_irq: | 1452 | failed_irq: |
1457 | iounmap((void __iomem *)ndev->base_addr); | 1453 | iounmap(fep->hwp); |
1458 | failed_ioremap: | 1454 | failed_ioremap: |
1459 | free_netdev(ndev); | 1455 | free_netdev(ndev); |
1456 | failed_alloc_etherdev: | ||
1457 | release_mem_region(r->start, resource_size(r)); | ||
1460 | 1458 | ||
1461 | return ret; | 1459 | return ret; |
1462 | } | 1460 | } |
@@ -1466,16 +1464,22 @@ fec_drv_remove(struct platform_device *pdev) | |||
1466 | { | 1464 | { |
1467 | struct net_device *ndev = platform_get_drvdata(pdev); | 1465 | struct net_device *ndev = platform_get_drvdata(pdev); |
1468 | struct fec_enet_private *fep = netdev_priv(ndev); | 1466 | struct fec_enet_private *fep = netdev_priv(ndev); |
1469 | 1467 | struct resource *r; | |
1470 | platform_set_drvdata(pdev, NULL); | ||
1471 | 1468 | ||
1472 | fec_stop(ndev); | 1469 | fec_stop(ndev); |
1473 | fec_enet_mii_remove(fep); | 1470 | fec_enet_mii_remove(fep); |
1474 | clk_disable(fep->clk); | 1471 | clk_disable(fep->clk); |
1475 | clk_put(fep->clk); | 1472 | clk_put(fep->clk); |
1476 | iounmap((void __iomem *)ndev->base_addr); | 1473 | iounmap(fep->hwp); |
1477 | unregister_netdev(ndev); | 1474 | unregister_netdev(ndev); |
1478 | free_netdev(ndev); | 1475 | free_netdev(ndev); |
1476 | |||
1477 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1478 | BUG_ON(!r); | ||
1479 | release_mem_region(r->start, resource_size(r)); | ||
1480 | |||
1481 | platform_set_drvdata(pdev, NULL); | ||
1482 | |||
1479 | return 0; | 1483 | return 0; |
1480 | } | 1484 | } |
1481 | 1485 | ||
@@ -1484,16 +1488,14 @@ static int | |||
1484 | fec_suspend(struct device *dev) | 1488 | fec_suspend(struct device *dev) |
1485 | { | 1489 | { |
1486 | struct net_device *ndev = dev_get_drvdata(dev); | 1490 | struct net_device *ndev = dev_get_drvdata(dev); |
1487 | struct fec_enet_private *fep; | 1491 | struct fec_enet_private *fep = netdev_priv(ndev); |
1488 | 1492 | ||
1489 | if (ndev) { | 1493 | if (netif_running(ndev)) { |
1490 | fep = netdev_priv(ndev); | 1494 | fec_stop(ndev); |
1491 | if (netif_running(ndev)) { | 1495 | netif_device_detach(ndev); |
1492 | fec_stop(ndev); | ||
1493 | netif_device_detach(ndev); | ||
1494 | } | ||
1495 | clk_disable(fep->clk); | ||
1496 | } | 1496 | } |
1497 | clk_disable(fep->clk); | ||
1498 | |||
1497 | return 0; | 1499 | return 0; |
1498 | } | 1500 | } |
1499 | 1501 | ||
@@ -1501,16 +1503,14 @@ static int | |||
1501 | fec_resume(struct device *dev) | 1503 | fec_resume(struct device *dev) |
1502 | { | 1504 | { |
1503 | struct net_device *ndev = dev_get_drvdata(dev); | 1505 | struct net_device *ndev = dev_get_drvdata(dev); |
1504 | struct fec_enet_private *fep; | 1506 | struct fec_enet_private *fep = netdev_priv(ndev); |
1505 | 1507 | ||
1506 | if (ndev) { | 1508 | clk_enable(fep->clk); |
1507 | fep = netdev_priv(ndev); | 1509 | if (netif_running(ndev)) { |
1508 | clk_enable(fep->clk); | 1510 | fec_restart(ndev, fep->full_duplex); |
1509 | if (netif_running(ndev)) { | 1511 | netif_device_attach(ndev); |
1510 | fec_restart(ndev, fep->full_duplex); | ||
1511 | netif_device_attach(ndev); | ||
1512 | } | ||
1513 | } | 1512 | } |
1513 | |||
1514 | return 0; | 1514 | return 0; |
1515 | } | 1515 | } |
1516 | 1516 | ||