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:
parent
34a4b2b916
commit
0bfa223c68
1 changed files with 2 additions and 18 deletions
|
@ -14,24 +14,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zephyr.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 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,
|
static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer,
|
||||||
uint16_t length)
|
uint16_t length)
|
||||||
|
@ -40,7 +24,7 @@ static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer,
|
||||||
size_t to_copy;
|
size_t to_copy;
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
|
||||||
value = prbs_read(PRBS_STATUS, PRBS_WIDTH);
|
value = litex_read(PRBS_STATUS, PRBS_WIDTH);
|
||||||
to_copy = MIN(length, sizeof(value));
|
to_copy = MIN(length, sizeof(value));
|
||||||
|
|
||||||
memcpy(buffer, &value, to_copy);
|
memcpy(buffer, &value, to_copy);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue