diff --git a/boards/m5stack/m5stack_cores3/doc/index.rst b/boards/m5stack/m5stack_cores3/doc/index.rst index 2fdd042c38e67..e5a293e97990e 100644 --- a/boards/m5stack/m5stack_cores3/doc/index.rst +++ b/boards/m5stack/m5stack_cores3/doc/index.rst @@ -26,6 +26,24 @@ M5Stack CoreS3/CoreS3 SE features consist of: - Proximity sensor LTR-553ALS-WA (Not available for CoreS3 SE) - 6-Axis IMU BMI270 (Not available for CoreS3 SE) +Display +======= + +The integrated 2" SPI display is supported via the :dtcompatible:`ilitek,ili9342c` +driver. Applications can access the panel through the +:kconfig:option:`CONFIG_DISPLAY` API. For example, the following command builds +the :zephyr:code-sample:`lvgl` sample for the primary CPU: + +.. zephyr-app-commands:: + :zephyr-app: samples/subsys/display/lvgl + :board: m5stack_cores3/esp32s3/procpu + :goals: build + :compact: + +The sample enables the LVGL GUI library by default. Once flashed, the graphical +output is rendered on the CoreS3 screen and touch input is provided by the +FT6336 controller. + Start Application Development ***************************** diff --git a/boards/m5stack/m5stack_cores3/m5stack_cores3_procpu_common.dtsi b/boards/m5stack/m5stack_cores3/m5stack_cores3_procpu_common.dtsi index 078f7afe7f255..d713b9c2e5360 100644 --- a/boards/m5stack/m5stack_cores3/m5stack_cores3_procpu_common.dtsi +++ b/boards/m5stack/m5stack_cores3/m5stack_cores3_procpu_common.dtsi @@ -9,6 +9,7 @@ #include "m5stack_cores3-pinctrl.dtsi" #include "m5stack_mbus_connectors.dtsi" #include "grove_connectors.dtsi" +#include / { chosen { @@ -20,6 +21,7 @@ zephyr,rtc = &bm8563_rtc; zephyr,bt-hci = &esp32_bt_hci; zephyr,touch = &ft6336_touch; + zephyr,display = &ili9342c; }; aliases { @@ -39,6 +41,29 @@ compatible = "zephyr,lvgl-pointer-input"; input = <&ft6336_touch>; }; + + mipi_dbi { + compatible = "zephyr,mipi-dbi-spi"; + dc-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; + reset-gpios = <&aw9523b_gpio 1 GPIO_ACTIVE_LOW>; + spi-dev = <&spi2>; + write-only; + #address-cells = <1>; + #size-cells = <0>; + + ili9342c: ili9342c@0 { + compatible = "ilitek,ili9342c"; + reg = <0>; + mipi-max-frequency = <30000000>; + vin-supply = <&vcc_bl>; + pixel-format = ; + color-order = "rgb"; + display-inversion; + width = <320>; + height = <240>; + rotation = <0>; + }; + }; }; &usb_serial { diff --git a/drivers/display/display_ili9xxx.c b/drivers/display/display_ili9xxx.c index ef258cfed8922..09e4b659f3a44 100644 --- a/drivers/display/display_ili9xxx.c +++ b/drivers/display/display_ili9xxx.c @@ -324,7 +324,8 @@ static int ili9xxx_set_orientation(const struct device *dev, struct ili9xxx_data *data = dev->data; int r; - uint8_t tx_data = ILI9XXX_MADCTL_BGR; + uint8_t tx_data = (config->color_order == ILI9XXX_COLOR_ORDER_BGR) ? + ILI9XXX_MADCTL_BGR : 0U; if (config->quirks->cmd_set == CMD_SET_1) { if (orientation == DISPLAY_ORIENTATION_NORMAL) { tx_data |= ILI9XXX_MADCTL_MX; @@ -549,11 +550,13 @@ static const struct ili9xxx_quirks ili9488_quirks = { .rotation = DT_PROP(INST_DT_ILI9XXX(n, t), rotation), \ .x_resolution = ILI##t##_X_RES, \ .y_resolution = ILI##t##_Y_RES, \ - .inversion = DT_PROP(INST_DT_ILI9XXX(n, t), display_inversion),\ - .te_mode = MIPI_DBI_TE_MODE_DT(INST_DT_ILI9XXX(n, t), te_mode),\ - .regs = &ili##t##_regs_##n, \ - .regs_init_fn = ili##t##_regs_init, \ - }; \ + .inversion = DT_PROP(INST_DT_ILI9XXX(n, t), display_inversion),\ + .te_mode = MIPI_DBI_TE_MODE_DT(INST_DT_ILI9XXX(n, t), te_mode),\ + .regs = &ili##t##_regs_##n, \ + .regs_init_fn = ili##t##_regs_init, \ + .color_order = \ + DT_ENUM_IDX(INST_DT_ILI9XXX(n, t), color_order), \ + }; \ \ static struct ili9xxx_data ili9##t##_data_##n; \ \ diff --git a/drivers/display/display_ili9xxx.h b/drivers/display/display_ili9xxx.h index cb3774246c72a..23a3cb8fa6f24 100644 --- a/drivers/display/display_ili9xxx.h +++ b/drivers/display/display_ili9xxx.h @@ -62,6 +62,11 @@ enum madctl_cmd_set { CMD_SET_2, /* Used by ILI9342c */ }; +enum ili9xxx_color_order { + ILI9XXX_COLOR_ORDER_RGB, + ILI9XXX_COLOR_ORDER_BGR, +}; + struct ili9xxx_quirks { enum madctl_cmd_set cmd_set; }; @@ -78,6 +83,7 @@ struct ili9xxx_config { uint8_t te_mode; const void *regs; int (*regs_init_fn)(const struct device *dev); + enum ili9xxx_color_order color_order; }; int ili9xxx_transmit(const struct device *dev, uint8_t cmd, diff --git a/dts/bindings/display/ilitek,ili9xxx-common.yaml b/dts/bindings/display/ilitek,ili9xxx-common.yaml index 7ce2f5eaa9c59..2b5da3513d573 100644 --- a/dts/bindings/display/ilitek,ili9xxx-common.yaml +++ b/dts/bindings/display/ilitek,ili9xxx-common.yaml @@ -42,3 +42,15 @@ properties: description: Display inversion mode. Every bit is inverted from the frame memory to the display. + + color-order: + type: string + enum: + - "rgb" + - "bgr" + default: "bgr" + description: | + Define the byte order used when updating display memory. Some panels + require RGB ordering while others expect BGR ordering. The default value + keeps backwards compatibility with existing boards that rely on the + BGR order.