Commit d941a0bc9a3825c85c67707245b4f49ffe098864

Authored by Silvano di Ninno
Committed by Ye Li
1 parent 15ff24b142

TEE-329-2: OP-TEE: Allow u-boot to add optee node in dtb

If OP-TEE is loaded by ATF, u-boot will add
optee device tree node in th edtb so that
Linux can loads OP-TEE driver.

Signed-off-by: Silvano di Ninno <silvano.dininno@nxp.com>
(cherry picked from commit 441c23698ffd5c90c6421113da55fae420072473)

Showing 1 changed file with 49 additions and 0 deletions Side-by-side Diff

arch/arm/mach-imx/imx8/cpu.c
... ... @@ -1300,6 +1300,54 @@
1300 1300 #endif
1301 1301  
1302 1302 #ifdef CONFIG_OF_SYSTEM_SETUP
  1303 +static int ft_add_optee_node(void *fdt, bd_t *bd)
  1304 +{
  1305 + const char *path, *subpath;
  1306 + int offs;
  1307 +
  1308 + /*
  1309 + * No TEE space allocated indicating no TEE running, so no
  1310 + * need to add optee node in dts
  1311 + */
  1312 + if (!rom_pointer[1])
  1313 + return 0;
  1314 +
  1315 + offs = fdt_increase_size(fdt, 512);
  1316 + if (offs) {
  1317 + printf("No Space for dtb\n");
  1318 + return 1;
  1319 + }
  1320 +
  1321 + path = "/firmware";
  1322 + offs = fdt_path_offset(fdt, path);
  1323 + if (offs < 0) {
  1324 + path = "/";
  1325 + offs = fdt_path_offset(fdt, path);
  1326 +
  1327 + if (offs < 0) {
  1328 + printf("Could not find root node.\n");
  1329 + return 1;
  1330 + }
  1331 +
  1332 + subpath = "firmware";
  1333 + offs = fdt_add_subnode(fdt, offs, subpath);
  1334 + if (offs < 0) {
  1335 + printf("Could not create %s node.\n", subpath);
  1336 + }
  1337 + }
  1338 +
  1339 + subpath = "optee";
  1340 + offs = fdt_add_subnode(fdt, offs, subpath);
  1341 + if (offs < 0) {
  1342 + printf("Could not create %s node.\n", subpath);
  1343 + }
  1344 +
  1345 + fdt_setprop_string(fdt, offs, "compatible", "linaro,optee-tz");
  1346 + fdt_setprop_string(fdt, offs, "method", "smc");
  1347 +
  1348 + return 0;
  1349 +}
  1350 +
1303 1351 int ft_system_setup(void *blob, bd_t *bd)
1304 1352 {
1305 1353 #ifdef BOOTAUX_RESERVED_MEM_BASE
... ... @@ -1320,6 +1368,7 @@
1320 1368 config_smmu_fdt(blob);
1321 1369 #endif
1322 1370  
  1371 + ft_add_optee_node(blob, bd);
1323 1372 return 0;
1324 1373 }
1325 1374 #endif