summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamin Guo <samin.guo@starfivetech.com>2023-07-18 07:48:33 +0300
committerSamin Guo <samin.guo@starfivetech.com>2023-07-19 13:16:39 +0300
commitdc2d30547d7d27610985175d0349ab5d1c99770f (patch)
tree6e07ab9c30163b3133febf2d350f6542a15faffe
parentab5d45b4a5812a9ffe2e9674388100b7902d1bdf (diff)
downloadu-boot-dc2d30547d7d27610985175d0349ab5d1c99770f.tar.xz
board: starfive: vf2: Add resize-ddr function
Add board-level resize-DDR function for visionfive 2 Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
-rw-r--r--board/starfive/visionfive2/starfive_visionfive2.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index e11e02104f..5349d1f276 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -490,3 +490,50 @@ err:
return 0;
}
#endif
+
+#ifdef CONFIG_ID_EEPROM
+
+#include <asm/arch/eeprom.h>
+#define STARFIVE_JH7110_EEPROM_DDRINFO_OFFSET 91
+
+static bool check_eeprom_dram_info(ulong size)
+{
+ switch (size) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ case 16:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static int resize_ddr_from_eeprom(void)
+{
+ ulong size;
+ u32 len = 1;
+ u8 data = 0;
+ int ret;
+
+ /* read memory size info */
+ ret = get_data_from_eeprom(STARFIVE_JH7110_EEPROM_DDRINFO_OFFSET, len, &data);
+ if (ret == len) {
+ size = hextoul(&data, NULL);
+ if (check_eeprom_dram_info(size))
+ return size;
+ }
+ return 0;
+}
+#else
+static int resize_ddr_from_eeprom(void)
+{
+ return 0;
+}
+#endif /* CONFIG_ID_EEPROM */
+
+int board_ddr_size(void)
+{
+ return resize_ddr_from_eeprom();
+}