blob: e800d70f763b537c05c7e6f9fd20507f3751883a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
rev13@wp.pled09a552015-03-01 12:44:42 +01002/*
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
Kamil Lulko66562412015-12-01 09:08:19 +010010 * Kamil Lulko, <kamil.lulko@gmail.com>
rev13@wp.pled09a552015-03-01 12:44:42 +010011 */
12
13#include <common.h>
Simon Glass9d922452017-05-17 17:18:03 -060014#include <dm.h>
Patrice Chotard4a56fd42017-12-12 09:49:39 +010015
rev13@wp.pled09a552015-03-01 12:44:42 +010016#include <asm/io.h>
rev13@wp.pled09a552015-03-01 12:44:42 +010017#include <asm/arch/stm32.h>
rev13@wp.pled09a552015-03-01 12:44:42 +010018
19DECLARE_GLOBAL_DATA_PTR;
20
rev13@wp.pled09a552015-03-01 12:44:42 +010021int dram_init(void)
22{
rev13@wp.pled09a552015-03-01 12:44:42 +010023 int rv;
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010024 struct udevice *dev;
rev13@wp.pled09a552015-03-01 12:44:42 +010025
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010026 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
27 if (rv) {
28 debug("DRAM init failed: %d\n", rv);
29 return rv;
30 }
rev13@wp.pled09a552015-03-01 12:44:42 +010031
Siva Durga Prasad Paladugu12308b12018-07-16 15:56:11 +053032 if (fdtdec_setup_mem_size_base() != 0)
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010033 rv = -EINVAL;
rev13@wp.pled09a552015-03-01 12:44:42 +010034
35 return rv;
36}
37
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010038int dram_init_banksize(void)
39{
40 fdtdec_setup_memory_banksize();
41
42 return 0;
43}
44
rev13@wp.pled09a552015-03-01 12:44:42 +010045u32 get_board_rev(void)
46{
47 return 0;
48}
49
50int board_early_init_f(void)
51{
rev13@wp.pled09a552015-03-01 12:44:42 +010052 return 0;
53}
54
55int board_init(void)
56{
57 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
58
59 return 0;
60}
Antonio Borneo089fddf2015-07-19 22:19:46 +080061
62#ifdef CONFIG_MISC_INIT_R
63int misc_init_r(void)
64{
65 char serialno[25];
66 uint32_t u_id_low, u_id_mid, u_id_high;
67
Simon Glass00caae62017-08-03 12:22:12 -060068 if (!env_get("serial#")) {
Antonio Borneo089fddf2015-07-19 22:19:46 +080069 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);
Simon Glass382bee52017-08-03 12:22:09 -060074 env_set("serial#", serialno);
Antonio Borneo089fddf2015-07-19 22:19:46 +080075 }
76
77 return 0;
78}
79#endif