From dc18ceaa54957d5ac05292b363a5ac6fe479f409 Mon Sep 17 00:00:00 2001 From: Mikael Olsson Date: Fri, 16 Feb 2024 11:04:46 +0100 Subject: Add NPU device type to capabilities In preparation to support the Linux kernel driver directly managing the NPU without a subsystem. A NPU device type has been added to the capabilities to be able to specify what kind of NPU is used. Change-Id: I45345b7d75d234f821d70b858453d3af2a99194e Signed-off-by: Mikael Olsson --- driver_library/include/ethosu.hpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'driver_library/include/ethosu.hpp') diff --git a/driver_library/include/ethosu.hpp b/driver_library/include/ethosu.hpp index 27f6828..d0e391c 100644 --- a/driver_library/include/ethosu.hpp +++ b/driver_library/include/ethosu.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates + * SPDX-FileCopyrightText: Copyright 2020-2024 Arm Limited and/or its affiliates * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may @@ -106,18 +106,39 @@ public: * Hardware Configuration * @macsPerClockCycle: MACs per clock cycle * @cmdStreamVersion: NPU command stream version + * @type: NPU device type * @customDma: Custom DMA enabled */ struct HardwareConfiguration { public: - HardwareConfiguration(uint32_t _macsPerClockCycle = 0, uint32_t _cmdStreamVersion = 0, bool _customDma = false) : - macsPerClockCycle(_macsPerClockCycle), cmdStreamVersion(_cmdStreamVersion), customDma(_customDma) {} + HardwareConfiguration(uint32_t _macsPerClockCycle = 0, + uint32_t _cmdStreamVersion = 0, + uint32_t _type = static_cast(DeviceType::UNKNOWN), + bool _customDma = false) : + macsPerClockCycle(_macsPerClockCycle), + cmdStreamVersion(_cmdStreamVersion), customDma(_customDma) { + + if (_type > static_cast(DeviceType::DIRECT)) { + throw EthosU::Exception(std::string("Invalid device type: ").append(std::to_string(_type)).c_str()); + } + + type = static_cast(_type); + } + + enum class DeviceType { + UNKNOWN = 0, + SUBSYSTEM, + DIRECT, + }; uint32_t macsPerClockCycle; uint32_t cmdStreamVersion; + DeviceType type; bool customDma; }; +std::ostream &operator<<(std::ostream &out, const HardwareConfiguration::DeviceType &deviceType); + /** * Device capabilities * @hwId: Hardware -- cgit v1.2.1