2 * (C) Copyright 2013 SAMSUNG Electronics
3 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
16 #include <asm/arch/board.h>
17 #include <asm/arch/cpu.h>
18 #include <asm/arch/dwmmc.h>
19 #include <asm/arch/gpio.h>
20 #include <asm/arch/mmc.h>
21 #include <asm/arch/pinmux.h>
22 #include <asm/arch/power.h>
23 #include <power/pmic.h>
24 #include <asm/arch/sromc.h>
26 #include <samsung/misc.h>
28 DECLARE_GLOBAL_DATA_PTR
;
31 struct cros_ec_dev
*cros_ec_dev
; /* Pointer to cros_ec device */
32 int cros_ec_err
; /* Error for cros_ec, 0 if ok */
35 static struct local_info local
;
37 int __exynos_early_init_f(void)
41 int exynos_early_init_f(void)
42 __attribute__((weak
, alias("__exynos_early_init_f")));
44 int __exynos_power_init(void)
48 int exynos_power_init(void)
49 __attribute__((weak
, alias("__exynos_power_init")));
51 #if defined CONFIG_EXYNOS_TMU
52 /* Boot Time Thermal Analysis for SoC temperature threshold breach */
53 static void boot_temp_check(void)
57 switch (tmu_monitor(&temp
)) {
58 case TMU_STATUS_NORMAL
:
60 case TMU_STATUS_TRIPPED
:
62 * Status TRIPPED ans WARNING means corresponding threshold
65 puts("EXYNOS_TMU: TRIPPING! Device power going down ...\n");
69 case TMU_STATUS_WARNING
:
70 puts("EXYNOS_TMU: WARNING! Temperature very high\n");
74 * TMU_STATUS_INIT means something is wrong with temperature
75 * sensing and TMU status was changed back from NORMAL to INIT.
77 puts("EXYNOS_TMU: WARNING! Temperature sensing not done\n");
80 debug("EXYNOS_TMU: Unknown TMU state\n");
87 gd
->bd
->bi_boot_params
= (PHYS_SDRAM_1
+ 0x100UL
);
88 #if defined CONFIG_EXYNOS_TMU
89 if (tmu_init(gd
->fdt_blob
) != TMU_STATUS_NORMAL
) {
90 debug("%s: Failed to init TMU\n", __func__
);
96 #ifdef CONFIG_EXYNOS_SPI
107 for (i
= 0; i
< CONFIG_NR_DRAM_BANKS
; i
++) {
108 addr
= CONFIG_SYS_SDRAM_BASE
+ (i
* SDRAM_BANK_SIZE
);
109 gd
->ram_size
+= get_ram_size((long *)addr
, SDRAM_BANK_SIZE
);
114 void dram_init_banksize(void)
119 for (i
= 0; i
< CONFIG_NR_DRAM_BANKS
; i
++) {
120 addr
= CONFIG_SYS_SDRAM_BASE
+ (i
* SDRAM_BANK_SIZE
);
121 size
= get_ram_size((long *)addr
, SDRAM_BANK_SIZE
);
123 gd
->bd
->bi_dram
[i
].start
= addr
;
124 gd
->bd
->bi_dram
[i
].size
= size
;
128 static int board_uart_init(void)
130 int err
, uart_id
, ret
= 0;
132 for (uart_id
= PERIPH_ID_UART0
; uart_id
<= PERIPH_ID_UART3
; uart_id
++) {
133 err
= exynos_pinmux_config(uart_id
, PINMUX_FLAG_NONE
);
135 debug("UART%d not configured\n",
136 (uart_id
- PERIPH_ID_UART0
));
143 #ifdef CONFIG_BOARD_EARLY_INIT_F
144 int board_early_init_f(void)
148 err
= board_uart_init();
150 debug("UART init failed\n");
154 #ifdef CONFIG_SYS_I2C_INIT_BOARD
155 board_i2c_init(gd
->fdt_blob
);
158 return exynos_early_init_f();
162 struct cros_ec_dev
*board_get_cros_ec_dev(void)
164 return local
.cros_ec_dev
;
167 #ifdef CONFIG_CROS_EC
168 static int board_init_cros_ec_devices(const void *blob
)
170 local
.cros_ec_err
= cros_ec_init(blob
, &local
.cros_ec_dev
);
171 if (local
.cros_ec_err
)
172 return -1; /* Will report in board_late_init() */
178 #if defined(CONFIG_POWER)
179 int power_init_board(void)
183 return exynos_power_init();
187 #ifdef CONFIG_OF_CONTROL
188 #ifdef CONFIG_SMC911X
189 static int decode_sromc(const void *blob
, struct fdt_sromc
*config
)
194 node
= fdtdec_next_compatible(blob
, 0, COMPAT_SAMSUNG_EXYNOS5_SROMC
);
196 debug("Could not find SROMC node\n");
200 config
->bank
= fdtdec_get_int(blob
, node
, "bank", 0);
201 config
->width
= fdtdec_get_int(blob
, node
, "width", 2);
203 err
= fdtdec_get_int_array(blob
, node
, "srom-timing", config
->timing
,
204 FDT_SROM_TIMING_COUNT
);
206 debug("Could not decode SROMC configuration Error: %s\n",
208 return -FDT_ERR_NOTFOUND
;
214 int board_eth_init(bd_t
*bis
)
216 #ifdef CONFIG_SMC911X
217 u32 smc_bw_conf
, smc_bc_conf
;
218 struct fdt_sromc config
;
219 fdt_addr_t base_addr
;
222 node
= decode_sromc(gd
->fdt_blob
, &config
);
224 debug("%s: Could not find sromc configuration\n", __func__
);
227 node
= fdtdec_next_compatible(gd
->fdt_blob
, node
, COMPAT_SMSC_LAN9215
);
229 debug("%s: Could not find lan9215 configuration\n", __func__
);
233 /* We now have a node, so any problems from now on are errors */
234 base_addr
= fdtdec_get_addr(gd
->fdt_blob
, node
, "reg");
235 if (base_addr
== FDT_ADDR_T_NONE
) {
236 debug("%s: Could not find lan9215 address\n", __func__
);
240 /* Ethernet needs data bus width of 16 bits */
241 if (config
.width
!= 2) {
242 debug("%s: Unsupported bus width %d\n", __func__
,
246 smc_bw_conf
= SROMC_DATA16_WIDTH(config
.bank
)
247 | SROMC_BYTE_ENABLE(config
.bank
);
249 smc_bc_conf
= SROMC_BC_TACS(config
.timing
[FDT_SROM_TACS
]) |
250 SROMC_BC_TCOS(config
.timing
[FDT_SROM_TCOS
]) |
251 SROMC_BC_TACC(config
.timing
[FDT_SROM_TACC
]) |
252 SROMC_BC_TCOH(config
.timing
[FDT_SROM_TCOH
]) |
253 SROMC_BC_TAH(config
.timing
[FDT_SROM_TAH
]) |
254 SROMC_BC_TACP(config
.timing
[FDT_SROM_TACP
]) |
255 SROMC_BC_PMC(config
.timing
[FDT_SROM_PMC
]);
257 /* Select and configure the SROMC bank */
258 exynos_pinmux_config(PERIPH_ID_SROMC
, config
.bank
);
259 s5p_config_sromc(config
.bank
, smc_bw_conf
, smc_bc_conf
);
260 return smc911x_initialize(0, base_addr
);
265 #ifdef CONFIG_GENERIC_MMC
266 int board_mmc_init(bd_t
*bis
)
271 /* mmc initializattion for available channels */
272 ret
= exynos_mmc_init(gd
->fdt_blob
);
274 debug("mmc init failed\n");
277 /* dwmmc initializattion for available channels */
278 ret
= exynos_dwmmc_init(gd
->fdt_blob
);
280 debug("dwmmc init failed\n");
287 #ifdef CONFIG_DISPLAY_BOARDINFO
290 const char *board_name
;
292 board_name
= fdt_getprop(gd
->fdt_blob
, 0, "model", NULL
);
293 printf("Board: %s\n", board_name
? board_name
: "unknown");
298 #endif /* CONFIG_OF_CONTROL */
300 #ifdef CONFIG_BOARD_LATE_INIT
301 int board_late_init(void)
303 stdio_print_current_devices();
305 if (local
.cros_ec_err
) {
306 /* Force console on */
307 gd
->flags
&= ~GD_FLG_SILENT
;
309 printf("cros-ec communications failure %d\n",
311 puts("\nPlease reset with Power+Refresh\n\n");
312 panic("Cannot init cros-ec device");
319 int arch_early_init_r(void)
321 #ifdef CONFIG_CROS_EC
322 if (board_init_cros_ec_devices(gd
->fdt_blob
)) {
323 printf("%s: Failed to init EC\n", __func__
);
331 #ifdef CONFIG_MISC_INIT_R
332 int misc_init_r(void)
334 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
337 #ifdef CONFIG_LCD_MENU
341 #ifdef CONFIG_CMD_BMP
342 if (panel_info
.logo_on
)