Browse Source

lib: utils/fdt: Use kconfig for enabling/disabling

We update FDT support makefile to use kconfig for enabling/disabling.
To avoid compilation errors, we also enable FDT for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Tested-by: Andrew Jones <ajones@ventanamicro.com>
Acked-by: Atish Patra <atishp@rivosinc.com>
Tested-by: Atish Patra <atishp@rivosinc.com>
Anup Patel 1 year ago
parent
commit
68d7b85ec7

+ 9 - 0
include/sbi_utils/fdt/fdt_domain.h

@@ -13,6 +13,8 @@
 
 #include <sbi/sbi_types.h>
 
+#ifdef CONFIG_FDT_DOMAIN
+
 struct sbi_domain;
 
 /**
@@ -70,4 +72,11 @@ void fdt_domain_fixup(void *fdt);
  */
 int fdt_domains_populate(void *fdt);
 
+#else
+
+static inline void fdt_domain_fixup(void *fdt) { }
+static inline int fdt_domains_populate(void *fdt) { return 0; }
+
+#endif
+
 #endif /* __FDT_DOMAIN_H__ */

+ 10 - 0
include/sbi_utils/fdt/fdt_pmu.h

@@ -13,6 +13,8 @@
 
 #include <sbi/sbi_types.h>
 
+#ifdef CONFIG_FDT_PMU
+
 /**
  * Fix up the PMU node in the device tree
  *
@@ -43,4 +45,12 @@ int fdt_pmu_setup(void *fdt);
  */
 uint64_t fdt_pmu_get_select_value(uint32_t event_idx);
 
+#else
+
+static inline void fdt_pmu_fixup(void *fdt) { }
+static inline int fdt_pmu_setup(void *fdt) { return 0; }
+static inline uint64_t fdt_pmu_get_select_value(uint32_t event_idx) { return 0; }
+
+#endif
+
 #endif

+ 4 - 0
lib/utils/Kconfig

@@ -2,6 +2,8 @@
 
 menu "Utils and Drivers Support"
 
+source "$(OPENSBI_SRC_DIR)/lib/utils/fdt/Kconfig"
+
 source "$(OPENSBI_SRC_DIR)/lib/utils/gpio/Kconfig"
 
 source "$(OPENSBI_SRC_DIR)/lib/utils/i2c/Kconfig"
@@ -10,6 +12,8 @@ source "$(OPENSBI_SRC_DIR)/lib/utils/ipi/Kconfig"
 
 source "$(OPENSBI_SRC_DIR)/lib/utils/irqchip/Kconfig"
 
+source "$(OPENSBI_SRC_DIR)/lib/utils/libfdt/Kconfig"
+
 source "$(OPENSBI_SRC_DIR)/lib/utils/reset/Kconfig"
 
 source "$(OPENSBI_SRC_DIR)/lib/utils/serial/Kconfig"

+ 18 - 0
lib/utils/fdt/Kconfig

@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-2-Clause
+
+menuconfig FDT
+	bool "Flattened Device Tree (FDT) support"
+	select LIBFDT
+	default n
+
+if FDT
+
+config FDT_DOMAIN
+	bool "FDT domain support"
+	default n
+
+config FDT_PMU
+	bool "FDT performance monitoring unit (PMU) support"
+	default n
+
+endif

+ 4 - 4
lib/utils/fdt/objects.mk

@@ -4,7 +4,7 @@
 # Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>
 #
 
-libsbiutils-objs-y += fdt/fdt_domain.o
-libsbiutils-objs-y += fdt/fdt_pmu.o
-libsbiutils-objs-y += fdt/fdt_helper.o
-libsbiutils-objs-y += fdt/fdt_fixup.o
+libsbiutils-objs-$(CONFIG_FDT_DOMAIN) += fdt/fdt_domain.o
+libsbiutils-objs-$(CONFIG_FDT_PMU) += fdt/fdt_pmu.o
+libsbiutils-objs-$(CONFIG_FDT) += fdt/fdt_helper.o
+libsbiutils-objs-$(CONFIG_FDT) += fdt/fdt_fixup.o

+ 1 - 0
lib/utils/gpio/Kconfig

@@ -4,6 +4,7 @@ menu "GPIO Support"
 
 config FDT_GPIO
 	bool "FDT based GPIO drivers"
+	depends on FDT
 	select GPIO
 	default n
 

+ 1 - 0
lib/utils/i2c/Kconfig

@@ -4,6 +4,7 @@ menu "I2C Support"
 
 config FDT_I2C
 	bool "FDT based I2C drivers"
+	depends on FDT
 	select I2C
 	default n
 

+ 1 - 0
lib/utils/ipi/Kconfig

@@ -4,6 +4,7 @@ menu "IPI Device Support"
 
 config FDT_IPI
 	bool "FDT based ipi drivers"
+	depends on FDT
 	default n
 
 if FDT_IPI

+ 1 - 0
lib/utils/irqchip/Kconfig

@@ -4,6 +4,7 @@ menu "Interrupt Controller Support"
 
 config FDT_IRQCHIP
 	bool "FDT based interrupt controller drivers"
+	depends on FDT
 	default n
 
 if FDT_IRQCHIP

+ 5 - 0
lib/utils/libfdt/Kconfig

@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: BSD-2-Clause
+
+config LIBFDT
+	bool
+	default n

+ 1 - 1
lib/utils/libfdt/objects.mk

@@ -12,5 +12,5 @@ libfdt_files = fdt.o fdt_addresses.o fdt_check.o fdt_empty_tree.o fdt_ro.o fdt_r
 $(foreach file, $(libfdt_files), \
         $(eval CFLAGS_$(file) = -I$(src)/../../utils/libfdt))
 
-libsbiutils-objs-y += $(addprefix libfdt/,$(libfdt_files))
+libsbiutils-objs-$(CONFIG_LIBFDT) += $(addprefix libfdt/,$(libfdt_files))
 libsbiutils-genflags-y  += -I$(libsbiutils_dir)/libfdt/

+ 1 - 0
lib/utils/reset/Kconfig

@@ -4,6 +4,7 @@ menu "System Reset Support"
 
 config FDT_RESET
 	bool "FDT based reset drivers"
+	depends on FDT
 	default n
 
 if FDT_RESET

+ 1 - 0
lib/utils/serial/Kconfig

@@ -4,6 +4,7 @@ menu "Serial Device Support"
 
 config FDT_SERIAL
 	bool "FDT based serial drivers"
+	depends on FDT
 	default n
 
 if FDT_SERIAL

+ 1 - 0
lib/utils/timer/Kconfig

@@ -4,6 +4,7 @@ menu "Timer Device Support"
 
 config FDT_TIMER
 	bool "FDT based timer drivers"
+	depends on FDT
 	default n
 
 if FDT_TIMER

+ 1 - 0
platform/andes/ae350/Kconfig

@@ -2,6 +2,7 @@
 
 config PLATFORM_ANDES_AE350
 	bool
+	select FDT
 	select IRQCHIP_PLIC
 	select SERIAL_UART8250
 	default y

+ 1 - 0
platform/fpga/ariane/Kconfig

@@ -2,6 +2,7 @@
 
 config PLATFORM_ARIANE_FPGA
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_UART8250

+ 1 - 0
platform/fpga/openpiton/Kconfig

@@ -2,6 +2,7 @@
 
 config PLATFORM_OPENPITON_FPGA
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_UART8250

+ 3 - 0
platform/generic/Kconfig

@@ -2,4 +2,7 @@
 
 config PLATFORM_GENERIC
 	bool
+	select FDT
+	select FDT_DOMAIN
+	select FDT_PMU
 	default y

+ 1 - 0
platform/kendryte/k210/Kconfig

@@ -2,6 +2,7 @@
 
 config PLATFORM_KENDRYTE_K210
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_SIFIVE

+ 1 - 0
platform/nuclei/ux600/Kconfig

@@ -2,6 +2,7 @@
 
 config PLATFORM_NUCLEI_UX600
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_SIFIVE

+ 0 - 1
platform/nuclei/ux600/platform.c

@@ -8,7 +8,6 @@
  *   hqfang <578567190@qq.com>
  */
 
-#include <libfdt.h>
 #include <sbi/riscv_asm.h>
 #include <sbi/riscv_io.h>
 #include <sbi/riscv_encoding.h>