Biju Das | 3e5f3db | 2021-03-17 14:11:50 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2021 Renesas Electronics Corporation |
| 4 | * |
| 5 | */ |
| 6 | #include <common.h> |
| 7 | #include <linux/libfdt.h> |
| 8 | |
| 9 | /* If the firmware passed a device tree, use it for soc identification. */ |
| 10 | extern u64 rcar_atf_boot_args[]; |
| 11 | |
| 12 | /* CPU information table */ |
| 13 | static const struct { |
| 14 | char *soc_name; |
| 15 | u8 cpu_name[10]; |
| 16 | } tfa_info[] = { |
| 17 | { "renesas,r8a774a1", "R8A774A1" }, |
| 18 | { "renesas,r8a774b1", "R8A774B1" }, |
| 19 | { "renesas,r8a774c0", "R8A774C0" }, |
| 20 | { "renesas,r8a774e1", "R8A774E1" } |
| 21 | }; |
| 22 | |
| 23 | const u8 *rzg_get_cpu_name(void) |
| 24 | { |
| 25 | void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]); |
| 26 | bool ret = false; |
| 27 | int i; |
| 28 | |
| 29 | if (fdt_magic(atf_fdt_blob) != FDT_MAGIC) |
| 30 | return NULL; |
| 31 | |
| 32 | for (i = 0; i < ARRAY_SIZE(tfa_info); i++) { |
| 33 | if (fdt_node_check_compatible(atf_fdt_blob, 0, |
| 34 | tfa_info[i].soc_name) == 0) { |
| 35 | ret = true; |
| 36 | break; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return ret ? tfa_info[i].cpu_name : NULL; |
| 41 | } |