ARM: uniphier: rework struct uniphier_board_data
[oweals/u-boot.git] / arch / arm / mach-uniphier / boards.c
1 /*
2  * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <libfdt.h>
9 #include <linux/kernel.h>
10
11 #include "init.h"
12
13 DECLARE_GLOBAL_DATA_PTR;
14
15 #if defined(CONFIG_ARCH_UNIPHIER_PH1_SLD3)
16 static const struct uniphier_board_data ph1_sld3_data = {
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         },
34 };
35 #endif
36
37 #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD4)
38 static const struct uniphier_board_data ph1_ld4_data = {
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         },
51 };
52 #endif
53
54 #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO4)
55 /* 1GB RAM board */
56 static const struct uniphier_board_data ph1_pro4_data = {
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         },
69 };
70
71 /* 2GB RAM board */
72 static const struct uniphier_board_data ph1_pro4_2g_data = {
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         },
85 };
86 #endif
87
88 #if defined(CONFIG_ARCH_UNIPHIER_PH1_SLD8)
89 static const struct uniphier_board_data ph1_sld8_data = {
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         },
102 };
103 #endif
104
105 #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO5)
106 static const struct uniphier_board_data ph1_pro5_data = {
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         },
119 };
120 #endif
121
122 #if defined(CONFIG_ARCH_UNIPHIER_PROXSTREAM2)
123 static const struct uniphier_board_data proxstream2_data = {
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         },
141 };
142 #endif
143
144 #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD6B)
145 static const struct uniphier_board_data ph1_ld6b_data = {
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         },
163 };
164 #endif
165
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)
179         { "socionext,ph1-pro4-ace", &ph1_pro4_2g_data, },
180         { "socionext,ph1-pro4-sanji", &ph1_pro4_2g_data, },
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
186 #if defined(CONFIG_ARCH_UNIPHIER_PH1_PRO5)
187         { "socionext,ph1-pro5", &ph1_pro5_data, },
188 #endif
189 #if defined(CONFIG_ARCH_UNIPHIER_PROXSTREAM2)
190         { "socionext,proxstream2", &proxstream2_data, },
191 #endif
192 #if defined(CONFIG_ARCH_UNIPHIER_PH1_LD6B)
193         { "socionext,ph1-ld6b", &ph1_ld6b_data, },
194 #endif
195 };
196
197 const struct uniphier_board_data *uniphier_get_board_param(void)
198 {
199         int i;
200
201         for (i = 0; i < ARRAY_SIZE(uniphier_boards); i++) {
202                 if (!fdt_node_check_compatible(gd->fdt_blob, 0,
203                                                uniphier_boards[i].compatible))
204                         return uniphier_boards[i].param;
205         }
206
207         return NULL;
208 }