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