[Banana BPI-R4] SPI

Here you can find an instruction (openwrt_spi_v3.pdf) and all needed files (Adafruit_Blinka_SPI_Pack.tar) +patch +dts file.

1 Like

I got pretty far with ST7789V and the DRM_PANEL_MIPI_DBI driver which provides DRM/KMS interface (and optional fbdev emulation including a text console in case CONFIG_DRM_FBDEV_EMULATION is enabled).

--- a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi
+++ b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi
@@ -75,6 +75,15 @@
 			default-state = "off";
 		};
 	};
+
+	backlight: backlight-lcd0 {
+		compatible = "pwm-backlight";
+		pwms = <&pwm 6 50000>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pwm6_backlight_pins>;
+
+		status = "okay";
+	};
 };
 
 &eth {
@@ -304,6 +313,18 @@
 			function = "pwm";
 		};
 	};
+
+	pwm6_backlight_pins: pwm6-pins {
+		mux {
+			groups = "pwm6_0";
+			function = "pwm";
+		};
+
+		conf {
+			groups = "pwm6_0";
+			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+		};
+	};
 };
 
 &pwm {
@@ -402,3 +423,40 @@
 &xphy {
 	status = "okay";
 };
+
+&spi1 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	status = "okay";
+
+	display@0 {
+		compatible = "zjy-ips130-v20", "panel-mipi-dbi-spi";
+		reg = <0>;
+		spi-max-frequency = <104000000>;
+		spi-tx-buswidth = <1>;
+		spi-rx-buswidth = <0>;
+		spi-cpha;
+		spi-cpol;
+
+		dc-gpios = <&pio 53 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&pio 52 GPIO_ACTIVE_HIGH>;
+		backlight = <&backlight>;
+		write-only;
+
+		width-mm = <23>;
+		height-mm = <23>;
+
+		panel-timing {
+			hactive = <240>;
+			vactive = <240>;
+			hback-porch = <0>;
+			vback-porch = <0>;
+			clock-frequency = <0>;
+			hfront-porch = <0>;
+			hsync-len = <0>;
+			vfront-porch = <0>;
+			vsync-len = <0>;
+		};
+	};
+};


(WPEWebKit's cog on wayland/weston)


(sdl2-doom on 240x240 16bpp display, playable with 60fps!)

See https://github.com/notro/panel-mipi-dbi/ for more details.

To make this work on OpenWrt you need to enable the display feature for the filogic target, select kmod-drm-panel-mipi-dbi as well as what ever userland you want to use the display with (eg. cage as Wayland compositor and WPEWebKit's cog as HTML renderer)

2 Likes

I saw similar article somewhere... :slight_smile:
yes possible that for touch screen part I need to activate something in dts but :wink:
to be honest not sure if it is needed :wink: for example in for display st7789 I only mentioned 2 pins but I use more :slight_smile: I need to check it out how it works.

About programing it is a bit more complex for me. Im not a real programmer. That;s why I adopted adafruit blinka to use libraries from there to work with my display. If there is no library for SPI device there I think Im not able to enable devices in another way.
Im using python and some modules:
import board
import terminalio
import displayio
Even I think Blinka doesnt work on pure spidev...

Nice, I added SPI LoRa Module sx1262/lr1110 to run Meshtastic
LoRa based mesh

(on OpenWRT One miktroBus also)

and

mixed case from BPi-R4 and OpenWRT One to have sma mount points for GNSS, Wifi scanning, and LoRa

Oh also have a diy usb Meshtick if you have USB but no spare SPI

1 Like

Issue with mirrored text solved:

If your text is mirrored please use option polarity 0/1 in function FourWires to correctly display text!

display_bus = FourWire(spi, command=tft_dc, chip_select=tft_cs, polarity=1)

(https://docs.circuitpython.org/en/stable/shared-bindings/fourwire/index.html)

In openwrt_spi_v4.pdf I put info about new version of python/Adafruit:

Adafruit-Blinka version: 8.51.0/Adafruit-platformdetect version: 3.77.0/
Python 3.13

Old instruction is ok in 99% , one change is needed. Of course it is not elegant solution but it is working :slight_smile:

2 Likes