Tc358743 9-000f: failed to get refclk: -2

[ 11.771315] tc358743 9-000f: failed to get refclk: -2
[ 11.771321] tc358743: probe of 9-000f failed with error -2
[ 11.771356] tc358743 10-000f: failed to get refclk: -2
[ 11.771359] tc358743: probe of 10-000f failed with error -2
Im trying to port tc358743 camera drive on r36.4.
When I boot up the probe fails in my probe_of function with the error “failed to get refclk: -2”.
The code below fails.

tc358743.c

refclk = devm_clk_get(dev, "refclk");
if (IS_ERR(refclk)) {
	if (PTR_ERR(refclk) != -EPROBE_DEFER)
		dev_err(dev, "failed to get refclk: %ld\n",
			PTR_ERR(refclk));
	return PTR_ERR(refclk);
}

I gave refclk in device tree related code but still got error.
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

include <dt-bindings/clock/tegra234-clock.h>
include <dt-bindings/gpio/tegra234-gpio.h>

/ {
fragment-camera-tc358743@0 {
target-path = “/”;
overlay {
tegra-capture-vi {
num-channels = <2>;
ports {
#address-cells = <1>;
#size-cells = <0>;
vi_port0: port@0 {
reg = <0>;
toshiba_tc358743_vi_in0: endpoint {
port-index = <1>;
bus-width = <2>;
remote-endpoint = <&toshiba_tc358743_csi_out0>;
};
};
vi_port1: port@1 {
reg = <1>;
toshiba_tc358743_vi_in1: endpoint {
port-index = <2>;
bus-width = <2>;
remote-endpoint = <&toshiba_tc358743_csi_out1>;
};
};
};
};

		bus@0 {
			host1x@13e00000 {
				nvcsi@15a00000 {
					num-channels = <2>;
					#address-cells = <1>;
					#size-cells = <0>;
					csi_chan0: channel@0 {
						reg = <0>;
						ports {
							#address-cells = <1>;
							#size-cells = <0>;
							csi_chan0_port0: port@0 {
								reg = <0>;
								toshiba_tc358743_csi_in0: endpoint@0 {
									port-index = <1>;
									bus-width = <2>;
									remote-endpoint = <&toshiba_tc358743_out0>;
								};
							};
							csi_chan0_port1: port@1 {
								reg = <1>;
								toshiba_tc358743_csi_out0: endpoint@1 {
									remote-endpoint = <&toshiba_tc358743_vi_in0>;
								};
							};
						};
						
					};
					csi_chan1: channel@1 {
						reg = <1>;
						ports {
							#address-cells = <1>;
							#size-cells = <0>;
							csi_chan1_port0: port@0 {
								reg = <0>;
								toshiba_tc358743_csi_in1: endpoint@2 {
									port-index = <2>;
									bus-width = <2>;
									remote-endpoint = <&toshiba_tc358743_out1>;
								};
							};
							csi_chan1_port1: port@1 {
								reg = <1>;
								toshiba_tc358743_csi_out1: endpoint@3 {
									remote-endpoint = <&toshiba_tc358743_vi_in1>;
								};
							};
						};
					};
				};
			};
			cam_i2cmux {
				i2c_0:i2c@0 {
					tc358743_cam0: toshiba_tc358743_a@0f {
						compatible = "toshiba,tc358743";
						/* I2C device address */
						reg = <0x0f>;
						/* V4L2 device node location */
						devnode = "video0";
						/* Physical dimensions of sensor */
						physical_w = "3.680";
						physical_h = "2.760";
						sensor_model = "tc358743";
						use_sensor_mode_id = "true";
						clock-names = "refclk";
						clock-frequency = <27000000>;
					
						ports {
							#address-cells = <1>;
							#size-cells = <0>;
							port@0 {
								reg = <0>;
								toshiba_tc358743_out0: endpoint {
									port-index = <1>;
									bus-width = <2>;
									remote-endpoint = <&toshiba_tc358743_csi_in0>;
								};
							};
						};
					};
				};

Please help me determine what the problem is.

Confirm the refclk by checking /proc/device-tree/…

What does ‘Confirm the refclk by checking /proc/device-tree/’ mean?
I did check the path.
test@test-desktop:/proc/device-tree$ grep -r refclk
grep: bus@0/cam_i2cmux/i2c@0/toshiba_tc358743_a@0f/clock-names: binary file matches
grep: bus@0/cam_i2cmux/i2c@1/toshiba_tc358743_c@0f/clock-names: binary file matches
test@test-desktop:/proc/device-tree$ cat bus@0/cam_i2cmux/i2c@0/toshiba_tc358743_a@0f/clock-names
refclk

Looks like Orin don’t have refclk. You need to check the HW connect to which clock source from Orin Nano to redefine it.

I fixed it like this but still have the same problem.

cam_i2cmux {
i2c_0:i2c@0 {
tc358743_cam0: toshiba_tc358743_a@0f {
compatible = “toshiba,tc358743”;
/* I2C device address /
reg = <0x0f>;
/
V4L2 device node location /
devnode = “video0”;
/
Physical dimensions of sensor */
physical_w = “3.680”;
physical_h = “2.760”;
sensor_model = “tc358743”;
use_sensor_mode_id = “true”;

						clocks = <&bpmp TEGRA234_CLK_EXTPERIPH1>;
						clock-names = "extperiph1";

						refclk = <27000000>;
					
						ports {
							#address-cells = <1>;
							#size-cells = <0>;
							port@0 {
								reg = <0>;
								toshiba_tc358743_out0: endpoint {
									port-index = <1>;
									bus-width = <2>;
									remote-endpoint = <&toshiba_tc358743_csi_in0>;
								};
							};
						};
					};
				};
				i2c_1: i2c@1 {
					tc358743_cam1: toshiba_tc358743_c@0f {
						compatible = "toshiba,tc358743";
						/* I2C device address */
						reg = <0x0f>;
						/* V4L2 device node location */
						devnode = "video1";
						/* Physical dimensions of sensor */
						physical_w = "3.680";
						physical_h = "2.760";
						sensor_model = "tc358743";
						use_sensor_mode_id = "true";
						//refclk = <27000000>;
						clocks = <&bpmp TEGRA234_CLK_EXTPERIPH1>;
						clock-names = "extperiph1";

						refclk = <27000000>;

						ports {
							#address-cells = <1>;
							#size-cells = <0>;
							port@0 {
								reg = <0>;
								toshiba_tc358743_out1: endpoint {
									port-index = <2>;
									bus-width = <2>;
									remote-endpoint = <&toshiba_tc358743_csi_in1>;
								};
							};
						};
					};
				};
			};

I have still probelm. How to do solve the problem?
I’ll list down the ways I did it.

  1. https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v4.0/release/Jetson_Linux_R36.4.0_aarch64.tbz2
  2. $tar xvf Jetson_linux_R36.4.0_aarch64.tbz2
  3. https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v4.0/release/Tegra_Linux_Sample-Root-Filesystem_R36.4.0_aarch64.tbz2
  4. Linux_for_Tegra/rootfs/sudo tar xvpf Tegra_Linux_Sample-Root-Filesystem_R36.4.0_aarch64.tbz2
  5. sudo ./tools/l4t_flash_prerequisites.sh
  6. sudo ./apply_binaries.sh
  7. mkdir $HOME/l4t-gcc
  8. https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v2.0/toolchain/aarch64--glibc--stable-2022.08-1.tar.bz2
  9. $HOME/l4t-gcc/tar xvf aarch64–glibc–stable-2022.08-1.tar
  10. https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v4.0/sources/public_sources.tbz2
  11. tar xvjf public_sources.tbz2
  12. tar xvf kernel_src.tbz2
  13. tar xvf kernel_oot_modules_src.tbz2
  14. tar xvf nvidia_kernel_display_driver_source.tbz2
  15. Add the Config below in the file location ‘arch/amr64/configs/defconfig’
  16. CONFIG_EMBEDDED=y
  17. make ARCH=arm64 menuconfig
  18. D Device Drivers
    => u Multimedia support
    => eeee Media ancillary drivers
    ==> v Video decoders
    => t TC358743 : set to ‘M’

make ARCH=arm64 savedefconfig
19. export CROSS_COMPILE=$HOME/l4t-gcc/aarch64–glibc–stable-2022.08-1/bin/aarch64-buildroot-linux-gnu-
20. make ARCH=arm64 -C kernel
21. export INSTALL_MOD_PATH=$PWD/rootfs/
22. sudo -E make ARCH=arm64 install -C kernel
23. cp kernel/kernel-jammy-src/arch/arm64/boot/Image …/kernel/Image
24. build modules of nvidia out-of-tree
export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
make ARCH=arm64 modules
25. sudo -E make ARCH=arm64 modules_install
26. sudo ./tools/l4t_update_initrd.sh
27. Before building dtb, I blocked ‘//include "tegra234-p3768-camera-rbpcv2-imx219.dtsi’ in the ‘tegra234-p3768-0000+p3767-0000-dynamic.dts’ file and added the following ‘include "tegra234-p3768-camera-toshiba-tc358743.dtsi’.

// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

/dts-v1/;
/plugin/;

//include “tegra234-p3768-camera-rbpcv2-imx219.dtsi”
//include “tegra234-p3768-camera-toshiba-tc358743.dtsi”
include “tegra234-camera-rbpcv2-tc358743.dtsi”
/// {
// overlay-name = “Tegra234 p3768-0000+p3767-xxxx Dynamic Overlay”;
//};

/*

  • Include this file last in the device tree. It manages run-time
  • pruning of peripherals that are not available across the various
  • SKUs of p3767. For example PVA can be enabled in the device tree
  • and it will automatically be disabled for SKUs without PVA support.
    */
    include “tegra234-p3767-sku-handling.dtsi”
  1. Just change the contents of ‘tegra234-p3767-camera-p3768-imx219-dual.dts’ to 'tegra234-p3767-camera-p3768-tc358743-dual.dts ’ was created.
  2. Related to this I modified the ‘tegra234-camera-rbpcv2-imx219.dtsi’ file to create ‘tegra234-camera-rbpcv2-tc358743.dtsi’.
  3. make dtbs
  4. cp kernel-devicetree/generic-dts/dtbs/* …/kernel/dtb/
  5. When I run this, I get an error like ‘[ 11.771315] tc358743 9-000f: failed to get refclk: -2
    [ 11.771321] tc358743: probe of 9-000f failed with error -2
    [ 11.771356] tc358743 10-000f: failed to get refclk: -2
    [ 11.771359] tc358743: probe of 10-000f failed with error -2’.

tegra234-camera-rbpcv2-tc358743.dtsi.txt (15.2 KB)
tegra234-p3767-camera-p3768-tc358743-dual.dts.txt (1.8 KB)
tegra234-p3768-0000+p3767-0000-dynamic.dts.txt (735 Bytes)
tegra234-p3768-camera-rbpcv2-tc358743.dtsi.txt (1.3 KB)

Could you explain the what is the problem?

What’s the refclk connect to? If there’s no need you can remove it from the driver.

This is clk in the tc358743_probe_of function.
static int tc358743_probe_of(struct tc358743_state *state)
{

struct clk *refclk;
u32 bps_pr_lane;
int ret;

refclk = devm_clk_get(dev, "refclk");
if (IS_ERR(refclk)) {
	if (PTR_ERR(refclk) != -EPROBE_DEFER)
		dev_err(dev, "failed to get refclk: %ld\n",
			PTR_ERR(refclk));
	return PTR_ERR(refclk);
}

ep = of_graph_get_next_endpoint(dev->of_node, NULL);
if (!ep) {
	dev_err(dev, "missing endpoint node\n");
	return -EINVAL;
}


}
If i block clk, an error will occur right after ‘missing endpoint node’.