From a0e3dd1f8715605f5c0d8eb0f9a3920d4bd02a49 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Tue, 4 Jun 2024 17:27:08 -0500 Subject: [PATCH] drivers: display: st7789v: convert to MIPI DBI API Convert ST7789V display driver to use MIPI DBI API. This commit also updates in tree boards to use the new devicetree syntax needed to enable this display with the MIPI DBI API. Signed-off-by: Daniel DeGrasse --- .../m5stack_atoms3/m5stack_atoms3_procpu.dts | 70 +++++----- .../m5stickc_plus/m5stickc_plus_procpu.dts | 67 ++++++---- .../pinetime_devkit0/pinetime_devkit0.dts | 65 +++++---- .../st7789v_tl019fqv01.overlay | 64 +++++---- .../st7789v_waveshare_240x240.overlay | 65 +++++---- drivers/display/Kconfig.st7789v | 2 +- drivers/display/display_st7789v.c | 123 +++++++----------- drivers/display/display_st7789v.h | 2 - dts/bindings/display/sitronix,st7789v.yaml | 25 +--- 9 files changed, 240 insertions(+), 243 deletions(-) diff --git a/boards/m5stack/m5stack_atoms3/m5stack_atoms3_procpu.dts b/boards/m5stack/m5stack_atoms3/m5stack_atoms3_procpu.dts index ad433760fca..dd20fb00a8d 100644 --- a/boards/m5stack/m5stack_atoms3/m5stack_atoms3_procpu.dts +++ b/boards/m5stack/m5stack_atoms3/m5stack_atoms3_procpu.dts @@ -9,6 +9,7 @@ #include "m5stack_atoms3-pinctrl.dtsi" #include "grove_connectors.dtsi" #include +#include / { model = "M5Stack AtomS3 PROCPU"; @@ -49,6 +50,45 @@ regulator-boot-on; }; + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + spi-dev = <&spi2>; + dc-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>; /* G33 */ + reset-gpios = <&gpio1 2 GPIO_ACTIVE_LOW>; /* G34 */ + write-only; + #address-cells = <1>; + #size-cells = <0>; + + st7789v: st7789v@0 { + compatible = "sitronix,st7789v"; + reg = <0>; + mipi-max-frequency = <27000000>; + + width = <128>; + height = <128>; + x-offset = <2>; + y-offset = <1>; + + vcom = <0x28>; + gctrl = <0x35>; + vrhs = <0x10>; + vdvs = <0x20>; + mdac = <0x00>; + gamma = <0x01>; + colmod = <0x55>; + lcm = <0x0c>; + porch-param = [0c 0c 00 33 33]; + cmd2en-param = [5a 69 02 00]; + pwctrl1-param = [a4 a1]; + pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17]; + nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e]; + ram-param = [00 E0]; + rgb-param = [40 02 14]; + mipi-mode = ; + }; + + }; + }; &usb_serial { @@ -92,36 +132,6 @@ status = "okay"; pinctrl-0 = <&spim2_default>; pinctrl-names = "default"; - - st7789v: st7789v@0 { - compatible = "sitronix,st7789v"; - reg = <0>; - spi-max-frequency = <27000000>; - cmd-data-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>; /* G33 */ - reset-gpios = <&gpio1 2 GPIO_ACTIVE_LOW>; /* G34 */ - - width = <128>; - height = <128>; - x-offset = <2>; - y-offset = <1>; - - vcom = <0x28>; - gctrl = <0x35>; - vrhs = <0x10>; - vdvs = <0x20>; - mdac = <0x00>; - gamma = <0x01>; - colmod = <0x55>; - lcm = <0x0c>; - porch-param = [0c 0c 00 33 33]; - cmd2en-param = [5a 69 02 00]; - pwctrl1-param = [a4 a1]; - pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17]; - nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e]; - ram-param = [00 E0]; - rgb-param = [40 02 14]; - }; - }; &gpio0 { diff --git a/boards/m5stack/m5stickc_plus/m5stickc_plus_procpu.dts b/boards/m5stack/m5stickc_plus/m5stickc_plus_procpu.dts index 0c34c90e056..28779d87ecb 100644 --- a/boards/m5stack/m5stickc_plus/m5stickc_plus_procpu.dts +++ b/boards/m5stack/m5stickc_plus/m5stickc_plus_procpu.dts @@ -9,6 +9,7 @@ #include "m5stickc_plus-pinctrl.dtsi" #include #include +#include / { model = "M5StickC Plus PROCPU"; @@ -59,6 +60,44 @@ zephyr,code = ; }; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + spi-dev = <&spi3>; + dc-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + st7789v: st7789v@0 { + compatible = "sitronix,st7789v"; + reg = <0>; + mipi-max-frequency = <20000000>; + + width = <135>; + height = <240>; + x-offset = <53>; + y-offset = <40>; + + vcom = <0x28>; + gctrl = <0x35>; + vrhs = <0x10>; + vdvs = <0x20>; + mdac = <0x00>; + gamma = <0x01>; + colmod = <0x55>; + lcm = <0x2c>; + porch-param = [0c 0c 00 33 33]; + cmd2en-param = [5a 69 02 00]; + pwctrl1-param = [a4 a1]; + pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17]; + nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e]; + ram-param = [00 F0]; + rgb-param = [40 02 14]; + mipi-mode = ; + }; + }; }; &uart0 { @@ -153,34 +192,6 @@ status = "okay"; pinctrl-0 = <&spim3_default>; pinctrl-names = "default"; - st7789v: st7789v@0 { - compatible = "sitronix,st7789v"; - reg = <0>; - spi-max-frequency = <20000000>; - cmd-data-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>; - reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; - - width = <135>; - height = <240>; - x-offset = <53>; - y-offset = <40>; - - vcom = <0x28>; - gctrl = <0x35>; - vrhs = <0x10>; - vdvs = <0x20>; - mdac = <0x00>; - gamma = <0x01>; - colmod = <0x55>; - lcm = <0x2c>; - porch-param = [0c 0c 00 33 33]; - cmd2en-param = [5a 69 02 00]; - pwctrl1-param = [a4 a1]; - pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17]; - nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e]; - ram-param = [00 F0]; - rgb-param = [40 02 14]; - }; }; &timer0 { diff --git a/boards/pine64/pinetime_devkit0/pinetime_devkit0.dts b/boards/pine64/pinetime_devkit0/pinetime_devkit0.dts index 207c8934880..7bdf52d79e4 100644 --- a/boards/pine64/pinetime_devkit0/pinetime_devkit0.dts +++ b/boards/pine64/pinetime_devkit0/pinetime_devkit0.dts @@ -12,6 +12,7 @@ #include #include "pinetime_devkit0-pinctrl.dtsi" #include +#include / { model = "Pine64 PineTime DevKit0"; @@ -77,6 +78,42 @@ output-ohms = <1000000>; full-ohms = <(1000000 + 1000000)>; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + spi-dev = <&spi1>; + dc-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; /* DET */ + reset-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; /* RESX reset */ + write-only; + #address-cells = <1>; + #size-cells = <0>; + /* Sitronix ST7789V LCD */ + st7789v: st7789v@1 { + compatible = "sitronix,st7789v"; + reg = <1>; + mipi-max-frequency = <8000000>; /* 8MHz */ + width = <240>; + height = <240>; + x-offset = <0>; + y-offset = <0>; + vcom = <0x19>; + gctrl = <0x35>; + vrhs = <0x12>; + vdvs = <0x20>; + mdac = <0x00>; + gamma = <0x01>; + colmod = <0x05>; + lcm = <0x2c>; + porch-param = [0c 0c 00 33 33]; + cmd2en-param = [5a 69 02 01]; + pwctrl1-param = [a4 a1]; + pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23]; + nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23]; + ram-param = [00 F0]; + rgb-param = [CD 08 14]; + mipi-mode = ; + }; + }; }; &adc { @@ -178,34 +215,6 @@ }; }; }; - - /* Sitronix ST7789V LCD */ - st7789v: st7789v@1 { - compatible = "sitronix,st7789v"; - reg = <1>; - spi-max-frequency = <8000000>; /* 8MHz */ - cmd-data-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; /* DET */ - reset-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; /* RESX reset */ - width = <240>; - height = <240>; - x-offset = <0>; - y-offset = <0>; - vcom = <0x19>; - gctrl = <0x35>; - vrhs = <0x12>; - vdvs = <0x20>; - mdac = <0x00>; - gamma = <0x01>; - colmod = <0x05>; - lcm = <0x2c>; - porch-param = [0c 0c 00 33 33]; - cmd2en-param = [5a 69 02 01]; - pwctrl1-param = [a4 a1]; - pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23]; - nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23]; - ram-param = [00 F0]; - rgb-param = [CD 08 14]; - }; }; &flash0 { diff --git a/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay b/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay index c12ee45515b..46c863b5ac8 100644 --- a/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay +++ b/boards/shields/st7789v_generic/st7789v_tl019fqv01.overlay @@ -3,41 +3,51 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include / { chosen { zephyr,display = &st7789v_st7789v_tl019fqv01; }; + + mipi_dbi_st7789v_tl019fqv01 { + 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 */ + write-only; + #address-cells = <1>; + #size-cells = <0>; + + st7789v_st7789v_tl019fqv01: st7789v@0 { + compatible = "sitronix,st7789v"; + mipi-max-frequency = <20000000>; + reg = <0>; + width = <320>; + height = <170>; + x-offset = <0>; + y-offset = <35>; + vcom = <0x2b>; + gctrl = <0x35>; + vrhs = <0x0f>; + vdvs = <0x20>; + mdac = <0x60>; + gamma = <0x01>; + colmod = <0x55>; + lcm = <0x2c>; + porch-param = [0c 0c 00 33 33]; + cmd2en-param = [5a 69 02 01]; + pwctrl1-param = [52 a1]; + pvgam-param = [D0 00 02 07 0B 1A 31 54 40 29 12 12 12 17]; + nvgam-param = [D0 00 02 07 05 15 2D 44 44 1C 18 16 1C 1D]; + ram-param = [00 F8]; + rgb-param = [CD 08 14]; + mipi-mode = ; + }; + }; }; &arduino_spi { status = "okay"; cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ - - st7789v_st7789v_tl019fqv01: st7789v@0 { - compatible = "sitronix,st7789v"; - 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 = <320>; - height = <170>; - x-offset = <0>; - y-offset = <35>; - vcom = <0x2b>; - gctrl = <0x35>; - vrhs = <0x0f>; - vdvs = <0x20>; - mdac = <0x60>; - gamma = <0x01>; - colmod = <0x55>; - lcm = <0x2c>; - porch-param = [0c 0c 00 33 33]; - cmd2en-param = [5a 69 02 01]; - pwctrl1-param = [52 a1]; - pvgam-param = [D0 00 02 07 0B 1A 31 54 40 29 12 12 12 17]; - nvgam-param = [D0 00 02 07 05 15 2D 44 44 1C 18 16 1C 1D]; - ram-param = [00 F8]; - rgb-param = [CD 08 14]; - }; }; diff --git a/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay b/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay index 3c7205ce287..0a92937a982 100644 --- a/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay +++ b/boards/shields/st7789v_generic/st7789v_waveshare_240x240.overlay @@ -5,40 +5,51 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + / { chosen { zephyr,display = &st7789v_st7789v_waveshare_240x240; }; + + mipi_dbi_st7789v_waveshare_240x240 { + 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 */ + write-only; + #address-cells = <1>; + #size-cells = <0>; + + st7789v_st7789v_waveshare_240x240: st7789v@0 { + compatible = "sitronix,st7789v"; + mipi-max-frequency = <20000000>; + reg = <0>; + width = <240>; + height = <240>; + x-offset = <0>; + y-offset = <0>; + vcom = <0x19>; + gctrl = <0x35>; + vrhs = <0x12>; + vdvs = <0x20>; + mdac = <0x00>; + gamma = <0x01>; + colmod = <0x05>; + lcm = <0x2c>; + porch-param = [0c 0c 00 33 33]; + cmd2en-param = [5a 69 02 01]; + pwctrl1-param = [a4 a1]; + pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23]; + nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23]; + ram-param = [00 F0]; + rgb-param = [CD 08 14]; + mipi-mode = ; + }; + }; }; &arduino_spi { status = "okay"; cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ - - st7789v_st7789v_waveshare_240x240: st7789v@0 { - compatible = "sitronix,st7789v"; - 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 = <240>; - height = <240>; - x-offset = <0>; - y-offset = <0>; - vcom = <0x19>; - gctrl = <0x35>; - vrhs = <0x12>; - vdvs = <0x20>; - mdac = <0x00>; - gamma = <0x01>; - colmod = <0x05>; - lcm = <0x2c>; - porch-param = [0c 0c 00 33 33]; - cmd2en-param = [5a 69 02 01]; - pwctrl1-param = [a4 a1]; - pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23]; - nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23]; - ram-param = [00 F0]; - rgb-param = [CD 08 14]; - }; }; diff --git a/drivers/display/Kconfig.st7789v b/drivers/display/Kconfig.st7789v index 5a452732779..61d9c5497fd 100644 --- a/drivers/display/Kconfig.st7789v +++ b/drivers/display/Kconfig.st7789v @@ -7,7 +7,7 @@ menuconfig ST7789V bool "ST7789V display driver" default y depends on DT_HAS_SITRONIX_ST7789V_ENABLED - select SPI + select MIPI_DBI help Enable driver for ST7789V display driver. diff --git a/drivers/display/display_st7789v.c b/drivers/display/display_st7789v.c index 72ae4eb0436..69e4e2cdb02 100644 --- a/drivers/display/display_st7789v.c +++ b/drivers/display/display_st7789v.c @@ -14,8 +14,7 @@ #include "display_st7789v.h" #include -#include -#include +#include #include #include #include @@ -25,9 +24,8 @@ LOG_MODULE_REGISTER(display_st7789v); struct st7789v_config { - struct spi_dt_spec bus; - struct gpio_dt_spec cmd_data_gpio; - struct gpio_dt_spec reset_gpio; + const struct device *mipi_dbi; + const struct mipi_dbi_config dbi_config; uint8_t vcom; uint8_t gctrl; bool vdv_vrh_enable; @@ -73,38 +71,9 @@ static void st7789v_transmit(const struct device *dev, uint8_t cmd, uint8_t *tx_data, size_t tx_count) { const struct st7789v_config *config = dev->config; - uint16_t data = cmd; - struct spi_buf tx_buf = { .buf = &cmd, .len = 1 }; - struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 }; - - if (config->cmd_data_gpio.port != NULL) { - if (cmd != ST7789V_CMD_NONE) { - gpio_pin_set_dt(&config->cmd_data_gpio, 1); - spi_write_dt(&config->bus, &tx_bufs); - } - - if (tx_data != NULL) { - tx_buf.buf = tx_data; - tx_buf.len = tx_count; - gpio_pin_set_dt(&config->cmd_data_gpio, 0); - spi_write_dt(&config->bus, &tx_bufs); - } - } else { - tx_buf.buf = &data; - tx_buf.len = 2; - - if (cmd != ST7789V_CMD_NONE) { - spi_write_dt(&config->bus, &tx_bufs); - } - - if (tx_data != NULL) { - for (size_t index = 0; index < tx_count; ++index) { - data = 0x0100 | tx_data[index]; - spi_write_dt(&config->bus, &tx_bufs); - } - } - } + mipi_dbi_command_write(config->mipi_dbi, &config->dbi_config, cmd, + tx_data, tx_count); } static void st7789v_exit_sleep(const struct device *dev) @@ -115,18 +84,19 @@ static void st7789v_exit_sleep(const struct device *dev) static void st7789v_reset_display(const struct device *dev) { + const struct st7789v_config *config = dev->config; + int ret; + LOG_DBG("Resetting display"); - const struct st7789v_config *config = dev->config; - if (config->reset_gpio.port != NULL) { - k_sleep(K_MSEC(1)); - gpio_pin_set_dt(&config->reset_gpio, 1); - k_sleep(K_MSEC(6)); - gpio_pin_set_dt(&config->reset_gpio, 0); - k_sleep(K_MSEC(20)); - } else { + k_sleep(K_MSEC(1)); + ret = mipi_dbi_reset(config->mipi_dbi, 6); + if (ret == -ENOTSUP) { + /* Send software reset command */ st7789v_transmit(dev, ST7789V_CMD_SW_RESET, NULL, 0); k_sleep(K_MSEC(5)); + } else { + k_sleep(K_MSEC(20)); } } @@ -166,9 +136,12 @@ static int st7789v_write(const struct device *dev, const struct display_buffer_descriptor *desc, const void *buf) { + const struct st7789v_config *config = dev->config; + struct display_buffer_descriptor mipi_desc; const uint8_t *write_data_start = (uint8_t *) buf; uint16_t nbr_of_writes; uint16_t write_h; + enum display_pixel_format pixfmt; __ASSERT(desc->width <= desc->pitch, "Pitch is smaller then width"); __ASSERT((desc->pitch * ST7789V_PIXEL_SIZE * desc->height) <= desc->buf_size, @@ -181,15 +154,31 @@ static int st7789v_write(const struct device *dev, if (desc->pitch > desc->width) { write_h = 1U; nbr_of_writes = desc->height; + mipi_desc.height = 1; + mipi_desc.buf_size = desc->pitch * ST7789V_PIXEL_SIZE; } else { write_h = desc->height; nbr_of_writes = 1U; + mipi_desc.height = desc->height; + mipi_desc.buf_size = desc->width * write_h * ST7789V_PIXEL_SIZE; + } + if (IS_ENABLED(CONFIG_ST7789V_RGB565)) { + pixfmt = PIXEL_FORMAT_RGB_565; + } else { + pixfmt = PIXEL_FORMAT_RGB_888; } + mipi_desc.width = desc->width; + /* Per MIPI API, pitch must always match width */ + mipi_desc.pitch = desc->width; + + /* Send RAMWR command */ + st7789v_transmit(dev, ST7789V_CMD_RAMWR, NULL, 0); + for (uint16_t write_cnt = 0U; write_cnt < nbr_of_writes; ++write_cnt) { - st7789v_transmit(dev, write_cnt == 0U ? ST7789V_CMD_RAMWR : ST7789V_CMD_NONE, - (void *) write_data_start, - desc->width * ST7789V_PIXEL_SIZE * write_h); + mipi_dbi_write_display(config->mipi_dbi, &config->dbi_config, + write_data_start, &mipi_desc, pixfmt); + write_data_start += (desc->pitch * ST7789V_PIXEL_SIZE); } @@ -326,35 +315,11 @@ static int st7789v_init(const struct device *dev) { const struct st7789v_config *config = dev->config; - if (!spi_is_ready_dt(&config->bus)) { - LOG_ERR("SPI device not ready"); + if (!device_is_ready(config->mipi_dbi)) { + LOG_ERR("MIPI DBI device not ready"); return -ENODEV; } - if (config->reset_gpio.port != NULL) { - if (!gpio_is_ready_dt(&config->reset_gpio)) { - LOG_ERR("Reset GPIO device not ready"); - return -ENODEV; - } - - if (gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE)) { - LOG_ERR("Couldn't configure reset pin"); - return -EIO; - } - } - - if (config->cmd_data_gpio.port != NULL) { - if (!gpio_is_ready_dt(&config->cmd_data_gpio)) { - LOG_ERR("CMD/DATA GPIO device not ready"); - return -ENODEV; - } - - if (gpio_pin_configure_dt(&config->cmd_data_gpio, GPIO_OUTPUT)) { - LOG_ERR("Couldn't configure CMD/DATA pin"); - return -EIO; - } - } - st7789v_reset_display(dev); st7789v_blanking_on(dev); @@ -398,14 +363,14 @@ static const struct display_driver_api st7789v_api = { }; #define ST7789V_WORD_SIZE(inst) \ - COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, cmd_data_gpios), (8), (9)) - + ((DT_INST_PROP(inst, mipi_mode) == MIPI_DBI_MODE_SPI_4WIRE) ? \ + SPI_WORD_SET(8) : SPI_WORD_SET(9)) #define ST7789V_INIT(inst) \ static const struct st7789v_config st7789v_config_ ## inst = { \ - .bus = SPI_DT_SPEC_INST_GET(inst, SPI_OP_MODE_MASTER | \ - SPI_WORD_SET(ST7789V_WORD_SIZE(inst)), 0), \ - .cmd_data_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, cmd_data_gpios, {}), \ - .reset_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {}), \ + .mipi_dbi = DEVICE_DT_GET(DT_INST_PARENT(inst)), \ + .dbi_config = MIPI_DBI_CONFIG_DT_INST(inst, \ + ST7789V_WORD_SIZE(inst) | \ + SPI_OP_MODE_MASTER, 0), \ .vcom = DT_INST_PROP(inst, vcom), \ .gctrl = DT_INST_PROP(inst, gctrl), \ .vdv_vrh_enable = (DT_INST_NODE_HAS_PROP(inst, vrhs) \ diff --git a/drivers/display/display_st7789v.h b/drivers/display/display_st7789v.h index aa16e8d5633..191135b02fe 100644 --- a/drivers/display/display_st7789v.h +++ b/drivers/display/display_st7789v.h @@ -68,6 +68,4 @@ #define ST7789V_CMD_PVGAMCTRL 0xe0 #define ST7789V_CMD_NVGAMCTRL 0xe1 -#define ST7789V_CMD_NONE 0xff - #endif diff --git a/dts/bindings/display/sitronix,st7789v.yaml b/dts/bindings/display/sitronix,st7789v.yaml index ec72e18d7f9..9b503eb86ba 100644 --- a/dts/bindings/display/sitronix,st7789v.yaml +++ b/dts/bindings/display/sitronix,st7789v.yaml @@ -6,29 +6,9 @@ description: ST7789V 320x240 display controller compatible: "sitronix,st7789v" -include: [spi-device.yaml, display-controller.yaml] +include: [mipi-dbi-spi-device.yaml, display-controller.yaml] properties: - reset-gpios: - type: phandle-array - description: | - RESET pin. - - The RESET pin of ST7789V is active low. - If connected directly the MCU pin should be configured - as active low. - - cmd-data-gpios: - type: phandle-array - description: | - D/CX pin. If configured, 4-lines serial interface is used, otherwise - 3-lines serial interface is used and a D/CX bit (9-bit) is added to - the protocol. - - The D/CX pin of ST7789V is active low (transmission command byte). - If connected directly the MCU pin should be configured - as active low. - x-offset: type: int required: true @@ -115,3 +95,6 @@ properties: type: uint8-array required: true description: RGB Interface Control Parameter + + mipi-mode: + required: true