Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | fcdbbec | 2016-07-22 13:38:32 +0900 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 Socionext Inc. |
| 3 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
Masahiro Yamada | c93f279 | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 8 | #include <common.h> |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 9 | #include <libfdt.h> |
| 10 | #include <linux/kernel.h> |
Masahiro Yamada | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 11 | |
| 12 | #include "init.h" |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 13 | |
Masahiro Yamada | c93f279 | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 16 | #if defined(CONFIG_ARCH_UNIPHIER_SLD3) |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 17 | static const struct uniphier_board_data uniphier_sld3_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 18 | .dram_freq = 1600, |
| 19 | .dram_nr_ch = 3, |
| 20 | .dram_ch[0] = { |
| 21 | .base = 0x80000000, |
| 22 | .size = 0x20000000, |
| 23 | .width = 32, |
| 24 | }, |
| 25 | .dram_ch[1] = { |
| 26 | .base = 0xc0000000, |
| 27 | .size = 0x20000000, |
| 28 | .width = 16, |
| 29 | }, |
| 30 | .dram_ch[2] = { |
| 31 | .base = 0xc0000000, |
| 32 | .size = 0x10000000, |
| 33 | .width = 16, |
| 34 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 35 | }; |
| 36 | #endif |
| 37 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 38 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 39 | static const struct uniphier_board_data uniphier_ld4_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 40 | .dram_freq = 1600, |
| 41 | .dram_nr_ch = 2, |
| 42 | .dram_ch[0] = { |
| 43 | .base = 0x80000000, |
| 44 | .size = 0x10000000, |
| 45 | .width = 16, |
| 46 | }, |
| 47 | .dram_ch[1] = { |
| 48 | .base = 0x90000000, |
| 49 | .size = 0x10000000, |
| 50 | .width = 16, |
| 51 | }, |
Masahiro Yamada | fcdbbec | 2016-07-22 13:38:32 +0900 | [diff] [blame] | 52 | .flags = UNIPHIER_BD_DDR3PLUS, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 53 | }; |
| 54 | #endif |
| 55 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 56 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
Masahiro Yamada | 40efc4f | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 57 | /* 1GB RAM board */ |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 58 | static const struct uniphier_board_data uniphier_pro4_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 59 | .dram_freq = 1600, |
| 60 | .dram_nr_ch = 2, |
| 61 | .dram_ch[0] = { |
| 62 | .base = 0x80000000, |
| 63 | .size = 0x20000000, |
| 64 | .width = 32, |
| 65 | }, |
| 66 | .dram_ch[1] = { |
| 67 | .base = 0xa0000000, |
| 68 | .size = 0x20000000, |
| 69 | .width = 32, |
| 70 | }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 71 | }; |
Masahiro Yamada | 40efc4f | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 72 | |
| 73 | /* 2GB RAM board */ |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 74 | static const struct uniphier_board_data uniphier_pro4_2g_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 75 | .dram_freq = 1600, |
| 76 | .dram_nr_ch = 2, |
| 77 | .dram_ch[0] = { |
| 78 | .base = 0x80000000, |
| 79 | .size = 0x40000000, |
| 80 | .width = 32, |
| 81 | }, |
| 82 | .dram_ch[1] = { |
| 83 | .base = 0xc0000000, |
| 84 | .size = 0x40000000, |
| 85 | .width = 32, |
| 86 | }, |
Masahiro Yamada | 40efc4f | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 87 | }; |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 88 | #endif |
| 89 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 90 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 91 | static const struct uniphier_board_data uniphier_sld8_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 92 | .dram_freq = 1333, |
| 93 | .dram_nr_ch = 2, |
| 94 | .dram_ch[0] = { |
| 95 | .base = 0x80000000, |
| 96 | .size = 0x10000000, |
| 97 | .width = 16, |
| 98 | }, |
| 99 | .dram_ch[1] = { |
| 100 | .base = 0x90000000, |
| 101 | .size = 0x10000000, |
| 102 | .width = 16, |
| 103 | }, |
Masahiro Yamada | fcdbbec | 2016-07-22 13:38:32 +0900 | [diff] [blame] | 104 | .flags = UNIPHIER_BD_DDR3PLUS, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 105 | }; |
| 106 | #endif |
| 107 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 108 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 109 | static const struct uniphier_board_data uniphier_pro5_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 110 | .dram_freq = 1866, |
| 111 | .dram_nr_ch = 2, |
| 112 | .dram_ch[0] = { |
| 113 | .base = 0x80000000, |
| 114 | .size = 0x20000000, |
| 115 | .width = 32, |
| 116 | }, |
| 117 | .dram_ch[1] = { |
| 118 | .base = 0xa0000000, |
| 119 | .size = 0x20000000, |
| 120 | .width = 32, |
| 121 | }, |
Masahiro Yamada | d5167d5 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 122 | }; |
| 123 | #endif |
| 124 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 125 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 126 | static const struct uniphier_board_data uniphier_pxs2_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 127 | .dram_freq = 2133, |
| 128 | .dram_nr_ch = 3, |
| 129 | .dram_ch[0] = { |
| 130 | .base = 0x80000000, |
| 131 | .size = 0x40000000, |
| 132 | .width = 32, |
| 133 | }, |
| 134 | .dram_ch[1] = { |
| 135 | .base = 0xc0000000, |
| 136 | .size = 0x20000000, |
| 137 | .width = 32, |
| 138 | }, |
| 139 | .dram_ch[2] = { |
| 140 | .base = 0xe0000000, |
| 141 | .size = 0x20000000, |
| 142 | .width = 16, |
| 143 | }, |
Masahiro Yamada | 9dd408f | 2015-12-17 17:47:43 +0900 | [diff] [blame] | 144 | }; |
| 145 | #endif |
| 146 | |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 147 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 148 | static const struct uniphier_board_data uniphier_ld6b_data = { |
Masahiro Yamada | 799e6f2 | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 149 | .dram_freq = 1866, |
| 150 | .dram_nr_ch = 3, |
| 151 | .dram_ch[0] = { |
| 152 | .base = 0x80000000, |
| 153 | .size = 0x40000000, |
| 154 | .width = 32, |
| 155 | }, |
| 156 | .dram_ch[1] = { |
| 157 | .base = 0xc0000000, |
| 158 | .size = 0x20000000, |
| 159 | .width = 32, |
| 160 | }, |
| 161 | .dram_ch[2] = { |
| 162 | .base = 0xe0000000, |
| 163 | .size = 0x20000000, |
| 164 | .width = 16, |
| 165 | }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 166 | }; |
| 167 | #endif |
| 168 | |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 169 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
| 170 | static const struct uniphier_board_data uniphier_ld11_data = { |
| 171 | .dram_freq = 1600, |
| 172 | .dram_nr_ch = 2, |
| 173 | .dram_ch[0] = { |
| 174 | .base = 0x80000000, |
| 175 | .size = 0x20000000, |
| 176 | .width = 16, |
| 177 | }, |
| 178 | .dram_ch[1] = { |
| 179 | .base = 0xa0000000, |
| 180 | .size = 0x20000000, |
| 181 | .width = 16, |
| 182 | }, |
| 183 | }; |
| 184 | #endif |
| 185 | |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 186 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
Masahiro Yamada | 2de45ed | 2016-09-14 01:06:10 +0900 | [diff] [blame] | 187 | static const struct uniphier_board_data uniphier_ld20_ref_data = { |
| 188 | .dram_freq = 1866, |
| 189 | .dram_nr_ch = 3, |
| 190 | .dram_ch[0] = { |
| 191 | .base = 0x80000000, |
| 192 | .size = 0x40000000, |
| 193 | .width = 32, |
| 194 | }, |
| 195 | .dram_ch[1] = { |
| 196 | .base = 0xc0000000, |
| 197 | .size = 0x40000000, |
| 198 | .width = 32, |
| 199 | }, |
| 200 | .dram_ch[2] = { |
| 201 | .base = 0x100000000UL, |
| 202 | .size = 0x40000000, |
| 203 | .width = 32, |
| 204 | }, |
| 205 | .flags = UNIPHIER_BD_BOARD_LD20_REF, |
| 206 | }; |
| 207 | |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 208 | static const struct uniphier_board_data uniphier_ld20_data = { |
| 209 | .dram_freq = 1866, |
| 210 | .dram_nr_ch = 3, |
| 211 | .dram_ch[0] = { |
| 212 | .base = 0x80000000, |
| 213 | .size = 0x40000000, |
| 214 | .width = 32, |
| 215 | }, |
| 216 | .dram_ch[1] = { |
| 217 | .base = 0xc0000000, |
| 218 | .size = 0x40000000, |
| 219 | .width = 32, |
| 220 | }, |
| 221 | .dram_ch[2] = { |
| 222 | .base = 0x100000000UL, |
| 223 | .size = 0x40000000, |
| 224 | .width = 32, |
| 225 | }, |
Masahiro Yamada | 2de45ed | 2016-09-14 01:06:10 +0900 | [diff] [blame] | 226 | .flags = UNIPHIER_BD_BOARD_LD20_GLOBAL, |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 227 | }; |
Masahiro Yamada | 78ead63 | 2016-07-22 13:38:33 +0900 | [diff] [blame] | 228 | |
| 229 | static const struct uniphier_board_data uniphier_ld21_data = { |
| 230 | .dram_freq = 1866, |
| 231 | .dram_nr_ch = 2, |
| 232 | .dram_ch[0] = { |
| 233 | .base = 0x80000000, |
Masahiro Yamada | 63cd9b1 | 2016-09-14 01:06:09 +0900 | [diff] [blame] | 234 | .size = 0x20000000, |
Masahiro Yamada | 78ead63 | 2016-07-22 13:38:33 +0900 | [diff] [blame] | 235 | .width = 32, |
| 236 | }, |
| 237 | .dram_ch[1] = { |
| 238 | .base = 0xc0000000, |
| 239 | .size = 0x40000000, |
| 240 | .width = 32, |
| 241 | }, |
Masahiro Yamada | 2de45ed | 2016-09-14 01:06:10 +0900 | [diff] [blame] | 242 | .flags = UNIPHIER_BD_BOARD_LD21_GLOBAL, |
Masahiro Yamada | 78ead63 | 2016-07-22 13:38:33 +0900 | [diff] [blame] | 243 | }; |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 244 | #endif |
| 245 | |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 246 | struct uniphier_board_id { |
| 247 | const char *compatible; |
| 248 | const struct uniphier_board_data *param; |
| 249 | }; |
| 250 | |
| 251 | static const struct uniphier_board_id uniphier_boards[] = { |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 252 | #if defined(CONFIG_ARCH_UNIPHIER_SLD3) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 253 | { "socionext,uniphier-sld3", &uniphier_sld3_data, }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 254 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 255 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 256 | { "socionext,uniphier-ld4", &uniphier_ld4_data, }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 257 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 258 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 259 | { "socionext,uniphier-pro4-ace", &uniphier_pro4_2g_data, }, |
| 260 | { "socionext,uniphier-pro4-sanji", &uniphier_pro4_2g_data, }, |
| 261 | { "socionext,uniphier-pro4", &uniphier_pro4_data, }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 262 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 263 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 264 | { "socionext,uniphier-sld8", &uniphier_sld8_data, }, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 265 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 266 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 267 | { "socionext,uniphier-pro5", &uniphier_pro5_data, }, |
Masahiro Yamada | d5167d5 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 268 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 269 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 270 | { "socionext,uniphier-pxs2", &uniphier_pxs2_data, }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 271 | #endif |
Masahiro Yamada | 53c59ae | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 272 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 273 | { "socionext,uniphier-ld6b", &uniphier_ld6b_data, }, |
Masahiro Yamada | 1fe65d3 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 274 | #endif |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 275 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 276 | { "socionext,uniphier-ld11", &uniphier_ld11_data, }, |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 277 | #endif |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 278 | #if defined(CONFIG_ARCH_UNIPHIER_LD20) |
Masahiro Yamada | 39a67ff | 2016-10-07 16:43:00 +0900 | [diff] [blame] | 279 | { "socionext,uniphier-ld21", &uniphier_ld21_data, }, |
| 280 | { "socionext,uniphier-ld20-ref", &uniphier_ld20_ref_data, }, |
| 281 | { "socionext,uniphier-ld20", &uniphier_ld20_data, }, |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 282 | #endif |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 283 | }; |
| 284 | |
Masahiro Yamada | c93f279 | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 285 | const struct uniphier_board_data *uniphier_get_board_param(void) |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 286 | { |
| 287 | int i; |
| 288 | |
| 289 | for (i = 0; i < ARRAY_SIZE(uniphier_boards); i++) { |
Masahiro Yamada | c93f279 | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 290 | if (!fdt_node_check_compatible(gd->fdt_blob, 0, |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 291 | uniphier_boards[i].compatible)) |
| 292 | return uniphier_boards[i].param; |
| 293 | } |
| 294 | |
| 295 | return NULL; |
| 296 | } |