2020-10-15 21:08:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
|
|
|
|
#include <common.h>
|
2021-11-15 22:45:46 +00:00
|
|
|
#include <dm.h>
|
2020-10-15 21:08:57 +00:00
|
|
|
#include <malloc.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fsl_ddr.h>
|
|
|
|
#include <fdt_support.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-10-15 21:08:57 +00:00
|
|
|
#include <linux/libfdt.h>
|
|
|
|
#include <env_internal.h>
|
|
|
|
#include <asm/arch-fsl-layerscape/soc.h>
|
|
|
|
#include <asm/arch-fsl-layerscape/fsl_icid.h>
|
|
|
|
#include <i2c.h>
|
|
|
|
#include <asm/arch/soc.h>
|
|
|
|
#include <fsl_immap.h>
|
|
|
|
#include <netdev.h>
|
2021-11-15 22:45:49 +00:00
|
|
|
#include <wdt.h>
|
2020-10-15 21:08:57 +00:00
|
|
|
|
2021-11-15 22:45:46 +00:00
|
|
|
#include <sl28cpld.h>
|
2020-10-15 21:08:57 +00:00
|
|
|
#include <fdtdec.h>
|
|
|
|
#include <miiphy.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2021-01-07 23:08:59 +00:00
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
|
|
|
fsl_lsch3_early_init_f();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-15 21:08:57 +00:00
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_eth_init(struct bd_info *bis)
|
|
|
|
{
|
|
|
|
return pci_eth_init(bis);
|
|
|
|
}
|
|
|
|
|
2021-11-15 22:45:46 +00:00
|
|
|
static int __sl28cpld_read(uint reg)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_driver(UCLASS_NOP,
|
|
|
|
DM_DRIVER_GET(sl28cpld), &dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return sl28cpld_read(dev, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_cpld_version(void)
|
|
|
|
{
|
|
|
|
int version = __sl28cpld_read(SL28CPLD_VERSION);
|
|
|
|
|
|
|
|
if (version < 0)
|
|
|
|
printf("CPLD: error reading version (%d)\n", version);
|
|
|
|
else
|
|
|
|
printf("CPLD: v%d\n", version);
|
|
|
|
}
|
|
|
|
|
2020-10-15 21:08:57 +00:00
|
|
|
int checkboard(void)
|
|
|
|
{
|
|
|
|
printf("EL: %d\n", current_el());
|
2021-11-15 22:45:46 +00:00
|
|
|
if (CONFIG_IS_ENABLED(SL28CPLD))
|
|
|
|
print_cpld_version();
|
|
|
|
|
2020-10-15 21:08:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-15 22:45:49 +00:00
|
|
|
static void stop_recovery_watchdog(void)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_driver(UCLASS_WDT,
|
|
|
|
DM_DRIVER_GET(sl28cpld_wdt), &dev);
|
|
|
|
if (!ret)
|
|
|
|
wdt_stop(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
int fsl_board_late_init(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Usually, the after a board reset, the watchdog is enabled by
|
|
|
|
* default. This is to supervise the bootloader boot-up. Therefore,
|
|
|
|
* to prevent a watchdog reset if we don't actively kick it, we have
|
|
|
|
* to disable it.
|
|
|
|
*
|
|
|
|
* If the watchdog isn't enabled at reset (which is a configuration
|
|
|
|
* option) disabling it doesn't hurt either.
|
|
|
|
*/
|
|
|
|
if (!CONFIG_IS_ENABLED(WATCHDOG_AUTOSTART))
|
|
|
|
stop_recovery_watchdog();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-15 21:08:57 +00:00
|
|
|
void detail_board_ddr_info(void)
|
|
|
|
{
|
|
|
|
print_ddr_info(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ft_board_setup(void *blob, struct bd_info *bd)
|
|
|
|
{
|
|
|
|
u64 base[CONFIG_NR_DRAM_BANKS];
|
|
|
|
u64 size[CONFIG_NR_DRAM_BANKS];
|
|
|
|
int nbanks = CONFIG_NR_DRAM_BANKS;
|
2020-11-18 16:46:02 +00:00
|
|
|
int node;
|
2020-10-15 21:08:57 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
ft_cpu_setup(blob, bd);
|
|
|
|
|
|
|
|
/* fixup DT for the two GPP DDR banks */
|
|
|
|
for (i = 0; i < nbanks; i++) {
|
|
|
|
base[i] = gd->bd->bi_dram[i].start;
|
|
|
|
size[i] = gd->bd->bi_dram[i].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
fdt_fixup_memory_banks(blob, base, size, nbanks);
|
|
|
|
|
|
|
|
fdt_fixup_icid(blob);
|
|
|
|
|
2020-11-18 16:46:02 +00:00
|
|
|
if (CONFIG_IS_ENABLED(SL28_SPL_LOADS_OPTEE_BL32)) {
|
|
|
|
node = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz");
|
|
|
|
if (node)
|
2021-11-26 13:57:08 +00:00
|
|
|
fdt_set_node_status(blob, node, FDT_STATUS_OKAY);
|
2020-11-18 16:46:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 21:08:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|