From: Masahiro Yamada Date: Sun, 15 Jan 2017 05:59:09 +0000 (+0900) Subject: ARM: uniphier: refactor spl_init_board() X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=a8e6300d483d;p=u-boot.git ARM: uniphier: refactor spl_init_board() Merge init-*.c into a single file using a table of callbacks because the initialization flow is almost common among SoCs. Signed-off-by: Masahiro Yamada --- diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile index 98b42a06ce..7f1abd03dc 100644 --- a/arch/arm/mach-uniphier/Makefile +++ b/arch/arm/mach-uniphier/Makefile @@ -4,8 +4,9 @@ ifdef CONFIG_SPL_BUILD +obj-y += spl_board_init.o obj-y += memconf.o -obj-y += init/ bcu/ +obj-y += bcu/ obj-$(CONFIG_MICRO_SUPPORT_CARD) += sbc/ else diff --git a/arch/arm/mach-uniphier/clk/Makefile b/arch/arm/mach-uniphier/clk/Makefile index bf77fca5a9..37df04b12e 100644 --- a/arch/arm/mach-uniphier/clk/Makefile +++ b/arch/arm/mach-uniphier/clk/Makefile @@ -8,9 +8,9 @@ obj-$(CONFIG_ARCH_UNIPHIER_SLD3) += clk-early-sld3.o clk-dram-sld3.o dpll-sld3.o obj-$(CONFIG_ARCH_UNIPHIER_LD4) += clk-early-sld3.o clk-dram-sld3.o dpll-ld4.o obj-$(CONFIG_ARCH_UNIPHIER_PRO4) += clk-early-sld3.o clk-dram-sld3.o dpll-pro4.o obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += clk-early-sld3.o clk-dram-sld3.o dpll-sld8.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += clk-early-sld3.o clk-dram-pro5.o -obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += clk-early-sld3.o clk-dram-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += clk-early-sld3.o clk-dram-pxs2.o +obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += clk-early-sld3.o clk-dram-pro5.o dpll-pro5.o +obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += clk-early-sld3.o clk-dram-pxs2.o dpll-pxs2.o +obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += clk-early-sld3.o clk-dram-pxs2.o dpll-pxs2.o obj-$(CONFIG_ARCH_UNIPHIER_LD11) += clk-early-ld11.o clk-dram-ld11.o dpll-ld11.o obj-$(CONFIG_ARCH_UNIPHIER_LD20) += clk-early-ld11.o clk-dram-ld20.o dpll-ld20.o diff --git a/arch/arm/mach-uniphier/clk/dpll-pro5.c b/arch/arm/mach-uniphier/clk/dpll-pro5.c new file mode 100644 index 0000000000..d3a42c7b4f --- /dev/null +++ b/arch/arm/mach-uniphier/clk/dpll-pro5.c @@ -0,0 +1,6 @@ +#include "../init.h" + +int uniphier_pro5_dpll_init(const struct uniphier_board_data *bd) +{ + return 0; +} diff --git a/arch/arm/mach-uniphier/clk/dpll-pxs2.c b/arch/arm/mach-uniphier/clk/dpll-pxs2.c new file mode 100644 index 0000000000..328ebf61f9 --- /dev/null +++ b/arch/arm/mach-uniphier/clk/dpll-pxs2.c @@ -0,0 +1,6 @@ +#include "../init.h" + +int uniphier_pxs2_dpll_init(const struct uniphier_board_data *bd) +{ + return 0; +} diff --git a/arch/arm/mach-uniphier/dram/Makefile b/arch/arm/mach-uniphier/dram/Makefile index 5b9d892511..2ce6199988 100644 --- a/arch/arm/mach-uniphier/dram/Makefile +++ b/arch/arm/mach-uniphier/dram/Makefile @@ -4,12 +4,14 @@ ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_ARCH_UNIPHIER_SLD3) += umc-sld3.o obj-$(CONFIG_ARCH_UNIPHIER_LD4) += umc-ld4.o \ ddrphy-training.o ddrphy-ld4.o obj-$(CONFIG_ARCH_UNIPHIER_PRO4) += umc-pro4.o \ ddrphy-training.o ddrphy-ld4.o obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += umc-sld8.o \ ddrphy-training.o ddrphy-ld4.o +obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += umc-pro5.o obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += umc-pxs2.o obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += umc-pxs2.o obj-$(CONFIG_ARCH_UNIPHIER_LD11) += umc-ld11.o diff --git a/arch/arm/mach-uniphier/dram/umc-pro5.c b/arch/arm/mach-uniphier/dram/umc-pro5.c new file mode 100644 index 0000000000..4f34d1f20c --- /dev/null +++ b/arch/arm/mach-uniphier/dram/umc-pro5.c @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2016 Socionext Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "../init.h" + +int uniphier_pro5_umc_init(const struct uniphier_board_data *bd) +{ + return 0; +} diff --git a/arch/arm/mach-uniphier/dram/umc-sld3.c b/arch/arm/mach-uniphier/dram/umc-sld3.c new file mode 100644 index 0000000000..99249eb201 --- /dev/null +++ b/arch/arm/mach-uniphier/dram/umc-sld3.c @@ -0,0 +1,6 @@ +#include "../init.h" + +int uniphier_sld3_umc_init(const struct uniphier_board_data *bd) +{ + return 0; +} diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h index 6a1816f6d5..d207806401 100644 --- a/arch/arm/mach-uniphier/init.h +++ b/arch/arm/mach-uniphier/init.h @@ -84,6 +84,8 @@ int uniphier_sld3_dpll_init(const struct uniphier_board_data *bd); int uniphier_ld4_dpll_init(const struct uniphier_board_data *bd); int uniphier_pro4_dpll_init(const struct uniphier_board_data *bd); int uniphier_sld8_dpll_init(const struct uniphier_board_data *bd); +int uniphier_pro5_dpll_init(const struct uniphier_board_data *bd); +int uniphier_pxs2_dpll_init(const struct uniphier_board_data *bd); int uniphier_ld11_dpll_init(const struct uniphier_board_data *bd); int uniphier_ld20_dpll_init(const struct uniphier_board_data *bd); @@ -96,9 +98,11 @@ void uniphier_pxs2_dram_clk_init(void); void uniphier_ld11_dram_clk_init(void); void uniphier_ld20_dram_clk_init(void); +int uniphier_sld3_umc_init(const struct uniphier_board_data *bd); int uniphier_ld4_umc_init(const struct uniphier_board_data *bd); int uniphier_pro4_umc_init(const struct uniphier_board_data *bd); int uniphier_sld8_umc_init(const struct uniphier_board_data *bd); +int uniphier_pro5_umc_init(const struct uniphier_board_data *bd); int uniphier_pxs2_umc_init(const struct uniphier_board_data *bd); int uniphier_ld20_umc_init(const struct uniphier_board_data *bd); int uniphier_ld11_umc_init(const struct uniphier_board_data *bd); diff --git a/arch/arm/mach-uniphier/init/Makefile b/arch/arm/mach-uniphier/init/Makefile deleted file mode 100644 index dcaa4451ad..0000000000 --- a/arch/arm/mach-uniphier/init/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# -# SPDX-License-Identifier: GPL-2.0+ -# - -obj-y += init.o - -obj-$(CONFIG_ARCH_UNIPHIER_SLD3) += init-sld3.o -obj-$(CONFIG_ARCH_UNIPHIER_LD4) += init-ld4.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO4) += init-pro4.o -obj-$(CONFIG_ARCH_UNIPHIER_SLD8) += init-sld8.o -obj-$(CONFIG_ARCH_UNIPHIER_PRO5) += init-pro5.o -obj-$(CONFIG_ARCH_UNIPHIER_PXS2) += init-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD6B) += init-pxs2.o -obj-$(CONFIG_ARCH_UNIPHIER_LD11) += init-ld11.o -obj-$(CONFIG_ARCH_UNIPHIER_LD20) += init-ld20.o diff --git a/arch/arm/mach-uniphier/init/init-ld11.c b/arch/arm/mach-uniphier/init/init-ld11.c deleted file mode 100644 index e19dc5b1a7..0000000000 --- a/arch/arm/mach-uniphier/init/init-ld11.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2016 Socionext Inc. - * Author: Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_ld11_init(const struct uniphier_board_data *bd) -{ - uniphier_ld11_sbc_init(); - - support_card_init(); - - led_puts("L0"); - - uniphier_memconf_2ch_init(bd); - - led_puts("L1"); - - uniphier_ld11_early_clk_init(); - uniphier_ld11_dram_clk_init(); - - led_puts("L2"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L3"); - - uniphier_ld11_dpll_init(bd); - - led_puts("L4"); - - { - int res; - - res = uniphier_ld11_umc_init(bd); - if (res < 0) { - while (1) - ; - } - } - - led_puts("L5"); - - dcache_disable(); - - led_puts("L6"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-ld20.c b/arch/arm/mach-uniphier/init/init-ld20.c deleted file mode 100644 index e056d5d0b9..0000000000 --- a/arch/arm/mach-uniphier/init/init-ld20.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2016 Socionext Inc. - * Author: Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_ld20_init(const struct uniphier_board_data *bd) -{ - uniphier_ld11_sbc_init(); - - support_card_init(); - - led_puts("L0"); - - uniphier_memconf_3ch_init(bd); - - led_puts("L1"); - - uniphier_ld11_early_clk_init(); - uniphier_ld20_dram_clk_init(); - - led_puts("L2"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L3"); - - uniphier_ld20_dpll_init(bd); - - led_puts("L4"); - - { - int res; - - res = uniphier_ld20_umc_init(bd); - if (res < 0) { - while (1) - ; - } - } - - led_puts("L5"); - - dcache_disable(); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-ld4.c b/arch/arm/mach-uniphier/init/init-ld4.c deleted file mode 100644 index a5b9493546..0000000000 --- a/arch/arm/mach-uniphier/init/init-ld4.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2013-2015 Panasonic Corporation - * Copyright (C) 2015-2016 Socionext Inc. - * Author: Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_ld4_init(const struct uniphier_board_data *bd) -{ - uniphier_ld4_bcu_init(bd); - - uniphier_ld4_sbc_init(); - - support_card_init(); - - uniphier_ld4_dpll_init(bd); - - led_puts("L0"); - - uniphier_memconf_2ch_init(bd); - - led_puts("L1"); - - uniphier_sld3_early_clk_init(); - uniphier_sld3_dram_clk_init(); - - led_puts("L2"); - - led_puts("L3"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L4"); - - { - int res; - - res = uniphier_ld4_umc_init(bd); - if (res < 0) { - while (1) - ; - } - } - - led_puts("L5"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-pro4.c b/arch/arm/mach-uniphier/init/init-pro4.c deleted file mode 100644 index c277071450..0000000000 --- a/arch/arm/mach-uniphier/init/init-pro4.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2013-2015 Panasonic Corporation - * Copyright (C) 2015-2016 Socionext Inc. - * Author: Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_pro4_init(const struct uniphier_board_data *bd) -{ - uniphier_sbc_init_savepin(); - - support_card_init(); - - uniphier_pro4_dpll_init(bd); - - led_puts("L0"); - - uniphier_memconf_2ch_init(bd); - - led_puts("L1"); - - uniphier_sld3_early_clk_init(); - uniphier_sld3_dram_clk_init(); - - led_puts("L2"); - - led_puts("L3"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L4"); - - { - int res; - - res = uniphier_pro4_umc_init(bd); - if (res < 0) { - while (1) - ; - } - } - - led_puts("L5"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-pro5.c b/arch/arm/mach-uniphier/init/init-pro5.c deleted file mode 100644 index 4e7041b19b..0000000000 --- a/arch/arm/mach-uniphier/init/init-pro5.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_pro5_init(const struct uniphier_board_data *bd) -{ - uniphier_sbc_init_savepin(); - - support_card_init(); - - led_puts("L0"); - - uniphier_memconf_2ch_init(bd); - - led_puts("L1"); - - uniphier_sld3_early_clk_init(); - uniphier_pro5_dram_clk_init(); - - led_puts("L2"); - - led_puts("L3"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L4"); - - led_puts("L5"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-pxs2.c b/arch/arm/mach-uniphier/init/init-pxs2.c deleted file mode 100644 index f7d5b4870c..0000000000 --- a/arch/arm/mach-uniphier/init/init-pxs2.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_pxs2_init(const struct uniphier_board_data *bd) -{ - int ret; - - uniphier_pxs2_sbc_init(); - - support_card_init(); - - led_puts("L0"); - - uniphier_memconf_3ch_init(bd); - - led_puts("L1"); - - uniphier_sld3_early_clk_init(); - uniphier_pxs2_dram_clk_init(); - - led_puts("L2"); - - led_puts("L3"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L4"); - - ret = uniphier_pxs2_umc_init(bd); - if (ret) - return ret; - - led_puts("L5"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-sld3.c b/arch/arm/mach-uniphier/init/init-sld3.c deleted file mode 100644 index 50d9eafd11..0000000000 --- a/arch/arm/mach-uniphier/init/init-sld3.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2013-2015 Panasonic Corporation - * Copyright (C) 2015-2016 Socionext Inc. - * Author: Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_sld3_init(const struct uniphier_board_data *bd) -{ - uniphier_sld3_bcu_init(bd); - - uniphier_sbc_init_admulti(); - - support_card_init(); - - uniphier_sld3_dpll_init(bd); - - led_puts("L0"); - - uniphier_memconf_3ch_no_disbit_init(bd); - - led_puts("L1"); - - uniphier_sld3_early_clk_init(); - uniphier_sld3_dram_clk_init(); - - led_puts("L2"); - - led_puts("L3"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L4"); - - led_puts("L5"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init-sld8.c b/arch/arm/mach-uniphier/init/init-sld8.c deleted file mode 100644 index 8da2843578..0000000000 --- a/arch/arm/mach-uniphier/init/init-sld8.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2013-2015 Panasonic Corporation - * Copyright (C) 2015-2016 Socionext Inc. - * Author: Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include - -#include "../init.h" -#include "../micro-support-card.h" - -int uniphier_sld8_init(const struct uniphier_board_data *bd) -{ - uniphier_ld4_bcu_init(bd); - - uniphier_ld4_sbc_init(); - - support_card_init(); - - uniphier_sld8_dpll_init(bd); - - led_puts("L0"); - - uniphier_memconf_2ch_init(bd); - - led_puts("L1"); - - uniphier_sld3_early_clk_init(); - uniphier_sld3_dram_clk_init(); - - led_puts("L2"); - - led_puts("L3"); - -#ifdef CONFIG_SPL_SERIAL_SUPPORT - preloader_console_init(); -#endif - - led_puts("L4"); - - { - int res; - - res = uniphier_sld8_umc_init(bd); - if (res < 0) { - while (1) - ; - } - } - - led_puts("L5"); - - return 0; -} diff --git a/arch/arm/mach-uniphier/init/init.c b/arch/arm/mach-uniphier/init/init.c deleted file mode 100644 index 77e5b99047..0000000000 --- a/arch/arm/mach-uniphier/init/init.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2015 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -#include "../init.h" -#include "../soc-info.h" - -void spl_board_init(void) -{ - const struct uniphier_board_data *param; - -#ifdef CONFIG_DEBUG_UART - debug_uart_init(); -#endif - - param = uniphier_get_board_param(); - if (!param) - hang(); - - switch (uniphier_get_soc_type()) { -#if defined(CONFIG_ARCH_UNIPHIER_SLD3) - case SOC_UNIPHIER_SLD3: - uniphier_sld3_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD4) - case SOC_UNIPHIER_LD4: - uniphier_ld4_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PRO4) - case SOC_UNIPHIER_PRO4: - uniphier_pro4_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_SLD8) - case SOC_UNIPHIER_SLD8: - uniphier_sld8_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PRO5) - case SOC_UNIPHIER_PRO5: - uniphier_pro5_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B) - case SOC_UNIPHIER_PXS2: - case SOC_UNIPHIER_LD6B: - uniphier_pxs2_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD11) - case SOC_UNIPHIER_LD11: - uniphier_ld11_init(param); - break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD20) - case SOC_UNIPHIER_LD20: - uniphier_ld20_init(param); - break; -#endif - default: - break; - } -} diff --git a/arch/arm/mach-uniphier/spl_board_init.c b/arch/arm/mach-uniphier/spl_board_init.c new file mode 100644 index 0000000000..d1e1ea74bc --- /dev/null +++ b/arch/arm/mach-uniphier/spl_board_init.c @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2015-2016 Socionext Inc. + * Author: Masahiro Yamada + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +#include "init.h" +#include "micro-support-card.h" +#include "soc-info.h" + +struct uniphier_spl_initdata { + enum uniphier_soc_id soc_id; + void (*bcu_init)(const struct uniphier_board_data *bd); + void (*early_clk_init)(void); + void (*sbc_init)(void); + int (*dpll_init)(const struct uniphier_board_data *bd); + int (*memconf_init)(const struct uniphier_board_data *bd); + void (*dram_clk_init)(void); + int (*umc_init)(const struct uniphier_board_data *bd); +}; + +static const struct uniphier_spl_initdata uniphier_spl_initdata[] = { +#if defined(CONFIG_ARCH_UNIPHIER_SLD3) + { + .soc_id = SOC_UNIPHIER_SLD3, + .bcu_init = uniphier_sld3_bcu_init, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_sbc_init_admulti, + .dpll_init = uniphier_sld3_dpll_init, + .memconf_init = uniphier_memconf_3ch_no_disbit_init, + .dram_clk_init = uniphier_sld3_dram_clk_init, + .umc_init = uniphier_sld3_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD4) + { + .soc_id = SOC_UNIPHIER_LD4, + .bcu_init = uniphier_ld4_bcu_init, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_ld4_sbc_init, + .dpll_init = uniphier_ld4_dpll_init, + .memconf_init = uniphier_memconf_2ch_init, + .dram_clk_init = uniphier_sld3_dram_clk_init, + .umc_init = uniphier_ld4_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_PRO4) + { + .soc_id = SOC_UNIPHIER_PRO4, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_sbc_init_savepin, + .dpll_init = uniphier_pro4_dpll_init, + .memconf_init = uniphier_memconf_2ch_init, + .dram_clk_init = uniphier_sld3_dram_clk_init, + .umc_init = uniphier_pro4_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_SLD8) + { + .soc_id = SOC_UNIPHIER_SLD8, + .bcu_init = uniphier_ld4_bcu_init, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_ld4_sbc_init, + .dpll_init = uniphier_sld8_dpll_init, + .memconf_init = uniphier_memconf_2ch_init, + .dram_clk_init = uniphier_sld3_dram_clk_init, + .umc_init = uniphier_sld8_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_PRO5) + { + .soc_id = SOC_UNIPHIER_PRO5, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_sbc_init_savepin, + .dpll_init = uniphier_pro5_dpll_init, + .memconf_init = uniphier_memconf_2ch_init, + .dram_clk_init = uniphier_pro5_dram_clk_init, + .umc_init = uniphier_pro5_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_PXS2) + { + .soc_id = SOC_UNIPHIER_PXS2, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_pxs2_sbc_init, + .dpll_init = uniphier_pxs2_dpll_init, + .memconf_init = uniphier_memconf_3ch_init, + .dram_clk_init = uniphier_pxs2_dram_clk_init, + .umc_init = uniphier_pxs2_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD6B) + { + .soc_id = SOC_UNIPHIER_LD6B, + .early_clk_init = uniphier_sld3_early_clk_init, + .sbc_init = uniphier_pxs2_sbc_init, + .dpll_init = uniphier_pxs2_dpll_init, + .memconf_init = uniphier_memconf_3ch_init, + .dram_clk_init = uniphier_pxs2_dram_clk_init, + .umc_init = uniphier_pxs2_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD11) + { + .soc_id = SOC_UNIPHIER_LD11, + .early_clk_init = uniphier_ld11_early_clk_init, + .sbc_init = uniphier_ld11_sbc_init, + .dpll_init = uniphier_ld11_dpll_init, + .memconf_init = uniphier_memconf_2ch_init, + .dram_clk_init = uniphier_ld11_dram_clk_init, + .umc_init = uniphier_ld11_umc_init, + }, +#endif +#if defined(CONFIG_ARCH_UNIPHIER_LD20) + { + .soc_id = SOC_UNIPHIER_LD20, + .early_clk_init = uniphier_ld11_early_clk_init, + .sbc_init = uniphier_ld11_sbc_init, + .dpll_init = uniphier_ld20_dpll_init, + .memconf_init = uniphier_memconf_3ch_init, + .dram_clk_init = uniphier_ld20_dram_clk_init, + .umc_init = uniphier_ld20_umc_init, + }, +#endif +}; + +static const struct uniphier_spl_initdata *uniphier_get_spl_initdata( + enum uniphier_soc_id soc_id) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(uniphier_spl_initdata); i++) { + if (uniphier_spl_initdata[i].soc_id == soc_id) + return &uniphier_spl_initdata[i]; + } + + return NULL; +} + +void spl_board_init(void) +{ + const struct uniphier_board_data *bd; + const struct uniphier_spl_initdata *initdata; + enum uniphier_soc_id soc_id; + int ret; + +#ifdef CONFIG_DEBUG_UART + debug_uart_init(); +#endif + + bd = uniphier_get_board_param(); + if (!bd) + hang(); + + soc_id = uniphier_get_soc_type(); + initdata = uniphier_get_spl_initdata(soc_id); + if (!initdata) + hang(); + + if (initdata->bcu_init) + initdata->bcu_init(bd); + + initdata->sbc_init(); + + initdata->early_clk_init(); + + support_card_init(); + + led_puts("L0"); + +#ifdef CONFIG_SPL_SERIAL_SUPPORT + preloader_console_init(); +#endif + + led_puts("L1"); + + ret = initdata->dpll_init(bd); + if (ret) { + pr_err("failed to init DPLL\n"); + hang(); + } + + led_puts("L2"); + + ret = initdata->memconf_init(bd); + if (ret) { + pr_err("failed to init MEMCONF\n"); + hang(); + } + + led_puts("L3"); + + initdata->dram_clk_init(); + + led_puts("L4"); + + ret = initdata->umc_init(bd); + if (ret) { + pr_err("failed to init DRAM\n"); + hang(); + } + + led_puts("L5"); +}