sgi_image_load.c 2.23 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <libfdt.h>
8
9
10
11

#include <arch_helpers.h>
#include <common/debug.h>
#include <common/desc_image_load.h>
12
#include <plat/arm/common/plat_arm.h>
13
14
#include <plat/common/platform.h>

15
#include <sgi_variant.h>
16
17
18
19
20

/*******************************************************************************
 * This function inserts Platform information via device tree nodes as,
 * system-id {
 *    platform-id = <0>;
21
 *    config-id = <0>;
22
23
24
25
26
27
28
 * }
 ******************************************************************************/
static int plat_sgi_append_config_node(void)
{
	bl_mem_params_node_t *mem_params;
	void *fdt;
	int nodeoffset, err;
29
	unsigned int platid = 0, platcfg = 0;
30

31
	mem_params = get_bl_mem_params_node(NT_FW_CONFIG_ID);
32
	if (mem_params == NULL) {
33
		ERROR("NT_FW CONFIG base address is NULL");
34
35
36
37
38
39
40
		return -1;
	}

	fdt = (void *)(mem_params->image_info.image_base);

	/* Check the validity of the fdt */
	if (fdt_check_header(fdt) != 0) {
41
		ERROR("Invalid NT_FW_CONFIG DTB passed\n");
42
43
44
		return -1;
	}

45
46
47
	nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
	if (nodeoffset < 0) {
		ERROR("Failed to get system-id node offset\n");
48
49
50
		return -1;
	}

51
	platid = plat_arm_sgi_get_platform_id();
52
53
54
	err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
	if (err < 0) {
		ERROR("Failed to set platform-id\n");
55
56
57
		return -1;
	}

58
	platcfg = plat_arm_sgi_get_config_id();
59
	err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg);
60
	if (err < 0) {
61
		ERROR("Failed to set config-id\n");
62
63
		return -1;
	}
64

65
66
67
68
69
70
71
	platcfg = plat_arm_sgi_get_multi_chip_mode();
	err = fdt_setprop_u32(fdt, nodeoffset, "multi-chip-mode", platcfg);
	if (err < 0) {
		ERROR("Failed to set multi-chip-mode\n");
		return -1;
	}

72
73
	flush_dcache_range((uintptr_t)fdt, mem_params->image_info.image_size);

74
75
76
77
78
79
80
81
82
83
84
85
86
87
	return 0;
}

/*******************************************************************************
 * This function returns the list of executable images.
 ******************************************************************************/
bl_params_t *plat_get_next_bl_params(void)
{
	int ret;

	ret = plat_sgi_append_config_node();
	if (ret != 0)
		panic();

88
	return arm_get_next_bl_params();
89
}
90