DCE-KMD: Update DCE OS abstraction - Part 1

- We will keep single abstraction layer for linux.
    - File: dce-os-*
    - Fn: dce_os_*()

Modules covered in this CL:
1) dce-os-types
2) dce-os-atomic
3) dce-os-utils
4) dce-os-device
    - This is renamed to dce-linux-device in
      I74e2deb17f49065d242bd80d50c5a849b3dfa3a1

JIRA TDS-16126

Change-Id: I2d5eb45da4f245c1491645b27e2be9141bc038df
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228474
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
anupamg
2024-10-11 19:01:08 +00:00
committed by Jon Hunter
parent 7726f604ca
commit 2f1230b256
35 changed files with 347 additions and 420 deletions

View File

@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef DCE_OS_ATOMIC_H
#define DCE_OS_ATOMIC_H
#include <linux/atomic.h>
/** 32 bit atomic variable. */
typedef atomic_t dce_os_atomic_t;
static inline void dce_os_atomic_set(dce_os_atomic_t *v, int i)
{
atomic_set(v, i);
}
static inline int dce_os_atomic_read(dce_os_atomic_t *v)
{
return atomic_read(v);
}
static inline int dce_os_atomic_add_unless(dce_os_atomic_t *v, int a, int u)
{
return atomic_add_unless(v, a, u);
}
#endif /* DCE_OS_ATOMIC_H */

View File

@@ -0,0 +1,91 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef DCE_OS_DEVICE_H
#define DCE_OS_DEVICE_H
#include <linux/cdev.h>
#include <linux/types.h>
#include <dce.h>
/**
* struct dce_os_device - DCE data structure for storing
* OS device specific info.
*/
struct dce_os_device {
/**
* @d : OS agnostic dce struct. Stores all runitme info for dce cluster
* elements.
*/
struct tegra_dce d;
/**
* @dev : Pointer to DCE Cluster's Linux device struct.
*/
struct device *dev;
/**
* @pdata : Pointer to dce platform data struct.
*/
struct dce_platform_data *pdata;
/**
* @max_cpu_irqs : stores maximum no. os irqs from DCE cluster to CPU
* for this platform.
*/
u8 max_cpu_irqs;
/**
* @regs : Stores the cpu-mapped base address of DCE Cluster. Will be
* used for MMIO transactions to DCE elements.
*/
void __iomem *regs;
#ifdef CONFIG_DEBUG_FS
/**
* @debugfs : Debugfs node for DCE Linux device.
*/
struct dentry *debugfs;
/**
* @ext_test_status : Return code for external client tests run via
* debugfs
*/
s32 ext_test_status;
#endif
};
/**
* dce_os_device_from_dce - inline function to get linux os data from the
* os agnostic struct tegra_dc
* @d : Pointer to the os agnostic tegra_dce data structure.
*
* Return : pointer to struct dce_os_device
*/
static inline struct dce_os_device *dce_os_device_from_dce(struct tegra_dce *d)
{
return container_of(d, struct dce_os_device, d);
}
/**
* dev_from_dce - inline function to get linux device from the
* os agnostic struct tegra_dce
* @d : Pointer to the os agnostic tegra_dce data structure.
*
* Return : pointer to struct device
*/
static inline struct device *dev_from_dce(struct tegra_dce *d)
{
return dce_os_device_from_dce(d)->dev;
}
/**
* pdata_from_dce - inline function to get dce platform data from
* the os agnostic struct tegra_dc.
*
* @d : Pointer to the os agnostic tegra_dce data structure.
*
* Return : pointer to struct device
*/
static inline struct dce_platform_data *pdata_from_dce(struct tegra_dce *d)
{
return ((struct dce_os_device *)dev_get_drvdata(dev_from_dce(d)))->pdata;
}
#endif /* DCE_OS_DEVICE_H */

View File

@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#ifndef DCE_OS_TYPES_H
#define DCE_OS_TYPES_H
#include <linux/types.h>
#endif /* DCE_OS_TYPES_H */