cpu_info.c 2.6 KB

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