1 /* 2 * Copyright (c) 2020, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 #include <common/debug.h> 9 #include <common/fdt_wrappers.h> 10 #include <fconf_hw_config_getter.h> 11 #include <libfdt.h> 12 #include <plat/common/platform.h> 13 14 struct gicv3_config_t gicv3_config; 15 16 int fconf_populate_gicv3_config(uintptr_t config) 17 { 18 int err; 19 int node; 20 int addr[20]; 21 22 /* Necessary to work with libfdt APIs */ 23 const void *hw_config_dtb = (const void *)config; 24 25 /* 26 * Find the offset of the node containing "arm,gic-v3" compatible property. 27 * Populating fconf strucutures dynamically is not supported for legacy 28 * systems which use GICv2 IP. Simply skip extracting GIC properties. 29 */ 30 node = fdt_node_offset_by_compatible(hw_config_dtb, -1, "arm,gic-v3"); 31 if (node < 0) { 32 WARN("FCONF: Unable to locate node with arm,gic-v3 compatible property\n"); 33 return 0; 34 } 35 /* Read the reg cell holding base address of GIC controller modules 36 A sample reg cell array is shown here: 37 reg = <0x0 0x2f000000 0 0x10000>, // GICD 38 <0x0 0x2f100000 0 0x200000>, // GICR 39 <0x0 0x2c000000 0 0x2000>, // GICC 40 <0x0 0x2c010000 0 0x2000>, // GICH 41 <0x0 0x2c02f000 0 0x2000>; // GICV 42 */ 43 44 err = fdtw_read_array(hw_config_dtb, node, "reg", 20, &addr); 45 if (err < 0) { 46 ERROR("FCONF: Failed to read reg property of GIC node\n"); 47 } 48 return err; 49 } 50 51 52 FCONF_REGISTER_POPULATOR(HW_CONFIG, gicv3_config, fconf_populate_gicv3_config); 53