cpu_info.c 2.5 KB

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