|
1 | 1 | /* SPDX-License-Identifier: MIT */ |
2 | 2 |
|
| 3 | +#include <stdint.h> |
| 4 | + |
3 | 5 | #include "kboot.h" |
4 | 6 | #include "adt.h" |
5 | 7 | #include "assert.h" |
@@ -884,6 +886,22 @@ static int dt_set_atc_tunables(void) |
884 | 886 | return 0; |
885 | 887 | } |
886 | 888 |
|
| 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 | + |
887 | 905 | static dart_dev_t *dt_init_dart_by_node(int node, u32 num) |
888 | 906 | { |
889 | 907 | int len; |
@@ -1118,6 +1136,20 @@ static int dt_carveout_reserved_regions(const char *dcp_alias, const char *disp_ |
1118 | 1136 | } |
1119 | 1137 | } |
1120 | 1138 |
|
| 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 | + } |
1121 | 1153 | err: |
1122 | 1154 | if (dart_dcp) |
1123 | 1155 | dart_shutdown(dart_dcp); |
|
0 commit comments