Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
Masahiro Yamada | 6ba60fa | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 7 | #include <common.h> |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 8 | #include <libfdt.h> |
| 9 | #include <linux/kernel.h> |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 10 | |
| 11 | #include "init.h" |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 12 | |
Masahiro Yamada | 6ba60fa | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 15 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_SLD3) |
| 16 | static const struct uniphier_board_data ph1_sld3_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 17 | .dram_freq = 1600, |
| 18 | .dram_nr_ch = 3, |
| 19 | .dram_ch[0] = { |
| 20 | .base = 0x80000000, |
| 21 | .size = 0x20000000, |
| 22 | .width = 32, |
| 23 | }, |
| 24 | .dram_ch[1] = { |
| 25 | .base = 0xc0000000, |
| 26 | .size = 0x20000000, |
| 27 | .width = 16, |
| 28 | }, |
| 29 | .dram_ch[2] = { |
| 30 | .base = 0xc0000000, |
| 31 | .size = 0x10000000, |
| 32 | .width = 16, |
| 33 | }, |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 34 | }; |
| 35 | #endif |
| 36 | |
| 37 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD4) |
| 38 | static const struct uniphier_board_data ph1_ld4_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 39 | .dram_freq = 1600, |
| 40 | .dram_nr_ch = 2, |
| 41 | .dram_ch[0] = { |
| 42 | .base = 0x80000000, |
| 43 | .size = 0x10000000, |
| 44 | .width = 16, |
| 45 | }, |
| 46 | .dram_ch[1] = { |
| 47 | .base = 0x90000000, |
| 48 | .size = 0x10000000, |
| 49 | .width = 16, |
| 50 | }, |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 51 | }; |
| 52 | #endif |
| 53 | |
| 54 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO4) |
Masahiro Yamada | 3f23111 | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 55 | /* 1GB RAM board */ |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 56 | static const struct uniphier_board_data ph1_pro4_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 57 | .dram_freq = 1600, |
| 58 | .dram_nr_ch = 2, |
| 59 | .dram_ch[0] = { |
| 60 | .base = 0x80000000, |
| 61 | .size = 0x20000000, |
| 62 | .width = 32, |
| 63 | }, |
| 64 | .dram_ch[1] = { |
| 65 | .base = 0xa0000000, |
| 66 | .size = 0x20000000, |
| 67 | .width = 32, |
| 68 | }, |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 69 | }; |
Masahiro Yamada | 3f23111 | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 70 | |
| 71 | /* 2GB RAM board */ |
| 72 | static const struct uniphier_board_data ph1_pro4_2g_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 73 | .dram_freq = 1600, |
| 74 | .dram_nr_ch = 2, |
| 75 | .dram_ch[0] = { |
| 76 | .base = 0x80000000, |
| 77 | .size = 0x40000000, |
| 78 | .width = 32, |
| 79 | }, |
| 80 | .dram_ch[1] = { |
| 81 | .base = 0xc0000000, |
| 82 | .size = 0x40000000, |
| 83 | .width = 32, |
| 84 | }, |
Masahiro Yamada | 3f23111 | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 85 | }; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 86 | #endif |
| 87 | |
| 88 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_SLD8) |
| 89 | static const struct uniphier_board_data ph1_sld8_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 90 | .dram_freq = 1333, |
| 91 | .dram_nr_ch = 2, |
| 92 | .dram_ch[0] = { |
| 93 | .base = 0x80000000, |
| 94 | .size = 0x10000000, |
| 95 | .width = 16, |
| 96 | }, |
| 97 | .dram_ch[1] = { |
| 98 | .base = 0x90000000, |
| 99 | .size = 0x10000000, |
| 100 | .width = 16, |
| 101 | }, |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 102 | }; |
| 103 | #endif |
| 104 | |
Masahiro Yamada | 28f40d4 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 105 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO5) |
| 106 | static const struct uniphier_board_data ph1_pro5_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 107 | .dram_freq = 1866, |
| 108 | .dram_nr_ch = 2, |
| 109 | .dram_ch[0] = { |
| 110 | .base = 0x80000000, |
| 111 | .size = 0x20000000, |
| 112 | .width = 32, |
| 113 | }, |
| 114 | .dram_ch[1] = { |
| 115 | .base = 0xa0000000, |
| 116 | .size = 0x20000000, |
| 117 | .width = 32, |
| 118 | }, |
Masahiro Yamada | 28f40d4 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 119 | }; |
| 120 | #endif |
| 121 | |
Masahiro Yamada | 89c05fa | 2015-12-17 17:47:43 +0900 | [diff] [blame] | 122 | #if defined(CONFIG_ARCH_UNIPHIER_PROXSTREAM2) |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 123 | static const struct uniphier_board_data proxstream2_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 124 | .dram_freq = 2133, |
| 125 | .dram_nr_ch = 3, |
| 126 | .dram_ch[0] = { |
| 127 | .base = 0x80000000, |
| 128 | .size = 0x40000000, |
| 129 | .width = 32, |
| 130 | }, |
| 131 | .dram_ch[1] = { |
| 132 | .base = 0xc0000000, |
| 133 | .size = 0x20000000, |
| 134 | .width = 32, |
| 135 | }, |
| 136 | .dram_ch[2] = { |
| 137 | .base = 0xe0000000, |
| 138 | .size = 0x20000000, |
| 139 | .width = 16, |
| 140 | }, |
Masahiro Yamada | 89c05fa | 2015-12-17 17:47:43 +0900 | [diff] [blame] | 141 | }; |
| 142 | #endif |
| 143 | |
| 144 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD6B) |
| 145 | static const struct uniphier_board_data ph1_ld6b_data = { |
Masahiro Yamada | 46abfcc | 2016-02-26 14:21:34 +0900 | [diff] [blame] | 146 | .dram_freq = 1866, |
| 147 | .dram_nr_ch = 3, |
| 148 | .dram_ch[0] = { |
| 149 | .base = 0x80000000, |
| 150 | .size = 0x40000000, |
| 151 | .width = 32, |
| 152 | }, |
| 153 | .dram_ch[1] = { |
| 154 | .base = 0xc0000000, |
| 155 | .size = 0x20000000, |
| 156 | .width = 32, |
| 157 | }, |
| 158 | .dram_ch[2] = { |
| 159 | .base = 0xe0000000, |
| 160 | .size = 0x20000000, |
| 161 | .width = 16, |
| 162 | }, |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 163 | }; |
| 164 | #endif |
| 165 | |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 166 | struct uniphier_board_id { |
| 167 | const char *compatible; |
| 168 | const struct uniphier_board_data *param; |
| 169 | }; |
| 170 | |
| 171 | static const struct uniphier_board_id uniphier_boards[] = { |
| 172 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_SLD3) |
| 173 | { "socionext,ph1-sld3", &ph1_sld3_data, }, |
| 174 | #endif |
| 175 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD4) |
| 176 | { "socionext,ph1-ld4", &ph1_ld4_data, }, |
| 177 | #endif |
| 178 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO4) |
Masahiro Yamada | 3f23111 | 2016-02-12 20:27:02 +0900 | [diff] [blame] | 179 | { "socionext,ph1-pro4-ace", &ph1_pro4_2g_data, }, |
| 180 | { "socionext,ph1-pro4-sanji", &ph1_pro4_2g_data, }, |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 181 | { "socionext,ph1-pro4", &ph1_pro4_data, }, |
| 182 | #endif |
| 183 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_SLD8) |
| 184 | { "socionext,ph1-sld8", &ph1_sld8_data, }, |
| 185 | #endif |
Masahiro Yamada | 28f40d4 | 2015-09-22 00:27:40 +0900 | [diff] [blame] | 186 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO5) |
| 187 | { "socionext,ph1-pro5", &ph1_pro5_data, }, |
| 188 | #endif |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 189 | #if defined(CONFIG_ARCH_UNIPHIER_PROXSTREAM2) |
| 190 | { "socionext,proxstream2", &proxstream2_data, }, |
| 191 | #endif |
| 192 | #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD6B) |
Masahiro Yamada | 89c05fa | 2015-12-17 17:47:43 +0900 | [diff] [blame] | 193 | { "socionext,ph1-ld6b", &ph1_ld6b_data, }, |
Masahiro Yamada | 019df87 | 2015-09-22 00:27:41 +0900 | [diff] [blame] | 194 | #endif |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 195 | }; |
| 196 | |
Masahiro Yamada | 6ba60fa | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 197 | const struct uniphier_board_data *uniphier_get_board_param(void) |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 198 | { |
| 199 | int i; |
| 200 | |
| 201 | for (i = 0; i < ARRAY_SIZE(uniphier_boards); i++) { |
Masahiro Yamada | 6ba60fa | 2015-12-17 17:47:42 +0900 | [diff] [blame] | 202 | if (!fdt_node_check_compatible(gd->fdt_blob, 0, |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 203 | uniphier_boards[i].compatible)) |
| 204 | return uniphier_boards[i].param; |
| 205 | } |
| 206 | |
| 207 | return NULL; |
| 208 | } |