drivers: display: st7735r: convert to MIPI DBI API

Convert the ST7735R display to use the MIPI DBI API. Boards and overlays
using this display are also updated.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2024-03-21 14:26:28 -05:00 committed by Anas Nashif
commit 13ae32e1c2
5 changed files with 124 additions and 158 deletions

View file

@ -4,38 +4,48 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
/ {
chosen {
zephyr,display = &st7735r_st7735r_ada_160x128;
};
mipi_dbi_st7735r_ada_160x128 {
compatible = "zephyr,mipi-dbi-spi";
spi-dev = <&arduino_spi>;
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_HIGH>; /* D9 */
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
#address-cells = <1>;
#size-cells = <0>;
st7735r_st7735r_ada_160x128: st7735r@0 {
compatible = "sitronix,st7735r";
mipi-max-frequency = <20000000>;
mipi-mode = <MIPI_DBI_MODE_SPI_4WIRE>;
reg = <0>;
width = <160>;
height = <128>;
x-offset = <0>;
y-offset = <0>;
madctl = <0x60>;
colmod = <0x55>;
vmctr1 = <0x0e>;
pwctr1 = [a2 02 84];
pwctr2 = [c5];
pwctr3 = [0a 00];
pwctr4 = [8a 2a];
pwctr5 = [8a ee];
frmctr1 = [01 2c 2d];
frmctr2 = [01 2c 2d];
frmctr3 = [01 2c 2d 01 2c 2d];
gamctrp1 = [02 1c 07 12 37 32 29 2d 29 25 2b 39 00 01 03 10];
gamctrn1 = [03 1d 07 06 2e 2c 29 2d 2e 2e 37 3f 00 00 02 10];
};
};
};
&arduino_spi {
status = "okay";
cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */
st7735r_st7735r_ada_160x128: st7735r@0 {
compatible = "sitronix,st7735r";
spi-max-frequency = <20000000>;
reg = <0>;
cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
width = <160>;
height = <128>;
x-offset = <0>;
y-offset = <0>;
madctl = <0x60>;
colmod = <0x55>;
vmctr1 = <0x0e>;
pwctr1 = [a2 02 84];
pwctr2 = [c5];
pwctr3 = [0a 00];
pwctr4 = [8a 2a];
pwctr5 = [8a ee];
frmctr1 = [01 2c 2d];
frmctr2 = [01 2c 2d];
frmctr3 = [01 2c 2d 01 2c 2d];
gamctrp1 = [02 1c 07 12 37 32 29 2d 29 25 2b 39 00 01 03 10];
gamctrn1 = [03 1d 07 06 2e 2c 29 2d 2e 2e 37 3f 00 00 02 10];
};
};

View file

@ -5,6 +5,7 @@
*/
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
/ {
chosen {
@ -65,6 +66,50 @@
sw0 = &button_boot0;
watchdog0 = &fwdgt;
};
mipi_dbi {
compatible = "zephyr,mipi-dbi-spi";
reset-gpios = <&gpiob 1 GPIO_ACTIVE_LOW>;
dc-gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
spi-dev = <&spi0>;
write-only;
#address-cells = <1>;
#size-cells = <0>;
/* longan nano has LCD with st7735s controller.
* It can use with st7735r driver.
*/
lcd0: lcd@0 {
compatible = "sitronix,st7735r";
reg = <0>;
status = "okay";
width = <160>;
height = <80>;
inversion-on;
rgb-is-inverted;
x-offset = <1>;
y-offset = <26>;
pwctr1 = [62 02 04];
pwctr2 = [C0];
pwctr3 = [0D 00];
pwctr4 = [8D 6A];
pwctr5 = [8D EE];
invctr = <3>;
frmctr1 = [05 3A 3A];
frmctr2 = [05 3A 3A];
frmctr3 = [05 3A 3A 05 3A 3A];
vmctr1 = <14>;
gamctrp1 = [10 0E 02 03 0E 07 02 07 0A 12 27 37 00 0D 0E 10];
gamctrn1 = [10 0E 03 03 0F 06 02 08 0A 13 26 36 00 0D 0E 10];
colmod = <5>;
madctl = <120>;
caset = [00 01 00 a0];
raset = [00 1a 00 69];
mipi-mode = <MIPI_DBI_MODE_SPI_4WIRE>;
mipi-max-frequency = <4000000>;
};
};
};
&gpioa {
@ -109,41 +154,6 @@
pinctrl-names = "default";
cs-gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
/* longan nano has LCD with st7735s controller.
* It can use with st7735r driver.
*/
lcd0: lcd@0 {
compatible = "sitronix,st7735r";
reg = <0>;
status = "okay";
reset-gpios = <&gpiob 1 GPIO_ACTIVE_LOW>;
cmd-data-gpios = <&gpiob 0 GPIO_ACTIVE_LOW>;
width = <160>;
height = <80>;
inversion-on;
rgb-is-inverted;
x-offset = <1>;
y-offset = <26>;
pwctr1 = [62 02 04];
pwctr2 = [C0];
pwctr3 = [0D 00];
pwctr4 = [8D 6A];
pwctr5 = [8D EE];
invctr = <3>;
frmctr1 = [05 3A 3A];
frmctr2 = [05 3A 3A];
frmctr3 = [05 3A 3A 05 3A 3A];
vmctr1 = <14>;
gamctrp1 = [10 0E 02 03 0E 07 02 07 0A 12 27 37 00 0D 0E 10];
gamctrn1 = [10 0E 03 03 0F 06 02 08 0A 13 26 36 00 0D 0E 10];
colmod = <5>;
madctl = <120>;
caset = [00 01 00 a0];
raset = [00 1a 00 69];
spi-max-frequency = <4000000>;
};
};
&spi1 {