blob: e88760ea51dd9f513fba6561d60eb025e825dfec [file] [log] [blame]
Andrew Davise819fab2024-02-14 10:30:08 -06001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
4 */
5
6#include <asm/hardware.h>
Tom Rinia9705f02024-06-03 18:42:11 -06007#include "../common_fdt.h"
Andrew Davise819fab2024-02-14 10:30:08 -06008#include <fdt_support.h>
9
Aparna Patra3beefff2025-01-08 10:19:36 +053010static void fdt_fixup_cores_wdt_nodes_am62p(void *blob, int core_nr)
11{
12 char node_path[32];
13
14 if (core_nr < 1)
15 return;
16
17 for (; core_nr < 4; core_nr++) {
18 snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
19 fdt_del_node_path(blob, node_path);
20 snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
21 fdt_del_node_path(blob, node_path);
22 snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
23 fdt_del_node_path(blob, node_path);
24 }
25}
26
27static void fdt_fixup_video_codec_nodes_am62p(void *blob, bool has_video_codec)
28{
29 if (!has_video_codec)
30 fdt_del_node_path(blob, "/bus@f0000/video-codec@30210000");
31}
32
33static void fdt_fixup_canfd_nodes_am62p(void *blob, bool has_canfd)
34{
35 if (!has_canfd) {
36 fdt_del_node_path(blob, "/bus@f0000/can@20701000");
37 fdt_del_node_path(blob, "/bus@f0000/can@20711000");
38 }
39}
40
Andrew Davise819fab2024-02-14 10:30:08 -060041int ft_system_setup(void *blob, struct bd_info *bd)
42{
Aparna Patra3beefff2025-01-08 10:19:36 +053043 fdt_fixup_cores_wdt_nodes_am62p(blob, k3_get_core_nr());
44 fdt_fixup_video_codec_nodes_am62p(blob, k3_has_video_codec());
45 fdt_fixup_canfd_nodes_am62p(blob, k3_has_canfd());
Andrew Davise819fab2024-02-14 10:30:08 -060046 fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
47 fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
48
49 return 0;
50}