summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSamin Guo <samin.guo@starfivetech.com>2023-06-16 04:55:38 +0300
committerSamin Guo <samin.guo@starfivetech.com>2023-07-10 06:38:05 +0300
commit7eb47f1ce4fb5ee18155fa3fa4679aed4d01a16d (patch)
tree2b2dd8e5710c8885f84dd3e38401b6d306c182a4 /arch
parentb354251c68d6ee4404ec08159a3d7a7bc948f78e (diff)
downloadu-boot-7eb47f1ce4fb5ee18155fa3fa4679aed4d01a16d.tar.xz
dram: jh7110: Add CONFIG_ID_EEPROM to determine if EEPROM is available
When eeprom reads, you need to determine whether eeprom supports it. Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/cpu/jh7110/dram.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/arch/riscv/cpu/jh7110/dram.c b/arch/riscv/cpu/jh7110/dram.c
index ddcb3da64e..b5d1934f35 100644
--- a/arch/riscv/cpu/jh7110/dram.c
+++ b/arch/riscv/cpu/jh7110/dram.c
@@ -2,16 +2,19 @@
/*
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-
#include <common.h>
-#include <asm/arch/eeprom.h>
#include <fdtdec.h>
#include <init.h>
#include <linux/sizes.h>
-DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_ID_EEPROM
+#include <asm/arch/eeprom.h>
#define STARFIVE_JH7110_EEPROM_DDRINFO_OFFSET 91
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_ID_EEPROM
static bool check_eeprom_dram_info(phys_size_t size)
{
switch (size) {
@@ -25,22 +28,15 @@ static bool check_eeprom_dram_info(phys_size_t size)
}
}
-int dram_init(void)
+static void resize_ddr_from_eeprom(void)
{
- int ret;
- u8 data;
- u32 len;
- u32 offset;
+ u32 offset = STARFIVE_JH7110_EEPROM_DDRINFO_OFFSET;
phys_size_t size;
+ u32 len = 1;
+ u8 data = 0;
+ int ret;
- data = 0;
- len = 1;
- offset = STARFIVE_JH7110_EEPROM_DDRINFO_OFFSET; /*offset of memory size stored in eeprom*/
- ret = fdtdec_setup_mem_size_base();
- if (ret)
- goto err;
-
- /*read memory size info*/
+ /* read memory size info */
ret = get_data_from_eeprom(offset, len, &data);
if (ret == len) {
size = ((phys_size_t)hextoul(&data, NULL)) << 30;
@@ -48,9 +44,21 @@ int dram_init(void)
gd->ram_size = size;
}
- ret = 0;
-err:
+}
+#endif /* CONFIG_ID_EEPROM */
+
+int dram_init(void)
+{
+ int ret;
+
+ ret = fdtdec_setup_mem_size_base();
+ if (ret)
return ret;
+
+#ifdef CONFIG_ID_EEPROM
+ resize_ddr_from_eeprom();
+#endif
+ return 0;
}
int dram_init_banksize(void)