Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 1 | /* |
| 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 | ******************************************************************************/ |
| 18 | static 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 | |
John Tsichritzis | 049db96 | 2018-08-16 14:37:40 +0100 | [diff] [blame] | 42 | if (platform_name == NULL) { |
| 43 | ERROR("Invalid HW_CONFIG DTB passed\n"); |
| 44 | return -1; |
| 45 | } |
| 46 | |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 47 | if (strcmp(platform_name, "arm,sgi575") == 0) { |
| 48 | platid = mmio_read_32(SSC_VERSION); |
| 49 | } else { |
John Tsichritzis | 049db96 | 2018-08-16 14:37:40 +0100 | [diff] [blame] | 50 | WARN("Invalid platform\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 51 | return -1; |
| 52 | } |
| 53 | |
| 54 | /* Increase DTB blob by 512 byte */ |
| 55 | err = fdt_open_into(fdt, fdt, mem_params->image_info.image_size + 512); |
| 56 | if (err < 0) { |
| 57 | ERROR("Failed to open HW_CONFIG DTB\n"); |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | /* Create "/system-id" node */ |
| 62 | nodeoffset = fdt_add_subnode(fdt, 0, "system-id"); |
| 63 | if (nodeoffset < 0) { |
| 64 | ERROR("Failed to add node system-id\n"); |
| 65 | return -1; |
| 66 | } |
| 67 | |
| 68 | err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid); |
| 69 | if (err < 0) { |
| 70 | ERROR("Failed to add node platform-id\n"); |
| 71 | return -1; |
| 72 | } |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | /******************************************************************************* |
| 77 | * This function returns the list of executable images. |
| 78 | ******************************************************************************/ |
| 79 | bl_params_t *plat_get_next_bl_params(void) |
| 80 | { |
| 81 | int ret; |
| 82 | bl_params_t *next_bl_params; |
| 83 | |
| 84 | ret = plat_sgi_append_config_node(); |
| 85 | if (ret != 0) |
| 86 | panic(); |
| 87 | |
| 88 | next_bl_params = get_next_bl_params_from_mem_params_desc(); |
| 89 | populate_next_bl_params_config(next_bl_params); |
| 90 | |
| 91 | return next_bl_params; |
| 92 | } |