blob: dda5e96c529bdc29ed21c5d5e74105391d94fa5c [file] [log] [blame]
Chandni Cherukuri771d6442018-05-10 12:03:50 +05301/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <debug.h>
8#include <desc_image_load.h>
9#include <libfdt.h>
10#include <platform.h>
11
12/*******************************************************************************
13 * This function inserts Platform information via device tree nodes as,
14 * system-id {
15 * platform-id = <0>;
16 * }
17 ******************************************************************************/
18static int plat_sgi_append_config_node(void)
19{
20 bl_mem_params_node_t *mem_params;
21 void *fdt;
22 int nodeoffset, err;
23 unsigned int platid = 0;
24 char *platform_name;
25
26 mem_params = get_bl_mem_params_node(HW_CONFIG_ID);
27 if (mem_params == NULL) {
28 ERROR("HW CONFIG base address is NULL");
29 return -1;
30 }
31
32 fdt = (void *)(mem_params->image_info.image_base);
33
34 /* Check the validity of the fdt */
35 if (fdt_check_header(fdt) != 0) {
36 ERROR("Invalid HW_CONFIG DTB passed\n");
37 return -1;
38 }
39
40 platform_name = (char *)fdt_getprop(fdt, 0, "compatible", NULL);
41
42 if (strcmp(platform_name, "arm,sgi575") == 0) {
43 platid = mmio_read_32(SSC_VERSION);
44 } else {
45 WARN("Invalid platform \n");
46 return -1;
47 }
48
49 /* Increase DTB blob by 512 byte */
50 err = fdt_open_into(fdt, fdt, mem_params->image_info.image_size + 512);
51 if (err < 0) {
52 ERROR("Failed to open HW_CONFIG DTB\n");
53 return -1;
54 }
55
56 /* Create "/system-id" node */
57 nodeoffset = fdt_add_subnode(fdt, 0, "system-id");
58 if (nodeoffset < 0) {
59 ERROR("Failed to add node system-id\n");
60 return -1;
61 }
62
63 err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
64 if (err < 0) {
65 ERROR("Failed to add node platform-id\n");
66 return -1;
67 }
68 return 0;
69}
70
71/*******************************************************************************
72 * This function returns the list of executable images.
73 ******************************************************************************/
74bl_params_t *plat_get_next_bl_params(void)
75{
76 int ret;
77 bl_params_t *next_bl_params;
78
79 ret = plat_sgi_append_config_node();
80 if (ret != 0)
81 panic();
82
83 next_bl_params = get_next_bl_params_from_mem_params_desc();
84 populate_next_bl_params_config(next_bl_params);
85
86 return next_bl_params;
87}