mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-25 02:32:08 +03:00
Compare commits
101 Commits
rel-38
...
rel-36_eng
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b6db0ce3c | ||
|
|
26e357d588 | ||
|
|
7635873f3d | ||
|
|
176a1bff8d | ||
|
|
e997e8ae5a | ||
|
|
d1c969184b | ||
|
|
e02b9efcc4 | ||
|
|
2ac404f410 | ||
|
|
e7868529f3 | ||
|
|
3f5ba8f70b | ||
|
|
f1f3771dec | ||
|
|
e30e21ebd1 | ||
|
|
ac6a53078b | ||
|
|
56c05f8e3f | ||
|
|
822abd1943 | ||
|
|
71876127a2 | ||
|
|
abeacc3534 | ||
|
|
902712a236 | ||
|
|
ff6f3c6916 | ||
|
|
11e0abc8a3 | ||
|
|
5d31085674 | ||
|
|
a86b3af506 | ||
|
|
32f23c8ab2 | ||
|
|
259736545b | ||
|
|
34fd7d68dc | ||
|
|
4a32aa94e5 | ||
|
|
e4d4103ebe | ||
|
|
7abc2d8726 | ||
|
|
f8e977a8c9 | ||
|
|
1f0954f43d | ||
|
|
711d4aee8d | ||
|
|
afe9bdc7c0 | ||
|
|
5b4a093e24 | ||
|
|
14abda2794 | ||
|
|
6ad6325734 | ||
|
|
a39a2be24e | ||
|
|
9c2c4a695c | ||
|
|
3a35e1c2b1 | ||
|
|
0d940461d4 | ||
|
|
e3fc979712 | ||
|
|
e3f7ab90e1 | ||
|
|
2fc926c8fe | ||
|
|
f7d42ed1c4 | ||
|
|
560b7c1345 | ||
|
|
e94f3bb6d8 | ||
|
|
82f8d2b998 | ||
|
|
b27e2e49de | ||
|
|
a6fc43ecb8 | ||
|
|
c61a3c670f | ||
|
|
ce24d01296 | ||
|
|
a77844b17d | ||
|
|
cef95180b3 | ||
|
|
c0beaa46b5 | ||
|
|
9bfb2e35b7 | ||
|
|
11670f570d | ||
|
|
f255a170a7 | ||
|
|
020bdeded8 | ||
|
|
e1471516b0 | ||
|
|
0ca520ee30 | ||
|
|
6b290b7f84 | ||
|
|
b5178e70d8 | ||
|
|
efbbf91f79 | ||
|
|
29ab9b19c9 | ||
|
|
1432eb248d | ||
|
|
4ab98ef641 | ||
|
|
7f9beef481 | ||
|
|
069d6bb3eb | ||
|
|
7f3751f642 | ||
|
|
e91b43420c | ||
|
|
5b6fed0199 | ||
|
|
7c4bfe82b2 | ||
|
|
1b537bff19 | ||
|
|
75363cdd58 | ||
|
|
09b54bda42 | ||
|
|
4a1a87890d | ||
|
|
ab8b8a6c84 | ||
|
|
9c77439e40 | ||
|
|
715c34434f | ||
|
|
c196de1377 | ||
|
|
0940779cd6 | ||
|
|
029ade906d | ||
|
|
b5d808a6ff | ||
|
|
6fe3abc899 | ||
|
|
a6701b19b9 | ||
|
|
daec781815 | ||
|
|
60adf47e0f | ||
|
|
7997b6e8b0 | ||
|
|
b02f2cd5ee | ||
|
|
ee4493d7bf | ||
|
|
9c2150982a | ||
|
|
9e94468082 | ||
|
|
4f1d3dbeb3 | ||
|
|
4da134034b | ||
|
|
2527826ca1 | ||
|
|
5fe2e2aacc | ||
|
|
067fbd7bbc | ||
|
|
856471d64f | ||
|
|
a3b3ef5cab | ||
|
|
7ffd0c9cfa | ||
|
|
7ff7dcd36a | ||
|
|
c0bc0aa39c |
60
Makefile
60
Makefile
@@ -1,67 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
|
||||
LINUXINCLUDE += -I$(srctree.nvconftest)
|
||||
LINUXINCLUDE += -I$(srctree.nvidia-oot)/include
|
||||
|
||||
subdir-ccflags-y += -Werror
|
||||
|
||||
LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL))
|
||||
LINUX_VERSION_6_2 := $(shell expr 6 \* 256 + 2)
|
||||
LINUX_VERSION_6_3 := $(shell expr 6 \* 256 + 3)
|
||||
LINUX_VERSION_6_6 := $(shell expr 6 \* 256 + 6)
|
||||
|
||||
# The Tegra IVC driver was updated to support iosys-map in Linux v6.2.
|
||||
# For Linux v6.2 kernels, don't build any drivers that requires this.
|
||||
ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_2); echo $$?),0)
|
||||
export CONFIG_TEGRA_IVC_LEGACY_DISABLE=y
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y)
|
||||
subdir-ccflags-y += -DCONFIG_TEGRA_IVC_LEGACY_DISABLE
|
||||
endif
|
||||
|
||||
# Legacy GPIO support is removed in Linux v6.3
|
||||
ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_3); echo $$?),0)
|
||||
export CONFIG_TEGRA_GPIO_LEGACY_DISABLE=y
|
||||
endif
|
||||
|
||||
# Changes done in Linux 6.6 onwards
|
||||
ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_6); echo $$?),0)
|
||||
# Move probe to DAI Ops.
|
||||
export CONFIG_SND_SOC_MOVE_DAI_PROBE_TO_OPS=y
|
||||
subdir-ccflags-y += -DNV_SND_SOC_DAI_OPS_STRUCT_HAS_PROBE_ARG
|
||||
|
||||
# probe_new is removed from i2c driver structure
|
||||
subdir-ccflags-y += -DNV_I2C_LEGACY_PROBE_NEW_REMOVED
|
||||
|
||||
# API changes to replace u8 with unsigned char
|
||||
subdir-ccflags-y += -DNV_TTY_SERIAL_TYPE_U8_CHANGE
|
||||
|
||||
# v4l2_async_subdev is renamed to v4l2_async_connection.
|
||||
subdir-ccflags-y += -DNV_V4L2_ASYNC_SUBDEV_RENAME
|
||||
|
||||
# Rename V4L2_ASYNC_MATCH_FWNODE to V4L2_ASYNC_MATCH_TYPE_FWNODE
|
||||
subdir-ccflags-y += -DNV_V4L2_ASYNC_MATCH_FWNODE_RENAME
|
||||
|
||||
# Rename async_nf_init and v4l2_async_subdev_nf_register
|
||||
subdir-ccflags-y += -DNV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME
|
||||
|
||||
# Deprecate PCIED Error reporting pci_enable_pcie_error_reporting
|
||||
subdir-ccflags-y += -DNV_DROP_PCIE_ERROR_REPORTING
|
||||
|
||||
# Split types and declaration of net/page_pool.h
|
||||
subdir-ccflags-y += -DNV_SPLIT_PAGE_POOL_HEADER
|
||||
|
||||
# Unexport helpers for fd/handle conversion
|
||||
subdir-ccflags-y += -DNV_UNEXPORT_FD_HANDLE_CONVERSION
|
||||
|
||||
# FB Deferred IO helpers name alignment
|
||||
subdir-ccflags-y += -DNV_FB_DEFERRED_IO_OPS_RENAME
|
||||
|
||||
# Crypto driver has major change in it ops, skip it
|
||||
export CONFIG_SKIP_CRYPTO=y
|
||||
endif
|
||||
subdir-ccflags-y += -Wmissing-prototypes
|
||||
|
||||
ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y)
|
||||
subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||
|
||||
objtree = $(srctree)
|
||||
|
||||
# Redefine the fixdep command
|
||||
cmd_and_fixdep = \
|
||||
$(cmd); \
|
||||
$(objtree)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
|
||||
rm -f $(depfile)
|
||||
|
||||
include $(oottree)/scripts/Makefile.lib
|
||||
|
||||
oot-dtstree = $(oottree)/arch/arm64/boot/dts/nvidia
|
||||
|
||||
DTB_LIST := $(dtb-y)
|
||||
DTBO_LIST := $(dtbo-y)
|
||||
dtb-y :=
|
||||
dts_makefile=$(foreach d,$(wildcard $1*), $(call dts_makefile,$(d)/,$(2)) $(if $(findstring Makefile,$(d)),$(d)))
|
||||
dts_mfiles = $(call dts_makefile, $(oot-dtstree), Makefile)
|
||||
|
||||
ifneq ($(dts_mfiles),)
|
||||
dts-include :=
|
||||
include $(dts_mfiles)
|
||||
dtb-y := $(addprefix nvidia/,$(dtb-y))
|
||||
dtbo-y := $(addprefix nvidia/,$(dtbo-y))
|
||||
endif
|
||||
|
||||
DTC_INCLUDE := $(oottree)/include
|
||||
|
||||
DTB_LIST += $(dtb-y)
|
||||
DTBO_LIST += $(dtbo-y)
|
||||
DTB_OBJS := $(addprefix $(obj)/,$(DTB_LIST))
|
||||
DTBO_OBJS := $(addprefix $(obj)/,$(DTBO_LIST))
|
||||
|
||||
dtbs: $(DTB_OBJS) $(DTBO_OBJS) FORCE
|
||||
|
||||
dtbsclean:
|
||||
find $(oot-dtstree) -name *.dtb | xargs rm -rf
|
||||
find $(oot-dtstree) -name *.dtbo | xargs rm -rf
|
||||
find $(oot-dtstree) -name *.tmp | xargs rm -rf
|
||||
@@ -1,9 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
DTC_FLAGS += -@
|
||||
|
||||
# DT overlays
|
||||
dtbo-y += tegra194-carveouts.dtbo
|
||||
dtbo-y += tegra194-jetson.dtbo
|
||||
dtbo-y += tegra194-p3509-0000+p3668-0001-overlay.dtbo
|
||||
@@ -1,29 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
fragment@0 {
|
||||
target-path = "/";
|
||||
__overlay__ {
|
||||
|
||||
reserved-memory {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
ranges;
|
||||
|
||||
vpr: vpr-carveout {
|
||||
compatible = "nvidia,vpr-carveout";
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
|
||||
tegra-carveouts {
|
||||
compatible = "nvidia,carveouts-t19x";
|
||||
memory-region = <&vpr>;
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
#include <dt-bindings/clock/tegra194-clock.h>
|
||||
#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
#include <dt-bindings/interrupt-controller/irq.h>
|
||||
#include <dt-bindings/memory/tegra194-mc.h>
|
||||
#include <dt-bindings/power/tegra194-powergate.h>
|
||||
#include <dt-bindings/reset/tegra194-reset.h>
|
||||
|
||||
/ {
|
||||
overlay-name = "Tegra194 Jetson Overlay";
|
||||
compatible = "nvidia,tegra194";
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/bus@0/host1x@13e00000";
|
||||
__overlay__ {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
|
||||
interrupt-parent = <&gic>;
|
||||
|
||||
ranges = <0x0 0x14800000 0x0 0x14800000 0x0 0x02800000>,
|
||||
<0x0 0x24f00000 0x0 0x24f00000 0x0 0x00100000>;
|
||||
|
||||
nvdla0@15880000 {
|
||||
compatible = "nvidia,tegra194-nvdla";
|
||||
reg = <0x0 0x15880000 0x0 0x00040000>;
|
||||
interrupts = <GIC_SPI 236 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clocks = <&bpmp TEGRA194_CLK_DLA0_CORE>,
|
||||
<&bpmp TEGRA194_CLK_DLA0_FALCON>;
|
||||
clock-names = "nvdla", "nvdla_flcn";
|
||||
resets = <&bpmp TEGRA194_RESET_DLA0>;
|
||||
reset-names = "nvdla";
|
||||
|
||||
power-domains = <&bpmp TEGRA194_POWER_DOMAIN_DLAA>;
|
||||
interconnects = <&mc TEGRA194_MEMORY_CLIENT_DLA0RDA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_DLA0FALRDB &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_DLA0WRA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_DLA0FALWRB &emc>;
|
||||
interconnect-names = "dma-mem", "read-1", "write", "write-1";
|
||||
iommus = <&smmu TEGRA194_SID_NVDLA0>;
|
||||
dma-coherent;
|
||||
};
|
||||
|
||||
nvdla1@158c0000 {
|
||||
compatible = "nvidia,tegra194-nvdla";
|
||||
reg = <0x0 0x158c0000 0x0 0x00040000>;
|
||||
interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clocks = <&bpmp TEGRA194_CLK_DLA1_CORE>,
|
||||
<&bpmp TEGRA194_CLK_DLA1_FALCON>;
|
||||
clock-names = "nvdla", "nvdla_flcn";
|
||||
resets = <&bpmp TEGRA194_RESET_DLA1>;
|
||||
reset-names = "nvdla";
|
||||
|
||||
power-domains = <&bpmp TEGRA194_POWER_DOMAIN_DLAB>;
|
||||
interconnects = <&mc TEGRA194_MEMORY_CLIENT_DLA1RDA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_DLA1FALRDB &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_DLA1WRA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_DLA1FALWRB &emc>;
|
||||
interconnect-names = "dma-mem", "read-1", "write", "write-1";
|
||||
iommus = <&smmu TEGRA194_SID_NVDLA1>;
|
||||
dma-coherent;
|
||||
};
|
||||
|
||||
pva0@16000000 {
|
||||
compatible = "nvidia,tegra194-pva";
|
||||
power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PVAA>;
|
||||
reg = <0x0 0x16000000 0x0 0x00800000>,
|
||||
<0x0 0x24f00000 0x0 0x00080000>;
|
||||
interrupts = <GIC_SPI 234 IRQ_TYPE_LEVEL_HIGH>;
|
||||
|
||||
resets = <&bpmp TEGRA194_RESET_PVA0_ALL>;
|
||||
reset-names = "nvpva";
|
||||
|
||||
clocks = <&bpmp TEGRA194_CLK_NAFLL_PVA_VPS>,
|
||||
<&bpmp TEGRA194_CLK_NAFLL_PVA_CORE>,
|
||||
<&bpmp TEGRA194_CLK_PVA0_AXI>,
|
||||
<&bpmp TEGRA194_CLK_PVA0_VPS0>,
|
||||
<&bpmp TEGRA194_CLK_PVA0_VPS1>;
|
||||
clock-names = "nafll_pva_vps", "nafll_pva_core", "axi", "vps0", "vps1";
|
||||
|
||||
interconnects = <&mc TEGRA194_MEMORY_CLIENT_PVA0RDA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA0RDB &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA0RDC &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA0WRA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA0WRB &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA0WRC &emc>;
|
||||
interconnect-names = "dma-mem", "read-b", "read-c", "write-a", "write-b", "write-c";
|
||||
|
||||
|
||||
iommus = <&smmu TEGRA194_SID_PVA0>;
|
||||
dma-coherent;
|
||||
};
|
||||
|
||||
pva1@16800000 {
|
||||
compatible = "nvidia,tegra194-pva";
|
||||
power-domains = <&bpmp TEGRA194_POWER_DOMAIN_PVAB>;
|
||||
reg = <0x0 0x16800000 0x0 0x00800000>,
|
||||
<0x0 0x24f80000 0x0 0x00080000>;
|
||||
interrupts = <GIC_SPI 235 IRQ_TYPE_LEVEL_HIGH>;
|
||||
|
||||
resets = <&bpmp TEGRA194_RESET_PVA1_ALL>;
|
||||
reset-names = "nvpva";
|
||||
|
||||
clocks = <&bpmp TEGRA194_CLK_PVA1_AXI>,
|
||||
<&bpmp TEGRA194_CLK_PVA1_VPS0>,
|
||||
<&bpmp TEGRA194_CLK_PVA1_VPS1>;
|
||||
clock-names = "axi", "vps0", "vps1";
|
||||
|
||||
interconnects = <&mc TEGRA194_MEMORY_CLIENT_PVA1RDA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA1RDB &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA1RDC &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA1WRA &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA1WRB &emc>,
|
||||
<&mc TEGRA194_MEMORY_CLIENT_PVA1WRC &emc>;
|
||||
interconnect-names = "dma-mem", "read-b", "read-c", "write-a", "write-b", "write-c";
|
||||
|
||||
iommus = <&smmu TEGRA194_SID_PVA1>;
|
||||
dma-coherent;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
fragment@1 {
|
||||
target-path = "/";
|
||||
__overlay__ {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
|
||||
cvnas@14000000 {
|
||||
compatible = "nvidia,tegra194-cvnas";
|
||||
reg = <0x0 0x14000000 0x0 0x20000>, /* CV0_REG0_BASE */
|
||||
<0x0 0x14020000 0x0 0x10000>, /* CV0_SRAM_BASE */
|
||||
<0x0 0x0b240000 0x0 0x10000>; /* HSM_BASE */
|
||||
interrupt-parent = <&gic>;
|
||||
interrupts = <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 239 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clocks = <&bpmp TEGRA194_CLK_CVNAS>;
|
||||
assigned-clocks = <&bpmp TEGRA194_CLK_CVNAS>;
|
||||
assigned-clock-rates = <1356800000>;
|
||||
resets = <&bpmp TEGRA194_RESET_CVNAS>,
|
||||
<&bpmp TEGRA194_RESET_CVNAS_FCM>;
|
||||
reset-names = "rst", "rst_fcm";
|
||||
power-domains = <&bpmp TEGRA194_POWER_DOMAIN_CV>;
|
||||
cvsramslice = <4 0x1000>;
|
||||
cvsram-reg = <0x0 0x50000000 0x0 0x400000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
overlay-name = "Add p3509-0000+p3668-0001 Overlay Support";
|
||||
compatible = "nvidia,tegra194";
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
objtree = $(srctree)
|
||||
objtree ?= $(srctree)
|
||||
|
||||
# Redefine the fixdep command
|
||||
cmd_and_fixdep = \
|
||||
|
||||
@@ -17,9 +17,7 @@ endif
|
||||
obj-m += c2c/
|
||||
obj-m += clink/
|
||||
obj-m += cpuidle/
|
||||
ifeq ($(CONFIG_SKIP_CRYPTO),)
|
||||
obj-m += crypto/
|
||||
endif
|
||||
ifdef CONFIG_PM_DEVFREQ
|
||||
obj-m += devfreq/
|
||||
endif
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
* };
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/i2c.h>
|
||||
@@ -1627,7 +1629,7 @@ static int bmi_init(struct bmi_state *st, const struct i2c_device_id *id)
|
||||
}
|
||||
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int bmi_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int bmi_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
|
||||
@@ -5,7 +5,9 @@ ifdef CONFIG_TEGRA_HOST1X
|
||||
obj-m += tegra-hv-vse-safety.o
|
||||
obj-m += tegra-nvvse-cryptodev.o
|
||||
ifdef CONFIG_CRYPTO_ENGINE
|
||||
ifndef CONFIG_SKIP_CRYPTO
|
||||
obj-m += tegra/
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
obj-m += tegra-se-nvrng.o
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
/*
|
||||
* Crypto driver to handle block cipher algorithms using NVIDIA Security Engine.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/host1x-next.h>
|
||||
@@ -23,7 +25,9 @@
|
||||
#include "tegra-se.h"
|
||||
|
||||
struct tegra_aes_ctx {
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
struct crypto_engine_ctx enginectx;
|
||||
#endif
|
||||
struct tegra_se *se;
|
||||
u32 alg;
|
||||
u32 keylen;
|
||||
@@ -41,7 +45,9 @@ struct tegra_aes_reqctx {
|
||||
};
|
||||
|
||||
struct tegra_aead_ctx {
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
struct crypto_engine_ctx enginectx;
|
||||
#endif
|
||||
struct tegra_se *se;
|
||||
unsigned int authsize;
|
||||
u32 alg;
|
||||
@@ -66,7 +72,9 @@ struct tegra_aead_reqctx {
|
||||
};
|
||||
|
||||
struct tegra_cmac_ctx {
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
struct crypto_engine_ctx enginectx;
|
||||
#endif
|
||||
struct crypto_shash *fallback_tfm;
|
||||
struct tegra_se *se;
|
||||
unsigned int alg;
|
||||
@@ -302,6 +310,12 @@ static int tegra_aes_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
struct tegra_se *se;
|
||||
int ret;
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ret = tegra_aes_prep_req(engine, areq);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
req = container_of(areq, struct skcipher_request, base);
|
||||
rctx = skcipher_request_ctx(req);
|
||||
ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
|
||||
@@ -336,6 +350,12 @@ static int tegra_aes_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
|
||||
crypto_finalize_skcipher_request(se->engine, req, ret);
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = tegra_aes_unprep_req(engine, areq);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -347,7 +367,11 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm)
|
||||
const char *algname;
|
||||
int ret;
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher.base);
|
||||
#else
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher);
|
||||
#endif
|
||||
|
||||
crypto_skcipher_set_reqsize(tfm, sizeof(struct tegra_aes_reqctx));
|
||||
|
||||
@@ -364,9 +388,11 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm)
|
||||
}
|
||||
|
||||
ctx->alg = ret;
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ctx->enginectx.op.prepare_request = tegra_aes_prep_req;
|
||||
ctx->enginectx.op.do_one_request = tegra_aes_do_one_req;
|
||||
ctx->enginectx.op.unprepare_request = tegra_aes_unprep_req;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -494,6 +520,9 @@ static int tegra_aes_decrypt(struct skcipher_request *req)
|
||||
static struct tegra_se_alg tegra_aes_algs[] = {
|
||||
{
|
||||
.alg.skcipher = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_aes_cra_init,
|
||||
.exit = tegra_aes_cra_exit,
|
||||
.setkey = tegra_xts_setkey,
|
||||
@@ -514,9 +543,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_aes_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.skcipher = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_aes_cra_init,
|
||||
.exit = tegra_aes_cra_exit,
|
||||
.setkey = tegra_aes_setkey,
|
||||
@@ -537,9 +573,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_aes_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.skcipher = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_aes_cra_init,
|
||||
.exit = tegra_aes_cra_exit,
|
||||
.setkey = tegra_aes_setkey,
|
||||
@@ -560,9 +603,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_aes_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.skcipher = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_aes_cra_init,
|
||||
.exit = tegra_aes_cra_exit,
|
||||
.setkey = tegra_aes_setkey,
|
||||
@@ -583,9 +633,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_aes_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.skcipher = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_aes_cra_init,
|
||||
.exit = tegra_aes_cra_exit,
|
||||
.setkey = tegra_aes_setkey,
|
||||
@@ -606,6 +663,10 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_aes_do_one_req,
|
||||
#endif
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1189,6 +1250,11 @@ static int tegra_ccm_crypt_init(struct aead_request *req, struct tegra_se *se,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
static int tegra_aead_prep_req(struct crypto_engine *engine, void *areq);
|
||||
static int tegra_aead_unprep_req(struct crypto_engine *engine, void *areq);
|
||||
#endif
|
||||
|
||||
static int tegra_ccm_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
{
|
||||
struct aead_request *req = container_of(areq, struct aead_request, base);
|
||||
@@ -1198,6 +1264,12 @@ static int tegra_ccm_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
struct tegra_se *se = ctx->se;
|
||||
int ret;
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ret = tegra_aead_prep_req(engine, areq);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
ret = tegra_ccm_crypt_init(req, se, rctx);
|
||||
if (ret)
|
||||
goto out;
|
||||
@@ -1231,6 +1303,11 @@ static int tegra_ccm_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
out:
|
||||
crypto_finalize_aead_request(se->engine, req, ret);
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ret = tegra_aead_unprep_req(engine, areq);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1242,6 +1319,12 @@ static int tegra_gcm_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
struct tegra_aead_reqctx *rctx = aead_request_ctx(req);
|
||||
int ret;
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ret = tegra_aead_prep_req(engine, areq);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
req = container_of(areq, struct aead_request, base);
|
||||
|
||||
rctx->src_sg = req->src;
|
||||
@@ -1281,6 +1364,11 @@ static int tegra_gcm_do_one_req(struct crypto_engine *engine, void *areq)
|
||||
|
||||
out:
|
||||
crypto_finalize_aead_request(ctx->se->engine, req, ret);
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ret = tegra_aead_unprep_req(engine, areq);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1338,7 +1426,11 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm)
|
||||
|
||||
algname = crypto_tfm_alg_name(&tfm->base);
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base);
|
||||
#else
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.aead);
|
||||
#endif
|
||||
|
||||
crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx));
|
||||
|
||||
@@ -1346,9 +1438,11 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm)
|
||||
ctx->key_id = 0;
|
||||
ctx->alg = se_algname_to_algid(algname);
|
||||
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ctx->enginectx.op.prepare_request = tegra_aead_prep_req;
|
||||
ctx->enginectx.op.do_one_request = tegra_ccm_do_one_req;
|
||||
ctx->enginectx.op.unprepare_request = tegra_aead_unprep_req;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1383,7 +1477,11 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm)
|
||||
const char *algname;
|
||||
|
||||
algname = crypto_tfm_alg_name(&tfm->base);
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base);
|
||||
#else
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.aead);
|
||||
#endif
|
||||
|
||||
crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx));
|
||||
|
||||
@@ -1391,9 +1489,11 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm)
|
||||
ctx->key_id = 0;
|
||||
ctx->alg = se_algname_to_algid(algname);
|
||||
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ctx->enginectx.op.prepare_request = tegra_aead_prep_req;
|
||||
ctx->enginectx.op.do_one_request = tegra_gcm_do_one_req;
|
||||
ctx->enginectx.op.unprepare_request = tegra_aead_unprep_req;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1637,7 +1737,11 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm)
|
||||
const char *algname;
|
||||
|
||||
algname = crypto_tfm_alg_name(tfm);
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base);
|
||||
#else
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash);
|
||||
#endif
|
||||
|
||||
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
|
||||
sizeof(struct tegra_cmac_reqctx));
|
||||
@@ -1645,9 +1749,11 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm)
|
||||
ctx->se = se_alg->se_dev;
|
||||
ctx->key_id = 0;
|
||||
ctx->alg = se_algname_to_algid(algname);
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ctx->enginectx.op.prepare_request = NULL;
|
||||
ctx->enginectx.op.do_one_request = tegra_cmac_do_one_req;
|
||||
ctx->enginectx.op.unprepare_request = NULL;
|
||||
#endif
|
||||
|
||||
ctx->fallback_tfm = crypto_alloc_shash(algname, 0,
|
||||
CRYPTO_ALG_NEED_FALLBACK);
|
||||
@@ -1792,6 +1898,9 @@ static int tegra_cmac_import(struct ahash_request *req, const void *in)
|
||||
static struct tegra_se_alg tegra_aead_algs[] = {
|
||||
{
|
||||
.alg.aead = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_gcm_cra_init,
|
||||
.exit = tegra_aead_cra_exit,
|
||||
.setkey = tegra_aead_setkey,
|
||||
@@ -1809,9 +1918,16 @@ static struct tegra_se_alg tegra_aead_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_gcm_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.aead = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_ccm_cra_init,
|
||||
.exit = tegra_aead_cra_exit,
|
||||
.setkey = tegra_aead_setkey,
|
||||
@@ -1830,6 +1946,10 @@ static struct tegra_se_alg tegra_aead_algs[] = {
|
||||
.cra_alignmask = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_ccm_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1837,6 +1957,9 @@ static struct tegra_se_alg tegra_aead_algs[] = {
|
||||
static struct tegra_se_alg tegra_cmac_algs[] = {
|
||||
{
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_cmac_init,
|
||||
.setkey = tegra_cmac_setkey,
|
||||
.update = tegra_cmac_update,
|
||||
@@ -1859,7 +1982,11 @@ static struct tegra_se_alg tegra_cmac_algs[] = {
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_init = tegra_cmac_cra_init,
|
||||
.cra_exit = tegra_cmac_cra_exit,
|
||||
}
|
||||
},
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_cmac_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1872,30 +1999,45 @@ int tegra_init_aes(struct tegra_se *se)
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) {
|
||||
tegra_aes_algs[i].se_dev = se;
|
||||
ret = crypto_register_skcipher(&tegra_aes_algs[i].alg.skcipher);
|
||||
ret = CRYPTO_REGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher);
|
||||
if (ret) {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_aes_algs[i].alg.skcipher.base.base.cra_name);
|
||||
#else
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_aes_algs[i].alg.skcipher.base.cra_name);
|
||||
#endif
|
||||
goto err_aes;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) {
|
||||
tegra_aead_algs[i].se_dev = se;
|
||||
ret = crypto_register_aead(&tegra_aead_algs[i].alg.aead);
|
||||
ret = CRYPTO_REGISTER(aead, &tegra_aead_algs[i].alg.aead);
|
||||
if (ret) {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_aead_algs[i].alg.aead.base.base.cra_name);
|
||||
#else
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_aead_algs[i].alg.aead.base.cra_name);
|
||||
#endif
|
||||
goto err_aead;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) {
|
||||
tegra_cmac_algs[i].se_dev = se;
|
||||
ret = crypto_register_ahash(&tegra_cmac_algs[i].alg.ahash);
|
||||
ret = CRYPTO_REGISTER(ahash, &tegra_cmac_algs[i].alg.ahash);
|
||||
if (ret) {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_cmac_algs[i].alg.ahash.halg.base.cra_name);
|
||||
tegra_cmac_algs[i].alg.ahash.base.halg.base.cra_name);
|
||||
#else
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_cmac_algs[i].alg.ahash.halg.base.cra_name);
|
||||
#endif
|
||||
goto err_cmac;
|
||||
}
|
||||
}
|
||||
@@ -1906,17 +2048,17 @@ int tegra_init_aes(struct tegra_se *se)
|
||||
|
||||
err_cmac:
|
||||
for (--i; i >= 0; i--)
|
||||
crypto_unregister_ahash(&tegra_cmac_algs[i].alg.ahash);
|
||||
CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash);
|
||||
|
||||
i = ARRAY_SIZE(tegra_aead_algs);
|
||||
err_aead:
|
||||
for (--i; i >= 0; i--)
|
||||
crypto_unregister_aead(&tegra_aead_algs[i].alg.aead);
|
||||
CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead);
|
||||
|
||||
i = ARRAY_SIZE(tegra_aes_algs);
|
||||
err_aes:
|
||||
for (--i; i >= 0; i--)
|
||||
crypto_unregister_skcipher(&tegra_aes_algs[i].alg.skcipher);
|
||||
CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1926,12 +2068,12 @@ void tegra_deinit_aes(void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++)
|
||||
crypto_unregister_skcipher(&tegra_aes_algs[i].alg.skcipher);
|
||||
CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++)
|
||||
crypto_unregister_aead(&tegra_aead_algs[i].alg.aead);
|
||||
CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++)
|
||||
crypto_unregister_ahash(&tegra_cmac_algs[i].alg.ahash);
|
||||
CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
/*
|
||||
* Crypto driver to handle HASH algorithms using NVIDIA Security Engine.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/host1x-next.h>
|
||||
@@ -23,7 +24,9 @@
|
||||
#include "tegra-se.h"
|
||||
|
||||
struct tegra_sha_ctx {
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
struct crypto_engine_ctx enginectx;
|
||||
#endif
|
||||
struct crypto_ahash *fallback_tfm;
|
||||
struct tegra_se *se;
|
||||
unsigned int alg;
|
||||
@@ -414,7 +417,11 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm)
|
||||
const char *algname;
|
||||
|
||||
algname = crypto_tfm_alg_name(tfm);
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base);
|
||||
#else
|
||||
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash);
|
||||
#endif
|
||||
|
||||
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
|
||||
sizeof(struct tegra_sha_reqctx));
|
||||
@@ -423,9 +430,11 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm)
|
||||
ctx->fallback = false;
|
||||
ctx->key_id = 0;
|
||||
ctx->alg = se_algname_to_algid(algname);
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
ctx->enginectx.op.prepare_request = NULL;
|
||||
ctx->enginectx.op.do_one_request = tegra_sha_do_one_req;
|
||||
ctx->enginectx.op.unprepare_request = NULL;
|
||||
#endif
|
||||
|
||||
if (se_alg->alg_base)
|
||||
tegra_sha_init_fallback(ctx, algname);
|
||||
@@ -492,7 +501,7 @@ digbuf_fail:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
int tegra_hmac_fallback_setkey(struct tegra_sha_ctx *ctx, const u8 *key,
|
||||
static int tegra_hmac_fallback_setkey(struct tegra_sha_ctx *ctx, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
if (!ctx->fallback_tfm) {
|
||||
@@ -608,6 +617,9 @@ static int tegra_sha_import(struct ahash_request *req, const void *in)
|
||||
static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
{
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -630,9 +642,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -655,9 +674,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -680,9 +706,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -705,9 +738,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -730,9 +770,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -755,9 +802,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -780,9 +834,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -805,9 +866,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -830,10 +898,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg_base = "sha224",
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -857,10 +932,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg_base = "sha256",
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -884,10 +966,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg_base = "sha384",
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -911,10 +1000,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}, {
|
||||
.alg_base = "sha512",
|
||||
.alg.ahash = {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
.base = {
|
||||
#endif
|
||||
.init = tegra_sha_init,
|
||||
.update = tegra_sha_update,
|
||||
.final = tegra_sha_final,
|
||||
@@ -938,6 +1034,10 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
||||
.cra_init = tegra_sha_cra_init,
|
||||
.cra_exit = tegra_sha_cra_exit,
|
||||
}
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
},
|
||||
.op.do_one_request = tegra_sha_do_one_req,
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -984,10 +1084,15 @@ int tegra_init_hash(struct tegra_se *se)
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_hash_algs); i++) {
|
||||
|
||||
tegra_hash_algs[i].se_dev = se;
|
||||
ret = crypto_register_ahash(&tegra_hash_algs[i].alg.ahash);
|
||||
ret = CRYPTO_REGISTER(ahash, &tegra_hash_algs[i].alg.ahash);
|
||||
if (ret) {
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_hash_algs[i].alg.ahash.halg.base.cra_name);
|
||||
tegra_hash_algs[i].alg.ahash.base.halg.base.cra_name);
|
||||
#else
|
||||
dev_err(se->dev, "failed to register %s\n",
|
||||
tegra_hash_algs[i].alg.ahash.halg.base.cra_name);
|
||||
#endif
|
||||
goto sha_err;
|
||||
}
|
||||
}
|
||||
@@ -998,7 +1103,7 @@ int tegra_init_hash(struct tegra_se *se)
|
||||
|
||||
sha_err:
|
||||
for (--i; i >= 0; i--)
|
||||
crypto_unregister_ahash(&tegra_hash_algs[i].alg.ahash);
|
||||
CRYPTO_UNREGISTER(ahash, &tegra_hash_algs[i].alg.ahash);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1009,5 +1114,5 @@ void tegra_deinit_hash(void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_hash_algs); i++)
|
||||
crypto_unregister_ahash(&tegra_hash_algs[i].alg.ahash);
|
||||
CRYPTO_UNREGISTER(ahash, &tegra_hash_algs[i].alg.ahash);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
/*
|
||||
* Header file for NVIDIA Security Engine driver.
|
||||
*/
|
||||
@@ -18,6 +18,9 @@
|
||||
#include <crypto/sm3.h>
|
||||
#include <crypto/skcipher.h>
|
||||
#include <nvidia/conftest.h>
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
#include <crypto/engine.h>
|
||||
#endif
|
||||
|
||||
#define SE_MAX_INSTANCES 3
|
||||
#define SE_OWNERSHIP 0x14
|
||||
@@ -359,6 +362,21 @@
|
||||
#define SHA_UPDATE BIT(1)
|
||||
#define SHA_FINAL BIT(2)
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
#define CRYPTO_REGISTER(alg, x) \
|
||||
crypto_engine_register_##alg(x)
|
||||
#else
|
||||
#define CRYPTO_REGISTER(alg, x) \
|
||||
crypto_register_##alg(x)
|
||||
#endif
|
||||
|
||||
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
#define CRYPTO_UNREGISTER(alg, x) \
|
||||
crypto_engine_unregister_##alg(x)
|
||||
#else
|
||||
#define CRYPTO_UNREGISTER(alg, x) \
|
||||
crypto_unregister_##alg(x)
|
||||
#endif
|
||||
|
||||
/* Security Engine operation modes */
|
||||
enum se_aes_alg {
|
||||
@@ -398,9 +416,15 @@ struct tegra_se_alg {
|
||||
const char *alg_base;
|
||||
|
||||
union {
|
||||
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||
struct skcipher_alg skcipher;
|
||||
struct aead_alg aead;
|
||||
struct ahash_alg ahash;
|
||||
#else
|
||||
struct skcipher_engine_alg skcipher;
|
||||
struct aead_engine_alg aead;
|
||||
struct ahash_engine_alg ahash;
|
||||
#endif
|
||||
} alg;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#
|
||||
# Makefile for Extended IVC Driver and BPMP driver
|
||||
#
|
||||
|
||||
obj-m += ivc_ext.o
|
||||
ifneq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y)
|
||||
tegra_bpmp-y += ../../clk/tegra/clk-bpmp.o
|
||||
tegra_bpmp-y += ../../reset/tegra/reset-bpmp.o
|
||||
tegra_bpmp-y += ../../soc/tegra/powergate-bpmp.o
|
||||
tegra_bpmp-$(CONFIG_DEBUG_FS) += bpmp-debugfs.o
|
||||
tegra_bpmp-y += bpmp-tegra186-hv.o
|
||||
obj-m += tegra_bpmp.o
|
||||
endif
|
||||
obj-m += tegra_bpmp.o
|
||||
@@ -1,8 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
@@ -82,7 +84,11 @@ static void tegra_bpmp_handle_mrq(struct tegra_bpmp *bpmp,
|
||||
|
||||
static void tegra_bpmp_channel_signal(struct tegra_bpmp_channel *channel)
|
||||
{
|
||||
#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP)
|
||||
unsigned long flags = tegra_bpmp_mb_read_field(&channel->ob, flags);
|
||||
#else
|
||||
unsigned long flags = channel->ob->flags;
|
||||
#endif
|
||||
|
||||
if ((flags & MSG_RING) == 0)
|
||||
return;
|
||||
@@ -116,8 +122,15 @@ void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp)
|
||||
|
||||
/* If supported incoming channel */
|
||||
if (bpmp->soc->channels.cpu_rx.count == MAX_POSSIBLE_RX_CHANNEL) {
|
||||
#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP)
|
||||
if (tegra_bpmp_is_request_ready(channel)) {
|
||||
unsigned int mrq = tegra_bpmp_mb_read_field(&channel->ib, code);
|
||||
tegra_bpmp_handle_mrq(bpmp, mrq, channel);
|
||||
}
|
||||
#else
|
||||
if (tegra_bpmp_is_request_ready(channel))
|
||||
tegra_bpmp_handle_mrq(bpmp, channel->ib->code, channel);
|
||||
#endif
|
||||
}
|
||||
|
||||
spin_lock(&bpmp->lock);
|
||||
@@ -198,12 +211,20 @@ static bool tegra186_bpmp_hv_is_message_ready(struct tegra_bpmp_channel *channel
|
||||
void *frame;
|
||||
|
||||
frame = tegra_hv_ivc_read_get_next_frame(hv_ivc);
|
||||
#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP)
|
||||
if (IS_ERR(frame)) {
|
||||
iosys_map_clear(&channel->ib);
|
||||
return false;
|
||||
}
|
||||
iosys_map_set_vaddr(&channel->ib, frame);
|
||||
#else
|
||||
if (IS_ERR(frame)) {
|
||||
channel->ib = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
channel->ib = frame;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -221,12 +242,20 @@ static bool tegra186_hv_bpmp_is_channel_free(struct tegra_bpmp_channel *channel)
|
||||
void *frame;
|
||||
|
||||
frame = tegra_hv_ivc_write_get_next_frame(hv_ivc);
|
||||
#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP)
|
||||
if (IS_ERR(frame)) {
|
||||
iosys_map_clear(&channel->ob);
|
||||
return false;
|
||||
}
|
||||
iosys_map_set_vaddr(&channel->ob, frame);
|
||||
#else
|
||||
if (IS_ERR(frame)) {
|
||||
channel->ob = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
channel->ob = frame;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -432,13 +461,23 @@ static void tegra_bpmp_mrq_handle_ping(unsigned int mrq,
|
||||
struct tegra_bpmp_channel *channel,
|
||||
void *data)
|
||||
{
|
||||
struct mrq_ping_request *request;
|
||||
struct mrq_ping_response response;
|
||||
#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP)
|
||||
struct mrq_ping_request request;
|
||||
|
||||
tegra_bpmp_mb_read(&request, &channel->ib, sizeof(request));
|
||||
|
||||
memset(&response, 0, sizeof(response));
|
||||
response.reply = request.challenge << 1;
|
||||
#else
|
||||
struct mrq_ping_request *request;
|
||||
|
||||
request = (struct mrq_ping_request *)channel->ib->data;
|
||||
|
||||
memset(&response, 0, sizeof(response));
|
||||
response.reply = request->challenge << 1;
|
||||
#endif
|
||||
|
||||
|
||||
tegra_bpmp_mrq_return(channel, 0, &response, sizeof(response));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/delay.h>
|
||||
@@ -1747,7 +1749,19 @@ static void tegra_dc_early_unregister(struct drm_crtc *crtc)
|
||||
struct drm_minor *minor = crtc->dev->primary;
|
||||
struct tegra_dc *dc = to_tegra_dc(crtc);
|
||||
|
||||
#if defined(NV_DRM_DEBUGFS_REMOVE_FILES_HAS_ROOT_ARG) /* Linux v6.7 */
|
||||
struct dentry *root;
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
root = crtc->debugfs_entry;
|
||||
#else
|
||||
root = NULL;
|
||||
#endif
|
||||
|
||||
drm_debugfs_remove_files(dc->debugfs_files, count, root, minor);
|
||||
#else
|
||||
drm_debugfs_remove_files(dc->debugfs_files, count, minor);
|
||||
#endif
|
||||
kfree(dc->debugfs_files);
|
||||
dc->debugfs_files = NULL;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <drm/drm_ioctl.h>
|
||||
#include <drm/drm_prime.h>
|
||||
#include <drm/drm_vblank.h>
|
||||
#include <drm/tegra_drm-next.h>
|
||||
|
||||
#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
|
||||
#include <asm/dma-iommu.h>
|
||||
@@ -891,8 +892,10 @@ static const struct drm_driver tegra_drm_driver = {
|
||||
.debugfs_init = tegra_debugfs_init,
|
||||
#endif
|
||||
|
||||
#if !defined(NV_UNEXPORT_FD_HANDLE_CONVERSION)
|
||||
#if NV_IS_EXPORT_SYMBOL_PRESENT_drm_gem_prime_handle_to_fd
|
||||
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
||||
#endif
|
||||
#if NV_IS_EXPORT_SYMBOL_PRESENT_drm_gem_prime_fd_to_handle
|
||||
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
||||
#endif
|
||||
.gem_prime_import = tegra_gem_prime_import,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Copyright (C) 2013 NVIDIA Corporation
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/delay.h>
|
||||
@@ -255,8 +257,14 @@ static void tegra_dsi_early_unregister(struct drm_connector *connector)
|
||||
unsigned int count = ARRAY_SIZE(debugfs_files);
|
||||
struct tegra_dsi *dsi = to_dsi(output);
|
||||
|
||||
#if defined(NV_DRM_DEBUGFS_REMOVE_FILES_HAS_ROOT_ARG) /* Linux v6.7 */
|
||||
drm_debugfs_remove_files(dsi->debugfs_files, count,
|
||||
connector->debugfs_entry,
|
||||
connector->dev->primary);
|
||||
#else
|
||||
drm_debugfs_remove_files(dsi->debugfs_files, count,
|
||||
connector->dev->primary);
|
||||
#endif
|
||||
kfree(dsi->debugfs_files);
|
||||
dsi->debugfs_files = NULL;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
#include <linux/fb.h>
|
||||
#endif
|
||||
|
||||
#include <drm/drm_fourcc.h>
|
||||
#include <drm/drm_framebuffer.h>
|
||||
@@ -214,24 +211,21 @@ static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
|
||||
return __tegra_gem_mmap(&bo->gem, vma);
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
#if defined(NV_FB_DEFERRED_IO_OPS_RENAME)
|
||||
FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(tegra_fb,
|
||||
drm_fb_helper_damage_range,
|
||||
drm_fb_helper_damage_area)
|
||||
#else
|
||||
FB_GEN_DEFAULT_DEFERRED_IO_OPS(tegra_fb,
|
||||
drm_fb_helper_damage_range,
|
||||
drm_fb_helper_damage_area)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const struct fb_ops tegra_fb_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
#if defined(__FB_DEFAULT_DMAMEM_OPS_RDWR) /* Linux v6.6 */
|
||||
__FB_DEFAULT_DMAMEM_OPS_RDWR,
|
||||
#elif defined(__FB_DEFAULT_SYS_OPS_RDWR) /* Linux v6.5 */
|
||||
__FB_DEFAULT_SYS_OPS_RDWR,
|
||||
#else
|
||||
.fb_read = drm_fb_helper_sys_read,
|
||||
.fb_write = drm_fb_helper_sys_write,
|
||||
#endif
|
||||
DRM_FB_HELPER_DEFAULT_OPS,
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
|
||||
__FB_DEFAULT_DEFERRED_OPS_RDWR(tegra_fb),
|
||||
__FB_DEFAULT_DEFERRED_OPS_DRAW(tegra_fb),
|
||||
#if defined(__FB_DEFAULT_DMAMEM_OPS_DRAW) /* Linux v6.6 */
|
||||
__FB_DEFAULT_DMAMEM_OPS_DRAW,
|
||||
#elif defined(__FB_DEFAULT_SYS_OPS_DRAW) /* Linux v6.5 */
|
||||
__FB_DEFAULT_SYS_OPS_DRAW,
|
||||
#else
|
||||
.fb_fillrect = drm_fb_helper_sys_fillrect,
|
||||
.fb_copyarea = drm_fb_helper_sys_copyarea,
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/iommu.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <drm/drm_drv.h>
|
||||
#include <drm/drm_prime.h>
|
||||
@@ -584,8 +583,7 @@ int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma)
|
||||
* and set the vm_pgoff (used as a fake buffer offset by DRM)
|
||||
* to 0 as we want to map the whole buffer.
|
||||
*/
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) \
|
||||
|| (defined(CONFIG_TEGRA_SYSTEM_TYPE_ACK) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)))
|
||||
#if defined(NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS) /* Linux v6.3 */
|
||||
vm_flags_clear(vma, VM_PFNMAP);
|
||||
#else
|
||||
vma->vm_flags &= ~VM_PFNMAP;
|
||||
@@ -603,8 +601,7 @@ int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma)
|
||||
} else {
|
||||
pgprot_t prot = vm_get_page_prot(vma->vm_flags);
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) \
|
||||
|| (defined(CONFIG_TEGRA_SYSTEM_TYPE_ACK) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)))
|
||||
#if defined(NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS) /* Linux v6.3 */
|
||||
vm_flags_set(vma, VM_MIXEDMAP);
|
||||
vm_flags_clear(vma, VM_PFNMAP);
|
||||
#else
|
||||
@@ -727,7 +724,6 @@ static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map)
|
||||
{
|
||||
struct drm_gem_object *gem = buf->priv;
|
||||
struct tegra_bo *bo = to_tegra_bo(gem);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
|
||||
void *vaddr;
|
||||
|
||||
vaddr = tegra_bo_mmap(&bo->base);
|
||||
@@ -735,21 +731,16 @@ static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map)
|
||||
return PTR_ERR(vaddr);
|
||||
|
||||
iosys_map_set_vaddr(map, vaddr);
|
||||
#else
|
||||
iosys_map_set_vaddr(map, bo->vaddr);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct iosys_map *map)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
|
||||
struct drm_gem_object *gem = buf->priv;
|
||||
struct tegra_bo *bo = to_tegra_bo(gem);
|
||||
|
||||
tegra_bo_munmap(&bo->base, map->vaddr);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
static int tegra_gem_prime_vmap(struct dma_buf *buf, struct dma_buf_map *map)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/reset.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <soc/tegra/common.h>
|
||||
|
||||
@@ -272,7 +271,7 @@ static int gr2d_probe(struct platform_device *pdev)
|
||||
gr2d->client.version = gr2d->soc->version;
|
||||
gr2d->client.ops = &gr2d_ops;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
|
||||
#if defined(NV_DEVM_TEGRA_CORE_DEV_INIT_OPP_TABLE_COMMON_PRESENT) /* Linux v5.17 */
|
||||
err = devm_tegra_core_dev_init_opp_table_common(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -530,7 +530,7 @@ static int gr3d_probe(struct platform_device *pdev)
|
||||
gr3d->client.version = gr3d->soc->version;
|
||||
gr3d->client.ops = &gr3d_ops;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
|
||||
#if defined(NV_DEVM_TEGRA_CORE_DEV_INIT_OPP_TABLE_COMMON_PRESENT) /* Linux v5.17 */
|
||||
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/delay.h>
|
||||
@@ -23,6 +25,9 @@
|
||||
#include <drm/drm_atomic_helper.h>
|
||||
#include <drm/drm_crtc.h>
|
||||
#include <drm/drm_debugfs.h>
|
||||
#if defined(NV_DRM_DRM_ELD_H_PRESENT)
|
||||
#include <drm/drm_eld.h>
|
||||
#endif
|
||||
#include <drm/drm_file.h>
|
||||
#include <drm/drm_fourcc.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
@@ -1122,7 +1127,12 @@ static void tegra_hdmi_early_unregister(struct drm_connector *connector)
|
||||
unsigned int count = ARRAY_SIZE(debugfs_files);
|
||||
struct tegra_hdmi *hdmi = to_hdmi(output);
|
||||
|
||||
#if defined(NV_DRM_DEBUGFS_REMOVE_FILES_HAS_ROOT_ARG) /* Linux v6.7 */
|
||||
drm_debugfs_remove_files(hdmi->debugfs_files, count,
|
||||
connector->debugfs_entry, minor);
|
||||
#else
|
||||
drm_debugfs_remove_files(hdmi->debugfs_files, count, minor);
|
||||
#endif
|
||||
kfree(hdmi->debugfs_files);
|
||||
hdmi->debugfs_files = NULL;
|
||||
}
|
||||
@@ -1864,16 +1874,14 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, hdmi);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
|
||||
err = devm_pm_runtime_enable(&pdev->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
#if defined(NV_DEVM_TEGRA_CORE_DEV_INIT_OPP_TABLE_COMMON_PRESENT) /* Linux v5.17 */
|
||||
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
|
||||
if (err)
|
||||
return err;
|
||||
#else
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
#endif
|
||||
|
||||
INIT_LIST_HEAD(&hdmi->client.list);
|
||||
@@ -1894,10 +1902,6 @@ static int tegra_hdmi_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct tegra_hdmi *hdmi = platform_get_drvdata(pdev);
|
||||
|
||||
#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0))
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
#endif
|
||||
|
||||
host1x_client_unregister(&hdmi->client);
|
||||
|
||||
tegra_output_remove(&hdmi->output);
|
||||
|
||||
@@ -108,7 +108,7 @@ static int nvdec_set_rate(struct nvdec *nvdec, unsigned long rate)
|
||||
|
||||
if (nvdec->icc_write) {
|
||||
emc_kbps = dev_rate * NVDEC_AXI_RW_BANDWIDTH / 1024;
|
||||
err = icc_set_bw(nvdec->icc_write, kbps_to_icc(emc_kbps), 0);
|
||||
err = icc_set_bw(nvdec->icc_write, 0, kbps_to_icc(emc_kbps));
|
||||
if (err)
|
||||
dev_warn(nvdec->dev, "failed to set icc bw: %d\n", err);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ static int nvenc_set_rate(struct nvenc *nvenc, unsigned long rate)
|
||||
|
||||
if (nvenc->icc_write) {
|
||||
emc_kbps = dev_rate * NVENC_AXI_RW_BANDWIDTH / 1024;
|
||||
err = icc_set_bw(nvenc->icc_write, kbps_to_icc(emc_kbps), 0);
|
||||
err = icc_set_bw(nvenc->icc_write, 0, kbps_to_icc(emc_kbps));
|
||||
if (err)
|
||||
dev_warn(nvenc->dev, "failed to set icc bw: %d\n", err);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static int nvjpg_set_rate(struct nvjpg *nvjpg, unsigned long rate)
|
||||
|
||||
if (nvjpg->icc_write) {
|
||||
emc_kbps = dev_rate * NVJPG_AXI_RW_BANDWIDTH / 1024;
|
||||
err = icc_set_bw(nvjpg->icc_write, kbps_to_icc(emc_kbps), 0);
|
||||
err = icc_set_bw(nvjpg->icc_write, 0, kbps_to_icc(emc_kbps));
|
||||
if (err)
|
||||
dev_warn(nvjpg->dev, "failed to set icc bw: %d\n", err);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
#endif
|
||||
#include <drm/drm_atomic_helper.h>
|
||||
#include <drm/drm_debugfs.h>
|
||||
#if defined(NV_DRM_DRM_ELD_H_PRESENT)
|
||||
#include <drm/drm_eld.h>
|
||||
#endif
|
||||
#include <drm/drm_file.h>
|
||||
#include <drm/drm_panel.h>
|
||||
#include <drm/drm_simple_kms_helper.h>
|
||||
@@ -1718,8 +1721,15 @@ static void tegra_sor_early_unregister(struct drm_connector *connector)
|
||||
unsigned int count = ARRAY_SIZE(debugfs_files);
|
||||
struct tegra_sor *sor = to_sor(output);
|
||||
|
||||
#if defined(NV_DRM_DEBUGFS_REMOVE_FILES_HAS_ROOT_ARG) /* Linux v6.7 */
|
||||
drm_debugfs_remove_files(sor->debugfs_files, count,
|
||||
connector->debugfs_entry,
|
||||
connector->dev->primary);
|
||||
#else
|
||||
|
||||
drm_debugfs_remove_files(sor->debugfs_files, count,
|
||||
connector->dev->primary);
|
||||
#endif
|
||||
kfree(sor->debugfs_files);
|
||||
sor->debugfs_files = NULL;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static int vic_set_rate(struct vic *vic, unsigned long rate)
|
||||
|
||||
if (vic->icc_write) {
|
||||
emc_kbps = dev_rate * VIC_AXI_RW_BANDWIDTH / 1024;
|
||||
err = icc_set_bw(vic->icc_write, kbps_to_icc(emc_kbps), 0);
|
||||
err = icc_set_bw(vic->icc_write, 0, kbps_to_icc(emc_kbps));
|
||||
if (err)
|
||||
dev_warn(vic->dev, "failed to set icc bw: %d\n", err);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* Copyright (C) 2012-2013, NVIDIA Corporation
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/host1x-next.h>
|
||||
@@ -11,7 +13,6 @@
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include "bus.h"
|
||||
#include "dev.h"
|
||||
@@ -339,7 +340,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
|
||||
return strcmp(dev_name(dev), drv->name) == 0;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
|
||||
#if defined(NV_BUS_TYPE_STRUCT_UEVENT_HAS_CONST_DEV_ARG) /* Linux v6.3 */
|
||||
static int host1x_device_uevent(const struct device *dev,
|
||||
#else
|
||||
static int host1x_device_uevent(struct device *dev,
|
||||
|
||||
@@ -496,7 +496,7 @@ resume:
|
||||
host1x_hw_cdma_resume(host1x, cdma, restart_addr);
|
||||
}
|
||||
|
||||
void cdma_update_work(struct work_struct *work)
|
||||
static void cdma_update_work(struct work_struct *work)
|
||||
{
|
||||
struct host1x_cdma *cdma = container_of(work, struct host1x_cdma, update_work);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (c) 2010-2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
@@ -15,7 +17,6 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <soc/tegra/common.h>
|
||||
|
||||
@@ -950,7 +951,7 @@ static int host1x_probe(struct platform_device *pdev)
|
||||
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
|
||||
#if defined(NV_DEVM_TEGRA_CORE_DEV_INIT_OPP_TABLE_COMMON_PRESENT) /* Linux v5.17 */
|
||||
err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
|
||||
if (err)
|
||||
goto pm_disable;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/hwmon.h>
|
||||
@@ -1214,7 +1216,7 @@ destroy_lock:
|
||||
return status;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int f75308_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void f75308_remove(struct i2c_client *client)
|
||||
@@ -1223,7 +1225,7 @@ static void f75308_remove(struct i2c_client *client)
|
||||
struct f75308_priv *priv = dev_get_drvdata(&client->dev);
|
||||
|
||||
mutex_destroy(&priv->locker);
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -1256,10 +1258,10 @@ static struct i2c_driver f75308_driver = {
|
||||
.of_match_table = of_match_ptr(f75308_match_table),
|
||||
},
|
||||
.detect = f75308_detect,
|
||||
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED)
|
||||
.probe = f75308_probe,
|
||||
#else
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
|
||||
.probe_new = f75308_probe,
|
||||
#else
|
||||
.probe = f75308_probe,
|
||||
#endif
|
||||
.remove = f75308_remove,
|
||||
.address_list = f75308_addr,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (C) 2022-2023 NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
@@ -242,7 +244,7 @@ static int nvvrs11_vendor_info(struct nvvrs11_chip *chip)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int nvvrs11_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int nvvrs11_probe(struct i2c_client *client,
|
||||
@@ -308,7 +310,7 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
|
||||
#if !defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static void nvvrs11_remove(struct i2c_client *client)
|
||||
{
|
||||
nvvrs11_delete_sys_files(&client->dev);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
subdir-ccflags-y += -Werror
|
||||
|
||||
@@ -7,6 +7,8 @@ obj-m += max9295.o
|
||||
obj-m += max9296.o
|
||||
ifeq ($(findstring ack_src,$(NV_BUILD_KERNEL_OPTIONS)),)
|
||||
obj-m += max96712.o
|
||||
|
||||
ifdef CONFIG_MEDIA_SUPPORT
|
||||
obj-m += ar1335_common.o
|
||||
obj-m += lt6911uxc.o
|
||||
obj-m += nv_imx185.o
|
||||
@@ -17,7 +19,9 @@ obj-m += nv_imx390.o
|
||||
obj-m += nv_imx477.o
|
||||
obj-m += nv_ov5693.o
|
||||
obj-m += nv_ar0234.o
|
||||
obj-m += pca9570.o
|
||||
obj-m += nv_hawk_owl.o
|
||||
endif
|
||||
|
||||
obj-m += pca9570.o
|
||||
obj-m += virtual_i2c_mux.o
|
||||
endif
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* ar1335.c - AR1335 sensor driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -2361,7 +2363,7 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int cam_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int cam_probe(struct i2c_client *client,
|
||||
@@ -2783,7 +2785,7 @@ exit:
|
||||
devm_kfree(dev, ptr); \
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int cam_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void cam_remove(struct i2c_client *client)
|
||||
@@ -2797,7 +2799,7 @@ static void cam_remove(struct i2c_client *client)
|
||||
|
||||
if (!s_data) {
|
||||
dev_err(&client->dev, "camera common data is NULL\n");
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -2809,7 +2811,7 @@ static void cam_remove(struct i2c_client *client)
|
||||
reset_gpio = of_get_named_gpio(node, "reset-gpios", 0);
|
||||
if (reset_gpio < 0) {
|
||||
dev_err(&client->dev, "Unable to get reset GPIO\n");
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* Lontium LT6911UXC HDMI-CSI bridge driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -19,6 +21,134 @@
|
||||
|
||||
#include "../platform/tegra/camera/camera_gpio.h"
|
||||
|
||||
#define lt6911uxc_reg struct reg_8
|
||||
#define LT6911_TABLE_WAIT_MS 0
|
||||
#define LT6911_TABLE_END 1
|
||||
|
||||
static lt6911uxc_reg lt_enable_i2c[] = {
|
||||
{0xff, 0x80},
|
||||
{0xee, 0x01},
|
||||
{0x10, 0x00},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static lt6911uxc_reg lt_configure_param[] = {
|
||||
{0x5e, 0xdf},
|
||||
{0x58, 0x00},
|
||||
{0x59, 0x50},
|
||||
{0x5a, 0x10},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x5a, 0x00},
|
||||
{0x58, 0x21},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static lt6911uxc_reg lt_block_erase[] = {
|
||||
{0x5a, 0x04},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x5a, 0x00},
|
||||
{0x5b, 0x01},
|
||||
{0x5c, 0x80},
|
||||
{0x5d, 0x00},
|
||||
{0x5a, 0x01},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x5a, 0x00},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static lt6911uxc_reg lt_fifo_rst[] = {
|
||||
{0xff, 0x81},
|
||||
{0x08, 0xbf},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x08, 0xff},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static lt6911uxc_reg lt_write_enable[] = {
|
||||
{0xff, 0x80},
|
||||
{0x5a, 0x04},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x5a, 0x00},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static lt6911uxc_reg lt_data_to_fifo[] = {
|
||||
{0x5e, 0xdf},
|
||||
{0x5a, 0x20},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x5a, 0x00},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static lt6911uxc_reg lt_write_disable[] = {
|
||||
{0xff, 0x80},
|
||||
{0x5a, 0x08},
|
||||
{LT6911_TABLE_WAIT_MS, 1},
|
||||
{0x5a, 0x00},
|
||||
{0x58, 0x00},
|
||||
{LT6911_TABLE_END, 0x00}
|
||||
};
|
||||
|
||||
static u8 LT6911_EDIDs[][256] = {
|
||||
// EDID with default 1920x1080 60fps
|
||||
{
|
||||
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x3A,0xC4,0x04,0xED,0x01,0x01,0x01,0x01,
|
||||
0x1E,0x21,0x01,0x03,0x80,0x6F,0x3E,0x78,0x0A,0xEE,0x91,0xA3,0x54,0x4C,0x99,0x26,
|
||||
0x0F,0x50,0x54,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3A,0x80,0x18,0x71,0x38,0x2D,0x40,0x58,0x2C,
|
||||
0x45,0x00,0xBA,0x88,0x21,0x00,0x00,0x1E,0x02,0x3A,0x80,0x18,0x71,0x38,0x2D,0x40,
|
||||
0x58,0x2C,0x45,0x00,0xBA,0x88,0x21,0x00,0x00,0x1E,0x00,0x00,0x00,0xFD,0x00,0x18,
|
||||
0x4B,0x0F,0x87,0x22,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,
|
||||
0x00,0x44,0x75,0x61,0x6C,0x20,0x50,0x6F,0x72,0x74,0x20,0x52,0x47,0x42,0x01,0x50,
|
||||
0x02,0x03,0x18,0x71,0x43,0x04,0x01,0x03,0x23,0x09,0x07,0x01,0x83,0x01,0x00,0x00,
|
||||
0x67,0x03,0x0C,0x00,0x10,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAD
|
||||
},
|
||||
// EDID with default 3840x2160 60fps
|
||||
{
|
||||
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x3A,0xC4,0x01,0xED,0x01,0x01,0x01,0x01,
|
||||
0x1E,0x21,0x01,0x03,0x80,0x6F,0x3E,0x78,0x0A,0xEE,0x91,0xA3,0x54,0x4C,0x99,0x26,
|
||||
0x0F,0x50,0x54,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x08,0xE8,0x00,0x30,0xF2,0x70,0x5A,0x80,0xB0,0x58,
|
||||
0x8A,0x00,0x50,0x1D,0x74,0x00,0x00,0x1E,0x08,0xE8,0x00,0x30,0xF2,0x70,0x5A,0x80,
|
||||
0xB0,0x58,0x8A,0x00,0x50,0x1D,0x74,0x00,0x00,0x1E,0x00,0x00,0x00,0xFD,0x00,0x18,
|
||||
0x4B,0x0F,0x87,0x3C,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,
|
||||
0x00,0x44,0x75,0x61,0x6C,0x20,0x50,0x6F,0x72,0x74,0x20,0x52,0x47,0x42,0x01,0xC7,
|
||||
0x02,0x03,0x20,0x71,0x43,0x61,0x01,0x03,0x23,0x09,0x07,0x01,0x83,0x01,0x00,0x00,
|
||||
0x67,0x03,0x0C,0x00,0x10,0x00,0x00,0x3C,0x67,0xD8,0x5D,0xC4,0x01,0x78,0x80,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEF
|
||||
},
|
||||
// EDID with default 1280x720 60fps
|
||||
{
|
||||
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x3A,0xC4,0x05,0xED,0x01,0x01,0x01,0x01,
|
||||
0x1E,0x21,0x01,0x03,0x80,0x6F,0x3E,0x78,0x0A,0xEE,0x91,0xA3,0x54,0x4C,0x99,0x26,
|
||||
0x0F,0x50,0x54,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1D,0x00,0x72,0x51,0xD0,0x1E,0x20,0x6E,0x28,
|
||||
0x55,0x00,0xC4,0x8E,0x21,0x00,0x00,0x1E,0x01,0x1D,0x00,0x72,0x51,0xD0,0x1E,0x20,
|
||||
0x6E,0x28,0x55,0x00,0xC4,0x8E,0x21,0x00,0x00,0x1E,0x00,0x00,0x00,0xFD,0x00,0x18,
|
||||
0x4B,0x0F,0x87,0x22,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,
|
||||
0x00,0x44,0x75,0x61,0x6C,0x20,0x50,0x6F,0x72,0x74,0x20,0x52,0x47,0x42,0x01,0xE1,
|
||||
0x02,0x03,0x18,0x71,0x43,0x04,0x01,0x03,0x23,0x09,0x07,0x01,0x83,0x01,0x00,0x00,
|
||||
0x67,0x03,0x0C,0x00,0x10,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAD
|
||||
}
|
||||
};
|
||||
|
||||
static const struct of_device_id lt6911uxc_of_match[] = {
|
||||
{ .compatible = "nvidia,lt6911uxc", },
|
||||
{ },
|
||||
@@ -37,13 +167,18 @@ static const int lt6911uxc_30fps[] = {
|
||||
30,
|
||||
};
|
||||
|
||||
static const u8 lt6911uxc_HDMI_Signal = 0xa3;
|
||||
|
||||
static const u8 lt6911uxc_FW_version[] = { 0xa7, 0xa8, 0xa9, 0xaa };
|
||||
|
||||
struct lt6911uxc {
|
||||
struct i2c_client *i2c_client;
|
||||
struct v4l2_subdev *subdev;
|
||||
u16 fine_integ_time;
|
||||
u32 frame_length;
|
||||
u16 fine_integ_time;
|
||||
u32 frame_length;
|
||||
struct camera_common_data *s_data;
|
||||
struct tegracam_device *tc_dev;
|
||||
struct regmap *regmap;
|
||||
};
|
||||
|
||||
static const struct camera_common_frmfmt lt6911uxc_frmfmt[] = {
|
||||
@@ -53,11 +188,50 @@ static const struct camera_common_frmfmt lt6911uxc_frmfmt[] = {
|
||||
};
|
||||
|
||||
static const struct regmap_config sensor_regmap_config = {
|
||||
.reg_bits = 16,
|
||||
.reg_bits = 8,
|
||||
.val_bits = 8,
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
static inline int lt6911uxc_read_reg(struct camera_common_data *s_data,
|
||||
u16 addr, u8 *val)
|
||||
{
|
||||
int err = 0;
|
||||
u32 reg_val = 0;
|
||||
|
||||
err = regmap_read(s_data->regmap, addr, ®_val);
|
||||
if (err) {
|
||||
dev_err(s_data->dev, "%s: i2c read , 0x%x = %x",
|
||||
__func__, addr, reg_val);
|
||||
return err;
|
||||
}
|
||||
|
||||
*val = reg_val & 0xff;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int lt6911uxc_write_reg(struct camera_common_data *s_data,
|
||||
u16 addr, u8 val)
|
||||
{
|
||||
int err = 0;
|
||||
err = regmap_write(s_data->regmap, addr, val);
|
||||
if (err)
|
||||
dev_err(s_data->dev, "%s: i2c write failed, 0x%x = %x",
|
||||
__func__, addr, val);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int lt6911uxc_write_table(struct lt6911uxc *priv,
|
||||
const lt6911uxc_reg table[])
|
||||
{
|
||||
return regmap_util_write_table_8(priv->s_data->regmap,
|
||||
table,
|
||||
NULL, 0,
|
||||
LT6911_TABLE_WAIT_MS,
|
||||
LT6911_TABLE_END);
|
||||
}
|
||||
|
||||
static int lt6911uxc_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
@@ -84,6 +258,8 @@ static int lt6911uxc_start_streaming(struct tegracam_device *tc_dev)
|
||||
else
|
||||
gpio_set_value(pw->reset_gpio, 1);
|
||||
}
|
||||
msleep(300);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -101,29 +277,7 @@ static int lt6911uxc_stop_streaming(struct tegracam_device *tc_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lt6911uxc_set_mode(struct tegracam_device *tc_dev)
|
||||
{
|
||||
/* Width and Height taken care of by the firmware */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int lt6911uxc_read_reg(struct camera_common_data *s_data,
|
||||
u16 addr, u8 *val)
|
||||
{
|
||||
int err = 0;
|
||||
u32 reg_val = 0;
|
||||
|
||||
err = regmap_read(s_data->regmap, addr, ®_val);
|
||||
*val = reg_val & 0xff;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int lt6911uxc_write_reg(struct camera_common_data *s_data,
|
||||
u16 addr, u8 val)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lt6911uxc_power_get(struct tegracam_device *tc_dev)
|
||||
{
|
||||
@@ -309,9 +463,9 @@ static int lt6911uxc_power_on(struct camera_common_data *s_data)
|
||||
|
||||
if (pw->reset_gpio) {
|
||||
if (gpiod_cansleep(gpio_to_desc(pw->reset_gpio)))
|
||||
gpio_set_value_cansleep(pw->reset_gpio, 0);
|
||||
gpio_set_value_cansleep(pw->reset_gpio, 1);
|
||||
else
|
||||
gpio_set_value(pw->reset_gpio, 0);
|
||||
gpio_set_value(pw->reset_gpio, 1);
|
||||
}
|
||||
|
||||
usleep_range(10, 20);
|
||||
@@ -335,7 +489,7 @@ static int lt6911uxc_power_on(struct camera_common_data *s_data)
|
||||
goto lt6911uxc_dvdd_fail;
|
||||
}
|
||||
|
||||
usleep_range(10, 20);
|
||||
msleep(300);
|
||||
|
||||
pw->state = SWITCH_ON;
|
||||
|
||||
@@ -389,11 +543,64 @@ static int lt6911uxc_power_off(struct camera_common_data *s_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lt6911uxc_set_mode(struct tegracam_device *tc_dev)
|
||||
{
|
||||
int err = 0;
|
||||
int i, j;
|
||||
|
||||
struct camera_common_data *s_data = tc_dev->s_data;
|
||||
struct lt6911uxc *priv = (struct lt6911uxc *)s_data->priv;
|
||||
struct camera_common_power_rail *pw = s_data->power;
|
||||
|
||||
// Write the corresponding Shadow EDID
|
||||
err |= lt6911uxc_write_table(priv, lt_enable_i2c);
|
||||
err |= lt6911uxc_write_table(priv, lt_configure_param);
|
||||
err |= lt6911uxc_write_table(priv, lt_block_erase);
|
||||
msleep(600);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
err |= lt6911uxc_write_table(priv, lt_fifo_rst);
|
||||
err |= lt6911uxc_write_table(priv, lt_write_enable);
|
||||
err |= lt6911uxc_write_table(priv, lt_data_to_fifo);
|
||||
|
||||
for(j = 0; j < 32; j++)
|
||||
{
|
||||
lt6911uxc_write_reg(priv->s_data, 0x59,
|
||||
LT6911_EDIDs[s_data->mode][(i * 32) + j]);
|
||||
}
|
||||
err |= lt6911uxc_write_reg(priv->s_data, 0x5b, 0x01);
|
||||
err |= lt6911uxc_write_reg(priv->s_data, 0x5c, 0x80);
|
||||
err |= lt6911uxc_write_reg(priv->s_data, 0x5d, (i) * 32);
|
||||
err |= lt6911uxc_write_reg(priv->s_data, 0x5a, 0x10);
|
||||
msleep(1);
|
||||
err |= lt6911uxc_write_reg(priv->s_data, 0x5a, 0x00);
|
||||
msleep(1);
|
||||
}
|
||||
err |= lt6911uxc_write_table(priv, lt_write_disable);
|
||||
if (err)
|
||||
dev_err(tc_dev->dev, "%s Error in writing shadow EDID \n", __func__);
|
||||
|
||||
// Toggle the reset pin to low, stream on will again set it to high
|
||||
if (pw->reset_gpio) {
|
||||
if (gpiod_cansleep(gpio_to_desc(pw->reset_gpio)))
|
||||
gpio_set_value_cansleep(pw->reset_gpio, 0);
|
||||
else
|
||||
gpio_set_value(pw->reset_gpio, 0);
|
||||
}
|
||||
// Keep reset pin low for the changes to take effect
|
||||
msleep(800);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int lt6911uxc_board_setup(struct lt6911uxc *priv)
|
||||
{
|
||||
struct camera_common_data *s_data = priv->s_data;
|
||||
struct camera_common_pdata *pdata = s_data->pdata;
|
||||
struct device *dev = s_data->dev;
|
||||
u8 version;
|
||||
int i = 0, fw_ver;
|
||||
int err = 0;
|
||||
|
||||
if (pdata->mclk_name) {
|
||||
@@ -409,11 +616,31 @@ static int lt6911uxc_board_setup(struct lt6911uxc *priv)
|
||||
dev_err(dev, "error during power on sensor (%d)\n", err);
|
||||
goto err_power_on;
|
||||
}
|
||||
msleep(300);
|
||||
|
||||
err |= lt6911uxc_write_table(priv, lt_enable_i2c);
|
||||
err |= lt6911uxc_write_reg(s_data, 0xff, 0x86);
|
||||
|
||||
for (i = 0; i < sizeof(lt6911uxc_FW_version); i++) {
|
||||
fw_ver = 0;
|
||||
err = lt6911uxc_read_reg(s_data, lt6911uxc_FW_version[i], &version);
|
||||
if (err)
|
||||
dev_err(s_data->dev, "%s: Error in reading FW version \n",
|
||||
__func__);
|
||||
fw_ver = (fw_ver << 1) | version;
|
||||
}
|
||||
dev_info(s_data->dev, "Lontium FW version %d \n",fw_ver);
|
||||
|
||||
err_power_on:
|
||||
if (pdata->mclk_name)
|
||||
camera_common_mclk_disable(s_data);
|
||||
|
||||
err = lt6911uxc_power_off(s_data);
|
||||
if (err) {
|
||||
dev_err(dev, "error during power off sensor (%d)\n", err);
|
||||
goto err_power_on;
|
||||
}
|
||||
|
||||
done:
|
||||
return err;
|
||||
}
|
||||
@@ -442,7 +669,7 @@ static struct camera_common_sensor_ops lt6911uxc_common_ops = {
|
||||
};
|
||||
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int lt6911uxc_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int lt6911uxc_probe(struct i2c_client *client,
|
||||
@@ -506,7 +733,7 @@ static int lt6911uxc_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int lt6911uxc_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void lt6911uxc_remove(struct i2c_client *client)
|
||||
@@ -516,7 +743,7 @@ static void lt6911uxc_remove(struct i2c_client *client)
|
||||
struct lt6911uxc *priv;
|
||||
|
||||
if (!s_data)
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -526,7 +753,7 @@ static void lt6911uxc_remove(struct i2c_client *client)
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* max9295.c - max9295 GMSL Serializer driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <media/camera_common.h>
|
||||
#include <linux/module.h>
|
||||
#include <media/max9295.h>
|
||||
@@ -463,7 +465,7 @@ static struct regmap_config max9295_regmap_config = {
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int max9295_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int max9295_probe(struct i2c_client *client,
|
||||
@@ -512,7 +514,7 @@ static int max9295_probe(struct i2c_client *client,
|
||||
return err;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int max9295_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void max9295_remove(struct i2c_client *client)
|
||||
@@ -526,7 +528,7 @@ static void max9295_remove(struct i2c_client *client)
|
||||
i2c_unregister_device(client);
|
||||
client = NULL;
|
||||
}
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* max9296.c - max9296 GMSL Deserializer driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@@ -846,7 +848,7 @@ static struct regmap_config max9296_regmap_config = {
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int max9296_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int max9296_probe(struct i2c_client *client,
|
||||
@@ -892,7 +894,7 @@ static int max9296_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int max9296_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void max9296_remove(struct i2c_client *client)
|
||||
@@ -906,7 +908,7 @@ static void max9296_remove(struct i2c_client *client)
|
||||
i2c_unregister_device(client);
|
||||
client = NULL;
|
||||
}
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <media/camera_common.h>
|
||||
@@ -226,7 +228,7 @@ static struct regmap_config max96712_regmap_config = {
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int max96712_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int max96712_probe(struct i2c_client *client,
|
||||
@@ -266,7 +268,7 @@ static int max96712_probe(struct i2c_client *client,
|
||||
return err;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int max96712_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void max96712_remove(struct i2c_client *client)
|
||||
@@ -277,7 +279,7 @@ static void max96712_remove(struct i2c_client *client)
|
||||
i2c_unregister_device(client);
|
||||
client = NULL;
|
||||
}
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2018-2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved.
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
/*
|
||||
* ar0234.c - ar0234 sensor driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#define DEBUG 1
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
@@ -62,7 +64,6 @@ static const u32 ctrl_cid_list[] = {
|
||||
TEGRA_CAMERA_CID_ALTERNATING_EXPOSURE,
|
||||
};
|
||||
|
||||
const u16 alternating_exposure_cfg_size = sizeof(struct alternating_exposure_cfg);
|
||||
|
||||
// Coefficients as per distortion model (wide FOV) being used
|
||||
struct fisheye_lens_distortion_coeff {
|
||||
@@ -792,7 +793,7 @@ static struct tegracam_ctrl_ops ar0234_ctrl_ops = {
|
||||
.numctrls = ARRAY_SIZE(ctrl_cid_list),
|
||||
.ctrl_cid_list = ctrl_cid_list,
|
||||
.string_ctrl_size = {AR0234_EEPROM_STR_SIZE},
|
||||
.compound_ctrl_size = {sizeof(struct NvCamSyncSensorCalibData), alternating_exposure_cfg_size},
|
||||
.compound_ctrl_size = {sizeof(struct NvCamSyncSensorCalibData), sizeof(struct alternating_exposure_cfg)},
|
||||
.set_gain = ar0234_set_gain,
|
||||
.set_exposure = ar0234_set_exposure,
|
||||
.set_exposure_short = ar0234_set_exposure,
|
||||
@@ -1044,7 +1045,7 @@ static int ar0234_board_setup(struct ar0234 *priv)
|
||||
|
||||
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int ar0234_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int ar0234_probe(struct i2c_client *client,
|
||||
@@ -1149,7 +1150,7 @@ static int ar0234_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int ar0234_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void ar0234_remove(struct i2c_client *client)
|
||||
@@ -1159,7 +1160,7 @@ static void ar0234_remove(struct i2c_client *client)
|
||||
struct ar0234 *priv;
|
||||
|
||||
if (!s_data)
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -1169,7 +1170,7 @@ static void ar0234_remove(struct i2c_client *client)
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
ar0234_eeprom_device_release(priv);
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved.
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
/*
|
||||
* nv_hawk_owl.c.c - ar0234 sensor driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#define DEBUG 0
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
@@ -15,6 +17,7 @@
|
||||
#include <linux/of_gpio.h>
|
||||
#include <media/max9295.h>
|
||||
#include <media/max9296.h>
|
||||
#include <media/nv_hawk_owl.h>
|
||||
#include <media/tegracam_core.h>
|
||||
#include "hawk_owl_mode_tbls.h"
|
||||
#include <linux/ktime.h>
|
||||
@@ -64,8 +67,6 @@ static const u32 ctrl_cid_list[] = {
|
||||
TEGRA_CAMERA_CID_ALTERNATING_EXPOSURE,
|
||||
};
|
||||
|
||||
const u16 alternating_exposure_cfg_size = sizeof(struct alternating_exposure_cfg);
|
||||
|
||||
// Coefficients as per distortion model (wide FOV) being used
|
||||
typedef struct
|
||||
{
|
||||
@@ -877,7 +878,7 @@ static struct tegracam_ctrl_ops ar0234_ctrl_ops = {
|
||||
.numctrls = ARRAY_SIZE(ctrl_cid_list),
|
||||
.ctrl_cid_list = ctrl_cid_list,
|
||||
.string_ctrl_size = {AR0234_EEPROM_STR_SIZE},
|
||||
.compound_ctrl_size = {sizeof(NvCamSyncSensorCalibData), alternating_exposure_cfg_size},
|
||||
.compound_ctrl_size = {sizeof(NvCamSyncSensorCalibData), sizeof(struct alternating_exposure_cfg)},
|
||||
.set_gain = ar0234_set_gain,
|
||||
.set_exposure = ar0234_set_exposure,
|
||||
.set_exposure_short = ar0234_set_exposure,
|
||||
@@ -1434,7 +1435,7 @@ static int ar0234_hawk_owl_deser_ser_program(struct ar0234 *priv)
|
||||
return err;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int ar0234_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int ar0234_probe(struct i2c_client *client,
|
||||
@@ -1572,7 +1573,7 @@ un_register:
|
||||
return err;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int ar0234_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void ar0234_remove(struct i2c_client *client)
|
||||
@@ -1582,7 +1583,7 @@ static void ar0234_remove(struct i2c_client *client)
|
||||
struct ar0234 *priv = (struct ar0234 *)s_data->priv;
|
||||
|
||||
if (!s_data)
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -1590,7 +1591,7 @@ static void ar0234_remove(struct i2c_client *client)
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
ar0234_eeprom_device_release(priv);
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (c) 2016-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -775,7 +777,7 @@ static const struct v4l2_subdev_internal_ops imx185_subdev_internal_ops = {
|
||||
.open = imx185_open,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int imx185_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int imx185_probe(struct i2c_client *client,
|
||||
@@ -838,11 +840,11 @@ static int imx185_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
static void
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int
|
||||
imx185_remove(struct i2c_client *client)
|
||||
#else
|
||||
static int
|
||||
static void
|
||||
imx185_remove(struct i2c_client *client)
|
||||
#endif
|
||||
{
|
||||
@@ -850,17 +852,17 @@ imx185_remove(struct i2c_client *client)
|
||||
struct imx185 *priv;
|
||||
|
||||
if (!s_data)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
return;
|
||||
#else
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
priv = (struct imx185 *)s_data->priv;
|
||||
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -691,7 +693,7 @@ static const struct v4l2_subdev_internal_ops imx219_subdev_internal_ops = {
|
||||
.open = imx219_open,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int imx219_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int imx219_probe(struct i2c_client *client,
|
||||
@@ -754,10 +756,10 @@ static int imx219_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE
|
||||
static void imx219_remove(struct i2c_client *client)
|
||||
#else
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int imx219_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void imx219_remove(struct i2c_client *client)
|
||||
#endif
|
||||
{
|
||||
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
|
||||
@@ -765,7 +767,7 @@ static int imx219_remove(struct i2c_client *client)
|
||||
|
||||
if (!s_data) {
|
||||
dev_err(&client->dev, "camera common data is NULL\n");
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -776,7 +778,7 @@ static int imx219_remove(struct i2c_client *client)
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (c) 2015-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -1260,7 +1262,7 @@ static const struct v4l2_subdev_internal_ops imx274_subdev_internal_ops = {
|
||||
.open = imx274_open,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int imx274_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int imx274_probe(struct i2c_client *client,
|
||||
@@ -1333,20 +1335,20 @@ static int imx274_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
static void imx274_remove(struct i2c_client *client)
|
||||
#else
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int imx274_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void imx274_remove(struct i2c_client *client)
|
||||
#endif
|
||||
{
|
||||
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
|
||||
struct imx274 *priv;
|
||||
|
||||
if (!s_data)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
return;
|
||||
#else
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
priv = (struct imx274 *)s_data->priv;
|
||||
@@ -1358,7 +1360,7 @@ static int imx274_remove(struct i2c_client *client)
|
||||
imx274_eeprom_device_release(priv);
|
||||
|
||||
mutex_destroy(&priv->streaming_lock);
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2017-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -695,7 +697,7 @@ static const struct v4l2_subdev_internal_ops imx318_subdev_internal_ops = {
|
||||
.open = imx318_open,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int imx318_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int imx318_probe(struct i2c_client *client,
|
||||
@@ -759,7 +761,7 @@ static int imx318_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int imx318_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void imx318_remove(struct i2c_client *client)
|
||||
@@ -769,7 +771,7 @@ static void imx318_remove(struct i2c_client *client)
|
||||
struct imx318 *priv;
|
||||
|
||||
if (!s_data)
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -780,7 +782,7 @@ static void imx318_remove(struct i2c_client *client)
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
imx318_eeprom_device_release(priv);
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -752,7 +754,7 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int imx390_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int imx390_probe(struct i2c_client *client,
|
||||
@@ -854,7 +856,7 @@ static int imx390_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int imx390_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void imx390_remove(struct i2c_client *client)
|
||||
@@ -864,7 +866,7 @@ static void imx390_remove(struct i2c_client *client)
|
||||
struct imx390 *priv;
|
||||
|
||||
if (!s_data)
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -878,7 +880,7 @@ static void imx390_remove(struct i2c_client *client)
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
* nv_imx477.c - imx477 sensor driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -720,7 +722,7 @@ static const struct v4l2_subdev_internal_ops imx477_subdev_internal_ops = {
|
||||
.open = imx477_open,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int imx477_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int imx477_probe(struct i2c_client *client,
|
||||
@@ -780,10 +782,10 @@ static int imx477_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
static void imx477_remove(struct i2c_client *client)
|
||||
#else
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int imx477_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void imx477_remove(struct i2c_client *client)
|
||||
#endif
|
||||
{
|
||||
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
|
||||
@@ -791,7 +793,7 @@ static int imx477_remove(struct i2c_client *client)
|
||||
|
||||
if (!s_data) {
|
||||
dev_err(&client->dev, "camera common data is NULL\n");
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -801,7 +803,7 @@ static int imx477_remove(struct i2c_client *client)
|
||||
|
||||
tegracam_v4l2subdev_unregister(priv->tc_dev);
|
||||
tegracam_device_unregister(priv->tc_dev);
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/gpio.h>
|
||||
@@ -1146,7 +1148,7 @@ static const struct v4l2_subdev_internal_ops ov5693_subdev_internal_ops = {
|
||||
.open = ov5693_open,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int ov5693_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int ov5693_probe(struct i2c_client *client,
|
||||
@@ -1236,7 +1238,7 @@ fail:
|
||||
return err;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int
|
||||
ov5693_remove(struct i2c_client *client)
|
||||
#else
|
||||
@@ -1248,7 +1250,7 @@ ov5693_remove(struct i2c_client *client)
|
||||
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
|
||||
|
||||
if (!s_data)
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return -EINVAL;
|
||||
#else
|
||||
return;
|
||||
@@ -1264,7 +1266,7 @@ ov5693_remove(struct i2c_client *client)
|
||||
ov5693_eeprom_device_release(priv);
|
||||
|
||||
mutex_destroy(&priv->streaming_lock);
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/i2c.h>
|
||||
@@ -258,7 +260,7 @@ static struct regmap_config pca9570_regmap_config = {
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int pca9570_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int pca9570_probe(struct i2c_client *client,
|
||||
@@ -308,7 +310,7 @@ static int pca9570_probe(struct i2c_client *client,
|
||||
return err;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int pca9570_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void pca9570_remove(struct i2c_client *client)
|
||||
@@ -319,7 +321,7 @@ static void pca9570_remove(struct i2c_client *client)
|
||||
client = NULL;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* virtual_i2c_mux.c - virtual i2c mux driver for P3762 & P3783 GMSL boards.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-mux.h>
|
||||
#include <linux/module.h>
|
||||
@@ -47,7 +49,7 @@ static int virtual_i2c_mux_deselect(struct i2c_mux_core *muxc, u32 chan)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int virtual_i2c_mux_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int virtual_i2c_mux_probe(struct i2c_client *client,
|
||||
@@ -104,7 +106,7 @@ err_parent:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int virtual_i2c_mux_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void virtual_i2c_mux_remove(struct i2c_client *client)
|
||||
@@ -114,7 +116,7 @@ static void virtual_i2c_mux_remove(struct i2c_client *client)
|
||||
|
||||
i2c_mux_del_adapters(muxc);
|
||||
i2c_put_adapter(muxc->parent);
|
||||
#if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
ifdef CONFIG_MEDIA_SUPPORT
|
||||
obj-m += cdi/
|
||||
obj-m += tpg/
|
||||
endif
|
||||
obj-m += isc/
|
||||
obj-m += camera/
|
||||
obj-m += tpg/
|
||||
obj-m += cam_fsync/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
|
||||
ifdef CONFIG_MEDIA_SUPPORT
|
||||
ifeq ($(findstring ack_src,$(NV_BUILD_KERNEL_OPTIONS)),)
|
||||
LINUXINCLUDE += -I$(srctree.nvidia-oot)/drivers/video/tegra/camera
|
||||
LINUXINCLUDE += -I$(srctree.nvidia-oot)/drivers/media/platform/tegra
|
||||
@@ -32,3 +33,4 @@ tegra-camera-objs += fusa-capture/capture-isp.o
|
||||
obj-m += tegra-camera.o
|
||||
obj-m += tests/
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
/*
|
||||
* NVIDIA Tegra CSI Device
|
||||
*
|
||||
* Copyright (c) 2015-2022, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2015-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
@@ -685,6 +687,9 @@ static int tegra_csi_set_format(struct v4l2_subdev *subdev,
|
||||
}
|
||||
|
||||
static int tegra_csi_g_frame_interval(struct v4l2_subdev *sd,
|
||||
#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL)
|
||||
struct v4l2_subdev_state *sd_state,
|
||||
#endif
|
||||
struct v4l2_subdev_frame_interval *vfi)
|
||||
{
|
||||
struct tegra_csi_channel *chan = to_csi_chan(sd);
|
||||
@@ -716,10 +721,15 @@ static int tegra_csi_enum_mbus_code(struct v4l2_subdev *sd,
|
||||
static struct v4l2_subdev_video_ops tegra_csi_video_ops = {
|
||||
.s_stream = tegra_csi_s_stream,
|
||||
.g_input_status = tegra_csi_g_input_status,
|
||||
#if !defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL)
|
||||
.g_frame_interval = tegra_csi_g_frame_interval,
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct v4l2_subdev_pad_ops tegra_csi_pad_ops = {
|
||||
#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL)
|
||||
.get_frame_interval = tegra_csi_g_frame_interval,
|
||||
#endif
|
||||
.get_fmt = tegra_csi_get_format,
|
||||
.set_fmt = tegra_csi_set_format,
|
||||
.enum_mbus_code = tegra_csi_enum_mbus_code,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* tegracam_ctrls - control framework for tegra camera drivers
|
||||
*
|
||||
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/nospec.h>
|
||||
@@ -326,7 +326,7 @@ static int tegracam_set_ctrls(struct tegracam_ctrl_handler *handler,
|
||||
/* For controls that require sensor to be on */
|
||||
switch (ctrl->id) {
|
||||
case TEGRA_CAMERA_CID_GAIN:
|
||||
if (*ctrl->p_new.p_s64 == ctrlprops->min_gain_val - 1)
|
||||
if (*ctrl->p_new.p_s64 == ctrlprops->max_gain_val + 1)
|
||||
return 0;
|
||||
err = ops->set_gain(tc_dev, *ctrl->p_new.p_s64);
|
||||
break;
|
||||
@@ -334,7 +334,7 @@ static int tegracam_set_ctrls(struct tegracam_ctrl_handler *handler,
|
||||
err = ops->set_frame_rate(tc_dev, *ctrl->p_new.p_s64);
|
||||
break;
|
||||
case TEGRA_CAMERA_CID_EXPOSURE:
|
||||
if (*ctrl->p_new.p_s64 == ctrlprops->min_exp_time.val - 1)
|
||||
if (*ctrl->p_new.p_s64 == ctrlprops->max_exp_time.val + 1)
|
||||
return 0;
|
||||
err = ops->set_exposure(tc_dev, *ctrl->p_new.p_s64);
|
||||
break;
|
||||
@@ -607,8 +607,8 @@ int tegracam_init_ctrl_ranges_by_mode(
|
||||
switch (ctrl->id) {
|
||||
case TEGRA_CAMERA_CID_GAIN:
|
||||
err = v4l2_ctrl_modify_range(ctrl,
|
||||
ctrlprops->min_gain_val - 1,
|
||||
ctrlprops->max_gain_val,
|
||||
ctrlprops->min_gain_val,
|
||||
ctrlprops->max_gain_val + 1,
|
||||
ctrlprops->step_gain_val,
|
||||
ctrlprops->default_gain);
|
||||
break;
|
||||
@@ -621,8 +621,8 @@ int tegracam_init_ctrl_ranges_by_mode(
|
||||
break;
|
||||
case TEGRA_CAMERA_CID_EXPOSURE:
|
||||
err = v4l2_ctrl_modify_range(ctrl,
|
||||
ctrlprops->min_exp_time.val - 1,
|
||||
ctrlprops->max_exp_time.val,
|
||||
ctrlprops->min_exp_time.val,
|
||||
ctrlprops->max_exp_time.val + 1,
|
||||
ctrlprops->step_exp_time.val,
|
||||
ctrlprops->default_exp_time.val);
|
||||
break;
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
/*
|
||||
* NVIDIA Media controller graph management
|
||||
*
|
||||
* Copyright (c) 2015-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/of.h>
|
||||
@@ -13,7 +16,6 @@
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/reset.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
#include <soc/tegra/fuse.h>
|
||||
#include <media/media-device.h>
|
||||
#include <media/v4l2-async.h>
|
||||
@@ -341,7 +343,7 @@ register_device_error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(NV_V4L2_ASYNC_SUBDEV_RENAME)
|
||||
#if defined(NV_V4L2_ASYNC_CONNECTION_STRUCT_PRESENT) /* Linux 6.5 */
|
||||
static int tegra_vi_graph_notify_bound(struct v4l2_async_notifier *notifier,
|
||||
struct v4l2_subdev *subdev,
|
||||
struct v4l2_async_connection *asd)
|
||||
@@ -380,7 +382,7 @@ static int tegra_vi_graph_notify_bound(struct v4l2_async_notifier *notifier,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if defined(NV_V4L2_ASYNC_SUBDEV_RENAME)
|
||||
#if defined(NV_V4L2_ASYNC_CONNECTION_STRUCT_PRESENT) /* Linux 6.5 */
|
||||
static void tegra_vi_graph_notify_unbind(struct v4l2_async_notifier *notifier,
|
||||
struct v4l2_subdev *subdev,
|
||||
struct v4l2_async_connection *asd)
|
||||
@@ -423,7 +425,7 @@ void tegra_vi_graph_cleanup(struct tegra_mc_vi *vi)
|
||||
|
||||
list_for_each_entry(chan, &vi->vi_chans, list) {
|
||||
#if defined(CONFIG_V4L2_ASYNC)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
|
||||
#if defined(NV_V4L2_ASYNC_NOTIFIER_INIT_PRESENT)
|
||||
v4l2_async_notifier_unregister(&chan->notifier);
|
||||
#else
|
||||
v4l2_async_nf_unregister(&chan->notifier);
|
||||
@@ -477,12 +479,14 @@ static int tegra_vi_graph_parse_one(struct tegra_channel *chan,
|
||||
}
|
||||
|
||||
entity->node = remote;
|
||||
#if defined(NV_V4L2_ASYNC_MATCH_FWNODE_RENAME)
|
||||
#if !defined(NV_V4L2_ASYNC_CONNECTION_STRUCT_PRESENT) /* Linux 6.5 */
|
||||
#if defined(NV_V4L2_ASYNC_MATCH_TYPE_ENUM_PRESENT) /* Linux 6.5 */
|
||||
entity->asd.match.type = V4L2_ASYNC_MATCH_TYPE_FWNODE;
|
||||
#else
|
||||
entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
|
||||
#endif
|
||||
entity->asd.match.fwnode = of_fwnode_handle(remote);
|
||||
#endif
|
||||
|
||||
list_add_tail(&entity->list, &chan->entities);
|
||||
chan->num_subdevs++;
|
||||
@@ -638,12 +642,14 @@ int tegra_vi_graph_init(struct tegra_mc_vi *vi)
|
||||
|
||||
/* Add the remote entity of this endpoint */
|
||||
entity->node = remote;
|
||||
#if defined(NV_V4L2_ASYNC_MATCH_FWNODE_RENAME)
|
||||
#if !defined(NV_V4L2_ASYNC_CONNECTION_STRUCT_PRESENT) /* Linux 6.5 */
|
||||
#if defined(NV_V4L2_ASYNC_MATCH_TYPE_ENUM_PRESENT) /* Linux 6.5 */
|
||||
entity->asd.match.type = V4L2_ASYNC_MATCH_TYPE_FWNODE;
|
||||
#else
|
||||
entity->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
|
||||
#endif
|
||||
entity->asd.match.fwnode = of_fwnode_handle(remote);
|
||||
#endif
|
||||
list_add_tail(&entity->list, &chan->entities);
|
||||
chan->num_subdevs++;
|
||||
chan->notifier.ops = chan->notifier.ops ? chan->notifier.ops : &vi_chan_notify_ops;
|
||||
@@ -664,39 +670,44 @@ int tegra_vi_graph_init(struct tegra_mc_vi *vi)
|
||||
|
||||
i = 0;
|
||||
#if defined(CONFIG_V4L2_ASYNC)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
|
||||
#if defined(NV_V4L2_ASYNC_NOTIFIER_INIT_PRESENT)
|
||||
v4l2_async_notifier_init(&chan->notifier);
|
||||
list_for_each_entry(entity, &chan->entities, list)
|
||||
__v4l2_async_notifier_add_subdev(&chan->notifier, &entity->asd);
|
||||
#else
|
||||
#if defined (NV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME)
|
||||
v4l2_async_subdev_nf_init(&chan->notifier, tegra_channel_find_linked_csi_subdev(chan));
|
||||
list_for_each_entry(entity, &chan->entities, list) {
|
||||
struct v4l2_async_connection *asd;
|
||||
asd = v4l2_async_nf_add_fwnode_remote(&chan->notifier, of_fwnode_handle(remote),
|
||||
struct v4l2_async_connection);
|
||||
if (IS_ERR(asd)) {
|
||||
ret = PTR_ERR(asd);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
#if defined(NV_V4L2_ASYNC_NF_INIT_HAS_V4L2_DEV_ARG) /* Linux 6.6 */
|
||||
v4l2_async_nf_init(&chan->notifier, &vi->v4l2_dev);
|
||||
#else
|
||||
v4l2_async_nf_init(&chan->notifier);
|
||||
#endif
|
||||
|
||||
#if defined(NV_V4L2_ASYNC_NF_ADD_SUBDEV_PRESENT) /* Linux 6.6 */
|
||||
list_for_each_entry(entity, &chan->entities, list)
|
||||
__v4l2_async_nf_add_subdev(&chan->notifier, &entity->asd);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
list_for_each_entry(entity, &chan->entities, list) {
|
||||
struct v4l2_async_connection *asc;
|
||||
asc = v4l2_async_nf_add_fwnode(&chan->notifier, of_fwnode_handle(entity->node),
|
||||
struct v4l2_async_connection);
|
||||
if (IS_ERR(asc))
|
||||
asc = NULL;
|
||||
entity->asc = asc;
|
||||
}
|
||||
#endif /* NV_V4L2_ASYNC_NF_ADD_SUBDEV_PRESENT */
|
||||
#endif /* NV_V4L2_ASYNC_NOTIFIER_INIT_PRESENT */
|
||||
|
||||
chan->link_status = 0;
|
||||
chan->subdevs_bound = 0;
|
||||
|
||||
/* Register the async notifier for this channel */
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
|
||||
#if defined(NV_V4L2_ASYNC_NOTIFIER_INIT_PRESENT)
|
||||
ret = v4l2_async_notifier_register(&vi->v4l2_dev,
|
||||
&chan->notifier);
|
||||
#else
|
||||
#if defined (NV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME)
|
||||
#if defined (NV_V4L2_ASYNC_NF_INIT_HAS_V4L2_DEV_ARG) /* Linux 6.6 */
|
||||
ret = v4l2_async_nf_register(&chan->notifier);
|
||||
if (ret < 0)
|
||||
v4l2_async_nf_cleanup(&chan->notifier);
|
||||
#else
|
||||
ret = v4l2_async_nf_register(&vi->v4l2_dev,
|
||||
&chan->notifier);
|
||||
@@ -705,9 +716,9 @@ int tegra_vi_graph_init(struct tegra_mc_vi *vi)
|
||||
#else
|
||||
dev_err(vi->dev, "CONFIG_V4L2_ASYNC is not enabled!\n");
|
||||
ret = -ENOTSUPP;
|
||||
#endif
|
||||
#endif /* CONFIG_V4L2_ASYNC */
|
||||
if (ret < 0) {
|
||||
dev_err(vi->dev, "notifier registration failed\n");
|
||||
dev_err(vi->dev, "notifier registration failed %d\n", ret);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
ifneq ($(CONFIG_TEGRA_GPIO_LEGACY_DISABLE),y)
|
||||
obj-m += cdi_gpio.o
|
||||
obj-m += cdi_mgr.o
|
||||
endif
|
||||
obj-m += cdi_dev.o
|
||||
obj-m += cdi_pwm.o
|
||||
ifeq ($(findstring ack_src,$(NV_BUILD_KERNEL_OPTIONS)),)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/fs.h>
|
||||
@@ -564,7 +566,7 @@ static void cdi_dev_get_cim_ver(struct device_node *np, struct cdi_dev_info *inf
|
||||
}
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int cdi_dev_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int cdi_dev_probe(struct i2c_client *client,
|
||||
@@ -805,7 +807,7 @@ static int cdi_dev_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int cdi_dev_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void cdi_dev_remove(struct i2c_client *client)
|
||||
@@ -826,7 +828,7 @@ static void cdi_dev_remove(struct i2c_client *client)
|
||||
if (info->cdev.dev)
|
||||
cdev_del(&info->cdev);
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2017-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@@ -40,6 +42,9 @@ static struct gpio_chip *cdi_gpio_get_chip(struct platform_device *pdev,
|
||||
struct cdi_gpio_plat_data *pd)
|
||||
{
|
||||
struct gpio_chip *gc = NULL;
|
||||
#if !defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */
|
||||
struct gpio_device *gdev;
|
||||
#endif
|
||||
char name[MAX_STR_SIZE];
|
||||
|
||||
if (strlen(pd->gpio_prnt_chip) > MAX_STR_SIZE) {
|
||||
@@ -49,7 +54,15 @@ static struct gpio_chip *cdi_gpio_get_chip(struct platform_device *pdev,
|
||||
}
|
||||
strcpy(name, pd->gpio_prnt_chip);
|
||||
|
||||
#if defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */
|
||||
gc = gpiochip_find(name, cdi_gpio_chip_match);
|
||||
#else
|
||||
gdev = gpio_device_find(name, cdi_gpio_chip_match);
|
||||
if (gdev) {
|
||||
gc = gpio_device_get_chip(gdev);
|
||||
gpio_device_put(gdev);
|
||||
}
|
||||
#endif
|
||||
if (!gc) {
|
||||
dev_err(&pdev->dev, "%s: unable to find gpio parent chip %s\n",
|
||||
__func__, pd->gpio_prnt_chip);
|
||||
@@ -275,7 +288,10 @@ static int cdi_gpio_probe(struct platform_device *pdev)
|
||||
gc->base = -1;
|
||||
gc->ngpio = pd->max_gpio;
|
||||
gc->label = "cdi-gpio";
|
||||
gc->parent = &pdev->dev;
|
||||
#if defined(NV_GPIO_CHIP_STRUCT_HAS_OF_NODE_PRESENT) /* Linux 6.2 */
|
||||
gc->of_node = pdev->dev.of_node;
|
||||
#endif
|
||||
gc->owner = THIS_MODULE;
|
||||
|
||||
err = gpiochip_add_data(gc, cdi_gpio);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <asm/siginfo.h>
|
||||
#include <linux/rcupdate.h>
|
||||
@@ -30,7 +31,6 @@
|
||||
#include <media/cdi-mgr.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <asm/barrier.h>
|
||||
|
||||
@@ -1328,15 +1328,23 @@ static int cdi_mgr_of_get_grp_gpio(
|
||||
struct device *dev, struct device_node *np,
|
||||
const char *name, int size, u32 *grp, u32 *flags)
|
||||
{
|
||||
char prop_name[32]; /* 32 is max size of property name */
|
||||
int num, i;
|
||||
|
||||
num = of_gpio_named_count(np, name);
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", name, num);
|
||||
snprintf(prop_name, sizeof(prop_name), "%s-gpios", name);
|
||||
|
||||
num = gpiod_count(dev, name);
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", prop_name, num);
|
||||
if (num < 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; (i < num) && (i < size); i++) {
|
||||
grp[i] = of_get_named_gpio_flags(np, name, i, &flags[i]);
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
grp[i] = of_get_named_gpio_flags(np, prop_name, i, &flags[i]);
|
||||
#else
|
||||
grp[i] = of_get_named_gpio(np, prop_name, i);
|
||||
flags[i] = 0;
|
||||
#endif
|
||||
if ((int)grp[i] < 0) {
|
||||
dev_err(dev, "%s: gpio[%d] invalid\n", __func__, i);
|
||||
return -EINVAL;
|
||||
@@ -1446,13 +1454,13 @@ static struct cdi_mgr_platform_data *of_cdi_mgr_pdata(struct platform_device
|
||||
dev_dbg(&pdev->dev, " csiport: %d\n", pd->csi_port);
|
||||
|
||||
pd->num_pwr_gpios = cdi_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, child_np, "pwdn-gpios",
|
||||
&pdev->dev, child_np, "pwdn",
|
||||
ARRAY_SIZE(pd->pwr_gpios), pd->pwr_gpios, pd->pwr_flags);
|
||||
if (pd->num_pwr_gpios < 0)
|
||||
return ERR_PTR(pd->num_pwr_gpios);
|
||||
|
||||
pd->num_mcdi_gpios = cdi_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, child_np, "mcdi-gpios",
|
||||
&pdev->dev, child_np, "mcdi",
|
||||
ARRAY_SIZE(pd->mcdi_gpios), pd->mcdi_gpios, pd->mcdi_flags);
|
||||
if (pd->num_mcdi_gpios < 0)
|
||||
return ERR_PTR(pd->num_mcdi_gpios);
|
||||
@@ -1488,10 +1496,10 @@ static struct cdi_mgr_platform_data *of_cdi_mgr_pdata(struct platform_device
|
||||
return pd;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)
|
||||
static char *cdi_mgr_devnode(struct device *dev, umode_t *mode)
|
||||
#else
|
||||
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||
static char *cdi_mgr_devnode(const struct device *dev, umode_t *mode)
|
||||
#else
|
||||
static char *cdi_mgr_devnode(struct device *dev, umode_t *mode)
|
||||
#endif
|
||||
{
|
||||
if (!mode)
|
||||
@@ -1652,13 +1660,8 @@ static int cdi_mgr_configure_gpios(struct device *dev, struct cdi_mgr_priv *cdi_
|
||||
}
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)
|
||||
cdi_mgr->gpios[i].desc = devm_fwnode_get_gpiod_from_child(dev,
|
||||
"devblk", &child->fwnode, GPIOD_ASIS, NULL);
|
||||
#else
|
||||
cdi_mgr->gpios[i].desc = devm_fwnode_gpiod_get_index(dev,
|
||||
&child->fwnode, "devblk", 0, GPIOD_ASIS, NULL);
|
||||
#endif
|
||||
if (IS_ERR(cdi_mgr->gpios[i].desc)) {
|
||||
ret = PTR_ERR(cdi_mgr->gpios[i].desc);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2016-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// Copyright (c) 2016-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@@ -130,7 +132,9 @@ static const struct pwm_ops cdi_pwm_ops = {
|
||||
.enable = cdi_pwm_enable,
|
||||
.disable = cdi_pwm_disable,
|
||||
#endif
|
||||
#if defined(NV_PWM_OPS_STRUCT_HAS_OWNER) /* Linux 6.7 */
|
||||
.owner = THIS_MODULE,
|
||||
#endif
|
||||
};
|
||||
|
||||
static int cdi_pwm_probe(struct platform_device *pdev)
|
||||
@@ -159,7 +163,9 @@ static int cdi_pwm_probe(struct platform_device *pdev)
|
||||
|
||||
info->chip.dev = &pdev->dev;
|
||||
info->chip.ops = &cdi_pwm_ops;
|
||||
#if defined(NV_PWM_CHIP_STRUCT_HAS_BASE_ARG)
|
||||
info->chip.base = -1;
|
||||
#endif
|
||||
info->chip.npwm = npwm;
|
||||
info->chip.of_xlate = of_cdi_pwm_xlate;
|
||||
info->chip.of_pwm_n_cells = 2;
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
|
||||
GCOV_PROFILE := y
|
||||
|
||||
LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL))
|
||||
LINUX_VERSION_6_3 := $(shell expr 6 \* 256 + 3)
|
||||
|
||||
ifneq ($(CONFIG_TEGRA_GPIO_LEGACY_DISABLE),y)
|
||||
obj-m += isc_gpio.o
|
||||
obj-m += isc_mgr.o
|
||||
endif
|
||||
obj-m += isc_dev.o
|
||||
obj-m += isc_pwm.o
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/fs.h>
|
||||
@@ -427,7 +429,7 @@ static const struct file_operations isc_dev_fileops = {
|
||||
.release = isc_dev_release,
|
||||
};
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int isc_dev_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int isc_dev_probe(struct i2c_client *client,
|
||||
@@ -512,7 +514,7 @@ static int isc_dev_probe(struct i2c_client *client,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
static int isc_dev_remove(struct i2c_client *client)
|
||||
#else
|
||||
static void isc_dev_remove(struct i2c_client *client)
|
||||
@@ -533,7 +535,7 @@ static void isc_dev_remove(struct i2c_client *client)
|
||||
if (info->cdev.dev)
|
||||
cdev_del(&info->cdev);
|
||||
|
||||
#if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2017-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@@ -41,6 +43,9 @@ static struct gpio_chip *isc_gpio_get_chip(struct platform_device *pdev,
|
||||
{
|
||||
struct gpio_chip *gc = NULL;
|
||||
char name[MAX_STR_SIZE];
|
||||
#if !defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */
|
||||
struct gpio_device *gdev;
|
||||
#endif
|
||||
|
||||
if (strlen(pd->gpio_prnt_chip) > MAX_STR_SIZE) {
|
||||
dev_err(&pdev->dev, "%s: gpio chip name is too long: %s\n",
|
||||
@@ -49,7 +54,15 @@ static struct gpio_chip *isc_gpio_get_chip(struct platform_device *pdev,
|
||||
}
|
||||
strcpy(name, pd->gpio_prnt_chip);
|
||||
|
||||
#if defined(NV_GPIOCHIP_FIND_PRESENT) /* Linux 6.7 */
|
||||
gc = gpiochip_find(name, isc_gpio_chip_match);
|
||||
#else
|
||||
gdev = gpio_device_find(name, isc_gpio_chip_match);
|
||||
if (gdev) {
|
||||
gc = gpio_device_get_chip(gdev);
|
||||
gpio_device_put(gdev);
|
||||
}
|
||||
#endif
|
||||
if (!gc) {
|
||||
dev_err(&pdev->dev, "%s: unable to find gpio parent chip %s\n",
|
||||
__func__, pd->gpio_prnt_chip);
|
||||
@@ -275,7 +288,10 @@ static int isc_gpio_probe(struct platform_device *pdev)
|
||||
gc->base = -1;
|
||||
gc->ngpio = pd->max_gpio;
|
||||
gc->label = "isc-gpio";
|
||||
gc->parent = &pdev->dev;
|
||||
#if defined(NV_GPIO_CHIP_STRUCT_HAS_OF_NODE_PRESENT) /* Linux 6.2 */
|
||||
gc->of_node = pdev->dev.of_node;
|
||||
#endif
|
||||
gc->owner = THIS_MODULE;
|
||||
|
||||
err = gpiochip_add_data(gc, isc_gpio);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/platform_device.h>
|
||||
@@ -18,7 +19,6 @@
|
||||
#include <asm/siginfo.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/sched/signal.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/atomic.h>
|
||||
@@ -813,15 +813,23 @@ static int isc_mgr_of_get_grp_gpio(
|
||||
struct device *dev, struct device_node *np,
|
||||
const char *name, int size, u32 *grp, u32 *flags)
|
||||
{
|
||||
char prop_name[32]; /* 32 is max size of property name */
|
||||
int num, i;
|
||||
|
||||
num = of_gpio_named_count(np, name);
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", name, num);
|
||||
snprintf(prop_name, sizeof(prop_name), "%s-gpios", name);
|
||||
|
||||
num = gpiod_count(dev, name);
|
||||
dev_dbg(dev, " num gpios of %s: %d\n", prop_name, num);
|
||||
if (num < 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; (i < num) && (i < size); i++) {
|
||||
grp[i] = of_get_named_gpio_flags(np, name, i, &flags[i]);
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
grp[i] = of_get_named_gpio_flags(np, prop_name, i, &flags[i]);
|
||||
#else
|
||||
grp[i] = of_get_named_gpio(np, prop_name, i);
|
||||
flags[i] = 0;
|
||||
#endif
|
||||
if ((int)grp[i] < 0) {
|
||||
dev_err(dev, "%s: gpio[%d] invalid\n", __func__, i);
|
||||
return -EINVAL;
|
||||
@@ -924,13 +932,13 @@ static struct isc_mgr_platform_data *of_isc_mgr_pdata(struct platform_device
|
||||
dev_dbg(&pdev->dev, " csiport: %d\n", pd->csi_port);
|
||||
|
||||
pd->num_pwr_gpios = isc_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, np, "pwdn-gpios",
|
||||
&pdev->dev, np, "pwdn",
|
||||
ARRAY_SIZE(pd->pwr_gpios), pd->pwr_gpios, pd->pwr_flags);
|
||||
if (pd->num_pwr_gpios < 0)
|
||||
return ERR_PTR(pd->num_pwr_gpios);
|
||||
|
||||
pd->num_misc_gpios = isc_mgr_of_get_grp_gpio(
|
||||
&pdev->dev, np, "misc-gpios",
|
||||
&pdev->dev, np, "misc",
|
||||
ARRAY_SIZE(pd->misc_gpios), pd->misc_gpios, pd->misc_flags);
|
||||
if (pd->num_misc_gpios < 0)
|
||||
return ERR_PTR(pd->num_misc_gpios);
|
||||
@@ -957,10 +965,10 @@ static struct isc_mgr_platform_data *of_isc_mgr_pdata(struct platform_device
|
||||
return pd;
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
|
||||
static char *isc_mgr_devnode(struct device *dev, umode_t *mode)
|
||||
#else
|
||||
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
|
||||
static char *isc_mgr_devnode(const struct device *dev, umode_t *mode)
|
||||
#else
|
||||
static char *isc_mgr_devnode(struct device *dev, umode_t *mode)
|
||||
#endif
|
||||
{
|
||||
if (!mode)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2016-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// Copyright (c) 2016-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@@ -130,7 +132,9 @@ static const struct pwm_ops isc_pwm_ops = {
|
||||
.enable = isc_pwm_enable,
|
||||
.disable = isc_pwm_disable,
|
||||
#endif
|
||||
#if defined(NV_PWM_OPS_STRUCT_HAS_OWNER) /* Linux 6.7 */
|
||||
.owner = THIS_MODULE,
|
||||
#endif
|
||||
};
|
||||
|
||||
static int isc_pwm_probe(struct platform_device *pdev)
|
||||
@@ -159,7 +163,9 @@ static int isc_pwm_probe(struct platform_device *pdev)
|
||||
|
||||
info->chip.dev = &pdev->dev;
|
||||
info->chip.ops = &isc_pwm_ops;
|
||||
#if defined(NV_PWM_CHIP_STRUCT_HAS_BASE_ARG)
|
||||
info->chip.base = -1;
|
||||
#endif
|
||||
info->chip.npwm = npwm;
|
||||
info->chip.of_xlate = of_isc_pwm_xlate;
|
||||
info->chip.of_pwm_n_cells = 2;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* Maxim MAX77851 MFD Driver
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mfd/core.h>
|
||||
@@ -14,7 +16,6 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#define IS_MX_MASTER23(fps) ((fps == MX_FPS_MASTER2) || (fps == MX_FPS_MASTER3))
|
||||
#define IS_MX_MASTER01(fps) ((fps == MX_FPS_MASTER0) || (fps == MX_FPS_MASTER1))
|
||||
@@ -503,7 +504,7 @@ static void max77851_pm_power_off(void)
|
||||
FPS_SW_COLD_RST, FPS_SW_COLD_RST);
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int max77851_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int max77851_probe(struct i2c_client *client,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (C) 2020-2023 NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mfd/core.h>
|
||||
@@ -16,7 +18,6 @@
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
static const struct resource rtc_resources[] = {
|
||||
DEFINE_RES_IRQ(NVVRS_PSEQ_INT_SRC1_RTC),
|
||||
@@ -185,7 +186,7 @@ static int nvvrs_pseq_vendor_info(struct nvvrs_pseq_chip *chip)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int nvvrs_pseq_probe(struct i2c_client *client)
|
||||
#else
|
||||
static int nvvrs_pseq_probe(struct i2c_client *client,
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
|
||||
ifeq ($(findstring ack_src,$(NV_BUILD_KERNEL_OPTIONS)),)
|
||||
ifneq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y)
|
||||
obj-m += mods/
|
||||
endif
|
||||
endif
|
||||
obj-m += nvsciipc/
|
||||
ifdef CONFIG_PCI
|
||||
obj-m += tegra-pcie-dma-test.o
|
||||
endif
|
||||
ifneq ($(CONFIG_TEGRA_GPIO_LEGACY_DISABLE),y)
|
||||
obj-m += bluedroid_pm.o
|
||||
endif
|
||||
obj-m += nvscic2c-pcie/
|
||||
obj-m += ioctl_example.o
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved */
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2019-2023 NVIDIA CORPORATION. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/module.h>
|
||||
@@ -13,7 +17,6 @@
|
||||
#include <linux/delay.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/version.h>
|
||||
#include "bluedroid_pm.h"
|
||||
|
||||
#define PROC_DIR "bluetooth/sleep"
|
||||
@@ -209,7 +212,7 @@ static ssize_t lpm_read_proc(struct file *file, char __user *buf, size_t size,
|
||||
loff_t *ppos)
|
||||
{
|
||||
char msg[50];
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
|
||||
#if defined(NV_PDE_DATA_LOWER_CASE_PRESENT) /* Linux v5.17 */
|
||||
struct bluedroid_pm_data *bluedroid_pm = pde_data(file_inode(file));
|
||||
#else
|
||||
struct bluedroid_pm_data *bluedroid_pm = PDE_DATA(file_inode(file));
|
||||
@@ -225,7 +228,7 @@ static ssize_t lpm_write_proc(struct file *file, const char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
char *buf;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
|
||||
#if defined(NV_PDE_DATA_LOWER_CASE_PRESENT) /* Linux v5.17 */
|
||||
struct bluedroid_pm_data *bluedroid_pm = pde_data(file_inode(file));
|
||||
#else
|
||||
struct bluedroid_pm_data *bluedroid_pm = PDE_DATA(file_inode(file));
|
||||
@@ -341,7 +344,9 @@ static int bluedroid_pm_probe(struct platform_device *pdev)
|
||||
int ret;
|
||||
bool enable = false; /* off */
|
||||
struct device_node *node;
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
enum of_gpio_flags of_flags;
|
||||
#endif
|
||||
unsigned long flags;
|
||||
|
||||
bluedroid_pm = devm_kzalloc(&pdev->dev, sizeof(*bluedroid_pm), GFP_KERNEL);
|
||||
@@ -365,9 +370,14 @@ static int bluedroid_pm_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
bluedroid_pm->gpio_reset =
|
||||
of_get_named_gpio_flags(node, "bluedroid_pm,reset-gpio",
|
||||
0, &of_flags);
|
||||
#else
|
||||
bluedroid_pm->gpio_reset =
|
||||
of_get_named_gpio(node, "bluedroid_pm,reset-gpio", 0);
|
||||
#endif
|
||||
bluedroid_pm->gpio_shutdown =
|
||||
of_get_named_gpio(node, "bluedroid_pm,shutdown-gpio", 0);
|
||||
bluedroid_pm->host_wake =
|
||||
@@ -380,7 +390,11 @@ static int bluedroid_pm_probe(struct platform_device *pdev)
|
||||
&bluedroid_pm->resume_min_frequency);
|
||||
|
||||
if (gpio_is_valid(bluedroid_pm->gpio_reset)) {
|
||||
#if defined(NV_OF_GET_NAMED_GPIO_FLAGS_PRESENT) /* Linux 6.2 */
|
||||
flags = (of_flags == OF_GPIO_ACTIVE_LOW) ? GPIOF_ACTIVE_LOW : 0;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
ret = gpio_request_one(bluedroid_pm->gpio_reset, flags,
|
||||
"reset_gpio");
|
||||
if (ret) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/* SPDX-FileCopyrightText: Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved. */
|
||||
/* SPDX-FileCopyrightText: Copyright (c) 2017-2024, NVIDIA CORPORATION. All rights reserved. */
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/dmaengine.h>
|
||||
@@ -279,9 +279,6 @@ int esc_mods_dma_set_config(struct mods_client *client,
|
||||
config.src_maxburst = p_config->src_maxburst;
|
||||
config.dst_maxburst = p_config->dst_maxburst;
|
||||
config.device_fc = (p_config->device_fc == 0) ? false : true;
|
||||
#if KERNEL_VERSION(5, 17, 0) > MODS_KERNEL_VERSION
|
||||
config.slave_id = p_config->slave_id;
|
||||
#endif
|
||||
|
||||
cl_debug(DEBUG_TEGRADMA,
|
||||
"ch: %d dir [%d], addr[%p -> %p], burst [%d %d] width [%d %d]\n",
|
||||
@@ -291,12 +288,6 @@ int esc_mods_dma_set_config(struct mods_client *client,
|
||||
config.src_maxburst, config.dst_maxburst,
|
||||
config.src_addr_width, config.dst_addr_width);
|
||||
|
||||
#if KERNEL_VERSION(5, 17, 0) > MODS_KERNEL_VERSION
|
||||
cl_debug(DEBUG_TEGRADMA,
|
||||
"slave id %d\n",
|
||||
config.slave_id);
|
||||
#endif
|
||||
|
||||
write_lock(&(p_mods_chan->lock));
|
||||
err = dmaengine_slave_config(p_mods_chan->pch, &config);
|
||||
write_unlock(&(p_mods_chan->lock));
|
||||
|
||||
@@ -670,7 +670,7 @@ int esc_mods_send_trustzone_msg(struct mods_client *client,
|
||||
struct MODS_TZ_PARAMS *p);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_OPTEE
|
||||
#if IS_ENABLED(CONFIG_OPTEE)
|
||||
/* OP-TEE TA call */
|
||||
int esc_mods_invoke_optee_ta(struct mods_client *client,
|
||||
struct MODS_OPTEE_PARAMS *p);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <linux/printk.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include <uapi/misc/nvscic2c-pcie-ioctl.h>
|
||||
@@ -345,7 +344,7 @@ endpoint_fops_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||
}
|
||||
|
||||
vma->vm_pgoff = 0;
|
||||
#if defined(CONFIG_TEGRA_SYSTEM_TYPE_ACK) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
|
||||
#if defined(NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS) /* Linux v6.3 */
|
||||
vm_flags_set(vma, VM_DONTCOPY);
|
||||
#else
|
||||
vma->vm_flags |= (VM_DONTCOPY); // fork() not supported.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#define pr_fmt(fmt) "nvscic2c-pcie: epc: " fmt
|
||||
|
||||
#include <linux/aer.h>
|
||||
@@ -290,7 +292,9 @@ deinit:
|
||||
|
||||
pci_release_region(pdev, 0);
|
||||
pci_clear_master(pdev);
|
||||
#if defined(NV_PCI_DISABLE_PCIE_ERROR_REPORTING_PRESENT) /* Linux 6.5 */
|
||||
pci_disable_pcie_error_reporting(pdev);
|
||||
#endif
|
||||
pci_disable_device(pdev);
|
||||
|
||||
dt_release(&drv_ctx->drv_param);
|
||||
@@ -350,7 +354,7 @@ nvscic2c_pcie_epc_probe(struct pci_dev *pdev,
|
||||
ret = pcim_enable_device(pdev);
|
||||
if (ret)
|
||||
goto err_enable_device;
|
||||
#if !defined(NV_DROP_PCIE_ERROR_REPORTING)
|
||||
#if defined(NV_PCI_ENABLE_PCIE_ERROR_REPORTING_PRESENT) /* Linux 6.5 */
|
||||
pci_enable_pcie_error_reporting(pdev);
|
||||
#endif
|
||||
pci_set_master(pdev);
|
||||
|
||||
@@ -733,7 +733,11 @@ static const struct pci_epc_event_ops nvscic2c_event_ops = {
|
||||
};
|
||||
|
||||
static int
|
||||
#if defined(NV_PCI_EPF_DRIVER_STRUCT_PROBE_HAS_ID_ARG) /* Linux 6.4 */
|
||||
nvscic2c_pcie_epf_probe(struct pci_epf *epf, const struct pci_epf_device_id *id)
|
||||
#else
|
||||
nvscic2c_pcie_epf_probe(struct pci_epf *epf)
|
||||
#endif
|
||||
{
|
||||
int ret = 0;
|
||||
char *name = NULL;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#define pr_fmt(fmt) "nvscic2c-pcie: stream-ext: " fmt
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/anon_inodes.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/errno.h>
|
||||
@@ -15,7 +17,6 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/tegra-pcie-edma.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <uapi/misc/nvscic2c-pcie-ioctl.h>
|
||||
|
||||
@@ -294,7 +295,7 @@ fops_mmap(struct file *filep, struct vm_area_struct *vma)
|
||||
memaddr = stream_obj->aper;
|
||||
|
||||
vma->vm_pgoff = 0;
|
||||
#if defined(CONFIG_TEGRA_SYSTEM_TYPE_ACK) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
|
||||
#if defined(NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS) /* Linux v6.3 */
|
||||
vm_flags_set(vma, VM_DONTCOPY);
|
||||
#else
|
||||
vma->vm_flags |= (VM_DONTCOPY);
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Copyright (C) 2021-2023 NVIDIA Corporation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/aer.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/crc32.h>
|
||||
@@ -170,7 +172,7 @@ static int ep_test_dma_probe(struct pci_dev *pdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(NV_DROP_PCIE_ERROR_REPORTING)
|
||||
#if defined(NV_PCI_ENABLE_PCIE_ERROR_REPORTING_PRESENT) /* Linux 6.5 */
|
||||
pci_enable_pcie_error_reporting(pdev);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2477,12 +2477,14 @@ static int ether_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)
|
||||
(unsigned int)phyreg);
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
|
||||
#if defined(NV_MII_BUS_STRUCT_HAS_WRITE_C45) /* Linux v6.3 */
|
||||
static int ether_mdio_write_c45(struct mii_bus *bus, int phyaddr, int devad, int regnum, u16 val)
|
||||
{
|
||||
return ether_mdio_write(bus, phyaddr, ether_mdio_c45_addr(devad, regnum), val);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NV_MII_BUS_STRUCT_HAS_READ_C45) /* Linux v6.3 */
|
||||
static int ether_mdio_read_c45(struct mii_bus *bus, int phyaddr, int devad, int regnum)
|
||||
{
|
||||
return ether_mdio_read(bus, phyaddr, ether_mdio_c45_addr(devad, regnum));
|
||||
@@ -2521,8 +2523,10 @@ static int ether_mdio_register(struct ether_priv_data *pdata)
|
||||
new_bus->name = "nvethernet_mdio_bus";
|
||||
new_bus->read = ether_mdio_read;
|
||||
new_bus->write = ether_mdio_write;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
|
||||
#if defined(NV_MII_BUS_STRUCT_HAS_READ_C45) /* Linux v6.3 */
|
||||
new_bus->read_c45 = ether_mdio_read_c45;
|
||||
#endif
|
||||
#if defined(NV_MII_BUS_STRUCT_HAS_WRITE_C45) /* Linux v6.3 */
|
||||
new_bus->write_c45 = ether_mdio_write_c45;
|
||||
#endif
|
||||
ret = snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(dev));
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#ifndef ETHER_LINUX_H
|
||||
#define ETHER_LINUX_H
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/platform/tegra/ptp-notifier.h>
|
||||
#include <linux/ptp_clock_kernel.h>
|
||||
#include <linux/pinctrl/consumer.h>
|
||||
@@ -37,11 +39,11 @@
|
||||
#include <soc/tegra/virt/hv-ivc.h>
|
||||
#include <soc/tegra/fuse.h>
|
||||
#if IS_ENABLED(CONFIG_PAGE_POOL)
|
||||
#if defined(NV_SPLIT_PAGE_POOL_HEADER)
|
||||
#if defined(NV_NET_PAGE_POOL_H_PRESENT)
|
||||
#include <net/page_pool.h>
|
||||
#else
|
||||
#include <net/page_pool/types.h>
|
||||
#include <net/page_pool/helpers.h>
|
||||
#else
|
||||
#include <net/page_pool.h>
|
||||
#endif
|
||||
#define ETHER_PAGE_POOL
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
@@ -1455,11 +1455,21 @@ static u32 ether_get_rxfh_indir_size(struct net_device *ndev)
|
||||
*
|
||||
* @retval 0 on success
|
||||
*/
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS)
|
||||
static int ether_get_rxfh(struct net_device *ndev,
|
||||
struct ethtool_rxfh_param *rxfh)
|
||||
#else
|
||||
static int ether_get_rxfh(struct net_device *ndev, u32 *indir, u8 *key,
|
||||
u8 *hfunc)
|
||||
#endif
|
||||
{
|
||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS)
|
||||
u32 *indir = rxfh->indir;
|
||||
u8 *hfunc = &rxfh->hfunc;
|
||||
u8 *key = rxfh->key;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
if (indir) {
|
||||
@@ -1487,12 +1497,23 @@ static int ether_get_rxfh(struct net_device *ndev, u32 *indir, u8 *key,
|
||||
* @retval 0 on success
|
||||
* @retval -1 on failure.
|
||||
*/
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS)
|
||||
static int ether_set_rxfh(struct net_device *ndev,
|
||||
struct ethtool_rxfh_param *rxfh,
|
||||
struct netlink_ext_ack *extack)
|
||||
#else
|
||||
static int ether_set_rxfh(struct net_device *ndev, const u32 *indir,
|
||||
const u8 *key, const u8 hfunc)
|
||||
#endif
|
||||
{
|
||||
struct ether_priv_data *pdata = netdev_priv(ndev);
|
||||
struct osi_core_priv_data *osi_core = pdata->osi_core;
|
||||
struct osi_ioctl ioctl_data = {};
|
||||
#if defined(NV_ETHTOOL_OPS_GET_SET_RXFH_HAS_RXFH_PARAM_ARGS)
|
||||
u32 *indir = rxfh->indir;
|
||||
u8 hfunc = rxfh->hfunc;
|
||||
u8 *key = rxfh->key;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
if (!netif_running(ndev)) {
|
||||
|
||||
@@ -749,7 +749,7 @@ static int tvnet_host_probe(struct pci_dev *pdev,
|
||||
goto free_netdev;
|
||||
}
|
||||
|
||||
#if !defined(NV_DROP_PCIE_ERROR_REPORTING)
|
||||
#if defined(NV_PCI_ENABLE_PCIE_ERROR_REPORTING_PRESENT) /* Linux 6.5 */
|
||||
pci_enable_pcie_error_reporting(pdev);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2113,7 +2113,7 @@ static u32 rtl8168_mdio_real_read_phy_ocp(struct rtl8168_private *tp,
|
||||
return mdio_real_direct_read_phy_ocp(tp, ocp_addr);
|
||||
}
|
||||
|
||||
u32 mdio_real_read(struct rtl8168_private *tp,
|
||||
static u32 mdio_real_read(struct rtl8168_private *tp,
|
||||
u32 RegAddr)
|
||||
{
|
||||
int i, value = 0;
|
||||
|
||||
@@ -93,7 +93,7 @@ void rtl8168_eeprom_cleanup(struct rtl8168_private *tp)
|
||||
rtl8168_lower_clock(tp, &x);
|
||||
}
|
||||
|
||||
int rtl8168_eeprom_cmd_done(struct rtl8168_private *tp)
|
||||
static int rtl8168_eeprom_cmd_done(struct rtl8168_private *tp)
|
||||
{
|
||||
u8 x;
|
||||
int i;
|
||||
|
||||
@@ -1,907 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
|
||||
#undef DEBUG
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <linux/tty.h>
|
||||
#include <linux/tty_flip.h>
|
||||
#include <linux/serial.h>
|
||||
#include <linux/serial_core.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/io.h>
|
||||
#include <soc/tegra/fuse.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#define DRV_NAME "tegra_hv_net"
|
||||
#define DRV_VERSION "0.1"
|
||||
|
||||
#include <soc/tegra/virt/syscalls.h>
|
||||
#include <soc/tegra/virt/hv-ivc.h>
|
||||
|
||||
/* frame format is
|
||||
* 0000: <flags>
|
||||
* 0004: data
|
||||
*
|
||||
* data frame
|
||||
* 0000: [16-bit frame size][13-bit pad][Last-bit][First-bit][F_CNTRL=0]
|
||||
* 0004: [packet-size 32 bit]
|
||||
* 0008: data
|
||||
*
|
||||
* control frame
|
||||
* 0000: <flags> (F_CNTRL == 1) F_CNTRL_CMD(x)
|
||||
* 0004: control frame data (deduced from F_CNTRL_CMD)
|
||||
*/
|
||||
|
||||
/* data header size */
|
||||
#define HDR_SIZE 8
|
||||
|
||||
#define F_CNTRL (1 << 0) /* control frame (0 = data frame) */
|
||||
#define F_CNTRL_CMD(x) ((u32)((x) & 0xff) << 24) /* control frame command */
|
||||
|
||||
#define F_CNTRL_CMD_STATUS F_CNTRL_CMD(0) /* link status cmd */
|
||||
#define F_STATUS_UP (1 << 1) /* link status is up */
|
||||
#define F_STATUS_PAUSE (1 << 2) /* link status is pause */
|
||||
|
||||
#define F_STATUS_PENDING (1 << 23) /* pending link status update */
|
||||
|
||||
#define F_DATA_FIRST (1 << 1) /* first chunk of a frame */
|
||||
#define F_DATA_LAST (1 << 2) /* last chunk of a frame */
|
||||
#define F_DATA_FSIZE_SHIFT 16
|
||||
#define F_DATA_FSIZE_MASK (~0 << F_DATA_FSIZE_SHIFT)
|
||||
#define F_DATA_FSIZE(x) (((u32)(x) << F_DATA_FSIZE_SHIFT) & F_DATA_FSIZE_MASK)
|
||||
|
||||
/* jumbo frame limit */
|
||||
#define MAX_MTU 9000
|
||||
#define MIN_MTU 14
|
||||
|
||||
#define DEFAULT_HIGH_WATERMARK_MULT 50
|
||||
#define DEFAULT_LOW_WATERMARK_MULT 25
|
||||
#define DEFAULT_MAX_TX_DELAY_MSECS 10
|
||||
|
||||
enum drop_kind {
|
||||
dk_none,
|
||||
/* tx */
|
||||
dk_linearize,
|
||||
dk_full,
|
||||
dk_wq,
|
||||
dk_write,
|
||||
/* rx */
|
||||
dk_frame,
|
||||
dk_packet,
|
||||
dk_unexpected,
|
||||
dk_alloc,
|
||||
dk_overflow,
|
||||
};
|
||||
|
||||
struct tegra_hv_net_stats {
|
||||
struct u64_stats_sync tx_syncp;
|
||||
struct u64_stats_sync rx_syncp;
|
||||
u64 tx_bytes;
|
||||
u64 tx_packets;
|
||||
u64 tx_drops;
|
||||
|
||||
u64 rx_bytes;
|
||||
u64 rx_packets;
|
||||
u64 rx_drops;
|
||||
|
||||
/* internal tx stats */
|
||||
u64 tx_linearize_fail;
|
||||
u64 tx_queue_full;
|
||||
u64 tx_wq_fail;
|
||||
u64 tx_ivc_write_fail;
|
||||
/* internal rx stats */
|
||||
u64 rx_bad_frame;
|
||||
u64 rx_bad_packet;
|
||||
u64 rx_unexpected_packet;
|
||||
u64 rx_alloc_fail;
|
||||
u64 rx_overflow;
|
||||
};
|
||||
|
||||
struct tegra_hv_net {
|
||||
struct platform_device *pdev;
|
||||
struct net_device *ndev;
|
||||
struct tegra_hv_ivc_cookie *ivck;
|
||||
int mac_address;
|
||||
struct napi_struct napi;
|
||||
struct tegra_hv_net_stats __percpu *stats;
|
||||
|
||||
struct sk_buff *rx_skb;
|
||||
struct sk_buff_head tx_q;
|
||||
|
||||
struct work_struct xmit_work;
|
||||
struct workqueue_struct *xmit_wq;
|
||||
wait_queue_head_t wq;
|
||||
|
||||
unsigned int high_watermark; /* mult * framesize */
|
||||
unsigned int low_watermark;
|
||||
unsigned int max_tx_delay;
|
||||
};
|
||||
|
||||
static int tegra_hv_net_open(struct net_device *ndev)
|
||||
{
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
napi_enable(&hvn->napi);
|
||||
netif_start_queue(ndev);
|
||||
|
||||
/*
|
||||
* check if there are already packets in our queue,
|
||||
* and if so, we need to schedule a call to handle them
|
||||
*/
|
||||
if (tegra_hv_ivc_can_read(hvn->ivck))
|
||||
napi_schedule(&hvn->napi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static irqreturn_t tegra_hv_net_interrupt(int irq, void *data)
|
||||
{
|
||||
struct net_device *ndev = data;
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
/* until this function returns 0, the channel is unusable */
|
||||
if (tegra_hv_ivc_channel_notified(hvn->ivck) != 0)
|
||||
return IRQ_HANDLED;
|
||||
|
||||
if (tegra_hv_ivc_can_write(hvn->ivck))
|
||||
wake_up_interruptible_all(&hvn->wq);
|
||||
|
||||
if (tegra_hv_ivc_can_read(hvn->ivck))
|
||||
napi_schedule(&hvn->napi);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void *tegra_hv_net_xmit_get_buffer(struct tegra_hv_net *hvn)
|
||||
{
|
||||
void *p;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* grabbing a frame can fail for the following reasons:
|
||||
* 1. the channel is full / peer is uncooperative
|
||||
* 2. the channel is under reset / peer has restarted
|
||||
*/
|
||||
p = tegra_hv_ivc_write_get_next_frame(hvn->ivck);
|
||||
if (IS_ERR(p)) {
|
||||
ret = wait_event_interruptible_timeout(hvn->wq,
|
||||
!IS_ERR(p = tegra_hv_ivc_write_get_next_frame(
|
||||
hvn->ivck)),
|
||||
msecs_to_jiffies(hvn->max_tx_delay));
|
||||
if (ret <= 0) {
|
||||
net_warn_ratelimited(
|
||||
"%s: timed out after %u ms\n",
|
||||
hvn->ndev->name,
|
||||
hvn->max_tx_delay);
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void tegra_hv_net_xmit_work(struct work_struct *work)
|
||||
{
|
||||
struct tegra_hv_net *hvn =
|
||||
container_of(work, struct tegra_hv_net, xmit_work);
|
||||
struct tegra_hv_net_stats *stats = raw_cpu_ptr(hvn->stats);
|
||||
struct net_device *ndev = hvn->ndev;
|
||||
struct sk_buff *skb;
|
||||
int ret, max_frame, count, first, last, orig_len;
|
||||
u32 *p, p0, p1;
|
||||
enum drop_kind dk;
|
||||
|
||||
max_frame = hvn->ivck->frame_size - HDR_SIZE;
|
||||
|
||||
dk = dk_none;
|
||||
while ((skb = skb_dequeue(&hvn->tx_q)) != NULL) {
|
||||
|
||||
/* start the queue if it is short again */
|
||||
if (netif_queue_stopped(ndev) &&
|
||||
skb_queue_len(&hvn->tx_q) < hvn->low_watermark)
|
||||
netif_start_queue(ndev);
|
||||
|
||||
ret = skb_linearize(skb);
|
||||
if (ret != 0) {
|
||||
netdev_err(hvn->ndev,
|
||||
"%s: skb_linearize error=%d\n",
|
||||
__func__, ret);
|
||||
|
||||
dk = dk_linearize;
|
||||
goto drop;
|
||||
}
|
||||
|
||||
/* print_hex_dump(KERN_INFO, "tx-", DUMP_PREFIX_OFFSET,
|
||||
* 16, 1, skb->data, skb->len, true); */
|
||||
|
||||
/* copy the fragments */
|
||||
orig_len = skb->len;
|
||||
first = 1;
|
||||
while (skb->len > 0) {
|
||||
count = skb->len;
|
||||
if (count > max_frame)
|
||||
count = max_frame;
|
||||
|
||||
/* wait up to the maximum send timeout */
|
||||
p = tegra_hv_net_xmit_get_buffer(hvn);
|
||||
if (IS_ERR(p)) {
|
||||
dk = dk_wq;
|
||||
goto drop;
|
||||
}
|
||||
|
||||
last = skb->len == count;
|
||||
|
||||
p0 = F_DATA_FSIZE(count);
|
||||
if (first)
|
||||
p0 |= F_DATA_FIRST;
|
||||
if (last)
|
||||
p0 |= F_DATA_LAST;
|
||||
p1 = orig_len;
|
||||
|
||||
netdev_dbg(ndev, "F: %c%c F%d P%d [%08x %08x]\n",
|
||||
first ? 'F' : '.',
|
||||
last ? 'L' : '.',
|
||||
count, orig_len, p[0], p[1]);
|
||||
|
||||
first = 0;
|
||||
|
||||
p[0] = p0;
|
||||
p[1] = p1;
|
||||
skb_copy_from_linear_data(skb, &p[2], count);
|
||||
|
||||
/* advance the tx queue */
|
||||
(void)tegra_hv_ivc_write_advance(hvn->ivck);
|
||||
skb_pull(skb, count);
|
||||
}
|
||||
/* all OK */
|
||||
dk = dk_none;
|
||||
|
||||
drop:
|
||||
dev_kfree_skb(skb);
|
||||
|
||||
u64_stats_update_begin(&stats->tx_syncp);
|
||||
if (dk == dk_none) {
|
||||
stats->tx_packets++;
|
||||
stats->tx_bytes += orig_len;
|
||||
} else {
|
||||
stats->tx_drops++;
|
||||
switch (dk) {
|
||||
default:
|
||||
/* never happens but gcc sometimes whines */
|
||||
break;
|
||||
case dk_linearize:
|
||||
stats->tx_linearize_fail++;
|
||||
break;
|
||||
case dk_full:
|
||||
stats->tx_queue_full++;
|
||||
break;
|
||||
case dk_wq:
|
||||
stats->tx_wq_fail++;
|
||||
break;
|
||||
case dk_write:
|
||||
stats->tx_ivc_write_fail++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
u64_stats_update_end(&stats->tx_syncp);
|
||||
}
|
||||
}
|
||||
|
||||
/* xmit is dummy, we just add the skb to the tx_q and queue work */
|
||||
static netdev_tx_t tegra_hv_net_xmit(struct sk_buff *skb,
|
||||
struct net_device *ndev)
|
||||
{
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
skb_orphan(skb);
|
||||
nf_reset_ct(skb);
|
||||
skb_queue_tail(&hvn->tx_q, skb);
|
||||
queue_work_on(WORK_CPU_UNBOUND, hvn->xmit_wq, &hvn->xmit_work);
|
||||
|
||||
/* stop the queue if it gets too long */
|
||||
if (!netif_queue_stopped(ndev) &&
|
||||
skb_queue_len(&hvn->tx_q) >= hvn->high_watermark)
|
||||
netif_stop_queue(ndev);
|
||||
else if (netif_queue_stopped(ndev) &&
|
||||
skb_queue_len(&hvn->tx_q) < hvn->low_watermark)
|
||||
netif_start_queue(ndev);
|
||||
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
tegra_hv_net_stop(struct net_device *ndev)
|
||||
{
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
netif_stop_queue(ndev);
|
||||
napi_disable(&hvn->napi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tegra_hv_net_change_mtu(struct net_device *ndev, int new_mtu)
|
||||
{
|
||||
if (new_mtu < MIN_MTU || new_mtu > MAX_MTU) {
|
||||
netdev_err(ndev, "invalid MTU, max MTU is: %d\n", MAX_MTU);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ndev->mtu == new_mtu)
|
||||
return 0;
|
||||
|
||||
/* we can really handle any MTU size */
|
||||
ndev->mtu = new_mtu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tegra_hv_net_set_rx_mode(struct net_device *ndev)
|
||||
{
|
||||
/* we don't do any kind of filtering */
|
||||
}
|
||||
|
||||
static void tegra_hv_net_tx_timeout(struct net_device *ndev, unsigned int txqueue)
|
||||
{
|
||||
netdev_err(ndev, "%s\n", __func__);
|
||||
}
|
||||
|
||||
void
|
||||
tegra_hv_net_get_stats64(struct net_device *ndev,
|
||||
struct rtnl_link_stats64 *tot)
|
||||
{
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
struct tegra_hv_net_stats *stats;
|
||||
u64 tx_packets, tx_bytes, tx_drops, rx_packets, rx_bytes, rx_drops;
|
||||
unsigned int start;
|
||||
int cpu;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
stats = per_cpu_ptr(hvn->stats, cpu);
|
||||
|
||||
do {
|
||||
start = u64_stats_fetch_begin_irq(&stats->tx_syncp);
|
||||
tx_packets = stats->tx_packets;
|
||||
tx_bytes = stats->tx_bytes;
|
||||
tx_drops = stats->tx_drops;
|
||||
} while (u64_stats_fetch_retry_irq(&stats->tx_syncp, start));
|
||||
|
||||
do {
|
||||
start = u64_stats_fetch_begin_irq(&stats->rx_syncp);
|
||||
rx_packets = stats->rx_packets;
|
||||
rx_bytes = stats->rx_bytes;
|
||||
rx_drops = stats->rx_drops;
|
||||
} while (u64_stats_fetch_retry_irq(&stats->rx_syncp, start));
|
||||
|
||||
tot->tx_packets += tx_packets;
|
||||
tot->tx_bytes += tx_bytes;
|
||||
tot->tx_dropped += tx_drops;
|
||||
|
||||
tot->rx_packets += rx_packets;
|
||||
tot->rx_bytes += rx_bytes;
|
||||
tot->rx_dropped += rx_drops;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int tegra_hv_net_set_mac_address(struct net_device *dev, void *p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct net_device_ops tegra_hv_netdev_ops = {
|
||||
.ndo_open = tegra_hv_net_open,
|
||||
.ndo_start_xmit = tegra_hv_net_xmit,
|
||||
.ndo_stop = tegra_hv_net_stop,
|
||||
.ndo_change_mtu = tegra_hv_net_change_mtu,
|
||||
.ndo_set_rx_mode = tegra_hv_net_set_rx_mode,
|
||||
.ndo_tx_timeout = tegra_hv_net_tx_timeout,
|
||||
.ndo_get_stats64 = tegra_hv_net_get_stats64,
|
||||
.ndo_set_mac_address = tegra_hv_net_set_mac_address,
|
||||
};
|
||||
|
||||
static void tegra_hv_net_ethtool_get_drvinfo(struct net_device *ndev,
|
||||
struct ethtool_drvinfo *info)
|
||||
{
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
|
||||
strlcpy(info->version, DRV_VERSION, sizeof(info->version));
|
||||
strlcpy(info->bus_info, dev_name(&hvn->pdev->dev),
|
||||
sizeof(info->bus_info));
|
||||
}
|
||||
|
||||
static const struct ethtool_ops tegra_hv_ethtool_ops = {
|
||||
.get_drvinfo = tegra_hv_net_ethtool_get_drvinfo,
|
||||
.get_link = ethtool_op_get_link,
|
||||
};
|
||||
|
||||
static void tegra_hv_net_tx_complete(struct tegra_hv_net *hvn)
|
||||
{
|
||||
struct net_device *ndev = hvn->ndev;
|
||||
|
||||
/* wake queue if no more tx buffers */
|
||||
if (skb_queue_len(&hvn->tx_q) == 0)
|
||||
netif_wake_queue(ndev);
|
||||
|
||||
}
|
||||
|
||||
static int tegra_hv_net_rx(struct tegra_hv_net *hvn, int limit)
|
||||
{
|
||||
struct tegra_hv_net_stats *stats = this_cpu_ptr(hvn->stats);
|
||||
struct net_device *ndev = hvn->ndev;
|
||||
struct sk_buff *skb;
|
||||
int nr, frame_size, max_frame, count, first, last;
|
||||
u32 *p, p0;
|
||||
enum drop_kind dk;
|
||||
|
||||
max_frame = hvn->ivck->frame_size - HDR_SIZE;
|
||||
|
||||
nr = 0;
|
||||
dk = dk_none;
|
||||
while (nr < limit) {
|
||||
/*
|
||||
* grabbing a frame can fail for the following reasons:
|
||||
* 1. the channel is empty / peer is uncooperative
|
||||
* 2. the channel is under reset / peer has restarted
|
||||
*/
|
||||
p = tegra_hv_ivc_read_get_next_frame(hvn->ivck);
|
||||
if (IS_ERR(p))
|
||||
break;
|
||||
|
||||
nr++;
|
||||
|
||||
p0 = p[0];
|
||||
first = !!(p0 & F_DATA_FIRST);
|
||||
last = !!(p0 & F_DATA_LAST);
|
||||
frame_size = (p0 & F_DATA_FSIZE_MASK) >> F_DATA_FSIZE_SHIFT;
|
||||
count = p[1];
|
||||
|
||||
netdev_dbg(ndev, "F: %c%c F%d P%d [%08x %08x]\n",
|
||||
first ? 'F' : '.',
|
||||
last ? 'L' : '.',
|
||||
frame_size, count, p[0], p[1]);
|
||||
|
||||
if (frame_size > max_frame) {
|
||||
netdev_err(ndev, "Bad fragment size %d\n", frame_size);
|
||||
dk = dk_frame;
|
||||
goto drop;
|
||||
}
|
||||
|
||||
/* verify that packet is sane */
|
||||
if (count < MIN_MTU || count > MAX_MTU + MIN_MTU) {
|
||||
netdev_err(ndev, "Bad packet size %d\n", count);
|
||||
dk = dk_packet;
|
||||
goto drop;
|
||||
}
|
||||
/* receive state machine */
|
||||
if (hvn->rx_skb == NULL) {
|
||||
if (!first) {
|
||||
netdev_err(ndev, "unexpected fragment\n");
|
||||
dk = dk_unexpected;
|
||||
goto drop;
|
||||
}
|
||||
hvn->rx_skb = netdev_alloc_skb(ndev, count);
|
||||
if (hvn->rx_skb == NULL) {
|
||||
netdev_err(ndev, "failed to allocate packet\n");
|
||||
dk = dk_alloc;
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
/* verify that skb still can receive the data */
|
||||
if (skb_tailroom(hvn->rx_skb) < frame_size) {
|
||||
netdev_err(ndev, "skb overflow\n");
|
||||
dev_kfree_skb(hvn->rx_skb);
|
||||
hvn->rx_skb = NULL;
|
||||
dk = dk_overflow;
|
||||
goto drop;
|
||||
}
|
||||
|
||||
/* append the data */
|
||||
skb = hvn->rx_skb;
|
||||
skb_copy_to_linear_data_offset(skb, skb->len, p + 2,
|
||||
frame_size);
|
||||
skb_put(skb, frame_size);
|
||||
|
||||
if (last) {
|
||||
/* print_hex_dump(KERN_INFO, "rx-", DUMP_PREFIX_OFFSET,
|
||||
* 16, 1, skb->data, skb->len, true); */
|
||||
|
||||
count = skb->len;
|
||||
|
||||
skb->protocol = eth_type_trans(skb, ndev);
|
||||
skb->ip_summed = CHECKSUM_NONE;
|
||||
netif_receive_skb(skb);
|
||||
hvn->rx_skb = NULL;
|
||||
}
|
||||
dk = dk_none;
|
||||
drop:
|
||||
(void)tegra_hv_ivc_read_advance(hvn->ivck);
|
||||
|
||||
u64_stats_update_begin(&stats->rx_syncp);
|
||||
if (dk == dk_none) {
|
||||
if (last) {
|
||||
stats->rx_packets++;
|
||||
stats->rx_bytes += count;
|
||||
}
|
||||
} else {
|
||||
stats->rx_drops++;
|
||||
switch (dk) {
|
||||
default:
|
||||
/* never happens but gcc sometimes whines */
|
||||
break;
|
||||
case dk_frame:
|
||||
stats->rx_bad_frame++;
|
||||
break;
|
||||
case dk_packet:
|
||||
stats->rx_bad_packet++;
|
||||
break;
|
||||
case dk_unexpected:
|
||||
stats->rx_unexpected_packet++;
|
||||
break;
|
||||
case dk_alloc:
|
||||
stats->rx_alloc_fail++;
|
||||
break;
|
||||
case dk_overflow:
|
||||
stats->rx_overflow++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
u64_stats_update_end(&stats->rx_syncp);
|
||||
|
||||
}
|
||||
return nr;
|
||||
}
|
||||
|
||||
static int tegra_hv_net_poll(struct napi_struct *napi, int budget)
|
||||
{
|
||||
struct tegra_hv_net *hvn =
|
||||
container_of(napi, struct tegra_hv_net, napi);
|
||||
int work_done = 0;
|
||||
|
||||
tegra_hv_net_tx_complete(hvn);
|
||||
|
||||
work_done = tegra_hv_net_rx(hvn, budget);
|
||||
|
||||
if (work_done < budget) {
|
||||
napi_complete(napi);
|
||||
|
||||
/*
|
||||
* if an interrupt occurs after tegra_hv_net_rx() but before
|
||||
* napi_complete(), we lose the call to napi_schedule().
|
||||
*/
|
||||
if (tegra_hv_ivc_can_read(hvn->ivck))
|
||||
napi_reschedule(napi);
|
||||
}
|
||||
|
||||
return work_done;
|
||||
}
|
||||
|
||||
static int tegra_hv_net_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *dn, *hv_dn;
|
||||
struct net_device *ndev = NULL;
|
||||
struct tegra_hv_net *hvn = NULL;
|
||||
int ret;
|
||||
u32 id;
|
||||
u32 highmark, lowmark, txdelay;
|
||||
|
||||
if (!is_tegra_hypervisor_mode()) {
|
||||
dev_info(dev, "Hypervisor is not present\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
dn = dev->of_node;
|
||||
if (dn == NULL) {
|
||||
dev_err(dev, "No OF data\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hv_dn = of_parse_phandle(dn, "ivc", 0);
|
||||
if (hv_dn == NULL) {
|
||||
dev_err(dev, "Failed to parse phandle of ivc prop\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32_index(dn, "ivc", 1, &id);
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to read IVC property ID\n");
|
||||
goto out_of_put;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(dn, "high-watermark-mult", &highmark);
|
||||
if (ret != 0)
|
||||
highmark = DEFAULT_HIGH_WATERMARK_MULT;
|
||||
|
||||
ret = of_property_read_u32(dn, "low-watermark-mult", &lowmark);
|
||||
if (ret != 0)
|
||||
lowmark = DEFAULT_LOW_WATERMARK_MULT;
|
||||
|
||||
if (highmark <= lowmark) {
|
||||
dev_err(dev, "Bad watermark configuration (high <= low = %u < %u)\n",
|
||||
highmark, lowmark);
|
||||
goto out_of_put;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(dn, "max-tx-delay-msecs", &txdelay);
|
||||
if (ret != 0)
|
||||
txdelay = DEFAULT_MAX_TX_DELAY_MSECS;
|
||||
|
||||
ndev = alloc_netdev(sizeof(*hvn), "hv%d", NET_NAME_UNKNOWN,
|
||||
ether_setup);
|
||||
if (ndev == NULL) {
|
||||
dev_err(dev, "Failed to allocate netdev\n");
|
||||
ret = -ENOMEM;
|
||||
goto out_of_put;
|
||||
}
|
||||
|
||||
hvn = netdev_priv(ndev);
|
||||
|
||||
hvn->stats = alloc_percpu(struct tegra_hv_net_stats);
|
||||
if (hvn->stats == NULL) {
|
||||
dev_err(dev, "Failed to allocate per-cpu stats\n");
|
||||
ret = -ENOMEM;
|
||||
goto out_free_ndev;
|
||||
}
|
||||
|
||||
hvn->ivck = tegra_hv_ivc_reserve(hv_dn, id, NULL);
|
||||
of_node_put(hv_dn);
|
||||
hv_dn = NULL;
|
||||
|
||||
if (IS_ERR_OR_NULL(hvn->ivck)) {
|
||||
dev_err(dev, "Failed to reserve IVC channel %d\n", id);
|
||||
ret = PTR_ERR(hvn->ivck);
|
||||
hvn->ivck = NULL;
|
||||
goto out_free_stats;
|
||||
}
|
||||
|
||||
hvn->high_watermark = highmark * hvn->ivck->nframes;
|
||||
hvn->low_watermark = lowmark * hvn->ivck->nframes;
|
||||
hvn->max_tx_delay = txdelay;
|
||||
|
||||
/* make sure the frame size is sufficient */
|
||||
if (hvn->ivck->frame_size <= HDR_SIZE + 4) {
|
||||
dev_err(dev, "frame size too small to support COMM\n");
|
||||
ret = -EINVAL;
|
||||
goto out_unreserve;
|
||||
}
|
||||
|
||||
dev_info(dev, "Reserved IVC channel #%d - frame_size=%d\n",
|
||||
id, hvn->ivck->frame_size);
|
||||
|
||||
SET_NETDEV_DEV(ndev, dev);
|
||||
platform_set_drvdata(pdev, ndev);
|
||||
ether_setup(ndev);
|
||||
ndev->max_mtu = MAX_MTU;
|
||||
ndev->netdev_ops = &tegra_hv_netdev_ops;
|
||||
ndev->ethtool_ops = &tegra_hv_ethtool_ops;
|
||||
skb_queue_head_init(&hvn->tx_q);
|
||||
INIT_WORK(&hvn->xmit_work, tegra_hv_net_xmit_work);
|
||||
|
||||
hvn->pdev = pdev;
|
||||
hvn->ndev = ndev;
|
||||
ndev->irq = hvn->ivck->irq;
|
||||
|
||||
init_waitqueue_head(&hvn->wq);
|
||||
|
||||
ndev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE;
|
||||
ndev->hw_features = 0; /* we're a really dumb device for now */
|
||||
ndev->features |= ndev->hw_features;
|
||||
/* get mac address from the DT */
|
||||
|
||||
hvn->mac_address = of_get_mac_address(dev->of_node, ndev->dev_addr);
|
||||
if (IS_ERR(&hvn->mac_address)) {
|
||||
if (of_property_read_bool(dev->of_node, "use-random-mac-addr"))
|
||||
eth_hw_addr_random(ndev);
|
||||
else {
|
||||
#if KERNEL_VERSION(5, 16, 0) >= LINUX_VERSION_CODE
|
||||
unsigned int gid;
|
||||
|
||||
dev_warn(dev, "No valid mac-address found, using fixed local address\n");
|
||||
|
||||
ndev->dev_addr[0] = 0x0a;
|
||||
ndev->dev_addr[1] = 0x86;
|
||||
ndev->dev_addr[2] = 0x4c;
|
||||
ndev->dev_addr[3] = 0xf8;
|
||||
ndev->dev_addr[4] = (uint8_t)id;
|
||||
|
||||
ret = hyp_read_gid(&gid);
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to read guest id\n");
|
||||
goto out_unreserve;
|
||||
}
|
||||
ndev->dev_addr[5] = (uint8_t)(gid);
|
||||
#else
|
||||
dev_err(dev, "No valid mac-address found\n");
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
/* Set the MAC address. */
|
||||
ether_addr_copy(ndev->dev_addr, (const u8 *)&hvn->mac_address);
|
||||
}
|
||||
|
||||
hvn->xmit_wq = alloc_workqueue("tgvnet-wq-%d",
|
||||
WQ_UNBOUND | WQ_MEM_RECLAIM,
|
||||
1, /* FIXME: from DT? */
|
||||
pdev->id);
|
||||
if (hvn->xmit_wq == NULL) {
|
||||
dev_err(dev, "Failed to allocate workqueue\n");
|
||||
ret = -ENOMEM;
|
||||
goto out_unreserve;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
netif_napi_add_weight(ndev, &hvn->napi, tegra_hv_net_poll, 64);
|
||||
#else
|
||||
netif_napi_add(ndev, &hvn->napi, tegra_hv_net_poll, 64);
|
||||
#endif
|
||||
ret = register_netdev(ndev);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to register netdev\n");
|
||||
goto out_free_wq;
|
||||
}
|
||||
|
||||
/*
|
||||
* start the channel reset process asynchronously. until the reset
|
||||
* process completes, any attempt to use the ivc channel will return
|
||||
* an error (e.g., all transmits will fail).
|
||||
*/
|
||||
tegra_hv_ivc_channel_reset(hvn->ivck);
|
||||
|
||||
/* the interrupt request must be the last action */
|
||||
ret = devm_request_irq(dev, ndev->irq, tegra_hv_net_interrupt, 0,
|
||||
dev_name(dev), ndev);
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Could not request irq #%d\n", ndev->irq);
|
||||
goto out_unreg_netdev;
|
||||
}
|
||||
|
||||
dev_info(dev, "ready\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out_unreg_netdev:
|
||||
unregister_netdev(ndev);
|
||||
|
||||
out_free_wq:
|
||||
netif_napi_del(&hvn->napi);
|
||||
destroy_workqueue(hvn->xmit_wq);
|
||||
|
||||
out_unreserve:
|
||||
tegra_hv_ivc_unreserve(hvn->ivck);
|
||||
|
||||
out_free_stats:
|
||||
free_percpu(hvn->stats);
|
||||
|
||||
out_free_ndev:
|
||||
free_netdev(ndev);
|
||||
|
||||
out_of_put:
|
||||
of_node_put(hv_dn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tegra_hv_net_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct net_device *ndev = platform_get_drvdata(pdev);
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
devm_free_irq(dev, ndev->irq, dev);
|
||||
unregister_netdev(ndev);
|
||||
netif_napi_del(&hvn->napi);
|
||||
destroy_workqueue(hvn->xmit_wq);
|
||||
tegra_hv_ivc_unreserve(hvn->ivck);
|
||||
free_percpu(hvn->stats);
|
||||
free_netdev(ndev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int tegra_hv_net_suspend(struct platform_device *pdev,
|
||||
pm_message_t state)
|
||||
{
|
||||
struct net_device *ndev = platform_get_drvdata(pdev);
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
/* If the netdev is not even running, no action */
|
||||
if (!netif_running(ndev))
|
||||
return 0;
|
||||
|
||||
/* As this device is going to suspend,
|
||||
* link can't be considered up, although we are not resetting
|
||||
* the IVC channel. Therefore mark the link detached
|
||||
* This would stop tx from getting queued as well
|
||||
*/
|
||||
netif_device_detach(ndev);
|
||||
|
||||
ndev->netdev_ops->ndo_stop(ndev);
|
||||
|
||||
/* tegra_hv_net_stop uses netif_stop_queue to disable the queue.
|
||||
* netif_stop_queue doesn't prevent xmit_transfer running on another
|
||||
* cpu, so additionally we need netif_tx_disable
|
||||
*/
|
||||
netif_tx_disable(ndev);
|
||||
|
||||
/* Now no further job should be coming in, but
|
||||
* there could be one queued or running already.
|
||||
* Cancel or wait for such a job
|
||||
*/
|
||||
cancel_work_sync(&hvn->xmit_work);
|
||||
|
||||
/* Workqueue should not be running at this point,
|
||||
* so disable irq
|
||||
*/
|
||||
disable_irq(ndev->irq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tegra_hv_net_resume(struct platform_device *pdev)
|
||||
{
|
||||
struct net_device *ndev = platform_get_drvdata(pdev);
|
||||
struct tegra_hv_net *hvn = netdev_priv(ndev);
|
||||
|
||||
if (!netif_running(ndev))
|
||||
return 0;
|
||||
|
||||
enable_irq(ndev->irq);
|
||||
|
||||
ndev->netdev_ops->ndo_open(ndev);
|
||||
|
||||
/* Would wake the queue and mark the link enabled */
|
||||
netif_device_attach(ndev);
|
||||
|
||||
/* Start the queue blindly, in case the previous
|
||||
* work was cancelled during suspend
|
||||
* If there is no pending xmit,
|
||||
* the workqueue will wake up then exit gracefully
|
||||
*/
|
||||
queue_work_on(WORK_CPU_UNBOUND, hvn->xmit_wq, &hvn->xmit_work);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static struct of_device_id tegra_hv_net_match[] = {
|
||||
{ .compatible = "nvidia,tegra-hv-net", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, tegra_hv_net_match);
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
static struct platform_driver tegra_hv_net_driver = {
|
||||
.probe = tegra_hv_net_probe,
|
||||
.remove = tegra_hv_net_remove,
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
.suspend = tegra_hv_net_suspend,
|
||||
.resume = tegra_hv_net_resume,
|
||||
#endif
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(tegra_hv_net_match),
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(tegra_hv_net_driver);
|
||||
|
||||
MODULE_AUTHOR("Pantelis Antoniou <pantoniou@nvidia.com>");
|
||||
MODULE_DESCRIPTION("Ethernet network device over Tegra Hypervisor IVC channel");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -18,6 +18,7 @@ EXTRA_CFLAGS += -Wno-implicit-fallthrough
|
||||
EXTRA_CFLAGS += -Wno-unused-function
|
||||
#EXTRA_CFLAGS += -Wno-unused
|
||||
#EXTRA_CFLAGS += -Wno-uninitialized
|
||||
EXTRA_CFLAGS += -Wno-missing-prototypes
|
||||
|
||||
GCC_VER_49 := $(shell echo `$(CC) -dumpversion | cut -f1-2 -d.` \>= 4.9 | bc )
|
||||
ifeq ($(GCC_VER_49),1)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
||||
* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
@@ -88,8 +89,6 @@
|
||||
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211)
|
||||
#define PHYDM_SNPRINTF snprintf
|
||||
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
|
||||
#undef pr_debug
|
||||
#define pr_debug printk
|
||||
#define RT_PRINTK(fmt, args...) pr_debug(fmt, ## args)
|
||||
#define RT_DISP(dbgtype, dbgflag, printstr)
|
||||
#define RT_TRACE(adapter, comp, drv_level, fmt, args...) \
|
||||
|
||||
@@ -266,7 +266,11 @@ static const struct pci_epc_event_ops pci_epf_dma_test_event_ops = {
|
||||
.core_deinit = pcie_dma_epf_core_deinit,
|
||||
};
|
||||
|
||||
#if defined(NV_PCI_EPF_DRIVER_STRUCT_PROBE_HAS_ID_ARG) /* Linux 6.4 */
|
||||
static int pcie_dma_epf_probe(struct pci_epf *epf, const struct pci_epf_device_id *id)
|
||||
#else
|
||||
static int pcie_dma_epf_probe(struct pci_epf *epf)
|
||||
#endif
|
||||
{
|
||||
struct device *dev = &epf->dev;
|
||||
struct pcie_epf_dma *epfnv;
|
||||
|
||||
@@ -10,6 +10,7 @@ LINUXINCLUDE += -I$(srctree.nvidia-oot)/drivers/platform/tegra/aon/include
|
||||
ccflags-y += -Werror
|
||||
|
||||
obj-m += tegra234-aon.o
|
||||
obj-m += tegra-aon-ivc-echo.o
|
||||
|
||||
tegra234-aon-objs += \
|
||||
tegra-aon-hsp.o \
|
||||
|
||||
124
drivers/platform/tegra/aon/tegra-aon-ivc-echo.c
Normal file
124
drivers/platform/tegra/aon/tegra-aon-ivc-echo.c
Normal file
@@ -0,0 +1,124 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2017-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/mailbox_client.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/tegra-aon.h>
|
||||
|
||||
#define TX_BLOCK_PERIOD 100
|
||||
#define IVC_FRAME_SIZE 64
|
||||
|
||||
struct tegra_aon_ivc_echo_data {
|
||||
struct mbox_client cl;
|
||||
struct mbox_chan *mbox;
|
||||
char rx_data[IVC_FRAME_SIZE];
|
||||
};
|
||||
|
||||
static ssize_t tegra_aon_ivc_echo_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct tegra_aon_ivc_echo_data *drvdata = dev_get_drvdata(dev);
|
||||
|
||||
memcpy(buf, drvdata->rx_data, IVC_FRAME_SIZE);
|
||||
|
||||
return IVC_FRAME_SIZE;
|
||||
}
|
||||
|
||||
static ssize_t tegra_aon_ivc_echo_tx(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct tegra_aon_ivc_echo_data *drvdata = dev_get_drvdata(dev);
|
||||
struct tegra_aon_mbox_msg msg;
|
||||
int ret;
|
||||
|
||||
if (count > IVC_FRAME_SIZE) {
|
||||
dev_err(dev, "Message is greater than the frame size %d\n",
|
||||
IVC_FRAME_SIZE);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
msg.length = count;
|
||||
msg.data = (void *)buf;
|
||||
ret = mbox_send_message(drvdata->mbox, (void *)&msg);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "mbox_send_message failed %d\n", ret);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const DEVICE_ATTR(data_channel, S_IRUGO | S_IWUSR,
|
||||
tegra_aon_ivc_echo_show, tegra_aon_ivc_echo_tx);
|
||||
|
||||
static void tegra_aon_ivc_echo_rx(struct mbox_client *cl, void *data)
|
||||
{
|
||||
struct tegra_aon_mbox_msg *msg = data;
|
||||
struct tegra_aon_ivc_echo_data *drvdata = container_of(cl,
|
||||
struct tegra_aon_ivc_echo_data,
|
||||
cl);
|
||||
memcpy(drvdata->rx_data, msg->data, IVC_FRAME_SIZE);
|
||||
}
|
||||
|
||||
static int tegra_aon_ivc_echo_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct tegra_aon_ivc_echo_data *drvdata;
|
||||
|
||||
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
||||
if (!drvdata)
|
||||
return -ENOMEM;
|
||||
dev_set_drvdata(dev, drvdata);
|
||||
drvdata->cl.dev = dev;
|
||||
drvdata->cl.tx_block = true;
|
||||
drvdata->cl.tx_tout = TX_BLOCK_PERIOD;
|
||||
drvdata->cl.knows_txdone = false;
|
||||
drvdata->cl.rx_callback = tegra_aon_ivc_echo_rx;
|
||||
drvdata->mbox = mbox_request_channel(&drvdata->cl, 0);
|
||||
if (IS_ERR(drvdata->mbox)) {
|
||||
ret = PTR_ERR(drvdata->mbox);
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "mbox_request_channel failed. Error %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = device_create_file(dev, &dev_attr_data_channel);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to create device file. Error %d\n", ret);
|
||||
mbox_free_channel(drvdata->mbox);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tegra_aon_ivc_echo_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct tegra_aon_ivc_echo_data *drvdata = dev_get_drvdata(&pdev->dev);
|
||||
|
||||
device_remove_file(&pdev->dev, &dev_attr_data_channel);
|
||||
mbox_free_channel(drvdata->mbox);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id tegra_aon_ivc_echo_match[] = {
|
||||
{ .compatible = "nvidia,tegra186-aon-ivc-echo", },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, tegra_aon_ivc_echo_match);
|
||||
|
||||
static struct platform_driver tegra_aon_ivc_echo_driver = {
|
||||
.probe = tegra_aon_ivc_echo_probe,
|
||||
.remove = tegra_aon_ivc_echo_remove,
|
||||
.driver = {
|
||||
.name = "tegra-aon-ivc-echo",
|
||||
.of_match_table = tegra_aon_ivc_echo_match,
|
||||
},
|
||||
};
|
||||
module_platform_driver(tegra_aon_ivc_echo_driver);
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -1,12 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*/
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <dce.h>
|
||||
#include <dce-debug-perf.h>
|
||||
#include <dce-log.h>
|
||||
#include <dce-util-common.h>
|
||||
#include <interface/dce-interface.h>
|
||||
|
||||
@@ -131,7 +131,7 @@ static ssize_t dbg_dce_load_fw_write(struct file *file,
|
||||
if (copy_from_user(buf, user_buf, buf_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (strtobool(buf, &bv) == 0) {
|
||||
if (kstrtobool(buf, &bv) == 0) {
|
||||
if (bv == true) {
|
||||
ret = dbg_dce_load_fw(d);
|
||||
if (ret)
|
||||
@@ -176,7 +176,7 @@ static ssize_t dbg_dce_config_ast_write(struct file *file,
|
||||
if (copy_from_user(buf, user_buf, buf_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (strtobool(buf, &bv) == 0) {
|
||||
if (kstrtobool(buf, &bv) == 0) {
|
||||
if (bv == true)
|
||||
dbg_dce_config_ast(d);
|
||||
}
|
||||
@@ -219,7 +219,7 @@ static ssize_t dbg_dce_reset_dce_fops_write(struct file *file,
|
||||
if (copy_from_user(buf, user_buf, buf_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (strtobool(buf, &bv) == 0) {
|
||||
if (kstrtobool(buf, &bv) == 0) {
|
||||
if (bv == true) {
|
||||
ret = dbg_dce_reset_dce(d);
|
||||
if (ret)
|
||||
@@ -455,7 +455,7 @@ static ssize_t dbg_dce_boot_dce_fops_write(struct file *file,
|
||||
if (copy_from_user(buf, user_buf, buf_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (strtobool(buf, &bv) == 0) {
|
||||
if (kstrtobool(buf, &bv) == 0) {
|
||||
if (bv == true) {
|
||||
ret = dbg_dce_boot_dce(d);
|
||||
if (ret)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/**
|
||||
* Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2014-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
@@ -323,7 +323,7 @@ bool is_adsp_dram_addr(u64 addr)
|
||||
return false;
|
||||
}
|
||||
|
||||
int is_cluster_mem_addr(u64 addr)
|
||||
static int is_cluster_mem_addr(u64 addr)
|
||||
{
|
||||
int clust_id;
|
||||
struct nvadsp_drv_data *drv_data = platform_get_drvdata(priv.pdev);
|
||||
@@ -769,7 +769,11 @@ static void *nvadsp_dma_alloc_and_map_at(struct platform_device *pdev,
|
||||
|
||||
/* Remap the contiguous physical addresses together */
|
||||
ret = iommu_map(domain, iova + offset, pa, mp_size,
|
||||
#if defined(NV_IOMMU_MAP_HAS_GFP_ARG)
|
||||
IOMMU_READ | IOMMU_WRITE, GFP_KERNEL);
|
||||
#else
|
||||
IOMMU_READ | IOMMU_WRITE);
|
||||
#endif
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to map pa %llx va %llx size %lx\n",
|
||||
pa, iova + offset, mp_size);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
ccflags-y += -Wframe-larger-than=2048
|
||||
|
||||
ifneq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y)
|
||||
obj-m += capture-ivc.o
|
||||
endif
|
||||
obj-m += ivc-bus.o
|
||||
obj-m += camchar.o
|
||||
obj-m += camera-diagnostics.o
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/tegra-capture-ivc.h>
|
||||
|
||||
@@ -357,11 +359,25 @@ static inline void tegra_capture_ivc_recv(struct tegra_capture_ivc *civc)
|
||||
{
|
||||
struct tegra_ivc *ivc = &civc->chan->ivc;
|
||||
struct device *dev = &civc->chan->dev;
|
||||
const void *msg;
|
||||
const struct tegra_capture_ivc_msg_header *hdr;
|
||||
uint32_t id;
|
||||
|
||||
while (tegra_ivc_can_read(ivc)) {
|
||||
const void *msg = tegra_ivc_read_get_next_frame(ivc);
|
||||
const struct tegra_capture_ivc_msg_header *hdr = msg;
|
||||
uint32_t id = hdr->channel_id;
|
||||
#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) /* Linux 6.2 */
|
||||
struct iosys_map map;
|
||||
int err;
|
||||
err = tegra_ivc_read_get_next_frame(ivc, &map);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to get next frame for read\n");
|
||||
return;
|
||||
}
|
||||
msg = map.vaddr;
|
||||
#else
|
||||
msg = tegra_ivc_read_get_next_frame(ivc);
|
||||
#endif
|
||||
hdr = msg;
|
||||
id = hdr->channel_id;
|
||||
|
||||
trace_capture_ivc_recv(dev_name(dev), hdr->msg_id, id);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
|
||||
#include "tegra_bootloader_debug.h"
|
||||
|
||||
static phys_addr_t tegra_bl_debug_data_start;
|
||||
static phys_addr_t tegra_bl_debug_data_size;
|
||||
static phys_addr_t tegra_bl_prof_start;
|
||||
|
||||
11
drivers/platform/tegra/tegra_bootloader_debug.h
Normal file
11
drivers/platform/tegra/tegra_bootloader_debug.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (C) 2023 NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __TEGRA_BOOTLOADER_DEBUG_H
|
||||
#define __TEGRA_BOOTLOADER_DEBUG_H
|
||||
|
||||
size_t tegra_bl_add_profiler_entry(const char *buf, size_t len);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||
// Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
@@ -316,7 +318,9 @@ static const struct pwm_ops pwm_tegra_tach_ops = {
|
||||
.apply = tegra_pwm_apply,
|
||||
#endif
|
||||
.capture = pwm_tegra_tacho_capture,
|
||||
#if defined(NV_PWM_OPS_STRUCT_HAS_OWNER) /* Linux 6.7 */
|
||||
.owner = THIS_MODULE,
|
||||
#endif
|
||||
};
|
||||
|
||||
static void pwm_tegra_tach_read_platform_data(struct pwm_tegra_tach *ptt)
|
||||
@@ -426,7 +430,9 @@ static int pwm_tegra_tach_probe(struct platform_device *pdev)
|
||||
|
||||
ptt->chip.dev = &pdev->dev;
|
||||
ptt->chip.ops = &pwm_tegra_tach_ops;
|
||||
#if defined(NV_PWM_CHIP_STRUCT_HAS_BASE_ARG)
|
||||
ptt->chip.base = -1;
|
||||
#endif
|
||||
ptt->chip.npwm = 1;
|
||||
|
||||
ret = pwmchip_add(&ptt->chip);
|
||||
|
||||
@@ -194,6 +194,8 @@ static irqreturn_t nvvrs_rtc_irq_handler(int irq, void *data)
|
||||
if (ret < 0)
|
||||
dev_err(info->dev, "Failed to disable alarm: ret %d\n", ret);
|
||||
|
||||
rtc_update_irq(info->rtc_dev, 1, RTC_IRQF | RTC_AF);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2015-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include "ufs-provision.h"
|
||||
#include "ufs-tegra.h"
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
|
||||
#include <drivers-private/scsi/ufs/k515/ufshcd.h>
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
|
||||
#include <drivers-private/scsi/ufs/k516/ufshcd.h>
|
||||
#if defined(NV_UFS_UFSHCD_H_PRESENT)
|
||||
#include <ufs/ufshcd.h>
|
||||
#else
|
||||
#include <drivers-private/scsi/ufs/k61/ufshcd.h>
|
||||
#include <drivers-private/scsi/ufs/ufshcd.h>
|
||||
#endif
|
||||
|
||||
void debugfs_provision_init(struct ufs_hba *hba, struct dentry *device_root)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2015-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <nvidia/conftest.h>
|
||||
|
||||
#include "ufs-provision.h"
|
||||
#include "ufs-tegra.h"
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
|
||||
#include <drivers-private/scsi/ufs/k515/ufshcd.h>
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
|
||||
#include <drivers-private/scsi/ufs/k516/ufshcd.h>
|
||||
#if defined(NV_UFS_UFSHCD_H_PRESENT)
|
||||
#include <ufs/ufshcd.h>
|
||||
#include <drivers-private/scsi/ufs/ufshcd-priv.h>
|
||||
#else
|
||||
#include <drivers-private/scsi/ufs/k61/ufshcd.h>
|
||||
#include <drivers-private/scsi/ufs/ufshcd.h>
|
||||
#endif
|
||||
|
||||
#define CHECK_NULL(expr) \
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user