From 301399d9e0b619fb2e229c9a9223aaf31ec6bcfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonny=20Sv=C3=A4rd?= Date: Tue, 26 Apr 2022 18:31:24 +0200 Subject: Refactor power handling Add reference counted ethosu_request_power(), ethosu_release_power() functions. While there are active requests, disable the Q-channel power gating of the Ethos-U device, leaving the device powered on. Note that clock gating is implemented to follow the state of the power gating. Add ethosu_soft_reset() function. Restore power- and clock gating state after reset. Refactor and simplify driver code to use the new functions. Change-Id: I9756572c5c3e51b2be244bcea856d88e890e2d40 --- src/ethosu_pmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ethosu_pmu.c') diff --git a/src/ethosu_pmu.c b/src/ethosu_pmu.c index e11636a..df69026 100644 --- a/src/ethosu_pmu.c +++ b/src/ethosu_pmu.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Arm Limited. All rights reserved. + * Copyright (c) 2019-2022 Arm Limited. * * SPDX-License-Identifier: Apache-2.0 * @@ -90,7 +90,7 @@ void ETHOSU_PMU_Enable(struct ethosu_driver *drv) LOG_DEBUG("Enable PMU"); struct pmcr_r pmcr = {0}; pmcr.cnt_en = 1; - set_clock_and_power_request(drv, ETHOSU_PMU_REQUEST, ETHOSU_CLOCK_Q_DISABLE, ETHOSU_POWER_Q_DISABLE); + ethosu_request_power(drv); drv->dev->reg->PMCR.word = pmcr.word; } @@ -98,7 +98,7 @@ void ETHOSU_PMU_Disable(struct ethosu_driver *drv) { LOG_DEBUG("Disable PMU"); drv->dev->reg->PMCR.word = 0; - set_clock_and_power_request(drv, ETHOSU_PMU_REQUEST, ETHOSU_CLOCK_Q_ENABLE, ETHOSU_POWER_Q_ENABLE); + ethosu_release_power(drv); } uint32_t ETHOSU_PMU_Get_NumEventCounters(void) -- cgit v1.2.1