2016-09-12 17:51:13 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2016-12-02 19:26:42 +00:00
|
|
|
static int set_fdt_addr(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2017-08-03 18:22:10 +00:00
|
|
|
ret = env_set_hex("fdt_addr", nvtboot_boot_x0);
|
2016-12-02 19:26:42 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("Failed to set fdt_addr to point at DTB: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-12 17:51:13 +00:00
|
|
|
/*
|
|
|
|
* 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 */
|
2017-08-03 18:22:12 +00:00
|
|
|
if (env_get("ethaddr"))
|
2016-09-12 17:51:13 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-08-03 18:22:09 +00:00
|
|
|
ret = env_set("ethaddr", (void *)prop);
|
2016-09-12 17:51:13 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("Failed to set ethaddr from nvtboot DTB: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tegra_soc_board_init_late(void)
|
|
|
|
{
|
2016-12-02 19:26:42 +00:00
|
|
|
/*
|
|
|
|
* Ignore errors here; the value may not be used depending on
|
|
|
|
* extlinux.conf or boot script content.
|
|
|
|
*/
|
|
|
|
set_fdt_addr();
|
2016-09-12 17:51:13 +00:00
|
|
|
/* Ignore errors here; not all cases care about Ethernet addresses */
|
|
|
|
set_ethaddr_from_nvtboot();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|