lib: utils/timer: Generate FDT timer driver list at compile-time

Instead of having FDT timer driver list hard-coded in the C source,
we generate it using carray.sh at compile-time.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
This commit is contained in:
Anup Patel
2022-05-13 09:26:20 +05:30
committed by Anup Patel
parent 1e62705adc
commit bfeb305e0f
3 changed files with 12 additions and 7 deletions

View File

@@ -12,11 +12,9 @@
#include <sbi_utils/fdt/fdt_helper.h>
#include <sbi_utils/timer/fdt_timer.h>
extern struct fdt_timer fdt_timer_mtimer;
static struct fdt_timer *timer_drivers[] = {
&fdt_timer_mtimer
};
/* List of FDT timer drivers generated at compile time */
extern struct fdt_timer *fdt_timer_drivers[];
extern unsigned long fdt_timer_drivers_size;
static struct fdt_timer dummy = {
.match_table = NULL,
@@ -47,8 +45,8 @@ static int fdt_timer_cold_init(void)
const struct fdt_match *match;
void *fdt = fdt_get_address();
for (pos = 0; pos < array_size(timer_drivers); pos++) {
drv = timer_drivers[pos];
for (pos = 0; pos < fdt_timer_drivers_size; pos++) {
drv = fdt_timer_drivers[pos];
noff = -1;
while ((noff = fdt_find_match(fdt, noff,

View File

@@ -0,0 +1,3 @@
HEADER: sbi_utils/timer/fdt_timer.h
TYPE: struct fdt_timer
NAME: fdt_timer_drivers

View File

@@ -8,5 +8,9 @@
#
libsbiutils-objs-y += timer/aclint_mtimer.o
libsbiutils-objs-y += timer/fdt_timer.o
libsbiutils-objs-y += timer/fdt_timer_drivers.o
carray-fdt_timer_drivers-y += fdt_timer_mtimer
libsbiutils-objs-y += timer/fdt_timer_mtimer.o