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