Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2021,2023 Renesas Electronics Corporation |
| 4 | * |
| 5 | */ |
| 6 | |
Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 7 | #include <asm/io.h> |
| 8 | #include <linux/libfdt.h> |
| 9 | |
| 10 | #define SYSC_LSI_DEVID 0x11020A04 |
| 11 | |
| 12 | /* If the firmware passed a device tree, use it for soc identification. */ |
| 13 | extern u64 rcar_atf_boot_args[]; |
| 14 | |
| 15 | /* CPU information table */ |
| 16 | struct tfa_info { |
| 17 | const char *soc_name; |
| 18 | const char *cpu_name; |
| 19 | u32 cpu_type; |
| 20 | }; |
| 21 | |
| 22 | static const struct tfa_info tfa_info[] = { |
| 23 | { "renesas,r9a07g044l2", "R9A07G044L", RMOBILE_CPU_TYPE_R9A07G044L }, |
| 24 | }; |
| 25 | |
| 26 | static const struct tfa_info invalid_tfa_info = { NULL, "(invalid)", 0 }; |
| 27 | |
| 28 | static const struct tfa_info *get_tfa_info(void) |
| 29 | { |
| 30 | void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]); |
| 31 | |
| 32 | if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) { |
| 33 | unsigned int i; |
| 34 | for (i = 0; i < ARRAY_SIZE(tfa_info); i++) { |
| 35 | if (!fdt_node_check_compatible(atf_fdt_blob, 0, |
| 36 | tfa_info[i].soc_name)) |
| 37 | return &tfa_info[i]; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return &invalid_tfa_info; |
| 42 | } |
| 43 | |
| 44 | const u8 *rzg_get_cpu_name(void) |
| 45 | { |
| 46 | return get_tfa_info()->cpu_name; |
| 47 | } |
| 48 | |
| 49 | u32 rmobile_get_cpu_type(void) |
| 50 | { |
| 51 | return get_tfa_info()->cpu_type; |
| 52 | } |
| 53 | |
| 54 | u32 rmobile_get_cpu_rev_integer(void) |
| 55 | { |
| 56 | return (readl(SYSC_LSI_DEVID) >> 28) + 1; |
| 57 | } |
| 58 | |
| 59 | u32 rmobile_get_cpu_rev_fraction(void) |
| 60 | { |
| 61 | return 0; |
| 62 | } |