blob: d09c91ab42c864a2da4ebfad51d6bd63b63c23b9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +09002/*
3 * Copyright (C) 2015-2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +09005 */
6
7#include <common.h>
8#include <debug_uart.h>
9#include <spl.h>
10
11#include "init.h"
12#include "micro-support-card.h"
13#include "soc-info.h"
14
15struct uniphier_spl_initdata {
Masahiro Yamada31649052017-01-21 18:05:26 +090016 unsigned int soc_id;
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090017 void (*bcu_init)(const struct uniphier_board_data *bd);
18 void (*early_clk_init)(void);
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090019 int (*dpll_init)(const struct uniphier_board_data *bd);
20 int (*memconf_init)(const struct uniphier_board_data *bd);
21 void (*dram_clk_init)(void);
22 int (*umc_init)(const struct uniphier_board_data *bd);
23};
24
25static const struct uniphier_spl_initdata uniphier_spl_initdata[] = {
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090026#if defined(CONFIG_ARCH_UNIPHIER_LD4)
27 {
Masahiro Yamada31649052017-01-21 18:05:26 +090028 .soc_id = UNIPHIER_LD4_ID,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090029 .bcu_init = uniphier_ld4_bcu_init,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090030 .early_clk_init = uniphier_ld4_early_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090031 .dpll_init = uniphier_ld4_dpll_init,
32 .memconf_init = uniphier_memconf_2ch_init,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090033 .dram_clk_init = uniphier_ld4_dram_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090034 .umc_init = uniphier_ld4_umc_init,
35 },
36#endif
37#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
38 {
Masahiro Yamada31649052017-01-21 18:05:26 +090039 .soc_id = UNIPHIER_PRO4_ID,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090040 .early_clk_init = uniphier_ld4_early_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090041 .dpll_init = uniphier_pro4_dpll_init,
42 .memconf_init = uniphier_memconf_2ch_init,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090043 .dram_clk_init = uniphier_ld4_dram_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090044 .umc_init = uniphier_pro4_umc_init,
45 },
46#endif
47#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
48 {
Masahiro Yamada31649052017-01-21 18:05:26 +090049 .soc_id = UNIPHIER_SLD8_ID,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090050 .bcu_init = uniphier_ld4_bcu_init,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090051 .early_clk_init = uniphier_ld4_early_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090052 .dpll_init = uniphier_sld8_dpll_init,
53 .memconf_init = uniphier_memconf_2ch_init,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090054 .dram_clk_init = uniphier_ld4_dram_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090055 .umc_init = uniphier_sld8_umc_init,
56 },
57#endif
58#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
59 {
Masahiro Yamada31649052017-01-21 18:05:26 +090060 .soc_id = UNIPHIER_PRO5_ID,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090061 .early_clk_init = uniphier_ld4_early_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090062 .dpll_init = uniphier_pro5_dpll_init,
63 .memconf_init = uniphier_memconf_2ch_init,
64 .dram_clk_init = uniphier_pro5_dram_clk_init,
65 .umc_init = uniphier_pro5_umc_init,
66 },
67#endif
68#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
69 {
Masahiro Yamada31649052017-01-21 18:05:26 +090070 .soc_id = UNIPHIER_PXS2_ID,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090071 .early_clk_init = uniphier_ld4_early_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090072 .dpll_init = uniphier_pxs2_dpll_init,
73 .memconf_init = uniphier_memconf_3ch_init,
74 .dram_clk_init = uniphier_pxs2_dram_clk_init,
75 .umc_init = uniphier_pxs2_umc_init,
76 },
77#endif
78#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
79 {
Masahiro Yamada31649052017-01-21 18:05:26 +090080 .soc_id = UNIPHIER_LD6B_ID,
Masahiro Yamadad3c14612017-08-13 09:01:13 +090081 .early_clk_init = uniphier_ld4_early_clk_init,
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090082 .dpll_init = uniphier_pxs2_dpll_init,
83 .memconf_init = uniphier_memconf_3ch_init,
84 .dram_clk_init = uniphier_pxs2_dram_clk_init,
85 .umc_init = uniphier_pxs2_umc_init,
86 },
87#endif
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090088};
Masahiro Yamada1b818982017-01-21 18:05:27 +090089UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_spl_initdata, uniphier_spl_initdata)
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090090
91void spl_board_init(void)
92{
93 const struct uniphier_board_data *bd;
94 const struct uniphier_spl_initdata *initdata;
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +090095 int ret;
96
97#ifdef CONFIG_DEBUG_UART
98 debug_uart_init();
99#endif
100
101 bd = uniphier_get_board_param();
102 if (!bd)
103 hang();
104
Masahiro Yamada1b818982017-01-21 18:05:27 +0900105 initdata = uniphier_get_spl_initdata();
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900106 if (!initdata)
107 hang();
108
109 if (initdata->bcu_init)
110 initdata->bcu_init(bd);
111
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900112 initdata->early_clk_init();
113
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900114#ifdef CONFIG_SPL_SERIAL_SUPPORT
115 preloader_console_init();
116#endif
117
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900118 ret = initdata->dpll_init(bd);
119 if (ret) {
120 pr_err("failed to init DPLL\n");
121 hang();
122 }
123
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900124 ret = initdata->memconf_init(bd);
125 if (ret) {
126 pr_err("failed to init MEMCONF\n");
127 hang();
128 }
129
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900130 initdata->dram_clk_init();
131
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900132 ret = initdata->umc_init(bd);
133 if (ret) {
134 pr_err("failed to init DRAM\n");
135 hang();
136 }
Masahiro Yamada8c3aa6b2017-01-15 14:59:09 +0900137}