Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8933FC433EF for ; Sat, 21 May 2022 10:43:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 44A79805FE; Sat, 21 May 2022 12:43:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ziswiler.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 1B322802F3; Sat, 21 May 2022 12:43:01 +0200 (CEST) Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D54F683D90 for ; Sat, 21 May 2022 12:42:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ziswiler.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=marcel@ziswiler.com Received: from toolbox.int.toradex.com ([81.221.85.15]) by mrelay.perfora.net (mreueus002 [74.208.5.2]) with ESMTPSA (Nemesis) id 0MX2dG-1oOFSQ1RbQ-00Vuo6; Sat, 21 May 2022 12:42:50 +0200 From: Marcel Ziswiler To: u-boot@lists.denx.de Cc: Tom Warren , Marcel Ziswiler Subject: [PATCH v1] board: apalis_t30/tk1/colibri_t20/t30: integrate mac address via dt Date: Sat, 21 May 2022 12:42:46 +0200 Message-Id: <20220521104246.1207955-1-marcel@ziswiler.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:ZDmtR6+E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 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Marcel Ziswiler Use device tree to set MAC address of the Ethernet chip. Signed-off-by: Marcel Ziswiler --- board/toradex/apalis-tk1/apalis-tk1.c | 19 +++++++++++++++++++ board/toradex/apalis_t30/apalis_t30.c | 20 ++++++++++++++++++++ board/toradex/colibri_t20/colibri_t20.c | 19 +++++++++++++++++++ board/toradex/colibri_t30/colibri_t30.c | 20 ++++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/board/toradex/apalis-tk1/apalis-tk1.c b/board/toradex/apalis-tk1/apalis-tk1.c index ccf665b2118..86b10400ffa 100644 --- a/board/toradex/apalis-tk1/apalis-tk1.c +++ b/board/toradex/apalis-tk1/apalis-tk1.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -99,6 +100,24 @@ int checkboard(void) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { + u8 enetaddr[6]; + + /* MAC addr */ + if (eth_env_get_enetaddr("ethaddr", enetaddr)) { + int err = fdt_find_and_setprop(blob, + "/pcie@1003000/pci@2,0/ethernet@0,0", + "local-mac-address", enetaddr, 6, 0); + + /* Older device trees might have used a different node name */ + if (err < 0) + err = fdt_find_and_setprop(blob, + "/pcie@1003000/pci@2,0/pcie@0", + "local-mac-address", enetaddr, 6, 0); + + if (err >= 0) + puts(" MAC address updated...\n"); + } + return ft_common_board_setup(blob, bd); } #endif diff --git a/board/toradex/apalis_t30/apalis_t30.c b/board/toradex/apalis_t30/apalis_t30.c index 0396eea56b5..ef71270d9f2 100644 --- a/board/toradex/apalis_t30/apalis_t30.c +++ b/board/toradex/apalis_t30/apalis_t30.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include #include #include "../common/tdx-common.h" @@ -54,6 +56,24 @@ int checkboard(void) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { + u8 enetaddr[6]; + + /* MAC addr */ + if (eth_env_get_enetaddr("ethaddr", enetaddr)) { + int err = fdt_find_and_setprop(blob, + "/pcie@3000/pci@3,0/ethernet@0,0", + "local-mac-address", enetaddr, 6, 0); + + /* Older device trees might have used a different node name */ + if (err < 0) + err = fdt_find_and_setprop(blob, + "/pcie@3000/pci@3,0/pcie@0", + "local-mac-address", enetaddr, 6, 0); + + if (err >= 0) + puts(" MAC address updated...\n"); + } + return ft_common_board_setup(blob, bd); } #endif diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index 73ef4d2db32..c58d2021cd3 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -81,6 +82,24 @@ int checkboard(void) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { + u8 enetaddr[6]; + + /* MAC addr */ + if (eth_env_get_enetaddr("ethaddr", enetaddr)) { + int err = fdt_find_and_setprop(blob, + "/usb@7d004000/ethernet@1", + "local-mac-address", enetaddr, 6, 0); + + /* Older device trees might have used a different node name */ + if (err < 0) + err = fdt_find_and_setprop(blob, + "/usb@7d004000/asix@1", + "local-mac-address", enetaddr, 6, 0); + + if (err >= 0) + puts(" MAC address updated...\n"); + } + return ft_common_board_setup(blob, bd); } #endif diff --git a/board/toradex/colibri_t30/colibri_t30.c b/board/toradex/colibri_t30/colibri_t30.c index 20cbb75a365..b6b004669c2 100644 --- a/board/toradex/colibri_t30/colibri_t30.c +++ b/board/toradex/colibri_t30/colibri_t30.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -12,6 +13,7 @@ #include #include #include +#include #include #include #include "pinmux-config-colibri_t30.h" @@ -36,6 +38,24 @@ int checkboard(void) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { + u8 enetaddr[6]; + + /* MAC addr */ + if (eth_env_get_enetaddr("ethaddr", enetaddr)) { + int err = fdt_find_and_setprop(blob, + "/usb@7d004000/ethernet@1", + "local-mac-address", enetaddr, 6, 0); + + /* Older device trees might have used a different node name */ + if (err < 0) + err = fdt_find_and_setprop(blob, + "/usb@7d004000/asix@1", + "local-mac-address", enetaddr, 6, 0); + + if (err >= 0) + puts(" MAC address updated...\n"); + } + return ft_common_board_setup(blob, bd); } #endif -- 2.34.1