1 /*
2  * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef FCONF_ETHOSN_GETTER_H
8 #define FCONF_ETHOSN_GETTER_H
9 
10 #include <assert.h>
11 #include <stdbool.h>
12 
13 #include <lib/fconf/fconf.h>
14 
15 #define hw_config__ethosn_config_getter(prop) ethosn_config.prop
16 #define hw_config__ethosn_device_getter(dev_idx) __extension__ ({	\
17 	assert(dev_idx < ethosn_config.num_devices);			\
18 	&ethosn_config.devices[dev_idx];				\
19 })
20 
21 #define ETHOSN_DEV_NUM_MAX U(2)
22 #define ETHOSN_DEV_CORE_NUM_MAX U(8)
23 #define ETHOSN_DEV_ASSET_ALLOCATOR_NUM_MAX U(16)
24 
25 struct ethosn_allocator_t {
26 	uint32_t stream_id;
27 };
28 
29 struct ethosn_main_allocator_t {
30 	struct ethosn_allocator_t firmware;
31 	struct ethosn_allocator_t working_data;
32 };
33 
34 struct ethosn_asset_allocator_t {
35 	struct ethosn_allocator_t command_stream;
36 	struct ethosn_allocator_t weight_data;
37 	struct ethosn_allocator_t buffer_data;
38 	struct ethosn_allocator_t intermediate_data;
39 };
40 
41 struct ethosn_core_t {
42 	uint64_t addr;
43 	struct ethosn_main_allocator_t main_allocator;
44 };
45 
46 struct ethosn_device_t {
47 	bool has_reserved_memory;
48 	uint32_t num_cores;
49 	struct ethosn_core_t cores[ETHOSN_DEV_CORE_NUM_MAX];
50 	uint32_t num_allocators;
51 	struct ethosn_asset_allocator_t asset_allocators[ETHOSN_DEV_ASSET_ALLOCATOR_NUM_MAX];
52 };
53 
54 struct ethosn_config_t {
55 	uint32_t num_devices;
56 	struct ethosn_device_t devices[ETHOSN_DEV_NUM_MAX];
57 };
58 
59 int fconf_populate_arm_ethosn(uintptr_t config);
60 
61 extern struct ethosn_config_t ethosn_config;
62 
63 #endif /* FCONF_ETHOSN_GETTER_H */
64