blob: ee6a90c9fdd0932d3cb6d204407463599e3a7014 [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>
Simon Glassed38aef2020-05-10 11:40:03 -060015#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -060016#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060017#include <log.h>
Patrice Chotardf3a701a2017-12-12 09:49:39 +010018
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010019#include <asm/io.h>
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010020#include <asm/arch/stm32.h>
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010021
22DECLARE_GLOBAL_DATA_PTR;
23
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010024int dram_init(void)
25{
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010026 int rv;
Patrice Chotardb59d10f2017-12-12 09:49:34 +010027 struct udevice *dev;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010028
Patrice Chotardb59d10f2017-12-12 09:49:34 +010029 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
30 if (rv) {
31 debug("DRAM init failed: %d\n", rv);
32 return rv;
33 }
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010034
Siva Durga Prasad Paladugub3d55ea2018-07-16 15:56:11 +053035 if (fdtdec_setup_mem_size_base() != 0)
Patrice Chotardb59d10f2017-12-12 09:49:34 +010036 rv = -EINVAL;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010037
Patrice Chotardb59d10f2017-12-12 09:49:34 +010038 return rv;
39}
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010040
Patrice Chotardb59d10f2017-12-12 09:49:34 +010041int dram_init_banksize(void)
42{
43 fdtdec_setup_memory_banksize();
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010044
Patrice Chotardb59d10f2017-12-12 09:49:34 +010045 return 0;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010046}
47
48u32 get_board_rev(void)
49{
50 return 0;
51}
52
53int board_early_init_f(void)
54{
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010055 return 0;
56}
57
58int board_init(void)
59{
Patrice Chotarda66c1b42018-08-03 11:46:11 +020060 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
rev13@wp.pl6b5e5a92015-03-01 12:44:42 +010061
62 return 0;
63}
Antonio Borneo989e8b22015-07-19 22:19:46 +080064
65#ifdef CONFIG_MISC_INIT_R
66int misc_init_r(void)
67{
68 char serialno[25];
69 uint32_t u_id_low, u_id_mid, u_id_high;
70
Simon Glass64b723f2017-08-03 12:22:12 -060071 if (!env_get("serial#")) {
Antonio Borneo989e8b22015-07-19 22:19:46 +080072 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);
Simon Glass6a38e412017-08-03 12:22:09 -060077 env_set("serial#", serialno);
Antonio Borneo989e8b22015-07-19 22:19:46 +080078 }
79
80 return 0;
81}
82#endif