Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Patrice Chotard | e23b19f | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
| 4 | * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics. |
Patrice Chotard | e23b19f | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
| 9 | |
| 10 | #include <asm/io.h> |
| 11 | #include <asm/arch/stm32.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | int dram_init(void) |
| 16 | { |
| 17 | int rv; |
| 18 | struct udevice *dev; |
| 19 | |
| 20 | rv = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 21 | if (rv) { |
| 22 | debug("DRAM init failed: %d\n", rv); |
| 23 | return rv; |
| 24 | } |
| 25 | |
Siva Durga Prasad Paladugu | 12308b1 | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 26 | if (fdtdec_setup_mem_size_base() != 0) |
Patrice Chotard | e23b19f | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 27 | rv = -EINVAL; |
| 28 | |
| 29 | return rv; |
| 30 | } |
| 31 | |
| 32 | int dram_init_banksize(void) |
| 33 | { |
| 34 | fdtdec_setup_memory_banksize(); |
| 35 | |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | u32 get_board_rev(void) |
| 40 | { |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | int board_early_init_f(void) |
| 45 | { |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | int board_init(void) |
| 50 | { |
Patrice Chotard | 725e09b | 2018-08-03 11:46:11 +0200 | [diff] [blame] | 51 | gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; |
Patrice Chotard | e23b19f | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | #ifdef CONFIG_MISC_INIT_R |
| 57 | int misc_init_r(void) |
| 58 | { |
| 59 | char serialno[25]; |
| 60 | u32 u_id_low, u_id_mid, u_id_high; |
| 61 | |
| 62 | if (!env_get("serial#")) { |
| 63 | u_id_low = readl(&STM32_U_ID->u_id_low); |
| 64 | u_id_mid = readl(&STM32_U_ID->u_id_mid); |
| 65 | u_id_high = readl(&STM32_U_ID->u_id_high); |
| 66 | sprintf(serialno, "%08x%08x%08x", |
| 67 | u_id_high, u_id_mid, u_id_low); |
| 68 | env_set("serial#", serialno); |
| 69 | } |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | #endif |