aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/lib
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2015-10-11 21:37:41 -0700
committerSimon Glass <sjg@chromium.org>2015-10-21 07:46:27 -0600
commit4b9f6a669ee22ac4694a3a339e94e8fe30bfad1f (patch)
tree578229c582254b2dd27d00bc83b7e79eacff9695 /arch/x86/lib
parent42913a1c7ad6efae598364f5ea1ae083279b571f (diff)
downloadu-boot-4b9f6a669ee22ac4694a3a339e94e8fe30bfad1f.zip
u-boot-4b9f6a669ee22ac4694a3a339e94e8fe30bfad1f.tar.gz
u-boot-4b9f6a669ee22ac4694a3a339e94e8fe30bfad1f.tar.bz2
x86: Use struct mrc_region to describe a mrc region
Currently struct fmap_entry is used to describe a mrc region. However this structure contains some other fields that are not related to mrc cache and causes confusion. Besides, it does not include a base address field to store SPI flash's base address. Instead in the mrccache.c it tries to use CONFIG_ROM_SIZE to calculate the SPI flash base address, which unfortunately is not 100% correct as CONFIG_ROM_SIZE may not match the whole SPI flash size. Define a new struct mrc_region and use it instead. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/x86/lib')
-rw-r--r--arch/x86/lib/mrccache.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index 0efae6d..53a1259 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -40,13 +40,13 @@ static int is_mrc_cache(struct mrc_data_container *cache)
return cache && (cache->signature == MRC_DATA_SIGNATURE);
}
-struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry)
+struct mrc_data_container *mrccache_find_current(struct mrc_region *entry)
{
struct mrc_data_container *cache, *next;
ulong base_addr, end_addr;
uint id;
- base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
+ base_addr = entry->base + entry->offset;
end_addr = base_addr + entry->length;
cache = NULL;
@@ -85,12 +85,12 @@ struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry)
*
* @return next cache entry if found, NULL if we got to the end
*/
-static struct mrc_data_container *find_next_mrc_cache(struct fmap_entry *entry,
+static struct mrc_data_container *find_next_mrc_cache(struct mrc_region *entry,
struct mrc_data_container *cache)
{
ulong base_addr, end_addr;
- base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
+ base_addr = entry->base + entry->offset;
end_addr = base_addr + entry->length;
cache = next_mrc_block(cache);
@@ -106,7 +106,7 @@ static struct mrc_data_container *find_next_mrc_cache(struct fmap_entry *entry,
return cache;
}
-int mrccache_update(struct udevice *sf, struct fmap_entry *entry,
+int mrccache_update(struct udevice *sf, struct mrc_region *entry,
struct mrc_data_container *cur)
{
struct mrc_data_container *cache;
@@ -118,7 +118,7 @@ int mrccache_update(struct udevice *sf, struct fmap_entry *entry,
return -EINVAL;
/* Find the last used block */
- base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
+ base_addr = entry->base + entry->offset;
debug("Updating MRC cache data\n");
cache = mrccache_find_current(entry);
if (cache && (cache->data_size == cur->data_size) &&
@@ -189,10 +189,11 @@ int mrccache_reserve(void)
return 0;
}
-int mrccache_get_region(struct udevice **devp, struct fmap_entry *entry)
+int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
{
const void *blob = gd->fdt_blob;
int node, mrc_node;
+ u32 reg[2];
int ret;
/* Find the flash chip within the SPI controller node */
@@ -200,13 +201,19 @@ int mrccache_get_region(struct udevice **devp, struct fmap_entry *entry)
if (node < 0)
return -ENOENT;
+ if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2))
+ return -FDT_ERR_NOTFOUND;
+ entry->base = reg[0];
+
/* Find the place where we put the MRC cache */
mrc_node = fdt_subnode_offset(blob, node, "rw-mrc-cache");
if (mrc_node < 0)
return -EPERM;
- if (fdtdec_read_fmap_entry(blob, mrc_node, "rm-mrc-cache", entry))
- return -EINVAL;
+ if (fdtdec_get_int_array(blob, mrc_node, "reg", reg, 2))
+ return -FDT_ERR_NOTFOUND;
+ entry->offset = reg[0];
+ entry->length = reg[1];
if (devp) {
ret = uclass_get_device_by_of_offset(UCLASS_SPI_FLASH, node,
@@ -222,7 +229,7 @@ int mrccache_get_region(struct udevice **devp, struct fmap_entry *entry)
int mrccache_save(void)
{
struct mrc_data_container *data;
- struct fmap_entry entry;
+ struct mrc_region entry;
struct udevice *sf;
int ret;