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 | |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 7 | #include <arch_helpers.h> |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 8 | #include <debug.h> |
| 9 | #include <desc_image_load.h> |
| 10 | #include <libfdt.h> |
| 11 | #include <platform.h> |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 12 | #include <sgi_variant.h> |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 13 | |
| 14 | /******************************************************************************* |
| 15 | * This function inserts Platform information via device tree nodes as, |
| 16 | * system-id { |
| 17 | * platform-id = <0>; |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 18 | * config-id = <0>; |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 19 | * } |
| 20 | ******************************************************************************/ |
| 21 | static int plat_sgi_append_config_node(void) |
| 22 | { |
| 23 | bl_mem_params_node_t *mem_params; |
| 24 | void *fdt; |
| 25 | int nodeoffset, err; |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 26 | unsigned int platid = 0, platcfg = 0; |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 27 | |
Chandni Cherukuri | 29ea98d | 2018-11-28 11:26:19 +0530 | [diff] [blame] | 28 | mem_params = get_bl_mem_params_node(NT_FW_CONFIG_ID); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 29 | if (mem_params == NULL) { |
Chandni Cherukuri | 29ea98d | 2018-11-28 11:26:19 +0530 | [diff] [blame] | 30 | ERROR("NT_FW CONFIG base address is NULL"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 31 | return -1; |
| 32 | } |
| 33 | |
| 34 | fdt = (void *)(mem_params->image_info.image_base); |
| 35 | |
| 36 | /* Check the validity of the fdt */ |
| 37 | if (fdt_check_header(fdt) != 0) { |
Chandni Cherukuri | 29ea98d | 2018-11-28 11:26:19 +0530 | [diff] [blame] | 38 | ERROR("Invalid NT_FW_CONFIG DTB passed\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 39 | return -1; |
| 40 | } |
| 41 | |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 42 | nodeoffset = fdt_subnode_offset(fdt, 0, "system-id"); |
| 43 | if (nodeoffset < 0) { |
| 44 | ERROR("Failed to get system-id node offset\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 45 | return -1; |
| 46 | } |
| 47 | |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 48 | platid = plat_arm_sgi_get_platform_id(); |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 49 | err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid); |
| 50 | if (err < 0) { |
| 51 | ERROR("Failed to set platform-id\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 52 | return -1; |
| 53 | } |
| 54 | |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 55 | platcfg = plat_arm_sgi_get_config_id(); |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 56 | err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 57 | if (err < 0) { |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 58 | ERROR("Failed to set config-id\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 59 | return -1; |
| 60 | } |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 61 | |
| 62 | flush_dcache_range((uintptr_t)fdt, mem_params->image_info.image_size); |
| 63 | |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | /******************************************************************************* |
| 68 | * This function returns the list of executable images. |
| 69 | ******************************************************************************/ |
| 70 | bl_params_t *plat_get_next_bl_params(void) |
| 71 | { |
| 72 | int ret; |
| 73 | bl_params_t *next_bl_params; |
| 74 | |
| 75 | ret = plat_sgi_append_config_node(); |
| 76 | if (ret != 0) |
| 77 | panic(); |
| 78 | |
| 79 | next_bl_params = get_next_bl_params_from_mem_params_desc(); |
| 80 | populate_next_bl_params_config(next_bl_params); |
| 81 | |
| 82 | return next_bl_params; |
| 83 | } |