2019-12-09 00:40:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright 2019 Google LLC
|
|
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-12-09 00:40:19 +00:00
|
|
|
#include <asm/arch/iomap.h>
|
2020-05-18 10:33:34 +00:00
|
|
|
#include <asm/arch/fsp_bindings.h>
|
2019-12-09 00:40:19 +00:00
|
|
|
#include <asm/fsp2/fsp_internal.h>
|
|
|
|
#include <dm/uclass-internal.h>
|
|
|
|
|
|
|
|
int fspm_update_config(struct udevice *dev, struct fspm_upd *upd)
|
|
|
|
{
|
|
|
|
struct fsp_m_config *cfg = &upd->config;
|
|
|
|
struct fspm_arch_upd *arch = &upd->arch;
|
2020-07-10 00:43:17 +00:00
|
|
|
int cache_ret = 0;
|
2020-05-18 10:33:34 +00:00
|
|
|
ofnode node;
|
2020-07-10 00:43:17 +00:00
|
|
|
int ret;
|
2019-12-09 00:40:19 +00:00
|
|
|
|
|
|
|
arch->nvs_buffer_ptr = NULL;
|
2020-07-10 00:43:17 +00:00
|
|
|
cache_ret = prepare_mrc_cache(upd);
|
|
|
|
if (cache_ret && cache_ret != -ENOENT)
|
|
|
|
return log_msg_ret("mrc", cache_ret);
|
2020-07-17 03:22:33 +00:00
|
|
|
arch->stack_base = (void *)(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE -
|
|
|
|
arch->stack_size);
|
2019-12-09 00:40:19 +00:00
|
|
|
arch->boot_loader_tolum_size = 0;
|
2020-07-17 03:22:32 +00:00
|
|
|
arch->boot_mode = cache_ret ? FSP_BOOT_WITH_FULL_CONFIGURATION :
|
|
|
|
FSP_BOOT_ASSUMING_NO_CONFIGURATION_CHANGES;
|
2019-12-09 00:40:19 +00:00
|
|
|
|
2020-05-18 10:33:34 +00:00
|
|
|
node = dev_ofnode(dev);
|
|
|
|
if (!ofnode_valid(node))
|
|
|
|
return log_msg_ret("fsp-m settings", -ENOENT);
|
2019-12-09 00:40:19 +00:00
|
|
|
|
2020-07-10 00:43:17 +00:00
|
|
|
ret = fsp_m_update_config_from_dtb(node, cfg);
|
|
|
|
if (ret)
|
|
|
|
return log_msg_ret("dtb", cache_ret);
|
|
|
|
|
|
|
|
return cache_ret;
|
2019-12-09 00:40:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The FSP-M binary appears to break the SPI controller. It can be fixed by
|
|
|
|
* writing the BAR again, so do that here
|
|
|
|
*/
|
|
|
|
int fspm_done(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct udevice *spi;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Don't probe the device, since that reads the BAR */
|
|
|
|
ret = uclass_find_first_device(UCLASS_SPI, &spi);
|
|
|
|
if (ret)
|
|
|
|
return log_msg_ret("SPI", ret);
|
|
|
|
if (!spi)
|
|
|
|
return log_msg_ret("no SPI", -ENODEV);
|
|
|
|
|
|
|
|
dm_pci_write_config32(spi, PCI_BASE_ADDRESS_0,
|
|
|
|
IOMAP_SPI_BASE | PCI_BASE_ADDRESS_SPACE_MEMORY);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|