]> git.sur5r.net Git - u-boot/commitdiff
ARM: tegra: configure Ethernet address on Tegra186
authorStephen Warren <swarren@nvidia.com>
Mon, 12 Sep 2016 17:51:13 +0000 (11:51 -0600)
committerJoe Hershberger <joe.hershberger@ni.com>
Mon, 7 Nov 2016 17:28:16 +0000 (11:28 -0600)
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 <swarren@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
arch/arm/mach-tegra/tegra186/Makefile
arch/arm/mach-tegra/tegra186/nvtboot_board.c [new file with mode: 0644]

index 7f46a057bca1bd4cfc3978b2c558753d6771392e..56f3378ecea373b938433e70b47682fd796f8326 100644 (file)
@@ -4,5 +4,6 @@
 
 obj-y += ../board186.o
 obj-y += cache.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 (file)
index 0000000..1d78346
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <fdt_support.h>
+#include <fdtdec.h>
+#include <asm/arch/tegra.h>
+
+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;
+}