2018-05-10 07:33:50 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
2018-08-17 06:53:46 +01:00
|
|
|
#include <arch_helpers.h>
|
2018-05-10 07:33:50 +01:00
|
|
|
#include <debug.h>
|
|
|
|
#include <desc_image_load.h>
|
|
|
|
#include <libfdt.h>
|
|
|
|
#include <platform.h>
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* This function inserts Platform information via device tree nodes as,
|
|
|
|
* system-id {
|
|
|
|
* platform-id = <0>;
|
2018-08-17 06:53:46 +01:00
|
|
|
* config-id = <0>;
|
2018-05-10 07:33:50 +01:00
|
|
|
* }
|
|
|
|
******************************************************************************/
|
|
|
|
static int plat_sgi_append_config_node(void)
|
|
|
|
{
|
|
|
|
bl_mem_params_node_t *mem_params;
|
|
|
|
void *fdt;
|
|
|
|
int nodeoffset, err;
|
2018-08-17 06:53:46 +01:00
|
|
|
unsigned int platid = 0, platcfg = 0;
|
2018-05-10 07:33:50 +01:00
|
|
|
char *platform_name;
|
|
|
|
|
|
|
|
mem_params = get_bl_mem_params_node(HW_CONFIG_ID);
|
|
|
|
if (mem_params == NULL) {
|
|
|
|
ERROR("HW CONFIG base address is NULL");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fdt = (void *)(mem_params->image_info.image_base);
|
|
|
|
|
|
|
|
/* Check the validity of the fdt */
|
|
|
|
if (fdt_check_header(fdt) != 0) {
|
|
|
|
ERROR("Invalid HW_CONFIG DTB passed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
platform_name = (char *)fdt_getprop(fdt, 0, "compatible", NULL);
|
|
|
|
|
2018-08-16 14:37:40 +01:00
|
|
|
if (platform_name == NULL) {
|
|
|
|
ERROR("Invalid HW_CONFIG DTB passed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-05-10 07:33:50 +01:00
|
|
|
if (strcmp(platform_name, "arm,sgi575") == 0) {
|
2018-08-17 06:53:46 +01:00
|
|
|
platid = mmio_read_32(SSC_VERSION) & SSC_VERSION_PART_NUM_MASK;
|
|
|
|
platcfg = (mmio_read_32(SSC_VERSION) >> SSC_VERSION_CONFIG_SHIFT)
|
|
|
|
& SSC_VERSION_CONFIG_MASK;
|
2018-10-04 12:02:03 +01:00
|
|
|
} else if (strcmp(platform_name, "arm,sgi-clark") == 0) {
|
|
|
|
platid = mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
|
|
|
|
& SID_SYSTEM_ID_PART_NUM_MASK;
|
|
|
|
platcfg = mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
|
2018-05-10 07:33:50 +01:00
|
|
|
} else {
|
2018-08-16 14:37:40 +01:00
|
|
|
WARN("Invalid platform\n");
|
2018-05-10 07:33:50 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-08-17 06:53:46 +01:00
|
|
|
nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
|
|
|
|
if (nodeoffset < 0) {
|
|
|
|
ERROR("Failed to get system-id node offset\n");
|
2018-05-10 07:33:50 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-08-17 06:53:46 +01:00
|
|
|
err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
|
|
|
|
if (err < 0) {
|
|
|
|
ERROR("Failed to set platform-id\n");
|
2018-05-10 07:33:50 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-08-17 06:53:46 +01:00
|
|
|
err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg);
|
2018-05-10 07:33:50 +01:00
|
|
|
if (err < 0) {
|
2018-08-17 06:53:46 +01:00
|
|
|
ERROR("Failed to set config-id\n");
|
2018-05-10 07:33:50 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2018-08-17 06:53:46 +01:00
|
|
|
|
|
|
|
flush_dcache_range((uintptr_t)fdt, mem_params->image_info.image_size);
|
|
|
|
|
2018-05-10 07:33:50 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* This function returns the list of executable images.
|
|
|
|
******************************************************************************/
|
|
|
|
bl_params_t *plat_get_next_bl_params(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
bl_params_t *next_bl_params;
|
|
|
|
|
|
|
|
ret = plat_sgi_append_config_node();
|
|
|
|
if (ret != 0)
|
|
|
|
panic();
|
|
|
|
|
|
|
|
next_bl_params = get_next_bl_params_from_mem_params_desc();
|
|
|
|
populate_next_bl_params_config(next_bl_params);
|
|
|
|
|
|
|
|
return next_bl_params;
|
|
|
|
}
|