Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 1 | /* |
Vijayenthiran Subramaniam | 03f58bf | 2019-10-30 12:52:25 +0530 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 7 | #include <libfdt.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <arch_helpers.h> |
| 10 | #include <common/debug.h> |
| 11 | #include <common/desc_image_load.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 12 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 13 | #include <plat/common/platform.h> |
| 14 | |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 15 | #include <sgi_variant.h> |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 16 | |
| 17 | /******************************************************************************* |
| 18 | * This function inserts Platform information via device tree nodes as, |
| 19 | * system-id { |
| 20 | * platform-id = <0>; |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 21 | * config-id = <0>; |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 22 | * } |
| 23 | ******************************************************************************/ |
| 24 | static int plat_sgi_append_config_node(void) |
| 25 | { |
| 26 | bl_mem_params_node_t *mem_params; |
| 27 | void *fdt; |
| 28 | int nodeoffset, err; |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 29 | unsigned int platid = 0, platcfg = 0; |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 30 | |
Chandni Cherukuri | 29ea98d | 2018-11-28 11:26:19 +0530 | [diff] [blame] | 31 | mem_params = get_bl_mem_params_node(NT_FW_CONFIG_ID); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 32 | if (mem_params == NULL) { |
Chandni Cherukuri | 29ea98d | 2018-11-28 11:26:19 +0530 | [diff] [blame] | 33 | ERROR("NT_FW CONFIG base address is NULL"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 34 | return -1; |
| 35 | } |
| 36 | |
| 37 | fdt = (void *)(mem_params->image_info.image_base); |
| 38 | |
| 39 | /* Check the validity of the fdt */ |
| 40 | if (fdt_check_header(fdt) != 0) { |
Chandni Cherukuri | 29ea98d | 2018-11-28 11:26:19 +0530 | [diff] [blame] | 41 | ERROR("Invalid NT_FW_CONFIG DTB passed\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 42 | return -1; |
| 43 | } |
| 44 | |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 45 | nodeoffset = fdt_subnode_offset(fdt, 0, "system-id"); |
| 46 | if (nodeoffset < 0) { |
| 47 | ERROR("Failed to get system-id node offset\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 48 | return -1; |
| 49 | } |
| 50 | |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 51 | platid = plat_arm_sgi_get_platform_id(); |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 52 | err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid); |
| 53 | if (err < 0) { |
| 54 | ERROR("Failed to set platform-id\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 55 | return -1; |
| 56 | } |
| 57 | |
Chandni Cherukuri | 3aa09f7 | 2018-11-28 11:31:51 +0530 | [diff] [blame] | 58 | platcfg = plat_arm_sgi_get_config_id(); |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 59 | err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 60 | if (err < 0) { |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 61 | ERROR("Failed to set config-id\n"); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 62 | return -1; |
| 63 | } |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 64 | |
Vijayenthiran Subramaniam | 03f58bf | 2019-10-30 12:52:25 +0530 | [diff] [blame] | 65 | platcfg = plat_arm_sgi_get_multi_chip_mode(); |
| 66 | err = fdt_setprop_u32(fdt, nodeoffset, "multi-chip-mode", platcfg); |
| 67 | if (err < 0) { |
| 68 | ERROR("Failed to set multi-chip-mode\n"); |
| 69 | return -1; |
| 70 | } |
| 71 | |
Chandni Cherukuri | 33fcfee | 2018-08-17 11:23:46 +0530 | [diff] [blame] | 72 | flush_dcache_range((uintptr_t)fdt, mem_params->image_info.image_size); |
| 73 | |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | /******************************************************************************* |
| 78 | * This function returns the list of executable images. |
| 79 | ******************************************************************************/ |
| 80 | bl_params_t *plat_get_next_bl_params(void) |
| 81 | { |
| 82 | int ret; |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 83 | |
| 84 | ret = plat_sgi_append_config_node(); |
| 85 | if (ret != 0) |
| 86 | panic(); |
| 87 | |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 88 | return arm_get_next_bl_params(); |
Chandni Cherukuri | 771d644 | 2018-05-10 12:03:50 +0530 | [diff] [blame] | 89 | } |
Sathees Balya | 9095009 | 2018-11-15 14:22:30 +0000 | [diff] [blame] | 90 | |