diff options
author | Tom Rini <trini@konsulko.com> | 2016-11-07 13:16:00 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-11-07 13:16:00 -0500 |
commit | d8c4eb60f8d1af74116eaee4f53adc937e618d6f (patch) | |
tree | ccdab4ffc0c3c32a1d788f33674f9f092830b7d0 /arch/arm/mach-tegra/tegra186/nvtboot_board.c | |
parent | dac09fc10b71045ac261a9b8a05d34029ebec2ae (diff) | |
parent | aa555fe9f07a21b3bbdab15aea594f3869e5ab22 (diff) |
Merge branch 'master' of git://git.denx.de/u-boot-net
Diffstat (limited to 'arch/arm/mach-tegra/tegra186/nvtboot_board.c')
-rw-r--r-- | arch/arm/mach-tegra/tegra186/nvtboot_board.c | 54 |
1 files changed, 54 insertions, 0 deletions
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 0000000000..1d78346f98 --- /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 <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; +} |