From 47baf51728fcaaacbd8a332b8d03717d6c03ace1 Mon Sep 17 00:00:00 2001 From: Luigi Ghionda Date: Thu, 30 May 2024 16:57:01 +0200 Subject: [PATCH] Add support to read neureka ECC-related internal registers (cherry picked from commit fe2be29f174072950d7ca448a2bf2d7b05ba7215) --- inc/pulp_nnx_neureka.h | 6 ++++++ neureka/hal/neureka_task_defs.h | 2 ++ src/pulp_nnx_neureka.c | 4 ++++ util/hwpe.c | 8 ++++++++ util/hwpe.h | 1 + 5 files changed, 21 insertions(+) diff --git a/inc/pulp_nnx_neureka.h b/inc/pulp_nnx_neureka.h index 80096c8..d2c0542 100644 --- a/inc/pulp_nnx_neureka.h +++ b/inc/pulp_nnx_neureka.h @@ -59,3 +59,9 @@ int neureka_nnx_resolve_check(neureka_dev_t *dev, neureka_task_t *task); * Block until you can resolve the task. */ void neureka_nnx_resolve_wait(neureka_dev_t *dev, neureka_task_t *task); + +/** neureka_nnx_read_ecc_regs + * + * Read ECC-related internal registers. + */ +void neureka_nnx_read_ecc_regs(neureka_dev_t *dev, uint32_t *ecc_regs); diff --git a/neureka/hal/neureka_task_defs.h b/neureka/hal/neureka_task_defs.h index 7a4ca3e..3360748 100644 --- a/neureka/hal/neureka_task_defs.h +++ b/neureka/hal/neureka_task_defs.h @@ -41,6 +41,8 @@ #define NEUREKA_OUTPUT_BANDWIDTH_BYTES (32) #define NEUREKA_WEIGHT_BANDWIDTH_BYTES (32) +#define NEUREKA_ECC_REGS_NUM (4) + /* TASK REGISTERS */ // job configuration diff --git a/src/pulp_nnx_neureka.c b/src/pulp_nnx_neureka.c index b814f23..73177b6 100644 --- a/src/pulp_nnx_neureka.c +++ b/src/pulp_nnx_neureka.c @@ -74,3 +74,7 @@ void neureka_nnx_resolve_wait(neureka_dev_t *dev, neureka_task_t *task) { neureka_bsp_event_wait_and_clear(); } } + +void neureka_nnx_read_ecc_regs(neureka_dev_t *dev, uint32_t *ecc_regs) { + hwpe_ecc_regs_check(&dev->hwpe_dev, ecc_regs, NEUREKA_ECC_REGS_NUM); +} diff --git a/util/hwpe.c b/util/hwpe.c index 0430081..4b52772 100644 --- a/util/hwpe.c +++ b/util/hwpe.c @@ -29,6 +29,8 @@ #define HWPE_SOFT_CLEAR 5 #define HWPE_SWSYNC 6 #define HWPE_TASK_REG_OFFSET 8 +#define HWPE_PARAMS_REG_OFFSET 48 +#define HWPE_ECC_REG_OFFSET (HWPE_TASK_REG_OFFSET+HWPE_PARAMS_REG_OFFSET) inline void hwpe_reg_write(hwpe_dev_t *dev, int reg, uint32_t value) { dev->base_addr[reg] = value; @@ -83,3 +85,9 @@ void hwpe_task_queue_release(hwpe_dev_t *dev) { uint8_t hwpe_last_task_id(hwpe_dev_t *dev) { return (uint8_t)hwpe_reg_read(dev, HWPE_RUNNING_JOB); } + +void hwpe_ecc_regs_check(hwpe_dev_t *dev, uint32_t *data, int len) { + for (int i = 0; i < len; i++) { + data[i] = hwpe_reg_read(dev, HWPE_ECC_REG_OFFSET + i); + } +} diff --git a/util/hwpe.h b/util/hwpe.h index 52bf912..3fbdba7 100644 --- a/util/hwpe.h +++ b/util/hwpe.h @@ -39,5 +39,6 @@ void hwpe_task_queue_write_task(hwpe_dev_t *dev, uint32_t *data, int len); void hwpe_task_queue_release_and_run(hwpe_dev_t *dev); void hwpe_task_queue_release(hwpe_dev_t *dev); uint8_t hwpe_last_task_id(hwpe_dev_t *dev); +void hwpe_ecc_regs_check(hwpe_dev_t *dev, uint32_t *data, int len); #endif // !__HWPE_H__