Skip to content

Commit 0bfa223

Browse files
michalsieroncarlescufi
authored andcommitted
entropy: entropy_litex: Use LiteX HAL
Use `litex_read` instead of separate implementation in driver. Signed-off-by: Michal Sieron <[email protected]>
1 parent 34a4b2b commit 0bfa223

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

drivers/entropy/entropy_litex.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,8 @@
1414
#include <string.h>
1515
#include <zephyr.h>
1616

17-
#define PRBS_STATUS ((volatile uint32_t *)DT_INST_REG_ADDR(0))
17+
#define PRBS_STATUS DT_INST_REG_ADDR(0)
1818
#define PRBS_WIDTH DT_INST_REG_SIZE(0)
19-
#define SUBREG_SIZE_BIT 8
20-
21-
static inline unsigned int prbs_read(volatile uint32_t *reg_status,
22-
volatile uint32_t reg_width)
23-
{
24-
uint32_t shifted_data, shift, i;
25-
uint32_t result = 0;
26-
27-
for (i = 0; i < reg_width; ++i) {
28-
shifted_data = *(reg_status + i);
29-
shift = (reg_width - i - 1) * SUBREG_SIZE_BIT;
30-
result |= (shifted_data << shift);
31-
}
32-
33-
return result;
34-
}
3519

3620
static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer,
3721
uint16_t length)
@@ -40,7 +24,7 @@ static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer,
4024
size_t to_copy;
4125
uint32_t value;
4226

43-
value = prbs_read(PRBS_STATUS, PRBS_WIDTH);
27+
value = litex_read(PRBS_STATUS, PRBS_WIDTH);
4428
to_copy = MIN(length, sizeof(value));
4529

4630
memcpy(buffer, &value, to_copy);

0 commit comments

Comments
 (0)