Skip to contentSkip to conversation

x86: fsp: Move platform-specific config to chipset directory

PATCH Superseded Bin Meng 2 participants 23 messages Dec 2, 2015 – Dec 3, 2015 x86

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

cover x86: fsp: Move platform-specific config to chipset directory

All FSP spec v1.0 complaint FSP binary uses struct fspinit_rtbuf as defined by the 1.0 spec, however there are FSPs that do not follow 1.0 spec, like Intel FSP for 3rd generation Intel Core and Intel Celeron processors with mobile Intel HM76 and QM77 chipsets platform (formerly Chief River Platform: Ivy Bridge and Panther Point). Although Intel website says this FSP conforms to FSP v1.0 specification which defines the UPD usage, it is not really the case. This might possible due to that FSP predates the 1.0 spec. Also future FSP binary that is complaint to v1.1 spec defines an optional paltform-specific runtime data in the struct fspinit_rtbuf.

Besides this fspinit_rtbuf, the IvyBridge FSP does not support UPD either, so that current codes in arch/x86/lib/fsp/fsp_support.c won't work for that FSP. We need some flexibility, hence move those platform-specific config to chipset directory.

Right now we still use hardcoded 'const struct' table (in flash) to pass the Azalia (Intel HD Audio) verb table to FSP, because different FSP may use different verb table format (at least for Queensbay and BayTrail), we cannot handle this in the common FSP support codes. But with this series, we are now able to get Azalia verb table from device tree, just like what we did for overriding UPD data configuration. This can be done in future patch set.

Bin Meng (8):
x86: fsp: Simplify fsp_continue()
x86: fsp: Avoid cast stack_top in struct shared_data
x86: fsp: Add boot_mode as a member of struct shared_data
x86: fsp: Rename shared_data to fsp_config_data
x86: fsp: Rename update_fsp_upd() and change its signature
x86: fsp: Move struct fspinit_rtbuf definition to chipset header
x86: fsp: Move VPD/UPD verification to update_fsp_configs()
x86: queensbay: Remove invalid comments in update_fsp_upd()

 arch/x86/cpu/baytrail/fsp_configs.c                | 27 ++++++++-
 arch/x86/cpu/queensbay/fsp_configs.c               | 30 ++++++++--
 .../include/asm/arch-baytrail/fsp/fsp_configs.h    | 21 +++++++
 .../include/asm/arch-queensbay/fsp/fsp_configs.h   | 21 +++++++
 arch/x86/include/asm/fsp/fsp_api.h                 |  2 +-
 arch/x86/include/asm/fsp/fsp_platform.h            | 15 -----
 arch/x86/include/asm/fsp/fsp_support.h             | 20 +++----
 arch/x86/lib/fsp/fsp_support.c                     | 64 +++++-----------------
 8 files changed, 112 insertions(+), 88 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h
 create mode 100644 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h
 delete mode 100644 arch/x86/include/asm/fsp/fsp_platform.h
Signature · 1 line
1.8.2.1
author
#1 lore raw

PATCH 1/8 x86: fsp: Simplify fsp_continue()

There is no need to pass shared_data to fsp_continue() so we can remove unnecessary codes that simplifies the function a lot.

---

 arch/x86/include/asm/fsp/fsp_support.h |  4 +---
 arch/x86/lib/fsp/fsp_support.c         | 29 ++++++-----------------------
 2 files changed, 7 insertions(+), 26 deletions(-)
arch/x86/include/asm/fsp/fsp_support.h +1 -3
index 7317dda..f30d7b4 100644
@@ -49,14 +49,12 @@ void fsp_init_done(void *hob_list);
 /**
  * FSP Continuation function
  *
- * @shared_data: Shared data base before stack migration
  * @status:      Always 0
  * @hob_list:    HOB list pointer
  *
  * @retval:      Never returns
  */
-void fsp_continue(struct shared_data *shared_data, u32 status,
-		  void *hob_list);
+void fsp_continue(u32 status, void *hob_list);
 
 /**
  * Find FSP header offset in FSP image
arch/x86/lib/fsp/fsp_support.c +6 -23
index 1d48ff4..0408b5d 100644
@@ -87,28 +87,12 @@ struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
 	return (struct fsp_header *)fsp;
 }
 
-void fsp_continue(struct shared_data *shared_data, u32 status, void *hob_list)
+void fsp_continue(u32 status, void *hob_list)
 {
-	u32 stack_len;
-	u32 stack_base;
-	u32 stack_top;
-
 	post_code(POST_MRC);
 
 	assert(status == 0);
 
-	/* Get the migrated stack in normal memory */
-	stack_base = (u32)fsp_get_bootloader_tmp_mem(hob_list, &stack_len);
-	assert(stack_base != 0);
-	stack_top  = stack_base + stack_len - sizeof(u32);
-
-	/*
-	 * Old stack base is stored at the very end of the stack top,
-	 * use it to calculate the migrated shared data base
-	 */
-	shared_data = (struct shared_data *)(stack_base +
-			((u32)shared_data - *(u32 *)stack_top));
-
 	/* The boot loader main function entry */
 	fsp_init_done(hob_list);
 }
@@ -176,19 +160,18 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	setup_fsp_gdt();
 
 	/*
-	 * Use ASM code to ensure the register value in EAX & ECX
-	 * will be passed into BlContinuationFunc
+	 * Use ASM code to ensure the register value in EAX & EDX
+	 * will be passed into fsp_continue
 	 */
 	asm volatile (
 		"pushl	%0;"
 		"call	*%%eax;"
 		".global asm_continuation;"
 		"asm_continuation:;"
-		"movl	%%ebx, %%eax;"		/* shared_data */
-		"movl	4(%%esp), %%edx;"	/* status */
-		"movl	8(%%esp), %%ecx;"	/* hob_list */
+		"movl	4(%%esp), %%eax;"	/* status */
+		"movl	8(%%esp), %%edx;"	/* hob_list */
 		"jmp	fsp_continue;"
-		: : "m"(params_ptr), "a"(init), "b"(&shared_data)
+		: : "m"(params_ptr), "a"(init)
 	);
 
 	/*
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 1/8 x86: fsp: Simplify fsp_continue()

Hi Bin,

Quoted 2 lines · Bin Meng

There is no need to pass shared_data to fsp_continue() so we can remove unnecessary codes that simplifies the function a lot.

Is this because shared_data is effectively useful for a bootloader due to the stack being changed?

Quoted 8 lines

---

 arch/x86/include/asm/fsp/fsp_support.h |  4 +---
 arch/x86/lib/fsp/fsp_support.c         | 29 ++++++-----------------------
 2 files changed, 7 insertions(+), 26 deletions(-)

[snip]

Regards,
Simon

author
#3 lore raw

PATCH 1/8 x86: fsp: Simplify fsp_continue()

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Bin,

Quoted 2 lines · Bin Meng

There is no need to pass shared_data to fsp_continue() so we can remove unnecessary codes that simplifies the function a lot.

Is this because shared_data is effectively useful for a bootloader due to the stack being changed?

The removed codes were originally from Queensbay FSP package. Looks Intel's intention was to help stack migration, but I doubt they ever worked. We don't support stack migration after fsp_init() hence these codes are never needed.

Quoted 9 lines
Quoted 8 lines

---

 arch/x86/include/asm/fsp/fsp_support.h |  4 +---
 arch/x86/lib/fsp/fsp_support.c         | 29 ++++++-----------------------
 2 files changed, 7 insertions(+), 26 deletions(-)
Quoted 4 lines

[snip]

Regards,
Simon

Regards,
Bin

#4 lore raw

PATCH 1/8 x86: fsp: Simplify fsp_continue()

Hi Bin,

Quoted 9 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

Hi Bin,

Quoted 2 lines · Bin Meng

There is no need to pass shared_data to fsp_continue() so we can remove unnecessary codes that simplifies the function a lot.

Quoted 8 lines
Quoted 3 lines

Is this because shared_data is effectively useful for a bootloader due to the stack being changed?

The removed codes were originally from Queensbay FSP package. Looks Intel's intention was to help stack migration, but I doubt they ever worked. We don't support stack migration after fsp_init() hence these codes are never needed.

Eek. Nasty unimplemented specs!

Quoted 17 lines
Quoted 10 lines
Quoted 9 lines

---

 arch/x86/include/asm/fsp/fsp_support.h |  4 +---
 arch/x86/lib/fsp/fsp_support.c         | 29 ++++++-----------------------
 2 files changed, 7 insertions(+), 26 deletions(-)
Quoted 4 lines

[snip]

Regards,
Simon

Regards,
Bin

author
#5 lore raw

PATCH 2/8 x86: fsp: Avoid cast stack_top in struct shared_data

In reply to Bin Meng

Declare stack_top as u32 in struct shared_data and struct common_buf so that we can avoid casting in fsp_init().

---

 arch/x86/include/asm/fsp/fsp_api.h     | 2 +-
 arch/x86/include/asm/fsp/fsp_support.h | 2 +-
 arch/x86/lib/fsp/fsp_support.c         | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/fsp/fsp_api.h +1 -1
index 2d34d13..db83e35 100644
@@ -30,7 +30,7 @@ struct common_buf {
 	 * Stack top pointer used by the bootloader. The new stack frame will be
 	 * set up at this location after FspInit API call.
 	 */
-	u32	*stack_top;
+	u32	stack_top;
 	u32	boot_mode;	/* Current system boot mode */
 	void	*upd_data;	/* User platform configuraiton data region */
 	u32	reserved[7];	/* Reserved */
arch/x86/include/asm/fsp/fsp_support.h +1 -1
index f30d7b4..685778e 100644
@@ -20,7 +20,7 @@
 
 struct shared_data {
 	struct fsp_header	*fsp_hdr;
-	u32			*stack_top;
+	u32			stack_top;
 	struct upd_region	fsp_upd;
 };
 
arch/x86/lib/fsp/fsp_support.c +2 -2
index 0408b5d..df62ba8 100644
@@ -122,7 +122,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	memset(&rt_buf, 0, sizeof(struct fspinit_rtbuf));
 
 	/* Reserve a gap in stack top */
-	rt_buf.common.stack_top = (u32 *)stack_top - 32;
+	rt_buf.common.stack_top = stack_top - 32;
 	rt_buf.common.boot_mode = boot_mode;
 	rt_buf.common.upd_data = fsp_upd;
 
@@ -152,7 +152,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	params_ptr = &params;
 
 	shared_data.fsp_hdr = fsp_hdr;
-	shared_data.stack_top = (u32 *)stack_top;
+	shared_data.stack_top = stack_top;
 
 	post_code(POST_PRE_MRC);
 
Signature · 1 line
1.8.2.1
#6 lore raw

PATCH 2/8 x86: fsp: Avoid cast stack_top in struct shared_data

Quoted 10 lines · Bin Meng

Declare stack_top as u32 in struct shared_data and struct common_buf so that we can avoid casting in fsp_init().

---

 arch/x86/include/asm/fsp/fsp_api.h     | 2 +-
 arch/x86/include/asm/fsp/fsp_support.h | 2 +-
 arch/x86/lib/fsp/fsp_support.c         | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
author
#7 lore raw

PATCH 3/8 x86: fsp: Add boot_mode as a member of struct shared_data

In reply to Bin Meng

Save boot_mode in struct shared_data for future refactoring

---

 arch/x86/include/asm/fsp/fsp_support.h | 1 +
 arch/x86/lib/fsp/fsp_support.c         | 1 +
 2 files changed, 2 insertions(+)
arch/x86/include/asm/fsp/fsp_support.h +1 -0
index 685778e..18e2d21 100644
@@ -21,6 +21,7 @@
 struct shared_data {
 	struct fsp_header	*fsp_hdr;
 	u32			stack_top;
+	u32			boot_mode;
 	struct upd_region	fsp_upd;
 };
 
arch/x86/lib/fsp/fsp_support.c +1 -0
index df62ba8..083d855 100644
@@ -153,6 +153,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 
 	shared_data.fsp_hdr = fsp_hdr;
 	shared_data.stack_top = stack_top;
+	shared_data.boot_mode = boot_mode;
 
 	post_code(POST_PRE_MRC);
 
Signature · 1 line
1.8.2.1
author
#9 lore raw

PATCH 4/8 x86: fsp: Rename shared_data to fsp_config_data

In reply to Bin Meng

FSP has several config data like UPD, HDA verb table which can be overridden or provided by bootloader. Currently in U-Boot only UPD is handled via struct shared_data. To accommodate any platform, we rename shared_data to fsp_config_data and move the definition from common place fsp_support.h to platform-specific place fsp_configs.h.

---

 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h  | 17 +++++++++++++++++
 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h | 17 +++++++++++++++++
 arch/x86/include/asm/fsp/fsp_support.h                |  8 +-------
 arch/x86/lib/fsp/fsp_support.c                        | 10 +++++-----
 4 files changed, 40 insertions(+), 12 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h
 create mode 100644 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +17 -0
new file mode 100644
index 0000000..2397553
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:	Intel
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__
+
+struct fsp_config_data {
+	struct fsp_header	*fsp_hdr;
+	u32			stack_top;
+	u32			boot_mode;
+	struct upd_region	fsp_upd;
+};
+
+#endif /* __FSP_CONFIGS_H__ */
arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h new file +17 -0
new file mode 100644
index 0000000..2397553
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:	Intel
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__
+
+struct fsp_config_data {
+	struct fsp_header	*fsp_hdr;
+	u32			stack_top;
+	u32			boot_mode;
+	struct upd_region	fsp_upd;
+};
+
+#endif /* __FSP_CONFIGS_H__ */
arch/x86/include/asm/fsp/fsp_support.h +1 -7
index 18e2d21..39b2864 100644
@@ -17,13 +17,7 @@
 #include "fsp_infoheader.h"
 #include "fsp_bootmode.h"
 #include <asm/arch/fsp/fsp_vpd.h>
-
-struct shared_data {
-	struct fsp_header	*fsp_hdr;
-	u32			stack_top;
-	u32			boot_mode;
-	struct upd_region	fsp_upd;
-};
+#include <asm/arch/fsp/fsp_configs.h>
 
 #define FSP_LOWMEM_BASE		0x100000UL
 #define FSP_HIGHMEM_BASE	0x100000000ULL
arch/x86/lib/fsp/fsp_support.c +5 -5
index 083d855..9da720b 100644
@@ -99,7 +99,7 @@ void fsp_continue(u32 status, void *hob_list)
 
 void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 {
-	struct shared_data shared_data;
+	struct fsp_config_data config_data;
 	fsp_init_f init;
 	struct fsp_init_params params;
 	struct fspinit_rtbuf rt_buf;
@@ -118,7 +118,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 		panic("Invalid FSP header");
 	}
 
-	fsp_upd = &shared_data.fsp_upd;
+	fsp_upd = &config_data.fsp_upd;
 	memset(&rt_buf, 0, sizeof(struct fspinit_rtbuf));
 
 	/* Reserve a gap in stack top */
@@ -151,9 +151,9 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	init = (fsp_init_f)(fsp_hdr->img_base + fsp_hdr->fsp_init);
 	params_ptr = &params;
 
-	shared_data.fsp_hdr = fsp_hdr;
-	shared_data.stack_top = stack_top;
-	shared_data.boot_mode = boot_mode;
+	config_data.fsp_hdr = fsp_hdr;
+	config_data.stack_top = stack_top;
+	config_data.boot_mode = boot_mode;
 
 	post_code(POST_PRE_MRC);
 
Signature · 1 line
1.8.2.1
#10 lore raw

PATCH 4/8 x86: fsp: Rename shared_data to fsp_config_data

Hi Bin,

Quoted 23 lines · Bin Meng

FSP has several config data like UPD, HDA verb table which can be overridden or provided by bootloader. Currently in U-Boot only UPD is handled via struct shared_data. To accommodate any platform, we rename shared_data to fsp_config_data and move the definition from common place fsp_support.h to platform-specific place fsp_configs.h.

---

 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h  | 17 +++++++++++++++++
 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h | 17 +++++++++++++++++
 arch/x86/include/asm/fsp/fsp_support.h                |  8 +-------
 arch/x86/lib/fsp/fsp_support.c                        | 10 +++++-----
 4 files changed, 40 insertions(+), 12 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h
 create mode 100644 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +0 -0
new file mode 100644
index 0000000..2397553

arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h line 8

Quoted 8 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +8 -0
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:    Intel
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__

Does this justify its own header file? I suppose it does...we have too many fsp header files and I never know which file contains a particular struct definition.

arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h line 14

Quoted 6 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +6 -0
+
+struct fsp_config_data {
+       struct fsp_header       *fsp_hdr;
+       u32                     stack_top;
+       u32                     boot_mode;
+       struct upd_region       fsp_upd;

These are common - should we have a common struct as the first member?

I'm just struggling to understand the benefit of duplicating this common thing into separate files.

Quoted 81 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +3 -0
+};
+
+#endif /* __FSP_CONFIGS_H__ */
arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h new file +17 -0
new file mode 100644
index 0000000..2397553
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:    Intel
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__
+
+struct fsp_config_data {
+       struct fsp_header       *fsp_hdr;
+       u32                     stack_top;
+       u32                     boot_mode;
+       struct upd_region       fsp_upd;
+};
+
+#endif /* __FSP_CONFIGS_H__ */
arch/x86/include/asm/fsp/fsp_support.h +1 -7
index 18e2d21..39b2864 100644
@@ -17,13 +17,7 @@
 #include "fsp_infoheader.h"
 #include "fsp_bootmode.h"
 #include <asm/arch/fsp/fsp_vpd.h>
-
-struct shared_data {
-       struct fsp_header       *fsp_hdr;
-       u32                     stack_top;
-       u32                     boot_mode;
-       struct upd_region       fsp_upd;
-};
+#include <asm/arch/fsp/fsp_configs.h>
 
 #define FSP_LOWMEM_BASE                0x100000UL
 #define FSP_HIGHMEM_BASE       0x100000000ULL
arch/x86/lib/fsp/fsp_support.c +5 -6
index 083d855..9da720b 100644
@@ -99,7 +99,7 @@ void fsp_continue(u32 status, void *hob_list)
 
 void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 {
-       struct shared_data shared_data;
+       struct fsp_config_data config_data;
        fsp_init_f init;
        struct fsp_init_params params;
        struct fspinit_rtbuf rt_buf;
@@ -118,7 +118,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
                panic("Invalid FSP header");
        }
 
-       fsp_upd = &shared_data.fsp_upd;
+       fsp_upd = &config_data.fsp_upd;
        memset(&rt_buf, 0, sizeof(struct fspinit_rtbuf));
 
        /* Reserve a gap in stack top */
@@ -151,9 +151,9 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
        init = (fsp_init_f)(fsp_hdr->img_base + fsp_hdr->fsp_init);
        params_ptr = &params;
 
-       shared_data.fsp_hdr = fsp_hdr;
-       shared_data.stack_top = stack_top;
-       shared_data.boot_mode = boot_mode;
+       config_data.fsp_hdr = fsp_hdr;
+       config_data.stack_top = stack_top;
+       config_data.boot_mode = boot_mode;
 
        post_code(POST_PRE_MRC);
 
--
Quoted 2 lines

1.8.2.1

Regards,
Simon

author
#11 lore raw

PATCH 4/8 x86: fsp: Rename shared_data to fsp_config_data

Hi Simon,

Quoted 39 lines · Simon Glass

Hi Bin,

Quoted 23 lines · Bin Meng

FSP has several config data like UPD, HDA verb table which can be overridden or provided by bootloader. Currently in U-Boot only UPD is handled via struct shared_data. To accommodate any platform, we rename shared_data to fsp_config_data and move the definition from common place fsp_support.h to platform-specific place fsp_configs.h.

---

 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h  | 17 +++++++++++++++++
 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h | 17 +++++++++++++++++
 arch/x86/include/asm/fsp/fsp_support.h                |  8 +-------
 arch/x86/lib/fsp/fsp_support.c                        | 10 +++++-----
 4 files changed, 40 insertions(+), 12 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h
 create mode 100644 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +0 -0
new file mode 100644
index 0000000..2397553

arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h line 8

Quoted 8 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +8 -0
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:    Intel
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__

Does this justify its own header file? I suppose it does...we have too many fsp header files and I never know which file contains a particular struct definition.

Quoted 9 lines

arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h line 14

Quoted 6 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +6 -0
+
+struct fsp_config_data {
+       struct fsp_header       *fsp_hdr;
+       u32                     stack_top;
+       u32                     boot_mode;
+       struct upd_region       fsp_upd;

These are common - should we have a common struct as the first member?

We certainly can create a common struct for the first 3 members (fsp_hdr, stack_top, boot_mode). Another way is to change fsp_update_configs() (in patch#7 of this series) signature to:

void update_fsp_configs(struct fsp_config_data *config, struct fspinit_rtbuf *rt_buf, struct fsp_header *fsp_hdr, u32 stack_top, u32 boot_mode);

This way we avoid saving these 3 parameters into struct fsp_config_data.

Quoted 3 lines

I'm just struggling to understand the benefit of duplicating this common thing into separate files.

[snip]

Regards,
Bin

#12 lore raw

PATCH 4/8 x86: fsp: Rename shared_data to fsp_config_data

Hi Bin,

Quoted 56 lines · Bin Meng

Hi Simon,

Quoted 39 lines · Simon Glass

Hi Bin,

Quoted 23 lines · Bin Meng

FSP has several config data like UPD, HDA verb table which can be overridden or provided by bootloader. Currently in U-Boot only UPD is handled via struct shared_data. To accommodate any platform, we rename shared_data to fsp_config_data and move the definition from common place fsp_support.h to platform-specific place fsp_configs.h.

---

 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h  | 17 +++++++++++++++++
 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h | 17 +++++++++++++++++
 arch/x86/include/asm/fsp/fsp_support.h                |  8 +-------
 arch/x86/lib/fsp/fsp_support.c                        | 10 +++++-----
 4 files changed, 40 insertions(+), 12 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h
 create mode 100644 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +0 -0
new file mode 100644
index 0000000..2397553

arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h line 8

Quoted 8 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +8 -0
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015, Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier:    Intel
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__

Does this justify its own header file? I suppose it does...we have too many fsp header files and I never know which file contains a particular struct definition.

Quoted 9 lines

arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h line 14

Quoted 6 lines
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h new file +6 -0
+
+struct fsp_config_data {
+       struct fsp_header       *fsp_hdr;
+       u32                     stack_top;
+       u32                     boot_mode;
+       struct upd_region       fsp_upd;

These are common - should we have a common struct as the first member?

We certainly can create a common struct for the first 3 members (fsp_hdr, stack_top, boot_mode). Another way is to change fsp_update_configs() (in patch#7 of this series) signature to:

Quoted 5 lines

void update_fsp_configs(struct fsp_config_data *config, struct fspinit_rtbuf *rt_buf, struct fsp_header *fsp_hdr, u32 stack_top, u32 boot_mode);

This way we avoid saving these 3 parameters into struct fsp_config_data.

That's a lot of parameters. I think a common struct seems better for now. We may see a different approach when newer FSPs turn up.

Quoted 9 lines
Quoted 4 lines

I'm just struggling to understand the benefit of duplicating this common thing into separate files.

[snip]

Regards,
Bin

Regards,
Simon

author
#13 lore raw

PATCH 5/8 x86: fsp: Rename update_fsp_upd() and change its signature

In reply to Bin Meng

To support platform-specific configurations (might not always be UPD on some platform), use a better name update_fsp_configs() and accepct struct fsp_config_data as its parameter so that platform codes can handle whatever configuration data for that FSP.

---

 arch/x86/cpu/baytrail/fsp_configs.c    |  5 +++--
 arch/x86/cpu/queensbay/fsp_configs.c   |  2 +-
 arch/x86/include/asm/fsp/fsp_support.h |  6 +++---
 arch/x86/lib/fsp/fsp_support.c         | 12 ++++++------
 4 files changed, 13 insertions(+), 12 deletions(-)
arch/x86/cpu/baytrail/fsp_configs.c +3 -2
index a72d615..9810921 100644
@@ -121,12 +121,13 @@ const struct pch_azalia_config azalia_config = {
 };
 
 /**
- * Override the FSP's UPD.
+ * Override the FSP's configuration data.
  * 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_upd(struct upd_region *fsp_upd)
+void update_fsp_configs(struct fsp_config_data *config)
 {
+	struct upd_region *fsp_upd = &config->fsp_upd;
 	struct memory_down_data *mem;
 	const void *blob = gd->fdt_blob;
 	int node;
arch/x86/cpu/queensbay/fsp_configs.c +1 -1
index 78bc966..f84ae30 100644
@@ -8,7 +8,7 @@
 #include <common.h>
 #include <asm/fsp/fsp_support.h>
 
-void update_fsp_upd(struct upd_region *fsp_upd)
+void update_fsp_configs(struct fsp_config_data *config)
 {
 	/* Override any UPD setting if required */
 
arch/x86/include/asm/fsp/fsp_support.h +3 -3
index 39b2864..67741cc 100644
@@ -192,13 +192,13 @@ void *fsp_get_nvs_data(const void *hob_list, u32 *len);
 void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len);
 
 /**
- * This function overrides the default configurations in the UPD data region.
+ * This function overrides the default configurations of FSP.
  *
- * @fsp_upd: A pointer to the upd_region data strcture
+ * @config:  A pointer to the FSP configuration data structure
  *
  * @return:  None
  */
-void update_fsp_upd(struct upd_region *fsp_upd);
+void update_fsp_configs(struct fsp_config_data *config);
 
 /**
  * fsp_init_phase_pci() - Tell the FSP that we have completed PCI init
arch/x86/lib/fsp/fsp_support.c +6 -6
index 9da720b..faca93e 100644
@@ -118,6 +118,10 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 		panic("Invalid FSP header");
 	}
 
+	config_data.fsp_hdr = fsp_hdr;
+	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));
 
@@ -140,8 +144,8 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	/* Verify the UPD data region is valid */
 	assert(fsp_upd->terminator == UPD_TERMINATOR);
 
-	/* Override any UPD setting if required */
-	update_fsp_upd(fsp_upd);
+	/* Override any configuration if required */
+	update_fsp_configs(&config_data);
 
 	memset(&params, 0, sizeof(struct fsp_init_params));
 	params.nvs_buf = nvs_buf;
@@ -151,10 +155,6 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 	init = (fsp_init_f)(fsp_hdr->img_base + fsp_hdr->fsp_init);
 	params_ptr = &params;
 
-	config_data.fsp_hdr = fsp_hdr;
-	config_data.stack_top = stack_top;
-	config_data.boot_mode = boot_mode;
-
 	post_code(POST_PRE_MRC);
 
 	/* Load GDT for FSP */
Signature · 1 line
1.8.2.1
#14 lore raw

PATCH 5/8 x86: fsp: Rename update_fsp_upd() and change its signature

Quoted 5 lines · Bin Meng

To support platform-specific configurations (might not always be UPD on some platform), use a better name update_fsp_configs() and accepct struct fsp_config_data as its parameter so that platform codes can handle whatever configuration data for that FSP.

Quoted 8 lines

---

 arch/x86/cpu/baytrail/fsp_configs.c    |  5 +++--
 arch/x86/cpu/queensbay/fsp_configs.c   |  2 +-
 arch/x86/include/asm/fsp/fsp_support.h |  6 +++---
 arch/x86/lib/fsp/fsp_support.c         | 12 ++++++------
 4 files changed, 13 insertions(+), 12 deletions(-)
author
#15 lore raw

PATCH 6/8 x86: fsp: Move struct fspinit_rtbuf definition to chipset header

In reply to Bin Meng

All FSP spec v1.0 complaint FSP binary uses struct fspinit_rtbuf as defined by the 1.0 spec, however there are FSPs that does not follow 1.0 spec (possible due to that FSP predates the 1.0 spec), and future FSP binary that is complaint to v1.1 spec defines an optional paltform-specific runtime data in the struct fspinit_rtbuf. Hence move the definition to chipset header.

---

 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h  |  4 ++++
 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h |  4 ++++
 arch/x86/include/asm/fsp/fsp_platform.h               | 15 ---------------
 arch/x86/include/asm/fsp/fsp_support.h                |  1 -
 4 files changed, 8 insertions(+), 16 deletions(-)
 delete mode 100644 arch/x86/include/asm/fsp/fsp_platform.h
arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h +4 -0
index 2397553..f1da205 100644
@@ -14,4 +14,8 @@ struct fsp_config_data {
 	struct upd_region	fsp_upd;
 };
 
+struct fspinit_rtbuf {
+	struct common_buf	common;	/* FSP common runtime data structure */
+};
+
 #endif /* __FSP_CONFIGS_H__ */
arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h +4 -0
index 2397553..f1da205 100644
@@ -14,4 +14,8 @@ struct fsp_config_data {
 	struct upd_region	fsp_upd;
 };
 
+struct fspinit_rtbuf {
+	struct common_buf	common;	/* FSP common runtime data structure */
+};
+
 #endif /* __FSP_CONFIGS_H__ */
arch/x86/include/asm/fsp/fsp_platform.h deleted +0 -15
deleted file mode 100644
index 61286ce..0000000
@@ -1,15 +0,0 @@
-/*
- * Copyright (C) 2013, Intel Corporation
- * Copyright (C) 2014, Bin Meng <[email protected]>
- *
- * SPDX-License-Identifier:	Intel
- */
-
-#ifndef __FSP_PLATFORM_H__
-#define __FSP_PLATFORM_H__
-
-struct fspinit_rtbuf {
-	struct common_buf	common;	/* FSP common runtime data structure */
-};
-
-#endif
arch/x86/include/asm/fsp/fsp_support.h +0 -1
index 67741cc..e65a130 100644
@@ -13,7 +13,6 @@
 #include "fsp_ffs.h"
 #include "fsp_api.h"
 #include "fsp_hob.h"
-#include "fsp_platform.h"
 #include "fsp_infoheader.h"
 #include "fsp_bootmode.h"
 #include <asm/arch/fsp/fsp_vpd.h>
Signature · 1 line
1.8.2.1
#16 lore raw

PATCH 6/8 x86: fsp: Move struct fspinit_rtbuf definition to chipset header

Quoted 8 lines · Bin Meng

All FSP spec v1.0 complaint FSP binary uses struct fspinit_rtbuf as defined by the 1.0 spec, however there are FSPs that does not follow 1.0 spec (possible due to that FSP predates the 1.0 spec), and future FSP binary that is complaint to v1.1 spec defines an optional paltform-specific runtime data in the struct fspinit_rtbuf. Hence move the definition to chipset header.

Quoted 8 lines

---

 arch/x86/include/asm/arch-baytrail/fsp/fsp_configs.h  |  4 ++++
 arch/x86/include/asm/arch-queensbay/fsp/fsp_configs.h |  4 ++++
 arch/x86/include/asm/fsp/fsp_platform.h               | 15 ---------------
 arch/x86/include/asm/fsp/fsp_support.h                |  1 -
 4 files changed, 8 insertions(+), 16 deletions(-)
 delete mode 100644 arch/x86/include/asm/fsp/fsp_platform.h
author
#17 lore raw

PATCH 7/8 x86: fsp: Move VPD/UPD verification to update_fsp_configs()

In reply to Bin Meng

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.

---

 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(-)
arch/x86/cpu/baytrail/fsp_configs.c +23 -1
index 9810921..3a03392 100644
@@ -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);
arch/x86/cpu/queensbay/fsp_configs.c +25 -1
index f84ae30..96ec116 100644
@@ -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 */
arch/x86/include/asm/fsp/fsp_support.h +3 -1
index e65a130..61d811f 100644
@@ -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
arch/x86/lib/fsp/fsp_support.c +1 -23
index faca93e..c386b75 100644
@@ -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;
Signature · 1 line
1.8.2.1
#18 lore raw

PATCH 7/8 x86: fsp: Move VPD/UPD verification to update_fsp_configs()

Hi Bin,

Quoted 42 lines · Bin Meng

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.

---

 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(-)
arch/x86/cpu/baytrail/fsp_configs.c +13 -1
index 9810921..3a03392 100644
@@ -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);
+

arch/x86/cpu/baytrail/fsp_configs.c const struct pch_azalia_config azalia_config = { · line 156

Quoted 10 lines
arch/x86/cpu/baytrail/fsp_configs.c +10 -0
+       /* 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);
+

Maybe rather than duplicating this code, it can go in a common function that is called for these two boards?

Quoted 107 lines
arch/x86/cpu/baytrail/fsp_configs.c +0 -0
        fsp_upd->azalia_config_ptr = (uint32_t)&azalia_config;
 
        node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_BAYTRAIL_FSP);
arch/x86/cpu/queensbay/fsp_configs.c +25 -1
index f84ae30..96ec116 100644
@@ -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 */
arch/x86/include/asm/fsp/fsp_support.h +3 -1
index e65a130..61d811f 100644
@@ -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
arch/x86/lib/fsp/fsp_support.c +1 -24
index faca93e..c386b75 100644
@@ -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;
--
Quoted 2 lines

1.8.2.1

Regards,
Simon

author
#19 lore raw

PATCH 7/8 x86: fsp: Move VPD/UPD verification to update_fsp_configs()

Hi Simon,

Quoted 50 lines · Simon Glass

Hi Bin,

Quoted 47 lines · Bin Meng

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.

---

 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(-)
arch/x86/cpu/baytrail/fsp_configs.c +18 -1
index 9810921..3a03392 100644
@@ -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),
Quoted 9 lines

arch/x86/cpu/baytrail/fsp_configs.c const struct pch_azalia_config azalia_config = { · line 156

Quoted 5 lines
arch/x86/cpu/baytrail/fsp_configs.c +5 -0
+              sizeof(struct upd_region));
+
+       /* Verify the UPD data region is valid */
+       assert(fsp_upd->terminator == UPD_TERMINATOR);
+

Maybe rather than duplicating this code, it can go in a common function that is called for these two boards?

Yes, we can create a common function to do these, but that requires we create a Kconfig option something like CONFIG_FSP_USE_UPD or CONFIG_FSP_NO_UPD to wrap these codes in arch/x86/lib/fsp_support.c. I don't want to create a Kconfig option so chose to duplicate the codes. What do you think?

[snip]

Regards,
Bin

#20 lore raw

PATCH 7/8 x86: fsp: Move VPD/UPD verification to update_fsp_configs()

Hi Bin,

Quoted 63 lines · Bin Meng

Hi Simon,

Quoted 50 lines · Simon Glass

Hi Bin,

Quoted 47 lines · Bin Meng

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.

---

 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(-)
arch/x86/cpu/baytrail/fsp_configs.c +18 -1
index 9810921..3a03392 100644
@@ -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),
Quoted 9 lines

arch/x86/cpu/baytrail/fsp_configs.c const struct pch_azalia_config azalia_config = { · line 156

Quoted 5 lines
arch/x86/cpu/baytrail/fsp_configs.c +5 -0
+              sizeof(struct upd_region));
+
+       /* Verify the UPD data region is valid */
+       assert(fsp_upd->terminator == UPD_TERMINATOR);
+

Maybe rather than duplicating this code, it can go in a common function that is called for these two boards?

Quoted 5 lines

Yes, we can create a common function to do these, but that requires we create a Kconfig option something like CONFIG_FSP_USE_UPD or CONFIG_FSP_NO_UPD to wrap these codes in arch/x86/lib/fsp_support.c. I don't want to create a Kconfig option so chose to duplicate the codes. What do you think?

Well I dislike duplicated code more, so I think CONFIG_FSP_USE_UPD might be best.

Quoted 5 lines

[snip]

Regards,
Bin

Regards,
Simon

author
#21 lore raw

PATCH 8/8 x86: queensbay: Remove invalid comments in update_fsp_upd()

In reply to Bin Meng

Those comments in update_fsp_upd() are not correct. Remove them.

---

 arch/x86/cpu/queensbay/fsp_configs.c | 6 ------
 1 file changed, 6 deletions(-)
arch/x86/cpu/queensbay/fsp_configs.c +0 -6
index 96ec116..faa79d1 100644
@@ -35,10 +35,4 @@ void update_fsp_configs(struct fsp_config_data *config,
 	assert(fsp_upd->terminator == UPD_TERMINATOR);
 
 	/* Override any UPD setting if required */
-
-	/* Uncomment the line below to enable DEBUG message */
-	/* fsp_upd->serial_dbgport_type = 1; */
-
-	/* Examples on how to initialize the pointers in UPD region */
-	/* fsp_upd->pcd_example = (EXAMPLE_DATA *)&example; */
 }
Signature · 1 line
1.8.2.1