mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-15 19:51:37 +00:00
riscv: starfive: jh7110: add check_eeprom_dram_info
Make sure that the read DDR information is a valid value Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
This commit is contained in:
parent
97f3b2aaee
commit
479dc3cb7e
1 changed files with 19 additions and 2 deletions
|
@ -11,12 +11,26 @@
|
|||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static bool check_eeprom_dram_info(phys_size_t size)
|
||||
{
|
||||
switch (size) {
|
||||
case 0x80000000:
|
||||
case 0x100000000:
|
||||
case 0x200000000:
|
||||
case 0x400000000:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int dram_init(void)
|
||||
{
|
||||
int ret;
|
||||
u8 data;
|
||||
u32 len;
|
||||
u32 offset;
|
||||
phys_size_t size;
|
||||
|
||||
data = 0;
|
||||
len = 1;
|
||||
|
@ -27,8 +41,11 @@ int dram_init(void)
|
|||
|
||||
/*read memory size info*/
|
||||
ret = get_data_from_eeprom(offset, len, &data);
|
||||
if (ret == len)
|
||||
gd->ram_size = ((phys_size_t)hextoul(&data, NULL)) << 30;
|
||||
if (ret == len) {
|
||||
size = ((phys_size_t)hextoul(&data, NULL)) << 30;
|
||||
if (check_eeprom_dram_info(size))
|
||||
gd->ram_size = size;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
err:
|
||||
|
|
Loading…
Add table
Reference in a new issue