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 | |
Tom Rini | 1c96c79 | 2023-12-14 13:16:54 -0500 | [diff] [blame] | 7 | #include <mach/rmobile.h> |
Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <linux/libfdt.h> |
| 10 | |
| 11 | #define SYSC_LSI_DEVID 0x11020A04 |
| 12 | |
| 13 | /* If the firmware passed a device tree, use it for soc identification. */ |
| 14 | extern u64 rcar_atf_boot_args[]; |
| 15 | |
| 16 | /* CPU information table */ |
| 17 | struct tfa_info { |
| 18 | const char *soc_name; |
| 19 | const char *cpu_name; |
| 20 | u32 cpu_type; |
| 21 | }; |
| 22 | |
| 23 | static const struct tfa_info tfa_info[] = { |
Marek Vasut | f972661 | 2024-02-27 17:05:47 +0100 | [diff] [blame^] | 24 | { "renesas,r9a07g044l2", "R9A07G044L", RENESAS_CPU_TYPE_R9A07G044L }, |
Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | static const struct tfa_info invalid_tfa_info = { NULL, "(invalid)", 0 }; |
| 28 | |
| 29 | static const struct tfa_info *get_tfa_info(void) |
| 30 | { |
| 31 | void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]); |
| 32 | |
| 33 | if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) { |
| 34 | unsigned int i; |
| 35 | for (i = 0; i < ARRAY_SIZE(tfa_info); i++) { |
| 36 | if (!fdt_node_check_compatible(atf_fdt_blob, 0, |
| 37 | tfa_info[i].soc_name)) |
| 38 | return &tfa_info[i]; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | return &invalid_tfa_info; |
| 43 | } |
| 44 | |
| 45 | const u8 *rzg_get_cpu_name(void) |
| 46 | { |
| 47 | return get_tfa_info()->cpu_name; |
| 48 | } |
| 49 | |
Marek Vasut | 30fe98e | 2024-02-27 17:05:45 +0100 | [diff] [blame] | 50 | u32 renesas_get_cpu_type(void) |
Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 51 | { |
| 52 | return get_tfa_info()->cpu_type; |
| 53 | } |
| 54 | |
Marek Vasut | 1760232 | 2024-02-27 17:05:46 +0100 | [diff] [blame] | 55 | u32 renesas_get_cpu_rev_integer(void) |
Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 56 | { |
| 57 | return (readl(SYSC_LSI_DEVID) >> 28) + 1; |
| 58 | } |
| 59 | |
Marek Vasut | 1760232 | 2024-02-27 17:05:46 +0100 | [diff] [blame] | 60 | u32 renesas_get_cpu_rev_fraction(void) |
Paul Barker | 1aa6de5 | 2023-10-16 10:25:40 +0100 | [diff] [blame] | 61 | { |
| 62 | return 0; |
| 63 | } |