All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] OpenSBI Kconfig Support
@ 2022-07-18 12:41 Anup Patel
  2022-07-18 12:41 ` [PATCH 01/14] Makefile: Add initial kconfig support for each platform Anup Patel
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:41 UTC (permalink / raw)
  To: opensbi

In future, we will see more drivers in OpenSBI for system reset, serial port,
power management, etc platform specific devices. We need platform specific
compile time configuration to allow users control the size of OpenSBI generic
firmware binaries by only enabling desired drivers. In other words, users
should be allowed to restrict the set of RISC-V platforms on which OpenSBI
generic firmwares built by them can run.

To address above, we add Kconfig support for OpenSBI platforms using the
kconfig-frontends project which is a standalone kconfig parser.

The kconfig-frontends is available as a package/receipe on various distros
(such as Debian, UBuntu, OpenSUSE, etc) and Yocto project.

To try OpenSBI Kconfig support with generic platform, here are few
example commands:
make PLATFORM=generic             <-- builds OpenSBI using "defconfig"
make PLATFORM=generic menuconfig  <-- launches graphical interface for changes

These patches can also be found in the kconfig_v1 brach at:
https://github.com/avpatel/opensbi.git

Anup Patel (14):
  Makefile: Add initial kconfig support for each platform
  Makefile: Compile lib/utils sources separately for each platform
  lib: utils/serial: Use kconfig for enabling/disabling drivers
  lib: utils/reset: Use kconfig for enabling/disabling drivers
  lib: utils/sys: Use kconfig for enabling/disabling drivers
  lib: utils/timer: Use kconfig for enabling/disabling drivers
  lib: utils/ipi: Use kconfig for enabling/disabling drivers
  lib: utils/irqchip: Use kconfig for enabling/disabling drivers
  lib: utils/i2c: Use kconfig for enabling/disabling drivers
  lib: utils/gpio: Use kconfig for enabling/disabling drivers
  lib: utils/fdt: Use kconfig for enabling/disabling
  platform: generic: Use kconfig for enabling/disabling overrides
  platform: Remove redundant config.mk from all platforms
  docs: Update documentation for kconfig support

 Kconfig                                   |  23 +++++
 Makefile                                  | 102 ++++++++++++++++------
 README.md                                 |  25 +++++-
 docs/firmware/fw_dynamic.md               |   2 +-
 docs/firmware/fw_jump.md                  |   4 +-
 docs/firmware/fw_payload.md               |   4 +-
 docs/library_usage.md                     |   6 +-
 docs/platform/platform.md                 |   4 +-
 docs/platform_guide.md                    |   9 +-
 firmware/Kconfig                          |   1 +
 include/sbi_utils/fdt/fdt_domain.h        |   9 ++
 include/sbi_utils/fdt/fdt_pmu.h           |  10 +++
 include/sbi_utils/ipi/fdt_ipi.h           |   9 ++
 include/sbi_utils/irqchip/fdt_irqchip.h   |  10 +++
 include/sbi_utils/irqchip/imsic.h         |  10 +++
 include/sbi_utils/reset/fdt_reset.h       |  12 +++
 include/sbi_utils/serial/fdt_serial.h     |   8 ++
 include/sbi_utils/timer/fdt_timer.h       |   9 ++
 lib/utils/Kconfig                         |  25 ++++++
 lib/utils/fdt/Kconfig                     |  18 ++++
 lib/utils/fdt/objects.mk                  |   8 +-
 lib/utils/gpio/Kconfig                    |  23 +++++
 lib/utils/gpio/objects.mk                 |  10 +--
 lib/utils/i2c/Kconfig                     |  23 +++++
 lib/utils/i2c/objects.mk                  |  10 +--
 lib/utils/ipi/Kconfig                     |  23 +++++
 lib/utils/ipi/objects.mk                  |  10 +--
 lib/utils/irqchip/Kconfig                 |  41 +++++++++
 lib/utils/irqchip/objects.mk              |  22 ++---
 lib/utils/libfdt/Kconfig                  |   5 ++
 lib/utils/libfdt/objects.mk               |   4 +-
 lib/utils/reset/Kconfig                   |  37 ++++++++
 lib/utils/reset/objects.mk                |  28 +++---
 lib/utils/serial/Kconfig                  |  73 ++++++++++++++++
 lib/utils/serial/objects.mk               |  44 +++++-----
 lib/utils/sys/Kconfig                     |  13 +++
 lib/utils/sys/objects.mk                  |   4 +-
 lib/utils/timer/Kconfig                   |  23 +++++
 lib/utils/timer/objects.mk                |  10 +--
 platform/andes/ae350/Kconfig              |   8 ++
 platform/andes/ae350/config.mk            |  36 --------
 platform/andes/ae350/configs/defconfig    |   0
 platform/andes/ae350/objects.mk           |  29 ++++++
 platform/fpga/ariane/Kconfig              |  10 +++
 platform/fpga/ariane/config.mk            |  36 --------
 platform/fpga/ariane/configs/defconfig    |   0
 platform/fpga/ariane/objects.mk           |  35 ++++++++
 platform/fpga/openpiton/Kconfig           |  10 +++
 platform/fpga/openpiton/config.mk         |  35 --------
 platform/fpga/openpiton/configs/defconfig |   0
 platform/fpga/openpiton/objects.mk        |  35 ++++++++
 platform/generic/Kconfig                  |  26 ++++++
 platform/generic/allwinner/objects.mk     |   4 +-
 platform/generic/config.mk                |  40 ---------
 platform/generic/configs/defconfig        |  29 ++++++
 platform/generic/objects.mk               |  33 +++++++
 platform/generic/sifive/objects.mk        |   8 +-
 platform/kendryte/k210/Kconfig            |  10 +++
 platform/kendryte/k210/config.mk          |  19 ----
 platform/kendryte/k210/configs/defconfig  |   0
 platform/kendryte/k210/objects.mk         |  12 +++
 platform/nuclei/ux600/Kconfig             |  10 +++
 platform/nuclei/ux600/config.mk           |  30 -------
 platform/nuclei/ux600/configs/defconfig   |   0
 platform/nuclei/ux600/objects.mk          |  22 +++++
 platform/nuclei/ux600/platform.c          |   1 -
 platform/template/Kconfig                 |   9 ++
 platform/template/config.mk               |  77 ----------------
 platform/template/configs/defconfig       |   0
 platform/template/objects.mk              |  72 +++++++++++++++
 platform/template/platform.c              |   2 +-
 scripts/create-binary-archive.sh          |   2 +-
 72 files changed, 948 insertions(+), 403 deletions(-)
 create mode 100644 Kconfig
 create mode 100644 firmware/Kconfig
 create mode 100644 lib/utils/Kconfig
 create mode 100644 lib/utils/fdt/Kconfig
 create mode 100644 lib/utils/gpio/Kconfig
 create mode 100644 lib/utils/i2c/Kconfig
 create mode 100644 lib/utils/ipi/Kconfig
 create mode 100644 lib/utils/irqchip/Kconfig
 create mode 100644 lib/utils/libfdt/Kconfig
 create mode 100644 lib/utils/reset/Kconfig
 create mode 100644 lib/utils/serial/Kconfig
 create mode 100644 lib/utils/sys/Kconfig
 create mode 100644 lib/utils/timer/Kconfig
 create mode 100644 platform/andes/ae350/Kconfig
 delete mode 100644 platform/andes/ae350/config.mk
 create mode 100644 platform/andes/ae350/configs/defconfig
 create mode 100644 platform/fpga/ariane/Kconfig
 delete mode 100644 platform/fpga/ariane/config.mk
 create mode 100644 platform/fpga/ariane/configs/defconfig
 create mode 100644 platform/fpga/openpiton/Kconfig
 delete mode 100644 platform/fpga/openpiton/config.mk
 create mode 100644 platform/fpga/openpiton/configs/defconfig
 create mode 100644 platform/generic/Kconfig
 delete mode 100644 platform/generic/config.mk
 create mode 100644 platform/generic/configs/defconfig
 create mode 100644 platform/kendryte/k210/Kconfig
 delete mode 100644 platform/kendryte/k210/config.mk
 create mode 100644 platform/kendryte/k210/configs/defconfig
 create mode 100644 platform/nuclei/ux600/Kconfig
 delete mode 100644 platform/nuclei/ux600/config.mk
 create mode 100644 platform/nuclei/ux600/configs/defconfig
 create mode 100644 platform/template/Kconfig
 delete mode 100644 platform/template/config.mk
 create mode 100644 platform/template/configs/defconfig

-- 
2.34.1



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 01/14] Makefile: Add initial kconfig support for each platform
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
@ 2022-07-18 12:41 ` Anup Patel
  2022-07-18 13:51   ` Jessica Clarke
  2022-07-18 12:41 ` [PATCH 02/14] Makefile: Compile lib/utils sources separately " Anup Patel
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:41 UTC (permalink / raw)
  To: opensbi

We extend the top-level makefile to allow kconfig based configuration
for each platform where each platform has it's own set of configs with
"defconfig" being the default config.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 Kconfig                                   | 23 ++++++++++
 Makefile                                  | 54 +++++++++++++++++++++--
 firmware/Kconfig                          |  1 +
 lib/utils/Kconfig                         |  1 +
 platform/andes/ae350/Kconfig              |  5 +++
 platform/andes/ae350/configs/defconfig    |  0
 platform/fpga/ariane/Kconfig              |  5 +++
 platform/fpga/ariane/configs/defconfig    |  0
 platform/fpga/openpiton/Kconfig           |  5 +++
 platform/fpga/openpiton/configs/defconfig |  0
 platform/generic/Kconfig                  |  5 +++
 platform/generic/configs/defconfig        |  0
 platform/kendryte/k210/Kconfig            |  5 +++
 platform/kendryte/k210/configs/defconfig  |  0
 platform/nuclei/ux600/Kconfig             |  5 +++
 platform/nuclei/ux600/configs/defconfig   |  0
 platform/template/Kconfig                 |  5 +++
 platform/template/configs/defconfig       |  0
 18 files changed, 111 insertions(+), 3 deletions(-)
 create mode 100644 Kconfig
 create mode 100644 firmware/Kconfig
 create mode 100644 lib/utils/Kconfig
 create mode 100644 platform/andes/ae350/Kconfig
 create mode 100644 platform/andes/ae350/configs/defconfig
 create mode 100644 platform/fpga/ariane/Kconfig
 create mode 100644 platform/fpga/ariane/configs/defconfig
 create mode 100644 platform/fpga/openpiton/Kconfig
 create mode 100644 platform/fpga/openpiton/configs/defconfig
 create mode 100644 platform/generic/Kconfig
 create mode 100644 platform/generic/configs/defconfig
 create mode 100644 platform/kendryte/k210/Kconfig
 create mode 100644 platform/kendryte/k210/configs/defconfig
 create mode 100644 platform/nuclei/ux600/Kconfig
 create mode 100644 platform/nuclei/ux600/configs/defconfig
 create mode 100644 platform/template/Kconfig
 create mode 100644 platform/template/configs/defconfig

diff --git a/Kconfig b/Kconfig
new file mode 100644
index 0000000..b8615d2
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0
+
+mainmenu "OpenSBI $OPENSBI_PLATFORM Configuration"
+
+config OPENSBI_SRC_DIR
+	string
+	option env="OPENSBI_SRC_DIR"
+
+config OPENSBI_PLATFORM
+	string
+	option env="OPENSBI_PLATFORM"
+
+config OPENSBI_PLATFORM_SRC_DIR
+	string
+	option env="OPENSBI_PLATFORM_SRC_DIR"
+
+menu "Platform Options"
+source "$OPENSBI_PLATFORM_SRC_DIR/Kconfig"
+endmenu
+
+source "$OPENSBI_SRC_DIR/lib/utils/Kconfig"
+
+source "$OPENSBI_SRC_DIR/firmware/Kconfig"
diff --git a/Makefile b/Makefile
index f619ef7..46c7c1c 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,9 @@ ifdef PLATFORM_DIR
 else
  platform_parent_dir=$(src_dir)/platform
 endif
+ifndef PLATFORM_DEFCONFIG
+PLATFORM_DEFCONFIG=defconfig
+endif
 
 # Check if verbosity is ON for build process
 CMD_PREFIX_DEFAULT := @
@@ -70,6 +73,19 @@ export libsbi_dir=$(CURDIR)/lib/sbi
 export libsbiutils_dir=$(CURDIR)/lib/utils
 export firmware_dir=$(CURDIR)/firmware
 
+# Setup variables for kconfig-frontends
+ifdef PLATFORM
+export KCONFIG_CONFIG=$(platform_build_dir)/.config
+export KCONFIG_AUTOCONFIG=$(platform_build_dir)/auto.conf
+export KCONFIG_TRISTATE=$(platform_build_dir)/tristate.conf
+export KCONFIG_AUTOHEADER=$(platform_build_dir)/autoconf.h
+export KCONFIG_AUTOCONF_CMD=$(platform_build_dir)/include/config/auto.conf.cmd
+# Additional exports for include paths in Kconfig files
+export OPENSBI_SRC_DIR=$(src_dir)
+export OPENSBI_PLATFORM=$(PLATFORM)
+export OPENSBI_PLATFORM_SRC_DIR=$(platform_src_dir)
+endif
+
 # Find library version
 OPENSBI_VERSION_MAJOR=`grep "define OPENSBI_VERSION_MAJOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'`
 OPENSBI_VERSION_MINOR=`grep "define OPENSBI_VERSION_MINOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'`
@@ -183,8 +199,34 @@ libsbi-object-mks=$(shell if [ -d $(libsbi_dir) ]; then find $(libsbi_dir) -inam
 libsbiutils-object-mks=$(shell if [ -d $(libsbiutils_dir) ]; then find $(libsbiutils_dir) -iname "objects.mk" | sort -r; fi)
 firmware-object-mks=$(shell if [ -d $(firmware_dir) ]; then find $(firmware_dir) -iname "objects.mk" | sort -r; fi)
 
-# Include platform specifig config.mk
+# The "make all" rule should always be first rule
+.PHONY: all
+all:
+
+# Include platform specific .config and config.mk
 ifdef PLATFORM
+.PHONY: menuconfig
+menuconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
+	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
+	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
+	$(CMD_PREFIX)kconfig-mconf $(src_dir)/Kconfig
+	$(CMD_PREFIX)cd $(platform_build_dir) && kconfig-conf --silentoldconfig $(src_dir)/Kconfig
+
+.PHONY: savedefconfig
+savedefconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
+	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
+	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
+	$(CMD_PREFIX)kconfig-conf --savedefconfig `dirname $(KCONFIG_CONFIG)`/defconfig $(src_dir)/Kconfig
+
+$(KCONFIG_CONFIG): $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
+	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
+	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
+	$(CMD_PREFIX)cp -f $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(KCONFIG_CONFIG)
+	$(CMD_PREFIX)cd $(platform_build_dir) && kconfig-conf --silentoldconfig --olddefconfig $(src_dir)/Kconfig
+$(KCONFIG_AUTOCONF_CMD): $(KCONFIG_CONFIG)
+include $(KCONFIG_CONFIG)
+include $(KCONFIG_AUTOCONF_CMD)
+
 include $(platform_src_dir)/config.mk
 endif
 
@@ -280,6 +322,9 @@ ifeq ($(BUILD_INFO),y)
 GENFLAGS	+=	-DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\""
 GENFLAGS	+=	-DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\""
 endif
+ifdef PLATFORM
+GENFLAGS	+=	-include $(KCONFIG_AUTOHEADER)
+endif
 GENFLAGS	+=	$(libsbiutils-genflags-y)
 GENFLAGS	+=	$(platform-genflags-y)
 GENFLAGS	+=	$(firmware-genflags-y)
@@ -419,7 +464,7 @@ targets-y += $(platform_build_dir)/lib/libplatsbi.a
 endif
 targets-y += $(firmware-bins-path-y)
 
-# Default rule "make" should always be first rule
+# The default "make all" rule
 .PHONY: all
 all: $(targets-y)
 
@@ -456,7 +501,7 @@ $(build_dir)/%.o: $(src_dir)/%.S
 	$(call compile_as,$@,$<)
 
 $(build_dir)/%.dep: $(src_dir)/%.carray
-	$(call compile_gen_dep,$@,.c,$<)
+	$(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG))
 	$(call compile_gen_dep,$@,.o,$(@:.dep=.c))
 
 $(build_dir)/%.c: $(src_dir)/%.carray
@@ -523,6 +568,9 @@ docs: $(build_dir)/docs/latex/refman.pdf
 # They should not be included for any "xxxconfig" or "xxxclean" rule
 all-deps-1 = $(if $(findstring config,$(MAKECMDGOALS)),,$(deps-y))
 all-deps-2 = $(if $(findstring clean,$(MAKECMDGOALS)),,$(all-deps-1))
+ifdef PLATFORM
+$(all-deps-2): | $(KCONFIG_CONFIG)
+endif
 -include $(all-deps-2)
 
 # Include external dependency of firmwares after default Makefile rules
diff --git a/firmware/Kconfig b/firmware/Kconfig
new file mode 100644
index 0000000..f66554c
--- /dev/null
+++ b/firmware/Kconfig
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
new file mode 100644
index 0000000..f66554c
--- /dev/null
+++ b/lib/utils/Kconfig
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0
diff --git a/platform/andes/ae350/Kconfig b/platform/andes/ae350/Kconfig
new file mode 100644
index 0000000..349c1d3
--- /dev/null
+++ b/platform/andes/ae350/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_ANDES_AE350
+	bool
+	default y
diff --git a/platform/andes/ae350/configs/defconfig b/platform/andes/ae350/configs/defconfig
new file mode 100644
index 0000000..e69de29
diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
new file mode 100644
index 0000000..26f9beb
--- /dev/null
+++ b/platform/fpga/ariane/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_ARIANE_FPGA
+	bool
+	default y
diff --git a/platform/fpga/ariane/configs/defconfig b/platform/fpga/ariane/configs/defconfig
new file mode 100644
index 0000000..e69de29
diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
new file mode 100644
index 0000000..8bfa85a
--- /dev/null
+++ b/platform/fpga/openpiton/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_OPENPITON_FPGA
+	bool
+	default y
diff --git a/platform/fpga/openpiton/configs/defconfig b/platform/fpga/openpiton/configs/defconfig
new file mode 100644
index 0000000..e69de29
diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
new file mode 100644
index 0000000..a811a05
--- /dev/null
+++ b/platform/generic/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_GENERIC
+	bool
+	default y
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
new file mode 100644
index 0000000..e69de29
diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
new file mode 100644
index 0000000..726423a
--- /dev/null
+++ b/platform/kendryte/k210/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_KENDRYTE_K210
+	bool
+	default y
diff --git a/platform/kendryte/k210/configs/defconfig b/platform/kendryte/k210/configs/defconfig
new file mode 100644
index 0000000..e69de29
diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
new file mode 100644
index 0000000..bb8410f
--- /dev/null
+++ b/platform/nuclei/ux600/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_NUCLEI_UX600
+	bool
+	default y
diff --git a/platform/nuclei/ux600/configs/defconfig b/platform/nuclei/ux600/configs/defconfig
new file mode 100644
index 0000000..e69de29
diff --git a/platform/template/Kconfig b/platform/template/Kconfig
new file mode 100644
index 0000000..bd95ea0
--- /dev/null
+++ b/platform/template/Kconfig
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config PLATFORM_TEMPLATE
+	bool
+	default y
diff --git a/platform/template/configs/defconfig b/platform/template/configs/defconfig
new file mode 100644
index 0000000..e69de29
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 02/14] Makefile: Compile lib/utils sources separately for each platform
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
  2022-07-18 12:41 ` [PATCH 01/14] Makefile: Add initial kconfig support for each platform Anup Patel
@ 2022-07-18 12:41 ` Anup Patel
  2022-07-18 12:41 ` [PATCH 03/14] lib: utils/serial: Use kconfig for enabling/disabling drivers Anup Patel
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:41 UTC (permalink / raw)
  To: opensbi

Currently, if same build directory is used to compile two different
platforms then lib/utils objects are shared for these platforms.

We will be having platform specific configs to enable/disable drivers
in lib/utils and select compile time options for lib/utils sources.
This means lib/utils sources will now be compiled in a platform
specific way.

To tackle above, we update top-level Makefile as follows:
1) Don't create libsbiutils.a anymore because this can't be shared
   between platforms.
2) Compile lib/utils sources separately for each platform.
3) Add comments showing which make rules are for lib/sbi, lib/utils,
   firmware, and platform sources.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 Makefile                         | 48 ++++++++++++++++----------------
 docs/library_usage.md            |  6 +---
 scripts/create-binary-archive.sh |  2 +-
 3 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/Makefile b/Makefile
index 46c7c1c..5fc67db 100644
--- a/Makefile
+++ b/Makefile
@@ -240,8 +240,8 @@ include $(firmware-object-mks)
 
 # Setup list of objects
 libsbi-objs-path-y=$(foreach obj,$(libsbi-objs-y),$(build_dir)/lib/sbi/$(obj))
-libsbiutils-objs-path-y=$(foreach obj,$(libsbiutils-objs-y),$(build_dir)/lib/utils/$(obj))
 ifdef PLATFORM
+libsbiutils-objs-path-y=$(foreach obj,$(libsbiutils-objs-y),$(platform_build_dir)/lib/utils/$(obj))
 platform-objs-path-y=$(foreach obj,$(platform-objs-y),$(platform_build_dir)/$(obj))
 firmware-bins-path-y=$(foreach bin,$(firmware-bins-y),$(platform_build_dir)/firmware/$(bin))
 endif
@@ -458,7 +458,6 @@ compile_gen_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
 	     echo "$(1:.dep=$(2)): $(3)" >> $(1)
 
 targets-y  = $(build_dir)/lib/libsbi.a
-targets-y  += $(build_dir)/lib/libsbiutils.a
 ifdef PLATFORM
 targets-y += $(platform_build_dir)/lib/libplatsbi.a
 endif
@@ -471,12 +470,10 @@ all: $(targets-y)
 # Preserve all intermediate files
 .SECONDARY:
 
+# Rules for lib/sbi sources
 $(build_dir)/lib/libsbi.a: $(libsbi-objs-path-y)
 	$(call compile_ar,$@,$^)
 
-$(build_dir)/lib/libsbiutils.a: $(libsbi-objs-path-y) $(libsbiutils-objs-path-y)
-	$(call compile_ar,$@,$^)
-
 $(platform_build_dir)/lib/libplatsbi.a: $(libsbi-objs-path-y) $(libsbiutils-objs-path-y) $(platform-objs-path-y)
 	$(call compile_ar,$@,$^)
 
@@ -500,22 +497,14 @@ $(build_dir)/%.dep: $(src_dir)/%.S
 $(build_dir)/%.o: $(src_dir)/%.S
 	$(call compile_as,$@,$<)
 
-$(build_dir)/%.dep: $(src_dir)/%.carray
+# Rules for platform sources
+$(platform_build_dir)/%.dep: $(platform_src_dir)/%.carray
 	$(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG))
 	$(call compile_gen_dep,$@,.o,$(@:.dep=.c))
 
-$(build_dir)/%.c: $(src_dir)/%.carray
+$(platform_build_dir)/%.c: $(platform_src_dir)/%.carray
 	$(call compile_carray,$@,$<)
 
-$(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf
-	$(call compile_objcopy,$@,$<)
-
-$(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a
-	$(call compile_elf,$@,$@.ld,$< $(platform_build_dir)/lib/libplatsbi.a)
-
-$(platform_build_dir)/%.ld: $(src_dir)/%.ldS
-	$(call compile_cpp,$@,$<)
-
 $(platform_build_dir)/%.dep: $(platform_src_dir)/%.c
 	$(call compile_cc_dep,$@,$<)
 
@@ -539,6 +528,23 @@ $(platform_build_dir)/%.c: $(platform_build_dir)/%.dtb
 $(platform_build_dir)/%.dtb: $(platform_src_dir)/%.dts
 	$(call compile_dts,$@,$<)
 
+# Rules for lib/utils and firmware sources
+$(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf
+	$(call compile_objcopy,$@,$<)
+
+$(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a
+	$(call compile_elf,$@,$@.ld,$< $(platform_build_dir)/lib/libplatsbi.a)
+
+$(platform_build_dir)/%.ld: $(src_dir)/%.ldS
+	$(call compile_cpp,$@,$<)
+
+$(platform_build_dir)/%.dep: $(src_dir)/%.carray
+	$(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG))
+	$(call compile_gen_dep,$@,.o,$(@:.dep=.c))
+
+$(platform_build_dir)/%.c: $(src_dir)/%.carray
+	$(call compile_carray,$@,$<)
+
 $(platform_build_dir)/%.dep: $(src_dir)/%.c
 	$(call compile_cc_dep,$@,$<)
 
@@ -592,7 +598,6 @@ endif
 endif
 
 install_targets-y  = install_libsbi
-install_targets-y  += install_libsbiutils
 ifdef PLATFORM
 install_targets-y += install_libplatsbi
 install_targets-y += install_firmwares
@@ -607,17 +612,12 @@ install_libsbi: $(build_dir)/lib/libsbi.a
 	$(call inst_header_dir,$(install_root_dir)/$(install_include_path),$(include_dir)/sbi)
 	$(call inst_file,$(install_root_dir)/$(install_lib_path)/libsbi.a,$(build_dir)/lib/libsbi.a)
 
-.PHONY: install_libsbiutils
-install_libsbiutils: $(build_dir)/lib/libsbiutils.a
-	$(call inst_header_dir,$(install_root_dir)/$(install_include_path),$(include_dir)/sbi_utils)
-	$(call inst_file,$(install_root_dir)/$(install_lib_path)/libsbiutils.a,$(build_dir)/lib/libsbiutils.a)
-
 .PHONY: install_libplatsbi
-install_libplatsbi: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(build_dir)/lib/libsbiutils.a
+install_libplatsbi: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a
 	$(call inst_file,$(install_root_dir)/$(install_lib_path)/opensbi/$(platform_subdir)/lib/libplatsbi.a,$(platform_build_dir)/lib/libplatsbi.a)
 
 .PHONY: install_firmwares
-install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(build_dir)/lib/libsbiutils.a $(firmware-bins-path-y)
+install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsbi.a $(firmware-bins-path-y)
 	$(call inst_file_list,$(install_root_dir),$(build_dir),$(install_firmware_path)/$(platform_subdir)/firmware,$(firmware-elfs-path-y))
 	$(call inst_file_list,$(install_root_dir),$(build_dir),$(install_firmware_path)/$(platform_subdir)/firmware,$(firmware-bins-path-y))
 
diff --git a/docs/library_usage.md b/docs/library_usage.md
index ff99801..d5d2ba9 100644
--- a/docs/library_usage.md
+++ b/docs/library_usage.md
@@ -8,11 +8,7 @@ OpenSBI provides two types of static libraries:
    hooks for the execution of this interface must be provided by the firmware or
    bootloader linking with this library. This library is installed as
    *<install_directory>/lib/libsbi.a*
-2. *libsbiutils.a* - A static library that will contain all common code required
-   by any platform supported in OpenSBI. It will be built by default and included
-   in libplatsbi.a. This library is installed as
-   *<install_directory>/lib/libsbiutils.a*.
-3. *libplatsbi.a* - An example platform-specific static library integrating
+2. *libplatsbi.a* - An example platform-specific static library integrating
    *libsbi.a* with platform-specific hooks. This library is available only for
    the platforms supported by OpenSBI. This library is installed as
    *<install_directory>/platform/<platform_subdir>/lib/libplatsbi.a*
diff --git a/scripts/create-binary-archive.sh b/scripts/create-binary-archive.sh
index 43c5452..261a45a 100755
--- a/scripts/create-binary-archive.sh
+++ b/scripts/create-binary-archive.sh
@@ -118,7 +118,7 @@ build_opensbi() {
 	# Build and install generic library
 	echo "Build and install generic library XLEN=${BUILD_RISCV_XLEN}"
 	echo ""
-	make -C "${BUILD_OPENSBI_SOURCE_PATH}" O="${BUILD_OUTPUT_PATH}/${BUILD_NAME}" I="${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}" PLATFORM_RISCV_XLEN="${BUILD_RISCV_XLEN}" install_libsbi install_libsbiutils -j "${BUILD_NUM_THREADS}"
+	make -C "${BUILD_OPENSBI_SOURCE_PATH}" O="${BUILD_OUTPUT_PATH}/${BUILD_NAME}" I="${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}" PLATFORM_RISCV_XLEN="${BUILD_RISCV_XLEN}" install_libsbi -j "${BUILD_NUM_THREADS}"
 	echo ""
 
 	# Build and install relevant platforms
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 03/14] lib: utils/serial: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
  2022-07-18 12:41 ` [PATCH 01/14] Makefile: Add initial kconfig support for each platform Anup Patel
  2022-07-18 12:41 ` [PATCH 02/14] Makefile: Compile lib/utils sources separately " Anup Patel
@ 2022-07-18 12:41 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 04/14] lib: utils/reset: " Anup Patel
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:41 UTC (permalink / raw)
  To: opensbi

We update serial drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate serial
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/serial/fdt_serial.h |  8 +++
 lib/utils/Kconfig                     |  6 +++
 lib/utils/serial/Kconfig              | 71 +++++++++++++++++++++++++++
 lib/utils/serial/objects.mk           | 44 ++++++++---------
 platform/andes/ae350/Kconfig          |  1 +
 platform/fpga/ariane/Kconfig          |  1 +
 platform/fpga/openpiton/Kconfig       |  1 +
 platform/generic/configs/defconfig    |  8 +++
 platform/kendryte/k210/Kconfig        |  1 +
 platform/nuclei/ux600/Kconfig         |  1 +
 platform/template/Kconfig             |  1 +
 11 files changed, 121 insertions(+), 22 deletions(-)
 create mode 100644 lib/utils/serial/Kconfig

diff --git a/include/sbi_utils/serial/fdt_serial.h b/include/sbi_utils/serial/fdt_serial.h
index 6451c23..daa2e4f 100644
--- a/include/sbi_utils/serial/fdt_serial.h
+++ b/include/sbi_utils/serial/fdt_serial.h
@@ -12,6 +12,8 @@
 
 #include <sbi/sbi_types.h>
 
+#ifdef CONFIG_FDT_SERIAL
+
 struct fdt_serial {
 	const struct fdt_match *match_table;
 	int (*init)(void *fdt, int nodeoff, const struct fdt_match *match);
@@ -19,4 +21,10 @@ struct fdt_serial {
 
 int fdt_serial_init(void);
 
+#else
+
+static inline int fdt_serial_init(void) { return 0; }
+
+#endif
+
 #endif
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index f66554c..464bd03 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -1 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+
+menu "Utils and Drivers Support"
+
+source "$OPENSBI_SRC_DIR/lib/utils/serial/Kconfig"
+
+endmenu
diff --git a/lib/utils/serial/Kconfig b/lib/utils/serial/Kconfig
new file mode 100644
index 0000000..9e6b6fc
--- /dev/null
+++ b/lib/utils/serial/Kconfig
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "Serial Device Support"
+
+config FDT_SERIAL
+	bool "FDT based serial drivers"
+	default n
+
+if FDT_SERIAL
+
+config FDT_SERIAL_GAISLER
+	bool "Gaisler UART FDT driver"
+	select SERIAL_GAISLER
+	default n
+
+config FDT_SERIAL_HTIF
+	bool "Host transfer interface (HTIF) UART FDT driver"
+	default n
+
+config FDT_SERIAL_SHAKTI
+	bool "Shakti UART FDT driver"
+	select SERIAL_SHAKTI
+	default n
+
+config FDT_SERIAL_SIFIVE
+	bool "SiFive UART FDT driver"
+	select SERIAL_SIFIVE
+	default n
+
+config FDT_SERIAL_LITEX
+	bool "LiteX UART FDT driver"
+	select SERIAL_LITEX
+	default n
+
+config FDT_SERIAL_UART8250
+	bool "8250 UART FDT driver"
+	select SERIAL_UART8250
+	default n
+
+config FDT_SERIAL_XILINX_UARTLITE
+	bool "Xilinx UART Lite FDT driver"
+	select SERIAL_XILINX_UARTLITE
+	default n
+
+endif
+
+config SERIAL_GAISLER
+	bool "Gaisler UART support"
+	default n
+
+config SERIAL_SHAKTI
+	bool "Shakti UART support"
+	default n
+
+config SERIAL_SIFIVE
+	bool "SiFive UART support"
+	default n
+
+config SERIAL_LITEX
+	bool "LiteX UART support"
+	default n
+
+config SERIAL_UART8250
+	bool "8250 UART support"
+	default n
+
+config SERIAL_XILINX_UARTLITE
+	bool "Xilinx UART Lite support"
+	default n
+
+endmenu
diff --git a/lib/utils/serial/objects.mk b/lib/utils/serial/objects.mk
index d26a74e..fa9f5a3 100644
--- a/lib/utils/serial/objects.mk
+++ b/lib/utils/serial/objects.mk
@@ -7,33 +7,33 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += serial/fdt_serial.o
-libsbiutils-objs-y += serial/fdt_serial_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_SERIAL) += serial/fdt_serial.o
+libsbiutils-objs-$(CONFIG_FDT_SERIAL) += serial/fdt_serial_drivers.o
 
-carray-fdt_serial_drivers-y += fdt_serial_gaisler
-libsbiutils-objs-y += serial/fdt_serial_gaisler.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_GAISLER) += fdt_serial_gaisler
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_GAISLER) += serial/fdt_serial_gaisler.o
 
-carray-fdt_serial_drivers-y += fdt_serial_htif
-libsbiutils-objs-y += serial/fdt_serial_htif.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_HTIF) += fdt_serial_htif
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_HTIF) += serial/fdt_serial_htif.o
 
-carray-fdt_serial_drivers-y += fdt_serial_shakti
-libsbiutils-objs-y += serial/fdt_serial_shakti.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_SHAKTI) += fdt_serial_shakti
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_SHAKTI) += serial/fdt_serial_shakti.o
 
-carray-fdt_serial_drivers-y += fdt_serial_sifive
-libsbiutils-objs-y += serial/fdt_serial_sifive.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_SIFIVE) += fdt_serial_sifive
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_SIFIVE) += serial/fdt_serial_sifive.o
 
-carray-fdt_serial_drivers-y += fdt_serial_litex
-libsbiutils-objs-y += serial/fdt_serial_litex.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_LITEX) += fdt_serial_litex
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_LITEX) += serial/fdt_serial_litex.o
 
-carray-fdt_serial_drivers-y += fdt_serial_uart8250
-libsbiutils-objs-y += serial/fdt_serial_uart8250.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_UART8250) += fdt_serial_uart8250
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_UART8250) += serial/fdt_serial_uart8250.o
 
-carray-fdt_serial_drivers-y += fdt_serial_xlnx_uartlite
-libsbiutils-objs-y += serial/fdt_serial_xlnx_uartlite.o
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_XILINX_UARTLITE) += fdt_serial_xlnx_uartlite
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_XILINX_UARTLITE) += serial/fdt_serial_xlnx_uartlite.o
 
-libsbiutils-objs-y += serial/gaisler-uart.o
-libsbiutils-objs-y += serial/shakti-uart.o
-libsbiutils-objs-y += serial/sifive-uart.o
-libsbiutils-objs-y += serial/litex-uart.o
-libsbiutils-objs-y += serial/uart8250.o
-libsbiutils-objs-y += serial/xlnx-uartlite.o
+libsbiutils-objs-$(CONFIG_SERIAL_GAISLER) += serial/gaisler-uart.o
+libsbiutils-objs-$(CONFIG_SERIAL_SHAKTI) += serial/shakti-uart.o
+libsbiutils-objs-$(CONFIG_SERIAL_SIFIVE) += serial/sifive-uart.o
+libsbiutils-objs-$(CONFIG_SERIAL_LITEX) += serial/litex-uart.o
+libsbiutils-objs-$(CONFIG_SERIAL_UART8250) += serial/uart8250.o
+libsbiutils-objs-$(CONFIG_SERIAL_XILINX_UARTLITE) += serial/xlnx-uartlite.o
diff --git a/platform/andes/ae350/Kconfig b/platform/andes/ae350/Kconfig
index 349c1d3..0048c1b 100644
--- a/platform/andes/ae350/Kconfig
+++ b/platform/andes/ae350/Kconfig
@@ -2,4 +2,5 @@
 
 config PLATFORM_ANDES_AE350
 	bool
+	select SERIAL_UART8250
 	default y
diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
index 26f9beb..797af74 100644
--- a/platform/fpga/ariane/Kconfig
+++ b/platform/fpga/ariane/Kconfig
@@ -2,4 +2,5 @@
 
 config PLATFORM_ARIANE_FPGA
 	bool
+	select SERIAL_UART8250
 	default y
diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
index 8bfa85a..09b658a 100644
--- a/platform/fpga/openpiton/Kconfig
+++ b/platform/fpga/openpiton/Kconfig
@@ -2,4 +2,5 @@
 
 config PLATFORM_OPENPITON_FPGA
 	bool
+	select SERIAL_UART8250
 	default y
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index e69de29..ce70c59 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -0,0 +1,8 @@
+CONFIG_FDT_SERIAL=y
+CONFIG_FDT_SERIAL_GAISLER=y
+CONFIG_FDT_SERIAL_HTIF=y
+CONFIG_FDT_SERIAL_SHAKTI=y
+CONFIG_FDT_SERIAL_SIFIVE=y
+CONFIG_FDT_SERIAL_LITEX=y
+CONFIG_FDT_SERIAL_UART8250=y
+CONFIG_FDT_SERIAL_XILINX_UARTLITE=y
diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
index 726423a..bc921c8 100644
--- a/platform/kendryte/k210/Kconfig
+++ b/platform/kendryte/k210/Kconfig
@@ -2,4 +2,5 @@
 
 config PLATFORM_KENDRYTE_K210
 	bool
+	select SERIAL_SIFIVE
 	default y
diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
index bb8410f..c4da266 100644
--- a/platform/nuclei/ux600/Kconfig
+++ b/platform/nuclei/ux600/Kconfig
@@ -2,4 +2,5 @@
 
 config PLATFORM_NUCLEI_UX600
 	bool
+	select SERIAL_SIFIVE
 	default y
diff --git a/platform/template/Kconfig b/platform/template/Kconfig
index bd95ea0..e01fb31 100644
--- a/platform/template/Kconfig
+++ b/platform/template/Kconfig
@@ -2,4 +2,5 @@
 
 config PLATFORM_TEMPLATE
 	bool
+	select SERIAL_UART8250
 	default y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 04/14] lib: utils/reset: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (2 preceding siblings ...)
  2022-07-18 12:41 ` [PATCH 03/14] lib: utils/serial: Use kconfig for enabling/disabling drivers Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 05/14] lib: utils/sys: " Anup Patel
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update reset drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate reset
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/reset/fdt_reset.h | 12 +++++++++++
 lib/utils/Kconfig                   |  2 ++
 lib/utils/reset/Kconfig             | 33 +++++++++++++++++++++++++++++
 lib/utils/reset/objects.mk          | 28 ++++++++++++------------
 platform/generic/configs/defconfig  |  6 ++++++
 5 files changed, 67 insertions(+), 14 deletions(-)
 create mode 100644 lib/utils/reset/Kconfig

diff --git a/include/sbi_utils/reset/fdt_reset.h b/include/sbi_utils/reset/fdt_reset.h
index e7f7350..ea8063b 100644
--- a/include/sbi_utils/reset/fdt_reset.h
+++ b/include/sbi_utils/reset/fdt_reset.h
@@ -17,6 +17,8 @@ struct fdt_reset {
 	int (*init)(void *fdt, int nodeoff, const struct fdt_match *match);
 };
 
+#ifdef CONFIG_FDT_RESET
+
 /**
  * fdt_reset_driver_init() - initialize reset driver based on the device-tree
  */
@@ -29,4 +31,14 @@ int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv);
  */
 void fdt_reset_init(void);
 
+#else
+
+static inline int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv)
+{
+	return 0;
+}
+static inline void fdt_reset_init(void) { }
+
+#endif
+
 #endif
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index 464bd03..5330e87 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -2,6 +2,8 @@
 
 menu "Utils and Drivers Support"
 
+source "$OPENSBI_SRC_DIR/lib/utils/reset/Kconfig"
+
 source "$OPENSBI_SRC_DIR/lib/utils/serial/Kconfig"
 
 endmenu
diff --git a/lib/utils/reset/Kconfig b/lib/utils/reset/Kconfig
new file mode 100644
index 0000000..d4a32a0
--- /dev/null
+++ b/lib/utils/reset/Kconfig
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "System Reset Support"
+
+config FDT_RESET
+	bool "FDT based reset drivers"
+	default n
+
+if FDT_RESET
+
+config FDT_RESET_GPIO
+	bool "GPIO FDT reset driver"
+	default n
+
+config FDT_RESET_HTIF
+	bool "Host transfer interface (HTIF) FDT reset driver"
+	default n
+
+config FDT_RESET_SIFIVE_TEST
+	bool "SiFive Test FDT reset driver"
+	default n
+
+config FDT_RESET_SUNXI_WDT
+	bool "Sunxi WDT FDT reset driver"
+	default n
+
+config FDT_RESET_THEAD
+	bool "T-HEAD FDT reset driver"
+	default n
+
+endif
+
+endmenu
diff --git a/lib/utils/reset/objects.mk b/lib/utils/reset/objects.mk
index 8cddcdf..8a50dd0 100644
--- a/lib/utils/reset/objects.mk
+++ b/lib/utils/reset/objects.mk
@@ -7,22 +7,22 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += reset/fdt_reset.o
-libsbiutils-objs-y += reset/fdt_reset_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_RESET) += reset/fdt_reset.o
+libsbiutils-objs-$(CONFIG_FDT_RESET) += 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-$(CONFIG_FDT_RESET_GPIO) += fdt_poweroff_gpio
+carray-fdt_reset_drivers-$(CONFIG_FDT_RESET_GPIO) += fdt_reset_gpio
+libsbiutils-objs-$(CONFIG_FDT_RESET_GPIO) += 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-$(CONFIG_FDT_RESET_HTIF) += fdt_reset_htif
+libsbiutils-objs-$(CONFIG_FDT_RESET_HTIF) += 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-$(CONFIG_FDT_RESET_SIFIVE_TEST) += fdt_reset_sifive_test
+libsbiutils-objs-$(CONFIG_FDT_RESET_SIFIVE_TEST) += 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-$(CONFIG_FDT_RESET_SUNXI_WDT) += fdt_reset_sunxi_wdt
+libsbiutils-objs-$(CONFIG_FDT_RESET_SUNXI_WDT) += 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
+carray-fdt_reset_drivers-$(CONFIG_FDT_RESET_THEAD) += fdt_reset_thead
+libsbiutils-objs-$(CONFIG_FDT_RESET_THEAD) += reset/fdt_reset_thead.o
+libsbiutils-objs-$(CONFIG_FDT_RESET_THEAD) += reset/fdt_reset_thead_asm.o
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index ce70c59..9778665 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -1,3 +1,9 @@
+CONFIG_FDT_RESET=y
+CONFIG_FDT_RESET_GPIO=y
+CONFIG_FDT_RESET_HTIF=y
+CONFIG_FDT_RESET_SIFIVE_TEST=y
+CONFIG_FDT_RESET_SUNXI_WDT=y
+CONFIG_FDT_RESET_THEAD=y
 CONFIG_FDT_SERIAL=y
 CONFIG_FDT_SERIAL_GAISLER=y
 CONFIG_FDT_SERIAL_HTIF=y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 05/14] lib: utils/sys: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (3 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 04/14] lib: utils/reset: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 06/14] lib: utils/timer: " Anup Patel
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update system drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate system
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 lib/utils/Kconfig        |  2 ++
 lib/utils/reset/Kconfig  |  2 ++
 lib/utils/serial/Kconfig |  1 +
 lib/utils/sys/Kconfig    | 13 +++++++++++++
 lib/utils/sys/objects.mk |  4 ++--
 5 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 lib/utils/sys/Kconfig

diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index 5330e87..6442b75 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -6,4 +6,6 @@ source "$OPENSBI_SRC_DIR/lib/utils/reset/Kconfig"
 
 source "$OPENSBI_SRC_DIR/lib/utils/serial/Kconfig"
 
+source "$OPENSBI_SRC_DIR/lib/utils/sys/Kconfig"
+
 endmenu
diff --git a/lib/utils/reset/Kconfig b/lib/utils/reset/Kconfig
index d4a32a0..4f04d8c 100644
--- a/lib/utils/reset/Kconfig
+++ b/lib/utils/reset/Kconfig
@@ -14,10 +14,12 @@ config FDT_RESET_GPIO
 
 config FDT_RESET_HTIF
 	bool "Host transfer interface (HTIF) FDT reset driver"
+	select SYS_HTIF
 	default n
 
 config FDT_RESET_SIFIVE_TEST
 	bool "SiFive Test FDT reset driver"
+	select SYS_SIFIVE_TEST
 	default n
 
 config FDT_RESET_SUNXI_WDT
diff --git a/lib/utils/serial/Kconfig b/lib/utils/serial/Kconfig
index 9e6b6fc..a425b13 100644
--- a/lib/utils/serial/Kconfig
+++ b/lib/utils/serial/Kconfig
@@ -15,6 +15,7 @@ config FDT_SERIAL_GAISLER
 
 config FDT_SERIAL_HTIF
 	bool "Host transfer interface (HTIF) UART FDT driver"
+	select SYS_HTIF
 	default n
 
 config FDT_SERIAL_SHAKTI
diff --git a/lib/utils/sys/Kconfig b/lib/utils/sys/Kconfig
new file mode 100644
index 0000000..0fa6b6d
--- /dev/null
+++ b/lib/utils/sys/Kconfig
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "System Device Support"
+
+config SYS_HTIF
+	bool "Host transfere interface (HTIF) support"
+	default n
+
+config SYS_SIFIVE_TEST
+	bool "SiFive test support"
+	default n
+
+endmenu
diff --git a/lib/utils/sys/objects.mk b/lib/utils/sys/objects.mk
index 06be322..9f67aee 100644
--- a/lib/utils/sys/objects.mk
+++ b/lib/utils/sys/objects.mk
@@ -7,5 +7,5 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += sys/htif.o
-libsbiutils-objs-y += sys/sifive_test.o
+libsbiutils-objs-$(CONFIG_SYS_HTIF) += sys/htif.o
+libsbiutils-objs-$(CONFIG_SYS_SIFIVE_TEST) += sys/sifive_test.o
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 06/14] lib: utils/timer: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (4 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 05/14] lib: utils/sys: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 07/14] lib: utils/ipi: " Anup Patel
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update timer drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate timer
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/timer/fdt_timer.h |  9 +++++++++
 lib/utils/Kconfig                   |  2 ++
 lib/utils/timer/Kconfig             | 22 ++++++++++++++++++++++
 lib/utils/timer/objects.mk          | 10 +++++-----
 platform/fpga/ariane/Kconfig        |  1 +
 platform/fpga/openpiton/Kconfig     |  1 +
 platform/generic/configs/defconfig  |  2 ++
 platform/kendryte/k210/Kconfig      |  1 +
 platform/nuclei/ux600/Kconfig       |  1 +
 platform/template/Kconfig           |  1 +
 10 files changed, 45 insertions(+), 5 deletions(-)
 create mode 100644 lib/utils/timer/Kconfig

diff --git a/include/sbi_utils/timer/fdt_timer.h b/include/sbi_utils/timer/fdt_timer.h
index 36202a4..cf105fe 100644
--- a/include/sbi_utils/timer/fdt_timer.h
+++ b/include/sbi_utils/timer/fdt_timer.h
@@ -12,6 +12,8 @@
 
 #include <sbi/sbi_types.h>
 
+#ifdef CONFIG_FDT_TIMER
+
 struct fdt_timer {
 	const struct fdt_match *match_table;
 	int (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match);
@@ -23,4 +25,11 @@ void fdt_timer_exit(void);
 
 int fdt_timer_init(bool cold_boot);
 
+#else
+
+static inline void fdt_timer_exit(void) { }
+static inline int fdt_timer_init(bool cold_boot) { return 0; }
+
+#endif
+
 #endif
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index 6442b75..e169ed4 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -8,4 +8,6 @@ source "$OPENSBI_SRC_DIR/lib/utils/serial/Kconfig"
 
 source "$OPENSBI_SRC_DIR/lib/utils/sys/Kconfig"
 
+source "$OPENSBI_SRC_DIR/lib/utils/timer/Kconfig"
+
 endmenu
diff --git a/lib/utils/timer/Kconfig b/lib/utils/timer/Kconfig
new file mode 100644
index 0000000..3b1221a
--- /dev/null
+++ b/lib/utils/timer/Kconfig
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "Timer Device Support"
+
+config FDT_TIMER
+	bool "FDT based timer drivers"
+	default n
+
+if FDT_TIMER
+
+config FDT_TIMER_MTIMER
+	bool "ACLINT MTIMER FDT driver"
+	select TIMER_MTIMER
+	default n
+
+endif
+
+config TIMER_MTIMER
+	bool "ACLINT MTIMER support"
+	default n
+
+endmenu
diff --git a/lib/utils/timer/objects.mk b/lib/utils/timer/objects.mk
index bc4073d..7f5f3ce 100644
--- a/lib/utils/timer/objects.mk
+++ b/lib/utils/timer/objects.mk
@@ -7,10 +7,10 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += timer/aclint_mtimer.o
+libsbiutils-objs-$(CONFIG_TIMER_MTIMER) += timer/aclint_mtimer.o
 
-libsbiutils-objs-y += timer/fdt_timer.o
-libsbiutils-objs-y += timer/fdt_timer_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_TIMER) += timer/fdt_timer.o
+libsbiutils-objs-$(CONFIG_FDT_TIMER) += timer/fdt_timer_drivers.o
 
-carray-fdt_timer_drivers-y += fdt_timer_mtimer
-libsbiutils-objs-y += timer/fdt_timer_mtimer.o
+carray-fdt_timer_drivers-$(CONFIG_FDT_TIMER_MTIMER) += fdt_timer_mtimer
+libsbiutils-objs-$(CONFIG_FDT_TIMER_MTIMER) += timer/fdt_timer_mtimer.o
diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
index 797af74..cf60f99 100644
--- a/platform/fpga/ariane/Kconfig
+++ b/platform/fpga/ariane/Kconfig
@@ -3,4 +3,5 @@
 config PLATFORM_ARIANE_FPGA
 	bool
 	select SERIAL_UART8250
+	select TIMER_MTIMER
 	default y
diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
index 09b658a..b0e1321 100644
--- a/platform/fpga/openpiton/Kconfig
+++ b/platform/fpga/openpiton/Kconfig
@@ -3,4 +3,5 @@
 config PLATFORM_OPENPITON_FPGA
 	bool
 	select SERIAL_UART8250
+	select TIMER_MTIMER
 	default y
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index 9778665..9b96a4f 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -12,3 +12,5 @@ CONFIG_FDT_SERIAL_SIFIVE=y
 CONFIG_FDT_SERIAL_LITEX=y
 CONFIG_FDT_SERIAL_UART8250=y
 CONFIG_FDT_SERIAL_XILINX_UARTLITE=y
+CONFIG_FDT_TIMER=y
+CONFIG_FDT_TIMER_MTIMER=y
diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
index bc921c8..a0e6116 100644
--- a/platform/kendryte/k210/Kconfig
+++ b/platform/kendryte/k210/Kconfig
@@ -3,4 +3,5 @@
 config PLATFORM_KENDRYTE_K210
 	bool
 	select SERIAL_SIFIVE
+	select TIMER_MTIMER
 	default y
diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
index c4da266..b05c6a9 100644
--- a/platform/nuclei/ux600/Kconfig
+++ b/platform/nuclei/ux600/Kconfig
@@ -3,4 +3,5 @@
 config PLATFORM_NUCLEI_UX600
 	bool
 	select SERIAL_SIFIVE
+	select TIMER_MTIMER
 	default y
diff --git a/platform/template/Kconfig b/platform/template/Kconfig
index e01fb31..933b9e7 100644
--- a/platform/template/Kconfig
+++ b/platform/template/Kconfig
@@ -3,4 +3,5 @@
 config PLATFORM_TEMPLATE
 	bool
 	select SERIAL_UART8250
+	select TIMER_MTIMER
 	default y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 07/14] lib: utils/ipi: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (5 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 06/14] lib: utils/timer: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 08/14] lib: utils/irqchip: " Anup Patel
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update ipi drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate ipi
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/ipi/fdt_ipi.h    |  9 +++++++++
 lib/utils/Kconfig                  |  2 ++
 lib/utils/ipi/Kconfig              | 22 ++++++++++++++++++++++
 lib/utils/ipi/objects.mk           | 10 +++++-----
 platform/fpga/ariane/Kconfig       |  1 +
 platform/fpga/openpiton/Kconfig    |  1 +
 platform/generic/configs/defconfig |  2 ++
 platform/kendryte/k210/Kconfig     |  1 +
 platform/nuclei/ux600/Kconfig      |  1 +
 platform/template/Kconfig          |  1 +
 10 files changed, 45 insertions(+), 5 deletions(-)
 create mode 100644 lib/utils/ipi/Kconfig

diff --git a/include/sbi_utils/ipi/fdt_ipi.h b/include/sbi_utils/ipi/fdt_ipi.h
index 9337353..1dd9062 100644
--- a/include/sbi_utils/ipi/fdt_ipi.h
+++ b/include/sbi_utils/ipi/fdt_ipi.h
@@ -12,6 +12,8 @@
 
 #include <sbi/sbi_types.h>
 
+#ifdef CONFIG_FDT_IPI
+
 struct fdt_ipi {
 	const struct fdt_match *match_table;
 	int (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match);
@@ -23,4 +25,11 @@ void fdt_ipi_exit(void);
 
 int fdt_ipi_init(bool cold_boot);
 
+#else
+
+static inline void fdt_ipi_exit(void) { }
+static inline int fdt_ipi_init(bool cold_boot) { return 0; }
+
+#endif
+
 #endif
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index e169ed4..4daeb1d 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -2,6 +2,8 @@
 
 menu "Utils and Drivers Support"
 
+source "$OPENSBI_SRC_DIR/lib/utils/ipi/Kconfig"
+
 source "$OPENSBI_SRC_DIR/lib/utils/reset/Kconfig"
 
 source "$OPENSBI_SRC_DIR/lib/utils/serial/Kconfig"
diff --git a/lib/utils/ipi/Kconfig b/lib/utils/ipi/Kconfig
new file mode 100644
index 0000000..e8b1446
--- /dev/null
+++ b/lib/utils/ipi/Kconfig
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "IPI Device Support"
+
+config FDT_IPI
+	bool "FDT based ipi drivers"
+	default n
+
+if FDT_IPI
+
+config FDT_IPI_MSWI
+	bool "ACLINT MSWI FDT driver"
+	select IPI_MSWI
+	default n
+
+endif
+
+config IPI_MSWI
+	bool "ACLINT MSWI support"
+	default n
+
+endmenu
diff --git a/lib/utils/ipi/objects.mk b/lib/utils/ipi/objects.mk
index 0b0bc2d..0600cac 100644
--- a/lib/utils/ipi/objects.mk
+++ b/lib/utils/ipi/objects.mk
@@ -7,10 +7,10 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += ipi/aclint_mswi.o
+libsbiutils-objs-$(CONFIG_IPI_MSWI) += ipi/aclint_mswi.o
 
-libsbiutils-objs-y += ipi/fdt_ipi.o
-libsbiutils-objs-y += ipi/fdt_ipi_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_IPI) += ipi/fdt_ipi.o
+libsbiutils-objs-$(CONFIG_FDT_IPI) += ipi/fdt_ipi_drivers.o
 
-carray-fdt_ipi_drivers-y += fdt_ipi_mswi
-libsbiutils-objs-y += ipi/fdt_ipi_mswi.o
+carray-fdt_ipi_drivers-$(CONFIG_FDT_IPI_MSWI) += fdt_ipi_mswi
+libsbiutils-objs-$(CONFIG_FDT_IPI_MSWI) += ipi/fdt_ipi_mswi.o
diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
index cf60f99..c9601f0 100644
--- a/platform/fpga/ariane/Kconfig
+++ b/platform/fpga/ariane/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_ARIANE_FPGA
 	bool
+	select IPI_MSWI
 	select SERIAL_UART8250
 	select TIMER_MTIMER
 	default y
diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
index b0e1321..aefd2e0 100644
--- a/platform/fpga/openpiton/Kconfig
+++ b/platform/fpga/openpiton/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_OPENPITON_FPGA
 	bool
+	select IPI_MSWI
 	select SERIAL_UART8250
 	select TIMER_MTIMER
 	default y
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index 9b96a4f..e218c32 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -1,3 +1,5 @@
+CONFIG_FDT_IPI=y
+CONFIG_FDT_IPI_MSWI=y
 CONFIG_FDT_RESET=y
 CONFIG_FDT_RESET_GPIO=y
 CONFIG_FDT_RESET_HTIF=y
diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
index a0e6116..da675dc 100644
--- a/platform/kendryte/k210/Kconfig
+++ b/platform/kendryte/k210/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_KENDRYTE_K210
 	bool
+	select IPI_MSWI
 	select SERIAL_SIFIVE
 	select TIMER_MTIMER
 	default y
diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
index b05c6a9..44b3425 100644
--- a/platform/nuclei/ux600/Kconfig
+++ b/platform/nuclei/ux600/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_NUCLEI_UX600
 	bool
+	select IPI_MSWI
 	select SERIAL_SIFIVE
 	select TIMER_MTIMER
 	default y
diff --git a/platform/template/Kconfig b/platform/template/Kconfig
index 933b9e7..2f97871 100644
--- a/platform/template/Kconfig
+++ b/platform/template/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_TEMPLATE
 	bool
+	select IPI_MSWI
 	select SERIAL_UART8250
 	select TIMER_MTIMER
 	default y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 08/14] lib: utils/irqchip: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (6 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 07/14] lib: utils/ipi: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 09/14] lib: utils/i2c: " Anup Patel
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update irqchip drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate irqchip
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/irqchip/fdt_irqchip.h | 10 +++++++
 include/sbi_utils/irqchip/imsic.h       | 10 +++++++
 lib/utils/Kconfig                       |  2 ++
 lib/utils/irqchip/Kconfig               | 40 +++++++++++++++++++++++++
 lib/utils/irqchip/objects.mk            | 22 +++++++-------
 platform/andes/ae350/Kconfig            |  1 +
 platform/fpga/ariane/Kconfig            |  1 +
 platform/fpga/openpiton/Kconfig         |  1 +
 platform/generic/configs/defconfig      |  4 +++
 platform/kendryte/k210/Kconfig          |  1 +
 platform/nuclei/ux600/Kconfig           |  1 +
 platform/template/Kconfig               |  1 +
 12 files changed, 83 insertions(+), 11 deletions(-)
 create mode 100644 lib/utils/irqchip/Kconfig

diff --git a/include/sbi_utils/irqchip/fdt_irqchip.h b/include/sbi_utils/irqchip/fdt_irqchip.h
index 13ef6f7..63e9fd9 100644
--- a/include/sbi_utils/irqchip/fdt_irqchip.h
+++ b/include/sbi_utils/irqchip/fdt_irqchip.h
@@ -12,6 +12,8 @@
 
 #include <sbi/sbi_types.h>
 
+#ifdef CONFIG_FDT_IRQCHIP
+
 struct fdt_irqchip {
 	const struct fdt_match *match_table;
 	int (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match);
@@ -23,4 +25,12 @@ void fdt_irqchip_exit(void);
 
 int fdt_irqchip_init(bool cold_boot);
 
+#else
+
+static inline void fdt_irqchip_exit(void) { }
+
+static inline int fdt_irqchip_init(bool cold_boot) { return 0; }
+
+#endif
+
 #endif
diff --git a/include/sbi_utils/irqchip/imsic.h b/include/sbi_utils/irqchip/imsic.h
index cffcb5a..e295771 100644
--- a/include/sbi_utils/irqchip/imsic.h
+++ b/include/sbi_utils/irqchip/imsic.h
@@ -33,6 +33,8 @@ struct imsic_data {
 	struct imsic_regs regs[IMSIC_MAX_REGS];
 };
 
+#ifdef CONFIG_IRQCHIP_IMSIC
+
 int imsic_map_hartid_to_data(u32 hartid, struct imsic_data *imsic, int file);
 
 struct imsic_data *imsic_get_data(u32 hartid);
@@ -47,4 +49,12 @@ int imsic_data_check(struct imsic_data *imsic);
 
 int imsic_cold_irqchip_init(struct imsic_data *imsic);
 
+#else
+
+static inline void imsic_local_irqchip_init(void) { }
+
+static inline int imsic_data_check(struct imsic_data *imsic) { return 0; }
+
+#endif
+
 #endif
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index 4daeb1d..e384cb8 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -4,6 +4,8 @@ menu "Utils and Drivers Support"
 
 source "$OPENSBI_SRC_DIR/lib/utils/ipi/Kconfig"
 
+source "$OPENSBI_SRC_DIR/lib/utils/irqchip/Kconfig"
+
 source "$OPENSBI_SRC_DIR/lib/utils/reset/Kconfig"
 
 source "$OPENSBI_SRC_DIR/lib/utils/serial/Kconfig"
diff --git a/lib/utils/irqchip/Kconfig b/lib/utils/irqchip/Kconfig
new file mode 100644
index 0000000..cc07c8e
--- /dev/null
+++ b/lib/utils/irqchip/Kconfig
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "Interrupt Controller Support"
+
+config FDT_IRQCHIP
+	bool "FDT based interrupt controller drivers"
+	default n
+
+if FDT_IRQCHIP
+
+config FDT_IRQCHIP_APLIC
+	bool "Advanced Platform Level Interrupt Controller (APLIC) FDT driver"
+	select IRQCHIP_APLIC
+	default n
+
+config FDT_IRQCHIP_IMSIC
+	bool "Incoming Message Signalled Interrupt Controller (IMSIC) FDT driver"
+	select IRQCHIP_IMSIC
+	default n
+
+config FDT_IRQCHIP_PLIC
+	bool "Platform Level Interrupt Controller (PLIC) FDT driver"
+	select IRQCHIP_PLIC
+	default n
+
+endif
+
+config IRQCHIP_APLIC
+	bool "Advanced Platform Level Interrupt Controller (APLIC) support"
+	default n
+
+config IRQCHIP_IMSIC
+	bool "Incoming Message Signalled Interrupt Controller (IMSIC) support"
+	default n
+
+config IRQCHIP_PLIC
+	bool "Platform Level Interrupt Controller (PLIC) support"
+	default n
+
+endmenu
diff --git a/lib/utils/irqchip/objects.mk b/lib/utils/irqchip/objects.mk
index 7775bc4..e458891 100644
--- a/lib/utils/irqchip/objects.mk
+++ b/lib/utils/irqchip/objects.mk
@@ -7,18 +7,18 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += irqchip/fdt_irqchip.o
-libsbiutils-objs-y += irqchip/fdt_irqchip_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_IRQCHIP) += irqchip/fdt_irqchip.o
+libsbiutils-objs-$(CONFIG_FDT_IRQCHIP) += irqchip/fdt_irqchip_drivers.o
 
-carray-fdt_irqchip_drivers-y += fdt_irqchip_aplic
-libsbiutils-objs-y += irqchip/fdt_irqchip_aplic.o
+carray-fdt_irqchip_drivers-$(CONFIG_FDT_IRQCHIP_APLIC) += fdt_irqchip_aplic
+libsbiutils-objs-$(CONFIG_FDT_IRQCHIP_APLIC) += irqchip/fdt_irqchip_aplic.o
 
-carray-fdt_irqchip_drivers-y += fdt_irqchip_imsic
-libsbiutils-objs-y += irqchip/fdt_irqchip_imsic.o
+carray-fdt_irqchip_drivers-$(CONFIG_FDT_IRQCHIP_IMSIC) += fdt_irqchip_imsic
+libsbiutils-objs-$(CONFIG_FDT_IRQCHIP_IMSIC) += irqchip/fdt_irqchip_imsic.o
 
-carray-fdt_irqchip_drivers-y += fdt_irqchip_plic
-libsbiutils-objs-y += irqchip/fdt_irqchip_plic.o
+carray-fdt_irqchip_drivers-$(CONFIG_FDT_IRQCHIP_PLIC) += fdt_irqchip_plic
+libsbiutils-objs-$(CONFIG_FDT_IRQCHIP_PLIC) += irqchip/fdt_irqchip_plic.o
 
-libsbiutils-objs-y += irqchip/aplic.o
-libsbiutils-objs-y += irqchip/imsic.o
-libsbiutils-objs-y += irqchip/plic.o
+libsbiutils-objs-$(CONFIG_IRQCHIP_APLIC) += irqchip/aplic.o
+libsbiutils-objs-$(CONFIG_IRQCHIP_IMSIC) += irqchip/imsic.o
+libsbiutils-objs-$(CONFIG_IRQCHIP_PLIC) += irqchip/plic.o
diff --git a/platform/andes/ae350/Kconfig b/platform/andes/ae350/Kconfig
index 0048c1b..69cb65e 100644
--- a/platform/andes/ae350/Kconfig
+++ b/platform/andes/ae350/Kconfig
@@ -2,5 +2,6 @@
 
 config PLATFORM_ANDES_AE350
 	bool
+	select IRQCHIP_PLIC
 	select SERIAL_UART8250
 	default y
diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
index c9601f0..3303689 100644
--- a/platform/fpga/ariane/Kconfig
+++ b/platform/fpga/ariane/Kconfig
@@ -3,6 +3,7 @@
 config PLATFORM_ARIANE_FPGA
 	bool
 	select IPI_MSWI
+	select IRQCHIP_PLIC
 	select SERIAL_UART8250
 	select TIMER_MTIMER
 	default y
diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
index aefd2e0..5bf77ae 100644
--- a/platform/fpga/openpiton/Kconfig
+++ b/platform/fpga/openpiton/Kconfig
@@ -3,6 +3,7 @@
 config PLATFORM_OPENPITON_FPGA
 	bool
 	select IPI_MSWI
+	select IRQCHIP_PLIC
 	select SERIAL_UART8250
 	select TIMER_MTIMER
 	default y
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index e218c32..ad66a63 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -1,5 +1,9 @@
 CONFIG_FDT_IPI=y
 CONFIG_FDT_IPI_MSWI=y
+CONFIG_FDT_IRQCHIP=y
+CONFIG_FDT_IRQCHIP_APLIC=y
+CONFIG_FDT_IRQCHIP_IMSIC=y
+CONFIG_FDT_IRQCHIP_PLIC=y
 CONFIG_FDT_RESET=y
 CONFIG_FDT_RESET_GPIO=y
 CONFIG_FDT_RESET_HTIF=y
diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
index da675dc..80b5ae9 100644
--- a/platform/kendryte/k210/Kconfig
+++ b/platform/kendryte/k210/Kconfig
@@ -3,6 +3,7 @@
 config PLATFORM_KENDRYTE_K210
 	bool
 	select IPI_MSWI
+	select IRQCHIP_PLIC
 	select SERIAL_SIFIVE
 	select TIMER_MTIMER
 	default y
diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
index 44b3425..02766a6 100644
--- a/platform/nuclei/ux600/Kconfig
+++ b/platform/nuclei/ux600/Kconfig
@@ -3,6 +3,7 @@
 config PLATFORM_NUCLEI_UX600
 	bool
 	select IPI_MSWI
+	select IRQCHIP_PLIC
 	select SERIAL_SIFIVE
 	select TIMER_MTIMER
 	default y
diff --git a/platform/template/Kconfig b/platform/template/Kconfig
index 2f97871..5c59915 100644
--- a/platform/template/Kconfig
+++ b/platform/template/Kconfig
@@ -3,6 +3,7 @@
 config PLATFORM_TEMPLATE
 	bool
 	select IPI_MSWI
+	select IRQCHIP_PLIC
 	select SERIAL_UART8250
 	select TIMER_MTIMER
 	default y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 09/14] lib: utils/i2c: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (7 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 08/14] lib: utils/irqchip: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 10/14] lib: utils/gpio: " Anup Patel
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update i2c drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate i2c
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 lib/utils/Kconfig                  |  2 ++
 lib/utils/i2c/Kconfig              | 22 ++++++++++++++++++++++
 lib/utils/i2c/objects.mk           | 10 +++++-----
 platform/generic/configs/defconfig |  2 ++
 4 files changed, 31 insertions(+), 5 deletions(-)
 create mode 100644 lib/utils/i2c/Kconfig

diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index e384cb8..9477ec7 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -2,6 +2,8 @@
 
 menu "Utils and Drivers Support"
 
+source "$OPENSBI_SRC_DIR/lib/utils/i2c/Kconfig"
+
 source "$OPENSBI_SRC_DIR/lib/utils/ipi/Kconfig"
 
 source "$OPENSBI_SRC_DIR/lib/utils/irqchip/Kconfig"
diff --git a/lib/utils/i2c/Kconfig b/lib/utils/i2c/Kconfig
new file mode 100644
index 0000000..bb29cd8
--- /dev/null
+++ b/lib/utils/i2c/Kconfig
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "I2C Support"
+
+config FDT_I2C
+	bool "FDT based I2C drivers"
+	select I2C
+	default n
+
+if FDT_I2C
+
+config FDT_I2C_SIFIVE
+	bool "SiFive I2C FDT driver"
+	default n
+
+endif
+
+config I2C
+	bool "I2C support"
+	default n
+
+endmenu
diff --git a/lib/utils/i2c/objects.mk b/lib/utils/i2c/objects.mk
index bb0d6d5..a0fbbb5 100644
--- a/lib/utils/i2c/objects.mk
+++ b/lib/utils/i2c/objects.mk
@@ -7,10 +7,10 @@
 #   Nikita Shubin <n.shubin@yadro.com>
 #
 
-libsbiutils-objs-y += i2c/i2c.o
+libsbiutils-objs-$(CONFIG_I2C) += i2c/i2c.o
 
-libsbiutils-objs-y += i2c/fdt_i2c.o
-libsbiutils-objs-y += i2c/fdt_i2c_adapter_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_I2C) += i2c/fdt_i2c.o
+libsbiutils-objs-$(CONFIG_FDT_I2C) += i2c/fdt_i2c_adapter_drivers.o
 
-carray-fdt_i2c_adapter_drivers-y += fdt_i2c_adapter_sifive
-libsbiutils-objs-y += i2c/fdt_i2c_sifive.o
+carray-fdt_i2c_adapter_drivers-$(CONFIG_FDT_I2C_SIFIVE) += fdt_i2c_adapter_sifive
+libsbiutils-objs-$(CONFIG_FDT_I2C_SIFIVE) += i2c/fdt_i2c_sifive.o
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index ad66a63..c9c221e 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -1,3 +1,5 @@
+CONFIG_FDT_I2C=y
+CONFIG_FDT_I2C_SIFIVE=y
 CONFIG_FDT_IPI=y
 CONFIG_FDT_IPI_MSWI=y
 CONFIG_FDT_IRQCHIP=y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 10/14] lib: utils/gpio: Use kconfig for enabling/disabling drivers
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (8 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 09/14] lib: utils/i2c: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 11/14] lib: utils/fdt: Use kconfig for enabling/disabling Anup Patel
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update gpio drivers makefile to use kconfig for enabling/disabling
drivers. To avoid compile errors, we also enable appropriate gpio
drivers for each platform.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 lib/utils/Kconfig                  |  2 ++
 lib/utils/gpio/Kconfig             | 22 ++++++++++++++++++++++
 lib/utils/gpio/objects.mk          | 10 +++++-----
 lib/utils/reset/Kconfig            |  1 +
 platform/generic/configs/defconfig |  2 ++
 5 files changed, 32 insertions(+), 5 deletions(-)
 create mode 100644 lib/utils/gpio/Kconfig

diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index 9477ec7..57a6509 100644
--- a/lib/utils/Kconfig
+++ b/lib/utils/Kconfig
@@ -2,6 +2,8 @@
 
 menu "Utils and Drivers Support"
 
+source "$OPENSBI_SRC_DIR/lib/utils/gpio/Kconfig"
+
 source "$OPENSBI_SRC_DIR/lib/utils/i2c/Kconfig"
 
 source "$OPENSBI_SRC_DIR/lib/utils/ipi/Kconfig"
diff --git a/lib/utils/gpio/Kconfig b/lib/utils/gpio/Kconfig
new file mode 100644
index 0000000..73673a3
--- /dev/null
+++ b/lib/utils/gpio/Kconfig
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "GPIO Support"
+
+config FDT_GPIO
+	bool "FDT based GPIO drivers"
+	select GPIO
+	default n
+
+if FDT_GPIO
+
+config FDT_GPIO_SIFIVE
+	bool "SiFive GPIO FDT driver"
+	default n
+
+endif
+
+config GPIO
+	bool "GPIO support"
+	default n
+
+endmenu
diff --git a/lib/utils/gpio/objects.mk b/lib/utils/gpio/objects.mk
index a5e131b..eedd699 100644
--- a/lib/utils/gpio/objects.mk
+++ b/lib/utils/gpio/objects.mk
@@ -7,10 +7,10 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
-libsbiutils-objs-y += gpio/fdt_gpio.o
-libsbiutils-objs-y += gpio/fdt_gpio_drivers.o
+libsbiutils-objs-$(CONFIG_FDT_GPIO) += gpio/fdt_gpio.o
+libsbiutils-objs-$(CONFIG_FDT_GPIO) += gpio/fdt_gpio_drivers.o
 
-carray-fdt_gpio_drivers-y += fdt_gpio_sifive
-libsbiutils-objs-y += gpio/fdt_gpio_sifive.o
+carray-fdt_gpio_drivers-$(CONFIG_FDT_GPIO_SIFIVE) += fdt_gpio_sifive
+libsbiutils-objs-$(CONFIG_FDT_GPIO_SIFIVE) += gpio/fdt_gpio_sifive.o
 
-libsbiutils-objs-y += gpio/gpio.o
+libsbiutils-objs-$(CONFIG_GPIO) += gpio/gpio.o
diff --git a/lib/utils/reset/Kconfig b/lib/utils/reset/Kconfig
index 4f04d8c..ead9e2a 100644
--- a/lib/utils/reset/Kconfig
+++ b/lib/utils/reset/Kconfig
@@ -10,6 +10,7 @@ if FDT_RESET
 
 config FDT_RESET_GPIO
 	bool "GPIO FDT reset driver"
+	depends on FDT_GPIO
 	default n
 
 config FDT_RESET_HTIF
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index c9c221e..d56cef2 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -1,3 +1,5 @@
+CONFIG_FDT_GPIO=y
+CONFIG_FDT_GPIO_SIFIVE=y
 CONFIG_FDT_I2C=y
 CONFIG_FDT_I2C_SIFIVE=y
 CONFIG_FDT_IPI=y
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 11/14] lib: utils/fdt: Use kconfig for enabling/disabling
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (9 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 10/14] lib: utils/gpio: " Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 12/14] platform: generic: Use kconfig for enabling/disabling overrides Anup Patel
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

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>
---
 include/sbi_utils/fdt/fdt_domain.h             |  9 +++++++++
 include/sbi_utils/fdt/fdt_pmu.h                | 10 ++++++++++
 lib/utils/Kconfig                              |  4 ++++
 lib/utils/fdt/Kconfig                          | 18 ++++++++++++++++++
 lib/utils/fdt/objects.mk                       |  8 ++++----
 lib/utils/gpio/Kconfig                         |  1 +
 lib/utils/i2c/Kconfig                          |  1 +
 lib/utils/ipi/Kconfig                          |  1 +
 lib/utils/irqchip/Kconfig                      |  1 +
 {platform/generic => lib/utils/libfdt}/Kconfig |  4 ++--
 lib/utils/libfdt/objects.mk                    |  4 ++--
 lib/utils/reset/Kconfig                        |  1 +
 lib/utils/serial/Kconfig                       |  1 +
 lib/utils/timer/Kconfig                        |  1 +
 platform/andes/ae350/Kconfig                   |  1 +
 platform/fpga/ariane/Kconfig                   |  1 +
 platform/fpga/openpiton/Kconfig                |  1 +
 platform/generic/Kconfig                       |  3 +++
 platform/kendryte/k210/Kconfig                 |  1 +
 platform/nuclei/ux600/Kconfig                  |  1 +
 platform/nuclei/ux600/platform.c               |  1 -
 21 files changed, 64 insertions(+), 9 deletions(-)
 create mode 100644 lib/utils/fdt/Kconfig
 copy {platform/generic => lib/utils/libfdt}/Kconfig (54%)

diff --git a/include/sbi_utils/fdt/fdt_domain.h b/include/sbi_utils/fdt/fdt_domain.h
index 5448eb4..ee09d1b 100644
--- a/include/sbi_utils/fdt/fdt_domain.h
+++ b/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__ */
diff --git a/include/sbi_utils/fdt/fdt_pmu.h b/include/sbi_utils/fdt/fdt_pmu.h
index 2fa01ed..c65cad7 100644
--- a/include/sbi_utils/fdt/fdt_pmu.h
+++ b/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
diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
index 57a6509..97f97b5 100644
--- a/lib/utils/Kconfig
+++ b/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"
diff --git a/lib/utils/fdt/Kconfig b/lib/utils/fdt/Kconfig
new file mode 100644
index 0000000..a8022a0
--- /dev/null
+++ b/lib/utils/fdt/Kconfig
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-2.0
+
+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
diff --git a/lib/utils/fdt/objects.mk b/lib/utils/fdt/objects.mk
index 03800f9..5cede81 100644
--- a/lib/utils/fdt/objects.mk
+++ b/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
diff --git a/lib/utils/gpio/Kconfig b/lib/utils/gpio/Kconfig
index 73673a3..ebf1b2c 100644
--- a/lib/utils/gpio/Kconfig
+++ b/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
 
diff --git a/lib/utils/i2c/Kconfig b/lib/utils/i2c/Kconfig
index bb29cd8..0313588 100644
--- a/lib/utils/i2c/Kconfig
+++ b/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
 
diff --git a/lib/utils/ipi/Kconfig b/lib/utils/ipi/Kconfig
index e8b1446..2a84ecd 100644
--- a/lib/utils/ipi/Kconfig
+++ b/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
diff --git a/lib/utils/irqchip/Kconfig b/lib/utils/irqchip/Kconfig
index cc07c8e..9090b18 100644
--- a/lib/utils/irqchip/Kconfig
+++ b/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
diff --git a/platform/generic/Kconfig b/lib/utils/libfdt/Kconfig
similarity index 54%
copy from platform/generic/Kconfig
copy to lib/utils/libfdt/Kconfig
index a811a05..096345b 100644
--- a/platform/generic/Kconfig
+++ b/lib/utils/libfdt/Kconfig
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
-config PLATFORM_GENERIC
+config LIBFDT
 	bool
-	default y
+	default n
diff --git a/lib/utils/libfdt/objects.mk b/lib/utils/libfdt/objects.mk
index 8c060df..a5b4001 100644
--- a/lib/utils/libfdt/objects.mk
+++ b/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-genflags-y  += -I$(libsbiutils_dir)/libfdt/
+libsbiutils-objs-$(CONFIG_LIBFDT) += $(addprefix libfdt/,$(libfdt_files))
+libsbiutils-genflags-$(CONFIG_LIBFDT)  += -I$(libsbiutils_dir)/libfdt/
diff --git a/lib/utils/reset/Kconfig b/lib/utils/reset/Kconfig
index ead9e2a..bcfb419 100644
--- a/lib/utils/reset/Kconfig
+++ b/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
diff --git a/lib/utils/serial/Kconfig b/lib/utils/serial/Kconfig
index a425b13..34d72ff 100644
--- a/lib/utils/serial/Kconfig
+++ b/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
diff --git a/lib/utils/timer/Kconfig b/lib/utils/timer/Kconfig
index 3b1221a..5266f1d 100644
--- a/lib/utils/timer/Kconfig
+++ b/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
diff --git a/platform/andes/ae350/Kconfig b/platform/andes/ae350/Kconfig
index 69cb65e..a9bbf46 100644
--- a/platform/andes/ae350/Kconfig
+++ b/platform/andes/ae350/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_ANDES_AE350
 	bool
+	select FDT
 	select IRQCHIP_PLIC
 	select SERIAL_UART8250
 	default y
diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
index 3303689..40d6ad6 100644
--- a/platform/fpga/ariane/Kconfig
+++ b/platform/fpga/ariane/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_ARIANE_FPGA
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_UART8250
diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
index 5bf77ae..08087fb 100644
--- a/platform/fpga/openpiton/Kconfig
+++ b/platform/fpga/openpiton/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_OPENPITON_FPGA
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_UART8250
diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
index a811a05..21ebd6a 100644
--- a/platform/generic/Kconfig
+++ b/platform/generic/Kconfig
@@ -2,4 +2,7 @@
 
 config PLATFORM_GENERIC
 	bool
+	select FDT
+	select FDT_DOMAIN
+	select FDT_PMU
 	default y
diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
index 80b5ae9..58b893e 100644
--- a/platform/kendryte/k210/Kconfig
+++ b/platform/kendryte/k210/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_KENDRYTE_K210
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_SIFIVE
diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
index 02766a6..11fabb1 100644
--- a/platform/nuclei/ux600/Kconfig
+++ b/platform/nuclei/ux600/Kconfig
@@ -2,6 +2,7 @@
 
 config PLATFORM_NUCLEI_UX600
 	bool
+	select FDT
 	select IPI_MSWI
 	select IRQCHIP_PLIC
 	select SERIAL_SIFIVE
diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c
index 5498a1f..2b02734 100644
--- a/platform/nuclei/ux600/platform.c
+++ b/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>
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 12/14] platform: generic: Use kconfig for enabling/disabling overrides
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (10 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 11/14] lib: utils/fdt: Use kconfig for enabling/disabling Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 13/14] platform: Remove redundant config.mk from all platforms Anup Patel
  2022-07-18 12:42 ` [PATCH 14/14] docs: Update documentation for kconfig support Anup Patel
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update generic platform to use kconfig for enabling/disabling
platform overrides. We also enable all platform overrides in generic
platform defconfig.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 platform/generic/Kconfig              | 18 ++++++++++++++++++
 platform/generic/allwinner/objects.mk |  4 ++--
 platform/generic/configs/defconfig    |  3 +++
 platform/generic/sifive/objects.mk    |  8 ++++----
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
index 21ebd6a..8b00772 100644
--- a/platform/generic/Kconfig
+++ b/platform/generic/Kconfig
@@ -6,3 +6,21 @@ config PLATFORM_GENERIC
 	select FDT_DOMAIN
 	select FDT_PMU
 	default y
+
+if PLATFORM_GENERIC
+
+config PLATFORM_ALLWINNER_D1
+	bool "Allwinner D1 support"
+	depends on FDT_IRQCHIP_PLIC
+	default n
+
+config PLATFORM_SIFIVE_FU540
+	bool "SiFive FU540 support"
+	default n
+
+config PLATFORM_SIFIVE_FU740
+	bool "SiFive FU740 support"
+	depends on FDT_RESET && FDT_I2C
+	default n
+
+endif
diff --git a/platform/generic/allwinner/objects.mk b/platform/generic/allwinner/objects.mk
index 9e36ab6..447cdf1 100644
--- a/platform/generic/allwinner/objects.mk
+++ b/platform/generic/allwinner/objects.mk
@@ -2,5 +2,5 @@
 # SPDX-License-Identifier: BSD-2-Clause
 #
 
-carray-platform_override_modules-y += sun20i_d1
-platform-objs-y += allwinner/sun20i-d1.o
+carray-platform_override_modules-$(CONFIG_PLATFORM_ALLWINNER_D1) += sun20i_d1
+platform-objs-$(CONFIG_PLATFORM_ALLWINNER_D1) += allwinner/sun20i-d1.o
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index d56cef2..2a75394 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -1,3 +1,6 @@
+CONFIG_PLATFORM_ALLWINNER_D1=y
+CONFIG_PLATFORM_SIFIVE_FU540=y
+CONFIG_PLATFORM_SIFIVE_FU740=y
 CONFIG_FDT_GPIO=y
 CONFIG_FDT_GPIO_SIFIVE=y
 CONFIG_FDT_I2C=y
diff --git a/platform/generic/sifive/objects.mk b/platform/generic/sifive/objects.mk
index c17e2df..d75e444 100644
--- a/platform/generic/sifive/objects.mk
+++ b/platform/generic/sifive/objects.mk
@@ -2,8 +2,8 @@
 # SPDX-License-Identifier: BSD-2-Clause
 #
 
-carray-platform_override_modules-y += sifive_fu540
-platform-objs-y += sifive/fu540.o
+carray-platform_override_modules-$(CONFIG_PLATFORM_SIFIVE_FU540) += sifive_fu540
+platform-objs-$(CONFIG_PLATFORM_SIFIVE_FU540) += sifive/fu540.o
 
-carray-platform_override_modules-y += sifive_fu740
-platform-objs-y += sifive/fu740.o
+carray-platform_override_modules-$(CONFIG_PLATFORM_SIFIVE_FU740) += sifive_fu740
+platform-objs-$(CONFIG_PLATFORM_SIFIVE_FU740) += sifive/fu740.o
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 13/14] platform: Remove redundant config.mk from all platforms
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (11 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 12/14] platform: generic: Use kconfig for enabling/disabling overrides Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  2022-07-18 12:42 ` [PATCH 14/14] docs: Update documentation for kconfig support Anup Patel
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

The options defined in config.mk can be specified in objects.mk of each
platform so let us remove config.mk from all platforms.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 Makefile                           |  4 +-
 platform/andes/ae350/config.mk     | 36 --------------
 platform/andes/ae350/objects.mk    | 29 +++++++++++
 platform/fpga/ariane/config.mk     | 36 --------------
 platform/fpga/ariane/objects.mk    | 35 ++++++++++++++
 platform/fpga/openpiton/config.mk  | 35 --------------
 platform/fpga/openpiton/objects.mk | 35 ++++++++++++++
 platform/generic/config.mk         | 40 ----------------
 platform/generic/objects.mk        | 33 +++++++++++++
 platform/kendryte/k210/config.mk   | 19 --------
 platform/kendryte/k210/objects.mk  | 12 +++++
 platform/nuclei/ux600/config.mk    | 30 ------------
 platform/nuclei/ux600/objects.mk   | 22 +++++++++
 platform/template/config.mk        | 77 ------------------------------
 platform/template/objects.mk       | 72 ++++++++++++++++++++++++++++
 platform/template/platform.c       |  2 +-
 16 files changed, 240 insertions(+), 277 deletions(-)
 delete mode 100644 platform/andes/ae350/config.mk
 delete mode 100644 platform/fpga/ariane/config.mk
 delete mode 100644 platform/fpga/openpiton/config.mk
 delete mode 100644 platform/generic/config.mk
 delete mode 100644 platform/kendryte/k210/config.mk
 delete mode 100644 platform/nuclei/ux600/config.mk
 delete mode 100644 platform/template/config.mk

diff --git a/Makefile b/Makefile
index 5fc67db..a6475a7 100644
--- a/Makefile
+++ b/Makefile
@@ -203,7 +203,7 @@ firmware-object-mks=$(shell if [ -d $(firmware_dir) ]; then find $(firmware_dir)
 .PHONY: all
 all:
 
-# Include platform specific .config and config.mk
+# Include platform specific .config
 ifdef PLATFORM
 .PHONY: menuconfig
 menuconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
@@ -226,8 +226,6 @@ $(KCONFIG_CONFIG): $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(platform_
 $(KCONFIG_AUTOCONF_CMD): $(KCONFIG_CONFIG)
 include $(KCONFIG_CONFIG)
 include $(KCONFIG_AUTOCONF_CMD)
-
-include $(platform_src_dir)/config.mk
 endif
 
 # Include all object.mk files
diff --git a/platform/andes/ae350/config.mk b/platform/andes/ae350/config.mk
deleted file mode 100644
index f555ef5..0000000
--- a/platform/andes/ae350/config.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2019 Andes Technology Corporation
-#
-# Authors:
-#   Zong Li <zong@andestech.com>
-#   Nylon Chen <nylon7@andestech.com>
-
-# Compiler flags
-platform-cppflags-y =
-platform-cflags-y =
-platform-asflags-y =
-platform-ldflags-y =
-
-# Blobs to build
-FW_TEXT_START=0x00000000
-
-FW_DYNAMIC=y
-
-FW_JUMP=y
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-  FW_JUMP_ADDR=0x400000
-else
-  FW_JUMP_ADDR=0x200000
-endif
-FW_JUMP_FDT_ADDR=0x2000000
-
-FW_PAYLOAD=y
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-  FW_PAYLOAD_OFFSET=0x400000
-else
-  FW_PAYLOAD_OFFSET=0x200000
-endif
-
-FW_PAYLOAD_FDT_ADDR=0x2000000
diff --git a/platform/andes/ae350/objects.mk b/platform/andes/ae350/objects.mk
index 5369677..80f0737 100644
--- a/platform/andes/ae350/objects.mk
+++ b/platform/andes/ae350/objects.mk
@@ -8,4 +8,33 @@
 #   Nylon Chen <nylon7@andestech.com>
 #
 
+# Compiler flags
+platform-cppflags-y =
+platform-cflags-y =
+platform-asflags-y =
+platform-ldflags-y =
+
+# Objects to build
 platform-objs-y += cache.o platform.o plicsw.o plmt.o
+
+# Blobs to build
+FW_TEXT_START=0x00000000
+
+FW_DYNAMIC=y
+
+FW_JUMP=y
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+  FW_JUMP_ADDR=0x400000
+else
+  FW_JUMP_ADDR=0x200000
+endif
+FW_JUMP_FDT_ADDR=0x2000000
+
+FW_PAYLOAD=y
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+  FW_PAYLOAD_OFFSET=0x400000
+else
+  FW_PAYLOAD_OFFSET=0x200000
+endif
+
+FW_PAYLOAD_FDT_ADDR=0x2000000
diff --git a/platform/fpga/ariane/config.mk b/platform/fpga/ariane/config.mk
deleted file mode 100644
index 3556461..0000000
--- a/platform/fpga/ariane/config.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (C) 2019 FORTH-ICS/CARV
-#		Panagiotis Peristerakis <perister@ics.forth.gr>
-#
-
-#for more infos, check out /platform/template/config.mk
-
-PLATFORM_RISCV_XLEN = 64
-
-# Blobs to build
-FW_TEXT_START=0x80000000
-FW_JUMP=n
-
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
- # This needs to be 4MB aligned for 32-bit support
- FW_JUMP_ADDR=0x80400000
- else
- # This needs to be 2MB aligned for 64-bit support
- FW_JUMP_ADDR=0x80200000
- endif
-FW_JUMP_FDT_ADDR=0x82200000
-
-# Firmware with payload configuration.
-FW_PAYLOAD=y
-
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-# This needs to be 4MB aligned for 32-bit support
-  FW_PAYLOAD_OFFSET=0x400000
-else
-# This needs to be 2MB aligned for 64-bit support
-  FW_PAYLOAD_OFFSET=0x200000
-endif
-FW_PAYLOAD_FDT_ADDR=0x82200000
-FW_PAYLOAD_ALIGN=0x1000
diff --git a/platform/fpga/ariane/objects.mk b/platform/fpga/ariane/objects.mk
index 814e6da..83581ac 100644
--- a/platform/fpga/ariane/objects.mk
+++ b/platform/fpga/ariane/objects.mk
@@ -5,4 +5,39 @@
 #		Panagiotis Peristerakis <perister@ics.forth.gr>
 #
 
+# Compiler flags
+platform-cppflags-y =
+platform-cflags-y =
+platform-asflags-y =
+platform-ldflags-y =
+
+# Object to build
 platform-objs-y += platform.o
+
+PLATFORM_RISCV_XLEN = 64
+
+# Blobs to build
+FW_TEXT_START=0x80000000
+FW_JUMP=n
+
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+ # This needs to be 4MB aligned for 32-bit support
+ FW_JUMP_ADDR=0x80400000
+ else
+ # This needs to be 2MB aligned for 64-bit support
+ FW_JUMP_ADDR=0x80200000
+ endif
+FW_JUMP_FDT_ADDR=0x82200000
+
+# Firmware with payload configuration.
+FW_PAYLOAD=y
+
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+# This needs to be 4MB aligned for 32-bit support
+  FW_PAYLOAD_OFFSET=0x400000
+else
+# This needs to be 2MB aligned for 64-bit support
+  FW_PAYLOAD_OFFSET=0x200000
+endif
+FW_PAYLOAD_FDT_ADDR=0x82200000
+FW_PAYLOAD_ALIGN=0x1000
diff --git a/platform/fpga/openpiton/config.mk b/platform/fpga/openpiton/config.mk
deleted file mode 100644
index a969b25..0000000
--- a/platform/fpga/openpiton/config.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2020 Western Digital Corporation or its affiliates.
-#
-
-#for more infos, check out /platform/template/config.mk
-
-PLATFORM_RISCV_XLEN = 64
-
-# Blobs to build
-FW_TEXT_START=0x80000000
-FW_JUMP=n
-
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
- # This needs to be 4MB aligned for 32-bit support
- FW_JUMP_ADDR=0x80400000
- else
- # This needs to be 2MB aligned for 64-bit support
- FW_JUMP_ADDR=0x80200000
- endif
-FW_JUMP_FDT_ADDR=0x82200000
-
-# Firmware with payload configuration.
-FW_PAYLOAD=y
-
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-# This needs to be 4MB aligned for 32-bit support
-  FW_PAYLOAD_OFFSET=0x400000
-else
-# This needs to be 2MB aligned for 64-bit support
-  FW_PAYLOAD_OFFSET=0x200000
-endif
-FW_PAYLOAD_FDT_ADDR=0x82200000
-FW_PAYLOAD_ALIGN=0x1000
diff --git a/platform/fpga/openpiton/objects.mk b/platform/fpga/openpiton/objects.mk
index 30a3c4f..c8c345a 100644
--- a/platform/fpga/openpiton/objects.mk
+++ b/platform/fpga/openpiton/objects.mk
@@ -4,4 +4,39 @@
 # Copyright (c) 2020 Western Digital Corporation or its affiliates.
 #
 
+# Compiler flags
+platform-cppflags-y =
+platform-cflags-y =
+platform-asflags-y =
+platform-ldflags-y =
+
+# Objects to build
 platform-objs-y += platform.o
+
+PLATFORM_RISCV_XLEN = 64
+
+# Blobs to build
+FW_TEXT_START=0x80000000
+FW_JUMP=n
+
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+ # This needs to be 4MB aligned for 32-bit support
+ FW_JUMP_ADDR=0x80400000
+ else
+ # This needs to be 2MB aligned for 64-bit support
+ FW_JUMP_ADDR=0x80200000
+ endif
+FW_JUMP_FDT_ADDR=0x82200000
+
+# Firmware with payload configuration.
+FW_PAYLOAD=y
+
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+# This needs to be 4MB aligned for 32-bit support
+  FW_PAYLOAD_OFFSET=0x400000
+else
+# This needs to be 2MB aligned for 64-bit support
+  FW_PAYLOAD_OFFSET=0x200000
+endif
+FW_PAYLOAD_FDT_ADDR=0x82200000
+FW_PAYLOAD_ALIGN=0x1000
diff --git a/platform/generic/config.mk b/platform/generic/config.mk
deleted file mode 100644
index 8151974..0000000
--- a/platform/generic/config.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2020 Western Digital Corporation or its affiliates.
-#
-# Authors:
-#   Anup Patel <anup.patel@wdc.com>
-#
-
-# Compiler flags
-platform-cppflags-y =
-platform-cflags-y =
-platform-asflags-y =
-platform-ldflags-y =
-
-# Command for platform specific "make run"
-platform-runcmd = qemu-system-riscv$(PLATFORM_RISCV_XLEN) -M virt -m 256M \
-  -nographic -bios $(build_dir)/platform/generic/firmware/fw_payload.elf
-
-# Blobs to build
-FW_TEXT_START=0x80000000
-FW_DYNAMIC=y
-FW_JUMP=y
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-  # This needs to be 4MB aligned for 32-bit system
-  FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x400000)))
-else
-  # This needs to be 2MB aligned for 64-bit system
-  FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
-endif
-FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x2200000)))
-FW_PAYLOAD=y
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-  # This needs to be 4MB aligned for 32-bit system
-  FW_PAYLOAD_OFFSET=0x400000
-else
-  # This needs to be 2MB aligned for 64-bit system
-  FW_PAYLOAD_OFFSET=0x200000
-endif
-FW_PAYLOAD_FDT_ADDR=$(FW_JUMP_FDT_ADDR)
diff --git a/platform/generic/objects.mk b/platform/generic/objects.mk
index 4907754..136853e 100644
--- a/platform/generic/objects.mk
+++ b/platform/generic/objects.mk
@@ -7,5 +7,38 @@
 #   Anup Patel <anup.patel@wdc.com>
 #
 
+# Compiler flags
+platform-cppflags-y =
+platform-cflags-y =
+platform-asflags-y =
+platform-ldflags-y =
+
+# Command for platform specific "make run"
+platform-runcmd = qemu-system-riscv$(PLATFORM_RISCV_XLEN) -M virt -m 256M \
+  -nographic -bios $(build_dir)/platform/generic/firmware/fw_payload.elf
+
+# Objects to build
 platform-objs-y += platform.o
 platform-objs-y += platform_override_modules.o
+
+# Blobs to build
+FW_TEXT_START=0x80000000
+FW_DYNAMIC=y
+FW_JUMP=y
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+  # This needs to be 4MB aligned for 32-bit system
+  FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x400000)))
+else
+  # This needs to be 2MB aligned for 64-bit system
+  FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
+endif
+FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x2200000)))
+FW_PAYLOAD=y
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+  # This needs to be 4MB aligned for 32-bit system
+  FW_PAYLOAD_OFFSET=0x400000
+else
+  # This needs to be 2MB aligned for 64-bit system
+  FW_PAYLOAD_OFFSET=0x200000
+endif
+FW_PAYLOAD_FDT_ADDR=$(FW_JUMP_FDT_ADDR)
diff --git a/platform/kendryte/k210/config.mk b/platform/kendryte/k210/config.mk
deleted file mode 100644
index 8a9b814..0000000
--- a/platform/kendryte/k210/config.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2019 Western Digital Corporation or its affiliates.
-#
-# Authors:
-#   Damien Le Moal <damien.lemoal@wdc.com>
-#
-
-# Compiler flags
-platform-cppflags-y =
-platform-cflags-y =
-platform-asflags-y =
-platform-ldflags-y =
-
-# Blobs to build
-FW_TEXT_START=0x80000000
-FW_PAYLOAD=y
-FW_PAYLOAD_ALIGN=0x1000
diff --git a/platform/kendryte/k210/objects.mk b/platform/kendryte/k210/objects.mk
index b74da74..1bfb898 100644
--- a/platform/kendryte/k210/objects.mk
+++ b/platform/kendryte/k210/objects.mk
@@ -7,8 +7,20 @@
 #   Damien Le Moal <damien.lemoal@wdc.com>
 #
 
+# Compiler flags
+platform-cppflags-y =
+platform-cflags-y =
+platform-asflags-y =
+platform-ldflags-y =
+
+# Objects to build
 platform-objs-y += platform.o
 
 platform-objs-y += k210.o
 platform-varprefix-k210.o = dt_k210
 platform-padding-k210.o = 2048
+
+# Blobs to build
+FW_TEXT_START=0x80000000
+FW_PAYLOAD=y
+FW_PAYLOAD_ALIGN=0x1000
diff --git a/platform/nuclei/ux600/config.mk b/platform/nuclei/ux600/config.mk
deleted file mode 100644
index dddcc4e..0000000
--- a/platform/nuclei/ux600/config.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2020 Nuclei Corporation or its affiliates.
-#
-# Authors:
-#   lujun <lujun@nucleisys.com>
-#   hqfang <578567190@qq.com>
-#
-
-# Compiler flags
-platform-cppflags-y =
-platform-cflags-y =
-platform-asflags-y =
-platform-ldflags-y =
-
-# Command for platform specific "make run"
-platform-runcmd = xl_spike \
-  $(build_dir)/platform/nuclei/ux600/firmware/fw_payload.elf
-
-# Blobs to build
-FW_TEXT_START=0xA0000000
-FW_DYNAMIC=y
-FW_JUMP=y
-
-FW_JUMP_ADDR=0xA0200000
-FW_JUMP_FDT_ADDR=0xA8000000
-FW_PAYLOAD=y
-FW_PAYLOAD_OFFSET=0x200000
-FW_PAYLOAD_FDT_ADDR=0xA8000000
diff --git a/platform/nuclei/ux600/objects.mk b/platform/nuclei/ux600/objects.mk
index 8c36c90..7c429e0 100644
--- a/platform/nuclei/ux600/objects.mk
+++ b/platform/nuclei/ux600/objects.mk
@@ -8,4 +8,26 @@
 #   hqfang <578567190@qq.com>
 #
 
+# Compiler flags
+platform-cppflags-y =
+platform-cflags-y =
+platform-asflags-y =
+platform-ldflags-y =
+
+# Command for platform specific "make run"
+platform-runcmd = xl_spike \
+  $(build_dir)/platform/nuclei/ux600/firmware/fw_payload.elf
+
+# Objects to build
 platform-objs-y += platform.o
+
+# Blobs to build
+FW_TEXT_START=0xA0000000
+FW_DYNAMIC=y
+FW_JUMP=y
+
+FW_JUMP_ADDR=0xA0200000
+FW_JUMP_FDT_ADDR=0xA8000000
+FW_PAYLOAD=y
+FW_PAYLOAD_OFFSET=0x200000
+FW_PAYLOAD_FDT_ADDR=0xA8000000
diff --git a/platform/template/config.mk b/platform/template/config.mk
deleted file mode 100644
index f817342..0000000
--- a/platform/template/config.mk
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2019 Western Digital Corporation or its affiliates.
-#
-
-# Compiler pre-processor flags
-platform-cppflags-y =
-
-# C Compiler and assembler flags.
-platform-cflags-y =
-platform-asflags-y =
-
-# Linker flags: additional libraries and object files that the platform
-# code needs can be added here
-platform-ldflags-y =
-
-#
-# Command for platform specific "make run"
-# Useful for development and debugging on plaftform simulator (such as QEMU)
-#
-# platform-runcmd = your_platform_run.sh
-
-#
-# Platform RISC-V XLEN, ABI, ISA and Code Model configuration.
-# These are optional parameters but platforms can optionaly provide it.
-# Some of these are guessed based on GCC compiler capabilities
-#
-# PLATFORM_RISCV_XLEN = 64
-# PLATFORM_RISCV_ABI = lp64
-# PLATFORM_RISCV_ISA = rv64imafdc
-# PLATFORM_RISCV_CODE_MODEL = medany
-
-# Firmware load address configuration. This is mandatory.
-FW_TEXT_START=0x80000000
-
-# Optional parameter for path to external FDT
-# FW_FDT_PATH="path to platform flattened device tree file"
-
-#
-# Dynamic firmware configuration.
-# Optional parameters are commented out. Uncomment and define these parameters
-# as needed.
-#
-FW_DYNAMIC=<y|n>
-
-#
-# Jump firmware configuration.
-# Optional parameters are commented out. Uncomment and define these parameters
-# as needed.
-#
-FW_JUMP=<y|n>
-# This needs to be 4MB aligned for 32-bit support
-# This needs to be 2MB aligned for 64-bit support
-# ifeq ($(PLATFORM_RISCV_XLEN), 32)
-# FW_JUMP_ADDR=0x80400000
-# else
-# FW_JUMP_ADDR=0x80200000
-# endif
-# FW_JUMP_FDT_ADDR=0x82200000
-
-#
-# Firmware with payload configuration.
-# Optional parameters are commented out. Uncomment and define these parameters
-# as needed.
-#
-FW_PAYLOAD=<y|n>
-# This needs to be 4MB aligned for 32-bit support
-# This needs to be 2MB aligned for 64-bit support
-ifeq ($(PLATFORM_RISCV_XLEN), 32)
-FW_PAYLOAD_OFFSET=0x400000
-else
-FW_PAYLOAD_OFFSET=0x200000
-endif
-# FW_PAYLOAD_ALIGN=0x1000
-# FW_PAYLOAD_PATH="path to next boot stage binary image file"
-# FW_PAYLOAD_FDT_ADDR=0x82200000
diff --git a/platform/template/objects.mk b/platform/template/objects.mk
index caaec2b..0025928 100644
--- a/platform/template/objects.mk
+++ b/platform/template/objects.mk
@@ -4,6 +4,33 @@
 # Copyright (c) 2019 Western Digital Corporation or its affiliates.
 #
 
+# Compiler pre-processor flags
+platform-cppflags-y =
+
+# C Compiler and assembler flags.
+platform-cflags-y =
+platform-asflags-y =
+
+# Linker flags: additional libraries and object files that the platform
+# code needs can be added here
+platform-ldflags-y =
+
+#
+# Command for platform specific "make run"
+# Useful for development and debugging on plaftform simulator (such as QEMU)
+#
+# platform-runcmd = your_platform_run.sh
+
+#
+# Platform RISC-V XLEN, ABI, ISA and Code Model configuration.
+# These are optional parameters but platforms can optionaly provide it.
+# Some of these are guessed based on GCC compiler capabilities
+#
+# PLATFORM_RISCV_XLEN = 64
+# PLATFORM_RISCV_ABI = lp64
+# PLATFORM_RISCV_ISA = rv64imafdc
+# PLATFORM_RISCV_CODE_MODEL = medany
+
 # Space separated list of object file names to be compiled for the platform
 platform-objs-y += platform.o
 
@@ -13,3 +40,48 @@ platform-objs-y += platform.o
 # source file be in the form <dt file name>.dts
 #
 # platform-objs-y += <dt file name>.o
+
+# Firmware load address configuration. This is mandatory.
+FW_TEXT_START=0x80000000
+
+# Optional parameter for path to external FDT
+# FW_FDT_PATH="path to platform flattened device tree file"
+
+#
+# Dynamic firmware configuration.
+# Optional parameters are commented out. Uncomment and define these parameters
+# as needed.
+#
+FW_DYNAMIC=<y|n>
+
+#
+# Jump firmware configuration.
+# Optional parameters are commented out. Uncomment and define these parameters
+# as needed.
+#
+FW_JUMP=<y|n>
+# This needs to be 4MB aligned for 32-bit support
+# This needs to be 2MB aligned for 64-bit support
+# ifeq ($(PLATFORM_RISCV_XLEN), 32)
+# FW_JUMP_ADDR=0x80400000
+# else
+# FW_JUMP_ADDR=0x80200000
+# endif
+# FW_JUMP_FDT_ADDR=0x82200000
+
+#
+# Firmware with payload configuration.
+# Optional parameters are commented out. Uncomment and define these parameters
+# as needed.
+#
+FW_PAYLOAD=<y|n>
+# This needs to be 4MB aligned for 32-bit support
+# This needs to be 2MB aligned for 64-bit support
+ifeq ($(PLATFORM_RISCV_XLEN), 32)
+FW_PAYLOAD_OFFSET=0x400000
+else
+FW_PAYLOAD_OFFSET=0x200000
+endif
+# FW_PAYLOAD_ALIGN=0x1000
+# FW_PAYLOAD_PATH="path to next boot stage binary image file"
+# FW_PAYLOAD_FDT_ADDR=0x82200000
diff --git a/platform/template/platform.c b/platform/template/platform.c
index 5524847..f3802da 100644
--- a/platform/template/platform.c
+++ b/platform/template/platform.c
@@ -11,7 +11,7 @@
 
 /*
  * Include these files as needed.
- * See config.mk PLATFORM_xxx configuration parameters.
+ * See objects.mk PLATFORM_xxx configuration parameters.
  */
 #include <sbi_utils/ipi/aclint_mswi.h>
 #include <sbi_utils/irqchip/plic.h>
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 14/14] docs: Update documentation for kconfig support
  2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
                   ` (12 preceding siblings ...)
  2022-07-18 12:42 ` [PATCH 13/14] platform: Remove redundant config.mk from all platforms Anup Patel
@ 2022-07-18 12:42 ` Anup Patel
  13 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 12:42 UTC (permalink / raw)
  To: opensbi

We update all documentation files to:
1) Remove references to platform specific config.mk file since it is
   has been removed.
2) Add details about platform specific configs/defconfig and Kconfig
   files mandatory for each platform.
3) Add required packages in top-level README.md

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 README.md                   | 25 +++++++++++++++++++++++--
 docs/firmware/fw_dynamic.md |  2 +-
 docs/firmware/fw_jump.md    |  4 ++--
 docs/firmware/fw_payload.md |  4 ++--
 docs/platform/platform.md   |  4 ++--
 docs/platform_guide.md      |  9 +++++----
 6 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index 54fabe4..cd852cb 100644
--- a/README.md
+++ b/README.md
@@ -92,8 +92,8 @@ N.B. Any S-mode boot loader (i.e. U-Boot) doesn't need to support HSM extension,
 as it doesn't need to boot all the harts. The operating system should be
 capable enough to bring up all other non-booting harts using HSM extension.
 
-Required Toolchain
-------------------
+Required Toolchain and Packages
+-------------------------------
 
 OpenSBI can be compiled natively or cross-compiled on a x86 host. For
 cross-compilation, you can build your own toolchain, download a prebuilt one
@@ -115,6 +115,14 @@ triple is used (e.g. *-target riscv64-unknown-elf*).
 Please note that only a 64-bit version of the toolchain is available in
 the Bootlin toolchain repository for now.
 
+In addition to a toolchain, OpenSBI also requires following packages on
+the host:
+
+1. device-tree-compiler: The device tree compiler for compiling device
+   tree sources (DTS files).
+2. kconfig-frontends: A standalone implementation of the Linux Kconfig
+   parser and frontends for OpenSBI platform configuration management.
+
 Building and Installing the OpenSBI Platform-Independent Library
 ----------------------------------------------------------------
 
@@ -196,6 +204,19 @@ top-level make command line. These options, such as *PLATFORM_<xyz>* or
 *docs/platform/<platform_name>.md* files and
 *docs/firmware/<firmware_name>.md* files.
 
+All OpenSBI platforms support Kconfig style build-time configuration. Users
+can change the build-time configuration of a platform using a graphical
+interface as follows:
+```
+make PLATFORM=<platform_subdir> menuconfig
+```
+
+Alternately, an OpenSBI platform can have multiple default configurations
+and users can select a custom default configuration as follows:
+```
+make PLATFORM=<platform_subdir> PLATFORM_DEFCONFIG=<platform_custom_defconfig>
+```
+
 Building 32-bit / 64-bit OpenSBI Images
 ---------------------------------------
 By default, building OpenSBI generates 32-bit or 64-bit images based on the
diff --git a/docs/firmware/fw_dynamic.md b/docs/firmware/fw_dynamic.md
index 7b9b192..e251488 100644
--- a/docs/firmware/fw_dynamic.md
+++ b/docs/firmware/fw_dynamic.md
@@ -20,7 +20,7 @@ the booting stage binary to follow OpenSBI firmware.
 A platform can enable *FW_DYNAMIC* firmware using any of the following methods.
 
 1. Specifying `FW_DYNAMIC=y` on the top level `make` command line.
-2. Specifying `FW_DYNAMIC=y` in the target platform *config.mk* configuration
+2. Specifying `FW_DYNAMIC=y` in the target platform *objects.mk* configuration
 file.
 
 The compiled *FW_DYNAMIC* firmware ELF file is named *fw_dynamic.elf*. It's
diff --git a/docs/firmware/fw_jump.md b/docs/firmware/fw_jump.md
index eea3013..35a4301 100644
--- a/docs/firmware/fw_jump.md
+++ b/docs/firmware/fw_jump.md
@@ -15,7 +15,7 @@ and the booting stage binary to follow the OpenSBI firmware.
 A platform *FW_JUMP* firmware can be enabled by any of the following methods:
 
 1. Specifying `FW_JUMP=y` on the top level `make` command line.
-2. Specifying `FW_JUMP=y` in the target platform *config.mk* configuration file.
+2. Specifying `FW_JUMP=y` in the target platform *objects.mk* configuration file.
 
 The compiled *FW_JUMP* firmware ELF file is named *fw_jump.elf*. Its expanded
 image file is *fw_jump.bin*. Both files are created in the platform-specific
@@ -26,7 +26,7 @@ build directory under the *build/platform/<platform_subdir>/firmware* directory.
 
 To operate correctly, a *FW_JUMP* firmware requires some configuration
 parameters to be defined using either the top level `make` command line or the
-target platform *config.mk* configuration file. The possible parameters are as
+target platform *objects.mk* configuration file. The possible parameters are as
 follows:
 
 * **FW_JUMP_ADDR** - Address of the entry point of the booting stage to be
diff --git a/docs/firmware/fw_payload.md b/docs/firmware/fw_payload.md
index 0947448..3bb918f 100644
--- a/docs/firmware/fw_payload.md
+++ b/docs/firmware/fw_payload.md
@@ -20,7 +20,7 @@ Enabling *FW_PAYLOAD* compilation
 The *FW_PAYLOAD* firmware can be enabled by any of the following methods:
 
 1. Specifying `FW_PAYLOAD=y` on the top level `make` command line.
-2. Specifying `FW_PAYLOAD=y` in the target platform *config.mk* configuration
+2. Specifying `FW_PAYLOAD=y` in the target platform *objects.mk* configuration
    file.
 
 The compiled *FW_PAYLOAD* firmware ELF file is named *fw_jump.elf*. Its
@@ -33,7 +33,7 @@ Configuration Options
 
 A *FW_PAYLOAD* firmware is built according to configuration parameters and
 options. These configuration parameters can be defined using either the top
-level `make` command line or the target platform *config.mk* configuration
+level `make` command line or the target platform *objects.mk* configuration
 file. The parameters currently defined are as follows:
 
 * **FW_PAYLOAD_OFFSET** - Offset from *FW_TEXT_BASE* where the payload binary
diff --git a/docs/platform/platform.md b/docs/platform/platform.md
index cb4bec6..b726e1d 100644
--- a/docs/platform/platform.md
+++ b/docs/platform/platform.md
@@ -42,8 +42,8 @@ OpenSBI currently supports the following virtual and hardware platforms:
 The code for these supported platforms can be used as example to implement
 support for other platforms. The *platform/template* directory also provides
 template files for implementing support for a new platform. The *object.mk*,
-*config.mk* and *platform.c* template files provides enough comments to
-facilitate the implementation.
+*Kconfig*, *configs/defconfig* and *platform.c* template files provides enough
+comments to facilitate the implementation.
 
 [generic.md]: generic.md
 [qemu_virt.md]: qemu_virt.md
diff --git a/docs/platform_guide.md b/docs/platform_guide.md
index b6c2c2e..8ac5aa0 100644
--- a/docs/platform_guide.md
+++ b/docs/platform_guide.md
@@ -28,11 +28,12 @@ Adding support for a new platform
 Support for a new platform named *&lt;xyz&gt;* can be added as follows:
 
 1. Create a directory named *&lt;xyz&gt;* under the *platform/* directory.
-2. Create a platform configuration file named *config.mk* under the
-   *platform/&lt;xyz&gt;/* directory. This configuration file will provide
+2. Create a platform configuration files named *Kconfig* and *configs/defconfig*
+   under the *platform/&lt;xyz&gt;/* directory. This configuration files will
+   provide the build time configuration for the sources to be compiled.
+3. Create a *platform/&lt;xyz&gt;/objects.mk* file for listing the platform
+   object files to be compiled. This file also provides platform-specific
    compiler flags, and select firmware options.
-3. Create a *platform/&lt;xyz&gt;/objects.mk* file for listing the
-   platform-specific object files to be compiled.
 4. Create a *platform/&lt;xyz&gt;/platform.c* file providing a
    *struct sbi_platform* instance.
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 01/14] Makefile: Add initial kconfig support for each platform
  2022-07-18 12:41 ` [PATCH 01/14] Makefile: Add initial kconfig support for each platform Anup Patel
@ 2022-07-18 13:51   ` Jessica Clarke
  2022-07-18 14:44     ` Anup Patel
  0 siblings, 1 reply; 17+ messages in thread
From: Jessica Clarke @ 2022-07-18 13:51 UTC (permalink / raw)
  To: opensbi

On 18 Jul 2022, at 13:41, Anup Patel <apatel@ventanamicro.com> wrote:
> 
> We extend the top-level makefile to allow kconfig based configuration
> for each platform where each platform has it's own set of configs with
> "defconfig" being the default config.
> 
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> Kconfig                                   | 23 ++++++++++
> Makefile                                  | 54 +++++++++++++++++++++--
> firmware/Kconfig                          |  1 +
> lib/utils/Kconfig                         |  1 +
> platform/andes/ae350/Kconfig              |  5 +++
> platform/andes/ae350/configs/defconfig    |  0
> platform/fpga/ariane/Kconfig              |  5 +++
> platform/fpga/ariane/configs/defconfig    |  0
> platform/fpga/openpiton/Kconfig           |  5 +++
> platform/fpga/openpiton/configs/defconfig |  0
> platform/generic/Kconfig                  |  5 +++
> platform/generic/configs/defconfig        |  0
> platform/kendryte/k210/Kconfig            |  5 +++
> platform/kendryte/k210/configs/defconfig  |  0
> platform/nuclei/ux600/Kconfig             |  5 +++
> platform/nuclei/ux600/configs/defconfig   |  0
> platform/template/Kconfig                 |  5 +++
> platform/template/configs/defconfig       |  0
> 18 files changed, 111 insertions(+), 3 deletions(-)
> create mode 100644 Kconfig
> create mode 100644 firmware/Kconfig
> create mode 100644 lib/utils/Kconfig
> create mode 100644 platform/andes/ae350/Kconfig
> create mode 100644 platform/andes/ae350/configs/defconfig
> create mode 100644 platform/fpga/ariane/Kconfig
> create mode 100644 platform/fpga/ariane/configs/defconfig
> create mode 100644 platform/fpga/openpiton/Kconfig
> create mode 100644 platform/fpga/openpiton/configs/defconfig
> create mode 100644 platform/generic/Kconfig
> create mode 100644 platform/generic/configs/defconfig
> create mode 100644 platform/kendryte/k210/Kconfig
> create mode 100644 platform/kendryte/k210/configs/defconfig
> create mode 100644 platform/nuclei/ux600/Kconfig
> create mode 100644 platform/nuclei/ux600/configs/defconfig
> create mode 100644 platform/template/Kconfig
> create mode 100644 platform/template/configs/defconfig
> 
> diff --git a/Kconfig b/Kconfig
> new file mode 100644
> index 0000000..b8615d2
> --- /dev/null
> +++ b/Kconfig
> @@ -0,0 +1,23 @@
> +# SPDX-License-Identifier: GPL-2.0

GPL in OpenSBI? I suspect you blindly copied this boilerplate from
Linux (and repeated it everywhere)?..

Jess

> +mainmenu "OpenSBI $OPENSBI_PLATFORM Configuration"
> +
> +config OPENSBI_SRC_DIR
> +	string
> +	option env="OPENSBI_SRC_DIR"
> +
> +config OPENSBI_PLATFORM
> +	string
> +	option env="OPENSBI_PLATFORM"
> +
> +config OPENSBI_PLATFORM_SRC_DIR
> +	string
> +	option env="OPENSBI_PLATFORM_SRC_DIR"
> +
> +menu "Platform Options"
> +source "$OPENSBI_PLATFORM_SRC_DIR/Kconfig"
> +endmenu
> +
> +source "$OPENSBI_SRC_DIR/lib/utils/Kconfig"
> +
> +source "$OPENSBI_SRC_DIR/firmware/Kconfig"
> diff --git a/Makefile b/Makefile
> index f619ef7..46c7c1c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -52,6 +52,9 @@ ifdef PLATFORM_DIR
> else
>  platform_parent_dir=$(src_dir)/platform
> endif
> +ifndef PLATFORM_DEFCONFIG
> +PLATFORM_DEFCONFIG=defconfig
> +endif
> 
> # Check if verbosity is ON for build process
> CMD_PREFIX_DEFAULT := @
> @@ -70,6 +73,19 @@ export libsbi_dir=$(CURDIR)/lib/sbi
> export libsbiutils_dir=$(CURDIR)/lib/utils
> export firmware_dir=$(CURDIR)/firmware
> 
> +# Setup variables for kconfig-frontends
> +ifdef PLATFORM
> +export KCONFIG_CONFIG=$(platform_build_dir)/.config
> +export KCONFIG_AUTOCONFIG=$(platform_build_dir)/auto.conf
> +export KCONFIG_TRISTATE=$(platform_build_dir)/tristate.conf
> +export KCONFIG_AUTOHEADER=$(platform_build_dir)/autoconf.h
> +export KCONFIG_AUTOCONF_CMD=$(platform_build_dir)/include/config/auto.conf.cmd
> +# Additional exports for include paths in Kconfig files
> +export OPENSBI_SRC_DIR=$(src_dir)
> +export OPENSBI_PLATFORM=$(PLATFORM)
> +export OPENSBI_PLATFORM_SRC_DIR=$(platform_src_dir)
> +endif
> +
> # Find library version
> OPENSBI_VERSION_MAJOR=`grep "define OPENSBI_VERSION_MAJOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'`
> OPENSBI_VERSION_MINOR=`grep "define OPENSBI_VERSION_MINOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'`
> @@ -183,8 +199,34 @@ libsbi-object-mks=$(shell if [ -d $(libsbi_dir) ]; then find $(libsbi_dir) -inam
> libsbiutils-object-mks=$(shell if [ -d $(libsbiutils_dir) ]; then find $(libsbiutils_dir) -iname "objects.mk" | sort -r; fi)
> firmware-object-mks=$(shell if [ -d $(firmware_dir) ]; then find $(firmware_dir) -iname "objects.mk" | sort -r; fi)
> 
> -# Include platform specifig config.mk
> +# The "make all" rule should always be first rule
> +.PHONY: all
> +all:
> +
> +# Include platform specific .config and config.mk
> ifdef PLATFORM
> +.PHONY: menuconfig
> +menuconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
> +	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
> +	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
> +	$(CMD_PREFIX)kconfig-mconf $(src_dir)/Kconfig
> +	$(CMD_PREFIX)cd $(platform_build_dir) && kconfig-conf --silentoldconfig $(src_dir)/Kconfig
> +
> +.PHONY: savedefconfig
> +savedefconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
> +	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
> +	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
> +	$(CMD_PREFIX)kconfig-conf --savedefconfig `dirname $(KCONFIG_CONFIG)`/defconfig $(src_dir)/Kconfig
> +
> +$(KCONFIG_CONFIG): $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
> +	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
> +	$(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
> +	$(CMD_PREFIX)cp -f $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(KCONFIG_CONFIG)
> +	$(CMD_PREFIX)cd $(platform_build_dir) && kconfig-conf --silentoldconfig --olddefconfig $(src_dir)/Kconfig
> +$(KCONFIG_AUTOCONF_CMD): $(KCONFIG_CONFIG)
> +include $(KCONFIG_CONFIG)
> +include $(KCONFIG_AUTOCONF_CMD)
> +
> include $(platform_src_dir)/config.mk
> endif
> 
> @@ -280,6 +322,9 @@ ifeq ($(BUILD_INFO),y)
> GENFLAGS	+=	-DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\""
> GENFLAGS	+=	-DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\""
> endif
> +ifdef PLATFORM
> +GENFLAGS	+=	-include $(KCONFIG_AUTOHEADER)
> +endif
> GENFLAGS	+=	$(libsbiutils-genflags-y)
> GENFLAGS	+=	$(platform-genflags-y)
> GENFLAGS	+=	$(firmware-genflags-y)
> @@ -419,7 +464,7 @@ targets-y += $(platform_build_dir)/lib/libplatsbi.a
> endif
> targets-y += $(firmware-bins-path-y)
> 
> -# Default rule "make" should always be first rule
> +# The default "make all" rule
> .PHONY: all
> all: $(targets-y)
> 
> @@ -456,7 +501,7 @@ $(build_dir)/%.o: $(src_dir)/%.S
> 	$(call compile_as,$@,$<)
> 
> $(build_dir)/%.dep: $(src_dir)/%.carray
> -	$(call compile_gen_dep,$@,.c,$<)
> +	$(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG))
> 	$(call compile_gen_dep,$@,.o,$(@:.dep=.c))
> 
> $(build_dir)/%.c: $(src_dir)/%.carray
> @@ -523,6 +568,9 @@ docs: $(build_dir)/docs/latex/refman.pdf
> # They should not be included for any "xxxconfig" or "xxxclean" rule
> all-deps-1 = $(if $(findstring config,$(MAKECMDGOALS)),,$(deps-y))
> all-deps-2 = $(if $(findstring clean,$(MAKECMDGOALS)),,$(all-deps-1))
> +ifdef PLATFORM
> +$(all-deps-2): | $(KCONFIG_CONFIG)
> +endif
> -include $(all-deps-2)
> 
> # Include external dependency of firmwares after default Makefile rules
> diff --git a/firmware/Kconfig b/firmware/Kconfig
> new file mode 100644
> index 0000000..f66554c
> --- /dev/null
> +++ b/firmware/Kconfig
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0
> diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
> new file mode 100644
> index 0000000..f66554c
> --- /dev/null
> +++ b/lib/utils/Kconfig
> @@ -0,0 +1 @@
> +# SPDX-License-Identifier: GPL-2.0
> diff --git a/platform/andes/ae350/Kconfig b/platform/andes/ae350/Kconfig
> new file mode 100644
> index 0000000..349c1d3
> --- /dev/null
> +++ b/platform/andes/ae350/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_ANDES_AE350
> +	bool
> +	default y
> diff --git a/platform/andes/ae350/configs/defconfig b/platform/andes/ae350/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
> new file mode 100644
> index 0000000..26f9beb
> --- /dev/null
> +++ b/platform/fpga/ariane/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_ARIANE_FPGA
> +	bool
> +	default y
> diff --git a/platform/fpga/ariane/configs/defconfig b/platform/fpga/ariane/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
> new file mode 100644
> index 0000000..8bfa85a
> --- /dev/null
> +++ b/platform/fpga/openpiton/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_OPENPITON_FPGA
> +	bool
> +	default y
> diff --git a/platform/fpga/openpiton/configs/defconfig b/platform/fpga/openpiton/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
> new file mode 100644
> index 0000000..a811a05
> --- /dev/null
> +++ b/platform/generic/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_GENERIC
> +	bool
> +	default y
> diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
> new file mode 100644
> index 0000000..726423a
> --- /dev/null
> +++ b/platform/kendryte/k210/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_KENDRYTE_K210
> +	bool
> +	default y
> diff --git a/platform/kendryte/k210/configs/defconfig b/platform/kendryte/k210/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
> new file mode 100644
> index 0000000..bb8410f
> --- /dev/null
> +++ b/platform/nuclei/ux600/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_NUCLEI_UX600
> +	bool
> +	default y
> diff --git a/platform/nuclei/ux600/configs/defconfig b/platform/nuclei/ux600/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> diff --git a/platform/template/Kconfig b/platform/template/Kconfig
> new file mode 100644
> index 0000000..bd95ea0
> --- /dev/null
> +++ b/platform/template/Kconfig
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config PLATFORM_TEMPLATE
> +	bool
> +	default y
> diff --git a/platform/template/configs/defconfig b/platform/template/configs/defconfig
> new file mode 100644
> index 0000000..e69de29
> -- 
> 2.34.1
> 
> 
> -- 
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 01/14] Makefile: Add initial kconfig support for each platform
  2022-07-18 13:51   ` Jessica Clarke
@ 2022-07-18 14:44     ` Anup Patel
  0 siblings, 0 replies; 17+ messages in thread
From: Anup Patel @ 2022-07-18 14:44 UTC (permalink / raw)
  To: opensbi

On Mon, Jul 18, 2022 at 7:21 PM Jessica Clarke <jrtc27@jrtc27.com> wrote:
>
> On 18 Jul 2022, at 13:41, Anup Patel <apatel@ventanamicro.com> wrote:
> >
> > We extend the top-level makefile to allow kconfig based configuration
> > for each platform where each platform has it's own set of configs with
> > "defconfig" being the default config.
> >
> > Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> > ---
> > Kconfig                                   | 23 ++++++++++
> > Makefile                                  | 54 +++++++++++++++++++++--
> > firmware/Kconfig                          |  1 +
> > lib/utils/Kconfig                         |  1 +
> > platform/andes/ae350/Kconfig              |  5 +++
> > platform/andes/ae350/configs/defconfig    |  0
> > platform/fpga/ariane/Kconfig              |  5 +++
> > platform/fpga/ariane/configs/defconfig    |  0
> > platform/fpga/openpiton/Kconfig           |  5 +++
> > platform/fpga/openpiton/configs/defconfig |  0
> > platform/generic/Kconfig                  |  5 +++
> > platform/generic/configs/defconfig        |  0
> > platform/kendryte/k210/Kconfig            |  5 +++
> > platform/kendryte/k210/configs/defconfig  |  0
> > platform/nuclei/ux600/Kconfig             |  5 +++
> > platform/nuclei/ux600/configs/defconfig   |  0
> > platform/template/Kconfig                 |  5 +++
> > platform/template/configs/defconfig       |  0
> > 18 files changed, 111 insertions(+), 3 deletions(-)
> > create mode 100644 Kconfig
> > create mode 100644 firmware/Kconfig
> > create mode 100644 lib/utils/Kconfig
> > create mode 100644 platform/andes/ae350/Kconfig
> > create mode 100644 platform/andes/ae350/configs/defconfig
> > create mode 100644 platform/fpga/ariane/Kconfig
> > create mode 100644 platform/fpga/ariane/configs/defconfig
> > create mode 100644 platform/fpga/openpiton/Kconfig
> > create mode 100644 platform/fpga/openpiton/configs/defconfig
> > create mode 100644 platform/generic/Kconfig
> > create mode 100644 platform/generic/configs/defconfig
> > create mode 100644 platform/kendryte/k210/Kconfig
> > create mode 100644 platform/kendryte/k210/configs/defconfig
> > create mode 100644 platform/nuclei/ux600/Kconfig
> > create mode 100644 platform/nuclei/ux600/configs/defconfig
> > create mode 100644 platform/template/Kconfig
> > create mode 100644 platform/template/configs/defconfig
> >
> > diff --git a/Kconfig b/Kconfig
> > new file mode 100644
> > index 0000000..b8615d2
> > --- /dev/null
> > +++ b/Kconfig
> > @@ -0,0 +1,23 @@
> > +# SPDX-License-Identifier: GPL-2.0
>
> GPL in OpenSBI? I suspect you blindly copied this boilerplate from
> Linux (and repeated it everywhere)?..

Aargh !!! This was totally unintentional.

Thanks for catching. I will quickly send a v2.

Regards,
Anup

>
> Jess
>
> > +mainmenu "OpenSBI $OPENSBI_PLATFORM Configuration"
> > +
> > +config OPENSBI_SRC_DIR
> > +     string
> > +     option env="OPENSBI_SRC_DIR"
> > +
> > +config OPENSBI_PLATFORM
> > +     string
> > +     option env="OPENSBI_PLATFORM"
> > +
> > +config OPENSBI_PLATFORM_SRC_DIR
> > +     string
> > +     option env="OPENSBI_PLATFORM_SRC_DIR"
> > +
> > +menu "Platform Options"
> > +source "$OPENSBI_PLATFORM_SRC_DIR/Kconfig"
> > +endmenu
> > +
> > +source "$OPENSBI_SRC_DIR/lib/utils/Kconfig"
> > +
> > +source "$OPENSBI_SRC_DIR/firmware/Kconfig"
> > diff --git a/Makefile b/Makefile
> > index f619ef7..46c7c1c 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -52,6 +52,9 @@ ifdef PLATFORM_DIR
> > else
> >  platform_parent_dir=$(src_dir)/platform
> > endif
> > +ifndef PLATFORM_DEFCONFIG
> > +PLATFORM_DEFCONFIG=defconfig
> > +endif
> >
> > # Check if verbosity is ON for build process
> > CMD_PREFIX_DEFAULT := @
> > @@ -70,6 +73,19 @@ export libsbi_dir=$(CURDIR)/lib/sbi
> > export libsbiutils_dir=$(CURDIR)/lib/utils
> > export firmware_dir=$(CURDIR)/firmware
> >
> > +# Setup variables for kconfig-frontends
> > +ifdef PLATFORM
> > +export KCONFIG_CONFIG=$(platform_build_dir)/.config
> > +export KCONFIG_AUTOCONFIG=$(platform_build_dir)/auto.conf
> > +export KCONFIG_TRISTATE=$(platform_build_dir)/tristate.conf
> > +export KCONFIG_AUTOHEADER=$(platform_build_dir)/autoconf.h
> > +export KCONFIG_AUTOCONF_CMD=$(platform_build_dir)/include/config/auto.conf.cmd
> > +# Additional exports for include paths in Kconfig files
> > +export OPENSBI_SRC_DIR=$(src_dir)
> > +export OPENSBI_PLATFORM=$(PLATFORM)
> > +export OPENSBI_PLATFORM_SRC_DIR=$(platform_src_dir)
> > +endif
> > +
> > # Find library version
> > OPENSBI_VERSION_MAJOR=`grep "define OPENSBI_VERSION_MAJOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MAJOR.*\([0-9][0-9]*\)/\1/'`
> > OPENSBI_VERSION_MINOR=`grep "define OPENSBI_VERSION_MINOR" $(include_dir)/sbi/sbi_version.h | sed 's/.*MINOR.*\([0-9][0-9]*\)/\1/'`
> > @@ -183,8 +199,34 @@ libsbi-object-mks=$(shell if [ -d $(libsbi_dir) ]; then find $(libsbi_dir) -inam
> > libsbiutils-object-mks=$(shell if [ -d $(libsbiutils_dir) ]; then find $(libsbiutils_dir) -iname "objects.mk" | sort -r; fi)
> > firmware-object-mks=$(shell if [ -d $(firmware_dir) ]; then find $(firmware_dir) -iname "objects.mk" | sort -r; fi)
> >
> > -# Include platform specifig config.mk
> > +# The "make all" rule should always be first rule
> > +.PHONY: all
> > +all:
> > +
> > +# Include platform specific .config and config.mk
> > ifdef PLATFORM
> > +.PHONY: menuconfig
> > +menuconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
> > +     $(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
> > +     $(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
> > +     $(CMD_PREFIX)kconfig-mconf $(src_dir)/Kconfig
> > +     $(CMD_PREFIX)cd $(platform_build_dir) && kconfig-conf --silentoldconfig $(src_dir)/Kconfig
> > +
> > +.PHONY: savedefconfig
> > +savedefconfig: $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
> > +     $(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
> > +     $(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
> > +     $(CMD_PREFIX)kconfig-conf --savedefconfig `dirname $(KCONFIG_CONFIG)`/defconfig $(src_dir)/Kconfig
> > +
> > +$(KCONFIG_CONFIG): $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(platform_src_dir)/Kconfig $(src_dir)/Kconfig
> > +     $(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_CONFIG)`
> > +     $(CMD_PREFIX)mkdir -p `dirname $(KCONFIG_AUTOCONF_CMD)`
> > +     $(CMD_PREFIX)cp -f $(platform_src_dir)/configs/$(PLATFORM_DEFCONFIG) $(KCONFIG_CONFIG)
> > +     $(CMD_PREFIX)cd $(platform_build_dir) && kconfig-conf --silentoldconfig --olddefconfig $(src_dir)/Kconfig
> > +$(KCONFIG_AUTOCONF_CMD): $(KCONFIG_CONFIG)
> > +include $(KCONFIG_CONFIG)
> > +include $(KCONFIG_AUTOCONF_CMD)
> > +
> > include $(platform_src_dir)/config.mk
> > endif
> >
> > @@ -280,6 +322,9 @@ ifeq ($(BUILD_INFO),y)
> > GENFLAGS      +=      -DOPENSBI_BUILD_TIME_STAMP="\"$(OPENSBI_BUILD_TIME_STAMP)\""
> > GENFLAGS      +=      -DOPENSBI_BUILD_COMPILER_VERSION="\"$(OPENSBI_BUILD_COMPILER_VERSION)\""
> > endif
> > +ifdef PLATFORM
> > +GENFLAGS     +=      -include $(KCONFIG_AUTOHEADER)
> > +endif
> > GENFLAGS      +=      $(libsbiutils-genflags-y)
> > GENFLAGS      +=      $(platform-genflags-y)
> > GENFLAGS      +=      $(firmware-genflags-y)
> > @@ -419,7 +464,7 @@ targets-y += $(platform_build_dir)/lib/libplatsbi.a
> > endif
> > targets-y += $(firmware-bins-path-y)
> >
> > -# Default rule "make" should always be first rule
> > +# The default "make all" rule
> > .PHONY: all
> > all: $(targets-y)
> >
> > @@ -456,7 +501,7 @@ $(build_dir)/%.o: $(src_dir)/%.S
> >       $(call compile_as,$@,$<)
> >
> > $(build_dir)/%.dep: $(src_dir)/%.carray
> > -     $(call compile_gen_dep,$@,.c,$<)
> > +     $(call compile_gen_dep,$@,.c,$< $(KCONFIG_CONFIG))
> >       $(call compile_gen_dep,$@,.o,$(@:.dep=.c))
> >
> > $(build_dir)/%.c: $(src_dir)/%.carray
> > @@ -523,6 +568,9 @@ docs: $(build_dir)/docs/latex/refman.pdf
> > # They should not be included for any "xxxconfig" or "xxxclean" rule
> > all-deps-1 = $(if $(findstring config,$(MAKECMDGOALS)),,$(deps-y))
> > all-deps-2 = $(if $(findstring clean,$(MAKECMDGOALS)),,$(all-deps-1))
> > +ifdef PLATFORM
> > +$(all-deps-2): | $(KCONFIG_CONFIG)
> > +endif
> > -include $(all-deps-2)
> >
> > # Include external dependency of firmwares after default Makefile rules
> > diff --git a/firmware/Kconfig b/firmware/Kconfig
> > new file mode 100644
> > index 0000000..f66554c
> > --- /dev/null
> > +++ b/firmware/Kconfig
> > @@ -0,0 +1 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > diff --git a/lib/utils/Kconfig b/lib/utils/Kconfig
> > new file mode 100644
> > index 0000000..f66554c
> > --- /dev/null
> > +++ b/lib/utils/Kconfig
> > @@ -0,0 +1 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > diff --git a/platform/andes/ae350/Kconfig b/platform/andes/ae350/Kconfig
> > new file mode 100644
> > index 0000000..349c1d3
> > --- /dev/null
> > +++ b/platform/andes/ae350/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_ANDES_AE350
> > +     bool
> > +     default y
> > diff --git a/platform/andes/ae350/configs/defconfig b/platform/andes/ae350/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/platform/fpga/ariane/Kconfig b/platform/fpga/ariane/Kconfig
> > new file mode 100644
> > index 0000000..26f9beb
> > --- /dev/null
> > +++ b/platform/fpga/ariane/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_ARIANE_FPGA
> > +     bool
> > +     default y
> > diff --git a/platform/fpga/ariane/configs/defconfig b/platform/fpga/ariane/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/platform/fpga/openpiton/Kconfig b/platform/fpga/openpiton/Kconfig
> > new file mode 100644
> > index 0000000..8bfa85a
> > --- /dev/null
> > +++ b/platform/fpga/openpiton/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_OPENPITON_FPGA
> > +     bool
> > +     default y
> > diff --git a/platform/fpga/openpiton/configs/defconfig b/platform/fpga/openpiton/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig
> > new file mode 100644
> > index 0000000..a811a05
> > --- /dev/null
> > +++ b/platform/generic/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_GENERIC
> > +     bool
> > +     default y
> > diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/platform/kendryte/k210/Kconfig b/platform/kendryte/k210/Kconfig
> > new file mode 100644
> > index 0000000..726423a
> > --- /dev/null
> > +++ b/platform/kendryte/k210/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_KENDRYTE_K210
> > +     bool
> > +     default y
> > diff --git a/platform/kendryte/k210/configs/defconfig b/platform/kendryte/k210/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/platform/nuclei/ux600/Kconfig b/platform/nuclei/ux600/Kconfig
> > new file mode 100644
> > index 0000000..bb8410f
> > --- /dev/null
> > +++ b/platform/nuclei/ux600/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_NUCLEI_UX600
> > +     bool
> > +     default y
> > diff --git a/platform/nuclei/ux600/configs/defconfig b/platform/nuclei/ux600/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > diff --git a/platform/template/Kconfig b/platform/template/Kconfig
> > new file mode 100644
> > index 0000000..bd95ea0
> > --- /dev/null
> > +++ b/platform/template/Kconfig
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +config PLATFORM_TEMPLATE
> > +     bool
> > +     default y
> > diff --git a/platform/template/configs/defconfig b/platform/template/configs/defconfig
> > new file mode 100644
> > index 0000000..e69de29
> > --
> > 2.34.1
> >
> >
> > --
> > opensbi mailing list
> > opensbi at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi
>


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-07-18 14:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18 12:41 [PATCH 00/14] OpenSBI Kconfig Support Anup Patel
2022-07-18 12:41 ` [PATCH 01/14] Makefile: Add initial kconfig support for each platform Anup Patel
2022-07-18 13:51   ` Jessica Clarke
2022-07-18 14:44     ` Anup Patel
2022-07-18 12:41 ` [PATCH 02/14] Makefile: Compile lib/utils sources separately " Anup Patel
2022-07-18 12:41 ` [PATCH 03/14] lib: utils/serial: Use kconfig for enabling/disabling drivers Anup Patel
2022-07-18 12:42 ` [PATCH 04/14] lib: utils/reset: " Anup Patel
2022-07-18 12:42 ` [PATCH 05/14] lib: utils/sys: " Anup Patel
2022-07-18 12:42 ` [PATCH 06/14] lib: utils/timer: " Anup Patel
2022-07-18 12:42 ` [PATCH 07/14] lib: utils/ipi: " Anup Patel
2022-07-18 12:42 ` [PATCH 08/14] lib: utils/irqchip: " Anup Patel
2022-07-18 12:42 ` [PATCH 09/14] lib: utils/i2c: " Anup Patel
2022-07-18 12:42 ` [PATCH 10/14] lib: utils/gpio: " Anup Patel
2022-07-18 12:42 ` [PATCH 11/14] lib: utils/fdt: Use kconfig for enabling/disabling Anup Patel
2022-07-18 12:42 ` [PATCH 12/14] platform: generic: Use kconfig for enabling/disabling overrides Anup Patel
2022-07-18 12:42 ` [PATCH 13/14] platform: Remove redundant config.mk from all platforms Anup Patel
2022-07-18 12:42 ` [PATCH 14/14] docs: Update documentation for kconfig support Anup Patel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.