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/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 @@
     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
@@ -158,6 +156,24 @@
 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.
  */
 void ethosu_get_driver_version(struct ethosu_driver_version *ver);
@@ -209,11 +225,6 @@
 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
  */
 struct ethosu_driver *ethosu_reserve_driver(void);
@@ -224,14 +235,6 @@
 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
  */
 static inline int ethosu_invoke_v2(const void *custom_data_ptr,