Device Tree for additional device on same I2C bus

I am adding a 2nd I2C device (pn547 NFC controller) on same I2C bus as RTC on colibri evaluation board. I added a child node of I2C side-by-side with RTC device in imx6dl-colibri-eval-v3.dts file as the following:

	/* M41T0M6 real time clock on carrier board */
	rtc_i2c: rtc@68 {
		compatible = "st,m41t0";
		reg = <0x68>;
	};
+	/* NFC Controller on carrier board */
+	pn547: pn547@28 {
+		compatible = "nxp,pn547";
+		reg = <0x28>;
+		clock-frequency = <400000>;  
+		interrupt-gpios = <&gpio2 2 0>;  
+		enable-gpios = <&gpio2 6 0>;  
	};

After building the device tree and flashing, I only see RTC device node with address 68 by i2cdetect command . It’s not showing new device being added.with address 28.

root@colibri-imx6:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

What am I missing in device tree?

William

What am I missing in device tree?

I would suggest to first check the h/w connections, as the slave address is not ACKed while checking with i2cdetect.

Secondly the driver, at least the 4.1 kernel doesn’t have PN547 driver. Not sure, are you following this application note of NXP for driver ?

Yes, I did follow instructions in that application note to build PN547 driver.
I just removed the RTC in the device tree file and disconnected the RTC by removing corresponding jumpers on the board. Now I don’t see any devices with command “i2cdetect -y -r 2”.

root@colibri-imx6:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

But I do see address 28 showing up with command “i2cdetect 2”.

root@colibri-imx6:~# i2cdetect 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

-r option with i2cdetect uses SMBUS read and this is known to lock SMBus on various write-only chips, have a look at the man page here. At least the slave device on the bus is active. Did the driver loaded successfully ? Seems the driver need to be build as an external kernel module. Can you check for any debug messages from the driver after loading it ?

The kernel has built-in driver.How do I check if the driver is loaded successfully? The kernel start-up log does not show anything related to the driver.
I can configure kernel to build driver as module (pn5xx_i2c.ko). But after the module is built, how do I add it to rootfs?

But after the module is built, how do I add it to rootfs?

For kernel module deployment hints, refer this article.

Do you also configure the pinmuxing of interrupt and enable IOs ?

The kernel has built-in driver.How do I check if the driver is loaded successfully? The kernel start-up log does not show anything related to the driver.

I pulled the driver and enabled it via device tree, I could see some debug logs during boot.

root@colibri-imx6:~# dmesg|grep pn5
[    5.470829] pn54x_dev_init
[    5.517483] pn54x_probe
[    5.521184] pn544 2-0028: FIRM GPIO <OPTIONAL> error getting from OF node
[    5.529315] pn544 2-0028: CLKREQ GPIO <OPTIONAL> error getting from OF node
[    5.735058] 2-0028 supply nxp,pn54x-pvdd not found, using dummy regulator
[    5.923962] 2-0028 supply nxp,pn54x-vbat not found, using dummy regulator
[    6.098982] 2-0028 supply nxp,pn54x-pmuvcc not found, using dummy regulator
[    6.251840] 2-0028 supply nxp,pn54x-sevdd not found, using dummy regulator
[    6.405530] pn54x_probe: request irq_gpio 34
[    6.411062] pn54x_probe: request ven_gpio 38
[    6.578863] pn54x_probe : requesting IRQ 71

Find the two patches in attachment. These patches are applied on top of toradex_4.1-2.0.x-imx-next branch

link text

The kernel module deployment command is complaining the gcc compiler not found while the compiler does exist. The kernel was built successfully under the same environment:

wz@wz-VirtualBox:~/linux-toradex$ make -j3 uImage LOADADDR=10008000 2>&1 | tee build.log
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CHK     include/generated/bounds.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  Kernel: arch/arm/boot/Image is ready
  Kernel: arch/arm/boot/zImage is ready
  Image arch/arm/boot/uImage is ready
wz@wz-VirtualBox:~/linux-toradex$ sudo -E make INSTALL_MOD_PATH=/srv/nfs/Colibri-iMX6_LXDE-Image_2.7.2/rootfs/ modules_install
[sudo] password for wz: 
make: arm-linux-gnueabihf-gcc: Command not found
cp: cannot stat ‘./modules.order’: No such file or directory
make: *** [_modinst_] Error 1
wz@wz-VirtualBox:~/linux-toradex$ which arm-linux-gnueabihf-gcc
/home/wz/gcc-linaro/bin/arm-linux-gnueabihf-gcc

I couldn’t get the kernel module deployment command to work. It keeps complaining command not found.

wz@wz-VirtualBox:~/linux-toradex$ sudo -E make INSTALL_MOD_PATH=/srv/nfs/Colibri-iMX6_LXDE-Image_2.7.2/rootfs/ modules_install
make: arm-linux-gnueabihf-gcc: Command not found
cp: cannot stat ‘./modules.order’: No such file or directory
make: *** [_modinst_] Error 1
wz@wz-VirtualBox:~/linux-toradex$ which arm-linux-gnueabihf-gcc
/home/wz/gcc-linaro/bin/arm-linux-gnueabihf-gcc

Did you compile the module (# make modules) ?
As such sudo -E should preserve your existing env variable values.
How exactly the CROSS_COMPILE variable got exported ?

I forgot to run “make -j3 modules” before installing the module. Now the deployment command is working now.

Thank you for the patches. It looks like the driver module was loaded successfully. The demo app is now running without any issues.
I did not configure the pinmuxing of interrupt and enable IOs. That seems fine.
Thank you very very much for your help.
William

Okay, glad to hear that.