2 * Copyright (C) 2015-2016 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <debug_uart.h>
13 #include "micro-support-card.h"
16 struct uniphier_spl_initdata {
17 enum uniphier_soc_id soc_id;
18 void (*bcu_init)(const struct uniphier_board_data *bd);
19 void (*early_clk_init)(void);
20 void (*sbc_init)(void);
21 int (*dpll_init)(const struct uniphier_board_data *bd);
22 int (*memconf_init)(const struct uniphier_board_data *bd);
23 void (*dram_clk_init)(void);
24 int (*umc_init)(const struct uniphier_board_data *bd);
27 static const struct uniphier_spl_initdata uniphier_spl_initdata[] = {
28 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
30 .soc_id = SOC_UNIPHIER_SLD3,
31 .bcu_init = uniphier_sld3_bcu_init,
32 .early_clk_init = uniphier_sld3_early_clk_init,
33 .sbc_init = uniphier_sbc_init_admulti,
34 .dpll_init = uniphier_sld3_dpll_init,
35 .memconf_init = uniphier_memconf_3ch_no_disbit_init,
36 .dram_clk_init = uniphier_sld3_dram_clk_init,
37 .umc_init = uniphier_sld3_umc_init,
40 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
42 .soc_id = SOC_UNIPHIER_LD4,
43 .bcu_init = uniphier_ld4_bcu_init,
44 .early_clk_init = uniphier_sld3_early_clk_init,
45 .sbc_init = uniphier_ld4_sbc_init,
46 .dpll_init = uniphier_ld4_dpll_init,
47 .memconf_init = uniphier_memconf_2ch_init,
48 .dram_clk_init = uniphier_sld3_dram_clk_init,
49 .umc_init = uniphier_ld4_umc_init,
52 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
54 .soc_id = SOC_UNIPHIER_PRO4,
55 .early_clk_init = uniphier_sld3_early_clk_init,
56 .sbc_init = uniphier_sbc_init_savepin,
57 .dpll_init = uniphier_pro4_dpll_init,
58 .memconf_init = uniphier_memconf_2ch_init,
59 .dram_clk_init = uniphier_sld3_dram_clk_init,
60 .umc_init = uniphier_pro4_umc_init,
63 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
65 .soc_id = SOC_UNIPHIER_SLD8,
66 .bcu_init = uniphier_ld4_bcu_init,
67 .early_clk_init = uniphier_sld3_early_clk_init,
68 .sbc_init = uniphier_ld4_sbc_init,
69 .dpll_init = uniphier_sld8_dpll_init,
70 .memconf_init = uniphier_memconf_2ch_init,
71 .dram_clk_init = uniphier_sld3_dram_clk_init,
72 .umc_init = uniphier_sld8_umc_init,
75 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
77 .soc_id = SOC_UNIPHIER_PRO5,
78 .early_clk_init = uniphier_sld3_early_clk_init,
79 .sbc_init = uniphier_sbc_init_savepin,
80 .dpll_init = uniphier_pro5_dpll_init,
81 .memconf_init = uniphier_memconf_2ch_init,
82 .dram_clk_init = uniphier_pro5_dram_clk_init,
83 .umc_init = uniphier_pro5_umc_init,
86 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
88 .soc_id = SOC_UNIPHIER_PXS2,
89 .early_clk_init = uniphier_sld3_early_clk_init,
90 .sbc_init = uniphier_pxs2_sbc_init,
91 .dpll_init = uniphier_pxs2_dpll_init,
92 .memconf_init = uniphier_memconf_3ch_init,
93 .dram_clk_init = uniphier_pxs2_dram_clk_init,
94 .umc_init = uniphier_pxs2_umc_init,
97 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
99 .soc_id = SOC_UNIPHIER_LD6B,
100 .early_clk_init = uniphier_sld3_early_clk_init,
101 .sbc_init = uniphier_pxs2_sbc_init,
102 .dpll_init = uniphier_pxs2_dpll_init,
103 .memconf_init = uniphier_memconf_3ch_init,
104 .dram_clk_init = uniphier_pxs2_dram_clk_init,
105 .umc_init = uniphier_pxs2_umc_init,
108 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
110 .soc_id = SOC_UNIPHIER_LD11,
111 .early_clk_init = uniphier_ld11_early_clk_init,
112 .sbc_init = uniphier_ld11_sbc_init,
113 .dpll_init = uniphier_ld11_dpll_init,
114 .memconf_init = uniphier_memconf_2ch_init,
115 .dram_clk_init = uniphier_ld11_dram_clk_init,
116 .umc_init = uniphier_ld11_umc_init,
119 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
121 .soc_id = SOC_UNIPHIER_LD20,
122 .early_clk_init = uniphier_ld11_early_clk_init,
123 .sbc_init = uniphier_ld11_sbc_init,
124 .dpll_init = uniphier_ld20_dpll_init,
125 .memconf_init = uniphier_memconf_3ch_init,
126 .dram_clk_init = uniphier_ld20_dram_clk_init,
127 .umc_init = uniphier_ld20_umc_init,
132 static const struct uniphier_spl_initdata *uniphier_get_spl_initdata(
133 enum uniphier_soc_id soc_id)
137 for (i = 0; i < ARRAY_SIZE(uniphier_spl_initdata); i++) {
138 if (uniphier_spl_initdata[i].soc_id == soc_id)
139 return &uniphier_spl_initdata[i];
145 void spl_board_init(void)
147 const struct uniphier_board_data *bd;
148 const struct uniphier_spl_initdata *initdata;
149 enum uniphier_soc_id soc_id;
152 #ifdef CONFIG_DEBUG_UART
156 bd = uniphier_get_board_param();
160 soc_id = uniphier_get_soc_type();
161 initdata = uniphier_get_spl_initdata(soc_id);
165 if (initdata->bcu_init)
166 initdata->bcu_init(bd);
168 initdata->sbc_init();
170 initdata->early_clk_init();
176 #ifdef CONFIG_SPL_SERIAL_SUPPORT
177 preloader_console_init();
182 ret = initdata->dpll_init(bd);
184 pr_err("failed to init DPLL\n");
190 ret = initdata->memconf_init(bd);
192 pr_err("failed to init MEMCONF\n");
198 initdata->dram_clk_init();
202 ret = initdata->umc_init(bd);
204 pr_err("failed to init DRAM\n");