This is a cache of https://discuss.96boards.org/t/kernel-configuration-for-enabling-i2c-on-hikey-lemaker-620/7517. It is a snapshot of the page at 2024-10-31T10:43:21.052+0000.
Kernel configuration for enabling I2C on Hikey LeMaker 620 - HiKey - 96Boards Forum

Kernel configuration for enabling I2C on Hikey LeMaker 620

I have a Hikey LeMaker 620 on which I am trying to enable I2C support as currently I am not getting /dev/i2c* node.

I am using the docs here : https://github.com/96boards/documentation/blob/master/consumer/hikey/hikey620/build/linux-kernel.md

I see that
I2C_DESIGNWARE_PLATFORM
I2C_CHARDEV

are already enabled, still I do not see anything in /sys/bus/i2c/devices/ and as a result my i2cdetect fails saying “/dev/i2c/0 : No such file or directory”

Can someone please help.

Is there any problem with dts file?

/ # dmesg | grep i2c
[    0.251154] i2c-core: driver [dummy] registered
[    0.284233] i2c-core: driver [pca953x] registered
[    0.286078] i2c-core: driver [sec_pmic] registered
[    0.287137] i2c_designware f7100000.i2c: could not find pctldev for node /soc/pinmux@f7010000/i2c0_pmx_func, deferring probe
[    0.287167] i2c_designware f7101000.i2c: could not find pctldev for node /soc/pinmux@f7010000/i2c1_pmx_func, deferring probe
[    0.287188] i2c_designware f7102000.i2c: could not find pctldev for node /soc/pinmux@f7010000/i2c2_pmx_func, deferring probe
[    0.323590] i2c-core: driver [cs2000-cp] registered
[    0.328647] i2c-core: driver [fan53555-regulator] registered
[    0.340913] i2c-core: driver [cros-ec-i2c] registered
[    0.341005] i2c-core: driver [max77620] registered
[    0.341054] i2c-core: driver [rk808] registered
[    0.351637] i2c-core: driver [usb3503] registered
[    0.353610] i2c-core: driver [rtc-ds3232] registered
[    0.354842] i2c /dev entries driver
[    0.355782] i2c-core: driver [pca954x] registered
[    0.356294] i2c-core: driver [bq27xxx-battery] registered
[    0.501408] i2c-core: driver [hmc5843] registered
[    2.209817] i2c_designware f7100000.i2c: Unknown Synopsys component type: 0x00000000
[    2.218809] i2c_designware f7101000.i2c: Unknown Synopsys component type: 0x00000000
[    2.227621] i2c_designware f7102000.i2c: Unknown Synopsys component type: 0x00000000

I am surprised that no one has answer to this.
I see a lot of questions here been asked for other i2c problems once they have those nodes. So at least I request those folks to share their kernel configs with with they were getting the /dev/i2c* nodes.

You don’t see I2C controllers because of init error:

[    2.209817] i2c_designware f7100000.i2c: Unknown Synopsys component type: 0x00000000
[    2.218809] i2c_designware f7101000.i2c: Unknown Synopsys component type: 0x00000000
[    2.227621] i2c_designware f7102000.i2c: Unknown Synopsys component type: 0x00000000

Look like something prevent the driver to correctly read a register:
https://elixir.bootlin.com/linux/v4.15.18/source/drivers/i2c/busses/i2c-designware-master.c#L65

Not sure why, did you change the device tree in any way?

No I did not change anything. I just take the exact kernel and used the same steps to build the kernel defined at : https://github.com/96boards/documentation/blob/master/consumer/hikey/hikey620/build/linux-kernel.md

$ git clone https://github.com/suihkulokki/linux.git
$ git checkout -t origin/hikey-v4.15
$ export ARCH=arm64 
$ export CROSS_COMPILE=<path-to-cross-compiler>/aarch64-linux-gnu-gcc-
$ make defconfig distro.config
$ make menuconfig #add I enabled some I2C flags
$ make -j111

I did not change anything after cloning that kernel, except few kernel configs relating to I2C.

@Naveen_Chaudhary Just for the confirmation, did you flash latest firmware as well? BoardRecovery for HiKey - 96Boards

I have not flashed those pre-built binaries but have prepared my own firmware and u-boot as mentioned here : https://github.com/qemu/u-boot/tree/master/board/hisilicon/hikey

What exactly are those? You don’t need to enable any additional Kconfig options for getting I2C to work.

Ok. When I tried very first time with that released configs (by adding no personal changes) i did not see any i2c nodes. After that only I started trying with enabling additional configs with a hope to see some i2c nodes.

So, with the original config also, it did not work for me. No /dev/i2c* or nothing in /sys/bus/i2c/devices/ and /sys/class/i2c-dev/ .

That’s weird. Btw, can you please try the same build instructions with this kernel tree? manivannan.sadhasivam/hikey.git - [no description]

Please make sure that the tree is clean before building.

Sure. Can you please tell the kernel config to use. I mean the kernel config command to run before make.

Same as before:

$ make defconfig distro.config

I have started the cloning and will update the results in next 1-2 hours.

Hi,
I see the exact same behaviour with 4.19.5 that you shared.

/ # uname -a
Linux 10.0.0.225 4.19.5 #1 SMP PREEMPT Thu Mar 7 09:41:28 IST 2019 aarch64 GNU/Linux
/ # ls /sys/i2c*
ls: /sys/i2c*: No such file or directory
/ # ls /sys/bus/i2c/devices/
/ #
/ #
/ # ls /sys/class/i2c-dev/
/ #
/ #

Here’s the dmesg with this new kernel :

/ # dmesg | grep i2c
[    0.396588] i2c /dev entries driver
[    0.796432] i2c_designware f7100000.i2c: Unknown Synopsys component type: 0x00000000
[    1.408924] i2c_designware f7101000.i2c: Unknown Synopsys component type: 0x00000000
[    2.156303] i2c_designware f7102000.i2c: Unknown Synopsys component type: 0x00000000

Here is my boot.scr (just for reference) :

tftpboot 0x80000 10.0.0.1:uImage
tftpboot 0x2000000 10.0.0.1:hi6220-hikey.dtb
setenv bootargs 'console=ttyAMA3,115200n8 root=/dev/nfs nfsroot=10.0.0.1:/home/naveen/rootfs-arm64,nolock,vers=4,tcp ip=dhcp rw'
bootm 0x80000 - 0x2000000

Okay. I’ll try to reproduce this behaviour with my hikey running u-boot and get back to you.

Thanks,
Mani

Were you able to reproduce this issue?

@Naveen_Chaudhary Yes, I can reproduce the issue on my Hikey. It seems like u-boot is missing some configs for enabling I2C properly. I2C is working fine with our official UEFI build.

I have created a bug report for tracking this issue: https://bugs.96boards.org/show_bug.cgi?id=822

Thanks for reporting. We will work on resolving this issue asap.

-Mani

Hi @Naveen_Chaudhary,

Please try the below commit for resolving this issue:

I have submitted a patch [1] to u-boot ML for the same.

Thanks,
Mani

[1] [U-Boot] [PATCH] hikey: Take peripherals out of reset during board init

Thanks Mani,

I tried this patch and it worked just fine. I can see the /dev/i2c-* nodes now.

Thanks for your great support.

I also connected a sensor to I2C-1 and able to get the sensor on bus.

/ # i2cdetect -r 1
i2cdetect: WARNING! This program can confuse your I2C bus
Continue? [y/N] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- 13 -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

0x13 is my sensor address. I was also able to communicate with the sensor well. However, for some reason, I was not able to get the sensor working on I2C-0 as the device didn’t show up. However, this could be because of muxing, which I can see. Thanks Mani for the patch, it really unblocked me :slight_smile: