blob: b7638c0f6a91d6cb956dce2c6a2ee28211cc99ab [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
rev13@wp.pl6b5e5a92015-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 Lulko75d48a62015-12-01 09:08:19 +010010 * Kamil Lulko, <kamil.lulko@gmail.com>
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010011 */
12
13#include <common.h>
Simon Glass11c89f32017-05-17 17:18:03 -060014#include <dm.h>
Patrice Chotardf3a701a2017-12-12 09:49:39 +010015
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010016#include <asm/io.h>
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010017#include <asm/arch/stm32.h>
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010018
19DECLARE_GLOBAL_DATA_PTR;
20
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010021int dram_init(void)
22{
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010023 int rv;
Patrice Chotardb59d10f2017-12-12 09:49:34 +010024 struct udevice *dev;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010025
Patrice Chotardb59d10f2017-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.pl6b5e5a92015-03-01 12:44:42 +010031
Patrice Chotardb59d10f2017-12-12 09:49:34 +010032 if (fdtdec_setup_memory_size() != 0)
33 rv = -EINVAL;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010034
Patrice Chotardb59d10f2017-12-12 09:49:34 +010035 return rv;
36}
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010037
Patrice Chotardb59d10f2017-12-12 09:49:34 +010038int dram_init_banksize(void)
39{
40 fdtdec_setup_memory_banksize();
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010041
Patrice Chotardb59d10f2017-12-12 09:49:34 +010042 return 0;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010043}
44
45u32 get_board_rev(void)
46{
47 return 0;
48}
49
50int board_early_init_f(void)
51{
rev13@wp.pl6b5e5a92015-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 Borneo989e8b22015-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 Glass64b723f2017-08-03 12:22:12 -060068 if (!env_get("serial#")) {
Antonio Borneo989e8b22015-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 Glass6a38e412017-08-03 12:22:09 -060074 env_set("serial#", serialno);
Antonio Borneo989e8b22015-07-19 22:19:46 +080075 }
76
77 return 0;
78}
79#endif