1*54fd6939SJiyong Park /* 2*54fd6939SJiyong Park * Copyright (c) 2019-2020, ARM Limited. All rights reserved. 3*54fd6939SJiyong Park * 4*54fd6939SJiyong Park * SPDX-License-Identifier: BSD-3-Clause 5*54fd6939SJiyong Park */ 6*54fd6939SJiyong Park 7*54fd6939SJiyong Park #ifndef FCONF_H 8*54fd6939SJiyong Park #define FCONF_H 9*54fd6939SJiyong Park 10*54fd6939SJiyong Park #include <stdint.h> 11*54fd6939SJiyong Park 12*54fd6939SJiyong Park /* Public API */ 13*54fd6939SJiyong Park #define FCONF_GET_PROPERTY(a, b, c) a##__##b##_getter(c) 14*54fd6939SJiyong Park 15*54fd6939SJiyong Park /* 16*54fd6939SJiyong Park * This macro takes three arguments: 17*54fd6939SJiyong Park * config: Configuration identifier 18*54fd6939SJiyong Park * name: property namespace 19*54fd6939SJiyong Park * callback: populate() function 20*54fd6939SJiyong Park */ 21*54fd6939SJiyong Park #define FCONF_REGISTER_POPULATOR(config, name, callback) \ 22*54fd6939SJiyong Park __attribute__((used, section(".fconf_populator"))) \ 23*54fd6939SJiyong Park const struct fconf_populator (name##__populator) = { \ 24*54fd6939SJiyong Park .config_type = (#config), \ 25*54fd6939SJiyong Park .info = (#name), \ 26*54fd6939SJiyong Park .populate = (callback) \ 27*54fd6939SJiyong Park }; 28*54fd6939SJiyong Park 29*54fd6939SJiyong Park /* 30*54fd6939SJiyong Park * Populator callback 31*54fd6939SJiyong Park * 32*54fd6939SJiyong Park * This structure are used by the fconf_populate function and should only be 33*54fd6939SJiyong Park * defined by the FCONF_REGISTER_POPULATOR macro. 34*54fd6939SJiyong Park */ 35*54fd6939SJiyong Park struct fconf_populator { 36*54fd6939SJiyong Park /* Description of the data loaded by the callback */ 37*54fd6939SJiyong Park const char *config_type; 38*54fd6939SJiyong Park const char *info; 39*54fd6939SJiyong Park 40*54fd6939SJiyong Park /* Callback used by fconf_populate function with a provided config dtb. 41*54fd6939SJiyong Park * Return 0 on success, err_code < 0 otherwise. 42*54fd6939SJiyong Park */ 43*54fd6939SJiyong Park int (*populate)(uintptr_t config); 44*54fd6939SJiyong Park }; 45*54fd6939SJiyong Park 46*54fd6939SJiyong Park /* This function supports to load tb_fw_config and fw_config dtb */ 47*54fd6939SJiyong Park int fconf_load_config(unsigned int image_id); 48*54fd6939SJiyong Park 49*54fd6939SJiyong Park /* Top level populate function 50*54fd6939SJiyong Park * 51*54fd6939SJiyong Park * This function takes a configuration dtb and calls all the registered 52*54fd6939SJiyong Park * populator callback with it. 53*54fd6939SJiyong Park * 54*54fd6939SJiyong Park * Panic on error. 55*54fd6939SJiyong Park */ 56*54fd6939SJiyong Park void fconf_populate(const char *config_type, uintptr_t config); 57*54fd6939SJiyong Park 58*54fd6939SJiyong Park /* FCONF specific getter */ 59*54fd6939SJiyong Park #define fconf__dtb_getter(prop) fconf_dtb_info.prop 60*54fd6939SJiyong Park 61*54fd6939SJiyong Park /* Structure used to locally keep a reference to the config dtb. */ 62*54fd6939SJiyong Park struct fconf_dtb_info_t { 63*54fd6939SJiyong Park uintptr_t base_addr; 64*54fd6939SJiyong Park size_t size; 65*54fd6939SJiyong Park }; 66*54fd6939SJiyong Park 67*54fd6939SJiyong Park extern struct fconf_dtb_info_t fconf_dtb_info; 68*54fd6939SJiyong Park 69*54fd6939SJiyong Park #endif /* FCONF_H */ 70