2019-12-07 04:42:18 +00:00
|
|
|
// SPDX-License-Identifier: Intel
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2015-2016 Intel Corp.
|
|
|
|
* (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
|
|
|
|
*
|
|
|
|
* Mostly taken from coreboot fsp2_0/silicon_init.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LOG_CATEGORY UCLASS_NORTHBRIDGE
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <binman.h>
|
2020-05-10 17:40:00 +00:00
|
|
|
#include <bootstage.h>
|
2019-12-07 04:42:18 +00:00
|
|
|
#include <dm.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-12-07 04:42:18 +00:00
|
|
|
#include <asm/arch/fsp/fsp_configs.h>
|
|
|
|
#include <asm/arch/fsp/fsp_s_upd.h>
|
|
|
|
#include <asm/fsp/fsp_infoheader.h>
|
|
|
|
#include <asm/fsp2/fsp_internal.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2019-12-07 04:42:18 +00:00
|
|
|
|
|
|
|
int fsp_silicon_init(bool s3wake, bool use_spi_flash)
|
|
|
|
{
|
|
|
|
struct fsps_upd upd, *fsp_upd;
|
|
|
|
fsp_silicon_init_func func;
|
|
|
|
struct fsp_header *hdr;
|
|
|
|
struct binman_entry entry;
|
|
|
|
struct udevice *dev;
|
|
|
|
ulong rom_offset = 0;
|
2020-09-22 18:45:37 +00:00
|
|
|
u32 init_addr;
|
2019-12-07 04:42:18 +00:00
|
|
|
int ret;
|
|
|
|
|
2020-09-22 18:45:37 +00:00
|
|
|
log_debug("Locating FSP\n");
|
2019-12-07 04:42:18 +00:00
|
|
|
ret = fsp_locate_fsp(FSP_S, &entry, use_spi_flash, &dev, &hdr,
|
|
|
|
&rom_offset);
|
|
|
|
if (ret)
|
|
|
|
return log_msg_ret("locate FSP", ret);
|
2020-07-08 03:32:25 +00:00
|
|
|
binman_set_rom_offset(rom_offset);
|
2019-12-07 04:42:18 +00:00
|
|
|
gd->arch.fsp_s_hdr = hdr;
|
|
|
|
|
|
|
|
/* Copy over the default config */
|
|
|
|
fsp_upd = (struct fsps_upd *)(hdr->img_base + hdr->cfg_region_off);
|
|
|
|
if (fsp_upd->header.signature != FSPS_UPD_SIGNATURE)
|
|
|
|
return log_msg_ret("Bad UPD signature", -EPERM);
|
|
|
|
memcpy(&upd, fsp_upd, sizeof(upd));
|
|
|
|
|
|
|
|
ret = fsps_update_config(dev, rom_offset, &upd);
|
|
|
|
if (ret)
|
|
|
|
return log_msg_ret("Could not setup config", ret);
|
2020-09-22 18:45:37 +00:00
|
|
|
log_debug("Silicon init @ %x...", init_addr);
|
2020-05-10 17:39:59 +00:00
|
|
|
bootstage_start(BOOTSTAGE_ID_ACCUM_FSP_S, "fsp-s");
|
2019-12-07 04:42:18 +00:00
|
|
|
func = (fsp_silicon_init_func)(hdr->img_base + hdr->fsp_silicon_init);
|
|
|
|
ret = func(&upd);
|
2020-05-10 17:39:59 +00:00
|
|
|
bootstage_accum(BOOTSTAGE_ID_ACCUM_FSP_S);
|
2019-12-07 04:42:18 +00:00
|
|
|
if (ret)
|
|
|
|
return log_msg_ret("Silicon init fail\n", ret);
|
|
|
|
log_debug("done\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|