BPI-R2 SPI Communication

Sorry, it was a copy/paste error. I’ve corrected the post.

have my git corrected too…

is my guess right, that driver had only handled TX but not RX? so it have to be fixed in mainline

Yes, you are right. In FIFO mode were two problems. RX mode was never handled and, in this case the tx_buf pointer was NULL and caused an exception.

1 Like

Posted Patch to mainline,let’s wait for reactions

Nice, merged on first version (for 5.15)

1 Like

Great work! Meanwhile I will also add this to OpenWrt. Do you plan to backport that to 5.4 and 5.10?

Imho patch should work on 5.4 too…but i’ve missed stable-tag :frowning:

1 Like

Just created the PR for the backport, but I still have no BPI-R2, that makes testing complicated… xD

1 Like

i’ve send mail to stable-ML to have it included in older LTS kernels (at least 5.4 and 5.10)

https://lkml.org/lkml/2021/7/24/27

btw. it is already in 5.14 as it is a fix and already merged in linus torvald’s tree

1 Like

Nice, thanks. :slight_smile: I accidentally wrote 5.15 kernel. ^^ I waiting for my BPI-R2! :smiley:

Spi fix is now queued for 4.9+ after a short conversation with stable maintainer (greg k h). 4.4 will need a backport,but as mtk uses their own source not up-to-date upstream 4.4 and most boards are not supported in 4.4 i have skipped 4.4

1 Like

The patch got a revert in Mailinglist as it breaks another device. Commit message says rx is normally handled by interrupt…but this seems not to be the case on r2…

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Maybe interrupt is wrong? https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/mt7623.dtsi#L487

How can we find out?

I’ m working on it. I’ ll build a separate SPI slave device to test all specific SPI communications to enshure everything works proper.

Hi, I’m trying to run Banana Pi R2 + ST7735s ???

  Kernel: 6.18.0-bpi-r2-main arch: armv7l bits: 32 compiler: N/A Console: pty pts/0 Distro: Debian
    GNU/Linux 12 (bookworm)
Machine:
  Type: ARM System: Bananapi BPI-R2 details: Mediatek Cortex-A7 rev: N/A

root@bpi-r2:~# ls -l /dev/spidev*
crw------- 1 root root 153, 0 Jan 11 20:55 /dev/spidev0.0

root@bpi-r2:~# lsmod | grep spi
spidev                 24576  0
spi_mt65xx             24576  0
root@bpi-r2:~# lsmod | grep 7735
st7735r                12288  0
backlight              16384  1 st7735r
drm_mipi_dbi           24576  1 st7735r

I have it connected

I have it connected
BPR2                                  st7735                       
MOSI  pin 19                           SDA
MISO  pin 23                           SCL 
RES   pin 16                           RES
DC    pin 22                           DC 
CS    pin24                            CS 
3,3V                                   VCC
GND                                    GND 

does SPI work in BPR2 at all? ???

root@bpi-r2:~#  grep SPI1 /sys/kernel/debug/pinctrl/*/pinmux-pins
pin 7 (SPI1_CSN): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 8 (SPI1_MI): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 9 (SPI1_MO): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 199 (SPI1_CLK): (MUX UNCLAIMED) (GPIO UNCLAIMED)
root@bpi-r2:~#  grep SPI0 /sys/kernel/debug/pinctrl/*/pinmux-pins
pin 0 (PWRAP_SPI0_MI): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 1 (PWRAP_SPI0_MO): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 3 (PWRAP_SPI0_CK): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 4 (PWRAP_SPI0_CSN): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 5 (PWRAP_SPI0_CK2): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 6 (PWRAP_SPI0_CSN2): (MUX UNCLAIMED) (GPIO UNCLAIMED)
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

I tried many methods in python - nothing works