public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Dannenberg <dannenberg@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 15/18] ti: common: am6: Add support for setting MAC addresses
Date: Wed, 8 May 2019 16:37:48 -0500	[thread overview]
Message-ID: <20190508213751.23179-16-dannenberg@ti.com> (raw)
In-Reply-To: <20190508213751.23179-1-dannenberg@ti.com>

The AM654x EVM based on the TI K3 family of SoCs has an updated board
detection EEPROM structure that contains a TLV record of dedicated MAC
addresses rather than a range of MAC addresses as it was used on earlier
platforms such as DRA7. Add a basic function that allows us setting up
Ethernet MAC addresses into the U-Boot environment based on the MAC
address record contained in the common TI EEPROM structure.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
---
 board/ti/common/board_detect.c | 32 ++++++++++++++++++++++++++++++++
 board/ti/common/board_detect.h | 12 ++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index fea39f21e8..32fa10599e 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -534,6 +534,25 @@ fail:
 	memset(mac_addr, 0, TI_EEPROM_HDR_ETH_ALEN);
 }
 
+void __maybe_unused
+board_ti_am6_get_eth_mac_addr(int index,
+			      u8 mac_addr[TI_EEPROM_HDR_ETH_ALEN])
+{
+	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
+
+	if (ep->header == TI_DEAD_EEPROM_MAGIC)
+		goto fail;
+
+	if (index < 0 || index >= ep->mac_addr_cnt)
+		goto fail;
+
+	memcpy(mac_addr, ep->mac_addr[index], TI_EEPROM_HDR_ETH_ALEN);
+	return;
+
+fail:
+	memset(mac_addr, 0, TI_EEPROM_HDR_ETH_ALEN);
+}
+
 u64 __maybe_unused board_ti_get_emif1_size(void)
 {
 	struct ti_common_eeprom *ep = TI_EEPROM_DATA;
@@ -667,6 +686,19 @@ void board_ti_set_ethaddr(int index)
 	}
 }
 
+void board_ti_am6_set_ethaddr(int index, int count)
+{
+	u8 mac_addr[6];
+	int i;
+
+	for (i = 0; i < count; i++) {
+		board_ti_am6_get_eth_mac_addr(i, mac_addr);
+		if (is_valid_ethaddr(mac_addr))
+			eth_env_set_enetaddr_by_index("eth", i + index,
+						      mac_addr);
+	}
+}
+
 bool __maybe_unused board_ti_was_eeprom_read(void)
 {
 	struct ti_common_eeprom *ep = TI_EEPROM_DATA;
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index bf563c84c8..a45d8961b9 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -398,6 +398,18 @@ void set_board_info_env_am6(char *name);
  */
 void board_ti_set_ethaddr(int index);
 
+/**
+ * board_ti_am6_set_ethaddr- Sets the ethaddr environment from EEPROM
+ * @index: The first eth<index>addr environment variable to set
+ * @count: The number of MAC addresses to process
+ *
+ * EEPROM should be already read before calling this function. The EEPROM
+ * contains n dedicated MAC addresses. This function sets the ethaddr
+ * environment variable for all the available MAC addresses starting
+ * from eth<index>addr.
+ */
+void board_ti_am6_set_ethaddr(int index, int count);
+
 /**
  * board_ti_was_eeprom_read() - Check to see if the eeprom contents have been read
  *
-- 
2.17.1

  parent reply	other threads:[~2019-05-08 21:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 21:37 [U-Boot] [PATCH 00/18] Add EEPROM-based board detect support for TI Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 01/18] i2c: omap24xx_i2c: Adapt driver to support K3 devices Andreas Dannenberg
2019-05-09 11:19   ` Heiko Schocher
2019-05-08 21:37 ` [U-Boot] [PATCH 02/18] arm: omap_i2c: Remove unwanted header file inclusion Andreas Dannenberg
2019-05-09 11:20   ` Heiko Schocher
2019-05-08 21:37 ` [U-Boot] [PATCH 03/18] arm: dts: k3-am65: Move pinctrl nodes out of U-Boot specific dtsi Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 04/18] arm: dts: k3-am65: Add I2C nodes Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 05/18] arm: dts: k3-am654-base-board: Enable wkup_i2c0 across all boot stages Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 06/18] configs: am65x_evm_defconfig: Enable I2C support Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 07/18] configs: am65x_hs_evm_defconfig: " Andreas Dannenberg
2019-05-08 21:53   ` Andrew F. Davis
2019-05-08 21:37 ` [U-Boot] [PATCH 08/18] arm64: dts: k3-am654-base-board: Add I2C GPIO expander @ 0x38 Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 09/18] configs: am65x_evm_a53: Enable PCA953X-type GPIO driver Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 10/18] configs: am65x_hs_evm_a53: " Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 11/18] configs: am65x_evm_a53: Increase malloc pool before relocation Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 12/18] configs: am65x_hs_evm_a53: " Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 13/18] arm: K3: am654: Map common EEPROM data into SRAM scratch space Andreas Dannenberg
2019-05-09  3:52   ` Lokesh Vutla
2019-05-09 16:03     ` Andrew F. Davis
2019-05-09 16:27       ` Andreas Dannenberg
2019-05-15 20:11         ` Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 14/18] ti: common: am6: Add support for board description EEPROM Andreas Dannenberg
2019-05-08 21:37 ` Andreas Dannenberg [this message]
2019-05-08 21:37 ` [U-Boot] [PATCH 16/18] board: ti: am654: Use EEPROM-based board detection Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 17/18] configs: am65x_evm: Add support for applying overlays Andreas Dannenberg
2019-05-08 21:37 ` [U-Boot] [PATCH 18/18] configs: am65x_hs_evm: " Andreas Dannenberg
2019-05-16 20:25 ` [U-Boot] [PATCH 00/18] Add EEPROM-based board detect support for TI Lokesh Vutla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190508213751.23179-16-dannenberg@ti.com \
    --to=dannenberg@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox