1 /*
2  * (C) Copyright 2011, 2012, 2013
3  * Yuri Tikhonov, Emcraft Systems, yur@emcraft.com
4  * Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
5  * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
6  * Pavel Boldin, Emcraft Systems, paboldin@emcraft.com
7  *
8  * (C) Copyright 2015
9  * Kamil Lulko, <kamil.lulko@gmail.com>
10  *
11  * SPDX-License-Identifier:	GPL-2.0+
12  */
13 
14 #include <common.h>
15 #include <dm.h>
16 
17 #include <asm/io.h>
18 #include <asm/arch/stm32.h>
19 
20 DECLARE_GLOBAL_DATA_PTR;
21 
22 int dram_init(void)
23 {
24 	int rv;
25 	struct udevice *dev;
26 
27 	rv = uclass_get_device(UCLASS_RAM, 0, &dev);
28 	if (rv) {
29 		debug("DRAM init failed: %d\n", rv);
30 		return rv;
31 	}
32 
33 	if (fdtdec_setup_memory_size() != 0)
34 		rv = -EINVAL;
35 
36 	return rv;
37 }
38 
39 int dram_init_banksize(void)
40 {
41 	fdtdec_setup_memory_banksize();
42 
43 	return 0;
44 }
45 
46 u32 get_board_rev(void)
47 {
48 	return 0;
49 }
50 
51 int board_early_init_f(void)
52 {
53 	return 0;
54 }
55 
56 int board_init(void)
57 {
58 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
59 
60 	return 0;
61 }
62 
63 #ifdef CONFIG_MISC_INIT_R
64 int misc_init_r(void)
65 {
66 	char serialno[25];
67 	uint32_t u_id_low, u_id_mid, u_id_high;
68 
69 	if (!env_get("serial#")) {
70 		u_id_low  = readl(&STM32_U_ID->u_id_low);
71 		u_id_mid  = readl(&STM32_U_ID->u_id_mid);
72 		u_id_high = readl(&STM32_U_ID->u_id_high);
73 		sprintf(serialno, "%08x%08x%08x",
74 			u_id_high, u_id_mid, u_id_low);
75 		env_set("serial#", serialno);
76 	}
77 
78 	return 0;
79 }
80 #endif
81