Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
rev13@wp.pl | ed09a55 | 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 | 6656241 | 2015-12-01 09:08:19 +0100 | [diff] [blame] | 10 | * Kamil Lulko, <kamil.lulko@gmail.com> |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Simon Glass | 9d92245 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 14 | #include <dm.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame^] | 15 | #include <init.h> |
Patrice Chotard | 4a56fd4 | 2017-12-12 09:49:39 +0100 | [diff] [blame] | 16 | |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 17 | #include <asm/io.h> |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 18 | #include <asm/arch/stm32.h> |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 22 | int dram_init(void) |
| 23 | { |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 24 | int rv; |
Patrice Chotard | 7fd65ef | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 25 | struct udevice *dev; |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 26 | |
Patrice Chotard | 7fd65ef | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 27 | rv = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 28 | if (rv) { |
| 29 | debug("DRAM init failed: %d\n", rv); |
| 30 | return rv; |
| 31 | } |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 32 | |
Siva Durga Prasad Paladugu | 12308b1 | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 33 | if (fdtdec_setup_mem_size_base() != 0) |
Patrice Chotard | 7fd65ef | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 34 | rv = -EINVAL; |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 35 | |
| 36 | return rv; |
| 37 | } |
| 38 | |
Patrice Chotard | 7fd65ef | 2017-12-12 09:49:34 +0100 | [diff] [blame] | 39 | int dram_init_banksize(void) |
| 40 | { |
| 41 | fdtdec_setup_memory_banksize(); |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 46 | u32 get_board_rev(void) |
| 47 | { |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | int board_early_init_f(void) |
| 52 | { |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | int board_init(void) |
| 57 | { |
Patrice Chotard | 725e09b | 2018-08-03 11:46:11 +0200 | [diff] [blame] | 58 | gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; |
rev13@wp.pl | ed09a55 | 2015-03-01 12:44:42 +0100 | [diff] [blame] | 59 | |
| 60 | return 0; |
| 61 | } |
Antonio Borneo | 089fddf | 2015-07-19 22:19:46 +0800 | [diff] [blame] | 62 | |
| 63 | #ifdef CONFIG_MISC_INIT_R |
| 64 | int misc_init_r(void) |
| 65 | { |
| 66 | char serialno[25]; |
| 67 | uint32_t u_id_low, u_id_mid, u_id_high; |
| 68 | |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 69 | if (!env_get("serial#")) { |
Antonio Borneo | 089fddf | 2015-07-19 22:19:46 +0800 | [diff] [blame] | 70 | u_id_low = readl(&STM32_U_ID->u_id_low); |
| 71 | u_id_mid = readl(&STM32_U_ID->u_id_mid); |
| 72 | u_id_high = readl(&STM32_U_ID->u_id_high); |
| 73 | sprintf(serialno, "%08x%08x%08x", |
| 74 | u_id_high, u_id_mid, u_id_low); |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 75 | env_set("serial#", serialno); |
Antonio Borneo | 089fddf | 2015-07-19 22:19:46 +0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | #endif |