blob: 9d8fc9f5a2e1540a02bc6aa058a1b8edaf28a9bd [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>
Simon Glass09140112020-05-10 11:40:03 -060015#include <env.h>
Simon Glass691d7192020-05-10 11:40:02 -060016#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060017#include <log.h>
Simon Glass401d1c42020-10-30 21:38:53 -060018#include <asm/global_data.h>
Patrice Chotard4a56fd42017-12-12 09:49:39 +010019
rev13@wp.pled09a552015-03-01 12:44:42 +010020#include <asm/io.h>
rev13@wp.pled09a552015-03-01 12:44:42 +010021#include <asm/arch/stm32.h>
rev13@wp.pled09a552015-03-01 12:44:42 +010022
23DECLARE_GLOBAL_DATA_PTR;
24
rev13@wp.pled09a552015-03-01 12:44:42 +010025int dram_init(void)
26{
rev13@wp.pled09a552015-03-01 12:44:42 +010027 int rv;
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010028 struct udevice *dev;
rev13@wp.pled09a552015-03-01 12:44:42 +010029
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010030 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
31 if (rv) {
32 debug("DRAM init failed: %d\n", rv);
33 return rv;
34 }
rev13@wp.pled09a552015-03-01 12:44:42 +010035
Siva Durga Prasad Paladugu12308b12018-07-16 15:56:11 +053036 if (fdtdec_setup_mem_size_base() != 0)
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010037 rv = -EINVAL;
rev13@wp.pled09a552015-03-01 12:44:42 +010038
39 return rv;
40}
41
Patrice Chotard7fd65ef2017-12-12 09:49:34 +010042int dram_init_banksize(void)
43{
44 fdtdec_setup_memory_banksize();
45
46 return 0;
47}
48
rev13@wp.pled09a552015-03-01 12:44:42 +010049u32 get_board_rev(void)
50{
51 return 0;
52}
53
54int board_early_init_f(void)
55{
rev13@wp.pled09a552015-03-01 12:44:42 +010056 return 0;
57}
58
59int board_init(void)
60{
Patrice Chotard725e09b2018-08-03 11:46:11 +020061 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
rev13@wp.pled09a552015-03-01 12:44:42 +010062
63 return 0;
64}
Antonio Borneo089fddf2015-07-19 22:19:46 +080065
66#ifdef CONFIG_MISC_INIT_R
67int misc_init_r(void)
68{
69 char serialno[25];
70 uint32_t u_id_low, u_id_mid, u_id_high;
71
Simon Glass00caae62017-08-03 12:22:12 -060072 if (!env_get("serial#")) {
Antonio Borneo089fddf2015-07-19 22:19:46 +080073 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);
Simon Glass382bee52017-08-03 12:22:09 -060078 env_set("serial#", serialno);
Antonio Borneo089fddf2015-07-19 22:19:46 +080079 }
80
81 return 0;
82}
83#endif