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 --- include/ethosu_driver.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'include/ethosu_driver.h') diff --git a/include/ethosu_driver.h b/include/ethosu_driver.h index 053b529..c48a3f2 100644 --- a/include/ethosu_driver.h +++ b/include/ethosu_driver.h @@ -74,11 +74,9 @@ struct ethosu_driver void *semaphore; uint64_t fast_memory; size_t fast_memory_size; + uint32_t power_request_counter; bool status_error; - bool dev_power_always_on; bool reserved; - uint8_t clock_request; - uint8_t power_request; }; struct ethosu_driver_version @@ -157,6 +155,24 @@ int ethosu_init(struct ethosu_driver *drv, */ void ethosu_deinit(struct ethosu_driver *drv); +/** + * Soft resets the Ethos-U device. + */ +bool ethosu_soft_reset(struct ethosu_driver *drv); + +/** + * Request to disable Q-channel power gating of the Ethos-U device. + * Power requests are ref.counted. Increases count. + * (Note: clock gating is made to follow power gating) + */ +bool ethosu_request_power(struct ethosu_driver *drv); + +/** + * Release disable request for Q-channel power gating of the Ethos-U device. + * Power requests are ref.counted. Decreases count. + */ +void ethosu_release_power(struct ethosu_driver *drv); + /** * Get Ethos-U driver version. */ @@ -208,11 +224,6 @@ int ethosu_invoke_async(struct ethosu_driver *drv, */ int ethosu_wait(struct ethosu_driver *drv, bool block); -/** - * Set Ethos-U power mode. - */ -void ethosu_set_power_mode(struct ethosu_driver *drv, bool always_on); - /** * Reserves a driver to execute inference with */ @@ -223,14 +234,6 @@ struct ethosu_driver *ethosu_reserve_driver(void); */ void ethosu_release_driver(struct ethosu_driver *drv); -/** - * Set clock and power request bits - */ -enum ethosu_error_codes set_clock_and_power_request(struct ethosu_driver *drv, - enum ethosu_request_clients client, - enum ethosu_clock_q_request clock_request, - enum ethosu_power_q_request power_request); - /** * Static inline for backwards-compatibility */ -- cgit v1.2.1