I2C device not detected with device tree implementation

Hello,

I have a custom PCB with an imaging sensor and a I2C GPIO expander. Both can be probed using i2cget but when I try to implement the devices using the device tree, it’s not working as expected.

My device tree:

hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-camera-custom.dtsi

/ {

    i2c@c240000 {
        tca9539_74: tca9539@74 { // Carrier board
            compatible = "ti,tca9539";
            gpio-controller;
            #gpio-cells = <2>;
            reg = <0x74>;
            skip_mux_detect = "yes";
            //vcc-supply = <&en_vdd_cam>;
            tca9539_74_outlow {
                gpio-hog;
                gpios = <0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 1 9 0 10 0 11 0 12 0 13 0 14 0 15 0>;
                output-low;
            };
            tca9539_74_outhigh {
                status = "disabled";
            };
            tca9539_74_input {
                status = "disabled";
            };
        };
    };
...

When I look into dmesg I see this (related to 0x74):

[   10.569378] tegra-i2c 3160000.i2c: pio timed out addr: 0x74 tlen:28 rlen:4
[   10.569422] tegra-i2c 3160000.i2c: --- register dump for debugging ----
[   10.569452] tegra-i2c 3160000.i2c: I2C_CNFG - 0x22c00
[   10.569478] tegra-i2c 3160000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x10001
[   10.569506] tegra-i2c 3160000.i2c: I2C_FIFO_CONTROL - 0xe0
[   10.569556] tegra-i2c 3160000.i2c: I2C_FIFO_STATUS - 0x800040
[   10.569581] tegra-i2c 3160000.i2c: I2C_INT_MASK - 0x7d
[   10.569607] tegra-i2c 3160000.i2c: I2C_INT_STATUS - 0x0
[   10.569633] tegra-i2c 3160000.i2c: i2c transfer timed out addr: 0x74
[   10.569694] pca953x 0-0074: failed reading register
[   10.569815] pca953x: probe of 0-0074 failed with error -110

Trying to detect the device gives me nothing. I have to ask for data in order to receive an ack:

ubuntu@jetsontx2:~$ sudo i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
ubuntu@jetsontx2:~$ sudo i2cget -y 1 0x74 0x00
0x00
ubuntu@jetsontx2:~$ sudo i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- 74 -- -- --
ubuntu@jetsontx2:~$

As you can see, my TCA9539 is connected to i2c@c240000. This is because it’s physically connected to I2C_GP0, which belongs to i2c-1 according to i2cdetect -l

Am I missing a step in implementing this I2C GPIO expander?

The error log shouldn’t not be “3160000.i2c”?
Have a check dmesg | grep -i tca9

Unfortunately it doesn’t result to anything.

This is the complete dmesg log: https://del.dog/TCA95

Check the if tca9539 really loaded.

sudo ls /proc/device-tree/i2c@c240000

It doesn’t seem to be listed. I searched the whole directory using

ubuntu@jetsontx2:~$ sudo find /proc/device-tree/ -name tca9539*

Neither can I find my IMX392 camera driver

ubuntu@jetsontx2:~$ sudo find /proc/device-tree/ -name imx*
/proc/device-tree/__symbols__/imx274_cam1
/proc/device-tree/__symbols__/imx390_csi_out1
/proc/device-tree/__symbols__/imx390_cam1
/proc/device-tree/__symbols__/imx390_csi_in0
/proc/device-tree/__symbols__/imx390_imx390_out0
/proc/device-tree/__symbols__/imx390_vi_in0
/proc/device-tree/__symbols__/imx274_cam0
/proc/device-tree/__symbols__/imx390_csi_in1
/proc/device-tree/__symbols__/imx390_csi_out0
/proc/device-tree/__symbols__/imx390_imx390_out1
/proc/device-tree/__symbols__/imx390_cam0
/proc/device-tree/__symbols__/imx390_vi_in1
/proc/device-tree/__symbols__/imx185_cam0
/proc/device-tree/i2c@3180000/tca9548@77/i2c@0/imx219_a@10
/proc/device-tree/i2c@3180000/tca9548@77/i2c@5/imx219_f@10
/proc/device-tree/i2c@3180000/tca9548@77/i2c@3/imx219_d@10
/proc/device-tree/i2c@3180000/tca9548@77/i2c@1/imx219_b@10
/proc/device-tree/i2c@3180000/tca9548@77/i2c@4/imx219_e@10
/proc/device-tree/i2c@3180000/tca9548@77/i2c@2/imx219_c@10
/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/imx390_a@1b
/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/imx390_b@1c
/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/imx318_a@10
/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/imx274_a@1a
/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/imx185_a@1a
/proc/device-tree/i2c@3180000/tca9546@70/i2c@1/imx274_c@1a

Just in case I’m missing something. I copy the files to the source directory in the L4T build environment and patch the files that need to be patched, then compile the kernel and eventually flash the Jetson using these two commands:

sudo ./flash.sh -k kernel jetson-tx2 mmcblk0p1
sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1

The logs are here:
Kernel flash
DTB flash

Am I supposed to find any custom related things in here?

Edit:
After doing a search through the whole system looking for “imx392*”, it seems like nothing is found. I believe there might be an issue regarding flashing the kernel. Compiling the kernel does show a result

CC      drivers/media/i2c/imx392.o

For the kernel Image you need to copy it to the /boot/Image to apply it.
Did you replace the copy the dtb file to the …/Linux_for_tegra/kernel/dtb/ and flash with -k kernel-dtb?

It seems that it doesn’t compile the new/custom device tree files, but does compile the driver:

$ sudo find . -name *imx392*
./images/drivers/media/i2c/.imx392.o.cmd
./images/drivers/media/i2c/imx392.o
./images/include/config/video/imx392.h
./sources/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-modules/tegra186-camera-imx392-dual.dtsi
./sources/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-camera-imx392-dual.dtsi
./sources/kernel/nvidia/drivers/media/i2c/imx392.c
./sources/kernel/nvidia/drivers/media/i2c/imx392_mode_tbls.h

Did I copy the dtsi files to the wrong location or do I manually have to compile using the devicetree command and copy them to …/Linux_for_Tegra/kernel/dtb/?

You need to copy the dtb file instead of dtsi file to …/Linux_for_tegra/kernel/dtb/. (should be the tegra186-quill-p3310-1000-c03-00-base.dtb)

That dtb file seems to be in place

$ sudo find . -name tegra186-quill-p3310-1000-c03-00-base.dtb
./build/Linux_for_Tegra/images/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb
./build/Linux_for_Tegra/images/arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dtb
./build/Linux_for_Tegra/bootloader/tegra186-quill-p3310-1000-c03-00-base.dtb
./build/Linux_for_Tegra/rootfs/boot/tegra186-quill-p3310-1000-c03-00-base.dtb
./build/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb

Copy ./build/Linux_for_Tegra/images/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb
to ./build/Linux_for_Tegra/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb

It seems to have done something, but I’m not sure if it’s correct as I can’t test it on my custom carrier board at the moment. Dmesg shows this regarding the TCA9539 and IMX392

[    0.538232] gpiochip_setup_dev: registered GPIOs 240 to 255 on device: gpiochip2 (tca9539)
[    0.539190] GPIO line 228 (lcd-bias-rails) hogged as output/high
[    0.539391] gpiochip_setup_dev: registered GPIOs 224 to 239 on device: gpiochip3 (tca9539)
[    0.541419] pca953x 1-0074: reg get err: -19
[    0.543320] i2c i2c-2: of_i2c: modalias failure on /i2c@3180000/lens_imx392@ACDCY1601G1
[    0.543361] i2c i2c-2: Failed to create I2C device for /i2c@3180000/lens_imx392@ACDCY1601G1
[    0.543370] i2c i2c-2: of_i2c: modalias failure on /i2c@3180000/lens_imx392@PN1230271
[    0.543404] i2c i2c-2: Failed to create I2C device for /i2c@3180000/lens_imx392@PN1230271
[    0.543412] i2c i2c-2: of_i2c: modalias failure on /i2c@3180000/lens_imx392@B5M3428S123
[    0.543466] i2c i2c-2: Failed to create I2C device for /i2c@3180000/lens_imx392@B5M3428S123

This tells me that the dtb files are flashed. I will test it as soon as I can. (I know that my lens implementations are incorrect, but this is an easy way to generate errors/warnings without breaking compiling of the dtb files)

Hi FPSUsername,

Have you managed to get device up and running? Any result can be shared?

Thanks

Hello,

I haven’t worked on this project for a while since the focus in my work has shifted to another project.
I will update this as soon as I can.

Thanks!

I had the time to test it today. It seems that the TCA9539 is loaded and the two imx392 sensors!

ubuntu@ubuntu-desktop:~$ sudo ls /proc/device-tree/i2c@c240000
'#address-cells'   clock-names   dmas          iommus                             ov23850_c@36    resets             status
 ak8963@0d         clocks        gpio@20       iqs263@44                          phandle         rt5659.1-001a@1a   tca9539@74
 bmi160@69         cm32180@48    i2cmux@70     linux,phandle                      prod-settings   scl-gpio
 bmp280@77         compatible    icm20628@68   lp8556-backlight-s-wqxga-10-1@2c   reg             sda-gpio
 clock-frequency   dma-names     interrupts    name                               reset-names    '#size-cells'
ubuntu@ubuntu-desktop:~$ sudo ls /proc/device-tree/i2c@3180000
'#address-cells'   dma-names     iommus                    name            reg          '#size-cells'
 clock-frequency   dmas          lens_imx392@ACDCY1601G1   ov23850_a@10    reset-names   status
 clock-names       imx392_a@36   lens_imx392@B5M3428S123   ov5693_c@36     resets        tca6408@21
 clocks            imx392_c@37   lens_imx392@PN1230271     phandle         scl-gpio      tca9546@70
 compatible        interrupts    linux,phandle             prod-settings   sda-gpio      tca9548@77

Unfortunately dmesg doesn’t show any information regarding the TCA9539 at i2c@c240000, and isn’t recognized with i2cdetect. Only after a i2cget command.

What I quite don’t understand is how I should start a video stream so that the TCA9539 will enable the power supplies of the sensors. In the first post you can see that pin 8 is set to a high state, this pin controls the power sequencer chip. However it doesn’t seem to be set to high after a reboot.

Besides that, I don’t see the devnotes of both sensors when I print the /dev directory to my terminal. There’s no video0 and video1.

I had the same problem

What do you mean “isn’t recognized with i2cdetect. Only after a i2cget command.” ?
The device can detect after issue an i2cget command?

Hello FPSUsername/Bruce_lol

As you could see the gpio-driver probe shows “reg get err”. Hence the gpio-controller isn’t getting probed. You can add the vcc-supply entry on your gpio-controller device tree node as the driver expects it or you can write a gpio-controller driver derived from drivers/gpio/gpio-pca953x.c and not use devm_regulator_get() on the driver to work with.

Hi Sarath:
There’s no “reg get err” on log,but shows “tegra-i2c c240000.i2c:no acknowledge from address 0x3~0x77”,neither can I i2cdetect or i2cget anything on i2c bus 0~8 which with the lastest BSP(32.3.1),confused about this issue.

When I run this command after boot, the spot on 0x74 is empty (–).

$ sudo i2cdetect -y -r 1

In order to get it shown I have to run this command and then rerun the i2cdetect command.

$ sudo i2cget -y 1 0x74 0x00

@Sarath- I have #vcc-supply = <&en_vdd_cam>; in the TCA9539 part in the device tree file of the imaging sensor. As you can see, it’s disabled. I’m not sure if this part <&en_vdd_cam> is correct. Is this what I should enable/add?

TX1 and TX2 are pin compatible,why TX1 works well,any diff?