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