Need advise to let cm32181 works on Xavier (Solved)

Hello,

I’m trying to apply cm32181(light sensor) via I2C#5 on Xavier.
I’ve done the following works and I now can see the node under /proc/device-tree/i2c@31b0000/cm32181
But currently I’m still failed to find my device by command i2cdetect or /sys/bus/iio/devices/iio:device*

  1. Pin-to-Pin connect from Xavier to CM32181.
    SDA pin connect to Expansion Header Pin 3 (I2C_GP5_DTA_3V3)
    SCL pin connect to Expansion Header Pin 5 (I2C_GP5_CLK_3V3)
    INT pin connect to Expansion Header Pin 16(GPIO8_AO_DMIC_IN_DAT)
    GND pin connect to Expansion Header Pin 6 (GND)
    VDD pin connect to Expansion Header Pin 1 (VDD_3V3)

  2. Apply cm32181 node on tegra194-p2888-0001-p2822-0000.dts.
    31b0000 is the address of I2C#5 that I got from Pinmux table.

i2c@31b0000 {
		cm32181@31b0000 {
			compatible = "capella,cm32181";
			reg = <0x10>;
			interrupt-parent = <&tegra_aon_gpio>;
			// GPIO8_AO_DMIC_IN_DAT is GPIO3_PBB.00.
			interrupts = <TEGRA194_AON_GPIO(BB, 0) IRQ_TYPE_LEVEL_LOW>;
			capella,intrpin-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(BB, 0) 0>;
			capella,ALS_slave_address = <0x10>;
		};
	};
  1. Enable cm32181 flag in Kconfig.
    And I can see “CONFIG_CM32181=y” is applying on .config.

  2. I fail to see my device on system
    nvidia@jetson-0423318029512:~$ sudo i2cdetect -l
    i2c-3 i2c 3190000.i2c I2C adapter
    i2c-1 i2c c240000.i2c I2C adapter
    i2c-8 i2c 31e0000.i2c I2C adapter
    i2c-6 i2c 31c0000.i2c I2C adapter
    i2c-4 i2c Tegra BPMP I2C adapter I2C adapter
    i2c-2 i2c 3180000.i2c I2C adapter
    i2c-0 i2c 3160000.i2c I2C adapter
    i2c-7 i2c c250000.i2c I2C adapter
    i2c-5 i2c 31b0000.i2c I2C adapter
    nvidia@jetson-0423318029512:~$ sudo i2cdetect -y 5
    Warning: Can’t use SMBus Quick Write command, will skip some addresses
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00:
    10:
    20:
    30: – – – – – – – –
    40:
    50: – – – – – – – – – – – – – – – –
    60:
    70:
    nvidia@jetson-0423318029512:~$ ll /sys/bus/iio/devices/
    total 0
    drwxr-xr-x 2 root root 0 Oct 26 08:40 ./
    drwxr-xr-x 4 root root 0 Oct 26 02:45 …/
    lrwxrwxrwx 1 root root 0 Oct 26 02:45 iio:device0 → …/…/…/devices/c240000.i2c/i2c-1/1-0040/iio:device0/
    lrwxrwxrwx 1 root root 0 Oct 26 02:45 iio:device1 → …/…/…/devices/c240000.i2c/i2c-1/1-0041/iio:device1/
    nvidia@jetson-0423318029512:~$

Thanks a lot.

I found that there is a probe register failure.
Is is caused by DTS?

nvidia@jetson-0423318029512:~$ sudo dmesg | grep "cm321"
[   15.566618] cm32181 5-0010: cm32181_probe: register init failed
[   15.567853] cm32181: probe of 5-0010 failed with error -110

Not the answer, but Pin 3 and Pin 5 on the Expansion Header are on I2C bus 8, ie

$ sudo i2cdetect -y -r 8

Hi Kanglow,

Many thanks for your reply,

nvidia@jetson-0423318029512:~$ sudo i2cdetect -y -r 8
[sudo] password for nvidia: 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- 74 -- -- --

I have a question about the I2C index you mentioned,
As I can see in Jetson_AGX_Devkit_Pinmux_Configuration_Template.xlsm
40-pin header pin3/pin5 is I2C5_DTA/I2C5_CLK usage.
It seems that I misunderstand I2C5 = bus 5.
How can I read the index mapping?

Hi Kangalow,

The sensor works fine after I move the CM32181 DTS to i2c@31e0000(i2C#8) scope.
Now I can read the illuminance from /sys/bus/iio/devices$ cat iio:device2/in_illuminance_input
However, I need to know how does the index mapping.

Thanks. ChihChia