xref: /openbmc/u-boot/arch/arm/mach-uniphier/boards.c (revision 010ad8c3)
1 /*
2  * Copyright (C) 2015-2016 Socionext Inc.
3  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.h>
9 #include <libfdt.h>
10 #include <linux/kernel.h>
11 
12 #include "init.h"
13 
14 DECLARE_GLOBAL_DATA_PTR;
15 
16 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
17 static const struct uniphier_board_data uniphier_sld3_data = {
18 	.dram_freq = 1600,
19 	.dram_ch[0] = {
20 		.size = 0x20000000,
21 		.width = 32,
22 	},
23 	.dram_ch[1] = {
24 		.size = 0x20000000,
25 		.width = 16,
26 	},
27 	.dram_ch[2] = {
28 		.size = 0x10000000,
29 		.width = 16,
30 	},
31 	.flags = UNIPHIER_BD_DRAM_SPARSE,
32 };
33 #endif
34 
35 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
36 static const struct uniphier_board_data uniphier_ld4_data = {
37 	.dram_freq = 1600,
38 	.dram_ch[0] = {
39 		.size = 0x10000000,
40 		.width = 16,
41 	},
42 	.dram_ch[1] = {
43 		.size = 0x10000000,
44 		.width = 16,
45 	},
46 	.flags = UNIPHIER_BD_DDR3PLUS,
47 };
48 #endif
49 
50 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
51 /* 1GB RAM board */
52 static const struct uniphier_board_data uniphier_pro4_data = {
53 	.dram_freq = 1600,
54 	.dram_ch[0] = {
55 		.size = 0x20000000,
56 		.width = 32,
57 	},
58 	.dram_ch[1] = {
59 		.size = 0x20000000,
60 		.width = 32,
61 	},
62 };
63 
64 /* 2GB RAM board */
65 static const struct uniphier_board_data uniphier_pro4_2g_data = {
66 	.dram_freq = 1600,
67 	.dram_ch[0] = {
68 		.size = 0x40000000,
69 		.width = 32,
70 	},
71 	.dram_ch[1] = {
72 		.size = 0x40000000,
73 		.width = 32,
74 	},
75 };
76 #endif
77 
78 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
79 static const struct uniphier_board_data uniphier_sld8_data = {
80 	.dram_freq = 1333,
81 	.dram_ch[0] = {
82 		.size = 0x10000000,
83 		.width = 16,
84 	},
85 	.dram_ch[1] = {
86 		.size = 0x10000000,
87 		.width = 16,
88 	},
89 	.flags = UNIPHIER_BD_DDR3PLUS,
90 };
91 #endif
92 
93 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
94 static const struct uniphier_board_data uniphier_pro5_data = {
95 	.dram_freq = 1866,
96 	.dram_ch[0] = {
97 		.size = 0x20000000,
98 		.width = 32,
99 	},
100 	.dram_ch[1] = {
101 		.size = 0x20000000,
102 		.width = 32,
103 	},
104 };
105 #endif
106 
107 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
108 static const struct uniphier_board_data uniphier_pxs2_data = {
109 	.dram_freq = 2133,
110 	.dram_ch[0] = {
111 		.size = 0x40000000,
112 		.width = 32,
113 	},
114 	.dram_ch[1] = {
115 		.size = 0x20000000,
116 		.width = 32,
117 	},
118 	.dram_ch[2] = {
119 		.size = 0x20000000,
120 		.width = 16,
121 	},
122 };
123 #endif
124 
125 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
126 static const struct uniphier_board_data uniphier_ld6b_data = {
127 	.dram_freq = 1866,
128 	.dram_ch[0] = {
129 		.size = 0x40000000,
130 		.width = 32,
131 	},
132 	.dram_ch[1] = {
133 		.size = 0x20000000,
134 		.width = 32,
135 	},
136 	.dram_ch[2] = {
137 		.size = 0x20000000,
138 		.width = 16,
139 	},
140 };
141 #endif
142 
143 struct uniphier_board_id {
144 	const char *compatible;
145 	const struct uniphier_board_data *param;
146 };
147 
148 static const struct uniphier_board_id uniphier_boards[] = {
149 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
150 	{ "socionext,uniphier-sld3", &uniphier_sld3_data, },
151 #endif
152 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
153 	{ "socionext,uniphier-ld4", &uniphier_ld4_data, },
154 #endif
155 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
156 	{ "socionext,uniphier-pro4-ace", &uniphier_pro4_2g_data, },
157 	{ "socionext,uniphier-pro4-sanji", &uniphier_pro4_2g_data, },
158 	{ "socionext,uniphier-pro4", &uniphier_pro4_data, },
159 #endif
160 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
161 	{ "socionext,uniphier-sld8", &uniphier_sld8_data, },
162 #endif
163 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
164 	{ "socionext,uniphier-pro5", &uniphier_pro5_data, },
165 #endif
166 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
167 	{ "socionext,uniphier-pxs2", &uniphier_pxs2_data, },
168 #endif
169 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
170 	{ "socionext,uniphier-ld6b", &uniphier_ld6b_data, },
171 #endif
172 };
173 
174 const struct uniphier_board_data *uniphier_get_board_param(void)
175 {
176 	int i;
177 
178 	for (i = 0; i < ARRAY_SIZE(uniphier_boards); i++) {
179 		if (!fdt_node_check_compatible(gd->fdt_blob, 0,
180 					       uniphier_boards[i].compatible))
181 			return uniphier_boards[i].param;
182 	}
183 
184 	return NULL;
185 }
186