diff options
author | Wolfgang Denk <wd@denx.de> | 2009-10-24 22:25:08 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-10-24 22:25:08 +0200 |
commit | 4ee63268152594bb7af6bec2b59d53bba68082bf (patch) | |
tree | 9232060ebf7ec2aff40f007cbf099e9a58a8a96a /common/fdt_support.c | |
parent | 62506ae1401c69f208b6aed1111ac57d820c06a0 (diff) | |
parent | cfc25874624a328f53ad59b1206e2103f2e62d74 (diff) | |
download | u-boot-imx-4ee63268152594bb7af6bec2b59d53bba68082bf.zip u-boot-imx-4ee63268152594bb7af6bec2b59d53bba68082bf.tar.gz u-boot-imx-4ee63268152594bb7af6bec2b59d53bba68082bf.tar.bz2 |
Merge branch 'master' of git://git.denx.de/u-boot-ppc4xx
Diffstat (limited to 'common/fdt_support.c')
-rw-r--r-- | common/fdt_support.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c index 89164a1..40ff00a 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -692,3 +692,47 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose) { return 0; } #endif + +#ifdef CONFIG_FDT_FIXUP_NOR_FLASH_SIZE +/* + * This function can be used to update the size in the "reg" property + * of the NOR FLASH device nodes. This is necessary for boards with + * non-fixed NOR FLASH sizes. + */ +int fdt_fixup_nor_flash_size(void *blob, int cs, u32 size) +{ + char compat[][16] = { "cfi-flash", "jedec-flash" }; + int off; + int len; + struct fdt_property *prop; + u32 *reg; + int i; + + for (i = 0; i < 2; i++) { + off = fdt_node_offset_by_compatible(blob, -1, compat[i]); + while (off != -FDT_ERR_NOTFOUND) { + /* + * Found one compatible node, now check if this one + * has the correct CS + */ + prop = fdt_get_property_w(blob, off, "reg", &len); + if (prop) { + reg = (u32 *)&prop->data[0]; + if (reg[0] == cs) { + reg[2] = size; + fdt_setprop(blob, off, "reg", reg, + 3 * sizeof(u32)); + + return 0; + } + } + + /* Move to next compatible node */ + off = fdt_node_offset_by_compatible(blob, off, + compat[i]); + } + } + + return -1; +} +#endif |