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
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 @@
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 @@
{
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)