Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019-2020 Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | * not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | /****************************************************************************** |
| 22 | * Includes |
| 23 | ******************************************************************************/ |
| 24 | |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame^] | 25 | #include "ethosu_device.h" |
| 26 | |
| 27 | #include <stdbool.h> |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 28 | #include <stdint.h> |
| 29 | |
| 30 | #ifdef __cplusplus |
| 31 | extern "C" { |
| 32 | #endif |
| 33 | |
| 34 | /****************************************************************************** |
| 35 | * Defines |
| 36 | ******************************************************************************/ |
| 37 | |
| 38 | /****************************************************************************** |
| 39 | * Types |
| 40 | ******************************************************************************/ |
| 41 | |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame^] | 42 | struct ethosu_driver |
| 43 | { |
| 44 | struct ethosu_device dev; |
| 45 | bool abort_inference; |
| 46 | }; |
| 47 | |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 48 | struct ethosu_version_id |
| 49 | { |
| 50 | // Ethos-U id |
| 51 | uint8_t version_status; |
| 52 | uint8_t version_minor; |
| 53 | uint8_t version_major; |
| 54 | uint8_t product_major; |
| 55 | uint8_t arch_patch_rev; |
| 56 | uint8_t arch_minor_rev; |
| 57 | uint8_t arch_major_rev; |
| 58 | |
| 59 | // Driver Version |
| 60 | uint8_t driver_patch_rev; |
| 61 | uint8_t driver_minor_rev; |
| 62 | uint8_t driver_major_rev; |
| 63 | }; |
| 64 | |
| 65 | struct ethosu_version_config |
| 66 | { |
| 67 | uint8_t macs_per_cc; |
| 68 | uint8_t cmd_stream_version; |
| 69 | uint8_t shram_size; |
| 70 | }; |
| 71 | |
| 72 | struct ethosu_version |
| 73 | { |
| 74 | struct ethosu_version_id id; |
| 75 | struct ethosu_version_config cfg; |
| 76 | }; |
| 77 | |
| 78 | /****************************************************************************** |
| 79 | * Prototypes |
| 80 | ******************************************************************************/ |
| 81 | |
| 82 | /** |
| 83 | * Initialize the Ethos-U driver. |
| 84 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame^] | 85 | int ethosu_init(const void *base_address); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Get Ethos-U version. |
| 89 | */ |
| 90 | int ethosu_get_version(struct ethosu_version *version); |
| 91 | |
| 92 | /** |
| 93 | * Invoke Vela command stream. |
| 94 | */ |
| 95 | int ethosu_invoke(const void *custom_data_ptr, |
| 96 | const int custom_data_size, |
| 97 | const uint64_t *base_addr, |
| 98 | const int num_base_addr); |
| 99 | /** |
| 100 | * Abort Ethos-U inference. |
| 101 | */ |
| 102 | void ethosu_abort(void); |
| 103 | |
Per Åstrand | 25d78c0 | 2020-04-21 14:19:44 +0200 | [diff] [blame] | 104 | /** |
| 105 | * Interrupt handler do be called on IRQ from Ethos-U |
| 106 | */ |
| 107 | void ethosu_irq_handler(void); |
| 108 | |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 109 | #ifdef __cplusplus |
| 110 | } |
| 111 | #endif |