Device tree for TSC (nvidia,tegra234-cdi-tsc)

Hi all,

I read many topics related to CAM_FRSYNC and I found that TSC_EDGE_OUTx pin can be used for frame sync.
In the following topic, I can see which kernel code is used: Linux_for_Tegra/source/kernel/nvidia/drivers/media/platform/tegra/cdi/cdi_tsc.c
GPIO fsync function consultation - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums

However, I don’t know which device tree file should be modified.
I checked other topics but these topics also don’t explain the detailed path of device tree file.
Probing the OSC signal using DSO - AGX Orin - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums
Controlling TSC_EDGE_OUT0 pin from sysfs in Orin AGX - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums

Could you explain which device tree file should be modified?
Thanks.

Hi jw.cs.park,

Are you using the devkit or custom board for AGX Orin?
What’s your Jetpack version in use?

There should be main device tree including other device trees.
Could you share the full flash log for further check?

Or you can just decompile the /boot/dtb/kernel_XXX.dtb from your board and find the node with compatible of nvidia,tegra234-cdi-tsc.

Hi Kevin,

I’m using AGX Orin devkit and JetPack version is 5.0.2 (L4T 35.1).
Does ‘full flash log’ mean the log of flash.sh in Linux_for_Tegra? If so, flashing will delete my rootfs so it is hard to check flashing log. I’m sorry.
So I decompiled /boot/dtb/kernel_tegra234-p3701-0000-p3737-0000.dtb. But I couldn’t find any tegra234-cdi-tsc related line.

The moderator in GPIO fsync function consultation - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums said the user need to add DT info and it includes compatible tegra234-cdi-tsc. My question is where I should add this DT info (detailed device tree file path. For example: hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dts).

I added DT info to hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dts and modified CONFIG_VIDEO_CDI=m->y in defconfig but /sys/kernel/debug/tsc_sig_gen@XXX/generator@XXX doesn’t exist.

Thanks.

hello jw.cs.park,

you may see-also AGX Orin’s device tree, which already has TSC Signal Generators defined.
$public_sources/kernel_src/hardware/nvidia/platform/t23x/common/kernel-dts/t234-common-cvb/tegra234-pwm.dtsi

note, the compatible is… nvidia,tegra234-cam-cdi-tsc for using NVIDIA tegra cdi-tsc driver.
$public_soruces/kernel_src/kernel/nvidia/drivers/media/platform/tegra/cdi/cam_cdi_tsc.c

1 Like

Hi JerryChang,
Thank you for detailed information.

I checked hardware/nvidia/platform/t23x/common/kernel-dts/t234-common-cvb/ folder but tegra234-pwm.dtsi doesn’t exist.

In the public_soruces/kernel_src/kernel/nvidia/drivers/media/platform/tegra/cdi folder, cdi_tsc.c exists but cam_cdi_tsc.c doesn’t exist.

I can’t find any lines including nvidia,tegra234-cam-cdi-tsc in the source codes also.

I downloaded the kernel codes in Jetson Linux 35.1 | NVIDIA Developer.

Thanks

hello jw.cs.park,

FYI, r35.1 is quite old, and there’re several bugs.
if that’s possible, please moving to the latest rel-35 release version, (i.e. l4t-r35.5.0) for development.

Hi JerryChang,

I checked your mentioned codes in L4T 35.5. I’ll try this version.
Thanks.

Hi Jerry,

I installed JetPack 5.1.3 and L4T 35.5.0. I have several questions.

  1. To enable cam-cdi-tsc.c, I modified CONFIG_VIDEO_CDI, CONFIG_NV_DESER_MAX96712, and CONFIG_NV_VIDEO_HAWK_OWL in tegra_defconfig from m to y. I’m using max9296 and other image sensors but I modified these files because of compile error. Is it correct?

  2. How can I check the signal release of of CAM_FRSYNC? I tried to access /sys/kernel/debug/tsc_sig_gen@XXX/ but this path doesn’t exist.

Thanks.

hello jw.cs.park,

what’s the camera modules you’re using, you may add the driver and enable its config manually.

please also check whether you’ve build the CDI TSC signal generation driver.
and… you should insert the cdi_tsc.ko kernel module, i.e. $ sudo insmod cdi_tsc.ko

Hi Jerry,

I did insmod cam_cdi_tsc.ko and I found /sys/kernel/debug/tsc_sig_gen@c6a0000 is generated. Thanks a lot.
I have one more question. Is there any possible way to check this signal generator is working or not?

you may arrange oscilloscope to monitor the waveform changes.

Thank you for your answer.
We used oscilloscope to check FRSYNC but the signal is not emitted.
I have a question in cam_cdi_tsc.c.

This code uses Hawk Owl releated codes like,

extern int Hawk_Owl_Fsync_program(int fsync_type);
static int cdi_tsc_chardev_open(struct inode* inode, struct file* file)
{
    pr_info("%s:Device opened\n",__func__);
    /* Set External Fsync */
    Hawk_Owl_Fsync_program(EXTERNAL_FSYNC);
    return 0;
}

static int cdi_tsc_chardev_release(struct inode* inode, struct file* file)
{

	pr_info("%s:Device closed\n",__func__);
	/* Set back to Internal Fsync */
	Hawk_Owl_Fsync_program(INTERNAL_FSYNC);

	return 0;
}

The function Hawk_Owl_Fsync_program is defined in nv_hawk_owl.c, which is a sensor module driver. This function calls max96712_fsync_program function, which calls max96712_write_reg_Dser. In conclusion, a table Owl_QuadLink_Dser_ExFsync is written into max96712. If I don’t add hawk owl and max96712 driver in Makefile and defconfig, compile error occurs when building the kernel.

I was wondering that it is necessary to enable max96712 and hawk owl sensor driver to just enable FRSYNC signal. This signal is emitted from CSI 120-pin and I think it is not related to serdes or sensor module.

Is insmod cam_cdi_tsc.c enough to enable FRSYNC without hawk owl and max96712?

I found cdi_tsc_start_generators function and it is called by cdi_tsc_chardev_ioctl. I thought that just insmod is enough but it looks I need more procedure to generate signal. Could you give me some guide for this?

Thanks a lot.

To enable TSC sync/lock to PTP (primary) source, you need to update TSC register with value corresponding to network interface. Currently, the value is chosen based on the interface name passed in nvpps device tree. i.e. interface = "eth0"; .

In the kernel/nvidia/drivers/nvpps/nvpps_main.c, the compatible is “nvidia,tegra194-nvpps”. However, there is no “nvidia,tegra194-nvpps” in any device tree. It looks like I need to add nvpps in device tree. I found the examples in kernel/nvidia/Documentation/devicetree/bindings/nvpps/nvpps.txt However there are four example cases and I don’t know what and where(dt file path) I should add.
I have another question. You mentioned I need to update TSC register. I want to know how to update(busybox devmem?) and what is the address(and value) of this register.

I tried insmod nvpps.ko but nothing happened in dmesg.

Thanks.

I tried to insert nvpps dt info in hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dts.

	nvpps {
		compatible = "nvidia,tegrat194-nvpps";
		status = "okay";
		gpios = <&tegra_aon_gpio TEGRA234_AON_GPIO(BB, 2) GPIO_ACTIVE_HIGH>;
	};

in hardware/nvidia/platform/t23x/common/kernel-dts/t234-common-cvb/tegra234-pwm.dtsi

		/* EDGE_OUT #0 */
		generator@380 {
			reg = <0x380 0x80>;
			freq_hz = <30>;
			duty_cycle = <25>;
			offset_ms = <0>;
			gpio_pinmux = <&tegra_aon_gpio TEGRA234_AON_GPIO(BB, 2) GPIO_ACTIVE_LOW>;
			status = "okay";
		};

After build the kernel, I did insmod cam_cdi_tsc.ko and nvpps.ko.
dmesg log

[   37.609120] cdi_tsc c6a0000.tsc_sig_gen: CDI TSC probing...
[   37.609279] cdi_tsc_probe: Initializing the driver
[   37.609836] cdi_tsc_probe: Successfully initialized the tsc char driver
[   40.683880] nvpps nvpps: nvpps_probe
[   40.683902] nvpps nvpps: gpio_pin(326)
[   40.683985] irq: IRQ327: trimming hierarchy from :interrupt-controller@f400000-1
[   40.683989] nvpps nvpps: gpio_to_irq(327)
[   40.683995] nvpps nvpps: using ptp notifier method with interface(eqos_0)
[   40.683998] nvpps nvpps: tsc_res_ns(32)
[   40.684664] nvpps nvpps: nvpps cdev(501:0)
[   40.685060] nvpps nvpps0: tegra_gte_register_event succeed
[   40.685107] nvpps nvpps0: Registered IRQ 327 for nvpps
[   40.685128] nvpps nvpps: TSC config ptx 0x0

Is TSC or FRSYNC working now?

hello jw.cs.park,

it looks functional, please also test with pps utility, $ sudo apt install pps-tools
here’s sample test command, $ sudo ppstest /dev/pps0 to check whether you’re able to get one timer trigger for each pulse.

Hi Jerry,

Thank you for the answer.
Here is the result of ppstest

sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1718347592.142258016, sequence: 1808 - clear  0.000000000, sequence: 0
source 0 - assert 1718347593.166249152, sequence: 1809 - clear  0.000000000, sequence: 0
source 0 - assert 1718347594.190253248, sequence: 1810 - clear  0.000000000, sequence: 0
source 0 - assert 1718347595.214248928, sequence: 1811 - clear  0.000000000, sequence: 0
source 0 - assert 1718347596.238253120, sequence: 1812 - clear  0.000000000, sequence: 0
source 0 - assert 1718347597.262252032, sequence: 1813 - clear  0.000000000, sequence: 0
source 0 - assert 1718347598.286249504, sequence: 1814 - clear  0.000000000, sequence: 0
source 0 - assert 1718347599.310253952, sequence: 1815 - clear  0.000000000, sequence: 0
source 0 - assert 1718347600.334250784, sequence: 1816 - clear  0.000000000, sequence: 0
source 0 - assert 1718347601.358255840, sequence: 1817 - clear  0.000000000, sequence: 0
source 0 - assert 1718347602.382253216, sequence: 1818 - clear  0.000000000, sequence: 0
source 0 - assert 1718347603.406254656, sequence: 1819 - clear  0.000000000, sequence: 0
source 0 - assert 1718347604.430248128, sequence: 1820 - clear  0.000000000, sequence: 0

Is it functional?

hello jw.cs.park,

it looks not correct.
there should be timestamps and its sequence numbers.

please try again to enable PPS from MGB with this… $ sudo devmem2 0x06810d70 w 1

Hi Jerry,
Thank you for your response.

I tried following commands after boot.

sudo insmod cam_cdi_tsc.ko
sudo insmod nvpps.ko
sudo devmem2 0x06810d70 w 1
sudo ppstest /dev/pps0

But still the timestamp and sequence number of ppstest remain 0. There is no noticeable event in dmesg.

Could you check the device tree of Device tree for TSC (nvidia,tegra234-cdi-tsc) - #19 by jw.cs.park one more time? Is it correct to connect gpio in nvpps and gpio_pinmux ins tegra234-pwm.dtsi?

I wonder if there are any steps that I missed.

Board: AGX Orin devkit, JP 5.1.3
Device tree modification: tegra234-p3701-0000-p3737-0000.dts, tegra234-pwm.dtsi
defconfig modification: CONFIG_VIDEO_CDI=m->y

Thanks