aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_82598.c
diff options
context:
space:
mode:
authorAuke Kok <auke-jan.h.kok@intel.com>2007-10-31 18:22:10 -0400
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:03:44 -0500
commit3957d63da0067ad6a7dc8261b7eeb824f9dc42b4 (patch)
tree6566a29315969cb531f204d3a5c4ebcb8a1fc311 /drivers/net/ixgbe/ixgbe_82598.c
parent040babf9d84e7010c457e9ce69e9eb1c27927c9e (diff)
ixgbe: Fix copper PHY initialization code
While cleaning up the internal API focussing on Fiber and CX4 code we found that I had broken the copper PHY initialization code. This patch restores the PHY-specific code. This is mostly uninteresting since no copper PHY boards are yet available. The changes have been tested against Fiber only as I do not even have copper PHY versions of 82598 macs. This change actually cleans up the API code a bit more and we lose some initialization code. A few PHY link detection helper lines of code have been snuck into this patch, as well as a read flush where it was suspected that this might cause issues. Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_82598.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c156
1 files changed, 47 insertions, 109 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 4d64673164ca..6321b059ce13 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -50,8 +50,6 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw, u32 speed,
50 bool autoneg, 50 bool autoneg,
51 bool autoneg_wait_to_complete); 51 bool autoneg_wait_to_complete);
52static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw); 52static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw);
53static s32 ixgbe_check_copper_link_82598(struct ixgbe_hw *hw, u32 *speed,
54 bool *link_up);
55static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, u32 speed, 53static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, u32 speed,
56 bool autoneg, 54 bool autoneg,
57 bool autoneg_wait_to_complete); 55 bool autoneg_wait_to_complete);
@@ -64,6 +62,28 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
64 hw->mac.num_tx_queues = IXGBE_82598_MAX_RX_QUEUES; 62 hw->mac.num_tx_queues = IXGBE_82598_MAX_RX_QUEUES;
65 hw->mac.num_rx_addrs = IXGBE_82598_RAR_ENTRIES; 63 hw->mac.num_rx_addrs = IXGBE_82598_RAR_ENTRIES;
66 64
65 /* PHY ops are filled in by default properly for Fiber only */
66 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
67 hw->mac.ops.setup_link = &ixgbe_setup_copper_link_82598;
68 hw->mac.ops.setup_link_speed = &ixgbe_setup_copper_link_speed_82598;
69 hw->mac.ops.get_link_settings =
70 &ixgbe_get_copper_link_settings_82598;
71
72 /* Call PHY identify routine to get the phy type */
73 ixgbe_identify_phy(hw);
74
75 switch (hw->phy.type) {
76 case ixgbe_phy_tn:
77 hw->phy.ops.setup_link = &ixgbe_setup_tnx_phy_link;
78 hw->phy.ops.check_link = &ixgbe_check_tnx_phy_link;
79 hw->phy.ops.setup_link_speed =
80 &ixgbe_setup_tnx_phy_link_speed;
81 break;
82 default:
83 break;
84 }
85 }
86
67 return 0; 87 return 0;
68} 88}
69 89
@@ -206,6 +226,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
206 autoc_reg |= hw->mac.link_mode_select; 226 autoc_reg |= hw->mac.link_mode_select;
207 227
208 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); 228 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
229 IXGBE_WRITE_FLUSH(hw);
209 msleep(50); 230 msleep(50);
210 } 231 }
211 232
@@ -314,7 +335,7 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,
314 * ixgbe_hw This will write the AUTOC register based on the new 335 * ixgbe_hw This will write the AUTOC register based on the new
315 * stored values 336 * stored values
316 */ 337 */
317 hw->phy.ops.setup(hw); 338 hw->mac.ops.setup_link(hw);
318 } 339 }
319 340
320 return status; 341 return status;
@@ -332,72 +353,18 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,
332 **/ 353 **/
333static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw) 354static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)
334{ 355{
335 s32 status; 356 s32 status = 0;
336 u32 speed = 0;
337 bool link_up = false;
338
339 /* Set up MAC */
340 hw->phy.ops.setup(hw);
341 357
342 /* Restart autonegotiation on PHY */ 358 /* Restart autonegotiation on PHY */
343 status = hw->phy.ops.setup(hw); 359 if (hw->phy.ops.setup_link)
344 360 status = hw->phy.ops.setup_link(hw);
345 /* Synchronize MAC to PHY speed */
346 if (status == 0)
347 status = hw->phy.ops.check(hw, &speed, &link_up);
348
349 return status;
350}
351 361
352/** 362 /* Set MAC to KX/KX4 autoneg, which defaultis to Parallel detection */
353 * ixgbe_check_copper_link_82598 - Syncs MAC & PHY link settings 363 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);
354 * @hw: pointer to hardware structure 364 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;
355 * @speed: pointer to link speed
356 * @link_up: true if link is up, false otherwise
357 *
358 * Reads the mac link, phy link, and synchronizes the MAC to PHY.
359 **/
360static s32 ixgbe_check_copper_link_82598(struct ixgbe_hw *hw, u32 *speed,
361 bool *link_up)
362{
363 s32 status;
364 u32 phy_speed = 0;
365 bool phy_link = false;
366 365
367 /* This is the speed and link the MAC is set at */ 366 /* Set up MAC */
368 hw->phy.ops.check(hw, speed, link_up); 367 hw->mac.ops.setup_link(hw);
369
370 /*
371 * Check current speed and link status of the PHY register.
372 * This is a vendor specific register and may have to
373 * be changed for other copper PHYs.
374 */
375 status = hw->phy.ops.check(hw, &phy_speed, &phy_link);
376
377 if ((status == 0) && (phy_link)) {
378 /*
379 * Check current link status of the MACs link's register
380 * matches that of the speed in the PHY register
381 */
382 if (*speed != phy_speed) {
383 /*
384 * The copper PHY requires 82598 attach type to be XAUI
385 * for 10G and BX for 1G
386 */
387 hw->mac.link_attach_type =
388 (IXGBE_AUTOC_10G_XAUI | IXGBE_AUTOC_1G_BX);
389
390 /* Synchronize the MAC speed to the PHY speed */
391 status = hw->phy.ops.setup_speed(hw, phy_speed, false,
392 false);
393 if (status == 0)
394 hw->phy.ops.check(hw, speed, link_up);
395 else
396 status = IXGBE_ERR_LINK_SETUP;
397 }
398 } else {
399 *link_up = phy_link;
400 }
401 368
402 return status; 369 return status;
403} 370}
@@ -415,16 +382,19 @@ static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, u32 speed,
415 bool autoneg, 382 bool autoneg,
416 bool autoneg_wait_to_complete) 383 bool autoneg_wait_to_complete)
417{ 384{
418 s32 status; 385 s32 status = 0;
419 bool link_up = 0;
420 386
421 /* Setup the PHY according to input speed */ 387 /* Setup the PHY according to input speed */
422 status = hw->phy.ops.setup_speed(hw, speed, autoneg, 388 if (hw->phy.ops.setup_link_speed)
423 autoneg_wait_to_complete); 389 status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
390 autoneg_wait_to_complete);
391
392 /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */
393 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);
394 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;
424 395
425 /* Synchronize MAC to PHY speed */ 396 /* Set up MAC */
426 if (status == 0) 397 hw->mac.ops.setup_link(hw);
427 status = hw->phy.ops.check(hw, &speed, &link_up);
428 398
429 return status; 399 return status;
430} 400}
@@ -542,47 +512,15 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
542static struct ixgbe_mac_operations mac_ops_82598 = { 512static struct ixgbe_mac_operations mac_ops_82598 = {
543 .reset = &ixgbe_reset_hw_82598, 513 .reset = &ixgbe_reset_hw_82598,
544 .get_media_type = &ixgbe_get_media_type_82598, 514 .get_media_type = &ixgbe_get_media_type_82598,
515 .setup_link = &ixgbe_setup_mac_link_82598,
516 .check_link = &ixgbe_check_mac_link_82598,
517 .setup_link_speed = &ixgbe_setup_mac_link_speed_82598,
518 .get_link_settings = &ixgbe_get_link_settings_82598,
545}; 519};
546 520
547static struct ixgbe_phy_operations phy_ops_82598EB = { 521struct ixgbe_info ixgbe_82598_info = {
548 .setup = &ixgbe_setup_copper_link_82598,
549 .check = &ixgbe_check_copper_link_82598,
550 .setup_speed = &ixgbe_setup_copper_link_speed_82598,
551 .get_settings = &ixgbe_get_copper_link_settings_82598,
552};
553
554struct ixgbe_info ixgbe_82598EB_info = {
555 .mac = ixgbe_mac_82598EB,
556 .get_invariants = &ixgbe_get_invariants_82598,
557 .mac_ops = &mac_ops_82598,
558 .phy_ops = &phy_ops_82598EB,
559};
560
561static struct ixgbe_phy_operations phy_ops_82598AT = {
562 .setup = &ixgbe_setup_tnx_phy_link,
563 .check = &ixgbe_check_tnx_phy_link,
564 .setup_speed = &ixgbe_setup_tnx_phy_link_speed,
565 .get_settings = &ixgbe_get_copper_link_settings_82598,
566};
567
568struct ixgbe_info ixgbe_82598AT_info = {
569 .mac = ixgbe_mac_82598EB,
570 .get_invariants = &ixgbe_get_invariants_82598,
571 .mac_ops = &mac_ops_82598,
572 .phy_ops = &phy_ops_82598AT,
573};
574
575static struct ixgbe_phy_operations phy_ops_82598AF = {
576 .setup = &ixgbe_setup_mac_link_82598,
577 .check = &ixgbe_check_mac_link_82598,
578 .setup_speed = &ixgbe_setup_mac_link_speed_82598,
579 .get_settings = &ixgbe_get_link_settings_82598,
580};
581
582struct ixgbe_info ixgbe_82598AF_info = {
583 .mac = ixgbe_mac_82598EB, 522 .mac = ixgbe_mac_82598EB,
584 .get_invariants = &ixgbe_get_invariants_82598, 523 .get_invariants = &ixgbe_get_invariants_82598,
585 .mac_ops = &mac_ops_82598, 524 .mac_ops = &mac_ops_82598,
586 .phy_ops = &phy_ops_82598AF,
587}; 525};
588 526