hwpm: Makefile: Add support to make as module

Add support to make the HWPM driver as module.
Set appropriate path and environment variable
which needs to be passed when building the driver
as module.
Use basic fuse.h file instead of using fuse-helper.h which is not
available in OOT builds.
Introduce HWPM mock file to add definitions for register and
unregister used if HWPM is not compiled in a build.

Bug 4088571

Change-Id: Id6cfb78356d752b963ad7eb16e39b85df92a9a4b
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/2894547
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2023-04-26 22:17:14 -07:00
committed by mobile promotions
parent ea6b4bcc07
commit 5b8bb57dcb
7 changed files with 120 additions and 22 deletions

7
drivers/Kconfig Normal file
View File

@@ -0,0 +1,7 @@
append_menu "Device Drivers"
if ARCH_TEGRA
source "drivers/tegra/hwpm/Kconfig"
endif
endmenu

5
drivers/Makefile Normal file
View File

@@ -0,0 +1,5 @@
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
subdir-ccflags-y += -Werror
obj-y += tegra/hwpm/

View File

@@ -1,3 +1,10 @@
config TEGRA_SOC_HWPM
tristate "Tegra SOC HWPM driver"
default m
help
The SOC HWPM driver enables performance monitoring for various Tegra
IPs.
config TEGRA_T234_HWPM config TEGRA_T234_HWPM
bool "Tegra T23x HWPM driver" bool "Tegra T23x HWPM driver"
depends on TEGRA_SOC_HWPM && ARCH_TEGRA_23x_SOC depends on TEGRA_SOC_HWPM && ARCH_TEGRA_23x_SOC

View File

@@ -1,13 +1,21 @@
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
# #
# Tegra SOC HWPM # Tegra SOC HWPM
# #
# SPDX-License-Identifier: GPL-2.0
GCOV_PROFILE := y GCOV_PROFILE := y
ccflags-y += -I$(srctree.nvidia)/include ifeq ($(origin srctree.hwpm), undefined)
ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm/include srctree.hwpm := $(abspath $(shell dirname $(lastword $(MAKEFILE_LIST))))/../../..
ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/hwpm endif
CONFIG_TEGRA_SOC_HWPM := y
ccflags-y += -DCONFIG_TEGRA_SOC_HWPM
CONFIG_TEGRA_T234_HWPM := y
ccflags-y += -DCONFIG_TEGRA_T234_HWPM
NVHWPM_OBJ = m
# For OOT builds, set required config flags # For OOT builds, set required config flags
ifeq ($(CONFIG_TEGRA_OOT_MODULE),m) ifeq ($(CONFIG_TEGRA_OOT_MODULE),m)
@@ -17,26 +25,24 @@ ccflags-y += -DCONFIG_TEGRA_HWPM_OOT
CONFIG_TEGRA_FUSE_UPSTREAM := y CONFIG_TEGRA_FUSE_UPSTREAM := y
ccflags-y += -DCONFIG_TEGRA_FUSE_UPSTREAM ccflags-y += -DCONFIG_TEGRA_FUSE_UPSTREAM
CONFIG_TEGRA_T234_HWPM := y LINUXINCLUDE += -I$(srctree.hwpm)/include
ccflags-y += -DCONFIG_TEGRA_T234_HWPM LINUXINCLUDE += -I$(srctree.hwpm)/drivers/tegra/hwpm/include
NVHWPM_OBJ = m LINUXINCLUDE += -I$(srctree.hwpm)/drivers/tegra/hwpm
else else
NVHWPM_OBJ = y ccflags-y += -I$(srctree.nvidia)/include
ccflags-y += -I$(srctree.hwpm)/include
ccflags-y += -I$(srctree.hwpm)/drivers/tegra/hwpm/include
ccflags-y += -I$(srctree.hwpm)/drivers/tegra/hwpm
endif endif
ifeq ($(NV_BUILD_CONFIGURATION_IS_SAFETY),1)
obj-${NVHWPM_OBJ} += tegra_hwpm_mock.o
else
# Add required objects to nvhwpm object variable # Add required objects to nvhwpm object variable
# Include common files include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.sources
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)
# Include T234 files
include $(srctree.nvidia)/drivers/platform/tegra/hwpm/Makefile.t234.sources
nvhwpm-objs += ${nvhwpm-t234-objs}
endif
obj-${NVHWPM_OBJ} += nvhwpm.o obj-${NVHWPM_OBJ} += nvhwpm.o
endif

View File

@@ -0,0 +1,18 @@
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Tegra SOC HWPM Sources
#
# Include common files
include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.common.sources
nvhwpm-objs += ${nvhwpm-common-objs}
# Include linux files
include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.linux.sources
nvhwpm-objs += ${nvhwpm-linux-objs}
ifeq ($(CONFIG_TEGRA_T234_HWPM),y)
# Include T234 files
include $(srctree.hwpm)/drivers/tegra/hwpm/Makefile.t234.sources
nvhwpm-objs += ${nvhwpm-t234-objs}
endif

View File

@@ -18,7 +18,7 @@
#if CONFIG_ACPI #if CONFIG_ACPI
#include <linux/acpi.h> #include <linux/acpi.h>
#endif #endif
#include <soc/tegra/fuse-helper.h> #include <soc/tegra/fuse.h>
#include <tegra_hwpm_log.h> #include <tegra_hwpm_log.h>
#include <tegra_hwpm_soc.h> #include <tegra_hwpm_soc.h>

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/export.h>
#include <linux/module.h>
#include <uapi/linux/tegra-soc-hwpm-uapi.h>
#include <os/linux/driver.h>
void tegra_soc_hwpm_ip_register(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
{
/* Dummy function */
}
EXPORT_SYMBOL(tegra_soc_hwpm_ip_register);
void tegra_soc_hwpm_ip_unregister(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
{
/* Dummy function */
}
EXPORT_SYMBOL(tegra_soc_hwpm_ip_unregister);
/* Dummy implementation for module */
static int __init tegra_hwpm_init(void)
{
return 0;
}
static void __exit tegra_hwpm_exit(void)
{
}
#if defined(CONFIG_TEGRA_HWPM_OOT)
module_init(tegra_hwpm_init);
#else
postcore_initcall(tegra_hwpm_init);
#endif
module_exit(tegra_hwpm_exit);
MODULE_ALIAS(TEGRA_SOC_HWPM_MODULE_NAME);
MODULE_DESCRIPTION("Tegra SOC HWPM MOCK Driver");
MODULE_LICENSE("GPL v2");