Skip to content

Instantly share code, notes, and snippets.

@Danct12
Created May 11, 2023 10:43
Show Gist options
  • Save Danct12/2ffe2291ec1f303a570346e43c144eb7 to your computer and use it in GitHub Desktop.
Save Danct12/2ffe2291ec1f303a570346e43c144eb7 to your computer and use it in GitHub Desktop.
SPI bitbanging and ILI9384 LCD on Sipeed M1s (and Pine64 0x64)
// SPDX-License-Identifier: (GPL-2.0+ or MIT)
/*
* Copyright (c) 2023 Danct12 <danct12/on/openbouffalo chatroom>
*
* This device tree overlay sets up spi-gpio (SPI bitbanging) and a ILI9384 LCD screen.
*/
/dts-v1/;
/plugin/;
/ {
fragment@0 {
target-path = "/";
__overlay__ {
spi-bb {
compatible = "spi-gpio";
#address-cells = <0x1>;
#size-cells = <0x0>;
/*
These GPIOs will be our SPI bus, if you have multiple chipselects
you can set them up too by adding another value(?) to cs-gpios after a comma.
(be sure to change num-chipselects too if that's the case)
*/
miso-gpios = <&pinctrl 29 0x0>; /* GP29 */
mosi-gpios = <&pinctrl 30 0x0>; /* GP30 */
sck-gpios = <&pinctrl 31 0x0>; /* GP31 */
cs-gpios = <&pinctrl 21 0x1>; /* GP21 */
num-chipselects = <0x1>;
status = "okay";
/*
This entry is for setting up a ILI9341 display using FBTFT driver.
If you use a different screen, you can pick another display driver and look at
it's device tree bindings.
*/
display@0 {
compatible = "ilitek,ili9341";
reg = <0x0>;
spi-max-frequency = <32000000>;
/* Data Select (DC/A0) and RESET pin */
dc-gpios = <&pinctrl 19 0x0>; /* GP19 */
reset-gpios = <&pinctrl 20 0x1>; /* GP20 */
/* Most ILI9341 will be 320x240 so you shouldn't need to change this. */
width = <320>;
height = <240>;
/* You can rotate the display if you want too, the values are (90, 180, 270) */
rotate = <0>;
buswidth = <8>;
/*
If your display is MI0283QT-9A, then please remove the init property below as
ILI9341 driver for FBTFT had it's init sequence hardcoded to this display.
However, if you have a different display such as MSP2807, Adafruit displays or
many others then you can use the init sequence below.
If your display is mirrored or being weird, then you'll have
to look for the init sequence for your display.
*/
init = <0x1000001
0x2000096
0x10000EF 0x03 0x80 0x02
0x10000CF 0x00 0xC1 0x30
0x10000ED 0x64 0x03 0x12 0x81
0x10000E8 0x85 0x00 0x78
0x10000CB 0x39 0x2C 0x00 0x34 0x02
0x10000F7 0x20
0x10000EA 0x00 0x00
0x10000C0 0x23
0x10000C1 0x10
0x10000C5 0x3E 0x28
0x10000C7 0x86
0x1000036 0x48
0x1000037 0x00
0x100003A 0x55
0x10000B1 0x00 0x18
0x10000B6 0x08 0x82 0x27
0x10000F2 0x00
0x1000026 0x01
0x10000E0 0x0F 0x31 0x2B 0x0C 0x0E 0x08 0x4E 0xF1 0x37 0x07 0x10 0x03 0x0E 0x09 0x00
0x10000E1 0x00 0x0E 0x14 0x03 0x11 0x07 0x31 0xC1 0x48 0x08 0x0F 0x0C 0x31 0x36 0x0F
0x1000011 0x80
0x2000096
0x1000029 0x80
0x2000096>;
status = "okay";
};
};
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment