blob: 09d2b59aa6bb17287b46727ae65905fa910e1249 [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
Madhukar Pappireddy81519692019-12-06 15:46:42 -060015/*
16 * This macro takes three arguments:
17 * config: Configuration identifier
18 * name: property namespace
19 * callback: populate() function
20 */
21#define FCONF_REGISTER_POPULATOR(config, name, callback) \
Louis Mayencourt944ade82019-08-08 12:03:26 +010022 __attribute__((used, section(".fconf_populator"))) \
Louis Mayencourt2711cc82020-02-24 14:37:25 +000023 const struct fconf_populator (name##__populator) = { \
Madhukar Pappireddy81519692019-12-06 15:46:42 -060024 .config_type = (#config), \
Louis Mayencourt2711cc82020-02-24 14:37:25 +000025 .info = (#name), \
26 .populate = (callback) \
Louis Mayencourt944ade82019-08-08 12:03:26 +010027 };
28
29/*
30 * Populator callback
31 *
32 * This structure are used by the fconf_populate function and should only be
33 * defined by the FCONF_REGISTER_POPULATOR macro.
34 */
35struct fconf_populator {
36 /* Description of the data loaded by the callback */
Madhukar Pappireddy81519692019-12-06 15:46:42 -060037 const char *config_type;
Louis Mayencourt944ade82019-08-08 12:03:26 +010038 const char *info;
39
40 /* Callback used by fconf_populate function with a provided config dtb.
41 * Return 0 on success, err_code < 0 otherwise.
42 */
43 int (*populate)(uintptr_t config);
44};
45
Louis Mayencourt5a15b2d2019-10-17 14:46:51 +010046/* Load firmware configuration dtb */
47void fconf_load_config(void);
48
Louis Mayencourt944ade82019-08-08 12:03:26 +010049/* Top level populate function
50 *
51 * This function takes a configuration dtb and calls all the registered
52 * populator callback with it.
53 *
54 * Panic on error.
55 */
Madhukar Pappireddy81519692019-12-06 15:46:42 -060056void fconf_populate(const char *config_type, uintptr_t config);
Louis Mayencourt944ade82019-08-08 12:03:26 +010057
Louis Mayencourt81bd9162019-10-17 15:14:25 +010058/* FCONF specific getter */
59#define fconf__dtb_getter(prop) fconf_dtb_info.prop
60
61/* Structure used to locally keep a reference to the config dtb. */
62struct fconf_dtb_info_t {
63 uintptr_t base_addr;
64 size_t size;
65};
66
67extern struct fconf_dtb_info_t fconf_dtb_info;
68
Louis Mayencourt944ade82019-08-08 12:03:26 +010069#endif /* FCONF_H */