public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] e1000: Driver additions for eXMeritus HWW-1U-1A
@ 2011-02-11 23:37 Kyle Moffett
  2011-02-11 23:37 ` [U-Boot] [PATCH 1/5] e1000: Clean up handling of dual-port NICs and support 82571 Kyle Moffett
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Kyle Moffett @ 2011-02-11 23:37 UTC (permalink / raw)
  To: u-boot

Sorry for taking so long to update and re-post these; I've had a lot of other
things on my plate for the last several months.  I've re-based them against
the latest U-Boot master branch as of today.

The following 5 patches are a series to provide the necessary support for
the onboard Intel 82571 E1000E chips on our eXMeritus HWW-1U-1A boards.

There are a few incidental fixups for dual-port NICs, but the main body of
these patches is an SPI driver and "e1000 eeprom" commands for programming
the configuration EEPROM attached to the 82571 chips.

Our manufacturing process directly attaches the unprogrammed EEPROMs to the
boards.  We then use this code to load the Intel EEPROM and update the
MAC address.

The overall diffstat is:
 drivers/net/e1000.c |  848 ++++++++++++++++++++++++++++++++++++++++++++-------
 drivers/net/e1000.h |   18 +-
 2 files changed, 751 insertions(+), 115 deletions(-)

Most of the new code is hidden behind a couple of config options, so it won't
affect other users of e1000 chips unless they explicitly request it.

Cheers,
Kyle Moffett

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [U-Boot] [PATCH 1/5] e1000: Clean up handling of dual-port NICs and support 82571
@ 2010-09-13 15:52 Kyle Moffett
  2010-09-13 15:52 ` [U-Boot] [PATCH 4/5] e1000: New "e1000" commands for SPI EEPROM management Kyle Moffett
  0 siblings, 1 reply; 15+ messages in thread
From: Kyle Moffett @ 2010-09-13 15:52 UTC (permalink / raw)
  To: u-boot

Consolidate the test for a dual-port NIC to one location for easy
modification, then fix support for the dual-port 82571.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 drivers/net/e1000.c |   66 +++++++++++++++++++++++++-------------------------
 drivers/net/e1000.h |    6 ----
 2 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 2825342..28cedf7 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -1096,6 +1096,20 @@ e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask)
 	return E1000_SUCCESS;
 }
 
+static boolean_t e1000_is_second_port(struct e1000_hw *hw)
+{
+	switch (hw->mac_type) {
+	case e1000_80003es2lan:
+	case e1000_82546:
+	case e1000_82571:
+		if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
+			return TRUE;
+		/* Fallthrough */
+	default:
+		return FALSE;
+	}
+}
+
 /******************************************************************************
  * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
  * second function of dual function devices
@@ -1122,11 +1136,11 @@ e1000_read_mac_addr(struct eth_device *nic)
 		nic->enetaddr[i] = eeprom_data & 0xff;
 		nic->enetaddr[i + 1] = (eeprom_data >> 8) & 0xff;
 	}
-	if ((hw->mac_type == e1000_82546) &&
-	    (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
-		/* Invert the last bit if this is the second device */
-		nic->enetaddr[5] += 1;
-	}
+
+	/* Invert the last bit if this is the second device */
+	if (e1000_is_second_port(hw))
+		nic->enetaddr[5] ^= 1;
+
 #ifdef CONFIG_E1000_FALLBACK_MAC
 	if ( *(u32*)(nic->enetaddr) == 0 || *(u32*)(nic->enetaddr) == ~0 ) {
 		unsigned char fb_mac[NODE_ADDRESS_SIZE] = CONFIG_E1000_FALLBACK_MAC;
@@ -2528,16 +2542,13 @@ e1000_check_mng_mode(struct e1000_hw *hw)
 static int32_t
 e1000_write_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data)
 {
+	uint16_t swfw = E1000_SWFW_PHY0_SM;
 	uint32_t reg_val;
-	uint16_t swfw;
 	DEBUGFUNC();
 
-	if ((hw->mac_type == e1000_80003es2lan) &&
-		(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
+	if (e1000_is_second_port(hw))
 		swfw = E1000_SWFW_PHY1_SM;
-	} else {
-		swfw = E1000_SWFW_PHY0_SM;
-	}
+
 	if (e1000_swfw_sync_acquire(hw, swfw))
 		return -E1000_ERR_SWFW_SYNC;
 
@@ -2552,16 +2563,13 @@ e1000_write_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data)
 static int32_t
 e1000_read_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *data)
 {
+	uint16_t swfw = E1000_SWFW_PHY0_SM;
 	uint32_t reg_val;
-	uint16_t swfw;
 	DEBUGFUNC();
 
-	if ((hw->mac_type == e1000_80003es2lan) &&
-	    (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
+	if (e1000_is_second_port(hw))
 		swfw = E1000_SWFW_PHY1_SM;
-	} else {
-		swfw = E1000_SWFW_PHY0_SM;
-	}
+
 	if (e1000_swfw_sync_acquire(hw, swfw))
 		return -E1000_ERR_SWFW_SYNC;
 
@@ -4259,11 +4267,13 @@ e1000_get_phy_cfg_done(struct e1000_hw *hw)
 	default:
 		mdelay(10);
 		break;
+
 	case e1000_80003es2lan:
 		/* Separate *_CFG_DONE_* bit for each port */
-		if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
+		if (e1000_is_second_port(hw))
 			cfg_mask = E1000_EEPROM_CFG_DONE_PORT_1;
-	/* Fall Through */
+		/* Fall Through */
+
 	case e1000_82571:
 	case e1000_82572:
 		while (timeout) {
@@ -4292,10 +4302,10 @@ e1000_get_phy_cfg_done(struct e1000_hw *hw)
 int32_t
 e1000_phy_hw_reset(struct e1000_hw *hw)
 {
+	uint16_t swfw = E1000_SWFW_PHY0_SM;
 	uint32_t ctrl, ctrl_ext;
 	uint32_t led_ctrl;
 	int32_t ret_val;
-	uint16_t swfw;
 
 	DEBUGFUNC();
 
@@ -4308,16 +4318,14 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
 	DEBUGOUT("Resetting Phy...\n");
 
 	if (hw->mac_type > e1000_82543) {
-		if ((hw->mac_type == e1000_80003es2lan) &&
-			(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
+		if (e1000_is_second_port(hw))
 			swfw = E1000_SWFW_PHY1_SM;
-		} else {
-			swfw = E1000_SWFW_PHY0_SM;
-		}
+
 		if (e1000_swfw_sync_acquire(hw, swfw)) {
 			DEBUGOUT("Unable to acquire swfw sync\n");
 			return -E1000_ERR_SWFW_SYNC;
 		}
+
 		/* Read the device control register and assert the E1000_CTRL_PHY_RST
 		 * bit. Then, take it out of reset.
 		 */
@@ -4771,14 +4779,6 @@ e1000_sw_init(struct eth_device *nic, int cardnum)
 		break;
 	}
 
-	/* lan a vs. lan b settings */
-	if (hw->mac_type == e1000_82546)
-		/*this also works w/ multiple 82546 cards */
-		/*but not if they're intermingled /w other e1000s */
-		hw->lan_loc = (cardnum % 2) ? e1000_lan_b : e1000_lan_a;
-	else
-		hw->lan_loc = e1000_lan_a;
-
 	/* flow control settings */
 	hw->fc_high_water = E1000_FC_HIGH_THRESH;
 	hw->fc_low_water = E1000_FC_LOW_THRESH;
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index eb0804b..8597e23 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -111,11 +111,6 @@ typedef enum {
 	e1000_100_full = 3
 } e1000_speed_duplex_type;
 
-typedef enum {
-	e1000_lan_a = 0,
-	e1000_lan_b = 1
-} e1000_lan_loc;
-
 /* Flow Control Settings */
 typedef enum {
 	e1000_fc_none = 0,
@@ -1055,7 +1050,6 @@ struct e1000_hw {
 	uint32_t phy_init_script;
 	uint32_t txd_cmd;
 	e1000_media_type media_type;
-	e1000_lan_loc lan_loc;
 	e1000_fc_type fc;
 	e1000_bus_type bus_type;
 #if 0
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2011-04-13 14:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-11 23:37 [U-Boot] e1000: Driver additions for eXMeritus HWW-1U-1A Kyle Moffett
2011-02-11 23:37 ` [U-Boot] [PATCH 1/5] e1000: Clean up handling of dual-port NICs and support 82571 Kyle Moffett
2011-02-11 23:37 ` [U-Boot] [PATCH 2/5] e1000: Restructure and streamline PCI device probing Kyle Moffett
2011-04-12 20:17   ` Wolfgang Denk
2011-04-12 22:56     ` Moffett, Kyle D
2011-04-13  5:13       ` Wolfgang Denk
2011-02-11 23:38 ` [U-Boot] [PATCH 3/5] e1000: Rewrite EEPROM checksum error to give more information Kyle Moffett
2011-02-11 23:38 ` [U-Boot] [PATCH 4/5] e1000: New "e1000" commands for SPI EEPROM management Kyle Moffett
2011-04-12 20:24   ` Wolfgang Denk
2011-04-12 23:26     ` Moffett, Kyle D
2011-04-13  5:23       ` Wolfgang Denk
2011-04-13 14:54         ` Moffett, Kyle D
2011-02-11 23:38 ` [U-Boot] [PATCH 5/5] e1000: Add a small SPI driver wrapper around the EEPROM code Kyle Moffett
2011-04-12 20:25   ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2010-09-13 15:52 [U-Boot] [PATCH 1/5] e1000: Clean up handling of dual-port NICs and support 82571 Kyle Moffett
2010-09-13 15:52 ` [U-Boot] [PATCH 4/5] e1000: New "e1000" commands for SPI EEPROM management Kyle Moffett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox