[U-Boot] [PATCH 7/8] x86: fsp: Move VPD/UPD verification to update_fsp_configs()

Bin Meng bmeng.cn at gmail.com
Wed Dec 2 09:59:03 CET 2015


Since VPD/UPD may not exist on every FSP, move the codes that
verifies VPD/UPD to chipset-specific update_fsp_configs().
This also updates update_fsp_configs() signature to accpect
FSP runtime buffer pointer as its second parameter.

Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---

 arch/x86/cpu/baytrail/fsp_configs.c    | 24 +++++++++++++++++++++++-
 arch/x86/cpu/queensbay/fsp_configs.c   | 26 +++++++++++++++++++++++++-
 arch/x86/include/asm/fsp/fsp_support.h |  4 +++-
 arch/x86/lib/fsp/fsp_support.c         | 24 +-----------------------
 4 files changed, 52 insertions(+), 26 deletions(-)

diff --git a/arch/x86/cpu/baytrail/fsp_configs.c b/arch/x86/cpu/baytrail/fsp_configs.c
index 9810921..3a03392 100644
--- a/arch/x86/cpu/baytrail/fsp_configs.c
+++ b/arch/x86/cpu/baytrail/fsp_configs.c
@@ -125,13 +125,35 @@ const struct pch_azalia_config azalia_config = {
  * If the device tree does not specify an integer setting, use the default
  * provided in Intel's Baytrail_FSP_Gold4.tgz release FSP/BayleyBayFsp.bsf file.
  */
-void update_fsp_configs(struct fsp_config_data *config)
+void update_fsp_configs(struct fsp_config_data *config,
+			struct fspinit_rtbuf *rt_buf)
 {
+	struct fsp_header *fsp_hdr = config->fsp_hdr;
+	struct vpd_region *fsp_vpd;
 	struct upd_region *fsp_upd = &config->fsp_upd;
 	struct memory_down_data *mem;
 	const void *blob = gd->fdt_blob;
 	int node;
 
+	/* Initialize runtime buffer for fsp_init() */
+	rt_buf->common.stack_top = config->stack_top - 32;
+	rt_buf->common.boot_mode = config->boot_mode;
+	rt_buf->common.upd_data = &config->fsp_upd;
+
+	/* Get VPD region start */
+	fsp_vpd = (struct vpd_region *)(fsp_hdr->img_base +
+			fsp_hdr->cfg_region_off);
+
+	/* Verify the VPD data region is valid */
+	assert(fsp_vpd->sign == VPD_IMAGE_ID);
+
+	/* Copy default data from Flash */
+	memcpy(fsp_upd, (void *)(fsp_hdr->img_base + fsp_vpd->upd_offset),
+	       sizeof(struct upd_region));
+
+	/* Verify the UPD data region is valid */
+	assert(fsp_upd->terminator == UPD_TERMINATOR);
+
 	fsp_upd->azalia_config_ptr = (uint32_t)&azalia_config;
 
 	node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_BAYTRAIL_FSP);
diff --git a/arch/x86/cpu/queensbay/fsp_configs.c b/arch/x86/cpu/queensbay/fsp_configs.c
index f84ae30..96ec116 100644
--- a/arch/x86/cpu/queensbay/fsp_configs.c
+++ b/arch/x86/cpu/queensbay/fsp_configs.c
@@ -8,8 +8,32 @@
 #include <common.h>
 #include <asm/fsp/fsp_support.h>
 
-void update_fsp_configs(struct fsp_config_data *config)
+void update_fsp_configs(struct fsp_config_data *config,
+			struct fspinit_rtbuf *rt_buf)
 {
+	struct fsp_header *fsp_hdr = config->fsp_hdr;
+	struct vpd_region *fsp_vpd;
+	struct upd_region *fsp_upd = &config->fsp_upd;
+
+	/* Initialize runtime buffer for fsp_init() */
+	rt_buf->common.stack_top = config->stack_top - 32;
+	rt_buf->common.boot_mode = config->boot_mode;
+	rt_buf->common.upd_data = &config->fsp_upd;
+
+	/* Get VPD region start */
+	fsp_vpd = (struct vpd_region *)(fsp_hdr->img_base +
+			fsp_hdr->cfg_region_off);
+
+	/* Verify the VPD data region is valid */
+	assert(fsp_vpd->sign == VPD_IMAGE_ID);
+
+	/* Copy default data from Flash */
+	memcpy(fsp_upd, (void *)(fsp_hdr->img_base + fsp_vpd->upd_offset),
+	       sizeof(struct upd_region));
+
+	/* Verify the UPD data region is valid */
+	assert(fsp_upd->terminator == UPD_TERMINATOR);
+
 	/* Override any UPD setting if required */
 
 	/* Uncomment the line below to enable DEBUG message */
diff --git a/arch/x86/include/asm/fsp/fsp_support.h b/arch/x86/include/asm/fsp/fsp_support.h
index e65a130..61d811f 100644
--- a/arch/x86/include/asm/fsp/fsp_support.h
+++ b/arch/x86/include/asm/fsp/fsp_support.h
@@ -194,10 +194,12 @@ void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len);
  * This function overrides the default configurations of FSP.
  *
  * @config:  A pointer to the FSP configuration data structure
+ * @rt_buf:  A pointer to the FSP runtime buffer data structure
  *
  * @return:  None
  */
-void update_fsp_configs(struct fsp_config_data *config);
+void update_fsp_configs(struct fsp_config_data *config,
+			struct fspinit_rtbuf *rt_buf);
 
 /**
  * fsp_init_phase_pci() - Tell the FSP that we have completed PCI init
diff --git a/arch/x86/lib/fsp/fsp_support.c b/arch/x86/lib/fsp/fsp_support.c
index faca93e..c386b75 100644
--- a/arch/x86/lib/fsp/fsp_support.c
+++ b/arch/x86/lib/fsp/fsp_support.c
@@ -103,10 +103,8 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	fsp_init_f init;
 	struct fsp_init_params params;
 	struct fspinit_rtbuf rt_buf;
-	struct vpd_region *fsp_vpd;
 	struct fsp_header *fsp_hdr;
 	struct fsp_init_params *params_ptr;
-	struct upd_region *fsp_upd;
 
 #ifdef CONFIG_DEBUG_UART
 	setup_early_uart();
@@ -122,30 +120,10 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	config_data.stack_top = stack_top;
 	config_data.boot_mode = boot_mode;
 
-	fsp_upd = &config_data.fsp_upd;
 	memset(&rt_buf, 0, sizeof(struct fspinit_rtbuf));
 
-	/* Reserve a gap in stack top */
-	rt_buf.common.stack_top = stack_top - 32;
-	rt_buf.common.boot_mode = boot_mode;
-	rt_buf.common.upd_data = fsp_upd;
-
-	/* Get VPD region start */
-	fsp_vpd = (struct vpd_region *)(fsp_hdr->img_base +
-			fsp_hdr->cfg_region_off);
-
-	/* Verify the VPD data region is valid */
-	assert(fsp_vpd->sign == VPD_IMAGE_ID);
-
-	/* Copy default data from Flash */
-	memcpy(fsp_upd, (void *)(fsp_hdr->img_base + fsp_vpd->upd_offset),
-	       sizeof(struct upd_region));
-
-	/* Verify the UPD data region is valid */
-	assert(fsp_upd->terminator == UPD_TERMINATOR);
-
 	/* Override any configuration if required */
-	update_fsp_configs(&config_data);
+	update_fsp_configs(&config_data, &rt_buf);
 
 	memset(&params, 0, sizeof(struct fsp_init_params));
 	params.nvs_buf = nvs_buf;
-- 
1.8.2.1



More information about the U-Boot mailing list