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