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