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