soc/intel/common: refactor locate_vbt and vbt_get

Instead of having all callers provide a region_device just for the
purpose of reading vbt.bin, let locate_vbt handle its entire life cycle,
simplifying the VBT access API.

Change-Id: Ib85e55164e217050b67674d020d17b2edf5ad14d
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/21897
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Patrick Georgi 2017-10-05 18:10:09 +02:00
parent cba7316c26
commit 9d3de2649f
6 changed files with 28 additions and 30 deletions

View File

@ -96,10 +96,7 @@ enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer)
uintptr_t fsp_load_vbt(void)
{
struct region_device rdev;
void *vbt_data = NULL;
vbt_data = locate_vbt(&rdev);
void *vbt_data = locate_vbt();
if (vbt_data == NULL)
printk(BIOS_NOTICE, "Could not locate a VBT file in CBFS\n");

View File

@ -49,7 +49,6 @@
#include "chip.h"
static void *vbt;
static struct region_device vbt_rdev;
static const char *soc_acpi_name(const struct device *dev)
{
@ -317,7 +316,7 @@ static void soc_init(void *data)
struct global_nvs_t *gnvs;
/* Save VBT info and mapping */
vbt = vbt_get(&vbt_rdev);
vbt = vbt_get();
/* Snapshot the current GPIO IRQ polarities. FSP is setting a
* default policy that doesn't honor boards' requirements. */
@ -354,9 +353,6 @@ static void soc_init(void *data)
static void soc_final(void *data)
{
if (vbt)
rdev_munmap(&vbt_rdev, vbt);
/* Disable global reset, just in case */
pmc_global_reset_enable(0);
/* Make sure payload/OS can't trigger global reset */

View File

@ -26,7 +26,6 @@
#include <string.h>
static void *vbt;
static struct region_device vbt_rdev;
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
static const char *soc_acpi_name(const struct device *dev)
@ -164,17 +163,10 @@ static void soc_enable(device_t dev)
dev->ops = &cpu_bus_ops;
}
static void soc_final(void *data)
{
if (vbt)
rdev_munmap(&vbt_rdev, vbt);
}
struct chip_operations soc_intel_cannonlake_ops = {
CHIP_NAME("Intel Cannonlake")
.enable_dev = &soc_enable,
.init = &soc_init_pre_device,
.final = &soc_final
};
/* UPD parameters to be initialized before SiliconInit */
@ -189,7 +181,7 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd)
parse_devicetree(params);
/* Save VBT info and mapping */
vbt = vbt_get(&vbt_rdev);
vbt = vbt_get();
/* Load VBT before devicetree-specific config. */
params->GraphicsConfigPtr = (uintptr_t)vbt;

View File

@ -23,11 +23,10 @@
enum cb_err init_igd_opregion(igd_opregion_t *opregion)
{
struct region_device vbt_rdev;
optionrom_vbt_t *vbt;
optionrom_vbt_t *ext_vbt;
vbt = locate_vbt(&vbt_rdev);
vbt = locate_vbt();
if (!vbt) {
printk(BIOS_ERR, "VBT couldn't be read\n");
@ -64,7 +63,5 @@ enum cb_err init_igd_opregion(igd_opregion_t *opregion)
/* FIXME We just assume we're mobile for now */
opregion->header.mailboxes = MAILBOXES_MOBILE;
rdev_munmap(&vbt_rdev, vbt);
return CB_SUCCESS;
}

View File

@ -17,6 +17,7 @@
#include <console/console.h>
#include <arch/acpi.h>
#include <bootmode.h>
#include <bootstate.h>
#include "vbt.h"
@ -28,11 +29,17 @@ const char *mainboard_vbt_filename(void)
return "vbt.bin";
}
void *locate_vbt(struct region_device *rdev)
static struct region_device vbt_rdev;
static void *vbt_data;
void *locate_vbt(void)
{
uint32_t vbtsig = 0;
struct cbfsf file_desc;
if (vbt_data != NULL)
return vbt_data;
const char *filename = mainboard_vbt_filename();
if (cbfs_boot_locate(&file_desc, filename, NULL) < 0) {
@ -40,18 +47,19 @@ void *locate_vbt(struct region_device *rdev)
return NULL;
}
cbfs_file_data(rdev, &file_desc);
rdev_readat(rdev, &vbtsig, 0, sizeof(uint32_t));
cbfs_file_data(&vbt_rdev, &file_desc);
rdev_readat(&vbt_rdev, &vbtsig, 0, sizeof(uint32_t));
if (vbtsig != VBT_SIGNATURE) {
printk(BIOS_ERR, "Missing/invalid signature in VBT data file!\n");
return NULL;
}
return rdev_mmap_full(rdev);
vbt_data = rdev_mmap_full(&vbt_rdev);
return vbt_data;
}
void *vbt_get(struct region_device *rdev)
void *vbt_get(void)
{
if (!IS_ENABLED(CONFIG_RUN_FSP_GOP))
return NULL;
@ -62,5 +70,13 @@ void *vbt_get(struct region_device *rdev)
return NULL;
if (!display_init_required())
return NULL;
return locate_vbt(rdev);
return locate_vbt();
}
static void unmap_vbt(void *unused)
{
if (vbt_data)
rdev_munmap(&vbt_rdev, vbt_data);
}
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, unmap_vbt, NULL);
BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, unmap_vbt, NULL);

View File

@ -28,10 +28,10 @@
const char *mainboard_vbt_filename(void);
/* locate vbt.bin file. Returns a pointer to its content. */
void *locate_vbt(struct region_device *rdev);
void *locate_vbt(void);
/*
* Returns VBT pointer and mapping after checking prerequisites for Pre OS
* Graphics initialization
*/
void *vbt_get(struct region_device *rdev);
void *vbt_get(void);
#endif