blob: f58ff5710382923832f7fd0bbc87c44073229682 [file] [log] [blame]
Louis Mayencourt944ade82019-08-08 12:03:26 +01001/*
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 */
28struct 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
Louis Mayencourt5a15b2d2019-10-17 14:46:51 +010038/* Load firmware configuration dtb */
39void fconf_load_config(void);
40
Louis Mayencourt944ade82019-08-08 12:03:26 +010041/* 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 */
48void fconf_populate(uintptr_t config);
49
Louis Mayencourt81bd9162019-10-17 15:14:25 +010050/* 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. */
54struct fconf_dtb_info_t {
55 uintptr_t base_addr;
56 size_t size;
57};
58
59extern struct fconf_dtb_info_t fconf_dtb_info;
60
Louis Mayencourt944ade82019-08-08 12:03:26 +010061#endif /* FCONF_H */