blob: de4892ee901eadbfb7291ae2b06e766dec0b8dc3 [file] [log] [blame]
Paul Barker1aa6de52023-10-16 10:25:40 +01001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2021,2023 Renesas Electronics Corporation
4 *
5 */
6
7#include <common.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. */
14extern u64 rcar_atf_boot_args[];
15
16/* CPU information table */
17struct tfa_info {
18 const char *soc_name;
19 const char *cpu_name;
20 u32 cpu_type;
21};
22
23static const struct tfa_info tfa_info[] = {
24 { "renesas,r9a07g044l2", "R9A07G044L", RMOBILE_CPU_TYPE_R9A07G044L },
25};
26
27static const struct tfa_info invalid_tfa_info = { NULL, "(invalid)", 0 };
28
29static 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
45const u8 *rzg_get_cpu_name(void)
46{
47 return get_tfa_info()->cpu_name;
48}
49
50u32 rmobile_get_cpu_type(void)
51{
52 return get_tfa_info()->cpu_type;
53}
54
55u32 rmobile_get_cpu_rev_integer(void)
56{
57 return (readl(SYSC_LSI_DEVID) >> 28) + 1;
58}
59
60u32 rmobile_get_cpu_rev_fraction(void)
61{
62 return 0;
63}