entropy: entropy_litex: Use LiteX HAL

Use `litex_read` instead of separate implementation in driver.

Signed-off-by: Michal Sieron <msieron@internships.antmicro.com>
This commit is contained in:
Michal Sieron 2022-04-11 17:24:18 +02:00 committed by Carles Cufí
commit 0bfa223c68

View file

@ -14,24 +14,8 @@
#include <string.h>
#include <zephyr.h>
#define PRBS_STATUS ((volatile uint32_t *)DT_INST_REG_ADDR(0))
#define PRBS_STATUS DT_INST_REG_ADDR(0)
#define PRBS_WIDTH DT_INST_REG_SIZE(0)
#define SUBREG_SIZE_BIT 8
static inline unsigned int prbs_read(volatile uint32_t *reg_status,
volatile uint32_t reg_width)
{
uint32_t shifted_data, shift, i;
uint32_t result = 0;
for (i = 0; i < reg_width; ++i) {
shifted_data = *(reg_status + i);
shift = (reg_width - i - 1) * SUBREG_SIZE_BIT;
result |= (shifted_data << shift);
}
return result;
}
static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer,
uint16_t length)
@ -40,7 +24,7 @@ static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer,
size_t to_copy;
uint32_t value;
value = prbs_read(PRBS_STATUS, PRBS_WIDTH);
value = litex_read(PRBS_STATUS, PRBS_WIDTH);
to_copy = MIN(length, sizeof(value));
memcpy(buffer, &value, to_copy);