diff options
author | Anup Patel <apatel@ventanamicro.com> | 2024-08-06 10:45:11 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2024-12-06 09:26:40 +0530 |
commit | ff4769bf08b50c61bb48f37ea00a17737096e2b5 (patch) | |
tree | c7f807fb05a5c379afa7a8c73706c8b802304cb9 | |
parent | 9d760b810e184479c65c2537594beaf4657f02ed (diff) | |
download | opensbi-ff4769bf08b50c61bb48f37ea00a17737096e2b5.zip opensbi-ff4769bf08b50c61bb48f37ea00a17737096e2b5.tar.gz opensbi-ff4769bf08b50c61bb48f37ea00a17737096e2b5.tar.bz2 |
lib: utils: Add simple FDT based HSM driver framework
The generic platform can have multiple HSM drivers so add a simple
FDT based HSM driver framework.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
-rw-r--r-- | include/sbi_utils/hsm/fdt_hsm.h | 26 | ||||
-rw-r--r-- | lib/utils/Kconfig | 2 | ||||
-rw-r--r-- | lib/utils/hsm/Kconfig | 10 | ||||
-rw-r--r-- | lib/utils/hsm/fdt_hsm.c | 22 | ||||
-rw-r--r-- | lib/utils/hsm/fdt_hsm_drivers.carray | 3 | ||||
-rw-r--r-- | lib/utils/hsm/objects.mk | 11 | ||||
-rw-r--r-- | platform/generic/configs/defconfig | 1 | ||||
-rw-r--r-- | platform/generic/platform.c | 2 |
8 files changed, 77 insertions, 0 deletions
diff --git a/include/sbi_utils/hsm/fdt_hsm.h b/include/sbi_utils/hsm/fdt_hsm.h new file mode 100644 index 0000000..58061af --- /dev/null +++ b/include/sbi_utils/hsm/fdt_hsm.h @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Ventana Micro Systems Inc. + * + * Authors: + * Anup Patel <apatel@ventanamicro.com> + */ + +#ifndef __FDT_HSM_H__ +#define __FDT_HSM_H__ + +#include <sbi/sbi_types.h> +#include <sbi_utils/fdt/fdt_driver.h> + +#ifdef CONFIG_FDT_HSM + +void fdt_hsm_init(const void *fdt); + +#else + +static inline void fdt_hsm_init(const void *fdt) { } + +#endif + +#endif diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig index 3f32c1c..c860a18 100644 --- a/lib/utils/Kconfig +++ b/lib/utils/Kconfig @@ -6,6 +6,8 @@ source "$(OPENSBI_SRC_DIR)/lib/utils/fdt/Kconfig" source "$(OPENSBI_SRC_DIR)/lib/utils/gpio/Kconfig" +source "$(OPENSBI_SRC_DIR)/lib/utils/hsm/Kconfig" + source "$(OPENSBI_SRC_DIR)/lib/utils/i2c/Kconfig" source "$(OPENSBI_SRC_DIR)/lib/utils/ipi/Kconfig" diff --git a/lib/utils/hsm/Kconfig b/lib/utils/hsm/Kconfig new file mode 100644 index 0000000..3150611 --- /dev/null +++ b/lib/utils/hsm/Kconfig @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-2-Clause + +menu "HSM Device Support" + +config FDT_HSM + bool "FDT based HSM drivers" + depends on FDT + default n + +endmenu diff --git a/lib/utils/hsm/fdt_hsm.c b/lib/utils/hsm/fdt_hsm.c new file mode 100644 index 0000000..162b986 --- /dev/null +++ b/lib/utils/hsm/fdt_hsm.c @@ -0,0 +1,22 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Ventana Micro Systems Inc. + * + * Authors: + * Anup Patel <apatel@ventanamicro.com> + */ + +#include <sbi_utils/hsm/fdt_hsm.h> + +/* List of FDT HSM drivers generated at compile time */ +extern const struct fdt_driver *const fdt_hsm_drivers[]; + +void fdt_hsm_init(const void *fdt) +{ + /* + * Platforms might have multiple HSM devices or might + * not have any so probe all and don't fail. + */ + fdt_driver_init_all(fdt, fdt_hsm_drivers); +} diff --git a/lib/utils/hsm/fdt_hsm_drivers.carray b/lib/utils/hsm/fdt_hsm_drivers.carray new file mode 100644 index 0000000..73680a2 --- /dev/null +++ b/lib/utils/hsm/fdt_hsm_drivers.carray @@ -0,0 +1,3 @@ +HEADER: sbi_utils/hsm/fdt_hsm.h +TYPE: const struct fdt_driver +NAME: fdt_hsm_drivers diff --git a/lib/utils/hsm/objects.mk b/lib/utils/hsm/objects.mk new file mode 100644 index 0000000..49337bf --- /dev/null +++ b/lib/utils/hsm/objects.mk @@ -0,0 +1,11 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2024 Ventana Micro Systems Inc. +# +# Authors: +# Anup Patel <apatel@ventanamicro.com> +# + +libsbiutils-objs-$(CONFIG_FDT_HSM) += hsm/fdt_hsm.o +libsbiutils-objs-$(CONFIG_FDT_HSM) += hsm/fdt_hsm_drivers.carray.o diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig index 54300fb..2efc713 100644 --- a/platform/generic/configs/defconfig +++ b/platform/generic/configs/defconfig @@ -10,6 +10,7 @@ CONFIG_FDT_GPIO=y CONFIG_FDT_GPIO_DESIGNWARE=y CONFIG_FDT_GPIO_SIFIVE=y CONFIG_FDT_GPIO_STARFIVE=y +CONFIG_FDT_HSM=y CONFIG_FDT_I2C=y CONFIG_FDT_I2C_SIFIVE=y CONFIG_FDT_I2C_DW=y diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 842e526..5f309a2 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -21,6 +21,7 @@ #include <sbi_utils/fdt/fdt_fixup.h> #include <sbi_utils/fdt/fdt_helper.h> #include <sbi_utils/fdt/fdt_pmu.h> +#include <sbi_utils/hsm/fdt_hsm.h> #include <sbi_utils/irqchip/fdt_irqchip.h> #include <sbi_utils/irqchip/imsic.h> #include <sbi_utils/serial/fdt_serial.h> @@ -249,6 +250,7 @@ static int generic_early_init(bool cold_boot) if (cold_boot) { fdt_reset_init(fdt); fdt_suspend_init(fdt); + fdt_hsm_init(fdt); if (semihosting_enabled()) rc = semihosting_init(); |