Solved nanopi neo2: enable i2c through dtb overlay

Board used is nanopi-neo2 (actually board ) whith Allwinner H5 cpu.
Though there is no precompiled image for this board, I've got it running by combining the PINE64 image with the following mods:
  • plugged u-boot-sunxi-with-spl.bin on image at offset 8k from package u-boot-nanopi-neo2
  • modded /boot/loader.conf with
    Code:
    fdt_overlays="sun50i-h5-opp,sun50i-h5-nanopi-neo2-opp"
But I cannot get the i2c interface active/available:
  • No iichb in bootlog
  • No iic in /dev
System boots with dtb from u-boot, which has i2c disabled.
Checked with ofwdump:
Code:
# ofwdump -p /soc/i2c@1c2ac00
Node 0x389c: i2c@1c2ac00
  compatible:
    61 6c 6c 77 69 6e 6e 65 72 2c 73 75 6e 36 69 2d 61 33 31 2d
    69 32 63 00
    'allwinner,sun6i-a31-i2c'
  reg:
    01 c2 ac 00 00 00 04 00
  interrupts:
    00 00 00 00 00 00 00 06 00 00 00 04
  clocks:
    00 00 00 1e 00 00 00 3b
  resets:
    00 00 00 1e 00 00 00 2e
  pinctrl-names:
    64 65 66 61 75 6c 74 00
    'default'
  pinctrl-0:
    00 00 00 22
  status:
    64 69 73 61 62 6c 65 64 00
    'disabled'
  #address-cells:
    00 00 00 01
  #size-cells:
    00 00 00 00
  phandle:
    00 00 00 45

Tried to enable by adding a compiled file /boot/dtb/overlays/sun50i-h5-i2c.dtbo and listing it to fdt_overlays in loader.conf :
Code:
/dts-v1/;

/  {

        compatible = "allwinner,sun6i-a31-i2c";
        fragment@0 {

                target-path = "/soc/i2c@1c2ac00";
                __overlay__ {

                        status = "okay";
                };
        };
        __symbols__ {

        };
};

But bootlog shows:
Code:
Booting [/boot/kernel/kernel]...               
Using DTB provided by EFI at 0x47ef6000.
Loading DTB overlays: 'sun50i-h5-opp,sun50i-h5-nanopi-neo2-opp,sun50i-h5-i2c'
/boot/dtb/overlays/sun50i-h5-opp.dtbo size=0x8c9
/boot/dtb/overlays/sun50i-h5-nanopi-neo2-opp.dtbo size=0x3da
/boot/dtb/overlays/sun50i-h5-i2c.dtbo size=0xfa
applying DTB overlay '/boot/dtb/overlays/sun50i-h5-opp.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun50i-h5-nanopi-neo2-opp.dtbo'
DTB overlay '/boot/dtb/overlays/sun50i-h5-i2c.dtbo' not compatible

Any hints/suggestions on how to enable i2c through overlay?
 
You should use the top level compatible that defines the whole SoC.
I guess that it is something like allwinner,sun50i-h5.

Also, I personally like to examine the device tree using this command:
sysctl -b hw.fdt.dtb | dtc -I dtb -O dts

Finally, you can use somewhat simpler, more modern syntax for writing overlays.
E.g.:
Code:
/dts-v1/;
/plugin/;
/ {
        compatible = "allwinner,sun8i-h3";
}
&{/soc/i2c@1c2ac00} {
        status = "okay";
};
 
Solved! Used this overlay, even simpler by referncing symbol:
Code:
/dts-v1/;                                                                      
/plugin/;                                                                      
/  {                                                                          
                                                                               
        compatible = "allwinner,sun50i-h5";                                    
}                                                                              
&i2c0 {                                                          
                status = "okay";                                              
};

Now it loads correctly:

Code:
..........
Loading DTB overlays: 'sun50i-h5-opp,sun50i-h5-nanopi-neo2-opp,sun50i-h5-i2c'
/boot/dtb/overlays/sun50i-h5-opp.dtbo size=0x8c9
/boot/dtb/overlays/sun50i-h5-nanopi-neo2-opp.dtbo size=0x3da
/boot/dtb/overlays/sun50i-h5-i2c.dtbo size=0xe2
applying DTB overlay '/boot/dtb/overlays/sun50i-h5-opp.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun50i-h5-nanopi-neo2-opp.dtbo'
applying DTB overlay '/boot/dtb/overlays/sun50i-h5-i2c.dtbo'
.........
iic0: <I2C generic I/O> on iicbus0

Thanks a lot.
 
Back
Top