summaryrefslogtreecommitdiff
path: root/common/fdt_support.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-03-06 07:25:04 -0500
committerTom Rini <trini@konsulko.com>2021-03-06 07:25:04 -0500
commite4dba4ba6f61e8128be0b4200ca2d8cebf62180b (patch)
tree9f2877b1278093a579247756fdfd7fbe1055f63c /common/fdt_support.c
parent6a026e5649f00c0b157a935279dfd625889db675 (diff)
parentb75ca06836567a467b8b5a9ee8ce0a8efde45e08 (diff)
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
- Convert qemu-ppce500 to driver model and enable additional driver support - bug fixes/updates in net-dsa driver, vid driver, move configs to kconfig - Update Maintainers of some powerpc, layerscape platforms
Diffstat (limited to 'common/fdt_support.c')
-rw-r--r--common/fdt_support.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 08d540bfc85..e624bbdf404 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1668,22 +1668,36 @@ u64 fdt_get_base_address(const void *fdt, int node)
}
/*
- * Read a property of size <prop_len>. Currently only supports 1 or 2 cells.
+ * Read a property of size <prop_len>. Currently only supports 1 or 2 cells,
+ * or 3 cells specially for a PCI address.
*/
static int fdt_read_prop(const fdt32_t *prop, int prop_len, int cell_off,
uint64_t *val, int cells)
{
- const fdt32_t *prop32 = &prop[cell_off];
- const unaligned_fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off];
+ const fdt32_t *prop32;
+ const unaligned_fdt64_t *prop64;
if ((cell_off + cells) > prop_len)
return -FDT_ERR_NOSPACE;
+ prop32 = &prop[cell_off];
+
+ /*
+ * Special handling for PCI address in PCI bus <ranges>
+ *
+ * PCI child address is made up of 3 cells. Advance the cell offset
+ * by 1 so that the PCI child address can be correctly read.
+ */
+ if (cells == 3)
+ cell_off += 1;
+ prop64 = (const fdt64_t *)&prop[cell_off];
+
switch (cells) {
case 1:
*val = fdt32_to_cpu(*prop32);
break;
case 2:
+ case 3:
*val = fdt64_to_cpu(*prop64);
break;
default: