BPI-R2 SPI Communication

Yes, boot from emmc.

My kernel version: 4.4.120

spi0: spi@1100a000 {
	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";
};

spi0_pins_a: spi@0 {
	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;
	};
};

&spi0 {

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

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

};

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.

Can you clone my repo and test with it?

@Ryder.Lee

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, ā€¦) .

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)?

https://github.com/frank-w/BPI-R2-4.4/commit/fd26f7d1c4e816acf37c06a88bac2b83f563a5ff

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.

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)

OK, Frank I donā€™t see data outputļ¼Œthe phenomenon is like yours.

1 Like

Which os do you use?

Hello, Frank, I use Ubuntu

Any fixes available for this SPI issue?.

TIA.

@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.

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

IMG_1595

1 Like

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";

	display@0{
		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.