diff options
author | Bhavik Patel <bhavik.patel@arm.com> | 2020-07-15 10:06:43 +0200 |
---|---|---|
committer | tim.hall <tim.hall@arm.com> | 2020-07-22 12:21:58 +0000 |
commit | 5da4092d07c31acaa3d44ac57fa3b02a3be67182 (patch) | |
tree | 04b9a3a61d81fe6ad599bfa55b47315b87fe6ec9 /src/ethosu_device.c | |
parent | f50578199cca79b73596672a4838640130d1aa8f (diff) | |
download | ethos-u-core-driver-5da4092d07c31acaa3d44ac57fa3b02a3be67182.tar.gz |
MLBEDSW-2594 Initialize the Ethos-U before every job
This includes resetting the Ethos-U and restoring the
previosuly saved PMU configuration (if any).
Change-Id: Id952fb6fef513468952b6a469e857510f8c0214c
Diffstat (limited to 'src/ethosu_device.c')
-rw-r--r-- | src/ethosu_device.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ethosu_device.c b/src/ethosu_device.c index 9bda87d..60fc243 100644 --- a/src/ethosu_device.c +++ b/src/ethosu_device.c @@ -551,3 +551,42 @@ void ethosu_write_reg(struct ethosu_device *dev, uint32_t address, uint32_t valu UNUSED(value); #endif } + +enum ethosu_error_codes ethosu_save_pmu_config(struct ethosu_device *dev) +{ +#if !defined(ARM_NPU_STUB) + dev->pmccntr = ETHOSU_PMU_Get_CCNTR(); + for (uint32_t i = 0; i < ETHOSU_PMU_NCOUNTERS; i++) + { + dev->pmu_evcntr[i] = ETHOSU_PMU_Get_EVCNTR(i); + dev->pmu_evtypr[i] = ETHOSU_PMU_Get_EVTYPER(i); + } + if (!dev->restore_pmu_config) + { + dev->restore_pmu_config = true; + } +#else + UNUSED(dev); +#endif + + return ETHOSU_SUCCESS; +} + +enum ethosu_error_codes ethosu_restore_pmu_config(struct ethosu_device *dev) +{ +#if !defined(ARM_NPU_STUB) + if (dev->restore_pmu_config) + { + ETHOSU_PMU_Set_CCNTR(dev->pmccntr); + for (uint32_t i = 0; i < ETHOSU_PMU_NCOUNTERS; i++) + { + ETHOSU_PMU_Set_EVCNTR(i, dev->pmu_evcntr[i]); + ETHOSU_PMU_Set_EVTYPER(i, dev->pmu_evtypr[i]); + } + } +#else + UNUSED(dev); +#endif + + return ETHOSU_SUCCESS; +} |