BPI-R2 SPI Communication

added spi-dev as module to 4.14.15-main…

https://drive.google.com/open?id=1EGN1TvqCpDHdOAS-mjRg9ipi0kahnOUV

Hi. Thanks for helps.

I use kernel 4.4.xx . Also, I activated the device -> driver->SPI support from kernel menuconfig. I compiled the kernel gcc-arm-linux-gnueabihf-6. It compiled succesfully. gcc-7 gives errors.

I still don’t see spidev0 or spidev1 driver in /dev directory.

Which one of the device driver Should I activate from ./build.sh option 4 for spidev?

spidev is under spi-support names somehow user-driver or similar…you can search in menuconfig with / for spidev

I have activeted all of SPI Support subheaders including spi user interface. But, I didn,t see /dev/spidev.

Is it necessary to enable or install spi after buildg kernel?

I don’t know which spi should be found…do you use gpio-spi or inside your camera? If using gpio you have to enanle it in dts(i)

I am using gpio spi. where can I enable dts?

Here i wrote the steps for enabling spi in dts: SPI touchscreen ads7846 (xpt2046) on UBUNTU images (BPI-R2)

The kernel which you sent me, is not booting? I have merged the compiled BPI_BOOT and BPI_ROOT directories with SD card but, it didn’t boot.

Or it has not hdmi support?

Kernel 4.14 has no no working hdmi yet…see the issue on github.

But you can use the nodes in dts and kernel-options from 4.14 to extend 4.4

We plan to send HDMI related patches to mainline late this month and will add MIPI support if we have time to do that.

If you want to use spi0: [email protected] you should enable it, add the correct pinmux setting and add a device which is connected to spi0.

There are many examples in /arch/arm//boot/dts/* (for more details please grep ‘spi’ ).

Thanks

Hi Ryder. I have editted mt7623.dtsi following;

         spi0: [email protected] {
                compatible = "mediatek,mt7623-spi",
                             "mediatek,mt2701-spi";
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <0 0x1100a000 0 0x100>;
                interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>;
                clocks = <&topckgen CLK_TOP_SYSPLL3_D2>,
                         <&topckgen CLK_TOP_SPI0_SEL>,
                         <&pericfg CLK_PERI_SPI0>;
                clock-names = "parent-clk", "sel-clk", "spi-clk";
                status = "disabled";
        };

Also, I added like this mt7623n_bpi_r2.dts file;

spi0_pins_a: [email protected] {
		pins_spi {
			pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
				<MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
				<MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
				<MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
			bias-disable;
		};
	};

I have checked gpio of spi are correct. But, I couldn’t see /dev/spidev.0.0 after rebuilding kernel.

Did you enable it : "status = “okay”?

Please type this command: find /sys/bus | grep spi

Yes I have also added to mt7623n_bpi_r2.dts following;

&spi0 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi0_pins_a>;
	status = "okay";
};

Actually, Driver is seen, but There is no /dev/spidev

[email protected]:~$ find /sys/bus | grep spi
/sys/bus/spi
/sys/bus/spi/devices
/sys/bus/spi/drivers
/sys/bus/spi/drivers/spidev
/sys/bus/spi/drivers/spidev/bind
/sys/bus/spi/drivers/spidev/uevent
/sys/bus/spi/drivers/spidev/unbind
/sys/bus/spi/uevent
/sys/bus/spi/drivers_probe
/sys/bus/spi/drivers_autoprobe
/sys/bus/platform/devices/1100a000.spi
/sys/bus/platform/drivers/mtk-spi
/sys/bus/platform/drivers/mtk-spi/bind
/sys/bus/platform/drivers/mtk-spi/1100a000.spi
/sys/bus/platform/drivers/mtk-spi/uevent
/sys/bus/platform/drivers/mtk-spi/unbind

also I have enabled spi user interface from kernel build options.

Please have a look at : https://www.kernel.org/doc/Documentation/spi/spidev

Hi.

I I have looked the link and made some research. I tried to create devices and bind to driver with “mknod” command. But, I couldn’t solve the problem.

Have you any another idea?

Did you have the slave devices connected to host controller? Did you try to use mdev or udev to create /dev/* node?

Sorry. I didn’t try to create device node from udev and mdev. Because I didn’t find any Info how to create it.

Can you send or tell me how to create spidev from mdev and udev? I will be very glad for this.

enable CONFIG_SPI_SPIDEV and CONFIG_SPI_MT65XX.

Add spidev node to spi bus:

&spi {

  pinctrl-names = "default"; 
  pinctrl-0 = <&spi_pins_a>; 
  status = "okay"; 

 spidev: [email protected] { 
    compatible = "spidev"; 
    spi-max-frequency = <1000000>; 
    reg = <0>; 
 }; 

};

build user space test code :Documentation/spi/spidev_test.c and copy to board.

./spidev_test -D /dev/spidevxxx

The below log indicates that spi bus loopback success.

spi mode: 0x0 bits per word:[ 1366.441051] <0>(O) max speed: 500000 Hz (500 KHz) FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DE AD BE EF BA AD F0 0D

1 Like

Nope… I can’t it. There is still no /dev/spidev and also device can’t opened at example program.