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