blob: a1683a26e356490bab7694c8d6c5b51a805095db [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
Tom Rini1c96c792023-12-14 13:16:54 -05007#include <mach/rmobile.h>
Paul Barker1aa6de52023-10-16 10:25:40 +01008#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[] = {
Marek Vasutf9726612024-02-27 17:05:47 +010024 { "renesas,r9a07g044l2", "R9A07G044L", RENESAS_CPU_TYPE_R9A07G044L },
Paul Barker1aa6de52023-10-16 10:25:40 +010025};
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
Marek Vasut30fe98e2024-02-27 17:05:45 +010050u32 renesas_get_cpu_type(void)
Paul Barker1aa6de52023-10-16 10:25:40 +010051{
52 return get_tfa_info()->cpu_type;
53}
54
Marek Vasut17602322024-02-27 17:05:46 +010055u32 renesas_get_cpu_rev_integer(void)
Paul Barker1aa6de52023-10-16 10:25:40 +010056{
57 return (readl(SYSC_LSI_DEVID) >> 28) + 1;
58}
59
Marek Vasut17602322024-02-27 17:05:46 +010060u32 renesas_get_cpu_rev_fraction(void)
Paul Barker1aa6de52023-10-16 10:25:40 +010061{
62 return 0;
63}