Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 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 |
Kamil Lulko | 75d48a6 | 2015-12-01 09:08:19 +0100 | [diff] [blame] | 10 | * Kamil Lulko, <kamil.lulko@gmail.com> |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Simon Glass | 11c89f3 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 14 | #include <dm.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 15 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 16 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 17 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 18 | #include <asm/global_data.h> |
Patrice Chotard | f3a701a | 2017-12-12 09:49:39 +0100 | [diff] [blame] | 19 | |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 20 | #include <asm/io.h> |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 21 | #include <asm/arch/stm32.h> |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 25 | int dram_init(void) |
| 26 | { |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 27 | int rv; |
Patrice Chotard | b59d10f | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 28 | struct udevice *dev; |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 29 | |
Patrice Chotard | b59d10f | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 30 | 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.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 35 | |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 36 | if (fdtdec_setup_mem_size_base() != 0) |
Patrice Chotard | b59d10f | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 37 | rv = -EINVAL; |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 38 | |
Patrice Chotard | b59d10f | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 39 | return rv; |
| 40 | } |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 41 | |
Patrice Chotard | b59d10f | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 42 | int dram_init_banksize(void) |
| 43 | { |
| 44 | fdtdec_setup_memory_banksize(); |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 45 | |
Patrice Chotard | b59d10f | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 46 | return 0; |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 47 | } |
| 48 | |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 49 | int board_init(void) |
| 50 | { |
rev13@wp.pl | 6b5e5a9 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 51 | return 0; |
| 52 | } |
Antonio Borneo | 989e8b2 | 2015-07-19 22:19:46 +0800 | [diff] [blame] | 53 | |
| 54 | #ifdef CONFIG_MISC_INIT_R |
| 55 | int misc_init_r(void) |
| 56 | { |
| 57 | char serialno[25]; |
| 58 | uint32_t u_id_low, u_id_mid, u_id_high; |
| 59 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 60 | if (!env_get("serial#")) { |
Antonio Borneo | 989e8b2 | 2015-07-19 22:19:46 +0800 | [diff] [blame] | 61 | u_id_low = readl(&STM32_U_ID->u_id_low); |
| 62 | u_id_mid = readl(&STM32_U_ID->u_id_mid); |
| 63 | u_id_high = readl(&STM32_U_ID->u_id_high); |
| 64 | sprintf(serialno, "%08x%08x%08x", |
| 65 | u_id_high, u_id_mid, u_id_low); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 66 | env_set("serial#", serialno); |
Antonio Borneo | 989e8b2 | 2015-07-19 22:19:46 +0800 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | #endif |