Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015-2016 Socionext Inc. |
| 4 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 5 | */ |
| 6 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 7 | #include <debug_uart.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 8 | #include <hang.h> |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 9 | #include <spl.h> |
Simon Glass | bdd5f81 | 2023-09-14 18:21:46 -0600 | [diff] [blame] | 10 | #include <linux/printk.h> |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 11 | |
| 12 | #include "init.h" |
| 13 | #include "micro-support-card.h" |
| 14 | #include "soc-info.h" |
| 15 | |
| 16 | struct uniphier_spl_initdata { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 17 | unsigned int soc_id; |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 18 | void (*bcu_init)(const struct uniphier_board_data *bd); |
| 19 | void (*early_clk_init)(void); |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 20 | int (*dpll_init)(const struct uniphier_board_data *bd); |
| 21 | int (*memconf_init)(const struct uniphier_board_data *bd); |
| 22 | void (*dram_clk_init)(void); |
| 23 | int (*umc_init)(const struct uniphier_board_data *bd); |
| 24 | }; |
| 25 | |
| 26 | static const struct uniphier_spl_initdata uniphier_spl_initdata[] = { |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 27 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
| 28 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 29 | .soc_id = UNIPHIER_LD4_ID, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 30 | .bcu_init = uniphier_ld4_bcu_init, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 31 | .early_clk_init = uniphier_ld4_early_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 32 | .dpll_init = uniphier_ld4_dpll_init, |
| 33 | .memconf_init = uniphier_memconf_2ch_init, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 34 | .dram_clk_init = uniphier_ld4_dram_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 35 | .umc_init = uniphier_ld4_umc_init, |
| 36 | }, |
| 37 | #endif |
| 38 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
| 39 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 40 | .soc_id = UNIPHIER_PRO4_ID, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 41 | .early_clk_init = uniphier_ld4_early_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 42 | .dpll_init = uniphier_pro4_dpll_init, |
| 43 | .memconf_init = uniphier_memconf_2ch_init, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 44 | .dram_clk_init = uniphier_ld4_dram_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 45 | .umc_init = uniphier_pro4_umc_init, |
| 46 | }, |
| 47 | #endif |
| 48 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
| 49 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 50 | .soc_id = UNIPHIER_SLD8_ID, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 51 | .bcu_init = uniphier_ld4_bcu_init, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 52 | .early_clk_init = uniphier_ld4_early_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 53 | .dpll_init = uniphier_sld8_dpll_init, |
| 54 | .memconf_init = uniphier_memconf_2ch_init, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 55 | .dram_clk_init = uniphier_ld4_dram_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 56 | .umc_init = uniphier_sld8_umc_init, |
| 57 | }, |
| 58 | #endif |
| 59 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
| 60 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 61 | .soc_id = UNIPHIER_PRO5_ID, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 62 | .early_clk_init = uniphier_ld4_early_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 63 | .dpll_init = uniphier_pro5_dpll_init, |
| 64 | .memconf_init = uniphier_memconf_2ch_init, |
| 65 | .dram_clk_init = uniphier_pro5_dram_clk_init, |
| 66 | .umc_init = uniphier_pro5_umc_init, |
| 67 | }, |
| 68 | #endif |
| 69 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
| 70 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 71 | .soc_id = UNIPHIER_PXS2_ID, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 72 | .early_clk_init = uniphier_ld4_early_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 73 | .dpll_init = uniphier_pxs2_dpll_init, |
| 74 | .memconf_init = uniphier_memconf_3ch_init, |
| 75 | .dram_clk_init = uniphier_pxs2_dram_clk_init, |
| 76 | .umc_init = uniphier_pxs2_umc_init, |
| 77 | }, |
| 78 | #endif |
| 79 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
| 80 | { |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 81 | .soc_id = UNIPHIER_LD6B_ID, |
Masahiro Yamada | d3c1461 | 2017-08-13 09:01:13 +0900 | [diff] [blame] | 82 | .early_clk_init = uniphier_ld4_early_clk_init, |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 83 | .dpll_init = uniphier_pxs2_dpll_init, |
| 84 | .memconf_init = uniphier_memconf_3ch_init, |
| 85 | .dram_clk_init = uniphier_pxs2_dram_clk_init, |
| 86 | .umc_init = uniphier_pxs2_umc_init, |
| 87 | }, |
| 88 | #endif |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 89 | }; |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 90 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_spl_initdata, uniphier_spl_initdata) |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 91 | |
| 92 | void spl_board_init(void) |
| 93 | { |
| 94 | const struct uniphier_board_data *bd; |
| 95 | const struct uniphier_spl_initdata *initdata; |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 96 | int ret; |
| 97 | |
| 98 | #ifdef CONFIG_DEBUG_UART |
| 99 | debug_uart_init(); |
| 100 | #endif |
| 101 | |
| 102 | bd = uniphier_get_board_param(); |
| 103 | if (!bd) |
| 104 | hang(); |
| 105 | |
Masahiro Yamada | 1b81898 | 2017-01-21 18:05:27 +0900 | [diff] [blame] | 106 | initdata = uniphier_get_spl_initdata(); |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 107 | if (!initdata) |
| 108 | hang(); |
| 109 | |
| 110 | if (initdata->bcu_init) |
| 111 | initdata->bcu_init(bd); |
| 112 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 113 | initdata->early_clk_init(); |
| 114 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 115 | preloader_console_init(); |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 116 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 117 | ret = initdata->dpll_init(bd); |
| 118 | if (ret) { |
| 119 | pr_err("failed to init DPLL\n"); |
| 120 | hang(); |
| 121 | } |
| 122 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 123 | ret = initdata->memconf_init(bd); |
| 124 | if (ret) { |
| 125 | pr_err("failed to init MEMCONF\n"); |
| 126 | hang(); |
| 127 | } |
| 128 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 129 | initdata->dram_clk_init(); |
| 130 | |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 131 | ret = initdata->umc_init(bd); |
| 132 | if (ret) { |
| 133 | pr_err("failed to init DRAM\n"); |
| 134 | hang(); |
| 135 | } |
Masahiro Yamada | 8c3aa6b | 2017-01-15 14:59:09 +0900 | [diff] [blame] | 136 | } |