BPI-R2 SPI Communication


Yes, boot from emmc.


My kernel version: 4.4.120

spi0: spi@1100a000 {
	compatible = "mediatek,mt7623-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";

spi0_pins_a: spi@0 {
	pins_spi {
		pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,

&spi0 {

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

spidev: spidev@0 {
	compatible = "rohm,dh2228fv";
	spi-max-frequency = <1000000>;
	reg = <0>;


(Frank W.) #84

you have the pinmux in dtsi? in pio-block or separate?

Jack have it pull also in the dts: https://github.com/JackZengBpi/BPI-R2-bsp/commit/0b7eb9e24a66d405970aff1b466bb50b21f925b8#diff-f6e9ae435447a08e357a3335e06dbabd


In dts pio block. I can’t figure out why you guys cannot see the outputs.

(Frank W.) #86

Can you clone my repo and test with it?

(Prakash) #87


I used your kernel on emmc boot and the test result as below. However, I was only able to boot into buildroot login, not able to boot into Ubuntu OS.

spidev_test -s 1000000 -D /dev/spidev32766.0

spi mode: 0x0

bits per word: 8

max speed: 1000000 Hz (1000 KHz)

RX | 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 F0 0D | …@…�…

@frank-w You need some modifications based on @Ryder.Lee inputs.


Sure, this is a minimum defconfig. I just want to prove that SPI function is okay. Anyway, If you want to run Ubuntu you should enable some configurations (lots of FS options, cgroup, …) .

(Frank W.) #89

removed above blocks from my dtsi (first section) and dts (lower 2 blocks) and added from ryders post, loaded spidev-module, same result

@Ryder.Lee can you please look at the spi-blocks in my dts(i)?


one change i see is spi vs. spi0


I don’t think it is a kernel level issue. Maybe you should check security level on your OS. I guess something blocks the output.

(Frank W.) #91

on my test-board it is the official debian jessie :wink: only apt-get upgraded (no upgrade to stretch) i have not enabled any security options there

that spidev is loaded as module should not be the problem or am i’m wrong? => tested also with spidev built-in…same result

how to check for a blocking? you have really nothing changed related to spi in your kernel?

same result with jacks kernel (had added spi too); @Jackzeng is spi working in your kernel?

as of documentation https://www.kernel.org/doc/Documentation/pinctrl.txt SPI-Pinmux should be CLK, RXD, TXD, FRM…don’t know what FRM is, but if i understand it right RX=MISO, TX=MOSI…so pinmux has wrong order

can you compare pins with kernel from @Ryder.Lee :

root@bpi-r2:~# cat /sys/kernel/debug/pinctrl/1000b000.pinctrl/pinmux-pins | grep spi
pin 53 (SPI0_CSN): 1100a000.spi (GPIO UNCLAIMED) function func1 group SPI0_CSN
pin 54 (SPI0_CK): 1100a000.spi (GPIO UNCLAIMED) function func1 group SPI0_CK
pin 55 (SPI0_MI): 1100a000.spi (GPIO UNCLAIMED) function func1 group SPI0_MI
pin 56 (SPI0_MO): 1100a000.spi (GPIO UNCLAIMED) function func1 group SPI0_MO

that matches the pin-defines from shematics… :thinking:

linux-mt/arch/arm/boot/dts/include/dt-bindings/pinctrl/mt7623-pinfunc.h:197:#define MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO (MTK_PIN_NO(56) | 1)
linux-mt/arch/arm/boot/dts/include/dt-bindings/pinctrl/mt7623-pinfunc.h:198:#define MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MI (MTK_PIN_NO(56) | 2)

(ZB) #92

OK, Frank I don’t see data output,the phenomenon is like yours.

(Frank W.) #93

Which os do you use?

(ZB) #94

Hello, Frank, I use Ubuntu

(Prakash) #95

Any fixes available for this SPI issue?.


(Frank W.) #96

@Ryder.Lee can you please share your kernel-source for comparison?


I didn’t do anything but just added SPI node in dts. Moreover, I can get the same results when using v4.16.

(Frank W.) #98

Maybe i’ve added it in wrong place or missing any kernel-option…


I’ve used the latest kernel version(v4.16-rc1) to test the SPI panel (ili9225).

Panel driver: drivers/gpu/drm/tinydrm/ili9225.c

Share my dts and config for you: mt7623n_evb_defconfig (5.2 KB) mt7623.dtsi (20.9 KB) mt7623n-bananapi-bpi-r2.dts (9.4 KB)

Test command: Capture

SPI touchscreen ads7846 (xpt2046) on UBUNTU images (BPI-R2)
(Frank W.) #100

the only diference i’ve found:

my spi-block in bpi.dts:

&spi0 {
	pinctrl-names = "default";
	pinctrl-0 = <&spi0_pins_a>;
	status = "okay";
	spidev: spidev@0 {
		compatible = "rohm,dh2228fv";
		spi-max-frequency = <1000000>;
		reg = <0>;

your block (direct for the device):

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

		compatible = "vot,v220hf01a-t", "ilitek,ili9225";
		reg = <0>;
		spi-max-frequency = <1000000>;
		rs-gpios = <&pio 25 GPIO_ACTIVE_HIGH>;
		reset-gpios = <&pio 18 GPIO_ACTIVE_HIGH>;
		rotation = <270>;

you have another compatible string and name for the spi-device (and some additional options for your device)…i don’t know if the gpios-options needed, too. Also on you screenshot i see that you have another HW-revision of bpi-board (maybe 1.2), because battery connector is missing and there is the uboot-switch


The difference is I connect a real device to SPI0, so the DTS should be modified accordingly.

Can you test the uImage I provided before (spidev_test)? I think it has nothing to do with HW-revision. I will suggest you to use buildroot or other simple rootfs to test HW.