Skip to content

Commit 973ac05

Browse files
kboot: pmp initialization
Copy all the things that PMP needs in order to boot. Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
1 parent 1924a83 commit 973ac05

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/kboot.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,53 @@ static int dt_set_display(void)
19841984
return dt_vram_reserved_region("dcp", "disp0");
19851985
}
19861986

1987+
static int dt_set_pmp(void)
1988+
{
1989+
const char *path = fdt_get_alias(dt, "pmp");
1990+
if (path == NULL) {
1991+
printf("FDT: pmp alias not found in devtree\n");
1992+
return 0;
1993+
}
1994+
1995+
int chosen_anode = adt_path_offset(adt, "/chosen");
1996+
if (chosen_anode < 0)
1997+
bail("ADT: /chosen not found \n");
1998+
int pmp_iop_anode = adt_path_offset(adt, "/arm-io/pmp/iop-pmp-nub");
1999+
if (pmp_iop_anode < 0)
2000+
bail("ADT: /arm-io/pmp/iop-pmp-nub not found \n");
2001+
2002+
u32 board_id, dram_vendor_id, dram_capacity;
2003+
if (ADT_GETPROP(adt, chosen_anode, "board-id", &board_id) < 0)
2004+
bail("ADT: failed to get board id\n");
2005+
if (ADT_GETPROP(adt, chosen_anode, "dram-vendor-id", &dram_vendor_id) < 0)
2006+
bail("ADT: failed to get dram vendor id\n");
2007+
if (ADT_GETPROP(adt, pmp_iop_anode, "dram-capacity", &dram_capacity) < 0)
2008+
bail("ADT: failed to get dram capacity\n");
2009+
2010+
int pmp_node = fdt_path_offset(dt, path);
2011+
if (pmp_node < 0)
2012+
bail("FDT: pmp not not found in devtree\n");
2013+
if (fdt_setprop_u32(dt, pmp_node, "apple,board-id", board_id))
2014+
bail("FDT: failed to set board id\n");
2015+
if (fdt_setprop_u32(dt, pmp_node, "apple,dram-vendor-id", dram_vendor_id))
2016+
bail("FDT: failed to set dram vendor id\n");
2017+
if (fdt_setprop_u32(dt, pmp_node, "apple,dram-capacity", dram_capacity))
2018+
bail("FDT: failed to set dram capacity\n");
2019+
2020+
int tunables_node = fdt_subnode_offset(dt, pmp_node, "tunables");
2021+
if (tunables_node < 0)
2022+
bail("FDT: pmp tunables not not found in devtree\n");
2023+
2024+
ADT_FOREACH_PROPERTY(adt, pmp_iop_anode, prop)
2025+
{
2026+
if (!strcmp(prop->name, "compatible") || !strcmp(prop->name, "AAPL,phandle"))
2027+
continue;
2028+
if (fdt_setprop(dt, tunables_node, prop->name, prop->value, prop->size))
2029+
bail("FDT: failed to transfer pmp tunable");
2030+
}
2031+
return 0;
2032+
}
2033+
19872034
static int dt_set_sep(void)
19882035
{
19892036
const char *path = fdt_get_alias(dt, "sep");
@@ -2685,6 +2732,8 @@ int kboot_prepare_dt(void *fdt)
26852732
return -1;
26862733
if (dt_set_sep())
26872734
return -1;
2735+
if (dt_set_pmp())
2736+
return -1;
26882737
if (dt_set_nvram())
26892738
return -1;
26902739
if (dt_set_ipd())

0 commit comments

Comments
 (0)