pfc_init.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdint.h>
  7. #include <common/debug.h>
  8. #include <lib/mmio.h>
  9. #include "rcar_def.h"
  10. #if RCAR_LSI == RCAR_AUTO
  11. #include "H3/pfc_init_h3_v1.h"
  12. #include "H3/pfc_init_h3_v2.h"
  13. #include "M3/pfc_init_m3.h"
  14. #include "M3N/pfc_init_m3n.h"
  15. #include "V3M/pfc_init_v3m.h"
  16. #endif
  17. #if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N) /* H3 */
  18. #include "H3/pfc_init_h3_v1.h"
  19. #include "H3/pfc_init_h3_v2.h"
  20. #endif
  21. #if RCAR_LSI == RCAR_M3 /* M3 */
  22. #include "M3/pfc_init_m3.h"
  23. #endif
  24. #if RCAR_LSI == RCAR_M3N /* M3N */
  25. #include "M3N/pfc_init_m3n.h"
  26. #endif
  27. #if RCAR_LSI == RCAR_V3M /* V3M */
  28. #include "V3M/pfc_init_v3m.h"
  29. #endif
  30. #if RCAR_LSI == RCAR_E3 /* E3 */
  31. #include "E3/pfc_init_e3.h"
  32. #endif
  33. #if RCAR_LSI == RCAR_D3 /* D3 */
  34. #include "D3/pfc_init_d3.h"
  35. #endif
  36. #define PRR_PRODUCT_ERR(reg) \
  37. do { \
  38. ERROR("LSI Product ID(PRR=0x%x) PFC initialize not supported.\n", \
  39. reg); \
  40. panic(); \
  41. } while (0)
  42. #define PRR_CUT_ERR(reg) \
  43. do { \
  44. ERROR("LSI Cut ID(PRR=0x%x) PFC initialize not supported.\n", \
  45. reg); \
  46. panic();\
  47. } while (0)
  48. void rcar_pfc_init(void)
  49. {
  50. uint32_t reg;
  51. reg = mmio_read_32(RCAR_PRR);
  52. #if RCAR_LSI == RCAR_AUTO
  53. switch (reg & PRR_PRODUCT_MASK) {
  54. case PRR_PRODUCT_H3:
  55. switch (reg & PRR_CUT_MASK) {
  56. case PRR_PRODUCT_10: /* H3 Ver.1.0 */
  57. pfc_init_h3_v1();
  58. break;
  59. case PRR_PRODUCT_11: /* H3 Ver.1.1 */
  60. pfc_init_h3_v1();
  61. break;
  62. default: /* H3 Ver.2.0 or later */
  63. pfc_init_h3_v2();
  64. break;
  65. }
  66. break;
  67. case PRR_PRODUCT_M3:
  68. pfc_init_m3();
  69. break;
  70. case PRR_PRODUCT_M3N:
  71. pfc_init_m3n();
  72. break;
  73. case PRR_PRODUCT_V3M:
  74. pfc_init_v3m();
  75. break;
  76. default:
  77. PRR_PRODUCT_ERR(reg);
  78. break;
  79. }
  80. #elif RCAR_LSI_CUT_COMPAT
  81. switch (reg & PRR_PRODUCT_MASK) {
  82. case PRR_PRODUCT_H3:
  83. #if (RCAR_LSI != RCAR_H3) && (RCAR_LSI != RCAR_H3N)
  84. PRR_PRODUCT_ERR(reg);
  85. #else
  86. switch (reg & PRR_CUT_MASK) {
  87. case PRR_PRODUCT_10: /* H3 Ver.1.0 */
  88. pfc_init_h3_v1();
  89. break;
  90. case PRR_PRODUCT_11: /* H3 Ver.1.1 */
  91. pfc_init_h3_v1();
  92. break;
  93. default: /* H3 Ver.2.0 or later */
  94. pfc_init_h3_v2();
  95. break;
  96. }
  97. #endif
  98. break;
  99. case PRR_PRODUCT_M3:
  100. #if RCAR_LSI != RCAR_M3
  101. PRR_PRODUCT_ERR(reg);
  102. #else
  103. pfc_init_m3();
  104. #endif
  105. break;
  106. case PRR_PRODUCT_M3N:
  107. #if RCAR_LSI != RCAR_M3N
  108. PRR_PRODUCT_ERR(reg);
  109. #else
  110. pfc_init_m3n();
  111. #endif
  112. break;
  113. case PRR_PRODUCT_V3M:
  114. #if RCAR_LSI != RCAR_V3M
  115. PRR_PRODUCT_ERR(reg);
  116. #else
  117. pfc_init_v3m();
  118. #endif
  119. break;
  120. case PRR_PRODUCT_E3:
  121. #if RCAR_LSI != RCAR_E3
  122. PRR_PRODUCT_ERR(reg);
  123. #else
  124. pfc_init_e3();
  125. #endif
  126. break;
  127. case PRR_PRODUCT_D3:
  128. #if RCAR_LSI != RCAR_D3
  129. PRR_PRODUCT_ERR(reg);
  130. #else
  131. pfc_init_d3();
  132. #endif
  133. break;
  134. default:
  135. PRR_PRODUCT_ERR(reg);
  136. break;
  137. }
  138. #else
  139. #if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N) /* H3 */
  140. #if RCAR_LSI_CUT == RCAR_CUT_10
  141. /* H3 Ver.1.0 */
  142. if ((PRR_PRODUCT_H3 | PRR_PRODUCT_10)
  143. != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
  144. PRR_PRODUCT_ERR(reg);
  145. }
  146. pfc_init_h3_v1();
  147. #elif RCAR_LSI_CUT == RCAR_CUT_11
  148. /* H3 Ver.1.1 */
  149. if ((PRR_PRODUCT_H3 | PRR_PRODUCT_11)
  150. != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
  151. PRR_PRODUCT_ERR(reg);
  152. }
  153. pfc_init_h3_v1();
  154. #else
  155. /* H3 Ver.2.0 or later */
  156. if (PRR_PRODUCT_H3 != (reg & PRR_PRODUCT_MASK)) {
  157. PRR_PRODUCT_ERR(reg);
  158. }
  159. pfc_init_h3_v2();
  160. #endif
  161. #elif RCAR_LSI == RCAR_M3 /* M3 */
  162. if ((PRR_PRODUCT_M3) != (reg & PRR_PRODUCT_MASK)) {
  163. PRR_PRODUCT_ERR(reg);
  164. }
  165. pfc_init_m3();
  166. #elif RCAR_LSI == RCAR_M3N /* M3N */
  167. if ((PRR_PRODUCT_M3N) != (reg & PRR_PRODUCT_MASK)) {
  168. PRR_PRODUCT_ERR(reg);
  169. }
  170. pfc_init_m3n();
  171. #elif RCAR_LSI == RCAR_V3M /* V3M */
  172. if ((PRR_PRODUCT_V3M) != (reg & PRR_PRODUCT_MASK)) {
  173. PRR_PRODUCT_ERR(reg);
  174. }
  175. pfc_init_v3m();
  176. #elif RCAR_LSI == RCAR_E3 /* E3 */
  177. if ((PRR_PRODUCT_E3) != (reg & PRR_PRODUCT_MASK)) {
  178. PRR_PRODUCT_ERR(reg);
  179. }
  180. pfc_init_e3();
  181. #elif RCAR_LSI == RCAR_D3 /* D3 */
  182. if ((PRR_PRODUCT_D3) != (reg & PRR_PRODUCT_MASK)) {
  183. PRR_PRODUCT_ERR(reg);
  184. }
  185. pfc_init_d3();
  186. #else
  187. #error "Don't have PFC initialize routine(unknown)."
  188. #endif
  189. #endif
  190. }