2018-12-14 15:16:47 +00:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Microsemi Corporation
|
|
|
|
*/
|
|
|
|
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2018-12-14 15:16:47 +00:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
|
|
|
|
#include <mach/tlb.h>
|
|
|
|
#include <mach/ddr.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
static inline int vcoreiii_train_bytelane(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hal_vcoreiii_train_bytelane(0);
|
|
|
|
|
2019-01-17 14:33:27 +00:00
|
|
|
#if defined(CONFIG_SOC_OCELOT) || defined(CONFIG_SOC_JR2) || \
|
2019-01-23 15:39:42 +00:00
|
|
|
defined(CONFIG_SOC_SERVALT) || defined(CONFIG_SOC_SERVAL)
|
2018-12-14 15:16:47 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = hal_vcoreiii_train_bytelane(1);
|
2018-12-14 15:16:48 +00:00
|
|
|
#endif
|
2018-12-14 15:16:47 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int vcoreiii_ddr_init(void)
|
|
|
|
{
|
2020-02-06 09:45:40 +00:00
|
|
|
register int res;
|
2018-12-14 15:16:47 +00:00
|
|
|
|
|
|
|
if (!(readl(BASE_CFG + ICPU_MEMCTRL_STAT)
|
|
|
|
& ICPU_MEMCTRL_STAT_INIT_DONE)) {
|
|
|
|
hal_vcoreiii_init_memctl();
|
|
|
|
hal_vcoreiii_wait_memctl();
|
|
|
|
if (hal_vcoreiii_init_dqs() || vcoreiii_train_bytelane())
|
|
|
|
hal_vcoreiii_ddr_failed();
|
|
|
|
}
|
2020-02-06 09:45:40 +00:00
|
|
|
|
2018-12-14 15:16:47 +00:00
|
|
|
res = dram_check();
|
|
|
|
if (res == 0)
|
|
|
|
hal_vcoreiii_ddr_verified();
|
|
|
|
else
|
|
|
|
hal_vcoreiii_ddr_failed();
|
|
|
|
|
2020-02-06 09:45:40 +00:00
|
|
|
/* Remap DDR to kuseg: Clear boot-mode */
|
2018-12-14 15:16:47 +00:00
|
|
|
clrbits_le32(BASE_CFG + ICPU_GENERAL_CTRL,
|
|
|
|
ICPU_GENERAL_CTRL_BOOT_MODE_ENA);
|
2020-02-06 09:45:40 +00:00
|
|
|
/* - and read-back to activate/verify */
|
2018-12-14 15:16:47 +00:00
|
|
|
readl(BASE_CFG + ICPU_GENERAL_CTRL);
|
2020-02-06 09:45:40 +00:00
|
|
|
|
2018-12-14 15:16:47 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int print_cpuinfo(void)
|
|
|
|
{
|
|
|
|
printf("MSCC VCore-III MIPS 24Kec\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
2022-11-16 18:10:37 +00:00
|
|
|
gd->ram_size = CFG_SYS_SDRAM_SIZE;
|
2018-12-14 15:16:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|