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 | |
Kristofer Jonsson | 3c43917 | 2020-08-05 09:38:40 +0200 | [diff] [blame] | 19 | #ifndef ETHOSU_DEVICE_H |
| 20 | #define ETHOSU_DEVICE_H |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 21 | |
| 22 | /****************************************************************************** |
| 23 | * Includes |
| 24 | ******************************************************************************/ |
| 25 | |
Bhavik Patel | 5da4092 | 2020-07-15 10:06:43 +0200 | [diff] [blame] | 26 | #include "pmu_ethosu.h" |
| 27 | |
| 28 | #include <stdbool.h> |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 29 | #include <stdint.h> |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | /****************************************************************************** |
| 36 | * Defines |
| 37 | ******************************************************************************/ |
| 38 | |
| 39 | #define ETHOSU_DRIVER_VERSION_MAJOR 0 ///< Driver major version |
Douglas Troha | f6a85da | 2020-05-11 11:45:28 +0200 | [diff] [blame] | 40 | #define ETHOSU_DRIVER_VERSION_MINOR 16 ///< Driver minor version |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 41 | #define ETHOSU_DRIVER_VERSION_PATCH 0 ///< Driver patch version |
| 42 | #define ETHOSU_DRIVER_BASEP_INDEXES 8 ///< Number of base pointer indexes |
| 43 | |
| 44 | /****************************************************************************** |
| 45 | * Types |
| 46 | ******************************************************************************/ |
| 47 | |
| 48 | enum ethosu_error_codes |
| 49 | { |
| 50 | ETHOSU_SUCCESS = 0, ///< Success |
| 51 | ETHOSU_GENERIC_FAILURE = -1, ///< Generic failure |
| 52 | ETHOSU_INVALID_PARAM = -2 ///< Invalid parameter |
| 53 | }; |
| 54 | |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 55 | struct ethosu_device |
| 56 | { |
Kristofer Jonsson | 4dc73dc | 2020-10-16 12:33:47 +0200 | [diff] [blame] | 57 | volatile uint32_t *base_address; |
Bhavik Patel | 5f8dad1 | 2020-09-30 09:06:52 +0200 | [diff] [blame] | 58 | uint32_t reset; |
Kristofer Jonsson | ef387ea | 2020-08-25 16:32:21 +0200 | [diff] [blame] | 59 | uint32_t pmcr; |
Kristofer Jonsson | 4dc73dc | 2020-10-16 12:33:47 +0200 | [diff] [blame] | 60 | uint32_t pmccntr[2]; |
Kristofer Jonsson | ef387ea | 2020-08-25 16:32:21 +0200 | [diff] [blame] | 61 | uint32_t pmcnten; |
| 62 | uint32_t pmint; |
| 63 | uint32_t pmccntr_cfg; |
Bhavik Patel | 5da4092 | 2020-07-15 10:06:43 +0200 | [diff] [blame] | 64 | uint32_t pmu_evcntr[ETHOSU_PMU_NCOUNTERS]; |
Kristofer Jonsson | 4dc73dc | 2020-10-16 12:33:47 +0200 | [diff] [blame] | 65 | uint32_t pmu_evtypr[ETHOSU_PMU_NCOUNTERS]; |
Per Åstrand | e6498f0 | 2020-11-09 15:33:12 +0100 | [diff] [blame] | 66 | uint32_t secure; |
| 67 | uint32_t privileged; |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 70 | struct ethosu_id |
| 71 | { |
| 72 | uint32_t version_status; ///< Version status |
| 73 | uint32_t version_minor; ///< Version minor |
| 74 | uint32_t version_major; ///< Version major |
| 75 | uint32_t product_major; ///< Product major |
| 76 | uint32_t arch_patch_rev; ///< Architecture version patch |
| 77 | uint32_t arch_minor_rev; ///< Architecture version minor |
| 78 | uint32_t arch_major_rev; ///< Architecture version major |
| 79 | }; |
| 80 | |
| 81 | struct ethosu_config |
| 82 | { |
| 83 | struct |
| 84 | { |
| 85 | uint32_t macs_per_cc; ///< MACs per clock cycle |
| 86 | uint32_t cmd_stream_version; ///< NPU command stream version |
| 87 | uint32_t shram_size; ///< SHRAM size |
| 88 | }; |
| 89 | }; |
| 90 | |
| 91 | /** |
| 92 | * Memory type parameter for set_regioncfg_reg: |
| 93 | * Counter{0,1}: Outstanding transactions for |
| 94 | * AXI port 0 for memory type/region a=0,b=1 |
| 95 | * Counter{2,3}: Outstanding transactions for |
| 96 | * AXI port 1 for memory type/region a=2,b=3 |
| 97 | */ |
| 98 | enum ethosu_memory_type |
| 99 | { |
| 100 | ETHOSU_AXI0_OUTSTANDING_COUNTER0 = 0, ///< NPU axi0_outstanding_counter0 |
| 101 | ETHOSU_AXI0_OUTSTANDING_COUNTER1 = 1, ///< NPU axi0_outstanding_counter1 |
| 102 | ETHOSU_AXI1_OUTSTANDING_COUNTER2 = 2, ///< NPU axi1_outstanding_counter2 |
| 103 | ETHOSU_AXI1_OUTSTANDING_COUNTER3 = 3 ///< NPU axi1_outstanding_counter3 |
| 104 | }; |
| 105 | |
| 106 | enum ethosu_axi_limit_beats |
| 107 | { |
| 108 | ETHOSU_AXI_LIMIT_64_BYTES = 0, ///< NPU AXI limit 64 byte burst split alignment. |
| 109 | ETHOSU_AXI_LIMIT_128_BYTES = 1, ///< NPU AXI limit 128 byte burst split alignment. |
| 110 | ETHOSU_AXI_LIMIT_256_BYTES = 2 ///< NPU AXI limit 256 byte burst split alignment. |
| 111 | }; |
| 112 | |
| 113 | enum ethosu_axi_limit_mem_type |
| 114 | { |
| 115 | ETHOSU_MEM_TYPE_DEVICE_NON_BUFFERABLE = 0, |
| 116 | ETHOSU_MEM_TYPE_DEVICE_BUFFERABLE = 1, |
| 117 | ETHOSU_MEM_TYPE_NORMAL_NON_CACHEABLE_NON_BUFFERABLE = 2, |
| 118 | ETHOSU_MEM_TYPE_NORMAL_NON_CACHEABLE_BUFFERABLE = 3, |
| 119 | ETHOSU_MEM_TYPE_WRITE_THROUGH_NO_ALLOCATE = 4, |
| 120 | ETHOSU_MEM_TYPE_WRITE_THROUGH_READ_ALLOCATE = 5, |
| 121 | ETHOSU_MEM_TYPE_WRITE_THROUGH_WRITE_ALLOCATE = 6, |
| 122 | ETHOSU_MEM_TYPE_WRITE_THROUGH_READ_AND_WRITE_ALLOCATE = 7, |
| 123 | ETHOSU_MEM_TYPE_WRITE_BACK_NO_ALLOCATE = 8, |
| 124 | ETHOSU_MEM_TYPE_WRITE_BACK_READ_ALLOCATE = 9, |
| 125 | ETHOSU_MEM_TYPE_WRITE_BACK_WRITE_ALLOCATE = 10, |
| 126 | ETHOSU_MEM_TYPE_WRITE_BACK_READ_AND_WRITE_ALLOCATE = 11 |
| 127 | }; |
| 128 | |
| 129 | enum ethosu_clock_q_request |
| 130 | { |
| 131 | ETHOSU_CLOCK_Q_DISABLE = 0, ///< Disble NPU signal ready for clock off. |
| 132 | ETHOSU_CLOCK_Q_ENABLE = 1 ///< Enable NPU signal ready for clock off when stop+idle state reached. |
| 133 | }; |
| 134 | |
| 135 | enum ethosu_power_q_request |
| 136 | { |
| 137 | ETHOSU_POWER_Q_DISABLE = 0, ///< Disble NPU signal ready for power off. |
| 138 | ETHOSU_POWER_Q_ENABLE = 1 ///< Enable NPU signal ready for power off when stop+idle state reached. |
| 139 | }; |
| 140 | |
| 141 | /****************************************************************************** |
| 142 | * Prototypes |
| 143 | ******************************************************************************/ |
| 144 | |
| 145 | /** |
| 146 | * Initialize the device. |
| 147 | */ |
Per Åstrand | e6498f0 | 2020-11-09 15:33:12 +0100 | [diff] [blame] | 148 | enum ethosu_error_codes ethosu_dev_init(struct ethosu_device *dev, |
| 149 | const void *base_address, |
| 150 | uint32_t secure_enable, |
| 151 | uint32_t privilege_enable); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * Get device id. |
| 155 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 156 | enum ethosu_error_codes ethosu_get_id(struct ethosu_device *dev, struct ethosu_id *id); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * Get device configuration. |
| 160 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 161 | enum ethosu_error_codes ethosu_get_config(struct ethosu_device *dev, struct ethosu_config *config); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 162 | |
| 163 | /** |
| 164 | * Execute a given command stream on NPU. |
| 165 | * \param[in] cmd_stream_ptr Pointer to the command stream |
| 166 | * \param[in] cms_length Command stream length |
| 167 | * \param[in] base_addr Pointer to array of base addresses |
| 168 | * - 0: weight tensor |
| 169 | * - 1: scratch tensor |
| 170 | * - All input tensors |
| 171 | * - All output tensors |
| 172 | * \param[in] num_base_addr Number of base addresses. |
| 173 | * \return \ref ethosu_error_codes |
| 174 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 175 | enum ethosu_error_codes ethosu_run_command_stream(struct ethosu_device *dev, |
| 176 | const uint8_t *cmd_stream_ptr, |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 177 | uint32_t cms_length, |
| 178 | const uint64_t *base_addr, |
| 179 | int num_base_addr); |
| 180 | |
| 181 | /** |
| 182 | * Check if IRQ is raised. |
| 183 | * \param[out] irq_status Pointer to IRQ status |
| 184 | * - 0 IRQ not raised |
| 185 | * - 1 IRQ raised |
| 186 | * \return \ref ethosu_error_codes |
| 187 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 188 | enum ethosu_error_codes ethosu_is_irq_raised(struct ethosu_device *dev, uint8_t *irq_status); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 189 | |
| 190 | /** |
| 191 | * Clear IRQ status. |
| 192 | * \return \ref ethosu_error_codes |
| 193 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 194 | enum ethosu_error_codes ethosu_clear_irq_status(struct ethosu_device *dev); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 195 | |
| 196 | /** |
| 197 | * Get the 16 bit status mask. |
| 198 | * \param[out] irq_status_mask Pointer to the status mask. |
| 199 | * The lower 16 bits of status reg are returned. |
| 200 | * bit0: state |
| 201 | * bit1: irq_raised |
| 202 | * bit2: bus_status |
| 203 | * bit3: reset_status |
| 204 | * bit4: cmd_parse_error |
| 205 | * bit5: cmd_end_reached |
| 206 | * bit6: pmu_irq_raised |
| 207 | * bit7-15: reserved |
| 208 | * \return \ref ethosu_error_codes |
| 209 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 210 | enum ethosu_error_codes ethosu_get_status_mask(struct ethosu_device *dev, uint16_t *status_mask); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * Get the 16 bit IRQ history mask. |
| 214 | * \param[out] irq_history_mask Pointer to the IRQ history mask. |
| 215 | * \return \ref ethosu_error_codes |
| 216 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 217 | enum ethosu_error_codes ethosu_get_irq_history_mask(struct ethosu_device *dev, uint16_t *irq_history_mask); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 218 | |
| 219 | /** |
| 220 | * Clear the given bits in the |
| 221 | * IRQ history mask. |
| 222 | * \param[in] irq_history_clear_mask 16 bit mask indicating which bits to |
| 223 | * clear in the IRQ history mask. |
| 224 | * \return \ref ethosu_error_codes |
| 225 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 226 | enum ethosu_error_codes ethosu_clear_irq_history_mask(struct ethosu_device *dev, uint16_t irq_history_clear_mask); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * Perform a NPU soft reset. |
| 230 | * \return \ref ethosu_error_codes |
| 231 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 232 | enum ethosu_error_codes ethosu_soft_reset(struct ethosu_device *dev); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 233 | |
| 234 | /** |
| 235 | * Wait for reset ready. |
| 236 | * \return \ref ethosu_error_codes |
| 237 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 238 | enum ethosu_error_codes ethosu_wait_for_reset(struct ethosu_device *dev); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 239 | |
| 240 | /** |
| 241 | * Read and return the content of a given NPU APB |
| 242 | * register range. |
| 243 | * \param[in] start_address Start address. |
| 244 | * \param[in] num_reg Number of registers to read. |
| 245 | * \param[out] reg_p Pointer to a output area, allocated by the |
| 246 | * caller, where the register content shall be |
| 247 | * written. |
| 248 | * \return \ref ethosu_error_codes |
| 249 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 250 | enum ethosu_error_codes ethosu_read_apb_reg(struct ethosu_device *dev, |
| 251 | uint32_t start_address, |
| 252 | uint16_t num_reg, |
| 253 | uint32_t *reg_p); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 254 | |
| 255 | /** |
| 256 | * Set qconfig register. I.e. |
| 257 | * AXI configuration for the command stream. |
| 258 | * \param[in] memory_type Memory_type to use for command stream: |
| 259 | * enum ethosu_memory_type. |
| 260 | * \return \ref ethosu_error_codes |
| 261 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 262 | enum ethosu_error_codes ethosu_set_qconfig(struct ethosu_device *dev, enum ethosu_memory_type memory_type); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 263 | |
| 264 | /** |
| 265 | * Set register REGIONCFG. |
| 266 | * Base pointer configuration. |
| 267 | * Bits[2*k+1:2*k] give the memory type for BASEP[k]. |
| 268 | * \param[in] region Region field to set: 0 - 7. |
| 269 | * \param[in] memory_type Memory_type to use for region: enum ethosu_memory_type. |
| 270 | * \return \ref ethosu_error_codes |
| 271 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 272 | enum ethosu_error_codes ethosu_set_regioncfg(struct ethosu_device *dev, |
| 273 | uint8_t region, |
| 274 | enum ethosu_memory_type memory_type); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 275 | |
| 276 | /** |
| 277 | * Set AXI limit parameters for port 0 counter 0. |
| 278 | * \param[in] max_beats Burst split alignment, \ref ethosu_axi_limit_beats. |
| 279 | * \param[in] memtype Cache policy \ref ethosu_axi_limit_mem_type |
| 280 | * \param[in] max_reads Maximum number of outstanding reads. |
| 281 | * \param[in] max_writes Maximum number of outstanding writes. |
| 282 | * \return \ref ethosu_error_codes |
| 283 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 284 | enum ethosu_error_codes ethosu_set_axi_limit0(struct ethosu_device *dev, |
| 285 | enum ethosu_axi_limit_beats max_beats, |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 286 | enum ethosu_axi_limit_mem_type memtype, |
| 287 | uint8_t max_reads, |
| 288 | uint8_t max_writes); |
| 289 | /** |
| 290 | * Set AXI limit parameters for port 0 counter 1. |
| 291 | * \param[in] max_beats Burst split alignment, \ref ethosu_axi_limit_beats. |
| 292 | * \param[in] memtype Cache policy \ref ethosu_axi_limit_mem_type |
| 293 | * \param[in] max_reads Maximum number of outstanding reads. |
| 294 | * \param[in] max_writes Maximum number of outstanding writes. |
| 295 | * \return \ref ethosu_error_codes |
| 296 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 297 | enum ethosu_error_codes ethosu_set_axi_limit1(struct ethosu_device *dev, |
| 298 | enum ethosu_axi_limit_beats max_beats, |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 299 | enum ethosu_axi_limit_mem_type memtype, |
| 300 | uint8_t max_reads, |
| 301 | uint8_t max_writes); |
| 302 | /** |
| 303 | * Set AXI limit parameters for port 1 counter 2. |
| 304 | * \param[in] max_beats Burst split alignment, \ref ethosu_axi_limit_beats. |
| 305 | * \param[in] memtype Cache policy \ref ethosu_axi_limit_mem_type |
| 306 | * \param[in] max_reads Maximum number of outstanding reads. |
| 307 | * \param[in] max_writes Maximum number of outstanding writes. |
| 308 | * \return \ref ethosu_error_codes |
| 309 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 310 | enum ethosu_error_codes ethosu_set_axi_limit2(struct ethosu_device *dev, |
| 311 | enum ethosu_axi_limit_beats max_beats, |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 312 | enum ethosu_axi_limit_mem_type memtype, |
| 313 | uint8_t max_reads, |
| 314 | uint8_t max_writes); |
| 315 | /** |
| 316 | * Set AXI limit parameters for port 1 counter 3. |
| 317 | * \param[in] max_beats Burst split alignment, \ref ethosu_axi_limit_beats. |
| 318 | * \param[in] memtype Cache policy \ref ethosu_axi_limit_mem_type |
| 319 | * \param[in] max_reads Maximum number of outstanding reads. |
| 320 | * \param[in] max_writes Maximum number of outstanding writes. |
| 321 | * \return \ref ethosu_error_codes |
| 322 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 323 | enum ethosu_error_codes ethosu_set_axi_limit3(struct ethosu_device *dev, |
| 324 | enum ethosu_axi_limit_beats max_beats, |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 325 | enum ethosu_axi_limit_mem_type memtype, |
| 326 | uint8_t max_reads, |
| 327 | uint8_t max_writes); |
| 328 | |
| 329 | /** |
| 330 | * Get current command stream queue read position. |
| 331 | * \param[out] qread Pointer to queue read. |
| 332 | * \return \ref ethosu_error_codes |
| 333 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 334 | enum ethosu_error_codes ethosu_get_qread(struct ethosu_device *dev, uint32_t *qread); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 335 | |
| 336 | /** |
| 337 | * Get revision of NPU |
| 338 | * \param[out] revision Pointer to revision read. |
| 339 | * \return \ref ethosu_error_codes |
| 340 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 341 | enum ethosu_error_codes ethosu_get_revision(struct ethosu_device *dev, uint32_t *revision); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 342 | |
| 343 | /** |
| 344 | * Issue run command for the currently programmed |
| 345 | * command stream, starting at current queue read |
| 346 | * position. |
| 347 | * \return \ref ethosu_error_codes |
| 348 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 349 | enum ethosu_error_codes ethosu_set_command_run(struct ethosu_device *dev); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 350 | |
| 351 | /** |
| 352 | * Dump a 1KB section of SHRAM. |
| 353 | * \param[in] section Section offset to 1KB section in SHRAM. |
| 354 | * \param[out] shram_p Pointer to a output area, allocated by the |
| 355 | * caller, where the SHRAM content shall be |
| 356 | * written. |
| 357 | * \return \ref ethosu_error_codes |
| 358 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 359 | enum ethosu_error_codes ethosu_get_shram_data(struct ethosu_device *dev, int section, uint32_t *shram_p); |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 360 | |
| 361 | /** |
| 362 | * Set clock and power q request enable bits. |
| 363 | * \param[in] clock_q Clock q ENABLE/DISABLE \ref clock_q_request. |
| 364 | * \param[in] power_q Power q ENABLE/DISABLE \ref power_q_request. |
| 365 | * \return \ref ethosu_error_codes |
| 366 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 367 | enum ethosu_error_codes ethosu_set_clock_and_power(struct ethosu_device *dev, |
| 368 | enum ethosu_clock_q_request clock_q, |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 369 | enum ethosu_power_q_request power_q); |
| 370 | |
Kristofer Jonsson | 3c43917 | 2020-08-05 09:38:40 +0200 | [diff] [blame] | 371 | /** |
| 372 | * Read register. |
| 373 | * \param[in] address Address to read. |
| 374 | * \return Register value. |
| 375 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 376 | uint32_t ethosu_read_reg(struct ethosu_device *dev, uint32_t address); |
| 377 | |
Kristofer Jonsson | 3c43917 | 2020-08-05 09:38:40 +0200 | [diff] [blame] | 378 | /** |
| 379 | * Write register. |
| 380 | * \param[in] address Address to read. |
| 381 | * \param[in] value Value to be written. |
| 382 | */ |
Bhavik Patel | dae5be0 | 2020-06-18 15:25:15 +0200 | [diff] [blame] | 383 | void ethosu_write_reg(struct ethosu_device *dev, uint32_t address, uint32_t value); |
| 384 | |
Bhavik Patel | 5da4092 | 2020-07-15 10:06:43 +0200 | [diff] [blame] | 385 | /** |
Kristofer Jonsson | 4dc73dc | 2020-10-16 12:33:47 +0200 | [diff] [blame] | 386 | * Write register with shadow variable. |
| 387 | * \param[in] address Address to read. |
| 388 | * \param[in] value Value to be written. |
| 389 | */ |
| 390 | void ethosu_write_reg_shadow(struct ethosu_device *dev, uint32_t address, uint32_t value, uint32_t *shadow); |
| 391 | |
| 392 | /** |
Bhavik Patel | 5da4092 | 2020-07-15 10:06:43 +0200 | [diff] [blame] | 393 | * Save the PMU configuration to ethosu_device struct. |
| 394 | * \param[in] dev Ethos-U device where the PMU configuration is |
| 395 | * saved. |
| 396 | * \return \ref ethosu_error_codes |
| 397 | */ |
| 398 | enum ethosu_error_codes ethosu_save_pmu_config(struct ethosu_device *dev); |
| 399 | |
| 400 | /** |
| 401 | * Restore the PMU configuration from a ethosu_device struct. |
| 402 | * \param[in] dev Ethos-U device where the PMU configuration is |
| 403 | * stored. |
| 404 | * \return \ref ethosu_error_codes |
| 405 | */ |
| 406 | enum ethosu_error_codes ethosu_restore_pmu_config(struct ethosu_device *dev); |
| 407 | |
Bhavik Patel | 5f8dad1 | 2020-09-30 09:06:52 +0200 | [diff] [blame] | 408 | /** |
Kristofer Jonsson | 4dc73dc | 2020-10-16 12:33:47 +0200 | [diff] [blame] | 409 | * Save PMU counters to shadow variables in memory. |
| 410 | * \param[in] dev Ethos-U device where the PMU configuration is |
| 411 | * stored. |
| 412 | * \return \ref ethosu_error_codes |
| 413 | */ |
| 414 | enum ethosu_error_codes ethosu_save_pmu_counters(struct ethosu_device *dev); |
| 415 | |
| 416 | /** |
Bhavik Patel | 5f8dad1 | 2020-09-30 09:06:52 +0200 | [diff] [blame] | 417 | * Check if the STATUS register has any error bits set or not. |
| 418 | * \param[in] dev Ethos-U device to check. |
| 419 | * \return true if any error bits set, |
| 420 | * false otherwise. |
| 421 | */ |
| 422 | bool ethosu_status_has_error(struct ethosu_device *dev); |
| 423 | |
Kristofer Jonsson | 49bdee8 | 2020-04-06 13:21:21 +0200 | [diff] [blame] | 424 | #ifdef __cplusplus |
| 425 | } |
| 426 | #endif |
Kristofer Jonsson | 3c43917 | 2020-08-05 09:38:40 +0200 | [diff] [blame] | 427 | |
| 428 | #endif // ETHOSU_DEVICE_H |