Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 1 | /* |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 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> |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 11 | #include <stdbool.h> |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 12 | |
| 13 | #include <lib/fconf/fconf.h> |
| 14 | |
| 15 | #define hw_config__ethosn_config_getter(prop) ethosn_config.prop |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 16 | #define hw_config__ethosn_device_getter(dev_idx) __extension__ ({ \ |
| 17 | assert(dev_idx < ethosn_config.num_devices); \ |
| 18 | ðosn_config.devices[dev_idx]; \ |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 19 | }) |
| 20 | |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 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) |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 24 | |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 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 | }; |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 40 | |
Laurent Carlier | 5205df2 | 2021-09-16 15:10:35 +0100 | [diff] [blame] | 41 | struct ethosn_core_t { |
| 42 | uint64_t addr; |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 43 | struct ethosn_main_allocator_t main_allocator; |
Laurent Carlier | 5205df2 | 2021-09-16 15:10:35 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 46 | struct ethosn_device_t { |
| 47 | bool has_reserved_memory; |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 48 | uint32_t num_cores; |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 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]; |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 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 */ |