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