blob: 755747e665cbb3aa894c70027273dd741f6c3114 [file] [log] [blame]
Paul Barker4e655452023-10-16 10:25:43 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * RZ/G2L board support.
4 * Copyright (C) 2023 Renesas Electronics Corporation
5 */
6
7#include <common.h>
8#include <fdtdec.h>
9#include <linux/libfdt.h>
10
11#if IS_ENABLED(CONFIG_MULTI_DTB_FIT)
12/* If the firmware passed a device tree, use it for board identification. */
13extern u64 rcar_atf_boot_args[];
14
15static bool is_rzg2l_board(const char *board_name)
16{
17 void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
18
19 return fdt_node_check_compatible(atf_fdt_blob, 0, board_name) == 0;
20}
21
22int board_fit_config_name_match(const char *name)
23{
24 void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
25
26 if (fdt_magic(atf_fdt_blob) != FDT_MAGIC)
27 return -1;
28
29 if (is_rzg2l_board("renesas,r9a07g044l2"))
30 return strcmp(name, "r9a07g044l2-smarc");
31
32 return -1;
33}
34#endif
35
36static void apply_atf_overlay(void *fdt_blob)
37{
38 void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
39
40 if (fdt_magic(atf_fdt_blob) == FDT_MAGIC)
41 fdt_overlay_apply_node(fdt_blob, 0, atf_fdt_blob, 0);
42}
43
44int fdtdec_board_setup(const void *fdt_blob)
45{
46 apply_atf_overlay((void *)fdt_blob);
47
48 return 0;
49}
50
51int ft_board_setup(void *blob, struct bd_info *bd)
52{
53 return 0;
54}
55
56int board_init(void)
57{
58 return 0;
59}
60
61void reset_cpu(void)
62{
63 /*
64 * TODO: Implement reset support once TrustedFirmware supports
65 * the appropriate call.
66 */
67}