mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-26 14:55:16 +00:00
Merge "fdt: Use proper #address-cells and #size-cells for reserved-memory" into integration
This commit is contained in:
commit
4a81a9f1be
1 changed files with 24 additions and 8 deletions
|
@ -188,6 +188,8 @@ int dt_add_psci_cpu_enable_methods(void *fdt)
|
||||||
*
|
*
|
||||||
* See reserved-memory/reserved-memory.txt in the (Linux kernel) DT binding
|
* See reserved-memory/reserved-memory.txt in the (Linux kernel) DT binding
|
||||||
* documentation for details.
|
* documentation for details.
|
||||||
|
* According to this binding, the address-cells and size-cells must match
|
||||||
|
* those of the root node.
|
||||||
*
|
*
|
||||||
* Return: 0 on success, a negative error value otherwise.
|
* Return: 0 on success, a negative error value otherwise.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -195,23 +197,37 @@ int fdt_add_reserved_memory(void *dtb, const char *node_name,
|
||||||
uintptr_t base, size_t size)
|
uintptr_t base, size_t size)
|
||||||
{
|
{
|
||||||
int offs = fdt_path_offset(dtb, "/reserved-memory");
|
int offs = fdt_path_offset(dtb, "/reserved-memory");
|
||||||
uint32_t addresses[3];
|
uint32_t addresses[4];
|
||||||
|
int ac, sc;
|
||||||
|
unsigned int idx = 0;
|
||||||
|
|
||||||
|
ac = fdt_address_cells(dtb, 0);
|
||||||
|
sc = fdt_size_cells(dtb, 0);
|
||||||
if (offs < 0) { /* create if not existing yet */
|
if (offs < 0) { /* create if not existing yet */
|
||||||
offs = fdt_add_subnode(dtb, 0, "reserved-memory");
|
offs = fdt_add_subnode(dtb, 0, "reserved-memory");
|
||||||
if (offs < 0)
|
if (offs < 0) {
|
||||||
return offs;
|
return offs;
|
||||||
fdt_setprop_u32(dtb, offs, "#address-cells", 2);
|
}
|
||||||
fdt_setprop_u32(dtb, offs, "#size-cells", 1);
|
fdt_setprop_u32(dtb, offs, "#address-cells", ac);
|
||||||
|
fdt_setprop_u32(dtb, offs, "#size-cells", sc);
|
||||||
fdt_setprop(dtb, offs, "ranges", NULL, 0);
|
fdt_setprop(dtb, offs, "ranges", NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
addresses[0] = cpu_to_fdt32(HIGH_BITS(base));
|
if (ac > 1) {
|
||||||
addresses[1] = cpu_to_fdt32(base & 0xffffffff);
|
addresses[idx] = cpu_to_fdt32(HIGH_BITS(base));
|
||||||
addresses[2] = cpu_to_fdt32(size & 0xffffffff);
|
idx++;
|
||||||
|
}
|
||||||
|
addresses[idx] = cpu_to_fdt32(base & 0xffffffff);
|
||||||
|
idx++;
|
||||||
|
if (sc > 1) {
|
||||||
|
addresses[idx] = cpu_to_fdt32(HIGH_BITS(size));
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
addresses[idx] = cpu_to_fdt32(size & 0xffffffff);
|
||||||
|
idx++;
|
||||||
offs = fdt_add_subnode(dtb, offs, node_name);
|
offs = fdt_add_subnode(dtb, offs, node_name);
|
||||||
fdt_setprop(dtb, offs, "no-map", NULL, 0);
|
fdt_setprop(dtb, offs, "no-map", NULL, 0);
|
||||||
fdt_setprop(dtb, offs, "reg", addresses, 12);
|
fdt_setprop(dtb, offs, "reg", addresses, idx * sizeof(uint32_t));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue