From patchwork Mon Sep 12 17:51:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 668911 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sXwNZ5VLMz9sf6 for ; Tue, 13 Sep 2016 03:51:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1817DA75AA; Mon, 12 Sep 2016 19:51:39 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mrycr1tFGCxi; Mon, 12 Sep 2016 19:51:38 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 89E71A7577; Mon, 12 Sep 2016 19:51:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 36722A7534 for ; Mon, 12 Sep 2016 19:51:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sHu1ain19lIk for ; Mon, 12 Sep 2016 19:51:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id F0C6B4BDBD for ; Mon, 12 Sep 2016 19:51:27 +0200 (CEST) Received: from swarren-lx1.nvidia.com (thunderhill.nvidia.com [216.228.112.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPSA id 52E1F1C0446; Mon, 12 Sep 2016 11:51:32 -0600 (MDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99 at avon.wwwdotorg.org From: Stephen Warren To: u-boot@lists.denx.de, Simon Glass , Tom Warren , Stephen Warren Date: Mon, 12 Sep 2016 11:51:13 -0600 Message-Id: <20160912175115.13198-2-swarren@wwwdotorg.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160912175115.13198-1-swarren@wwwdotorg.org> References: <20160912175115.13198-1-swarren@wwwdotorg.org> X-NVConfidentiality: public Subject: [U-Boot] [PATCH 2/4] ARM: tegra: configure Ethernet address on Tegra186 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Stephen Warren On Tegra186, the bootloader which runs before U-Boot passes the Ethernet MAC address to U-Boot using device tree. Extract this value and write it to the environment, so that the Ethernet uclass picks it up and uses it for the built-in Ethernet device. Signed-off-by: Stephen Warren Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- arch/arm/mach-tegra/tegra186/Makefile | 1 + arch/arm/mach-tegra/tegra186/nvtboot_board.c | 54 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 arch/arm/mach-tegra/tegra186/nvtboot_board.c diff --git a/arch/arm/mach-tegra/tegra186/Makefile b/arch/arm/mach-tegra/tegra186/Makefile index 033d6005fb44..26bc462930c1 100644 --- a/arch/arm/mach-tegra/tegra186/Makefile +++ b/arch/arm/mach-tegra/tegra186/Makefile @@ -3,5 +3,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += ../board186.o +obj-y += nvtboot_board.o obj-y += nvtboot_ll.o obj-y += nvtboot_mem.o diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_board.c b/arch/arm/mach-tegra/tegra186/nvtboot_board.c new file mode 100644 index 000000000000..1d78346f9843 --- /dev/null +++ b/arch/arm/mach-tegra/tegra186/nvtboot_board.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, NVIDIA CORPORATION. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include + +extern unsigned long nvtboot_boot_x0; + +/* + * Attempt to use /chosen/nvidia,ether-mac in the nvtboot DTB to U-Boot's + * ethaddr environment variable if possible. + */ +static int set_ethaddr_from_nvtboot(void) +{ + const void *nvtboot_blob = (void *)nvtboot_boot_x0; + int ret, node, len; + const u32 *prop; + + /* Already a valid address in the environment? If so, keep it */ + if (getenv("ethaddr")) + return 0; + + node = fdt_path_offset(nvtboot_blob, "/chosen"); + if (node < 0) { + printf("Can't find /chosen node in nvtboot DTB\n"); + return node; + } + prop = fdt_getprop(nvtboot_blob, node, "nvidia,ether-mac", &len); + if (!prop) { + printf("Can't find nvidia,ether-mac property in nvtboot DTB\n"); + return -ENOENT; + } + + ret = setenv("ethaddr", (void *)prop); + if (ret) { + printf("Failed to set ethaddr from nvtboot DTB: %d\n", ret); + return ret; + } + + return 0; +} + +int tegra_soc_board_init_late(void) +{ + /* Ignore errors here; not all cases care about Ethernet addresses */ + set_ethaddr_from_nvtboot(); + + return 0; +}