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