cpu_info.c 2.6 KB

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