cpu_info.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/cache.h>
  9. #include <init.h>
  10. #include <asm/io.h>
  11. #include <env.h>
  12. #include <linux/ctype.h>
  13. #ifdef CONFIG_ARCH_CPU_INIT
  14. int arch_cpu_init(void)
  15. {
  16. icache_enable();
  17. return 0;
  18. }
  19. #endif
  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)
  23. void enable_caches(void)
  24. {
  25. dcache_enable();
  26. }
  27. #endif
  28. #endif
  29. #ifdef CONFIG_DISPLAY_CPUINFO
  30. #ifndef CONFIG_RZA1
  31. static u32 __rmobile_get_cpu_type(void)
  32. {
  33. return 0x0;
  34. }
  35. u32 rmobile_get_cpu_type(void)
  36. __attribute__((weak, alias("__rmobile_get_cpu_type")));
  37. static u32 __rmobile_get_cpu_rev_integer(void)
  38. {
  39. return 0;
  40. }
  41. u32 rmobile_get_cpu_rev_integer(void)
  42. __attribute__((weak, alias("__rmobile_get_cpu_rev_integer")));
  43. static u32 __rmobile_get_cpu_rev_fraction(void)
  44. {
  45. return 0;
  46. }
  47. u32 rmobile_get_cpu_rev_fraction(void)
  48. __attribute__((weak, alias("__rmobile_get_cpu_rev_fraction")));
  49. /* CPU infomation table */
  50. static const struct {
  51. u16 cpu_type;
  52. u8 cpu_name[10];
  53. } rmobile_cpuinfo[] = {
  54. { RMOBILE_CPU_TYPE_SH73A0, "SH73A0" },
  55. { RMOBILE_CPU_TYPE_R8A7740, "R8A7740" },
  56. { RMOBILE_CPU_TYPE_R8A7790, "R8A7790" },
  57. { RMOBILE_CPU_TYPE_R8A7791, "R8A7791" },
  58. { RMOBILE_CPU_TYPE_R8A7792, "R8A7792" },
  59. { RMOBILE_CPU_TYPE_R8A7793, "R8A7793" },
  60. { RMOBILE_CPU_TYPE_R8A7794, "R8A7794" },
  61. { RMOBILE_CPU_TYPE_R8A7795, "R8A7795" },
  62. { RMOBILE_CPU_TYPE_R8A7796, "R8A7796" },
  63. { RMOBILE_CPU_TYPE_R8A77965, "R8A77965" },
  64. { RMOBILE_CPU_TYPE_R8A77970, "R8A77970" },
  65. { RMOBILE_CPU_TYPE_R8A77980, "R8A77980" },
  66. { RMOBILE_CPU_TYPE_R8A77990, "R8A77990" },
  67. { RMOBILE_CPU_TYPE_R8A77995, "R8A77995" },
  68. { 0x0, "CPU" },
  69. };
  70. static int rmobile_cpuinfo_idx(void)
  71. {
  72. int i = 0;
  73. u32 cpu_type = rmobile_get_cpu_type();
  74. for (; i < ARRAY_SIZE(rmobile_cpuinfo); i++)
  75. if (rmobile_cpuinfo[i].cpu_type == cpu_type)
  76. break;
  77. return i;
  78. }
  79. #ifdef CONFIG_ARCH_MISC_INIT
  80. int arch_misc_init(void)
  81. {
  82. int i, idx = rmobile_cpuinfo_idx();
  83. char cpu[10] = { 0 };
  84. for (i = 0; i < sizeof(cpu); i++)
  85. cpu[i] = tolower(rmobile_cpuinfo[idx].cpu_name[i]);
  86. env_set("platform", cpu);
  87. return 0;
  88. }
  89. #endif
  90. int print_cpuinfo(void)
  91. {
  92. int i = rmobile_cpuinfo_idx();
  93. printf("CPU: Renesas Electronics %s rev %d.%d\n",
  94. rmobile_cpuinfo[i].cpu_name, rmobile_get_cpu_rev_integer(),
  95. rmobile_get_cpu_rev_fraction());
  96. return 0;
  97. }
  98. #else
  99. int print_cpuinfo(void)
  100. {
  101. printf("CPU: Renesas Electronics RZ/A1\n");
  102. return 0;
  103. }
  104. #endif
  105. #endif /* CONFIG_DISPLAY_CPUINFO */