mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 21:51:31 +00:00
x86: Adjust mrccache_get_region() to use livetree
Change the algorithm to first find the flash device then read the properties using the livetree API. With this change the device is not probed so this needs to be done in mrccache_save(). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
0ad9b6a988
commit
87f1084a63
1 changed files with 26 additions and 29 deletions
|
@ -14,6 +14,8 @@
|
||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
#include <spi_flash.h>
|
#include <spi_flash.h>
|
||||||
#include <asm/mrccache.h>
|
#include <asm/mrccache.h>
|
||||||
|
#include <dm/device-internal.h>
|
||||||
|
#include <dm/uclass-internal.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
@ -206,45 +208,37 @@ int mrccache_reserve(void)
|
||||||
|
|
||||||
int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
|
int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
|
||||||
{
|
{
|
||||||
const void *blob = gd->fdt_blob;
|
struct udevice *dev;
|
||||||
int node, mrc_node;
|
ofnode mrc_node;
|
||||||
u32 reg[2];
|
u32 reg[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Find the flash chip within the SPI controller node */
|
/*
|
||||||
node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
|
* Find the flash chip within the SPI controller node. Avoid probing
|
||||||
if (node < 0) {
|
* the device here since it may put it into a strange state where the
|
||||||
debug("%s: Cannot find SPI flash\n", __func__);
|
* memory map cannot be read.
|
||||||
return -ENOENT;
|
*/
|
||||||
}
|
ret = uclass_find_first_device(UCLASS_SPI_FLASH, &dev);
|
||||||
|
if (ret)
|
||||||
if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2)) {
|
return log_msg_ret("Cannot find SPI flash\n", ret);
|
||||||
debug("%s: Cannot find memory map\n", __func__);
|
ret = dev_read_u32_array(dev, "memory-map", reg, 2);
|
||||||
return -EINVAL;
|
if (ret)
|
||||||
}
|
return log_msg_ret("Cannot find memory map\n", ret);
|
||||||
entry->base = reg[0];
|
entry->base = reg[0];
|
||||||
|
|
||||||
/* Find the place where we put the MRC cache */
|
/* Find the place where we put the MRC cache */
|
||||||
mrc_node = fdt_subnode_offset(blob, node, "rw-mrc-cache");
|
mrc_node = dev_read_subnode(dev, "rw-mrc-cache");
|
||||||
if (mrc_node < 0) {
|
if (!ofnode_valid(mrc_node))
|
||||||
debug("%s: Cannot find node\n", __func__);
|
return log_msg_ret("Cannot find node", -EPERM);
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fdtdec_get_int_array(blob, mrc_node, "reg", reg, 2)) {
|
ret = ofnode_read_u32_array(mrc_node, "reg", reg, 2);
|
||||||
debug("%s: Cannot find address\n", __func__);
|
if (ret)
|
||||||
return -EINVAL;
|
return log_msg_ret("Cannot find address", ret);
|
||||||
}
|
|
||||||
entry->offset = reg[0];
|
entry->offset = reg[0];
|
||||||
entry->length = reg[1];
|
entry->length = reg[1];
|
||||||
|
|
||||||
if (devp) {
|
if (devp)
|
||||||
ret = uclass_get_device_by_of_offset(UCLASS_SPI_FLASH, node,
|
*devp = dev;
|
||||||
devp);
|
|
||||||
debug("ret = %d\n", ret);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -262,6 +256,9 @@ int mrccache_save(void)
|
||||||
gd->arch.mrc_output_len);
|
gd->arch.mrc_output_len);
|
||||||
|
|
||||||
ret = mrccache_get_region(&sf, &entry);
|
ret = mrccache_get_region(&sf, &entry);
|
||||||
|
if (ret)
|
||||||
|
goto err_entry;
|
||||||
|
ret = device_probe(sf);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_entry;
|
goto err_entry;
|
||||||
data = (struct mrc_data_container *)gd->arch.mrc_output;
|
data = (struct mrc_data_container *)gd->arch.mrc_output;
|
||||||
|
|
Loading…
Add table
Reference in a new issue