TC358840 interface

Hello,

I am trying to interface with TC358840 on our custom design board.

I am using Nvidia Jetson Nano SOM.

I am interfacing with TC358840 on I2C0 interface and trying to read CSI data through CSI0-3 (8 lane) port.

TC358840 detected on I2C0 lane with 0x1f address.

user@user-desktop:~$ i2cdetect -y -r 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – 1f
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – –

I made following dtsi changes in dtb.
tegra210-tc358840.txt (5.9 KB)

As TC358840 default drivers are present in Nano OS.

user@user-desktop:~$ lsmod
Module Size Used by
overlay 48718 0
fuse 104554 3
r8188eu 470649 0
cfg80211 591474 1 r8188eu
userspace_alert 5828 0
tc358840 41609 0
nvgpu 1590185 32
ip_tables 19441 2 iptable_filter,iptable_nat
x_tables 28951 5 ip_tables,iptable_filter,ipt_MASQUERADE,xt_addrtype,xt_conntrack

But module is not engage.
Actually I m trying to debug the things for that I am trying to disable default driver of TC358840.
I tried to modify tegra_defconfig and compile source but still its not get disabled.
Please guide me on either how to disable default driver of TC358840? or how to make proper dtsi changes in dtb to support default driver?

hello rusurya,

please update compatible property, which for identifies the node.
for instance, since both of them were using the same string, such as… compatible="toshiba,tc358840";
this is point-to default built-in driver, kernel/nvidia/drivers/media/i2c/tc358840.c

Hello,

Thanks a lot for reply.

Actually in dtsi I had define same compatible property.

 compatible = "toshiba,tc358840";

Please check given dtsi file.

One more thing I want to mention here that normally its seen that ref_clk taken 48MHz in my case I have use 40MHz clk.

Will that make any issue?
Please guide me on this.

hello rusurya,

here’s default device tree of tc358840,
as you can see… $public_sources/kernel_src/hardware/nvidia/platform/t210/jetson/kernel-dts/jetson-platforms/tegra210-camera-imx274-hdmi.dtsi
you may try to exclude this device tree to avoid settings being overwritten.

besides,
you may check the VI driver for debugging,
$public_source/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/sensor_common.c
especially the sensor_common_parse_signal_props() and sensor_common_parse_image_props() to parse the settings via device tree.
please check you’ve correct settings parsed and sending to low-level driver for sensor initialization.

Hello,
Thanks a lot for reply.
I took default source without any dtsi changes and compiled it. I got final dtb
tegra210-p3448-0002-p3449-0000-b00.dtb. I convert this dtb in to dts and search for tc358840 but I won’t find any thing in that.
I think in Nano OS for TC358840 there is only default driver (kernel module) is available but corresponding dtsi changes are not there.
When I flash SOM with default dtb then tc358840 is not visible in the list when I gave lsmod command.
So I think whatever changes I made in device tree with above mentioned dtsi , they are not get overwritten by tegra210-camera-imx274-hdmi.dtsi.
Because whenever I made above dtsi changes then only tc358840 module activated.
I want to know how can I disable or remove default driver of TC358840?
I tried to edit tegra_defconfig list but it won’t work.

Please guide me on this issue.
Thanks a lot for support.

hello rusurya,

please aware that Jetson Nano using those dtsi file within… hardware/nvidia/platform/t210/porg
such tegra210-camera-imx274-hdmi.dtsi is available for TX1 targets only.

I just don’t understand what did you meant… disable or remove default driver of TC358840
as mentioned, it’s compatible property for loading its corresponding driver, you may using another unique string if you’re developing your own TC358840 driver.

Hello,

Thanks a lot for reply.

Actually in tegra_defconfig file there is kernel module is listed as

CONFIG_VIDEO_TC358840=m
I change this “m” to “y” to create module but not to deploy.
I compiled whole kernel and flashed SOM. But when I start the system TC358840 module is automatically activated and its shown in lsmod command.
I was expecting that TC358840. ko is present but should not get deploy.
It should activate when I give

sudo insmod tc358840.ko.

Please guide me on how to stop tc358840 module to auto activate (auto deploy)?

Please guide me on this topic.
Thanks a for reply.

Hello,

Please check the following dmesg log when tc358840 driver installed.

user@user-desktop:~$ sudo dmesg --follow | grep tc358840
[sudo] password for user:
[ 4.300716] tc358840 0-001f: camera_common_regulator_get vdig ERR: fffffffffffffdfb
[ 4.360020] tc358840 0-001f: cannot get regulator vdig -517

To trace out this error I check the driver code of tc358840, in tc358840_probe function
there tc358840_pwr_init function is called,
this function consist of camera_common_regulator_get function

static int tc358840_pwr_init(struct tc358840_platform_data *pdata,
struct i2c_client *client)
{
struct device_node *node = client->dev.of_node;
int cam2_rst;
int err;
struct regulator *dvdd;
struct regulator *iovdd;

err = camera_common_regulator_get(&client->dev, &iovdd, "vif");
if (err < 0) {
	dev_err(&client->dev, "cannot get regulator vif %d\n", err);
	return -EINVAL;
}

err = camera_common_regulator_get(&client->dev, &dvdd, "vdig");
if (err < 0) {
	dev_err(&client->dev, "cannot get regulator vdig %d\n", err);
	return -EINVAL;
}

I think these functions read supply parameters from dtsi. As per reference dtsi in

$public_sources/kernel_src/hardware/nvidia/platform/t210/jetson/kernel-dts/jetson-platforms/tegra210-camera-imx274-hdmi.dtsi

vif-supply = <&en_vdd_cam>;
vdig-supply = <&en_vdd_cam_1v2_alt>;

I add these parameters in my dtsi but this dtsi is not get compiled.
error says that <en_vdd_cam_1v2_alt> node is not define.

Then I changed <en_vdd_cam_1v2_alt > to <en_vdd_cam_1v2> then device tree get compiled.
But might be driver required <en_vdd_cam_1v2_alt> node, because of this it give above error.

Please guide me on this issue.

Thanks for support.

hello rusurya,

it’s driver config, you should config CONFIG_VIDEO_TC358840 to report the built favor,
for instance, obj-$(CONFIG_VIDEO_TC358840) += tc358840.o
it’s m to build as loadable kernel module, y to built-in with kernel image.
so,
you don’t need to perform insmod to load the driver if you already changed kernel config to y.

it’s camera registration during kernel initialization stage.
there’s failure of get regulator, such failure return to skip camera node registration.

there’re no en_vdd_cam and en_vdd_cam_1v2_alt defined for Jetson Nano.
you may see-also Camera Module Hardware Design Guide for [Chapter 4. Power].
please use VDD_3V3_SYS instead for power-supply.

Hello,

Thanks for reply.

So if I don’t want to use default driver of tc358840 then should I make
CONFIG_VIDEO_TC358840 = n in config file.
Or should I remove obj-$(CONFIG_VIDEO_TC358840) += tc358840.o from config file and then compile the kernel.

Please guide me on this.
Thanks a lot for support.

you should just remove that line, i.e. obj-$(CONFIG_VIDEO_TC358840) += tc358840.o from build config.

Hello,

Thanks a lot for reply.

Actually in Linux for Tegra source ~/kernel/nvidia/drivers/media/i2c location there are two files are there
Kconfig file which consist of configuration for tc358840 and second there is makefile which consist of
obj-$(CONFIG_VIDEO_TC358840) += tc358840.o
I removed line for TC358840 then in tegra_defconfig file I removed
CONFIG_VIDEO_TC358840=m line in file.
compile the kernel and then flash the som
In this OS there are no dtsi changes for tc358840 then tc358840 kernel module is not visible in lsmod list but as soon as I include dtsi changes in dtb then tc358840 module is visible in the lsmod list.
That indicate after removing the tc358840 from build config its kernel object is still active.
Please guide me how to remove that.
Thanks for support.

hello rusurya,

may I double confirm which dtsi change you’ve included.

I still don’t understand,
why you need to exclude TC358840’s kernel module, but you using that compatible property to load TC358840’s driver; these two were contradiction.

Hello,

Thanks a lot for reply.
Please check attached dtsi file.
tegra210-tc358840.txt (6.1 KB)
This file I include in my dts (tegra210-p3448-0002-p3449-0000-b00.dts) and compile the dtb and flash the SOM.
Thanks for support.

hello rusurya,

please check the logs after you include dtsi. you may enable kernel logs with… $ dmesg --follow.
you’ll see the logs for camera device registration to setup a video device node to linux kernel. such sensor probing only run once during kernel initialization stage, the driver will Power On the sensor, Start Sensor Streaming, sending relevant v4l2 controls, and finally power off the sensor.

it’s normal, or… may I know what you expected.

Hello,

Thanks a lot for reply.
Please check attached full log file and filtered log file for tc358840.
It look driver initiate but if fails.
I modified default driver code and put more debug messages across each function.
Please check attached log of custom driver.
There it look like it gone through all the probing process and bound successfully.
But after installing driver tc358840 module is not engage with device.
We are getting video0 device but its giving false value when we check through v4l2 command.
One thing I realize that in probing function there is parse_dt function is there.
In this function there are lot of debug messages are there to print but if we check our custom / default driver its not printing those messages.
As per log it goes in parse_dt function but its not executing functions in that.
Why its happening?
Please guide me on that.
customdriverlog2807.txt (1.7 KB)
defaulttc358840driverlog2807.txt (474 Bytes)
fulllog2807.txt (58.3 KB)

Hello,

One more thing is that we remove
obj-$(CONFIG_VIDEO_TC358840) += tc358840.o
from make file and compile kernel.
in this case tc358840 default driver should not be there in default OS then how it activate when I boot the SOM?
Please guide me on this issue.
Thanks for support.

this should be my question to you, which I asked several times.
why you need to remove a driver but you’re actually need that?

Hello,

Actually right now I am checking this TC358840 circuit first time.
Default driver is not working on that.
So I thought I can disable default driver, take that code , add few debug traces to identify where I am failing?

Actually I disabled TC358840 default driver.
In /lib/modules/4.9.253/kernel/driver/media/i2c there is tc358840.ko is there. That I removed from that location.
Now default driver is not activate when I boot the SOM.
Now I am working on same driver code , added few debug messages and insert module manually and trying to check where is the issue?

hello rusurya,

all right, now I understand.

please refer to /kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig
it’s by default configure to built as kernel module, i.e. CONFIG_VIDEO_TC358840=m

you may simply rebuilt the source code, it shall generate a new *.ko file.
after that, just copy that binary file via ssh to the target, overwriting with the default kernel module to apply your change.
please refer to developer guide, Building the NVIDIA Kernel for reference.