diff --git a/drivers/misc/mods/Makefile b/drivers/misc/mods/Makefile index f7b5b037..d044e8d7 100644 --- a/drivers/misc/mods/Makefile +++ b/drivers/misc/mods/Makefile @@ -10,6 +10,7 @@ mods-$(CONFIG_PCI) += mods_pci.o mods-$(CONFIG_ACPI) += mods_acpi.o mods-$(CONFIG_DMA_SHARED_BUFFER) += mods_dmabuf.o mods-$(CONFIG_ARCH_TEGRA) += mods_smmu_drv.o +mods-$(CONFIG_ARCH_TEGRA) += mods_oist.o mods-$(CONFIG_DMA_ENGINE) += mods_dma.o mods-$(CONFIG_DEBUG_FS) += mods_debugfs.o mods-$(CONFIG_TEGRA_DC) += mods_tegradc.o diff --git a/drivers/misc/mods/mods_internal.h b/drivers/misc/mods/mods_internal.h index 8ff97887..a69430ac 100644 --- a/drivers/misc/mods/mods_internal.h +++ b/drivers/misc/mods/mods_internal.h @@ -2,7 +2,7 @@ /* * mods_internal.h - This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2008-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2008-2022, NVIDIA CORPORATION. All rights reserved. * * NVIDIA MODS kernel driver is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -637,6 +637,10 @@ int esc_mods_dma_free_coherent(struct mods_client *client, int esc_mods_dma_copy_to_user(struct mods_client *client, struct MODS_DMA_COPY_TO_USER *p); +/* oist */ +int esc_mods_oist_status(struct mods_client *client, + struct MODS_TEGRA_OIST_STATUS *p); + #ifdef CONFIG_DMA_ENGINE int esc_mods_dma_request_channel(struct mods_client *client, struct MODS_DMA_HANDLE *p); diff --git a/drivers/misc/mods/mods_krnl.c b/drivers/misc/mods/mods_krnl.c index 1f1340b2..34df1345 100644 --- a/drivers/misc/mods/mods_krnl.c +++ b/drivers/misc/mods/mods_krnl.c @@ -2,7 +2,7 @@ /* * mods_krnl.c - This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2008-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2008-2022, NVIDIA CORPORATION. All rights reserved. * * NVIDIA MODS kernel driver is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -2546,6 +2546,11 @@ static long mods_krnl_ioctl(struct file *fp, MODS_IOCTL(MODS_ESC_SEND_TZ_MSG, esc_mods_send_trustzone_msg, MODS_TZ_PARAMS); break; + + case MODS_ESC_OIST_STATUS: + MODS_IOCTL(MODS_ESC_OIST_STATUS, + esc_mods_oist_status, MODS_TEGRA_OIST_STATUS); + break; #endif case MODS_ESC_ACQUIRE_ACCESS_TOKEN: diff --git a/drivers/misc/mods/mods_oist.c b/drivers/misc/mods/mods_oist.c new file mode 100644 index 00000000..db104947 --- /dev/null +++ b/drivers/misc/mods/mods_oist.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022, 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. + */ + +#include "mods_internal.h" +#include + +#define SMCCC_VERSION 0x80000000 + +int esc_mods_oist_status(struct mods_client *client, + struct MODS_TEGRA_OIST_STATUS *p) +{ + int ret = 0; + struct arm_smccc_res res = { 0 }; + + if (p->smc_func_id == SMCCC_VERSION) { + // For SMC version, We are only reading res.a0 value, not a1,a2,a3 + arm_smccc_1_1_smc(p->smc_func_id, res.a0, &res); + p->smc_status = res.a0; + } else { + arm_smccc_1_1_smc(p->smc_func_id, p->a1, p->a2, &res); + p->smc_status = res.a1; + } + + return ret; +} diff --git a/include/uapi/misc/mods.h b/include/uapi/misc/mods.h index fda0f329..6277b861 100644 --- a/include/uapi/misc/mods.h +++ b/include/uapi/misc/mods.h @@ -2,7 +2,7 @@ /* * mods.h - This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2008-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2008-2022, NVIDIA CORPORATION. All rights reserved. * * NVIDIA MODS kernel driver is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -1795,6 +1795,21 @@ struct MODS_TZ_PARAMS { int status; }; +/* Used by MODS_ESC_OIST_STATUS ioctl. + * + * Available only on Tegra. + */ +struct MODS_TEGRA_OIST_STATUS { + /* IN */ + __u64 smc_func_id; + /* IN */ + __u64 a1; + /* IN */ + __u64 a2; + /* OUT */ + __u64 smc_status; +}; + #define MODS_IOMMU_MAP_CONTIGUOUS 1 #pragma pack(pop) @@ -1995,5 +2010,6 @@ struct MODS_TZ_PARAMS { #define MODS_ESC_BPMP_SET_PCIE_STATE MODSIO(W, 136, MODS_SET_PCIE_STATE) #define MODS_ESC_BPMP_INIT_PCIE_EP_PLL MODSIO(W, 137, MODS_INIT_PCIE_EP_PLL) #define MODS_ESC_SEND_TZ_MSG MODSIO(WR, 139, MODS_TZ_PARAMS) +#define MODS_ESC_OIST_STATUS MODSIO(WR, 140, MODS_TEGRA_OIST_STATUS) #endif /* _UAPI_MODS_H_ */