From 2f1230b256af725234c873591099c0954d8a83d5 Mon Sep 17 00:00:00 2001 From: anupamg Date: Fri, 11 Oct 2024 19:01:08 +0000 Subject: [PATCH] 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 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3228474 Reviewed-by: Mahesh Kumar Reviewed-by: Arun Swain GVS: buildbot_gerritrpt --- drivers/platform/tegra/dce/Makefile | 5 +- drivers/platform/tegra/dce/dce-admin-debug.c | 2 +- drivers/platform/tegra/dce/dce-admin.c | 18 ++-- drivers/platform/tegra/dce/dce-ast.c | 34 +++---- drivers/platform/tegra/dce/dce-bootstrap.c | 4 +- drivers/platform/tegra/dce/dce-client-ipc.c | 22 ++--- drivers/platform/tegra/dce/dce-debug-perf.c | 2 +- drivers/platform/tegra/dce/dce-debug.c | 14 +-- drivers/platform/tegra/dce/dce-fsm.c | 2 +- drivers/platform/tegra/dce/dce-hsp-smb-t264.c | 20 ++-- drivers/platform/tegra/dce/dce-hsp-smb.c | 20 ++-- drivers/platform/tegra/dce/dce-hsp-ss-t264.c | 12 +-- drivers/platform/tegra/dce/dce-hsp-ss.c | 12 +-- drivers/platform/tegra/dce/dce-init-deinit.c | 4 +- drivers/platform/tegra/dce/dce-ipc-signal.c | 2 +- drivers/platform/tegra/dce/dce-ipc.c | 2 +- drivers/platform/tegra/dce/dce-mailbox.c | 2 +- drivers/platform/tegra/dce/dce-module.c | 12 +-- .../dce/{dce-util-common.c => dce-os-utils.c} | 97 ++++++++++++------ drivers/platform/tegra/dce/dce-pm.c | 2 +- drivers/platform/tegra/dce/dce-reset.c | 8 +- drivers/platform/tegra/dce/dce-worker.c | 16 +-- .../dce/include/dce-client-ipc-internal.h | 6 +- .../tegra/dce/include/dce-util-common.h | 58 ----------- .../platform/tegra/dce/include/dce-worker.h | 4 +- .../platform/tegra/dce/os/include/atomic.h | 24 ----- .../tegra/dce/os/include/dce-os-utils.h | 47 +++++++++ .../tegra/dce/os/include/linux-kmd/atomic.h | 37 ------- .../dce/os/include/linux-kmd/os-dce-device.h | 98 ------------------- .../tegra/dce/os/include/linux/os-types.h | 11 --- .../tegra/dce/os/include/os-dce-device.h | 24 ----- .../platform/tegra/dce/os/include/os-utils.h | 24 ----- .../dce/os/linux/include/dce-os-atomic.h | 29 ++++++ .../dce/os/linux/include/dce-os-device.h | 91 +++++++++++++++++ .../include/dce-os-types.h | 2 +- 35 files changed, 347 insertions(+), 420 deletions(-) rename drivers/platform/tegra/dce/{dce-util-common.c => dce-os-utils.c} (85%) delete mode 100644 drivers/platform/tegra/dce/include/dce-util-common.h delete mode 100644 drivers/platform/tegra/dce/os/include/atomic.h create mode 100644 drivers/platform/tegra/dce/os/include/dce-os-utils.h delete mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h delete mode 100644 drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h delete mode 100644 drivers/platform/tegra/dce/os/include/linux/os-types.h delete mode 100644 drivers/platform/tegra/dce/os/include/os-dce-device.h delete mode 100644 drivers/platform/tegra/dce/os/include/os-utils.h create mode 100644 drivers/platform/tegra/dce/os/linux/include/dce-os-atomic.h create mode 100644 drivers/platform/tegra/dce/os/linux/include/dce-os-device.h rename drivers/platform/tegra/dce/os/{interface => linux}/include/dce-os-types.h (90%) diff --git a/drivers/platform/tegra/dce/Makefile b/drivers/platform/tegra/dce/Makefile index f809fbd8..6c27b5c3 100644 --- a/drivers/platform/tegra/dce/Makefile +++ b/drivers/platform/tegra/dce/Makefile @@ -15,8 +15,7 @@ endif # CONFIG_TEGRA_OOT_MODULE ccflags-y += -I$(srctree.nvidia-oot)/include ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/include ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/os/include -ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/os/interface/include -ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/os/include/linux +ccflags-y += -I$(srctree.nvidia-oot)/drivers/platform/tegra/dce/os/linux/include obj-$(CONFIG_TEGRA_DCE) += tegra-dce.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-ast.o @@ -34,7 +33,7 @@ tegra-dce-$(CONFIG_TEGRA_DCE) += dce-ipc-signal.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-client-ipc.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-module.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-pm.o -tegra-dce-$(CONFIG_TEGRA_DCE) += dce-util-common.o +tegra-dce-$(CONFIG_TEGRA_DCE) += dce-os-utils.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-hsp-smb-t264.o tegra-dce-$(CONFIG_TEGRA_DCE) += dce-hsp-ss-t264.o diff --git a/drivers/platform/tegra/dce/dce-admin-debug.c b/drivers/platform/tegra/dce/dce-admin-debug.c index 16dce100..b131096f 100644 --- a/drivers/platform/tegra/dce/dce-admin-debug.c +++ b/drivers/platform/tegra/dce/dce-admin-debug.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/platform/tegra/dce/dce-admin.c b/drivers/platform/tegra/dce/dce-admin.c index 22c33474..91067f7f 100644 --- a/drivers/platform/tegra/dce/dce-admin.c +++ b/drivers/platform/tegra/dce/dce-admin.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -113,19 +113,19 @@ static struct dce_ipc_message *dce_admin_allocate_message(struct tegra_dce *d) { struct dce_ipc_message *msg; - msg = dce_kzalloc(d, sizeof(*msg), false); + msg = dce_os_kzalloc(d, sizeof(*msg), false); if (!msg) { dce_err(d, "Insufficient memory for admin msg"); goto err_alloc_msg; } - msg->tx.data = dce_kzalloc(d, DCE_ADMIN_CMD_SIZE, false); + msg->tx.data = dce_os_kzalloc(d, DCE_ADMIN_CMD_SIZE, false); if (!msg->tx.data) { dce_err(d, "Insufficient memory for admin msg"); goto err_alloc_tx; } - msg->rx.data = dce_kzalloc(d, DCE_ADMIN_RESP_SIZE, false); + msg->rx.data = dce_os_kzalloc(d, DCE_ADMIN_RESP_SIZE, false); if (!msg->rx.data) { dce_err(d, "Insufficient memory for admin msg"); goto err_alloc_rx; @@ -137,9 +137,9 @@ static struct dce_ipc_message *dce_admin_allocate_message(struct tegra_dce *d) return msg; err_alloc_rx: - dce_kfree(d, msg->tx.data); + dce_os_kfree(d, msg->tx.data); err_alloc_tx: - dce_kfree(d, msg); + dce_os_kfree(d, msg); err_alloc_msg: return NULL; } @@ -159,9 +159,9 @@ static void dce_admin_free_message(struct tegra_dce *d, if (!msg || !msg->tx.data || !msg->rx.data) return; - dce_kfree(d, msg->tx.data); - dce_kfree(d, msg->rx.data); - dce_kfree(d, msg); + dce_os_kfree(d, msg->tx.data); + dce_os_kfree(d, msg->rx.data); + dce_os_kfree(d, msg); } /** diff --git a/drivers/platform/tegra/dce/dce-ast.c b/drivers/platform/tegra/dce/dce-ast.c index cf80ee20..c4bb67cc 100644 --- a/drivers/platform/tegra/dce/dce-ast.c +++ b/drivers/platform/tegra/dce/dce-ast.c @@ -4,7 +4,7 @@ */ #include #include -#include +#include #define MAX_NO_ASTS 2 #define MAX_AST_REGIONS 1 @@ -38,7 +38,7 @@ static void dce_config_ast0_control(struct tegra_dce *d) | def_physical | ast_ast0_control_matcherrctl_decerr_f() | ast_ast0_control_lock_false_f(); - dce_writel(d, ast_ast0_control_r(), val); + dce_os_writel(d, ast_ast0_control_r(), val); } /** @@ -67,7 +67,7 @@ static void dce_config_ast1_control(struct tegra_dce *d) | def_physical | ast_ast1_control_matcherrctl_decerr_f() | ast_ast1_control_lock_false_f(); - dce_writel(d, ast_ast1_control_r(), val); + dce_os_writel(d, ast_ast1_control_r(), val); } /** @@ -101,7 +101,7 @@ static void dce_cfg_ast0_streamid_ctl_0(struct tegra_dce *d) else stream_id_en = ast_ast0_streamid_ctl_0_enable_enable_f(); - dce_writel(d, ast_ast0_streamid_ctl_0_r(), + dce_os_writel(d, ast_ast0_streamid_ctl_0_r(), (dce_stream_id << ast_ast0_streamid_ctl_0_streamid_shift_v()) | stream_id_en); } @@ -124,7 +124,7 @@ static void dce_cfg_ast0_streamid_ctl_1(struct tegra_dce *d) else stream_id_en = ast_ast0_streamid_ctl_1_enable_enable_f(); - dce_writel(d, ast_ast0_streamid_ctl_1_r(), (dce_stream_id << + dce_os_writel(d, ast_ast0_streamid_ctl_1_r(), (dce_stream_id << ast_ast0_streamid_ctl_1_streamid_shift_v()) | stream_id_en); } @@ -147,7 +147,7 @@ static void dce_cfg_ast1_streamid_ctl_0(struct tegra_dce *d) else stream_id_en = ast_ast1_streamid_ctl_0_enable_enable_f(); - dce_writel(d, ast_ast1_streamid_ctl_0_r(), + dce_os_writel(d, ast_ast1_streamid_ctl_0_r(), (dce_stream_id << ast_ast1_streamid_ctl_0_streamid_shift_v()) | stream_id_en); } @@ -170,7 +170,7 @@ static void dce_cfg_ast1_streamid_ctl_1(struct tegra_dce *d) else stream_id_en = ast_ast1_streamid_ctl_1_enable_enable_f(); - dce_writel(d, ast_ast1_streamid_ctl_1_r(), + dce_os_writel(d, ast_ast1_streamid_ctl_1_r(), (dce_stream_id << ast_ast1_streamid_ctl_1_streamid_shift_v()) | stream_id_en); } @@ -207,7 +207,7 @@ static void (*const ast_strmidctl_fn[MAX_NO_ASTS][MAX_AST_STRMCTLS]) */ static void dce_set_ast0_slave_addr_32_reg0(struct tegra_dce *d, u32 addr) { - dce_writel(d, ast_ast0_region_0_slave_base_lo_r(), + dce_os_writel(d, ast_ast0_region_0_slave_base_lo_r(), (addr | ast_ast0_region_0_slave_base_lo_enable_true_f()) & ast_ast1_region_0_slave_base_lo_write_mask_v()); } @@ -223,7 +223,7 @@ static void dce_set_ast0_slave_addr_32_reg0(struct tegra_dce *d, u32 addr) */ static void dce_set_ast1_slave_addr_32_reg0(struct tegra_dce *d, u32 addr) { - dce_writel(d, ast_ast1_region_0_slave_base_lo_r(), + dce_os_writel(d, ast_ast1_region_0_slave_base_lo_r(), (addr | ast_ast1_region_0_slave_base_lo_enable_true_f()) & ast_ast1_region_0_slave_base_lo_write_mask_v()); } @@ -259,7 +259,7 @@ static void (*const ast_slave_addr_fn[MAX_NO_ASTS][MAX_AST_REGIONS]) static inline void dce_set_ast0_master_addr_lo_reg0(struct tegra_dce *d, u32 addr) { - dce_writel(d, ast_ast0_region_0_master_base_lo_r(), addr); + dce_os_writel(d, ast_ast0_region_0_master_base_lo_r(), addr); } /** @@ -274,7 +274,7 @@ dce_set_ast0_master_addr_lo_reg0(struct tegra_dce *d, u32 addr) static inline void dce_set_ast1_master_addr_lo_reg0(struct tegra_dce *d, u32 addr) { - dce_writel(d, ast_ast1_region_0_master_base_lo_r(), addr); + dce_os_writel(d, ast_ast1_region_0_master_base_lo_r(), addr); } /** @@ -289,7 +289,7 @@ dce_set_ast1_master_addr_lo_reg0(struct tegra_dce *d, u32 addr) static inline void dce_set_ast1_master_addr_hi_reg0(struct tegra_dce *d, u32 addr) { - dce_writel(d, ast_ast1_region_0_master_base_hi_r(), addr); + dce_os_writel(d, ast_ast1_region_0_master_base_hi_r(), addr); } /** @@ -304,7 +304,7 @@ dce_set_ast1_master_addr_hi_reg0(struct tegra_dce *d, u32 addr) static inline void dce_set_ast0_master_addr_hi_reg0(struct tegra_dce *d, u32 addr) { - dce_writel(d, ast_ast0_region_0_master_base_hi_r(), addr); + dce_os_writel(d, ast_ast0_region_0_master_base_hi_r(), addr); } /** @@ -398,7 +398,7 @@ static void dce_ast_cfg_reg_mask_ast0_reg0(struct tegra_dce *d) u64 size_mask = dce_get_fw_ast_reg_mask(d); u32 val = size_mask & ast_ast0_region_0_mask_lo_write_mask_v(); - dce_writel(d, ast_ast0_region_0_mask_lo_r(), val); + dce_os_writel(d, ast_ast0_region_0_mask_lo_r(), val); } /** @@ -414,7 +414,7 @@ static void dce_ast_cfg_reg_mask_ast1_reg0(struct tegra_dce *d) u64 size_mask = dce_get_fw_ast_reg_mask(d); u32 val = size_mask & ast_ast1_region_0_mask_lo_write_mask_v(); - dce_writel(d, ast_ast1_region_0_mask_lo_r(), val); + dce_os_writel(d, ast_ast1_region_0_mask_lo_r(), val); } /** @@ -463,7 +463,7 @@ static void dce_ast_cfg_reg_control_ast0_reg0(struct tegra_dce *d) carveout_id = dce_get_fw_carveout_id(d) << ast_ast0_region_0_control_carveoutid_shift_v(); - dce_writel(d, ast_ast0_region_0_control_r(), + dce_os_writel(d, ast_ast0_region_0_control_r(), use_physical_id | vm_index | carveout_id | ast_ast0_region_0_control_snoop_enable_f()); } @@ -498,7 +498,7 @@ static void dce_ast_cfg_reg_control_ast1_reg0(struct tegra_dce *d) ast_ast1_region_0_control_carveoutid_shift_v(); - dce_writel(d, ast_ast1_region_0_control_r(), + dce_os_writel(d, ast_ast1_region_0_control_r(), use_physical_id | vm_index | carveout_id | ast_ast1_region_0_control_snoop_enable_f()); } diff --git a/drivers/platform/tegra/dce/dce-bootstrap.c b/drivers/platform/tegra/dce/dce-bootstrap.c index 61ea1ddb..b2a9f6e4 100644 --- a/drivers/platform/tegra/dce/dce-bootstrap.c +++ b/drivers/platform/tegra/dce/dce-bootstrap.c @@ -3,7 +3,7 @@ * SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #include -#include +#include #include #include @@ -165,7 +165,7 @@ dce_start_boot_flow(struct tegra_dce *d) } dce_admin_ivc_channel_reset(d); - dce_usleep_range(10, 50); + dce_os_usleep_range(10, 50); ret = dce_start_admin_seq(d); if (ret) { diff --git a/drivers/platform/tegra/dce/dce-client-ipc.c b/drivers/platform/tegra/dce/dce-client-ipc.c index e84c0423..28b32e16 100644 --- a/drivers/platform/tegra/dce/dce-client-ipc.c +++ b/drivers/platform/tegra/dce/dce-client-ipc.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #define DCE_IPC_HANDLES_MAX 6U @@ -114,7 +114,7 @@ static void dce_client_async_event_work(struct work_struct *data) cl = d->d_clients[DCE_CLIENT_IPC_TYPE_RM_EVENT]; dce_client_process_event_ipc(d, cl); - os_atomic_set(&work->in_use, 0); + dce_os_atomic_set(&work->in_use, 0); } int tegra_dce_register_ipc_client(u32 type, @@ -171,7 +171,7 @@ int tegra_dce_register_ipc_client(u32 type, cl->handle = handle; cl->int_type = int_type; cl->callback_fn = callback_fn; - os_atomic_set(&cl->complete, 0); + dce_os_atomic_set(&cl->complete, 0); ret = dce_cond_init(&cl->recv_wait); if (ret) { @@ -249,7 +249,7 @@ int dce_client_init(struct tegra_dce *d) INIT_WORK(&d_work->async_event_work, dce_client_async_event_work); d_work->d = d; - os_atomic_set(&d_work->in_use, 0); + dce_os_atomic_set(&d_work->in_use, 0); } return ret; @@ -284,11 +284,11 @@ int dce_client_ipc_wait(struct tegra_dce *d, u32 int_type) retry_wait: DCE_COND_WAIT_INTERRUPTIBLE(&cl->recv_wait, - os_atomic_read(&cl->complete) == 1); - if (os_atomic_read(&cl->complete) != 1) + dce_os_atomic_read(&cl->complete) == 1); + if (dce_os_atomic_read(&cl->complete) != 1) goto retry_wait; - os_atomic_set(&cl->complete, 0); + dce_os_atomic_set(&cl->complete, 0); return 0; } @@ -310,7 +310,7 @@ static void dce_client_process_event_ipc(struct tegra_dce *d, return; } - msg_data = dce_kzalloc(d, DCE_CLIENT_MAX_IPC_MSG_SIZE, false); + msg_data = dce_os_kzalloc(d, DCE_CLIENT_MAX_IPC_MSG_SIZE, false); if (msg_data == NULL) { dce_err(d, "Could not allocate msg read buffer"); goto done; @@ -330,7 +330,7 @@ static void dce_client_process_event_ipc(struct tegra_dce *d, done: if (msg_data) - dce_kfree(d, msg_data); + dce_os_kfree(d, msg_data); } static void dce_client_schedule_event_work(struct tegra_dce *d) @@ -341,7 +341,7 @@ static void dce_client_schedule_event_work(struct tegra_dce *d) for (i = 0; i < DCE_MAX_ASYNC_WORK; i++) { struct dce_async_work *d_work = &async_work_info->work[i]; - if (os_atomic_add_unless(&d_work->in_use, 1, 1) > 0) { + if (dce_os_atomic_add_unless(&d_work->in_use, 1, 1) > 0) { queue_work(async_work_info->async_event_wq, &d_work->async_event_work); break; @@ -374,6 +374,6 @@ void dce_client_ipc_wakeup(struct tegra_dce *d, u32 ch_type) if (type == DCE_CLIENT_IPC_TYPE_RM_EVENT) return dce_client_schedule_event_work(d); - os_atomic_set(&cl->complete, 1); + dce_os_atomic_set(&cl->complete, 1); dce_cond_signal_interruptible(&cl->recv_wait); } diff --git a/drivers/platform/tegra/dce/dce-debug-perf.c b/drivers/platform/tegra/dce/dce-debug-perf.c index 8a7361aa..72f1606d 100644 --- a/drivers/platform/tegra/dce/dce-debug-perf.c +++ b/drivers/platform/tegra/dce/dce-debug-perf.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #define DCE_PERF_OUTPUT_FORMAT_CSV ((uint32_t)(0U)) diff --git a/drivers/platform/tegra/dce/dce-debug.c b/drivers/platform/tegra/dce/dce-debug.c index 359e9e49..ebd47f46 100644 --- a/drivers/platform/tegra/dce/dce-debug.c +++ b/drivers/platform/tegra/dce/dce-debug.c @@ -9,8 +9,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -26,7 +26,7 @@ static int dbg_dce_load_fw(struct tegra_dce *d) { const char *name = dce_get_fw_name(d); - d->fw_data = dce_request_firmware(d, name); + d->fw_data = dce_os_request_firmware(d, name); if (!d->fw_data) { dce_err(d, "FW Request Failed"); return -EBUSY; @@ -335,7 +335,7 @@ static ssize_t dbg_dce_tests_external_status_fops_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct tegra_dce *d = file->private_data; - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); char buf[15]; ssize_t bytes_printed; @@ -366,7 +366,7 @@ static ssize_t dbg_dce_tests_external_run_fops_write(struct file *file, struct dce_admin_ipc_cmd *req_msg = NULL; struct dce_admin_ipc_resp *resp_msg = NULL; struct tegra_dce *d = file->private_data; - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); ret = kstrtou32_from_user(user_buf, count, 10, &test); if (ret) { @@ -652,7 +652,7 @@ static const struct file_operations perf_events_help_fops = { void dce_remove_debug(struct tegra_dce *d) { - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); debugfs_remove(d_dev->debugfs); @@ -735,7 +735,7 @@ void dce_init_debug(struct tegra_dce *d) { struct dentry *retval; struct device *dev = dev_from_dce(d); - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); struct dentry *debugfs_dir = NULL; struct dentry *perf_debugfs_dir = NULL; diff --git a/drivers/platform/tegra/dce/dce-fsm.c b/drivers/platform/tegra/dce/dce-fsm.c index 6e1a1895..0d85a7b8 100644 --- a/drivers/platform/tegra/dce/dce-fsm.c +++ b/drivers/platform/tegra/dce/dce-fsm.c @@ -4,7 +4,7 @@ */ #include -#include +#include struct dce_event_process_struct { enum dce_fsm_event_id_type event; diff --git a/drivers/platform/tegra/dce/dce-hsp-smb-t264.c b/drivers/platform/tegra/dce/dce-hsp-smb-t264.c index 37fd0c81..c9b9c7f6 100644 --- a/drivers/platform/tegra/dce/dce-hsp-smb-t264.c +++ b/drivers/platform/tegra/dce/dce-hsp-smb-t264.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include @@ -114,7 +114,7 @@ void dce_smb_set_t264(struct tegra_dce *d, u32 val, u8 hsp_id, u8 id) return; } - dce_writel(d, smb_regs[hsp_id][id](), val); + dce_os_writel(d, smb_regs[hsp_id][id](), val); } /** @@ -136,7 +136,7 @@ void dce_smb_set_full_ie_t264(struct tegra_dce *d, bool en, u8 hsp_id, u8 id) return; } - dce_writel(d, smb_full_ie_regs[hsp_id][id](), val); + dce_os_writel(d, smb_full_ie_regs[hsp_id][id](), val); } /** @@ -155,7 +155,7 @@ u32 dce_smb_read_full_ie_t264(struct tegra_dce *d, u8 hsp_id, u8 id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, smb_full_ie_regs[hsp_id][id]()); + return dce_os_readl(d, smb_full_ie_regs[hsp_id][id]()); } /** @@ -177,7 +177,7 @@ void dce_smb_set_empty_ie_t264(struct tegra_dce *d, bool en, u8 hsp_id, u8 id) return; } - dce_writel(d, smb_empty_ie_regs[hsp_id][id](), val); + dce_os_writel(d, smb_empty_ie_regs[hsp_id][id](), val); } /** @@ -196,7 +196,7 @@ u32 dce_smb_read_t264(struct tegra_dce *d, u8 hsp_id, u8 id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, smb_regs[hsp_id][id]()); + return dce_os_readl(d, smb_regs[hsp_id][id]()); } /** @@ -259,7 +259,7 @@ u32 dce_hsp_ie_read_t264(struct tegra_dce *d, u8 hsp_id, u8 id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, hsp_int_ie_regs[hsp_id][id]()); + return dce_os_readl(d, hsp_int_ie_regs[hsp_id][id]()); } /** @@ -280,8 +280,8 @@ void dce_hsp_ie_write_t264(struct tegra_dce *d, u32 val, u8 hsp_id, u8 id) return; } - dce_writel(d, hsp_int_ie_regs[hsp_id][id](), - val | dce_readl(d, hsp_int_ie_regs[hsp_id][id]())); + dce_os_writel(d, hsp_int_ie_regs[hsp_id][id](), + val | dce_os_readl(d, hsp_int_ie_regs[hsp_id][id]())); } /** @@ -300,5 +300,5 @@ u32 dce_hsp_ir_read_t264(struct tegra_dce *d, u8 hsp_id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, hsp_int_ir_regs[hsp_id]()); + return dce_os_readl(d, hsp_int_ir_regs[hsp_id]()); } diff --git a/drivers/platform/tegra/dce/dce-hsp-smb.c b/drivers/platform/tegra/dce/dce-hsp-smb.c index 23ee7f62..4c31f42a 100644 --- a/drivers/platform/tegra/dce/dce-hsp-smb.c +++ b/drivers/platform/tegra/dce/dce-hsp-smb.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -85,7 +85,7 @@ void dce_smb_set_t234(struct tegra_dce *d, u32 val, u8 hsp_id, u8 id) return; } - dce_writel(d, smb_regs[hsp_id][id](), val); + dce_os_writel(d, smb_regs[hsp_id][id](), val); } /** @@ -107,7 +107,7 @@ void dce_smb_set_full_ie_t234(struct tegra_dce *d, bool en, u8 hsp_id, u8 id) return; } - dce_writel(d, smb_full_ie_regs[hsp_id][id](), val); + dce_os_writel(d, smb_full_ie_regs[hsp_id][id](), val); } /** @@ -126,7 +126,7 @@ u32 dce_smb_read_full_ie_t234(struct tegra_dce *d, u8 hsp_id, u8 id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, smb_full_ie_regs[hsp_id][id]()); + return dce_os_readl(d, smb_full_ie_regs[hsp_id][id]()); } /** @@ -148,7 +148,7 @@ void dce_smb_set_empty_ie_t234(struct tegra_dce *d, bool en, u8 hsp_id, u8 id) return; } - dce_writel(d, smb_empty_ie_regs[hsp_id][id](), val); + dce_os_writel(d, smb_empty_ie_regs[hsp_id][id](), val); } /** @@ -167,7 +167,7 @@ u32 dce_smb_read_t234(struct tegra_dce *d, u8 hsp_id, u8 id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, smb_regs[hsp_id][id]()); + return dce_os_readl(d, smb_regs[hsp_id][id]()); } /** @@ -219,7 +219,7 @@ u32 dce_hsp_ie_read_t234(struct tegra_dce *d, u8 hsp_id, u8 id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, hsp_int_ie_regs[hsp_id][id]()); + return dce_os_readl(d, hsp_int_ie_regs[hsp_id][id]()); } /** @@ -240,8 +240,8 @@ void dce_hsp_ie_write_t234(struct tegra_dce *d, u32 val, u8 hsp_id, u8 id) return; } - dce_writel(d, hsp_int_ie_regs[hsp_id][id](), - val | dce_readl(d, hsp_int_ie_regs[hsp_id][id]())); + dce_os_writel(d, hsp_int_ie_regs[hsp_id][id](), + val | dce_os_readl(d, hsp_int_ie_regs[hsp_id][id]())); } /** @@ -260,5 +260,5 @@ u32 dce_hsp_ir_read_t234(struct tegra_dce *d, u8 hsp_id) return 0xffffffff; /* TODO : Add DCE Error Numbers */ } - return dce_readl(d, hsp_int_ir_regs[hsp_id]()); + return dce_os_readl(d, hsp_int_ir_regs[hsp_id]()); } diff --git a/drivers/platform/tegra/dce/dce-hsp-ss-t264.c b/drivers/platform/tegra/dce/dce-hsp-ss-t264.c index 418f59c4..b8a4c20f 100644 --- a/drivers/platform/tegra/dce/dce-hsp-ss-t264.c +++ b/drivers/platform/tegra/dce/dce-hsp-ss-t264.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include @@ -84,7 +84,7 @@ static u32 (*const ss_state_regs[DCE_MAX_HSP_T264][DCE_MAX_NO_SS_T264])(void) = */ u32 dce_ss_get_state_t264(struct tegra_dce *d, u8 hsp_id, u8 id) { - return dce_readl(d, ss_state_regs[hsp_id][id]()); + return dce_os_readl(d, ss_state_regs[hsp_id][id]()); } /** @@ -116,14 +116,14 @@ void dce_ss_set_t264(struct tegra_dce *d, u8 bpos, u8 hsp_id, u8 id) /** * TODO :Use DCE_INSERT here. */ - dce_bitmap_set(&val, bpos, 1); + dce_os_bitmap_set(&val, bpos, 1); /** * Debug info. please remove */ dce_info(d, "Value after bitmap operation : %lx", val); - dce_writel(d, ss_set_regs[hsp_id][id](), (u32)val); + dce_os_writel(d, ss_set_regs[hsp_id][id](), (u32)val); /** * Debug info. please remove @@ -153,7 +153,7 @@ void dce_ss_clear_t264(struct tegra_dce *d, u8 bpos, u8 hsp_id, u8 id) val = dce_ss_get_state_t264(d, d->hsp_id, id); - dce_bitmap_set(&val, bpos, 1); + dce_os_bitmap_set(&val, bpos, 1); - dce_writel(d, ss_clear_regs[hsp_id][id](), val); + dce_os_writel(d, ss_clear_regs[hsp_id][id](), val); } diff --git a/drivers/platform/tegra/dce/dce-hsp-ss.c b/drivers/platform/tegra/dce/dce-hsp-ss.c index 382320fd..eaf94b00 100644 --- a/drivers/platform/tegra/dce/dce-hsp-ss.c +++ b/drivers/platform/tegra/dce/dce-hsp-ss.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -67,7 +67,7 @@ static u32 (*const ss_state_regs[DCE_MAX_HSP_T234][DCE_MAX_NO_SS_T234])(void) = */ u32 dce_ss_get_state_t234(struct tegra_dce *d, u8 hsp_id, u8 id) { - return dce_readl(d, ss_state_regs[hsp_id][id]()); + return dce_os_readl(d, ss_state_regs[hsp_id][id]()); } /** @@ -99,14 +99,14 @@ void dce_ss_set_t234(struct tegra_dce *d, u8 bpos, u8 hsp_id, u8 id) /** * TODO :Use DCE_INSERT here. */ - dce_bitmap_set(&val, bpos, 1); + dce_os_bitmap_set(&val, bpos, 1); /** * Debug info. please remove */ dce_info(d, "Value after bitmap operation : %lx", val); - dce_writel(d, ss_set_regs[hsp_id][id](), (u32)val); + dce_os_writel(d, ss_set_regs[hsp_id][id](), (u32)val); /** * Debug info. please remove @@ -136,7 +136,7 @@ void dce_ss_clear_t234(struct tegra_dce *d, u8 bpos, u8 hsp_id, u8 id) val = dce_ss_get_state_t234(d, d->hsp_id, id); - dce_bitmap_set(&val, bpos, 1); + dce_os_bitmap_set(&val, bpos, 1); - dce_writel(d, ss_clear_regs[hsp_id][id](), val); + dce_os_writel(d, ss_clear_regs[hsp_id][id](), val); } diff --git a/drivers/platform/tegra/dce/dce-init-deinit.c b/drivers/platform/tegra/dce/dce-init-deinit.c index 553bcbc1..8b8e7d11 100644 --- a/drivers/platform/tegra/dce/dce-init-deinit.c +++ b/drivers/platform/tegra/dce/dce-init-deinit.c @@ -4,7 +4,7 @@ */ #include -#include +#include /** * dce_driver_start - Start executing DCE logic @@ -125,5 +125,5 @@ void dce_driver_deinit(struct tegra_dce *d) dce_boot_interface_deinit(d); - dce_release_fw(d, d->fw_data); + dce_os_release_fw(d, d->fw_data); } diff --git a/drivers/platform/tegra/dce/dce-ipc-signal.c b/drivers/platform/tegra/dce/dce-ipc-signal.c index 107ffa44..b5b898db 100644 --- a/drivers/platform/tegra/dce/dce-ipc-signal.c +++ b/drivers/platform/tegra/dce/dce-ipc-signal.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include static struct dce_ipc_signal_instance *mb_signals[DCE_NUM_MBOX_REGS]; diff --git a/drivers/platform/tegra/dce/dce-ipc.c b/drivers/platform/tegra/dce/dce-ipc.c index 11686584..afd25c3c 100644 --- a/drivers/platform/tegra/dce/dce-ipc.c +++ b/drivers/platform/tegra/dce/dce-ipc.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/drivers/platform/tegra/dce/dce-mailbox.c b/drivers/platform/tegra/dce/dce-mailbox.c index 19ca6d9c..e3b4d1a1 100644 --- a/drivers/platform/tegra/dce/dce-mailbox.c +++ b/drivers/platform/tegra/dce/dce-mailbox.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/drivers/platform/tegra/dce/dce-module.c b/drivers/platform/tegra/dce/dce-module.c index b7e86b5b..9364b38e 100644 --- a/drivers/platform/tegra/dce/dce-module.c +++ b/drivers/platform/tegra/dce/dce-module.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ MODULE_DEVICE_TABLE(of, tegra_dce_of_match); */ static inline struct tegra_dce *dce_get_pdata_dce(struct platform_device *pdev) { - return (&((struct dce_device *)dev_get_drvdata(&pdev->dev))->d); + return (&((struct dce_os_device *)dev_get_drvdata(&pdev->dev))->d); } /** @@ -76,7 +76,7 @@ static inline struct tegra_dce *dce_get_pdata_dce(struct platform_device *pdev) */ static inline struct tegra_dce *dce_get_tegra_dce_from_dev(struct device *dev) { - return (&((struct dce_device *)dev_get_drvdata(dev))->d); + return (&((struct dce_os_device *)dev_get_drvdata(dev))->d); } /** @@ -92,7 +92,7 @@ static inline struct tegra_dce *dce_get_tegra_dce_from_dev(struct device *dev) static int dce_init_dev_data(struct platform_device *pdev, struct dce_platform_data *pdata) { struct device *dev = &pdev->dev; - struct dce_device *d_dev = NULL; + struct dce_os_device *d_dev = NULL; d_dev = devm_kzalloc(dev, sizeof(*d_dev), GFP_KERNEL); if (!d_dev) @@ -126,7 +126,7 @@ static void dce_set_irqs(struct platform_device *pdev, bool en) { int i = 0; struct tegra_dce *d; - struct dce_device *d_dev = NULL; + struct dce_os_device *d_dev = NULL; d_dev = dev_get_drvdata(&pdev->dev); d = dce_get_pdata_dce(pdev); @@ -152,7 +152,7 @@ static int dce_req_interrupts(struct platform_device *pdev) int ret = 0; int no_ints = 0; struct tegra_dce *d; - struct dce_device *d_dev = NULL; + struct dce_os_device *d_dev = NULL; d_dev = dev_get_drvdata(&pdev->dev); d = dce_get_pdata_dce(pdev); diff --git a/drivers/platform/tegra/dce/dce-util-common.c b/drivers/platform/tegra/dce/dce-os-utils.c similarity index 85% rename from drivers/platform/tegra/dce/dce-util-common.c rename to drivers/platform/tegra/dce/dce-os-utils.c index 505aac30..04f6ac7e 100644 --- a/drivers/platform/tegra/dce/dce-util-common.c +++ b/drivers/platform/tegra/dce/dce-os-utils.c @@ -4,17 +4,24 @@ */ #include #include -#include -#include +#include +#include #include #include #include #include #include #include +#include +#include /** - * dce_writel - Dce io function to perform MMIO writes + * Do not add any more util functions to this file. + * We should add OS util functions to respective OS module files. + */ + +/** + * dce_os_writel - Dce io function to perform MMIO writes * * @d : Pointer to tegra_dce struct. * @r : register offset from dce_base. @@ -22,9 +29,9 @@ * * Return : Void */ -void dce_writel(struct tegra_dce *d, u32 r, u32 v) +void dce_os_writel(struct tegra_dce *d, u32 r, u32 v) { - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); if (unlikely(!d_dev->regs)) dce_err(d, "DCE Register Space not IOMAPed to CPU"); @@ -33,18 +40,18 @@ void dce_writel(struct tegra_dce *d, u32 r, u32 v) } /** - * dce_readl - Dce io function to perform MMIO reads + * dce_os_readl - Dce io function to perform MMIO reads * * @d : Pointer to tegra_dce struct. * @r : register offset from dce_base. * * Return : the read value */ -u32 dce_readl(struct tegra_dce *d, u32 r) +u32 dce_os_readl(struct tegra_dce *d, u32 r) { u32 v = 0xffffffff; - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); if (unlikely(!d_dev->regs)) dce_err(d, "DCE Register Space not IOMAPed to CPU"); @@ -55,7 +62,7 @@ u32 dce_readl(struct tegra_dce *d, u32 r) } /** - * dce_writel_check - Performs MMIO writes and checks if the writes + * dce_os_writel_check - Performs MMIO writes and checks if the writes * are actaully correct. * * @d : Pointer to tegra_dce struct. @@ -64,28 +71,28 @@ u32 dce_readl(struct tegra_dce *d, u32 r) * * Return : Void */ -void dce_writel_check(struct tegra_dce *d, u32 r, u32 v) +void dce_os_writel_check(struct tegra_dce *d, u32 r, u32 v) { /* TODO : Write and read back to check */ } /** - * dce_io_exists - Dce io function to check if the registers are mapped + * dce_os_io_exists - Dce io function to check if the registers are mapped * to CPU correctly * * @d : Pointer to tegra_dce struct. * * Return : True if mapped. */ -bool dce_io_exists(struct tegra_dce *d) +bool dce_os_io_exists(struct tegra_dce *d) { - struct dce_device *d_dev = dce_device_from_dce(d); + struct dce_os_device *d_dev = dce_os_device_from_dce(d); return d_dev->regs != NULL; } /** - * dce_io_valid_regs - Dce io function to check if the requested offset is + * dce_os_io_valid_reg - Dce io function to check if the requested offset is * within the range of CPU mapped MMIO range. * * @d : Pointer to tegra_dce struct. @@ -93,14 +100,14 @@ bool dce_io_exists(struct tegra_dce *d) * * Return : True if offset within range. */ -bool dce_io_valid_reg(struct tegra_dce *d, u32 r) +bool dce_os_io_valid_reg(struct tegra_dce *d, u32 r) { /* TODO : Implement range check here. Returning true for now*/ return true; } /** - * dce_kzalloc - Function to allocate contiguous kernel memory + * dce_os_kzalloc - Function to allocate contiguous kernel memory * * @d : Pointer to tegra_dce struct. * @size_t : Size of the memory to be allocated @@ -108,7 +115,7 @@ bool dce_io_valid_reg(struct tegra_dce *d, u32 r) * * Return : CPU Mapped Address if successful else NULL. */ -void *dce_kzalloc(struct tegra_dce *d, size_t size, bool dma_flag) +void *dce_os_kzalloc(struct tegra_dce *d, size_t size, bool dma_flag) { void *alloc; gfp_t flags = GFP_KERNEL; @@ -122,34 +129,34 @@ void *dce_kzalloc(struct tegra_dce *d, size_t size, bool dma_flag) } /** - * dce_kfree - Frees an alloc from dce_kzalloc + * dce_os_kfree - Frees an alloc from dce_os_kzalloc * * @d : Pointer to tegra_dce struct. * @addr : Address of the object to free. * * Return : void */ -void dce_kfree(struct tegra_dce *d, void *addr) +void dce_os_kfree(struct tegra_dce *d, void *addr) { kfree(addr); } /** - * dce_request_firmware - Reads the fw into memory. + * dce_os_request_firmware - Reads the fw into memory. * * @d : Pointer to tegra_dce struct. * @fw_name : Name of the fw. * * Return : Pointer to dce_firmware if successful else NULL. */ -struct dce_firmware *dce_request_firmware(struct tegra_dce *d, +struct dce_firmware *dce_os_request_firmware(struct tegra_dce *d, const char *fw_name) { struct device *dev = dev_from_dce(d); struct dce_firmware *fw; const struct firmware *l_fw; - fw = dce_kzalloc(d, sizeof(*fw), false); + fw = dce_os_kzalloc(d, sizeof(*fw), false); if (!fw) return NULL; @@ -187,7 +194,7 @@ struct dce_firmware *dce_request_firmware(struct tegra_dce *d, err_release: release_firmware(l_fw); err: - dce_kfree(d, fw); + dce_os_kfree(d, fw); return NULL; } @@ -199,7 +206,7 @@ err: * * Return : void */ -void dce_release_fw(struct tegra_dce *d, struct dce_firmware *fw) +void dce_os_release_fw(struct tegra_dce *d, struct dce_firmware *fw) { struct device *dev = dev_from_dce(d); @@ -210,7 +217,7 @@ void dce_release_fw(struct tegra_dce *d, struct dce_firmware *fw) (void *)fw->data, (dma_addr_t)fw->dma_handle); - dce_kfree(d, fw); + dce_os_kfree(d, fw); } /** @@ -571,14 +578,14 @@ void dce_thread_join(struct dce_thread *thread) }; /** - * dce_get_nxt_pow_of_2 : get next power of 2 number for a given number + * dce_os_get_nxt_pow_of_2 : get next power of 2 number for a given number * * @addr : Address of given number * @nbits : bits in given number * * Return : unsigned long next power of 2 value */ -unsigned long dce_get_nxt_pow_of_2(unsigned long *addr, u8 nbits) +unsigned long dce_os_get_nxt_pow_of_2(unsigned long *addr, u8 nbits) { u8 l_bit = 0; u8 bit_index = 0; @@ -604,7 +611,7 @@ unsigned long dce_get_nxt_pow_of_2(unsigned long *addr, u8 nbits) } /* - * dce_usleep_range : sleep between min-max range + * dce_os_usleep_range : sleep between min-max range * * @min : minimum sleep time in usec * @max : maximum sleep time in usec @@ -612,7 +619,7 @@ unsigned long dce_get_nxt_pow_of_2(unsigned long *addr, u8 nbits) * Return : void */ -void dce_usleep_range(unsigned long min, unsigned long max) +void dce_os_usleep_range(unsigned long min, unsigned long max) { usleep_range(min, max); } @@ -695,7 +702,7 @@ static int ipc_allocate_region(struct tegra_dce *d) ); tot_ivc_q_sz = tegra_ivc_total_queue_size(tot_q_sz); - region->size = dce_get_nxt_pow_of_2(&tot_ivc_q_sz, 32); + region->size = dce_os_get_nxt_pow_of_2(&tot_ivc_q_sz, 32); region->base = dma_alloc_coherent(dev, region->size, ®ion->iova, GFP_KERNEL | __GFP_ZERO); if (!region->base) @@ -751,3 +758,33 @@ void dce_ipc_deinit_region_info(struct tegra_dce *d) { return ipc_free_region(d); } + +/** + * dce_os_bitmap_set - Set bits in a bitmap + * + * @map : Pointer to map + * @start : Start bit + * @len : Length indicating number of bits to set. + * + * Return : Void + */ +void dce_os_bitmap_set(unsigned long *map, + unsigned int start, unsigned int len) +{ + bitmap_set(map, start, (int)len); +} + +/** + * dce_os_bitmap_set - Set bits in a bitmap + * + * @map : Pointer to map + * @start : Start bit + * @len : Length indicating number of bits to clear. + * + * Return : Void + */ +void dce_os_bitmap_clear(unsigned long *map, + unsigned int start, unsigned int len) +{ + bitmap_clear(map, start, (int)len); +} diff --git a/drivers/platform/tegra/dce/dce-pm.c b/drivers/platform/tegra/dce/dce-pm.c index 6f53be29..59b62d5c 100644 --- a/drivers/platform/tegra/dce/dce-pm.c +++ b/drivers/platform/tegra/dce/dce-pm.c @@ -4,7 +4,7 @@ */ #include -#include +#include #define CCPLEX_HSP_IE 1U /* TODO : Have an api to read from platform data */ diff --git a/drivers/platform/tegra/dce/dce-reset.c b/drivers/platform/tegra/dce/dce-reset.c index 55426397..d0a812c8 100644 --- a/drivers/platform/tegra/dce/dce-reset.c +++ b/drivers/platform/tegra/dce/dce-reset.c @@ -5,7 +5,7 @@ #include #include -#include +#include enum pm_controls { FW_LOAD_HALTED, @@ -22,7 +22,7 @@ enum pm_controls { */ static inline void dce_evp_set_reset_addr(struct tegra_dce *d, u32 addr) { - dce_writel(d, evp_reset_addr_r(), addr); + dce_os_writel(d, evp_reset_addr_r(), addr); } /** @@ -37,10 +37,10 @@ static void dce_pm_set_pm_ctrl(struct tegra_dce *d, enum pm_controls val) { switch (val) { case FW_LOAD_DONE: - dce_writel(d, pm_r5_ctrl_r(), pm_r5_ctrl_fwloaddone_done_f()); + dce_os_writel(d, pm_r5_ctrl_r(), pm_r5_ctrl_fwloaddone_done_f()); break; case FW_LOAD_HALTED: - dce_writel(d, pm_r5_ctrl_r(), pm_r5_ctrl_fwloaddone_halted_f()); + dce_os_writel(d, pm_r5_ctrl_r(), pm_r5_ctrl_fwloaddone_halted_f()); break; default: break; diff --git a/drivers/platform/tegra/dce/dce-worker.c b/drivers/platform/tegra/dce/dce-worker.c index ea054d20..ce413f9b 100644 --- a/drivers/platform/tegra/dce/dce-worker.c +++ b/drivers/platform/tegra/dce/dce-worker.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include /* @@ -35,9 +35,9 @@ int dce_wait_interruptible(struct tegra_dce *d, u32 msg_id) * Will be "1" and we immediately exit from the wait. */ DCE_COND_WAIT_INTERRUPTIBLE(&wait->cond_wait, - os_atomic_read(&wait->complete) == 1); + dce_os_atomic_read(&wait->complete) == 1); - if (os_atomic_read(&wait->complete) != 1) + if (dce_os_atomic_read(&wait->complete) != 1) return -EINTR; /* @@ -45,7 +45,7 @@ int dce_wait_interruptible(struct tegra_dce *d, u32 msg_id) * So that when the next dce_wait_interruptible is called, it doesn't see old * wait->complete state. */ - os_atomic_set(&wait->complete, 0); + dce_os_atomic_set(&wait->complete, 0); return 0; } @@ -73,7 +73,7 @@ void dce_wakeup_interruptible(struct tegra_dce *d, u32 msg_id) * "dce_cond_signal_interruptible", it'll see the complete variable * as "1" and exit the wait immediately. */ - os_atomic_set(&wait->complete, 1); + dce_os_atomic_set(&wait->complete, 1); dce_cond_signal_interruptible(&wait->cond_wait); } @@ -95,7 +95,7 @@ void dce_cond_wait_reset(struct tegra_dce *d, u32 msg_id) } wait = &d->ipc_waits[msg_id]; - os_atomic_set(&wait->complete, 0); + dce_os_atomic_set(&wait->complete, 0); } /** @@ -125,7 +125,7 @@ int dce_work_cond_sw_resource_init(struct tegra_dce *d) goto init_error; } - os_atomic_set(&wait->complete, 0); + dce_os_atomic_set(&wait->complete, 0); } return 0; @@ -156,7 +156,7 @@ void dce_work_cond_sw_resource_deinit(struct tegra_dce *d) struct dce_wait_cond *wait = &d->ipc_waits[i]; dce_cond_destroy(&wait->cond_wait); - os_atomic_set(&wait->complete, 0); + dce_os_atomic_set(&wait->complete, 0); } dce_cond_destroy(&d->dce_bootstrap_done); diff --git a/drivers/platform/tegra/dce/include/dce-client-ipc-internal.h b/drivers/platform/tegra/dce/include/dce-client-ipc-internal.h index 02da224e..10e79f9e 100644 --- a/drivers/platform/tegra/dce/include/dce-client-ipc-internal.h +++ b/drivers/platform/tegra/dce/include/dce-client-ipc-internal.h @@ -7,7 +7,7 @@ #define DCE_CLIENT_IPC_INTERNAL_H #include -#include +#include /** * struct tegra_dce_client_ipc - Data Structure to hold client specific ipc @@ -34,7 +34,7 @@ struct tegra_dce_client_ipc { uint32_t int_type; struct tegra_dce *d; struct dce_cond recv_wait; - os_atomic_t complete; + dce_os_atomic_t complete; tegra_dce_client_ipc_callback_t callback_fn; }; @@ -42,7 +42,7 @@ struct tegra_dce_client_ipc { struct dce_async_work { struct tegra_dce *d; struct work_struct async_event_work; - os_atomic_t in_use; + dce_os_atomic_t in_use; }; /** diff --git a/drivers/platform/tegra/dce/include/dce-util-common.h b/drivers/platform/tegra/dce/include/dce-util-common.h deleted file mode 100644 index 243d615d..00000000 --- a/drivers/platform/tegra/dce/include/dce-util-common.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - */ - -#ifndef DCE_UTIL_COMMON_H -#define DCE_UTIL_COMMON_H - -#include -#include -#include -#include - -/** - * This file contains all dce common fucntions and data strutcures which are - * abstarcted out from the operating system. The underlying OS layer will - * implement the pertinent low level details. This design is to make sure that - * dce cpu driver can be leveraged across multiple OSes if the neede arises. - */ - -struct tegra_dce; - -void dce_writel(struct tegra_dce *d, u32 r, u32 v); - -u32 dce_readl(struct tegra_dce *d, u32 r); - -void dce_writel_check(struct tegra_dce *d, u32 r, u32 v); - -bool dce_io_exists(struct tegra_dce *d); - -bool dce_io_valid_reg(struct tegra_dce *d, u32 r); - -struct dce_firmware *dce_request_firmware(struct tegra_dce *d, - const char *fw_name); - -void dce_release_fw(struct tegra_dce *d, struct dce_firmware *fw); - -void *dce_kzalloc(struct tegra_dce *d, size_t size, bool dma_flag); - -void dce_kfree(struct tegra_dce *d, void *addr); - -unsigned long dce_get_nxt_pow_of_2(unsigned long *addr, u8 nbits); - -void dce_usleep_range(unsigned long min, unsigned long max); - -static inline void dce_bitmap_set(unsigned long *map, - unsigned int start, unsigned int len) -{ - bitmap_set(map, start, (int)len); -} - -static inline void dce_bitmap_clear(unsigned long *map, - unsigned int start, unsigned int len) -{ - bitmap_clear(map, start, (int)len); -} - -#endif diff --git a/drivers/platform/tegra/dce/include/dce-worker.h b/drivers/platform/tegra/dce/include/dce-worker.h index 450a30ec..45ae9f8c 100644 --- a/drivers/platform/tegra/dce/include/dce-worker.h +++ b/drivers/platform/tegra/dce/include/dce-worker.h @@ -8,7 +8,7 @@ #include #include -#include +#include struct tegra_dce; @@ -20,7 +20,7 @@ struct tegra_dce; #define DCE_MAX_WAIT 5 struct dce_wait_cond { - os_atomic_t complete; + dce_os_atomic_t complete; struct dce_cond cond_wait; }; diff --git a/drivers/platform/tegra/dce/os/include/atomic.h b/drivers/platform/tegra/dce/os/include/atomic.h deleted file mode 100644 index 99b4231f..00000000 --- a/drivers/platform/tegra/dce/os/include/atomic.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: LicenseRef-NvidiaProprietary - * - * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual - * property and proprietary rights in and to this material, related - * documentation and any modifications thereto. Any use, reproduction, - * disclosure or distribution of this material and related documentation - * without an express license agreement from NVIDIA CORPORATION or - * its affiliates is strictly prohibited. - */ - -#ifndef NVDISPLAY_SERVER_ATOMIC_H -#define NVDISPLAY_SERVER_ATOMIC_H - -#ifdef __KERNEL__ -#include -#elif defined(NVDISPLAY_SERVER_HVRTOS) -#include -#else -#error "OS Not Supported" -#endif - -#endif /* NVDISPLAY_SERVER_ATOMIC_H */ diff --git a/drivers/platform/tegra/dce/os/include/dce-os-utils.h b/drivers/platform/tegra/dce/os/include/dce-os-utils.h new file mode 100644 index 00000000..739c3d1d --- /dev/null +++ b/drivers/platform/tegra/dce/os/include/dce-os-utils.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + */ + +#ifndef DCE_OS_UTILS_H +#define DCE_OS_UTILS_H + +#include + +/** + * Do not add any more util functions to this file. + * We should add OS util functions to respective OS module files. + */ + +struct tegra_dce; + +void dce_os_writel(struct tegra_dce *d, u32 r, u32 v); + +u32 dce_os_readl(struct tegra_dce *d, u32 r); + +void dce_os_writel_check(struct tegra_dce *d, u32 r, u32 v); + +bool dce_os_io_exists(struct tegra_dce *d); + +bool dce_os_io_valid_reg(struct tegra_dce *d, u32 r); + +struct dce_firmware *dce_os_request_firmware(struct tegra_dce *d, + const char *fw_name); + +void dce_os_release_fw(struct tegra_dce *d, struct dce_firmware *fw); + +void *dce_os_kzalloc(struct tegra_dce *d, size_t size, bool dma_flag); + +void dce_os_kfree(struct tegra_dce *d, void *addr); + +unsigned long dce_os_get_nxt_pow_of_2(unsigned long *addr, u8 nbits); + +void dce_os_usleep_range(unsigned long min, unsigned long max); + +void dce_os_bitmap_set(unsigned long *map, + unsigned int start, unsigned int len); + +void dce_os_bitmap_clear(unsigned long *map, + unsigned int start, unsigned int len); + +#endif /* DCE_OS_UTILS_H */ diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h b/drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h deleted file mode 100644 index 8985cbae..00000000 --- a/drivers/platform/tegra/dce/os/include/linux-kmd/atomic.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: LicenseRef-NvidiaProprietary - * - * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual - * property and proprietary rights in and to this material, related - * documentation and any modifications thereto. Any use, reproduction, - * disclosure or distribution of this material and related documentation - * without an express license agreement from NVIDIA CORPORATION or - * its affiliates is strictly prohibited. - */ - -#ifndef NVDISPLAY_SERVER_ATOMIC_LINUX_H -#define NVDISPLAY_SERVER_ATOMIC_LINUX_H - -#include - -/** 32 bit atomic variable. */ -typedef atomic_t os_atomic_t; - -static inline void os_atomic_set(os_atomic_t *v, int i) -{ - atomic_set(v, i); - return; -} - -static inline int os_atomic_read(os_atomic_t *v) -{ - return atomic_read(v); -} - -static inline int os_atomic_add_unless(os_atomic_t *v, int a, int u) -{ - return atomic_add_unless(v, a, u); -} - -#endif /* NVDISPLAY_SERVER_ATOMIC_LINUX_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h b/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h deleted file mode 100644 index 0cadf25a..00000000 --- a/drivers/platform/tegra/dce/os/include/linux-kmd/os-dce-device.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: LicenseRef-NvidiaProprietary - * - * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual - * property and proprietary rights in and to this material, related - * documentation and any modifications thereto. Any use, reproduction, - * disclosure or distribution of this material and related documentation - * without an express license agreement from NVIDIA CORPORATION or - * its affiliates is strictly prohibited. - */ - -#ifndef NVDISPLAY_SERVER_OS_DCE_DEVICE_LINUX_H -#define NVDISPLAY_SERVER_OS_DCE_DEVICE_LINUX_H - -#include -#include -#include - -/** - * struct dce_device - DCE data structure for storing - * linux device specific info. - */ -struct dce_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_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_device - */ -static inline struct dce_device *dce_device_from_dce(struct tegra_dce *d) -{ - return container_of(d, struct dce_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_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_device *)dev_get_drvdata(dev_from_dce(d)))->pdata; -} - -#endif /* NVDISPLAY_SERVER_OS_DCE_DEVICE_LINUX_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/linux/os-types.h b/drivers/platform/tegra/dce/os/include/linux/os-types.h deleted file mode 100644 index 35925a2f..00000000 --- a/drivers/platform/tegra/dce/os/include/linux/os-types.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - */ - -#ifndef OS_TYPES_H -#define OS_TYPES_H - -#include - -#endif /* OS_TYPES_H */ diff --git a/drivers/platform/tegra/dce/os/include/os-dce-device.h b/drivers/platform/tegra/dce/os/include/os-dce-device.h deleted file mode 100644 index 4e6a6c63..00000000 --- a/drivers/platform/tegra/dce/os/include/os-dce-device.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: LicenseRef-NvidiaProprietary - * - * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual - * property and proprietary rights in and to this material, related - * documentation and any modifications thereto. Any use, reproduction, - * disclosure or distribution of this material and related documentation - * without an express license agreement from NVIDIA CORPORATION or - * its affiliates is strictly prohibited. - */ - -#ifndef NVDISPLAY_SERVER_OS_DCE_DEVICE_H -#define NVDISPLAY_SERVER_OS_DCE_DEVICE_H - -#ifdef __KERNEL__ -#include -#elif defined(NVDISPLAY_SERVER_HVRTOS) -#include -#else -#error "OS Not Supported" -#endif - -#endif /* NVDISPLAY_SERVER_OS_DCE_DEVICE_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/include/os-utils.h b/drivers/platform/tegra/dce/os/include/os-utils.h deleted file mode 100644 index b69f4281..00000000 --- a/drivers/platform/tegra/dce/os/include/os-utils.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: LicenseRef-NvidiaProprietary - * - * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual - * property and proprietary rights in and to this material, related - * documentation and any modifications thereto. Any use, reproduction, - * disclosure or distribution of this material and related documentation - * without an express license agreement from NVIDIA CORPORATION or - * its affiliates is strictly prohibited. - */ - -#ifndef NVDISPLAY_SERVER_OS_UTILS_H -#define NVDISPLAY_SERVER_OS_UTILS_H - -#ifdef __KERNEL__ -#include -#elif defined(NVDISPLAY_SERVER_HVRTOS) -#include -#else -#error "OS Not Supported" -#endif - -#endif /* NVDISPLAY_SERVER_OS_UTILS_H */ \ No newline at end of file diff --git a/drivers/platform/tegra/dce/os/linux/include/dce-os-atomic.h b/drivers/platform/tegra/dce/os/linux/include/dce-os-atomic.h new file mode 100644 index 00000000..9b471348 --- /dev/null +++ b/drivers/platform/tegra/dce/os/linux/include/dce-os-atomic.h @@ -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 + +/** 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 */ diff --git a/drivers/platform/tegra/dce/os/linux/include/dce-os-device.h b/drivers/platform/tegra/dce/os/linux/include/dce-os-device.h new file mode 100644 index 00000000..e41f9ca9 --- /dev/null +++ b/drivers/platform/tegra/dce/os/linux/include/dce-os-device.h @@ -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 +#include +#include + +/** + * 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 */ diff --git a/drivers/platform/tegra/dce/os/interface/include/dce-os-types.h b/drivers/platform/tegra/dce/os/linux/include/dce-os-types.h similarity index 90% rename from drivers/platform/tegra/dce/os/interface/include/dce-os-types.h rename to drivers/platform/tegra/dce/os/linux/include/dce-os-types.h index c0bdb6f6..fce3bc12 100644 --- a/drivers/platform/tegra/dce/os/interface/include/dce-os-types.h +++ b/drivers/platform/tegra/dce/os/linux/include/dce-os-types.h @@ -6,6 +6,6 @@ #ifndef DCE_OS_TYPES_H #define DCE_OS_TYPES_H -#include +#include #endif /* DCE_OS_TYPES_H */