Minor bugfixes and clean up

Change error message to LOG_ERR from LOG_DEBUG and simplify
error checks

Remove redundant code in driver

Disable the PMU before enabling power/clock gating

Change-Id: I3092113250c1b165d985194ca2da213622629488
diff --git a/src/ethosu_device_u55_u65.c b/src/ethosu_device_u55_u65.c
index 06c6afb..f5a72b2 100644
--- a/src/ethosu_device_u55_u65.c
+++ b/src/ethosu_device_u55_u65.c
@@ -166,16 +166,18 @@
 
     // If a fault has occured, the NPU needs to be reset
     if (dev->reg->STATUS.bus_status || dev->reg->STATUS.cmd_parse_error || dev->reg->STATUS.wd_fault ||
-        dev->reg->STATUS.ecc_fault)
+        dev->reg->STATUS.ecc_fault || !dev->reg->STATUS.cmd_end_reached)
     {
-        LOG_DEBUG("NPU fault. status=0x%08x, qread=%" PRIu32, dev->reg->STATUS.word, dev->reg->QREAD.word);
+        LOG_ERR("NPU fault. status=0x%08x, qread=%" PRIu32 ", cmd_end_reached=%" PRIu32,
+                dev->reg->STATUS.word,
+                dev->reg->QREAD.word,
+                dev->reg->STATUS.cmd_end_reached);
         ethosu_dev_soft_reset(dev);
         ethosu_dev_set_clock_and_power(dev, ETHOSU_CLOCK_Q_UNCHANGED, ETHOSU_POWER_Q_DISABLE);
         return false;
     }
 
-    // Verify that the cmd stream finished executing
-    return dev->reg->STATUS.cmd_end_reached ? true : false;
+    return true;
 }
 
 bool ethosu_dev_verify_access_state(struct ethosu_device *dev)
diff --git a/src/ethosu_driver.c b/src/ethosu_driver.c
index 1c78bcc..522f3e8 100644
--- a/src/ethosu_driver.c
+++ b/src/ethosu_driver.c
@@ -522,25 +522,12 @@
     // NPU might have lost power and thus its settings and state
     if (!drv->dev_power_always_on)
     {
-        bool axi_reinit = true;
-        // Only soft reset if security state or privilege level needs changing
-        if (ethosu_dev_verify_access_state(drv->dev) != true)
-        {
-            if (ethosu_dev_soft_reset(drv->dev) != ETHOSU_SUCCESS)
-            {
-                return -1;
-            }
-            axi_reinit = false;
-        }
-
-        // Set power ON during the inference
+        // Set power ON during the inference. Will soft reset if security state or
+        // privilege level needs changing
         set_clock_and_power_request(drv, ETHOSU_INFERENCE_REQUEST, ETHOSU_CLOCK_Q_ENABLE, ETHOSU_POWER_Q_DISABLE);
 
-        // If a soft reset occured, AXI reinit has already been performed
-        if (axi_reinit)
-        {
-            ethosu_dev_axi_init(drv->dev);
-        }
+        // Make sure AXI settings are applied
+        ethosu_dev_axi_init(drv->dev);
     }
 
     drv->status_error = false;
diff --git a/src/ethosu_pmu.c b/src/ethosu_pmu.c
index 6feb324..647f3b0 100644
--- a/src/ethosu_pmu.c
+++ b/src/ethosu_pmu.c
@@ -97,8 +97,8 @@
 void ETHOSU_PMU_Disable(struct ethosu_driver *drv)
 {
     LOG_DEBUG("Disable PMU");
-    set_clock_and_power_request(drv, ETHOSU_PMU_REQUEST, ETHOSU_CLOCK_Q_ENABLE, ETHOSU_POWER_Q_ENABLE);
     drv->dev->reg->PMCR.word = 0;
+    set_clock_and_power_request(drv, ETHOSU_PMU_REQUEST, ETHOSU_CLOCK_Q_ENABLE, ETHOSU_POWER_Q_ENABLE);
 }
 
 void ETHOSU_PMU_Set_EVTYPER(struct ethosu_driver *drv, uint32_t num, enum ethosu_pmu_event_type type)