How to enable spi on Hikey960 Linux

I have an rpb desktop image and I am trying to interface a display using SPI. I am unable to find the file /dev/spi* . This means that the SPI is not exported to userspace by the kernel. How do I achieve that, if anyone can please help.

Hi @sejalgupta,

Userspace access to SPI devices are taken care by SPIDEV interface. You can use the following diff and CONFIG_SPI_SPIDEV menuconfig option for enabling SPIDEV on HiKey960.

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
index 97d768730952..8930170699a5 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
@@ -564,6 +564,12 @@
        /* On Low speed expansion */
        label = "LS-SPI0";
        status = "okay";
+
+       spidev@0 {
+               compatible = "spidev";
+               spi-max-frequency = <500000>;
+               reg = <0>;
+       };
 };
 
 &spi3 {

Then build and flash the kernel and DTB as mentioned here [1]. Finally, SPIDEV can be tested according to the instructions specified in the guide[2].

Thanks,
Mani

[1] https://github.com/96boards/documentation/blob/master/consumer/hikey/hikey620/build/linux-kernel.md
[2] https://github.com/96boards/documentation/blob/master/consumer/dragonboard/dragonboard410c/guides/enable-spi.md#3-testing-spidev

1 Like

Hey @Mani
Thank you for replying
I tried this solution but I cannot find /dev/spi* .There is an spidev folder in sys/class/ but it is empty. Hence I am unable to test SPIDEV according to the link shared by you

Is SPIDEV enabled using CONFIG_SPI_SPIDEV option? Can you please share the dmesg log through pastebin here?

Thanks,
Mani

Hey @Mani
Thank you for replying

Here is the dmesg log for SPI :-
linaro@hikey960:~$ dmesg| grep spi
[ 0.285875] ssp-pl022 ffd68000.spi: could not find pctldev for node /soc/pinmux@fff11000/spi2_pmx_func, deferring probe
[ 0.285900] ssp-pl022 ff3b3000.spi: could not find pctldev for node /soc/pinmux@ff3b6000/spi3_pmx_func, deferring probe
[ 0.690747] ssp-pl022 ffd68000.spi: ARM PL022 driver, device ID: 0x00041022
[ 0.690872] ssp-pl022 ffd68000.spi: mapped registers from 0x00000000ffd68000 to ffff000009d05000
[ 0.690931] ssp-pl022 ffd68000.spi: setup for DMA on RX dma0chan0, TX dma0chan1
[ 0.691487] ssp-pl022 ff3b3000.spi: ARM PL022 driver, device ID: 0x00041022
[ 0.691686] ssp-pl022 ff3b3000.spi: mapped registers from 0x00000000ff3b3000 to ffff000009d0d000
[ 0.691731] ssp-pl022 ff3b3000.spi: setup for DMA on RX dma0chan2, TX dma0chan3

The complete dmesg log is here :-

Thank You

Hi,
Is your problem have been resolved Sajengupta ?
If yes please share the information too.