summaryrefslogtreecommitdiff
path: root/src/mainboard/google
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-03-28 23:56:22 -0500
committerAaron Durbin <adurbin@chromium.org>2015-05-26 22:33:53 +0200
commit0424c95a6dafdb65070538d6c5aa394b75eb9850 (patch)
treef5bd9f485a1a44eece1662a29c1435a44ab5c58a /src/mainboard/google
parentb6981c0f9c4ce89c4209c14fb326a414096f2ff1 (diff)
downloadcoreboot-0424c95a6dafdb65070538d6c5aa394b75eb9850.tar.xz
fmap: new API using region_device
Instead of being pointer based use the region infrastrucutre. Additionally, this removes the need for arch-specific compilation paths. The users of the new API can use the region APIs to memory map or read the region provided by the new fmap API. Change-Id: Ie36e9ff9cb554234ec394b921f029eeed6845aee Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/9170 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/mainboard/google')
-rw-r--r--src/mainboard/google/butterfly/mainboard.c41
-rw-r--r--src/mainboard/google/panther/lan.c25
2 files changed, 41 insertions, 25 deletions
diff --git a/src/mainboard/google/butterfly/mainboard.c b/src/mainboard/google/butterfly/mainboard.c
index bd2fbd5218..e09336d675 100644
--- a/src/mainboard/google/butterfly/mainboard.c
+++ b/src/mainboard/google/butterfly/mainboard.c
@@ -20,11 +20,13 @@
#include <types.h>
#include <string.h>
+#include <cbfs.h>
#include <device/device.h>
#include <device/pci_def.h>
#include <device/pci_ops.h>
#include <console/console.h>
#include <drivers/intel/gma/int15.h>
+#include <fmap.h>
#include <pc80/mc146818rtc.h>
#include <arch/acpi.h>
#include <arch/io.h>
@@ -36,11 +38,6 @@
#include <smbios.h>
#include <device/pci.h>
#include <ec/quanta/ene_kb3940q/ec.h>
-#if CONFIG_CHROMEOS
-#include <vendorcode/google/chromeos/fmap.h>
-#else
-#include <cbfs.h>
-#endif
static unsigned int search(char *p, char *a, unsigned int lengthp,
unsigned int lengtha)
@@ -200,20 +197,30 @@ static void mainboard_init(device_t dev)
size_t search_length = -1;
u16 io_base = 0;
struct device *ethernet_dev = NULL;
-#if CONFIG_CHROMEOS
- char **vpd_region_ptr = NULL;
- search_length = find_fmap_entry("RO_VPD", (void **)vpd_region_ptr);
- search_address = (unsigned long)(*vpd_region_ptr);
-#else
- void *vpd_file = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, "vpd.bin",
- CBFS_TYPE_RAW, &search_length);
- if (vpd_file) {
- search_address = (unsigned long)vpd_file;
+ void *vpd_file;
+
+ if (IS_ENABLED(CONFIG_CHROMEOS)) {
+ struct region_device rdev;
+
+ if (fmap_locate_area_as_rdev("RO_VPD", &rdev) == 0) {
+ vpd_file = rdev_mmap_full(&rdev);
+
+ if (vpd_file != NULL) {
+ search_length = region_device_sz(&rdev);
+ search_address = (uintptr_t)vpd_file;
+ }
+ }
} else {
- search_length = -1;
- search_address = 0;
+ vpd_file = cbfs_get_file_content(CBFS_DEFAULT_MEDIA,
+ "vpd.bin", CBFS_TYPE_RAW,
+ &search_length);
+ if (vpd_file) {
+ search_address = (unsigned long)vpd_file;
+ } else {
+ search_length = -1;
+ search_address = 0;
+ }
}
-#endif
/* Initialize the Embedded Controller */
butterfly_ec_init();
diff --git a/src/mainboard/google/panther/lan.c b/src/mainboard/google/panther/lan.c
index 9fd325f5d2..8a648cb250 100644
--- a/src/mainboard/google/panther/lan.c
+++ b/src/mainboard/google/panther/lan.c
@@ -24,8 +24,8 @@
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
+#include <fmap.h>
#include <southbridge/intel/bd82x6x/pch.h>
-#include <vendorcode/google/chromeos/fmap.h>
#include "onboard.h"
static unsigned int search(char *p, u8 *a, unsigned int lengthp,
@@ -117,15 +117,24 @@ static void program_mac_address(u16 io_base)
u32 high_dword = 0xD0BA00A0; /* high dword of mac address */
u32 low_dword = 0x0000AD0B; /* low word of mac address as a dword */
-#if CONFIG_CHROMEOS
- search_length = find_fmap_entry("RO_VPD", &search_address);
-#else
- search_address = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, "vpd.bin",
- CBFS_TYPE_RAW, &search_length);
-#endif
+ if (IS_ENABLED(CONFIG_CHROMEOS)) {
+ struct region_device rdev;
+
+ if (fmap_locate_area_as_rdev("RO_VPD", &rdev) == 0) {
+ search_address = rdev_mmap_full(&rdev);
+
+ if (search_address != NULL)
+ search_length = region_device_sz(&rdev);
+ }
+ } else {
+ search_address = cbfs_get_file_content(CBFS_DEFAULT_MEDIA,
+ "vpd.bin",
+ CBFS_TYPE_RAW,
+ &search_length);
+ }
if (search_length <= 0)
- printk(BIOS_ERR, "LAN: find_fmap_entry returned -1.\n");
+ printk(BIOS_ERR, "LAN: VPD not found.\n");
else
get_mac_address(&high_dword, &low_dword, search_address,
search_length);