tegra: hwpm: add wrappers for io functions

In an effort to make HWPM driver OS agnostic, add wrappers for io
functions.

Jira THWPM-59

Change-Id: I9309ee15a965aa3d2f122ef959eec211c9a84623
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2738156
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Vedashree Vidwans
2022-06-30 00:25:23 -07:00
committed by mobile promotions
parent c893ae2cd9
commit 42a33fd9d0
4 changed files with 86 additions and 19 deletions

View File

@@ -10,7 +10,7 @@ ccflags-y += -I$(srctree.nvidia)/include
obj-$(CONFIG_DEBUG_FS) += os/linux/debugfs.o
obj-y += os/linux/driver.o
obj-y += os/linux/io.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

View File

@@ -49,22 +49,55 @@ static inline u32 get_field(u32 input_data, u32 mask)
return (input_data & mask);
}
#ifdef __KERNEL__
#include <os/linux/io_utils.h>
#else
int tegra_hwpm_read_sticky_bits_impl(struct tegra_soc_hwpm *hwpm,
u64 reg_base, u64 reg_offset, u32 *val)
{
return -EINVAL;
}
struct tegra_soc_hwpm;
struct hwpm_ip_inst;
struct hwpm_ip_aperture;
int tegra_hwpm_readl_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 *val)
{
return -EINVAL;
}
int tegra_hwpm_read_sticky_bits(struct tegra_soc_hwpm *hwpm,
u64 reg_base, u64 reg_offset, u32 *val);
int tegra_hwpm_readl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 *val);
int tegra_hwpm_writel(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 val);
int tegra_hwpm_regops_readl(struct tegra_soc_hwpm *hwpm,
int tegra_hwpm_writel_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 val)
{
return -EINVAL;
}
int tegra_hwpm_regops_readl_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_inst *ip_inst, struct hwpm_ip_aperture *aperture,
u64 addr, u32 *val);
int tegra_hwpm_regops_writel(struct tegra_soc_hwpm *hwpm,
u64 addr, u32 *val)
{
return -EINVAL;
}
int tegra_hwpm_regops_writel_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_inst *ip_inst, struct hwpm_ip_aperture *aperture,
u64 addr, u32 val);
u64 addr, u32 val)
{
return -EINVAL;
}
#endif
#define tegra_hwpm_read_sticky_bits(hwpm, reg_base, reg_offset, val) \
tegra_hwpm_read_sticky_bits_impl(hwpm, reg_base, reg_offset, val)
#define tegra_hwpm_readl(hwpm, aperture, addr, val) \
tegra_hwpm_readl_impl(hwpm, aperture, addr, val)
#define tegra_hwpm_writel(hwpm, aperture, addr, val) \
tegra_hwpm_writel_impl(hwpm, aperture, addr, val)
#define tegra_hwpm_regops_readl(hwpm, ip_inst, aperture, addr, val) \
tegra_hwpm_regops_readl_impl(hwpm, ip_inst, aperture, addr, val)
#define tegra_hwpm_regops_writel(hwpm, ip_inst, aperture, addr, val) \
tegra_hwpm_regops_writel_impl(hwpm, ip_inst, aperture, addr, val)
#endif /* TEGRA_HWPM_IO_H */

View File

@@ -23,7 +23,7 @@
#include <tegra_hwpm_log.h>
#include <tegra_hwpm_static_analysis.h>
int tegra_hwpm_read_sticky_bits(struct tegra_soc_hwpm *hwpm,
int tegra_hwpm_read_sticky_bits_impl(struct tegra_soc_hwpm *hwpm,
u64 reg_base, u64 reg_offset, u32 *val)
{
void __iomem *ptr = NULL;
@@ -217,7 +217,7 @@ static int hwpm_writel(struct tegra_soc_hwpm *hwpm,
* Read a HWPM domain register. It is assumed that valid aperture
* is passed to the function.
*/
int tegra_hwpm_readl(struct tegra_soc_hwpm *hwpm,
int tegra_hwpm_readl_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 *val)
{
tegra_hwpm_fn(hwpm, " ");
@@ -244,7 +244,7 @@ int tegra_hwpm_readl(struct tegra_soc_hwpm *hwpm,
* Write to a HWPM domain register. It is assumed that valid aperture
* is passed to the function.
*/
int tegra_hwpm_writel(struct tegra_soc_hwpm *hwpm,
int tegra_hwpm_writel_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 val)
{
tegra_hwpm_fn(hwpm, " ");
@@ -271,7 +271,7 @@ int tegra_hwpm_writel(struct tegra_soc_hwpm *hwpm,
* Read a register from the EXEC_REG_OPS IOCTL. It is assumed that the allowlist
* check has been done before calling this function.
*/
int tegra_hwpm_regops_readl(struct tegra_soc_hwpm *hwpm,
int tegra_hwpm_regops_readl_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_inst *ip_inst, struct hwpm_ip_aperture *aperture,
u64 addr, u32 *val)
{
@@ -300,7 +300,7 @@ int tegra_hwpm_regops_readl(struct tegra_soc_hwpm *hwpm,
* Write a register from the EXEC_REG_OPS IOCTL. It is assumed that the
* allowlist check has been done before calling this function.
*/
int tegra_hwpm_regops_writel(struct tegra_soc_hwpm *hwpm,
int tegra_hwpm_regops_writel_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_inst *ip_inst, struct hwpm_ip_aperture *aperture,
u64 addr, u32 val)
{

34
os/linux/io_utils.h Normal file
View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. 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.
*/
#ifndef TEGRA_HWPM_OS_LINUX_IO_UTILS_H
#define TEGRA_HWPM_OS_LINUX_IO_UTILS_H
struct tegra_soc_hwpm;
struct hwpm_ip_inst;
struct hwpm_ip_aperture;
int tegra_hwpm_read_sticky_bits_impl(struct tegra_soc_hwpm *hwpm,
u64 reg_base, u64 reg_offset, u32 *val);
int tegra_hwpm_readl_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 *val);
int tegra_hwpm_writel_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_aperture *aperture, u64 addr, u32 val);
int tegra_hwpm_regops_readl_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_inst *ip_inst, struct hwpm_ip_aperture *aperture,
u64 addr, u32 *val);
int tegra_hwpm_regops_writel_impl(struct tegra_soc_hwpm *hwpm,
struct hwpm_ip_inst *ip_inst, struct hwpm_ip_aperture *aperture,
u64 addr, u32 val);
#endif /* TEGRA_HWPM_OS_LINUX_IO_UTILS_H */