diff options
author | Anup Patel <apatel@ventanamicro.com> | 2022-05-13 06:56:06 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2022-05-13 06:56:06 +0300 |
commit | 73cf51191403be2ebdf9f9a1d17812d1550316ff (patch) | |
tree | 84da2c707e8e51365149f37584489b124e777e75 /lib | |
parent | 7fb474b9dde5d56e0d4d6a0c1627337694cdc2f2 (diff) | |
download | opensbi-73cf51191403be2ebdf9f9a1d17812d1550316ff.tar.xz |
lib: utils/reset: Generate FDT reset driver list at compile-time
Instead of having FDT reset 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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/reset/fdt_reset.c | 22 | ||||
-rw-r--r-- | lib/utils/reset/fdt_reset_drivers.carray | 3 | ||||
-rw-r--r-- | lib/utils/reset/objects.mk | 12 |
3 files changed, 20 insertions, 17 deletions
diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c index 66281cb..4334586 100644 --- a/lib/utils/reset/fdt_reset.c +++ b/lib/utils/reset/fdt_reset.c @@ -13,21 +13,9 @@ #include <sbi_utils/fdt/fdt_helper.h> #include <sbi_utils/reset/fdt_reset.h> -extern struct fdt_reset fdt_poweroff_gpio; -extern struct fdt_reset fdt_reset_gpio; -extern struct fdt_reset fdt_reset_htif; -extern struct fdt_reset fdt_reset_sifive_test; -extern struct fdt_reset fdt_reset_sunxi_wdt; -extern struct fdt_reset fdt_reset_thead; - -static struct fdt_reset *reset_drivers[] = { - &fdt_poweroff_gpio, - &fdt_reset_gpio, - &fdt_reset_htif, - &fdt_reset_sifive_test, - &fdt_reset_sunxi_wdt, - &fdt_reset_thead, -}; +/* List of FDT reset drivers generated at compile time */ +extern struct fdt_reset *fdt_reset_drivers[]; +extern unsigned long fdt_reset_drivers_size; int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv) { @@ -54,6 +42,6 @@ void fdt_reset_init(void) int pos; void *fdt = fdt_get_address(); - for (pos = 0; pos < array_size(reset_drivers); pos++) - fdt_reset_driver_init(fdt, reset_drivers[pos]); + for (pos = 0; pos < fdt_reset_drivers_size; pos++) + fdt_reset_driver_init(fdt, fdt_reset_drivers[pos]); } diff --git a/lib/utils/reset/fdt_reset_drivers.carray b/lib/utils/reset/fdt_reset_drivers.carray new file mode 100644 index 0000000..6ff799c --- /dev/null +++ b/lib/utils/reset/fdt_reset_drivers.carray @@ -0,0 +1,3 @@ +HEADER: sbi_utils/reset/fdt_reset.h +TYPE: struct fdt_reset +NAME: fdt_reset_drivers diff --git a/lib/utils/reset/objects.mk b/lib/utils/reset/objects.mk index 6c95db3..8cddcdf 100644 --- a/lib/utils/reset/objects.mk +++ b/lib/utils/reset/objects.mk @@ -8,9 +8,21 @@ # libsbiutils-objs-y += reset/fdt_reset.o +libsbiutils-objs-y += reset/fdt_reset_drivers.o + +carray-fdt_reset_drivers-y += fdt_poweroff_gpio +carray-fdt_reset_drivers-y += fdt_reset_gpio libsbiutils-objs-y += reset/fdt_reset_gpio.o + +carray-fdt_reset_drivers-y += fdt_reset_htif libsbiutils-objs-y += reset/fdt_reset_htif.o + +carray-fdt_reset_drivers-y += fdt_reset_sifive_test libsbiutils-objs-y += reset/fdt_reset_sifive_test.o + +carray-fdt_reset_drivers-y += fdt_reset_sunxi_wdt libsbiutils-objs-y += reset/fdt_reset_sunxi_wdt.o + +carray-fdt_reset_drivers-y += fdt_reset_thead libsbiutils-objs-y += reset/fdt_reset_thead.o libsbiutils-objs-y += reset/fdt_reset_thead_asm.o |