From 71664d7c990f09591f827f8ced5364fb81289bea Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Mon, 15 Aug 2022 22:27:12 -0700 Subject: [PATCH] tegra: hwpm: redo hwpm driver as OOT Make HWPM driver as loadable kernel module. Separate common, linux and t234 specific files into separate objects. This will allow hwpm common files to be included in other projects. Jira THWPM-41 Bug 3583624 Change-Id: Ia7472122c71520076a1516c8e386cfe79862dd61 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2683488 Reviewed-by: svc-mobile-coverity Reviewed-by: Vasuki Shankar Reviewed-by: Seema Khowala GVS: Gerrit_Virtual_Submit --- Makefile | 160 ++++++---------------------------------- Makefile.common.sources | 11 +++ Makefile.linux.sources | 21 ++++++ Makefile.t234.sources | 114 ++++++++++++++++++++++++++++ common/init.c | 2 +- os/linux/driver.c | 2 +- 6 files changed, 171 insertions(+), 139 deletions(-) create mode 100644 Makefile.common.sources create mode 100644 Makefile.linux.sources create mode 100644 Makefile.t234.sources diff --git a/Makefile b/Makefile index aef8dbe..84376f3 100644 --- a/Makefile +++ b/Makefile @@ -2,149 +2,35 @@ # Tegra SOC HWPM # +# SPDX-License-Identifier: GPL-2.0 GCOV_PROFILE := y -ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm -ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm/include ccflags-y += -I$(srctree.nvidia)/include +ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm/include +ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm -obj-$(CONFIG_DEBUG_FS) += os/linux/debugfs.o -obj-y += os/linux/aperture_utils.o -obj-y += os/linux/driver.o -obj-y += os/linux/io_utils.o -obj-y += os/linux/ip_utils.o -obj-y += os/linux/ioctl.o -obj-y += os/linux/kmem.o -obj-y += os/linux/log.o -obj-y += os/linux/timers.o -obj-y += os/linux/mem_mgmt_utils.o -obj-y += os/linux/regops_utils.o -obj-y += os/linux/soc_utils.o +# For OOT builds, set required config flags +ifeq ($(CONFIG_TEGRA_OOT_MODULE),m) +CONFIG_TEGRA_T234_HWPM = y +ccflags-y += -DCONFIG_TEGRA_T234_HWPM +NVHWPM_OBJ = m +else +NVHWPM_OBJ = y +endif -obj-y += common/allowlist.o -obj-y += common/aperture.o -obj-y += common/ip.o -obj-y += common/resource.o -obj-y += common/init.o +# Add required objects to nvhwpm object variable +# Include common files +include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.common.sources +nvhwpm-objs += ${nvhwpm-common-objs} + +# Include linux files +include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.linux.sources +nvhwpm-objs += ${nvhwpm-linux-objs} ifeq ($(CONFIG_TEGRA_T234_HWPM),y) - -obj-y += hal/t234/t234_alist.o -obj-y += hal/t234/t234_aperture.o -obj-y += hal/t234/t234_interface.o -obj-y += hal/t234/t234_ip.o -obj-y += hal/t234/t234_mem_mgmt.o -obj-y += hal/t234/t234_regops_allowlist.o -obj-y += hal/t234/t234_resource.o - -obj-y += hal/t234/ip/pma/t234_pma.o -obj-y += hal/t234/ip/rtr/t234_rtr.o - -# -# Control IP config -# To disable an IP config in compilation, add condition for both -# IP config flag and IP specific .o file. -# - -# -# One of the HWPM components is a perfmux. Perfmux registers belong to the -# IP domain. There are 2 ways of accessing perfmux registers -# - option 1: implement HWPM <-> IP interface. IP drivers register with HWPM -# driver and share required function pointers -# - option 2: map perfmux register address in HWPM driver -# Option 1 is a preferred solution. However, IP drivers have yet to -# implement the interface. Such IPs can be force enabled from HWPM driver -# perspective. However, forcing an IP will enable all instances of the IP. -# Hence, IP force enable should only be done on full chip config. -# Note as power management API is not available, unpowergating the IP via -# command line is required. -# -##define CONFIG_T234_HWPM_ALLOW_FORCE_ENABLE - -# -# Define a Minimal IP config flag -# Enable only MSS_Channel, NVDLA and PVA IPs -# When CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE is set to y. -# -CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE=y - -ifeq ($(CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE),y) -ccflags-y += -DCONFIG_T234_HWPM_ALLOW_FORCE_ENABLE +# Include T234 files +include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.t234.sources +nvhwpm-objs += ${nvhwpm-t234-objs} endif -ifeq ($(CONFIG_TEGRA_GRHOST_NVDLA),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_NVDLA -obj-y += hal/t234/ip/nvdla/t234_nvdla.o -endif - -ifeq ($(CONFIG_TEGRA_GRHOST_PVA),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_PVA -obj-y += hal/t234/ip/pva/t234_pva.o -endif - -ifeq ($(CONFIG_NV_TEGRA_MC),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_CHANNEL -obj-y += hal/t234/ip/mss_channel/t234_mss_channel.o -endif - -ifneq ($(CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_DISPLAY -obj-y += hal/t234/ip/display/t234_display.o - -ifeq ($(CONFIG_TEGRA_GRHOST_ISP),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_ISP -obj-y += hal/t234/ip/isp/t234_isp.o -endif - -ifeq ($(CONFIG_NVETHERNET),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_MGBE -obj-y += hal/t234/ip/mgbe/t234_mgbe.o -endif - -ifeq ($(CONFIG_NV_TEGRA_MC),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_ISO_NISO_HUBS -obj-y += hal/t234/ip/mss_iso_niso_hubs/t234_mss_iso_niso_hubs.o - -ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_MCF -obj-y += hal/t234/ip/mss_mcf/t234_mss_mcf.o -endif - -ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_GPU_HUB -obj-y += hal/t234/ip/mss_gpu_hub/t234_mss_gpu_hub.o - -ifeq ($(CONFIG_TEGRA_GRHOST_NVDEC),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_NVDEC -obj-y += hal/t234/ip/nvdec/t234_nvdec.o -endif - -ifeq ($(CONFIG_TEGRA_GRHOST_NVENC),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_NVENC -obj-y += hal/t234/ip/nvenc/t234_nvenc.o -endif - -ifeq ($(CONFIG_TEGRA_GRHOST_OFA),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_OFA -obj-y += hal/t234/ip/ofa/t234_ofa.o -endif - -ifeq ($(CONFIG_PCIE_TEGRA194),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_PCIE -obj-y += hal/t234/ip/pcie/t234_pcie.o -endif - -ccflags-y += -DCONFIG_T234_HWPM_IP_SCF -obj-y += hal/t234/ip/scf/t234_scf.o - -ifeq ($(CONFIG_VIDEO_TEGRA_VI),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_VI -obj-y += hal/t234/ip/vi/t234_vi.o -endif - -ifeq ($(CONFIG_TEGRA_GRHOST_VIC),y) -ccflags-y += -DCONFIG_T234_HWPM_IP_VIC -obj-y += hal/t234/ip/vic/t234_vic.o -endif - -endif - -endif +obj-${NVHWPM_OBJ} += nvhwpm.o diff --git a/Makefile.common.sources b/Makefile.common.sources new file mode 100644 index 0000000..9d8f0c4 --- /dev/null +++ b/Makefile.common.sources @@ -0,0 +1,11 @@ +# +# Tegra SOC HWPM Common sources +# + +# SPDX-License-Identifier: GPL-2.0 + +nvhwpm-common-objs += common/allowlist.o +nvhwpm-common-objs += common/aperture.o +nvhwpm-common-objs += common/ip.o +nvhwpm-common-objs += common/resource.o +nvhwpm-common-objs += common/init.o diff --git a/Makefile.linux.sources b/Makefile.linux.sources new file mode 100644 index 0000000..cdeb7bf --- /dev/null +++ b/Makefile.linux.sources @@ -0,0 +1,21 @@ +# +# Tegra SOC HWPM Linux Sources +# + +# SPDX-License-Identifier: GPL-2.0 + +nvhwpm-linux-objs += os/linux/aperture_utils.o +nvhwpm-linux-objs += os/linux/driver.o +nvhwpm-linux-objs += os/linux/io_utils.o +nvhwpm-linux-objs += os/linux/ip_utils.o +nvhwpm-linux-objs += os/linux/ioctl.o +nvhwpm-linux-objs += os/linux/kmem.o +nvhwpm-linux-objs += os/linux/log.o +nvhwpm-linux-objs += os/linux/mem_mgmt_utils.o +nvhwpm-linux-objs += os/linux/regops_utils.o +nvhwpm-linux-objs += os/linux/timers.o +nvhwpm-linux-objs += os/linux/soc_utils.o + +ifeq ($(CONFIG_DEBUG_FS),y) +nvhwpm-linux-objs += os/linux/debugfs.o +endif diff --git a/Makefile.t234.sources b/Makefile.t234.sources new file mode 100644 index 0000000..98655c6 --- /dev/null +++ b/Makefile.t234.sources @@ -0,0 +1,114 @@ +# +# Tegra SOC HWPM T234 sources +# + +# SPDX-License-Identifier: GPL-2.0 + +ifeq ($(CONFIG_TEGRA_T234_HWPM),y) +nvhwpm-t234-objs += hal/t234/t234_alist.o +nvhwpm-t234-objs += hal/t234/t234_aperture.o +nvhwpm-t234-objs += hal/t234/t234_interface.o +nvhwpm-t234-objs += hal/t234/t234_ip.o +nvhwpm-t234-objs += hal/t234/t234_mem_mgmt.o +nvhwpm-t234-objs += hal/t234/t234_regops_allowlist.o +nvhwpm-t234-objs += hal/t234/t234_resource.o + +# +# Control IP config +# To disable an IP config in compilation, add condition for both +# IP config flag and IP specific .o file. +# + +# +# RTR/PMA are HWPM IPs and can be enabled by default +# +nvhwpm-t234-objs += hal/t234/ip/rtr/t234_rtr.o +nvhwpm-t234-objs += hal/t234/ip/pma/t234_pma.o + +# +# Define a Minimal IP config flag +# Enable only MSS_Channel, NVDLA and PVA IPs +# When CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE is set to y. +# +CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE=y + +ifeq ($(CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE),y) +ccflags-y += -DCONFIG_HWPM_ALLOW_FORCE_ENABLE +endif + +ifeq ($(CONFIG_TEGRA_GRHOST_NVDLA),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_NVDLA +nvhwpm-t234-objs += hal/t234/ip/nvdla/t234_nvdla.o +endif + +ifeq ($(CONFIG_TEGRA_GRHOST_PVA),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_PVA +nvhwpm-t234-objs += hal/t234/ip/pva/t234_pva.o +endif + +ifeq ($(CONFIG_NV_TEGRA_MC),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_CHANNEL +nvhwpm-t234-objs += hal/t234/ip/mss_channel/t234_mss_channel.o +endif + +ifneq ($(CONFIG_TEGRA_HWPM_MINIMAL_IP_ENABLE),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_DISPLAY +nvhwpm-t234-objs += hal/t234/ip/display/t234_display.o + +ifeq ($(CONFIG_TEGRA_GRHOST_ISP),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_ISP +nvhwpm-t234-objs += hal/t234/ip/isp/t234_isp.o +endif + +ifeq ($(CONFIG_NVETHERNET),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_MGBE +nvhwpm-t234-objs += hal/t234/ip/mgbe/t234_mgbe.o +endif + +ifeq ($(CONFIG_NV_TEGRA_MC),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_ISO_NISO_HUBS +nvhwpm-t234-objs += hal/t234/ip/mss_iso_niso_hubs/t234_mss_iso_niso_hubs.o + +ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_MCF +nvhwpm-t234-objs += hal/t234/ip/mss_mcf/t234_mss_mcf.o +endif + +ccflags-y += -DCONFIG_T234_HWPM_IP_MSS_GPU_HUB +nvhwpm-t234-objs += hal/t234/ip/mss_gpu_hub/t234_mss_gpu_hub.o + +ifeq ($(CONFIG_TEGRA_GRHOST_NVDEC),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_NVDEC +nvhwpm-t234-objs += hal/t234/ip/nvdec/t234_nvdec.o +endif + +ifeq ($(CONFIG_TEGRA_GRHOST_NVENC),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_NVENC +nvhwpm-t234-objs += hal/t234/ip/nvenc/t234_nvenc.o +endif + +ifeq ($(CONFIG_TEGRA_GRHOST_OFA),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_OFA +nvhwpm-t234-objs += hal/t234/ip/ofa/t234_ofa.o +endif + +ifeq ($(CONFIG_PCIE_TEGRA194),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_PCIE +nvhwpm-t234-objs += hal/t234/ip/pcie/t234_pcie.o +endif + +ccflags-y += -DCONFIG_T234_HWPM_IP_SCF +nvhwpm-t234-objs += hal/t234/ip/scf/t234_scf.o + +ifeq ($(CONFIG_VIDEO_TEGRA_VI),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_VI +nvhwpm-t234-objs += hal/t234/ip/vi/t234_vi.o +endif + +ifeq ($(CONFIG_TEGRA_GRHOST_VIC),y) +ccflags-y += -DCONFIG_T234_HWPM_IP_VIC +nvhwpm-t234-objs += hal/t234/ip/vic/t234_vic.o +endif + +endif + +endif diff --git a/common/init.c b/common/init.c index cb39ebc..a383681 100644 --- a/common/init.c +++ b/common/init.c @@ -21,7 +21,7 @@ #include #ifdef CONFIG_TEGRA_NEXT1_HWPM -#include +#include #endif diff --git a/os/linux/driver.c b/os/linux/driver.c index bf7b6af..6d1f426 100644 --- a/os/linux/driver.c +++ b/os/linux/driver.c @@ -36,7 +36,7 @@ static const struct of_device_id tegra_soc_hwpm_of_match[] = { .compatible = "nvidia,t234-soc-hwpm", }, #ifdef CONFIG_TEGRA_NEXT1_HWPM -#include +#include #endif { }, };