diff options
Diffstat (limited to 'drivers/net/ibm_newemac')
-rw-r--r-- | drivers/net/ibm_newemac/core.c | 87 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/core.h | 12 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/debug.c | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/debug.h | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/emac.h | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/mal.c | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/mal.h | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/phy.c | 81 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/phy.h | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/rgmii.c | 25 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/rgmii.h | 10 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/tah.c | 8 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/tah.h | 5 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/zmii.c | 9 | ||||
-rw-r--r-- | drivers/net/ibm_newemac/zmii.h | 5 |
15 files changed, 227 insertions, 45 deletions
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 0de3aa2a2e44..cb06280dced5 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
@@ -402,7 +407,7 @@ static u32 __emac_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_s | |||
402 | static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_size) | 407 | static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_size) |
403 | { | 408 | { |
404 | u32 ret = EMAC_MR1_VLE | EMAC_MR1_IST | EMAC4_MR1_TR | | 409 | u32 ret = EMAC_MR1_VLE | EMAC_MR1_IST | EMAC4_MR1_TR | |
405 | EMAC4_MR1_OBCI(dev->opb_bus_freq); | 410 | EMAC4_MR1_OBCI(dev->opb_bus_freq / 1000000); |
406 | 411 | ||
407 | DBG2(dev, "__emac4_calc_base_mr1" NL); | 412 | DBG2(dev, "__emac4_calc_base_mr1" NL); |
408 | 413 | ||
@@ -464,26 +469,34 @@ static int emac_configure(struct emac_instance *dev) | |||
464 | { | 469 | { |
465 | struct emac_regs __iomem *p = dev->emacp; | 470 | struct emac_regs __iomem *p = dev->emacp; |
466 | struct net_device *ndev = dev->ndev; | 471 | struct net_device *ndev = dev->ndev; |
467 | int tx_size, rx_size; | 472 | int tx_size, rx_size, link = netif_carrier_ok(dev->ndev); |
468 | u32 r, mr1 = 0; | 473 | u32 r, mr1 = 0; |
469 | 474 | ||
470 | DBG(dev, "configure" NL); | 475 | DBG(dev, "configure" NL); |
471 | 476 | ||
472 | if (emac_reset(dev) < 0) | 477 | if (!link) { |
478 | out_be32(&p->mr1, in_be32(&p->mr1) | ||
479 | | EMAC_MR1_FDE | EMAC_MR1_ILE); | ||
480 | udelay(100); | ||
481 | } else if (emac_reset(dev) < 0) | ||
473 | return -ETIMEDOUT; | 482 | return -ETIMEDOUT; |
474 | 483 | ||
475 | if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) | 484 | if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) |
476 | tah_reset(dev->tah_dev); | 485 | tah_reset(dev->tah_dev); |
477 | 486 | ||
478 | DBG(dev, " duplex = %d, pause = %d, asym_pause = %d\n", | 487 | DBG(dev, " link = %d duplex = %d, pause = %d, asym_pause = %d\n", |
479 | dev->phy.duplex, dev->phy.pause, dev->phy.asym_pause); | 488 | link, dev->phy.duplex, dev->phy.pause, dev->phy.asym_pause); |
480 | 489 | ||
481 | /* Default fifo sizes */ | 490 | /* Default fifo sizes */ |
482 | tx_size = dev->tx_fifo_size; | 491 | tx_size = dev->tx_fifo_size; |
483 | rx_size = dev->rx_fifo_size; | 492 | rx_size = dev->rx_fifo_size; |
484 | 493 | ||
494 | /* No link, force loopback */ | ||
495 | if (!link) | ||
496 | mr1 = EMAC_MR1_FDE | EMAC_MR1_ILE; | ||
497 | |||
485 | /* Check for full duplex */ | 498 | /* Check for full duplex */ |
486 | if (dev->phy.duplex == DUPLEX_FULL) | 499 | else if (dev->phy.duplex == DUPLEX_FULL) |
487 | mr1 |= EMAC_MR1_FDE | EMAC_MR1_MWSW_001; | 500 | mr1 |= EMAC_MR1_FDE | EMAC_MR1_MWSW_001; |
488 | 501 | ||
489 | /* Adjust fifo sizes, mr1 and timeouts based on link speed */ | 502 | /* Adjust fifo sizes, mr1 and timeouts based on link speed */ |
@@ -642,9 +655,11 @@ static void emac_reset_work(struct work_struct *work) | |||
642 | DBG(dev, "reset_work" NL); | 655 | DBG(dev, "reset_work" NL); |
643 | 656 | ||
644 | mutex_lock(&dev->link_lock); | 657 | mutex_lock(&dev->link_lock); |
645 | emac_netif_stop(dev); | 658 | if (dev->opened) { |
646 | emac_full_tx_reset(dev); | 659 | emac_netif_stop(dev); |
647 | emac_netif_start(dev); | 660 | emac_full_tx_reset(dev); |
661 | emac_netif_start(dev); | ||
662 | } | ||
648 | mutex_unlock(&dev->link_lock); | 663 | mutex_unlock(&dev->link_lock); |
649 | } | 664 | } |
650 | 665 | ||
@@ -701,7 +716,7 @@ static int __emac_mdio_read(struct emac_instance *dev, u8 id, u8 reg) | |||
701 | r = EMAC_STACR_BASE(dev->opb_bus_freq); | 716 | r = EMAC_STACR_BASE(dev->opb_bus_freq); |
702 | if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT)) | 717 | if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT)) |
703 | r |= EMAC_STACR_OC; | 718 | r |= EMAC_STACR_OC; |
704 | if (emac_has_feature(dev, EMAC_FTR_HAS_AXON_STACR)) | 719 | if (emac_has_feature(dev, EMAC_FTR_HAS_NEW_STACR)) |
705 | r |= EMACX_STACR_STAC_READ; | 720 | r |= EMACX_STACR_STAC_READ; |
706 | else | 721 | else |
707 | r |= EMAC_STACR_STAC_READ; | 722 | r |= EMAC_STACR_STAC_READ; |
@@ -773,7 +788,7 @@ static void __emac_mdio_write(struct emac_instance *dev, u8 id, u8 reg, | |||
773 | r = EMAC_STACR_BASE(dev->opb_bus_freq); | 788 | r = EMAC_STACR_BASE(dev->opb_bus_freq); |
774 | if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT)) | 789 | if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT)) |
775 | r |= EMAC_STACR_OC; | 790 | r |= EMAC_STACR_OC; |
776 | if (emac_has_feature(dev, EMAC_FTR_HAS_AXON_STACR)) | 791 | if (emac_has_feature(dev, EMAC_FTR_HAS_NEW_STACR)) |
777 | r |= EMACX_STACR_STAC_WRITE; | 792 | r |= EMACX_STACR_STAC_WRITE; |
778 | else | 793 | else |
779 | r |= EMAC_STACR_STAC_WRITE; | 794 | r |= EMAC_STACR_STAC_WRITE; |
@@ -1063,10 +1078,9 @@ static int emac_open(struct net_device *ndev) | |||
1063 | dev->rx_sg_skb = NULL; | 1078 | dev->rx_sg_skb = NULL; |
1064 | 1079 | ||
1065 | mutex_lock(&dev->link_lock); | 1080 | mutex_lock(&dev->link_lock); |
1081 | dev->opened = 1; | ||
1066 | 1082 | ||
1067 | /* XXX Start PHY polling now. Shouldn't wr do like sungem instead and | 1083 | /* Start PHY polling now. |
1068 | * always poll the PHY even when the iface is down ? That would allow | ||
1069 | * things like laptop-net to work. --BenH | ||
1070 | */ | 1084 | */ |
1071 | if (dev->phy.address >= 0) { | 1085 | if (dev->phy.address >= 0) { |
1072 | int link_poll_interval; | 1086 | int link_poll_interval; |
@@ -1145,9 +1159,11 @@ static void emac_link_timer(struct work_struct *work) | |||
1145 | int link_poll_interval; | 1159 | int link_poll_interval; |
1146 | 1160 | ||
1147 | mutex_lock(&dev->link_lock); | 1161 | mutex_lock(&dev->link_lock); |
1148 | |||
1149 | DBG2(dev, "link timer" NL); | 1162 | DBG2(dev, "link timer" NL); |
1150 | 1163 | ||
1164 | if (!dev->opened) | ||
1165 | goto bail; | ||
1166 | |||
1151 | if (dev->phy.def->ops->poll_link(&dev->phy)) { | 1167 | if (dev->phy.def->ops->poll_link(&dev->phy)) { |
1152 | if (!netif_carrier_ok(dev->ndev)) { | 1168 | if (!netif_carrier_ok(dev->ndev)) { |
1153 | /* Get new link parameters */ | 1169 | /* Get new link parameters */ |
@@ -1162,21 +1178,22 @@ static void emac_link_timer(struct work_struct *work) | |||
1162 | link_poll_interval = PHY_POLL_LINK_ON; | 1178 | link_poll_interval = PHY_POLL_LINK_ON; |
1163 | } else { | 1179 | } else { |
1164 | if (netif_carrier_ok(dev->ndev)) { | 1180 | if (netif_carrier_ok(dev->ndev)) { |
1165 | emac_reinitialize(dev); | ||
1166 | netif_carrier_off(dev->ndev); | 1181 | netif_carrier_off(dev->ndev); |
1167 | netif_tx_disable(dev->ndev); | 1182 | netif_tx_disable(dev->ndev); |
1183 | emac_reinitialize(dev); | ||
1168 | emac_print_link_status(dev); | 1184 | emac_print_link_status(dev); |
1169 | } | 1185 | } |
1170 | link_poll_interval = PHY_POLL_LINK_OFF; | 1186 | link_poll_interval = PHY_POLL_LINK_OFF; |
1171 | } | 1187 | } |
1172 | schedule_delayed_work(&dev->link_work, link_poll_interval); | 1188 | schedule_delayed_work(&dev->link_work, link_poll_interval); |
1173 | 1189 | bail: | |
1174 | mutex_unlock(&dev->link_lock); | 1190 | mutex_unlock(&dev->link_lock); |
1175 | } | 1191 | } |
1176 | 1192 | ||
1177 | static void emac_force_link_update(struct emac_instance *dev) | 1193 | static void emac_force_link_update(struct emac_instance *dev) |
1178 | { | 1194 | { |
1179 | netif_carrier_off(dev->ndev); | 1195 | netif_carrier_off(dev->ndev); |
1196 | smp_rmb(); | ||
1180 | if (dev->link_polling) { | 1197 | if (dev->link_polling) { |
1181 | cancel_rearming_delayed_work(&dev->link_work); | 1198 | cancel_rearming_delayed_work(&dev->link_work); |
1182 | if (dev->link_polling) | 1199 | if (dev->link_polling) |
@@ -1191,11 +1208,14 @@ static int emac_close(struct net_device *ndev) | |||
1191 | 1208 | ||
1192 | DBG(dev, "close" NL); | 1209 | DBG(dev, "close" NL); |
1193 | 1210 | ||
1194 | if (dev->phy.address >= 0) | 1211 | if (dev->phy.address >= 0) { |
1212 | dev->link_polling = 0; | ||
1195 | cancel_rearming_delayed_work(&dev->link_work); | 1213 | cancel_rearming_delayed_work(&dev->link_work); |
1196 | 1214 | } | |
1215 | mutex_lock(&dev->link_lock); | ||
1197 | emac_netif_stop(dev); | 1216 | emac_netif_stop(dev); |
1198 | flush_scheduled_work(); | 1217 | dev->opened = 0; |
1218 | mutex_unlock(&dev->link_lock); | ||
1199 | 1219 | ||
1200 | emac_rx_disable(dev); | 1220 | emac_rx_disable(dev); |
1201 | emac_tx_disable(dev); | 1221 | emac_tx_disable(dev); |
@@ -2427,7 +2447,7 @@ static int __devinit emac_init_config(struct emac_instance *dev) | |||
2427 | if (emac_read_uint_prop(np, "tah-device", &dev->tah_ph, 0)) | 2447 | if (emac_read_uint_prop(np, "tah-device", &dev->tah_ph, 0)) |
2428 | dev->tah_ph = 0; | 2448 | dev->tah_ph = 0; |
2429 | if (emac_read_uint_prop(np, "tah-channel", &dev->tah_port, 0)) | 2449 | if (emac_read_uint_prop(np, "tah-channel", &dev->tah_port, 0)) |
2430 | dev->tah_ph = 0; | 2450 | dev->tah_port = 0; |
2431 | if (emac_read_uint_prop(np, "mdio-device", &dev->mdio_ph, 0)) | 2451 | if (emac_read_uint_prop(np, "mdio-device", &dev->mdio_ph, 0)) |
2432 | dev->mdio_ph = 0; | 2452 | dev->mdio_ph = 0; |
2433 | if (emac_read_uint_prop(np, "zmii-device", &dev->zmii_ph, 0)) | 2453 | if (emac_read_uint_prop(np, "zmii-device", &dev->zmii_ph, 0)) |
@@ -2465,16 +2485,19 @@ static int __devinit emac_init_config(struct emac_instance *dev) | |||
2465 | /* Check EMAC version */ | 2485 | /* Check EMAC version */ |
2466 | if (of_device_is_compatible(np, "ibm,emac4")) | 2486 | if (of_device_is_compatible(np, "ibm,emac4")) |
2467 | dev->features |= EMAC_FTR_EMAC4; | 2487 | dev->features |= EMAC_FTR_EMAC4; |
2468 | if (of_device_is_compatible(np, "ibm,emac-axon") | 2488 | |
2469 | || of_device_is_compatible(np, "ibm,emac-440epx")) | 2489 | /* Fixup some feature bits based on the device tree */ |
2470 | dev->features |= EMAC_FTR_HAS_AXON_STACR | 2490 | if (of_get_property(np, "has-inverted-stacr-oc", NULL)) |
2471 | | EMAC_FTR_STACR_OC_INVERT; | ||
2472 | if (of_device_is_compatible(np, "ibm,emac-440spe")) | ||
2473 | dev->features |= EMAC_FTR_STACR_OC_INVERT; | 2491 | dev->features |= EMAC_FTR_STACR_OC_INVERT; |
2492 | if (of_get_property(np, "has-new-stacr-staopc", NULL)) | ||
2493 | dev->features |= EMAC_FTR_HAS_NEW_STACR; | ||
2474 | 2494 | ||
2475 | /* Fixup some feature bits based on the device tree and verify | 2495 | /* CAB lacks the appropriate properties */ |
2476 | * we have support for them compiled in | 2496 | if (of_device_is_compatible(np, "ibm,emac-axon")) |
2477 | */ | 2497 | dev->features |= EMAC_FTR_HAS_NEW_STACR | |
2498 | EMAC_FTR_STACR_OC_INVERT; | ||
2499 | |||
2500 | /* Enable TAH/ZMII/RGMII features as found */ | ||
2478 | if (dev->tah_ph != 0) { | 2501 | if (dev->tah_ph != 0) { |
2479 | #ifdef CONFIG_IBM_NEW_EMAC_TAH | 2502 | #ifdef CONFIG_IBM_NEW_EMAC_TAH |
2480 | dev->features |= EMAC_FTR_HAS_TAH; | 2503 | dev->features |= EMAC_FTR_HAS_TAH; |
@@ -2532,6 +2555,10 @@ static int __devinit emac_probe(struct of_device *ofdev, | |||
2532 | struct device_node **blist = NULL; | 2555 | struct device_node **blist = NULL; |
2533 | int err, i; | 2556 | int err, i; |
2534 | 2557 | ||
2558 | /* Skip unused/unwired EMACS */ | ||
2559 | if (of_get_property(np, "unused", NULL)) | ||
2560 | return -ENODEV; | ||
2561 | |||
2535 | /* Find ourselves in the bootlist if we are there */ | 2562 | /* Find ourselves in the bootlist if we are there */ |
2536 | for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++) | 2563 | for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++) |
2537 | if (emac_boot_list[i] == np) | 2564 | if (emac_boot_list[i] == np) |
@@ -2756,6 +2783,8 @@ static int __devexit emac_remove(struct of_device *ofdev) | |||
2756 | 2783 | ||
2757 | unregister_netdev(dev->ndev); | 2784 | unregister_netdev(dev->ndev); |
2758 | 2785 | ||
2786 | flush_scheduled_work(); | ||
2787 | |||
2759 | if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) | 2788 | if (emac_has_feature(dev, EMAC_FTR_HAS_TAH)) |
2760 | tah_detach(dev->tah_dev, dev->tah_port); | 2789 | tah_detach(dev->tah_dev, dev->tah_port); |
2761 | if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) | 2790 | if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) |
diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h index 4011803117ca..4e74d8287c65 100644 --- a/drivers/net/ibm_newemac/core.h +++ b/drivers/net/ibm_newemac/core.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
@@ -258,6 +263,7 @@ struct emac_instance { | |||
258 | int stop_timeout; /* in us */ | 263 | int stop_timeout; /* in us */ |
259 | int no_mcast; | 264 | int no_mcast; |
260 | int mcast_pending; | 265 | int mcast_pending; |
266 | int opened; | ||
261 | struct work_struct reset_work; | 267 | struct work_struct reset_work; |
262 | spinlock_t lock; | 268 | spinlock_t lock; |
263 | }; | 269 | }; |
@@ -292,9 +298,9 @@ struct emac_instance { | |||
292 | */ | 298 | */ |
293 | #define EMAC_FTR_HAS_RGMII 0x00000020 | 299 | #define EMAC_FTR_HAS_RGMII 0x00000020 |
294 | /* | 300 | /* |
295 | * Set if we have axon-type STACR | 301 | * Set if we have new type STACR with STAOPC |
296 | */ | 302 | */ |
297 | #define EMAC_FTR_HAS_AXON_STACR 0x00000040 | 303 | #define EMAC_FTR_HAS_NEW_STACR 0x00000040 |
298 | 304 | ||
299 | 305 | ||
300 | /* Right now, we don't quite handle the always/possible masks on the | 306 | /* Right now, we don't quite handle the always/possible masks on the |
@@ -306,7 +312,7 @@ enum { | |||
306 | 312 | ||
307 | EMAC_FTRS_POSSIBLE = | 313 | EMAC_FTRS_POSSIBLE = |
308 | #ifdef CONFIG_IBM_NEW_EMAC_EMAC4 | 314 | #ifdef CONFIG_IBM_NEW_EMAC_EMAC4 |
309 | EMAC_FTR_EMAC4 | EMAC_FTR_HAS_AXON_STACR | | 315 | EMAC_FTR_EMAC4 | EMAC_FTR_HAS_NEW_STACR | |
310 | EMAC_FTR_STACR_OC_INVERT | | 316 | EMAC_FTR_STACR_OC_INVERT | |
311 | #endif | 317 | #endif |
312 | #ifdef CONFIG_IBM_NEW_EMAC_TAH | 318 | #ifdef CONFIG_IBM_NEW_EMAC_TAH |
diff --git a/drivers/net/ibm_newemac/debug.c b/drivers/net/ibm_newemac/debug.c index 170524ee0f19..a2fc660ca5d4 100644 --- a/drivers/net/ibm_newemac/debug.c +++ b/drivers/net/ibm_newemac/debug.c | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies | 11 | * Copyright (c) 2004, 2005 Zultys Technologies |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/debug.h b/drivers/net/ibm_newemac/debug.h index 1dd2dcbc157f..b631842ec8d0 100644 --- a/drivers/net/ibm_newemac/debug.h +++ b/drivers/net/ibm_newemac/debug.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies | 11 | * Copyright (c) 2004, 2005 Zultys Technologies |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/emac.h b/drivers/net/ibm_newemac/emac.h index bef92efeeadc..91cb096ab405 100644 --- a/drivers/net/ibm_newemac/emac.h +++ b/drivers/net/ibm_newemac/emac.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Register definitions for PowerPC 4xx on-chip ethernet contoller | 4 | * Register definitions for PowerPC 4xx on-chip ethernet contoller |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c index 9a88f71db004..6869f08c9dcb 100644 --- a/drivers/net/ibm_newemac/mal.c +++ b/drivers/net/ibm_newemac/mal.c | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Memory Access Layer (MAL) support | 4 | * Memory Access Layer (MAL) support |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/mal.h b/drivers/net/ibm_newemac/mal.h index 784edb8ea822..eaa7262dc079 100644 --- a/drivers/net/ibm_newemac/mal.h +++ b/drivers/net/ibm_newemac/mal.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Memory Access Layer (MAL) support | 4 | * Memory Access Layer (MAL) support |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/phy.c b/drivers/net/ibm_newemac/phy.c index aa1f0ddf1e3e..37bfeea8788a 100644 --- a/drivers/net/ibm_newemac/phy.c +++ b/drivers/net/ibm_newemac/phy.c | |||
@@ -8,6 +8,11 @@ | |||
8 | * This file should be shared with other drivers or eventually | 8 | * This file should be shared with other drivers or eventually |
9 | * merged as the "low level" part of miilib | 9 | * merged as the "low level" part of miilib |
10 | * | 10 | * |
11 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
12 | * <benh@kernel.crashing.org> | ||
13 | * | ||
14 | * Based on the arch/ppc version of the driver: | ||
15 | * | ||
11 | * (c) 2003, Benjamin Herrenscmidt (benh@kernel.crashing.org) | 16 | * (c) 2003, Benjamin Herrenscmidt (benh@kernel.crashing.org) |
12 | * (c) 2004-2005, Eugene Surovegin <ebs@ebshome.net> | 17 | * (c) 2004-2005, Eugene Surovegin <ebs@ebshome.net> |
13 | * | 18 | * |
@@ -306,8 +311,84 @@ static struct mii_phy_def cis8201_phy_def = { | |||
306 | .ops = &cis8201_phy_ops | 311 | .ops = &cis8201_phy_ops |
307 | }; | 312 | }; |
308 | 313 | ||
314 | static struct mii_phy_def bcm5248_phy_def = { | ||
315 | |||
316 | .phy_id = 0x0143bc00, | ||
317 | .phy_id_mask = 0x0ffffff0, | ||
318 | .name = "BCM5248 10/100 SMII Ethernet", | ||
319 | .ops = &generic_phy_ops | ||
320 | }; | ||
321 | |||
322 | static int m88e1111_init(struct mii_phy *phy) | ||
323 | { | ||
324 | pr_debug("%s: Marvell 88E1111 Ethernet\n", __FUNCTION__); | ||
325 | phy_write(phy, 0x14, 0x0ce3); | ||
326 | phy_write(phy, 0x18, 0x4101); | ||
327 | phy_write(phy, 0x09, 0x0e00); | ||
328 | phy_write(phy, 0x04, 0x01e1); | ||
329 | phy_write(phy, 0x00, 0x9140); | ||
330 | phy_write(phy, 0x00, 0x1140); | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | static int et1011c_init(struct mii_phy *phy) | ||
336 | { | ||
337 | u16 reg_short; | ||
338 | |||
339 | reg_short = (u16)(phy_read(phy, 0x16)); | ||
340 | reg_short &= ~(0x7); | ||
341 | reg_short |= 0x6; /* RGMII Trace Delay*/ | ||
342 | phy_write(phy, 0x16, reg_short); | ||
343 | |||
344 | reg_short = (u16)(phy_read(phy, 0x17)); | ||
345 | reg_short &= ~(0x40); | ||
346 | phy_write(phy, 0x17, reg_short); | ||
347 | |||
348 | phy_write(phy, 0x1c, 0x74f0); | ||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | static struct mii_phy_ops et1011c_phy_ops = { | ||
353 | .init = et1011c_init, | ||
354 | .setup_aneg = genmii_setup_aneg, | ||
355 | .setup_forced = genmii_setup_forced, | ||
356 | .poll_link = genmii_poll_link, | ||
357 | .read_link = genmii_read_link | ||
358 | }; | ||
359 | |||
360 | static struct mii_phy_def et1011c_phy_def = { | ||
361 | .phy_id = 0x0282f000, | ||
362 | .phy_id_mask = 0x0fffff00, | ||
363 | .name = "ET1011C Gigabit Ethernet", | ||
364 | .ops = &et1011c_phy_ops | ||
365 | }; | ||
366 | |||
367 | |||
368 | |||
369 | |||
370 | |||
371 | static struct mii_phy_ops m88e1111_phy_ops = { | ||
372 | .init = m88e1111_init, | ||
373 | .setup_aneg = genmii_setup_aneg, | ||
374 | .setup_forced = genmii_setup_forced, | ||
375 | .poll_link = genmii_poll_link, | ||
376 | .read_link = genmii_read_link | ||
377 | }; | ||
378 | |||
379 | static struct mii_phy_def m88e1111_phy_def = { | ||
380 | |||
381 | .phy_id = 0x01410CC0, | ||
382 | .phy_id_mask = 0x0ffffff0, | ||
383 | .name = "Marvell 88E1111 Ethernet", | ||
384 | .ops = &m88e1111_phy_ops, | ||
385 | }; | ||
386 | |||
309 | static struct mii_phy_def *mii_phy_table[] = { | 387 | static struct mii_phy_def *mii_phy_table[] = { |
388 | &et1011c_phy_def, | ||
310 | &cis8201_phy_def, | 389 | &cis8201_phy_def, |
390 | &bcm5248_phy_def, | ||
391 | &m88e1111_phy_def, | ||
311 | &genmii_phy_def, | 392 | &genmii_phy_def, |
312 | NULL | 393 | NULL |
313 | }; | 394 | }; |
diff --git a/drivers/net/ibm_newemac/phy.h b/drivers/net/ibm_newemac/phy.h index 6feca26afedb..1b65c81f6557 100644 --- a/drivers/net/ibm_newemac/phy.h +++ b/drivers/net/ibm_newemac/phy.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, PHY support | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, PHY support |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Benjamin Herrenschmidt <benh@kernel.crashing.org> | 11 | * Benjamin Herrenschmidt <benh@kernel.crashing.org> |
7 | * February 2003 | 12 | * February 2003 |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c index de416951a435..9bc1132fa788 100644 --- a/drivers/net/ibm_newemac/rgmii.c +++ b/drivers/net/ibm_newemac/rgmii.c | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
@@ -140,7 +145,7 @@ void rgmii_get_mdio(struct of_device *ofdev, int input) | |||
140 | 145 | ||
141 | RGMII_DBG2(dev, "get_mdio(%d)" NL, input); | 146 | RGMII_DBG2(dev, "get_mdio(%d)" NL, input); |
142 | 147 | ||
143 | if (dev->type != RGMII_AXON) | 148 | if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) |
144 | return; | 149 | return; |
145 | 150 | ||
146 | mutex_lock(&dev->lock); | 151 | mutex_lock(&dev->lock); |
@@ -161,7 +166,7 @@ void rgmii_put_mdio(struct of_device *ofdev, int input) | |||
161 | 166 | ||
162 | RGMII_DBG2(dev, "put_mdio(%d)" NL, input); | 167 | RGMII_DBG2(dev, "put_mdio(%d)" NL, input); |
163 | 168 | ||
164 | if (dev->type != RGMII_AXON) | 169 | if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) |
165 | return; | 170 | return; |
166 | 171 | ||
167 | fer = in_be32(&p->fer); | 172 | fer = in_be32(&p->fer); |
@@ -250,11 +255,13 @@ static int __devinit rgmii_probe(struct of_device *ofdev, | |||
250 | goto err_free; | 255 | goto err_free; |
251 | } | 256 | } |
252 | 257 | ||
253 | /* Check for RGMII type */ | 258 | /* Check for RGMII flags */ |
259 | if (of_get_property(ofdev->node, "has-mdio", NULL)) | ||
260 | dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; | ||
261 | |||
262 | /* CAB lacks the right properties, fix this up */ | ||
254 | if (of_device_is_compatible(ofdev->node, "ibm,rgmii-axon")) | 263 | if (of_device_is_compatible(ofdev->node, "ibm,rgmii-axon")) |
255 | dev->type = RGMII_AXON; | 264 | dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; |
256 | else | ||
257 | dev->type = RGMII_STANDARD; | ||
258 | 265 | ||
259 | DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", | 266 | DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", |
260 | in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); | 267 | in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); |
@@ -263,9 +270,9 @@ static int __devinit rgmii_probe(struct of_device *ofdev, | |||
263 | out_be32(&dev->base->fer, 0); | 270 | out_be32(&dev->base->fer, 0); |
264 | 271 | ||
265 | printk(KERN_INFO | 272 | printk(KERN_INFO |
266 | "RGMII %s %s initialized\n", | 273 | "RGMII %s initialized with%s MDIO support\n", |
267 | dev->type == RGMII_STANDARD ? "standard" : "axon", | 274 | ofdev->node->full_name, |
268 | ofdev->node->full_name); | 275 | (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); |
269 | 276 | ||
270 | wmb(); | 277 | wmb(); |
271 | dev_set_drvdata(&ofdev->dev, dev); | 278 | dev_set_drvdata(&ofdev->dev, dev); |
diff --git a/drivers/net/ibm_newemac/rgmii.h b/drivers/net/ibm_newemac/rgmii.h index 57806833121e..c4a4b358a270 100644 --- a/drivers/net/ibm_newemac/rgmii.h +++ b/drivers/net/ibm_newemac/rgmii.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Based on ocp_zmii.h/ibm_emac_zmii.h | 11 | * Based on ocp_zmii.h/ibm_emac_zmii.h |
7 | * Armin Kuster akuster@mvista.com | 12 | * Armin Kuster akuster@mvista.com |
8 | * | 13 | * |
@@ -35,8 +40,9 @@ struct rgmii_regs { | |||
35 | struct rgmii_instance { | 40 | struct rgmii_instance { |
36 | struct rgmii_regs __iomem *base; | 41 | struct rgmii_regs __iomem *base; |
37 | 42 | ||
38 | /* Type of RGMII bridge */ | 43 | /* RGMII bridge flags */ |
39 | int type; | 44 | int flags; |
45 | #define EMAC_RGMII_FLAG_HAS_MDIO 0x00000001 | ||
40 | 46 | ||
41 | /* Only one EMAC whacks us at a time */ | 47 | /* Only one EMAC whacks us at a time */ |
42 | struct mutex lock; | 48 | struct mutex lock; |
diff --git a/drivers/net/ibm_newemac/tah.c b/drivers/net/ibm_newemac/tah.c index f161fb100e8e..96417adec326 100644 --- a/drivers/net/ibm_newemac/tah.c +++ b/drivers/net/ibm_newemac/tah.c | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright 2004 MontaVista Software, Inc. | 11 | * Copyright 2004 MontaVista Software, Inc. |
7 | * Matt Porter <mporter@kernel.crashing.org> | 12 | * Matt Porter <mporter@kernel.crashing.org> |
8 | * | 13 | * |
@@ -116,13 +121,14 @@ static int __devinit tah_probe(struct of_device *ofdev, | |||
116 | goto err_free; | 121 | goto err_free; |
117 | } | 122 | } |
118 | 123 | ||
124 | dev_set_drvdata(&ofdev->dev, dev); | ||
125 | |||
119 | /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ | 126 | /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ |
120 | tah_reset(ofdev); | 127 | tah_reset(ofdev); |
121 | 128 | ||
122 | printk(KERN_INFO | 129 | printk(KERN_INFO |
123 | "TAH %s initialized\n", ofdev->node->full_name); | 130 | "TAH %s initialized\n", ofdev->node->full_name); |
124 | wmb(); | 131 | wmb(); |
125 | dev_set_drvdata(&ofdev->dev, dev); | ||
126 | 132 | ||
127 | return 0; | 133 | return 0; |
128 | 134 | ||
diff --git a/drivers/net/ibm_newemac/tah.h b/drivers/net/ibm_newemac/tah.h index bc41853b6e26..a068b5658dad 100644 --- a/drivers/net/ibm_newemac/tah.h +++ b/drivers/net/ibm_newemac/tah.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright 2004 MontaVista Software, Inc. | 11 | * Copyright 2004 MontaVista Software, Inc. |
7 | * Matt Porter <mporter@kernel.crashing.org> | 12 | * Matt Porter <mporter@kernel.crashing.org> |
8 | * | 13 | * |
diff --git a/drivers/net/ibm_newemac/zmii.c b/drivers/net/ibm_newemac/zmii.c index 2219ec2740e0..2ea472aeab06 100644 --- a/drivers/net/ibm_newemac/zmii.c +++ b/drivers/net/ibm_newemac/zmii.c | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |
@@ -83,12 +88,14 @@ int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode) | |||
83 | 88 | ||
84 | ZMII_DBG(dev, "init(%d, %d)" NL, input, *mode); | 89 | ZMII_DBG(dev, "init(%d, %d)" NL, input, *mode); |
85 | 90 | ||
86 | if (!zmii_valid_mode(*mode)) | 91 | if (!zmii_valid_mode(*mode)) { |
87 | /* Probably an EMAC connected to RGMII, | 92 | /* Probably an EMAC connected to RGMII, |
88 | * but it still may need ZMII for MDIO so | 93 | * but it still may need ZMII for MDIO so |
89 | * we don't fail here. | 94 | * we don't fail here. |
90 | */ | 95 | */ |
96 | dev->users++; | ||
91 | return 0; | 97 | return 0; |
98 | } | ||
92 | 99 | ||
93 | mutex_lock(&dev->lock); | 100 | mutex_lock(&dev->lock); |
94 | 101 | ||
diff --git a/drivers/net/ibm_newemac/zmii.h b/drivers/net/ibm_newemac/zmii.h index 82a9968b1f74..6c9beba0c4b6 100644 --- a/drivers/net/ibm_newemac/zmii.h +++ b/drivers/net/ibm_newemac/zmii.h | |||
@@ -3,6 +3,11 @@ | |||
3 | * | 3 | * |
4 | * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. | 4 | * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. |
5 | * | 5 | * |
6 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. | ||
7 | * <benh@kernel.crashing.org> | ||
8 | * | ||
9 | * Based on the arch/ppc version of the driver: | ||
10 | * | ||
6 | * Copyright (c) 2004, 2005 Zultys Technologies. | 11 | * Copyright (c) 2004, 2005 Zultys Technologies. |
7 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | 12 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
8 | * | 13 | * |