Skip to content

Commit ba1dfab

Browse files
jannaumarcan
authored andcommitted
kboot: Enable dart-disp0 as part of the display setup
Devicetrees with dart-disp0 will have it disabled to avoid breaking scanout off the boot framebuffer when booting via m1n1 version which does not lock dart-disp0. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent de0c032 commit ba1dfab

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/kboot.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-License-Identifier: MIT */
22

3+
#include <stdint.h>
4+
35
#include "kboot.h"
46
#include "adt.h"
57
#include "assert.h"
@@ -884,6 +886,22 @@ static int dt_set_atc_tunables(void)
884886
return 0;
885887
}
886888

889+
static int dt_get_iommu_node(int node, u32 num)
890+
{
891+
int len;
892+
assert(num < 32);
893+
const void *prop = fdt_getprop(dt, node, "iommus", &len);
894+
if (!prop || len < 0 || (u32)len < 8 * (num + 1)) {
895+
printf("FDT: unexpected 'iommus' prop / len %d\n", len);
896+
return -FDT_ERR_NOTFOUND;
897+
}
898+
899+
const fdt32_t *iommus = prop;
900+
uint32_t phandle = fdt32_ld(&iommus[num * 2]);
901+
902+
return fdt_node_offset_by_phandle(dt, phandle);
903+
}
904+
887905
static dart_dev_t *dt_init_dart_by_node(int node, u32 num)
888906
{
889907
int len;
@@ -1118,6 +1136,20 @@ static int dt_carveout_reserved_regions(const char *dcp_alias, const char *disp_
11181136
}
11191137
}
11201138

1139+
/* enable dart-disp0, it is disabled in device tree to avoid resetting
1140+
* it and breaking display scanout when booting with old m1n1 which
1141+
* does not lock dart-disp0.
1142+
*/
1143+
if (disp_alias) {
1144+
int disp_node = fdt_path_offset(dt, disp_alias);
1145+
1146+
int dart_disp0 = dt_get_iommu_node(disp_node, 0);
1147+
if (dart_disp0 < 0)
1148+
bail_cleanup("DT: failed to find 'dart-disp0'\n");
1149+
1150+
if (fdt_setprop_string(dt, dart_disp0, "status", "okay") < 0)
1151+
bail_cleanup("DT: failed to enable 'dart-disp0'\n");
1152+
}
11211153
err:
11221154
if (dart_dcp)
11231155
dart_shutdown(dart_dcp);

0 commit comments

Comments
 (0)