diff --git a/boards/arm/bl5340_dvk/bl5340_dvk_cpuapp_common.dtsi b/boards/arm/bl5340_dvk/bl5340_dvk_cpuapp_common.dtsi index 04039294b76..5a748b1bf9d 100644 --- a/boards/arm/bl5340_dvk/bl5340_dvk_cpuapp_common.dtsi +++ b/boards/arm/bl5340_dvk/bl5340_dvk_cpuapp_common.dtsi @@ -107,6 +107,25 @@ bbram0 = &extrtc0; spi-flash0 = &mx25r64; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + reset-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; + dc-gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; + spi-dev = <&spi2>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9340: ili9340@0 { + compatible = "ilitek,ili9340"; + reg = <0>; + mipi-max-frequency = <32000000>; + rotation = <270>; + width = <320>; + height = <240>; + }; + }; }; &adc { @@ -224,16 +243,6 @@ pinctrl-0 = <&spi4_default>; pinctrl-1 = <&spi4_sleep>; pinctrl-names = "default", "sleep"; - ili9340: ili9340@0 { - compatible = "ilitek,ili9340"; - reg = <0>; - spi-max-frequency = <32000000>; - reset-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; - cmd-data-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; - rotation = <270>; - width = <320>; - height = <240>; - }; }; &uart0 { diff --git a/boards/arm/stm32f429i_disc1/stm32f429i_disc1.dts b/boards/arm/stm32f429i_disc1/stm32f429i_disc1.dts index 153f0cab3a9..51b7ac84d49 100644 --- a/boards/arm/stm32f429i_disc1/stm32f429i_disc1.dts +++ b/boards/arm/stm32f429i_disc1/stm32f429i_disc1.dts @@ -62,6 +62,43 @@ invert-x; invert-y; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&gpiod 13 GPIO_ACTIVE_HIGH>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + spi-dev = <&spi5>; + + ili9341: ili9341@0 { + compatible = "ilitek,ili9341"; + mipi-max-frequency = <5625000>; + reg = <0>; + width = <240>; + height = <320>; + rotation = <180>; + pixel-format = ; + pwctrla = [39 2c 00 34 02]; + pwctrlb = [00 c1 30]; + timctrla = [85 00 78]; + timctrlb = [00 00]; + pwseqctrl = [64 03 12 81]; + pumpratioctrl = [20]; + disctrl = [08 82 27 04]; + vmctrl1 = [45 15]; + vmctrl2 = [90]; + enable3g = [00]; + ifctl = [01 00 06]; + ifmode = [c2]; + gamset = [01]; + frmctr1 = [00 1b]; + pwctrl1 = [10]; + pwctrl2 = [10]; + pgamctrl = [0F 29 24 0c 0e 09 4e 78 3c 09 13 05 17 11 00]; + ngamctrl = [00 16 1b 04 11 07 31 33 42 05 0c 0a 28 2f 0f]; + }; + }; }; &clk_lsi { @@ -147,34 +184,6 @@ pinctrl-names = "default"; status = "okay"; cs-gpios = <&gpioc 2 GPIO_ACTIVE_LOW>; - ili9341: ili9341@0 { - compatible = "ilitek,ili9341"; - spi-max-frequency = <5625000>; - reg = <0>; - cmd-data-gpios = <&gpiod 13 GPIO_ACTIVE_LOW>; - width = <240>; - height = <320>; - rotation = <180>; - pixel-format = ; - pwctrla = [39 2c 00 34 02]; - pwctrlb = [00 c1 30]; - timctrla = [85 00 78]; - timctrlb = [00 00]; - pwseqctrl = [64 03 12 81]; - pumpratioctrl = [20]; - disctrl = [08 82 27 04]; - vmctrl1 = [45 15]; - vmctrl2 = [90]; - enable3g = [00]; - ifctl = [01 00 06]; - ifmode = [c2]; - gamset = [01]; - frmctr1 = [00 1b]; - pwctrl1 = [10]; - pwctrl2 = [10]; - pgamctrl = [0F 29 24 0c 0e 09 4e 78 3c 09 13 05 17 11 00]; - ngamctrl = [00 16 1b 04 11 07 31 33 42 05 0c 0a 28 2f 0f]; - }; }; &fmc { diff --git a/boards/arm/wio_terminal/wio_terminal.dts b/boards/arm/wio_terminal/wio_terminal.dts index 99e07373526..a88eeee9e94 100644 --- a/boards/arm/wio_terminal/wio_terminal.dts +++ b/boards/arm/wio_terminal/wio_terminal.dts @@ -123,6 +123,27 @@ regulator-name = "usb_power_5v_en"; enable-gpios = <&porta 27 GPIO_ACTIVE_LOW>; }; + + /* LCD */ + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&portc 6 GPIO_ACTIVE_HIGH>; + reset-gpios = <&portc 7 GPIO_ACTIVE_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + spi-dev = <&sercom7>; + write-only; + + ili9341: ili9341@0 { + compatible = "ilitek,ili9341"; + mipi-max-frequency = <24000000>; + reg = <0>; + pixel-format = ; + rotation = <270>; + width = <320>; + height = <240>; + }; + }; }; &cpu0 { @@ -271,19 +292,6 @@ pinctrl-0 = <&sercom7_spi_default>; pinctrl-names = "default"; cs-gpios = <&portb 21 GPIO_ACTIVE_LOW>; - - /* LCD */ - ili9341: ili9341@0 { - compatible = "ilitek,ili9341"; - spi-max-frequency = <24000000>; - reg = <0>; - cmd-data-gpios = <&portc 6 GPIO_ACTIVE_LOW>; - reset-gpios = <&portc 7 GPIO_ACTIVE_LOW>; - pixel-format = ; - rotation = <270>; - width = <320>; - height = <240>; - }; }; /* USB */ diff --git a/boards/shields/adafruit_2_8_tft_touch_v2/dts/adafruit_2_8_tft_touch_v2.dtsi b/boards/shields/adafruit_2_8_tft_touch_v2/dts/adafruit_2_8_tft_touch_v2.dtsi index 543d0b86df1..9413a7834d9 100644 --- a/boards/shields/adafruit_2_8_tft_touch_v2/dts/adafruit_2_8_tft_touch_v2.dtsi +++ b/boards/shields/adafruit_2_8_tft_touch_v2/dts/adafruit_2_8_tft_touch_v2.dtsi @@ -8,7 +8,7 @@ / { chosen { - zephyr,display = &ili9340; + zephyr,display = &adafruit_2_8_tft_touch_v2_ili9340; }; lvgl_pointer { @@ -18,6 +18,31 @@ invert-x; invert-y; }; + + adafruit_2_8_tft_touch_v2_mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + spi-dev = <&arduino_spi>; + dc-gpios = <&arduino_header 15 GPIO_ACTIVE_HIGH>; /* D9 */ + write-only; + #address-cells = <1>; + #size-cells = <0>; + + adafruit_2_8_tft_touch_v2_ili9340: ili9340@0 { + compatible = "ilitek,ili9340"; + mipi-max-frequency = <15151515>; + reg = <0>; + width = <320>; + height = <240>; + pixel-format = ; + rotation = <90>; + frmctr1 = [00 18]; + pwctrl1 = [23 00]; + vmctrl1 = [3e 28]; + vmctrl2 = [86]; + pgamctrl = [0f 31 2b 0c 0e 08 4e f1 37 07 10 03 0e 09 00]; + ngamctrl = [00 0e 14 03 11 07 31 c1 48 08 0f 0c 31 36 0f]; + }; + }; }; &arduino_spi { @@ -25,24 +50,6 @@ cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>, /* D10 */ <&arduino_header 10 GPIO_ACTIVE_LOW>; /* D04 */ - - ili9340: ili9340@0 { - compatible = "ilitek,ili9340"; - spi-max-frequency = <15151515>; - reg = <0>; - cmd-data-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ - width = <320>; - height = <240>; - pixel-format = ; - rotation = <90>; - frmctr1 = [00 18]; - pwctrl1 = [23 00]; - vmctrl1 = [3e 28]; - vmctrl2 = [86]; - pgamctrl = [0f 31 2b 0c 0e 08 4e f1 37 07 10 03 0e 09 00]; - ngamctrl = [00 0e 14 03 11 07 31 c1 48 08 0f 0c 31 36 0f]; - }; - adafruit_2_8_tft_touch_v2_sdhc: sdhc@1 { compatible = "zephyr,sdhc-spi-slot"; reg = <1>; diff --git a/boards/shields/buydisplay_2_8_tft_touch_arduino/buydisplay_2_8_tft_touch_arduino.overlay b/boards/shields/buydisplay_2_8_tft_touch_arduino/buydisplay_2_8_tft_touch_arduino.overlay index 3cc257e9366..162b1450111 100644 --- a/boards/shields/buydisplay_2_8_tft_touch_arduino/buydisplay_2_8_tft_touch_arduino.overlay +++ b/boards/shields/buydisplay_2_8_tft_touch_arduino/buydisplay_2_8_tft_touch_arduino.overlay @@ -18,29 +18,37 @@ invert-x; invert-y; }; + + buydisplay_2_8_tft_touch_arduino_mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */ + reset-gpios = <&arduino_header 16 GPIO_ACTIVE_HIGH>; /* D10 */ + spi-dev = <&arduino_spi>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9340_buydisplay_2_8_tft_touch_arduino: ili9340@0 { + compatible = "ilitek,ili9340"; + mipi-max-frequency = <25000000>; + reg = <0>; + width = <240>; + height = <320>; + pixel-format = ; + rotation = <0>; + frmctr1 = [00 18]; + pwctrl1 = [23 00]; + vmctrl1 = [3e 28]; + vmctrl2 = [86]; + pgamctrl = [0f 31 2b 0c 0e 08 4e f1 37 07 10 03 0e 09 00]; + ngamctrl = [00 0e 14 03 11 07 31 c1 48 08 0f 0c 31 36 0f]; + }; + }; }; &arduino_spi { status = "okay"; cs-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ - - ili9340_buydisplay_2_8_tft_touch_arduino: ili9340@0 { - compatible = "ilitek,ili9340"; - spi-max-frequency = <25000000>; - reg = <0>; - cmd-data-gpios = <&arduino_header 13 GPIO_ACTIVE_LOW>; /* D7 */ - reset-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ - width = <240>; - height = <320>; - pixel-format = ; - rotation = <0>; - frmctr1 = [00 18]; - pwctrl1 = [23 00]; - vmctrl1 = [3e 28]; - vmctrl2 = [86]; - pgamctrl = [0f 31 2b 0c 0e 08 4e f1 37 07 10 03 0e 09 00]; - ngamctrl = [00 0e 14 03 11 07 31 c1 48 08 0f 0c 31 36 0f]; - }; }; &arduino_i2c { diff --git a/boards/shields/buydisplay_3_5_tft_touch_arduino/buydisplay_3_5_tft_touch_arduino.overlay b/boards/shields/buydisplay_3_5_tft_touch_arduino/buydisplay_3_5_tft_touch_arduino.overlay index 5764c415460..0ba02cb5648 100644 --- a/boards/shields/buydisplay_3_5_tft_touch_arduino/buydisplay_3_5_tft_touch_arduino.overlay +++ b/boards/shields/buydisplay_3_5_tft_touch_arduino/buydisplay_3_5_tft_touch_arduino.overlay @@ -18,28 +18,36 @@ invert-x; invert-y; }; + + buydisplay_3_5_tft_touch_arduino_mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */ + reset-gpios = <&arduino_header 16 GPIO_ACTIVE_HIGH>; /* D10 */ + spi-dev = <&arduino_spi>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9488_buydisplay_3_5_tft_touch_arduino: ili9488@0 { + compatible = "ilitek,ili9488"; + mipi-max-frequency = <25000000>; + reg = <0>; + pixel-format = ; + width = <320>; + height = <480>; + rotation = <0>; + frmctr1 = [a0 11]; + pwctrl1 = [17 15]; + pwctrl2 = [41]; + pgamctrl = [00 03 09 08 16 0a 3f 78 4c 09 0a 08 16 1a 0f]; + ngamctrl = [00 16 19 03 0f 05 32 45 46 04 0e 0d 35 37 0f]; + }; + }; }; &arduino_spi { status = "okay"; cs-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */ - - ili9488_buydisplay_3_5_tft_touch_arduino: ili9488@0 { - compatible = "ilitek,ili9488"; - spi-max-frequency = <25000000>; - reg = <0>; - cmd-data-gpios = <&arduino_header 13 GPIO_ACTIVE_LOW>; /* D7 */ - reset-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ - pixel-format = ; - width = <320>; - height = <480>; - rotation = <0>; - frmctr1 = [a0 11]; - pwctrl1 = [17 15]; - pwctrl2 = [41]; - pgamctrl = [00 03 09 08 16 0a 3f 78 4c 09 0a 08 16 1a 0f]; - ngamctrl = [00 16 19 03 0f 05 32 45 46 04 0e 0d 35 37 0f]; - }; }; &arduino_i2c { diff --git a/boards/xtensa/esp_wrover_kit/esp_wrover_kit.dts b/boards/xtensa/esp_wrover_kit/esp_wrover_kit.dts index f5d366e0313..f7385037609 100644 --- a/boards/xtensa/esp_wrover_kit/esp_wrover_kit.dts +++ b/boards/xtensa/esp_wrover_kit/esp_wrover_kit.dts @@ -70,6 +70,26 @@ pwms = <&ledc0 2 PWM_HZ(100) PWM_POLARITY_NORMAL>; }; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + spi-dev = <&spi3>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9341: ili9341@0 { + compatible = "ilitek,ili9341"; + mipi-max-frequency = <25000000>; + reg = <0>; + pixel-format = <0>; + rotation = <0>; + width = <240>; + height = <320>; + }; + }; }; &cpu0 { @@ -125,18 +145,6 @@ status = "okay"; pinctrl-0 = <&spim3_default>; pinctrl-names = "default"; - - ili9341: ili9341@0 { - compatible = "ilitek,ili9341"; - spi-max-frequency = <25000000>; - reg = <0>; - cmd-data-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>; - reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; - pixel-format = <0>; - rotation = <0>; - width = <240>; - height = <320>; - }; }; &ledc0 { diff --git a/boards/xtensa/m5stack_core2/Kconfig.defconfig b/boards/xtensa/m5stack_core2/Kconfig.defconfig index 0edbda5d302..15dfc61483a 100644 --- a/boards/xtensa/m5stack_core2/Kconfig.defconfig +++ b/boards/xtensa/m5stack_core2/Kconfig.defconfig @@ -41,4 +41,13 @@ config INPUT config LV_COLOR_16_SWAP default y if LVGL +# Increase initialization priority of MIPI DBI device, so that it initializes +# after the GPIO controller +if MIPI_DBI + +config MIPI_DBI_INIT_PRIORITY + default 82 + +endif # MIPI_DBI + endif # BOARD_M5STACK_CORE2 diff --git a/boards/xtensa/m5stack_core2/m5stack_core2.dts b/boards/xtensa/m5stack_core2/m5stack_core2.dts index c17b540ca5d..c8c56b75ff9 100644 --- a/boards/xtensa/m5stack_core2/m5stack_core2.dts +++ b/boards/xtensa/m5stack_core2/m5stack_core2.dts @@ -48,6 +48,28 @@ input = <&ft5336_touch>; swap-xy; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>; + reset-gpios = <&axp192_gpio 4 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_HIGH)>; + spi-dev = <&spi3>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9342c: ili9342c@0 { + compatible = "ilitek,ili9342c"; + mipi-max-frequency = <30000000>; + reg = <0>; + vin-supply = <&lcd_bg>; + pixel-format = ; + display-inversion; + width = <320>; + height = <240>; + rotation = <0>; + }; + }; }; &cpu0 { @@ -186,21 +208,6 @@ cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>, <&gpio0 4 GPIO_ACTIVE_LOW>; - ili9342c: ili9342c@0 { - compatible = "ilitek,ili9342c"; - status = "okay"; - spi-max-frequency = <30000000>; - reg = <0>; - cmd-data-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; - vin-supply = <&lcd_bg>; - reset-gpios = <&axp192_gpio 4 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>; - pixel-format = ; - display-inversion; - width = <320>; - height = <240>; - rotation = <0>; - }; - sdhc0: sdhc@1 { compatible = "zephyr,sdhc-spi-slot"; reg = <1>; diff --git a/boards/xtensa/odroid_go/odroid_go.dts b/boards/xtensa/odroid_go/odroid_go.dts index 458a8251b1c..31ceee79d3c 100644 --- a/boards/xtensa/odroid_go/odroid_go.dts +++ b/boards/xtensa/odroid_go/odroid_go.dts @@ -77,6 +77,25 @@ sw0 = &menu_button; watchdog0 = &wdt0; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>; + spi-dev = <&spi3>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9341: ili9341@0 { + compatible = "ilitek,ili9341"; + mipi-max-frequency = <25000000>; + pixel-format = <0>; + reg = <0>; + rotation = <270>; + width = <320>; + height = <240>; + }; + }; }; &cpu0 { @@ -124,17 +143,6 @@ pinctrl-0 = <&spim3_default>; pinctrl-names = "default"; - ili9341: ili9341@0 { - compatible = "ilitek,ili9341"; - spi-max-frequency = <25000000>; - reg = <0>; - cmd-data-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>; - pixel-format = <0>; - rotation = <270>; - width = <320>; - height = <240>; - }; - sdhc0: sdhc@1 { compatible = "zephyr,sdhc-spi-slot"; reg = <1>; diff --git a/drivers/display/Kconfig.ili9xxx b/drivers/display/Kconfig.ili9xxx index 0ae849260cf..ccd6778d04a 100644 --- a/drivers/display/Kconfig.ili9xxx +++ b/drivers/display/Kconfig.ili9xxx @@ -14,7 +14,7 @@ config ILI9340 bool "ILI9340 display driver" default y depends on DT_HAS_ILITEK_ILI9340_ENABLED - select SPI + select MIPI_DBI select ILI9XXX help Enable driver for ILI9340 display driver. @@ -23,7 +23,7 @@ config ILI9341 bool "ILI9341 display driver" default y depends on DT_HAS_ILITEK_ILI9341_ENABLED - select SPI + select MIPI_DBI select ILI9XXX help Enable driver for ILI9341 display driver. @@ -32,7 +32,7 @@ config ILI9342C bool "ILI9342C display driver" default y depends on DT_HAS_ILITEK_ILI9342C_ENABLED - select SPI + select MIPI_DBI select ILI9XXX help Enable driver for ILI9342C display driver. @@ -41,7 +41,7 @@ config ILI9488 bool "ILI9488 display driver" default y depends on DT_HAS_ILITEK_ILI9488_ENABLED - select SPI + select MIPI_DBI select ILI9XXX help Enable driver for ILI9488 display driver. diff --git a/drivers/display/display_ili9xxx.c b/drivers/display/display_ili9xxx.c index 2df7c60ea21..6f1ff01d6b1 100644 --- a/drivers/display/display_ili9xxx.c +++ b/drivers/display/display_ili9xxx.c @@ -26,33 +26,8 @@ int ili9xxx_transmit(const struct device *dev, uint8_t cmd, const void *tx_data, { const struct ili9xxx_config *config = dev->config; - int r; - struct spi_buf tx_buf; - struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1U }; - - /* send command */ - tx_buf.buf = &cmd; - tx_buf.len = 1U; - - gpio_pin_set_dt(&config->cmd_data, ILI9XXX_CMD); - r = spi_write_dt(&config->spi, &tx_bufs); - if (r < 0) { - return r; - } - - /* send data (if any) */ - if (tx_data != NULL) { - tx_buf.buf = (void *)tx_data; - tx_buf.len = tx_len; - - gpio_pin_set_dt(&config->cmd_data, ILI9XXX_DATA); - r = spi_write_dt(&config->spi, &tx_bufs); - if (r < 0) { - return r; - } - } - - return 0; + return mipi_dbi_command_write(config->mipi_dev, &config->dbi_config, + cmd, tx_data, tx_len); } static int ili9xxx_exit_sleep(const struct device *dev) @@ -73,14 +48,7 @@ static void ili9xxx_hw_reset(const struct device *dev) { const struct ili9xxx_config *config = dev->config; - if (config->reset.port == NULL) { - return; - } - - gpio_pin_set_dt(&config->reset, 1); - k_sleep(K_MSEC(ILI9XXX_RESET_PULSE_TIME)); - gpio_pin_set_dt(&config->reset, 0); - + mipi_dbi_reset(config->mipi_dev, ILI9XXX_RESET_PULSE_TIME); k_sleep(K_MSEC(ILI9XXX_RESET_WAIT_TIME)); } @@ -115,11 +83,10 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x, { const struct ili9xxx_config *config = dev->config; struct ili9xxx_data *data = dev->data; + struct display_buffer_descriptor mipi_desc; int r; const uint8_t *write_data_start = (const uint8_t *)buf; - struct spi_buf tx_buf; - struct spi_buf_set tx_bufs; uint16_t write_cnt; uint16_t nbr_of_writes; uint16_t write_h; @@ -139,26 +106,31 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x, if (desc->pitch > desc->width) { write_h = 1U; nbr_of_writes = desc->height; + mipi_desc.height = 1; + mipi_desc.buf_size = desc->pitch * data->bytes_per_pixel; } else { write_h = desc->height; + mipi_desc.height = desc->height; + mipi_desc.buf_size = desc->buf_size; nbr_of_writes = 1U; } - r = ili9xxx_transmit(dev, ILI9XXX_RAMWR, write_data_start, - desc->width * data->bytes_per_pixel * write_h); + mipi_desc.width = desc->width; + mipi_desc.height = desc->height; + /* Per MIPI API, pitch must always match width */ + mipi_desc.pitch = desc->width; + + r = ili9xxx_transmit(dev, ILI9XXX_RAMWR, NULL, 0); if (r < 0) { return r; } - tx_bufs.buffers = &tx_buf; - tx_bufs.count = 1; - - write_data_start += desc->pitch * data->bytes_per_pixel; - for (write_cnt = 1U; write_cnt < nbr_of_writes; ++write_cnt) { - tx_buf.buf = (void *)write_data_start; - tx_buf.len = desc->width * data->bytes_per_pixel * write_h; - - r = spi_write_dt(&config->spi, &tx_bufs); + for (write_cnt = 0U; write_cnt < nbr_of_writes; ++write_cnt) { + r = mipi_dbi_write_display(config->mipi_dev, + &config->dbi_config, + write_data_start, + &mipi_desc, + data->pixel_format); if (r < 0) { return r; } @@ -363,35 +335,11 @@ static int ili9xxx_init(const struct device *dev) int r; - if (!spi_is_ready_dt(&config->spi)) { - LOG_ERR("SPI device is not ready"); + if (!device_is_ready(config->mipi_dev)) { + LOG_ERR("MIPI DBI device is not ready"); return -ENODEV; } - if (!gpio_is_ready_dt(&config->cmd_data)) { - LOG_ERR("Command/Data GPIO device not ready"); - return -ENODEV; - } - - r = gpio_pin_configure_dt(&config->cmd_data, GPIO_OUTPUT); - if (r < 0) { - LOG_ERR("Could not configure command/data GPIO (%d)", r); - return r; - } - - if (config->reset.port != NULL) { - if (!gpio_is_ready_dt(&config->reset)) { - LOG_ERR("Reset GPIO device not ready"); - return -ENODEV; - } - - r = gpio_pin_configure_dt(&config->reset, GPIO_OUTPUT_INACTIVE); - if (r < 0) { - LOG_ERR("Could not configure reset GPIO (%d)", r); - return r; - } - } - ili9xxx_hw_reset(dev); r = ili9xxx_transmit(dev, ILI9XXX_SWRESET, NULL, 0); @@ -463,13 +411,15 @@ static const struct ili9xxx_quirks ili9488_quirks = { \ static const struct ili9xxx_config ili9xxx_config_##n = { \ .quirks = &ili##t##_quirks, \ - .spi = SPI_DT_SPEC_GET(INST_DT_ILI9XXX(n, t), \ - SPI_OP_MODE_MASTER | SPI_WORD_SET(8), \ - 0), \ - .cmd_data = GPIO_DT_SPEC_GET(INST_DT_ILI9XXX(n, t), \ - cmd_data_gpios), \ - .reset = GPIO_DT_SPEC_GET_OR(INST_DT_ILI9XXX(n, t), \ - reset_gpios, {0}), \ + .mipi_dev = DEVICE_DT_GET(DT_PARENT(INST_DT_ILI9XXX(n, t))), \ + .dbi_config = { \ + .mode = MIPI_DBI_MODE_SPI_4WIRE, \ + .config = MIPI_DBI_SPI_CONFIG_DT( \ + INST_DT_ILI9XXX(n, t), \ + SPI_OP_MODE_MASTER | \ + SPI_WORD_SET(8), \ + 0), \ + }, \ .pixel_format = DT_PROP(INST_DT_ILI9XXX(n, t), pixel_format), \ .rotation = DT_PROP(INST_DT_ILI9XXX(n, t), rotation), \ .x_resolution = ILI##t##_X_RES, \ diff --git a/drivers/display/display_ili9xxx.h b/drivers/display/display_ili9xxx.h index 2cd6da98088..ddf8254224e 100644 --- a/drivers/display/display_ili9xxx.h +++ b/drivers/display/display_ili9xxx.h @@ -9,8 +9,7 @@ #ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9XXX_H_ #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9XXX_H_ -#include -#include +#include #include /* Commands/registers. */ @@ -65,10 +64,8 @@ struct ili9xxx_quirks { struct ili9xxx_config { const struct ili9xxx_quirks *quirks; - - struct spi_dt_spec spi; - struct gpio_dt_spec cmd_data; - struct gpio_dt_spec reset; + const struct device *mipi_dev; + struct mipi_dbi_config dbi_config; uint8_t pixel_format; uint16_t rotation; uint16_t x_resolution; diff --git a/dts/bindings/display/ilitek,ili9xxx-common.yaml b/dts/bindings/display/ilitek,ili9xxx-common.yaml index fe1fd852f87..802250002d6 100644 --- a/dts/bindings/display/ilitek,ili9xxx-common.yaml +++ b/dts/bindings/display/ilitek,ili9xxx-common.yaml @@ -4,26 +4,9 @@ description: ILI9XXX display controllers common properties. -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 ILI9340 is active low. - If connected directly the MCU pin should be configured - as active low. - - cmd-data-gpios: - type: phandle-array - required: true - description: D/CX pin. - - The D/CX pin of ILI9340 is active low (transmission command byte). - If connected directly the MCU pin should be configured - as active low. - pixel-format: type: int default: 0 diff --git a/tests/drivers/build_all/display/app.overlay b/tests/drivers/build_all/display/app.overlay index 2ce1a401b37..0e115ef6996 100644 --- a/tests/drivers/build_all/display/app.overlay +++ b/tests/drivers/build_all/display/app.overlay @@ -23,6 +23,26 @@ status = "okay"; }; + test_mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + status = "okay"; + dc-gpios = <&test_gpio 0 0>; + spi-dev = <&test_spi>; + #address-cells = <1>; + #size-cells = <0>; + + test_mipi_dbi_ili9342c: ili9342c@0 { + compatible = "ilitek,ili9342c"; + reg = <0>; + mipi-max-frequency = <25000000>; + pixel-format = <0>; + rotation = <270>; + width = <320>; + height = <240>; + }; + }; + + test_spi: spi@33334444 { #address-cells = <1>; #size-cells = <0>; @@ -34,17 +54,6 @@ /* one entry for every devices at spi.dtsi */ cs-gpios = <&test_gpio 0 0>; - test_spi_ili9342c: ili9342c@0 { - compatible = "ilitek,ili9342c"; - reg = <0>; - spi-max-frequency = <25000000>; - cmd-data-gpios = <&test_gpio 0 0>; - pixel-format = <0>; - rotation = <270>; - width = <320>; - height = <240>; - }; - test_spi_gc9x01x: gc9x01x@1 { compatible = "galaxycore,gc9x01x"; reg = <1>;