uboot/arch/arm/mach-rmobile/cpu_info.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * (C) Copyright 2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
   4 * (C) Copyright 2012 Renesas Solutions Corp.
   5 */
   6#include <common.h>
   7#include <cpu_func.h>
   8#include <asm/io.h>
   9#include <env.h>
  10#include <linux/ctype.h>
  11
  12#ifdef CONFIG_ARCH_CPU_INIT
  13int arch_cpu_init(void)
  14{
  15        icache_enable();
  16        return 0;
  17}
  18#endif
  19
  20/* R-Car Gen3 D-cache is enabled in memmap-gen3.c */
  21#ifndef CONFIG_RCAR_GEN3
  22#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
  23void enable_caches(void)
  24{
  25        dcache_enable();
  26}
  27#endif
  28#endif
  29
  30#ifdef CONFIG_DISPLAY_CPUINFO
  31#ifndef CONFIG_RZA1
  32static u32 __rmobile_get_cpu_type(void)
  33{
  34        return 0x0;
  35}
  36u32 rmobile_get_cpu_type(void)
  37                __attribute__((weak, alias("__rmobile_get_cpu_type")));
  38
  39static u32 __rmobile_get_cpu_rev_integer(void)
  40{
  41        return 0;
  42}
  43u32 rmobile_get_cpu_rev_integer(void)
  44                __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
  45
  46static u32 __rmobile_get_cpu_rev_fraction(void)
  47{
  48        return 0;
  49}
  50u32 rmobile_get_cpu_rev_fraction(void)
  51                __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
  52
  53/* CPU infomation table */
  54static const struct {
  55        u16 cpu_type;
  56        u8 cpu_name[10];
  57} rmobile_cpuinfo[] = {
  58        { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
  59        { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
  60        { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
  61        { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
  62        { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
  63        { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
  64        { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
  65        { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
  66        { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
  67        { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
  68        { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
  69        { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
  70        { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
  71        { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
  72        { 0x0, "CPU" },
  73};
  74
  75static int rmobile_cpuinfo_idx(void)
  76{
  77        int i = 0;
  78        u32 cpu_type = rmobile_get_cpu_type();
  79
  80        for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
  81                if (rmobile_cpuinfo[i].cpu_type == cpu_type)
  82                        break;
  83
  84        return i;
  85}
  86
  87#ifdef CONFIG_ARCH_MISC_INIT
  88int arch_misc_init(void)
  89{
  90        int i, idx = rmobile_cpuinfo_idx();
  91        char cpu[10] = { 0 };
  92
  93        for (i = 0; i < sizeof(cpu); i++)
  94                cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
  95
  96        env_set("platform", cpu);
  97
  98        return 0;
  99}
 100#endif
 101
 102int print_cpuinfo(void)
 103{
 104        int i = rmobile_cpuinfo_idx();
 105
 106        printf("CPU: Renesas Electronics %s rev %d.%d\n",
 107                rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
 108                rmobile_get_cpu_rev_fraction());
 109
 110        return 0;
 111}
 112#else
 113int print_cpuinfo(void)
 114{
 115        printf("CPU: Renesas Electronics RZ/A1\n");
 116        return 0;
 117}
 118#endif
 119#endif /* CONFIG_DISPLAY_CPUINFO */
 120