blob: 64ccb898f9ef9f529a5f01d844b00408015f7caa [file] [log] [blame]
Kristofer Jonsson49bdee82020-04-06 13:21:21 +02001/*
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
Kristofer Jonsson3c439172020-08-05 09:38:40 +020019#ifndef ETHOSU_DRIVER_H
20#define ETHOSU_DRIVER_H
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020021
22/******************************************************************************
23 * Includes
24 ******************************************************************************/
25
Bhavik Pateldae5be02020-06-18 15:25:15 +020026#include "ethosu_device.h"
27
28#include <stdbool.h>
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020029#include <stdint.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/******************************************************************************
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020036 * Types
37 ******************************************************************************/
38
Bhavik Pateldae5be02020-06-18 15:25:15 +020039struct ethosu_driver
40{
41 struct ethosu_device dev;
42 bool abort_inference;
43};
44
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020045struct ethosu_version_id
46{
47 // Ethos-U id
48 uint8_t version_status;
49 uint8_t version_minor;
50 uint8_t version_major;
51 uint8_t product_major;
52 uint8_t arch_patch_rev;
53 uint8_t arch_minor_rev;
54 uint8_t arch_major_rev;
55
56 // Driver Version
57 uint8_t driver_patch_rev;
58 uint8_t driver_minor_rev;
59 uint8_t driver_major_rev;
60};
61
62struct ethosu_version_config
63{
64 uint8_t macs_per_cc;
65 uint8_t cmd_stream_version;
66 uint8_t shram_size;
67};
68
69struct ethosu_version
70{
71 struct ethosu_version_id id;
72 struct ethosu_version_config cfg;
73};
74
75/******************************************************************************
76 * Prototypes
77 ******************************************************************************/
78
79/**
80 * Initialize the Ethos-U driver.
81 */
Bhavik Pateldae5be02020-06-18 15:25:15 +020082int ethosu_init(const void *base_address);
Kristofer Jonsson49bdee82020-04-06 13:21:21 +020083
84/**
85 * Get Ethos-U version.
86 */
87int ethosu_get_version(struct ethosu_version *version);
88
89/**
90 * Invoke Vela command stream.
91 */
92int ethosu_invoke(const void *custom_data_ptr,
93 const int custom_data_size,
94 const uint64_t *base_addr,
95 const int num_base_addr);
96/**
97 * Abort Ethos-U inference.
98 */
99void ethosu_abort(void);
100
Per Åstrand25d78c02020-04-21 14:19:44 +0200101/**
102 * Interrupt handler do be called on IRQ from Ethos-U
103 */
104void ethosu_irq_handler(void);
105
Kristofer Jonsson49bdee82020-04-06 13:21:21 +0200106#ifdef __cplusplus
107}
108#endif
Kristofer Jonsson3c439172020-08-05 09:38:40 +0200109
110#endif // ETHOSU_DRIVER_H