ARM: renesas: Rename ARCH_RMOBILE to ARCH_RENESAS
[pandora-u-boot.git] / arch / arm / mach-rmobile / cpu_info-rzg2l.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2021,2023 Renesas Electronics Corporation
4  *
5  */
6
7 #include <mach/renesas.h>
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[] = {
24         { "renesas,r9a07g044l2", "R9A07G044L", RENESAS_CPU_TYPE_R9A07G044L },
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
50 u32 renesas_get_cpu_type(void)
51 {
52         return get_tfa_info()->cpu_type;
53 }
54
55 u32 renesas_get_cpu_rev_integer(void)
56 {
57         return (readl(SYSC_LSI_DEVID) >> 28) + 1;
58 }
59
60 u32 renesas_get_cpu_rev_fraction(void)
61 {
62         return 0;
63 }