Jetson TX2 TCA9548 I2C switch and TCA6408 I2C GPIO Expander

Hello,

We designed our own carrier board for the TX2, and are now looking into software to get things working.

When looking into the “Sensor driver programming” guide, it pointed towards a sample IMX185 dtsi file. Looking closer into this, I noted the following line:

proc-device-tree = "/proc/device-tree/i2c@3180000/tca9546@70/i2c@0/imx185_a@1a";

This seems to suggest theres an TCA9546 @ I2C address 0x70 onboard of the TX2 module. As it happens, we designed the TCA9548 on our design, to facilitate multiple identical sensors on the same I2C bus. I can access our own TCA9548 perfectly fine with i2cget/set commands, but now I’m looking to implement it the same way as it apparantly already has been done on the TX2 for the TCA9546.

However, when looking through the kernel source files I could only find the driver file, located in \kernel\kernel-4.4\drivers\i2c\muxes\i2c-mux-pca954x.c. This file also includes an option for our TCA9548.

I can’t seem to find the dtsi file or any other file where the TCA9546 is instantiated. This would make it much easier to implement, as our own design is pretty much an exact copy.

Long story short; where can I find the files necessary editing to add the TCA9548 to our device tree?

I’m also wondering how these edited .dtsi files are added/compiled to the kernel, but I’ve got a lot more documentation to read first :)

Thanks in advance

Hi
You can reference to the E3333 DT that is 6 sensors board design use the TCA9548.

Thank you, this helped me getting the TCA9548 registered and working. I also noted the IMX219 code also uses an TCA6408 expander.

However, I’m now running into problems getting our TCA6408 to work… Our hardware design looks the following:

I’m starting with implementing only 1 sensor, but it runs into problems with the reset_gpio:

[    8.597189] invalid GPIO -517
[    8.601118] ------------[ cut here ]------------
[    8.601121] WARNING: at ffffffc00037a4f8 [verbose debug info unavailable]
[    8.601130] Modules linked in: pci_tegra bluedroid_pm

[    8.601138] CPU: 1 PID: 356 Comm: v4l_id Not tainted 4.4.38+ #16
[    8.601139] Hardware name: quill (DT)
[    8.601142] task: ffffffc1e5927080 ti: ffffffc1e148c000 task.ti: ffffffc1e148c000
[    8.601151] PC is at gpio_to_desc+0xc4/0xd0
[    8.601153] LR is at gpio_to_desc+0xc4/0xd0
[    8.601163] pc : [<ffffffc00037a4f8>] lr : [<ffffffc00037a4f8>] pstate: 80000045
[    8.601172] sp : ffffffc1e148f9f0
[    8.601181] x29: ffffffc1e148f9f0 x28: 0000000000000000 
[    8.601184] x27: 0000000000000000 x26: 0000000000000000 
[    8.601194] x25: ffffffc1e148fe80 x24: ffffffc001445000 
[    8.601202] x23: 0000000000000000 x22: ffffffc1ebddf300 
[    8.601206] x21: ffffffc00144b000 x20: 00000000fffffdfb 
[    8.601215] x19: ffffffc00129cfc8 x18: 0000007fe11eecf8 
[    8.601218] x17: 0000000000000000 x16: 0000000000000000 
[    8.601221] x15: 0000000000000000 x14: 0000000000000000 
[    8.601224] x13: 0000000000000000 x12: 0000000000000000 
[    8.601227] x11: 0000000000000000 x10: 00000000000008b0 
[    8.601276] x9 : ffffffc1e148f7b0 x8 : ffffffc1e5927990 
[    8.601285] x7 : 0000000000000400 x6 : 0000000002ca037f 
[    8.601306] x5 : ffffffc1f666d9a8 x4 : ffffffc1e5927998 
[    8.601309] x3 : 0000000000000000 x2 : ffffffc1e36c4b28 
[    8.601312] x1 : 0000000000000000 x0 : 0000000000000011 

[    8.601611] ---[ end trace f4ea3f2c4e39bf94 ]---
[    8.601612] Call trace:
[    8.601617] [<ffffffc00037a4f8>] gpio_to_desc+0xc4/0xd0
[    8.601623] [<ffffffc000777fd0>] imx290_power_on+0xd8/0x118
[    8.601628] [<ffffffc0007a5fb0>] camera_common_s_power+0xe4/0x17c
[    8.601634] [<ffffffc00079b328>] tegra_channel_set_power+0x50/0x90
[    8.601638] [<ffffffc0007a0cec>] vi4_power_on+0x74/0x90
[    8.601641] [<ffffffc00079ad30>] tegra_channel_open+0x64/0xbc
[    8.601645] [<ffffffc00077b9ec>] v4l2_open+0xb8/0xfc
[    8.601650] [<ffffffc0001d96ec>] chrdev_open+0xa0/0x190
[    8.601657] [<ffffffc0001d2b8c>] do_dentry_open+0x1e0/0x2f8
[    8.601660] [<ffffffc0001d3f48>] vfs_open+0x50/0x7c
[    8.601663] [<ffffffc0001e1eb4>] do_last+0x120/0xbec
[    8.601666] [<ffffffc0001e29f4>] path_openat+0x74/0x2b4
[    8.601669] [<ffffffc0001e40ac>] do_filp_open+0x58/0xb0
[    8.601671] [<ffffffc0001d42fc>] do_sys_open+0x140/0x21c
[    8.601674] [<ffffffc0001d4410>] SyS_openat+0x10/0x18
[    8.601679] [<ffffffc000084ff0>] el0_svc_naked+0x24/0x28
[    8.602214] invalid GPIO -517
[    8.602264] ------------[ cut here ]------------
[    8.602266] WARNING: at ffffffc00037a4f8 [verbose debug info unavailable]
[    8.602271] Modules linked in: pci_tegra bluedroid_pm

[    8.602277] CPU: 1 PID: 356 Comm: v4l_id Tainted: G        W       4.4.38+ #16
[    8.602278] Hardware name: quill (DT)
[    8.602281] task: ffffffc1e5927080 ti: ffffffc1e148c000 task.ti: ffffffc1e148c000
[    8.602285] PC is at gpio_to_desc+0xc4/0xd0
[    8.602287] LR is at gpio_to_desc+0xc4/0xd0
[    8.602290] pc : [<ffffffc00037a4f8>] lr : [<ffffffc00037a4f8>] pstate: 80000045
[    8.602291] sp : ffffffc1e148f9f0
[    8.602296] x29: ffffffc1e148f9f0 x28: 0000000000000000 
[    8.602299] x27: 0000000000000000 x26: 0000000000000000 
[    8.602303] x25: ffffffc1e148fe80 x24: ffffffc001445000 
[    8.602306] x23: 0000000000000000 x22: ffffffc1ebddf300 
[    8.602309] x21: ffffffc00144b000 x20: 00000000fffffdfb 
[    8.602313] x19: ffffffc00129cfc8 x18: 0000007fe11eecf8 
[    8.602316] x17: 0000000000000000 x16: 0000000000000000 
[    8.602319] x15: 00000000fa83b2da x14: 00000000000002c8 
[    8.602322] x13: 00000000fa83b2da x12: ffffffc001255000 
[    8.602325] x11: ffffffc0013f4000 x10: 0000000000000000 
[    8.602329] x9 : 000000000000a984 x8 : ffffffc00140ae9f 
[    8.602332] x7 : 0000000000000000 x6 : 000000001001607a 
[    8.602335] x5 : 000000001001607a x4 : 0000000000000000 
[    8.602338] x3 : 0000000000000000 x2 : 0000000000000000 
[    8.602341] x1 : 0000000000000008 x0 : 0000000000000011 

[    8.602459] ---[ end trace f4ea3f2c4e39bf95 ]---
[    8.602460] Call trace:
[    8.602463] [<ffffffc00037a4f8>] gpio_to_desc+0xc4/0xd0
[    8.602467] [<ffffffc000777fec>] imx290_power_on+0xf4/0x118
[    8.602470] [<ffffffc0007a5fb0>] camera_common_s_power+0xe4/0x17c
[    8.602473] [<ffffffc00079b328>] tegra_channel_set_power+0x50/0x90
[    8.602476] [<ffffffc0007a0cec>] vi4_power_on+0x74/0x90
[    8.602479] [<ffffffc00079ad30>] tegra_channel_open+0x64/0xbc
[    8.602494] [<ffffffc00077b9ec>] v4l2_open+0xb8/0xfc
[    8.602498] [<ffffffc0001d96ec>] chrdev_open+0xa0/0x190
[    8.602504] [<ffffffc0001d2b8c>] do_dentry_open+0x1e0/0x2f8
[    8.602507] [<ffffffc0001d3f48>] vfs_open+0x50/0x7c
[    8.602525] [<ffffffc0001e1eb4>] do_last+0x120/0xbec
[    8.602528] [<ffffffc0001e29f4>] path_openat+0x74/0x2b4
[    8.602531] [<ffffffc0001e40ac>] do_filp_open+0x58/0xb0
[    8.602540] [<ffffffc0001d42fc>] do_sys_open+0x140/0x21c
[    8.602543] [<ffffffc0001d4410>] SyS_openat+0x10/0x18
[    8.602546] [<ffffffc000084ff0>] el0_svc_naked+0x24/0x28

I’ve never seen the TCA6408 show up as a gpiochip in /sys/class/gpio, but I am quite sure it is detected.

TX2 on a devkit (thus no 9548 and 6408 present):

[    0.370190] pca954x 2-0070: pca954x_probe: forcing device bus number, start 30.
[    0.370210] pca954x 2-0070: device detect skipped.
[    0.370310] regulator_get() failed for (2-0070,vcc-pullup), -19
[    0.370325] pca954x 2-0070: vcc-pullup regulator not found
[    0.370415] i2c i2c-2: Added multiplexed i2c bus 30
[    0.370491] i2c i2c-2: Added multiplexed i2c bus 31
[    0.370561] i2c i2c-2: Added multiplexed i2c bus 32
[    0.371362] tegra-i2c 3180000.i2c: no acknowledge from address 0x70
[    0.371660] tegra-i2c 3180000.i2c: no acknowledge from address 0x70
[    0.371814] pca953x 33-0021: failed reading register
[    0.372036] pca953x: probe of 33-0021 failed with error -121
[    0.372064] i2c i2c-2: Added multiplexed i2c bus 33
[    0.372138] i2c i2c-2: Added multiplexed i2c bus 34
[    0.372211] i2c i2c-2: Added multiplexed i2c bus 35
[    0.372277] i2c i2c-2: Added multiplexed i2c bus 36
[    0.372345] i2c i2c-2: Added multiplexed i2c bus 37

TX2 on custom carrier with sensorboard attached:

[    0.352032] pca954x 2-0070: pca954x_probe: forcing device bus number, start 30.
[    0.352053] pca954x 2-0070: device detect skipped.
[    0.352133] regulator_get() failed for (2-0070,vcc-pullup), -19
[    0.352147] pca954x 2-0070: vcc-pullup regulator not found
[    0.352234] i2c i2c-2: Added multiplexed i2c bus 30
[    0.352309] i2c i2c-2: Added multiplexed i2c bus 31
[    0.352379] i2c i2c-2: Added multiplexed i2c bus 32
[    0.352611] i2c i2c-2: Added multiplexed i2c bus 33
[    0.352685] i2c i2c-2: Added multiplexed i2c bus 34
[    0.352763] i2c i2c-2: Added multiplexed i2c bus 35
[    0.352832] i2c i2c-2: Added multiplexed i2c bus 36
[    0.352898] i2c i2c-2: Added multiplexed i2c bus 37
[    0.352912] pca954x 2-0070: registered 8 multiplexed busses for I2C switch pca9548

I’ve tried several things, but I just can’t get it to work… any suggestions on where to start to make the 6408 working? I can see that GPIO -517 will be invalid, but I cannot try to understand how to solve this…

See attached files for DTSI’s and driver file used.
imx290.c (30.1 KB)
tegra186-camera-imx290-a00-dtsi.txt (8.13 KB)
tegra186-quill-camera-imx290-a00-dtsi.txt (3.28 KB)
tegra186-quill-p3310-1000-a00-00-base-dts.txt (5.77 KB)
tegra18_defconfig.txt (15.2 KB)

Looks like have problem to access the pca954x, it could be the HW issue.

[ 0.371362] tegra-i2c 3180000.i2c: no acknowledge from address 0x70

No that is a correct message, since that is from the dmesg log when the TX2 module is placed on the original dev kit (so there is no PCA954x attached). The 2nd log is when the TX2 module is placed on our custom carrier, it doesn’t show that message then, suggesting it is properly probed. Both full logs are also attached to that post.

To add some more information; our custom sensorboard is already up and running on another platform, so the hardware should be ok. I also tested the TCA9548 hardware with i2c_detect, i2c_set and i2c_get commands, conforming the hardware is working ok.

Well, We’ve found our problem eventually… in the common platforms DTSI we had to change the following:

tca6408_test: gpio@21 {
					status = "okay";
					compatible = "ti,tca6408";
					gpio-controller;
					#gpio-cells = <2>;
					reg = <0x21>;
					/* vcc-supply = <&en_vdd_cam>; Falco: doesn't exist on our own carrier board */
                                        vcc-supply = <&battery_reg>; /* Says it's always on */

Now it appears correctly as a gpiochip in /sys/class/gpio. We only found out after adding some printk’s to the PCA953x driver file, only then it showed failed to start the regulator.

The en_vdd_cam is defined in /common/kernel-dts/t18x-common-platforms/tegra186-cvb-prod-p2597-b00-p3310-1000-a00-00.dtsi. However, it is defined as an gpio on an gpio extender (gpio = <&gpio_i2c_0_77 9 1>;). This gpio extender is present on the dev kit, but not on our own carrier. This is why it failed, but the regulator enable function doesn’t have an option to report when it fails.