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 |
Patrice Chotard | 5d9950d | 2020-12-02 18:47:30 +0100 | [diff] [blame] | 4 | * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics. |
Patrice Chotard | ac871ab | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Patrice Chotard | ac871ab | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 7 | #include <dm.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Patrice Chotard | ac871ab | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 12 | |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/arch/stm32.h> |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | int dram_init(void) |
| 19 | { |
| 20 | int rv; |
| 21 | struct udevice *dev; |
| 22 | |
| 23 | rv = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 24 | if (rv) { |
| 25 | debug("DRAM init failed: %d\n", rv); |
| 26 | return rv; |
| 27 | } |
| 28 | |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 29 | if (fdtdec_setup_mem_size_base() != 0) |
Patrice Chotard | ac871ab | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 30 | rv = -EINVAL; |
| 31 | |
| 32 | return rv; |
| 33 | } |
| 34 | |
| 35 | int dram_init_banksize(void) |
| 36 | { |
| 37 | fdtdec_setup_memory_banksize(); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
Patrice Chotard | ac871ab | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 42 | int board_init(void) |
| 43 | { |
Patrice Chotard | ac871ab | 2018-01-18 13:39:32 +0100 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | #ifdef CONFIG_MISC_INIT_R |
| 48 | int misc_init_r(void) |
| 49 | { |
| 50 | char serialno[25]; |
| 51 | u32 u_id_low, u_id_mid, u_id_high; |
| 52 | |
| 53 | if (!env_get("serial#")) { |
| 54 | u_id_low = readl(&STM32_U_ID->u_id_low); |
| 55 | u_id_mid = readl(&STM32_U_ID->u_id_mid); |
| 56 | u_id_high = readl(&STM32_U_ID->u_id_high); |
| 57 | sprintf(serialno, "%08x%08x%08x", |
| 58 | u_id_high, u_id_mid, u_id_low); |
| 59 | env_set("serial#", serialno); |
| 60 | } |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | #endif |