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