Modify device tree to add csi camera not work

I’m trying to add csi camera device. I modified the device tree, but the device still does not exist. Below is my device tree:

tegra-camera-platform add module:
module0 {
				badge = "radar_bottom_mmwave";
				position = "bottom";
				orientation = [31 00];
				status = "okay";
				phandle = <0x547>;
            
				drivernode0 {
					pcl_id = "v4l2_sensor";
					devname = "radar 30-0050";
					proc-device-tree = "/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/radar@50";
					status = "okay";
					phandle = <0x548>;
				};
            
				drivernode1 {
					pcl_id = "v4l2_lens";
					proc-device-tree = "/proc/device-tree/lens_ar0231@A6V26/";
					status = "disabled";
					phandle = <0x549>;
				};
			};

i2c add a node in  tca9546@70:
radar@50 {
					compatible = "ct,radar";
					reg = <0x50>;
					devnode = "video0";
					physical_w = "3.674";
					physical_h = "2.738";
					sensor_model = "radar";
					avdd-reg = "vana";
					iovdd-reg = "vif";
					delayed_gain = "true";
					has-eeprom;
					fuse_id_start_addr = <0x5b>;
					clocks = <0x04 0x24 0x04 0x24>;
					clock-names = "extperiph1\0pllp_grtba";
					mclk = "extperiph1";
					reset-gpios = <0x14 0x3b 0x00>;
					vana-supply = <0x40>;
					vif-supply = <0x3d>;
					status = "okay";
					phandle = <0x381>;
        mode0{
             xxxxxxxxxxxx;
        };
        ports {
						#address-cells = <0x01>;
						#size-cells = <0x00>;

						port@0 {
							reg = <0x00>;

							endpoint {
								port-index = <0x00>;
								bus-width = <0x04>;
								remote-endpoint = <0x3e>;
								phandle = <0x382>;
							};
						};
					};

nvsci channel0 add port:
port@0 {
						reg = <0x00>;
						status = "okay";
						phandle = <0x4d9>;

						endpoint@0 {
							port-index = <0x00>;
							bus-width = <0x04>;
							//remote-endpoint = <0x2be>;
							//remote-endpoint = <&mmwave_out>;
							remote-endpoint = <0x382>;
							status = "okay";
							phandle = <0x3e>;
						};
					};

					port@1 {
						reg = <0x01>;
						status = "okay";
						phandle = <0x4da>;

						endpoint@1 {
							remote-endpoint = <0x2bf>;
							status = "okay";
							phandle = <0x272>;
						};
					};

tegra-capture-vi add port:
port@0 {
				reg = <0x00>;
				status = "okay";
				phandle = <0x4b3>;

				endpoint {
					vc-id = <0x00>;
					port-index = <0x00>;
					bus-width = <0x04>;
					remote-endpoint = <0x272>;
					status = "okay";
					phandle = <0x2bf>;
				};
			};

and after system run media-ctl -p /dev/media0
Media controller API version 5.10.104

Media device information

driver tegra-camrtc-ca
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 5.10.104

Device topology

  • entity 1: 13e40000.host1x:nvcsi@15a00000- (2 pads, 0 link)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev0
    pad0: Sink
    pad1: Source

/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/radar@50/status is okay

hello fyjtm,

I assume you’re working with JP-5, may I confirm which public release version it is?
you may double check the release tag, i.e. $ cat /etc/nv_tegra_release for confirmation.

besides, please see-also developer guide, To verify the port binding result.
the correct device topology should report the connections of nvcsi/vi/sensor.

cat /etc/nv_tegra_release
# R35 (release), REVISION: 3.1, GCID: 32827747, BOARD: t186ref, EABI: aarch64, DATE: Sun Mar 19 15:19:21 UTC 2023

The problem is port binding now work. I checked the device tree, and it seems there is no error.

media-ctl -p /dev/media0
Media controller API version 5.10.104
Media device information

driver tegra-camrtc-ca
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 5.10.104

Device topology

    entity 1: 13e40000.host1x:nvcsi@15a00000- (2 pads, 0 link)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev0
    pad0: Sink
    pad1: Source

/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/radar@50/status is okay

hello fyjtm,

I don’t see the NVCSI/VI port bindings according to your results.
BTW, there’re several camera bugs within early JP-5 public release version, it is suggest you moving to JP-5.1.4/r35.6.0 (or later) to include the bug fixes for sensor bring-up.

Hi Jerry,
I know NVCSI/VI port bindings failed, I want know how to fix it. Is there any error in the device tree?

hello fyjtm,

please share your device tree (without truncated) for reference.
you may upload it as single text file to attachment.

Hi Jerry,
please see the file. The device is tegra-camera-platform module0.
Thanks!
mmwave.txt (708.1 KB)

Hi Jerrry,
Did you find anything error?
Thanks!

hello fyjtm,

there’re several camera nodes, (i.e. module0 ~ module15) within your tegra-camera-platform. do you have 16 camera device connected physically?

per checking to your camera node.

				radar@50 {
					...
					ports {
						port@0 {
							endpoint {
								port-index = <0x00>;
								bus-width = <0x04>;
								remote-endpoint = <0x3e>;

it looks you’ve several camera node that using the same remote-endpoint.
for instance, ar0231_a@50 {, ov5693_a@36 {..etc.
you’ll need to have device tree settings to match your camera hardware connections, please try to update the it accordingly.

mmwave.txt (624.9 KB)
Hi Jerry,
I removed all other node. but the port binding still now work. please check the new dts file.

media-ctl -p /dev/media0
Media controller API version 5.10.104

Media device information
------------------------
driver          tegra-camrtc-ca
model           NVIDIA Tegra Video Input Device
serial
bus info
hw revision     0x3
driver version  5.10.104

Device topology
- entity 1: 13e40000.host1x:nvcsi@15a00000- (2 pads, 0 link)
            type V4L2 subdev subtype Unknown flags 0
        pad0: Sink
        pad1: Source

Thanks!

hello fyjtm,

the issue should be on sensor side, during kernel initialization stage, it’s step for camera device registration to setup a video device node to linux kernel. sensor probing only run once during kernel initialization stage of system boot-up.
for a typical camera application running cycle, the driver will Power On the sensor, Start Sensor Streaming, sending relevant v4l2 controls, and finally power off the sensor.
so… if there’s a error returns, it’ll not register a video node, (/dev/video0).
please see-also Topic 293662 and Topic 290610 to examine camera device registration process.

BTW,
please also add some debug prints to your sensor driver.
for instance, it’s subdev: Holds a handle for the V4L2 subdevice; used to run subdev operations (ops).
here’s an example of IMX185, it’s the operations to toggle sensor controls.

static struct v4l2_subdev_ops imx185_subdev_ops = {
    .core = &imx185_subdev_core_ops,
    .video = &imx185_subdev_video_ops,
};

Hi Jerry,
I modified imx214
driver and only left the necessary part, but when insmod the system painc. I attached the source code. It’s very simple, I did not find the problem.

Thanks for help!
radar.c.txt (6.9 KB)

 Unable to handle kernel paging request at virtual address 0000000000002000
[  416.165241] Mem abort info:
[  416.168106]   ESR = 0x96000044
[  416.171251]   EC = 0x25: DABT (current EL), IL = 32 bits
[  416.176718]   SET = 0, FnV = 0
[  416.179851]   EA = 0, S1PTW = 0
[  416.183079] Data abort info:
[  416.186043]   ISV = 0, ISS = 0x00000044
[  416.189994]   CM = 0, WnR = 1
[  416.193063] user pgtable: 4k pages, 48-bit VAs, pgdp=000000010cb1a000
[  416.199684] [0000000000002000] pgd=0000000000000000, p4d=0000000000000000
[  416.206682] Internal error: Oops: 0000000096000044 [#1] PREEMPT SMP
[  416.213144] Modules linked in: radar(OE+) nvidia_modeset(OE) lzo_rle(E) lzo_compress(E) zram(E) bnep(E) ramoops(E) reed_solomon(E) snd_soc_tegra186_dspk(E) snd_soc_tegra186_asrc(E) snd_soc_tegra210_ope(E) snd_soc_tegra210_admaif(E) snd_soc_tegra210_mvc(E) snd_soc_tegra186_arad(E) snd_soc_tegra210_iqc(E) snd_soc_tegra_pcm(E) snd_soc_tegra210_afc(E) snd_soc_tegra210_dmic(E) snd_soc_tegra210_adx(E) snd_soc_tegra210_amx(E) snd_soc_tegra210_mixer(E) snd_soc_tegra210_i2s(E) snd_soc_tegra210_sfc(E) aes_ce_blk(E) crypto_simd(E) cryptd(E) aes_ce_cipher(E) input_leds(E) ghash_ce(E) sha2_ce(E) rtl8822ce(E) sha256_arm64(E) sha1_ce(E) rtk_btusb(E) snd_soc_tegra210_adsp(E) btusb(E) btrtl(E) snd_soc_tegra_machine_driver(E) ucsi_ccg(E) btbcm(E) snd_soc_tegra_utils(E) typec_ucsi(E) btintel(E) snd_soc_simple_card_utils(E) snd_soc_spdif_tx(E) typec(E) i2c_nvvrs11(E) snd_soc_tegra210_ahub(E) nct1008(E) nvadsp(E) snd_hda_codec_hdmi(E) userspace_alert(E) tegra_bpmp_thermal(E) tegra210_adma(E) snd_hda_tegra(E)
[  416.213219]  snd_soc_rt5640(E) snd_hda_codec(E) snd_soc_rl6231(E) snd_hda_core(E) cfg80211(E) spi_tegra114(E) loop(E) nvidia(OE) binfmt_misc(E) ina3221(E) pwm_fan(E) nvgpu(E) nvmap(E) ip_tables(E) x_tables(E) [last unloaded: mtd]
[  416.325977] CPU: 3 PID: 4919 Comm: insmod Tainted: G           OE     5.10.216-tegra #2
[  416.334206] Hardware name: NVIDIA Jetson AGX Orin Developer Kit/Jetson, BIOS 6.0-37391689 08/28/2024
[  416.343592] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO BTYPE=--)
[  416.349797] pc : tegra_channel_init_subdevices+0x4e4/0x790
[  416.355437] lr : tegra_channel_init_subdevices+0x50c/0x790
[  416.361072] sp : ffff8000270336b0
[  416.364483] x29: ffff8000270336b0 x28: ffff5d620f0a2000
[  416.369950] x27: ffff5d6218754000 x26: ffff5d620c8be648
[  416.375418] x25: 0000000000002000 x24: 0000000000002448
[  416.380882] x23: ffff5d620f0ec000 x22: ffff5d6209386400
[  416.386344] x21: 0000000000000081 x20: ffff5d6209391118
[  416.391807] x19: ffff5d62042cc080 x18: 0000000000000001
[  416.397271] x17: 0000000000000000 x16: ffffdb1c4c101bb0
[  416.402734] x15: ffffffffffffffff x14: 0000000000000000
[  416.408196] x13: 0000000000000000 x12: 0000000000000000
[  416.413657] x11: 0000000000000000 x10: 0000000000002000
[  416.419118] x9 : 2d646d6574737973 x8 : ffff5d620f0a0000
[  416.424581] x7 : 0000000000000000 x6 : ffff5d620f0f08d8
[  416.430039] x5 : 0000000000000000 x4 : 0000000000000008
[  416.435500] x3 : 0000000000000010 x2 : 0000000000000090
[  416.440959] x1 : ffff5d6209391088 x0 : 0000000000004800
[  416.446422] Call trace:
[  416.448935]  tegra_channel_init_subdevices+0x4e4/0x790
[  416.454222]  tegra_vi_graph_notify_complete+0x2f8/0x670
[  416.459603]  v4l2_async_notifier_try_complete.part.0+0x5c/0x80
[  416.465594]  v4l2_async_register_subdev+0x104/0x1c0
[  416.470617]  radar_probe+0xd0/0xf4 [radar]
[  416.474835]  i2c_device_probe+0xb0/0x2e0
[  416.478876]  really_probe+0xf8/0x3f0
[  416.482553]  driver_probe_device+0x60/0x100
[  416.486849]  device_driver_attach+0x78/0x80
[  416.491156]  __driver_attach+0x74/0x100
[  416.495108]  bus_for_each_dev+0x84/0xe0
[  416.499049]  driver_attach+0x34/0x40
[  416.502731]  bus_add_driver+0x154/0x200
[  416.506672]  driver_register+0x68/0x120
[  416.510616]  i2c_register_driver+0x50/0xa0
[  416.514831]  radar_i2c_driver_init+0x28/0x1000 [radar]
[  416.520121]  do_one_initcall+0x50/0x300
[  416.524083]  do_init_module+0x50/0x200
[  416.527937]  load_module+0x1f74/0x2380
[  416.531792]  __do_sys_finit_module+0xb4/0x100
[  416.536270]  __arm64_sys_finit_module+0x2c/0x40
[  416.540942]  el0_svc_common.constprop.0+0x80/0x1d0
[  416.545868]  do_el0_svc+0x38/0xc0
[  416.549290]  el0_svc+0x1c/0x30
[  416.552434]  el0_sync_handler+0xa8/0xb0
[  416.556386]  el0_sync+0x16c/0x180
[  416.559800] Code: f9002144 f940678a a9731684 8b19014a (a9001544)
[  416.566099] ---[ end trace cc285ed7dfd69414 ]---
[  416.575999] Kernel panic - not syncing: Oops: Fatal exception
[  416.581909] SMP: stopping secondary CPUs
[  416.585952] Kernel Offset: 0x5b1c3b430000 from 0xffff800010000000
[  416.592230] PHYS_OFFSET: 0xffffa29f00000000
[  416.596532] CPU features: 0x08040006,4a80aa38
[  416.601015] Memory Limit: none
[  416.609204] ---[ end Kernel panic - not syncing: Oops: Fatal exception ]---

hello fyjtm,

please try using standard driver model interfaces to probe the driver,
for instance,

static struct i2c_driver imx214_i2c_driver = { ...
	.probe  = imx214_probe,
static int imx214_probe(struct i2c_client *client, const struct i2c_device_id *id){...}

besides..
you may also add some debug prints, please check which line caused kernel panic.

I’ve found the problem. I’m using the driver code below kernel/driver/media/i2c/imx214.c as template,but the right file should be kernel/nvidia/driver/media/i2c/ .

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.