Merge tag 'xilinx-for-v2021.04-rc3' of https://gitlab.denx.de/u-boot/custodians/u...
[platform/kernel/u-boot.git] / board / st / stm32f429-discovery / stm32f429-discovery.c
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 #include <env.h>
16 #include <init.h>
17 #include <log.h>
18 #include <asm/global_data.h>
19
20 #include <asm/io.h>
21 #include <asm/arch/stm32.h>
22
23 DECLARE_GLOBAL_DATA_PTR;
24
25 int dram_init(void)
26 {
27         int rv;
28         struct udevice *dev;
29
30         rv = uclass_get_device(UCLASS_RAM, 0, &dev);
31         if (rv) {
32                 debug("DRAM init failed: %d\n", rv);
33                 return rv;
34         }
35
36         if (fdtdec_setup_mem_size_base() != 0)
37                 rv = -EINVAL;
38
39         return rv;
40 }
41
42 int dram_init_banksize(void)
43 {
44         fdtdec_setup_memory_banksize();
45
46         return 0;
47 }
48
49 u32 get_board_rev(void)
50 {
51         return 0;
52 }
53
54 int board_early_init_f(void)
55 {
56         return 0;
57 }
58
59 int board_init(void)
60 {
61         gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
62
63         return 0;
64 }
65
66 #ifdef CONFIG_MISC_INIT_R
67 int misc_init_r(void)
68 {
69         char serialno[25];
70         uint32_t u_id_low, u_id_mid, u_id_high;
71
72         if (!env_get("serial#")) {
73                 u_id_low  = readl(&STM32_U_ID->u_id_low);
74                 u_id_mid  = readl(&STM32_U_ID->u_id_mid);
75                 u_id_high = readl(&STM32_U_ID->u_id_high);
76                 sprintf(serialno, "%08x%08x%08x",
77                         u_id_high, u_id_mid, u_id_low);
78                 env_set("serial#", serialno);
79         }
80
81         return 0;
82 }
83 #endif