1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2010-2016, NVIDIA CORPORATION.
9 #include <asm/arch-tegra/cboot.h>
10 #include <asm/arch-tegra/gpu.h>
13 * This function is called right before the kernel is booted. "blob" is the
14 * device tree that will be passed to the kernel.
16 int ft_system_setup(void *blob, struct bd_info *bd)
18 const char *gpu_compats[] = {
19 #if defined(CONFIG_TEGRA124)
22 #if defined(CONFIG_TEGRA210)
28 /* Enable GPU node if GPU setup has been performed */
29 for (i = 0; i < ARRAY_SIZE(gpu_compats); i++) {
30 ret = tegra_gpu_enable_node(blob, gpu_compats[i]);
38 #if defined(CONFIG_ARM64)
39 void ft_mac_address_setup(void *fdt)
41 const void *cboot_fdt = (const void *)cboot_boot_x0;
42 uint8_t mac[ETH_ALEN], local_mac[ETH_ALEN];
46 err = cboot_get_ethaddr(cboot_fdt, local_mac);
48 memset(local_mac, 0, ETH_ALEN);
50 path = fdt_get_alias(fdt, "ethernet");
54 debug("ethernet alias found: %s\n", path);
56 offset = fdt_path_offset(fdt, path);
58 printf("ethernet alias points to absent node %s\n", path);
62 if (is_valid_ethaddr(local_mac)) {
63 err = fdt_setprop(fdt, offset, "local-mac-address", local_mac,
66 debug("Local MAC address set: %pM\n", local_mac);
69 if (eth_env_get_enetaddr("ethaddr", mac)) {
70 if (memcmp(local_mac, mac, ETH_ALEN) != 0) {
71 err = fdt_setprop(fdt, offset, "mac-address", mac,
74 debug("MAC address set: %pM\n", mac);
79 static int ft_copy_carveout(void *dst, const void *src, const char *node)
81 struct fdt_memory carveout;
82 unsigned int index = 0;
86 const char **compatibles = NULL;
87 unsigned int num_compatibles;
92 err = fdtdec_get_carveout(src, node, "memory-region", index,
93 &carveout, &name, &compatibles,
94 &num_compatibles, &flags);
96 if (err != -FDT_ERR_NOTFOUND)
97 printf("failed to get carveout for %s: %d\n",
104 const char *ptr = strchr(name, '@');
107 copy = strndup(name, ptr - name);
114 err = fdtdec_set_carveout(dst, node, "memory-region", index,
115 &carveout, name, compatibles,
116 num_compatibles, flags);
118 printf("failed to set carveout for %s: %d\n", node,
132 void ft_carveout_setup(void *fdt, const char * const *nodes, unsigned int count)
134 const void *cboot_fdt = (const void *)cboot_boot_x0;
138 for (i = 0; i < count; i++) {
139 printf("copying carveout for %s...\n", nodes[i]);
141 err = ft_copy_carveout(fdt, cboot_fdt, nodes[i]);
143 if (err != -FDT_ERR_NOTFOUND)
144 printf("failed to copy carveout for %s: %d\n",