2 * (C) Copyright 2013 SAMSUNG Electronics
3 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/arch/board.h>
18 #include <asm/arch/cpu.h>
19 #include <asm/arch/dwmmc.h>
20 #include <asm/arch/mmc.h>
21 #include <asm/arch/pinmux.h>
22 #include <asm/arch/power.h>
23 #include <asm/arch/system.h>
24 #include <asm/arch/sromc.h>
27 #include <samsung/misc.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 __weak int exynos_early_init_f(void)
37 __weak int exynos_power_init(void)
42 #if defined CONFIG_EXYNOS_TMU
43 /* Boot Time Thermal Analysis for SoC temperature threshold breach */
44 static void boot_temp_check(void)
48 switch (tmu_monitor(&temp)) {
49 case TMU_STATUS_NORMAL:
51 case TMU_STATUS_TRIPPED:
53 * Status TRIPPED ans WARNING means corresponding threshold
56 puts("EXYNOS_TMU: TRIPPING! Device power going down ...\n");
60 case TMU_STATUS_WARNING:
61 puts("EXYNOS_TMU: WARNING! Temperature very high\n");
65 * TMU_STATUS_INIT means something is wrong with temperature
66 * sensing and TMU status was changed back from NORMAL to INIT.
68 puts("EXYNOS_TMU: WARNING! Temperature sensing not done\n");
71 debug("EXYNOS_TMU: Unknown TMU state\n");
78 gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
79 #if defined CONFIG_EXYNOS_TMU
80 if (tmu_init(gd->fdt_blob) != TMU_STATUS_NORMAL) {
81 debug("%s: Failed to init TMU\n", __func__);
86 #ifdef CONFIG_TZSW_RESERVED_DRAM_SIZE
87 /* The last few MB of memory can be reserved for secure firmware */
88 ulong size = CONFIG_TZSW_RESERVED_DRAM_SIZE;
91 gd->bd->bi_dram[CONFIG_NR_DRAM_BANKS - 1].size -= size;
101 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
102 addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
103 gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
108 void dram_init_banksize(void)
113 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
114 addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
115 size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
117 gd->bd->bi_dram[i].start = addr;
118 gd->bd->bi_dram[i].size = size;
122 static int board_uart_init(void)
124 int err, uart_id, ret = 0;
126 for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) {
127 err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE);
129 debug("UART%d not configured\n",
130 (uart_id - PERIPH_ID_UART0));
137 #ifdef CONFIG_BOARD_EARLY_INIT_F
138 int board_early_init_f(void)
141 #ifdef CONFIG_BOARD_TYPES
144 err = board_uart_init();
146 debug("UART init failed\n");
150 #ifdef CONFIG_SYS_I2C_INIT_BOARD
151 board_i2c_init(gd->fdt_blob);
154 #if defined(CONFIG_OF_CONTROL) && defined(CONFIG_EXYNOS_FB)
156 * board_init_f(arch/arm/lib/board.c) calls lcd_setmem() which needs
157 * panel_info.vl_col, panel_info.vl_row and panel_info.vl_bpix, to reserve
158 * FB memory at a very early stage. So, we need to fill panel_info.vl_col,
159 * panel_info.vl_row and panel_info.vl_bpix before lcd_setmem() is called.
161 err = exynos_lcd_early_init(gd->fdt_blob);
163 debug("LCD early init failed\n");
168 return exynos_early_init_f();
172 #if defined(CONFIG_POWER) || defined(CONFIG_DM_PMIC)
173 int power_init_board(void)
177 return exynos_power_init();
181 #ifdef CONFIG_OF_CONTROL
182 #ifdef CONFIG_SMC911X
183 static int decode_sromc(const void *blob, struct fdt_sromc *config)
188 node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SROMC);
190 debug("Could not find SROMC node\n");
194 config->bank = fdtdec_get_int(blob, node, "bank", 0);
195 config->width = fdtdec_get_int(blob, node, "width", 2);
197 err = fdtdec_get_int_array(blob, node, "srom-timing", config->timing,
198 FDT_SROM_TIMING_COUNT);
200 debug("Could not decode SROMC configuration Error: %s\n",
202 return -FDT_ERR_NOTFOUND;
208 int board_eth_init(bd_t *bis)
210 #ifdef CONFIG_SMC911X
211 u32 smc_bw_conf, smc_bc_conf;
212 struct fdt_sromc config;
213 fdt_addr_t base_addr;
216 node = decode_sromc(gd->fdt_blob, &config);
218 debug("%s: Could not find sromc configuration\n", __func__);
221 node = fdtdec_next_compatible(gd->fdt_blob, node, COMPAT_SMSC_LAN9215);
223 debug("%s: Could not find lan9215 configuration\n", __func__);
227 /* We now have a node, so any problems from now on are errors */
228 base_addr = fdtdec_get_addr(gd->fdt_blob, node, "reg");
229 if (base_addr == FDT_ADDR_T_NONE) {
230 debug("%s: Could not find lan9215 address\n", __func__);
234 /* Ethernet needs data bus width of 16 bits */
235 if (config.width != 2) {
236 debug("%s: Unsupported bus width %d\n", __func__,
240 smc_bw_conf = SROMC_DATA16_WIDTH(config.bank)
241 | SROMC_BYTE_ENABLE(config.bank);
243 smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) |
244 SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |
245 SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |
246 SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |
247 SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) |
248 SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |
249 SROMC_BC_PMC(config.timing[FDT_SROM_PMC]);
251 /* Select and configure the SROMC bank */
252 exynos_pinmux_config(PERIPH_ID_SROMC, config.bank);
253 s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf);
254 return smc911x_initialize(0, base_addr);
259 #ifdef CONFIG_GENERIC_MMC
260 static int init_mmc(void)
263 return exynos_mmc_init(gd->fdt_blob);
269 static int init_dwmmc(void)
272 return exynos_dwmmc_init(gd->fdt_blob);
278 int board_mmc_init(bd_t *bis)
282 if (get_boot_mode() == BOOT_MODE_SD) {
291 debug("mmc init failed\n");
297 #ifdef CONFIG_DISPLAY_BOARDINFO
300 const char *board_info;
302 board_info = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
303 printf("Board: %s\n", board_info ? board_info : "unknown");
304 #ifdef CONFIG_BOARD_TYPES
305 board_info = get_board_type();
307 printf("Model: %s\n", board_info ? board_info : "unknown");
312 #endif /* CONFIG_OF_CONTROL */
314 #ifdef CONFIG_BOARD_LATE_INIT
315 int board_late_init(void)
317 stdio_print_current_devices();
319 if (cros_ec_get_error()) {
320 /* Force console on */
321 gd->flags &= ~GD_FLG_SILENT;
323 printf("cros-ec communications failure %d\n",
324 cros_ec_get_error());
325 puts("\nPlease reset with Power+Refresh\n\n");
326 panic("Cannot init cros-ec device");
333 #ifdef CONFIG_MISC_INIT_R
334 int misc_init_r(void)
336 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
339 #ifdef CONFIG_LCD_MENU
343 #ifdef CONFIG_CMD_BMP
344 if (panel_info.logo_on)
351 void reset_misc(void)
353 struct gpio_desc gpio = {};
356 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0,
357 "samsung,emmc-reset");
361 gpio_request_by_name_nodev(gd->fdt_blob, node, "reset-gpio", 0, &gpio,
364 if (dm_gpio_is_valid(&gpio)) {
368 * FIXME: Need to optimize delay time. Minimum 1usec pulse is
369 * required by 'JEDEC Standard No.84-A441' (eMMC)
370 * document but real delay time is expected to greater
373 dm_gpio_set_value(&gpio, 0);
375 dm_gpio_set_value(&gpio, 1);
379 int board_usb_cleanup(int index, enum usb_init_type init)