diff mbox series

[11/16] board: traverse: ten64: set serial# to be 'label' MAC

Message ID 20230721043931.14188-12-matt@traverse.com.au
State Accepted
Commit 06e19a6d3e2311efb4078806394954f39cbd15a2
Delegated to: Tom Rini
Headers show
Series Ten64 updates 2023-07 | expand

Commit Message

Mathew McBride July 21, 2023, 4:39 a.m. UTC
The GE0 (first Gigabit Ethernet interface) is used as the
'serial number' for the board and appliance.

To ensure the 'true' board S/N is available regardless of how
the DPAA2 subsystem is configured, use serial# so it is passed in
the device tree.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
---
 board/traverse/ten64/ten64.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Peng Fan (OSS) July 21, 2023, 8:05 a.m. UTC | #1
On 7/21/2023 12:39 PM, Mathew McBride wrote:
> The GE0 (first Gigabit Ethernet interface) is used as the
> 'serial number' for the board and appliance.
> 
> To ensure the 'true' board S/N is available regardless of how
> the DPAA2 subsystem is configured, use serial# so it is passed in
> the device tree.
> 
> Signed-off-by: Mathew McBride<matt@traverse.com.au>

Reviewed-by: Peng Fan <peng.fan@nxp.com>
diff mbox series

Patch

diff --git a/board/traverse/ten64/ten64.c b/board/traverse/ten64/ten64.c
index 0febc0baf0..17057966c8 100644
--- a/board/traverse/ten64/ten64.c
+++ b/board/traverse/ten64/ten64.c
@@ -296,6 +296,7 @@  static void ten64_set_macaddrs_from_board_info(struct t64uc_board_info *boardinf
 {
 	char ethaddr[18];
 	char enetvar[10];
+	char serial[18];
 	u8 intfidx, this_dpmac_num;
 	u64 macaddr = 0;
 	/* We will copy the MAC address returned from the
@@ -316,6 +317,19 @@  static void ten64_set_macaddrs_from_board_info(struct t64uc_board_info *boardinf
 	 */
 	macaddr = __be64_to_cpu(macaddr);
 
+	/* Set serial# to GE0/DPMAC7 MAC address
+	 * (Matches the labels on the board and appliance)
+	 */
+	snprintf(serial, 18, "%02X%02X%02X%02X%02X%02X",
+		 MACADDRBITS(macaddr, 40),
+		 MACADDRBITS(macaddr, 32),
+		 MACADDRBITS(macaddr, 24),
+		 MACADDRBITS(macaddr, 16),
+		 MACADDRBITS(macaddr, 8),
+		 MACADDRBITS(macaddr, 0));
+	if (!env_get("serial#"))
+		env_set("serial#", serial);
+
 	for (intfidx = 0; intfidx < 10; intfidx++) {
 		snprintf(ethaddr, 18, "%02X:%02X:%02X:%02X:%02X:%02X",
 			 MACADDRBITS(macaddr, 40),