This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a17a66dcd26851db7f7c6a3914cc924d6e8d2360
Author: raiden00pl <[email protected]>
AuthorDate: Wed Nov 18 13:25:17 2026 +0100

    boards/stm32n6570-dk: Add the LCD, touch and the fb and lvgl configurations.
    
    The 800x480 RK050HR18 panel is /dev/fb0 on the LTDC with a 25 MHz IC16
    pixel clock, and the GT911 on I2C2 is /dev/input0.  With the D-cache
    the framebuffer is mapped non-cacheable through the MPU.  fb runs the
    framebuffer example, lvgl the LVGL widgets demo.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 .../arm/stm32n6/boards/stm32n6570-dk/index.rst     | 28 +++++++
 .../arm/stm32n6/stm32n6570-dk/configs/fb/defconfig | 72 ++++++++++++++++++
 .../stm32n6/stm32n6570-dk/configs/lvgl/defconfig   | 84 +++++++++++++++++++++
 boards/arm/stm32n6/stm32n6570-dk/include/board.h   | 71 ++++++++++++++++++
 .../arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt   |  4 +
 boards/arm/stm32n6/stm32n6570-dk/src/Make.defs     |  4 +
 boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c  | 27 +++++++
 .../arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c  | 28 +++++++
 .../src/{stm32_boot.c => stm32_lcd.c}              | 85 +++++++++++++++-------
 .../arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h  | 20 +++++
 10 files changed, 396 insertions(+), 27 deletions(-)

diff --git a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst 
b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst
index 49f3d4c22d5..ed95a297c47 100644
--- a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst
+++ b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst
@@ -167,6 +167,21 @@ its 125 MHz CLK125 output clocks the MAC.  The MAC address 
is derived from the u
 device ID.  The interface is ``eth0``; check it with ``ifconfig`` and
 ``ping``, and read the PHY registers with ``mdio``.
 
+LCD
+===
+
+The 5" 800x480 Rocktech RK050HR18 panel is driven by the LTDC (RGB888
+output, pins in ``board.h``) and registered as ``/dev/fb0``.  The 25 MHz
+pixel clock is IC16 (PLL1 / 96).  PQ3 enables the panel, PQ6 the backlight
+and PE1 is the shared panel/touch reset.  Layer 1 is RGB565 and its
+framebuffer is placed in AXISRAM1/2 at 0x34080000 (768000 bytes), below
+the image, so the heap is not affected.  Run ``fb`` to draw the test
+pattern.
+
+The GT911 touch controller on I2C2 (interrupt on PQ4) is reset at bring-up
+with PQ4 held low, which selects address 0x5d, and registered as
+``/dev/input0``; ``tc`` prints the touch coordinates.
+
 Clocking
 ========
 
@@ -196,3 +211,16 @@ netnsh
 The ``nsh`` configuration with Ethernet: IPv4, TCP, UDP, ICMP, a DHCP
 client started by NSH, ``ping``, ``telnetd`` and ``mdio``.  The link is
 auto-negotiated up to 1000 Mbps when ``eth0`` comes up.
+
+fb
+--
+
+``nsh`` plus the LCD framebuffer ``/dev/fb0`` and the ``fb`` example, which
+draws nested coloured rectangles on the panel.
+
+lvgl
+----
+
+``fb`` plus the touch controller, LVGL and its widgets demo.  Start it
+with ``lvgldemo &``.  The image is close to the 511 KiB limit of the boot
+ROM, so LVGL logging and extra fonts are left out.
diff --git a/boards/arm/stm32n6/stm32n6570-dk/configs/fb/defconfig 
b/boards/arm/stm32n6/stm32n6570-dk/configs/fb/defconfig
new file mode 100644
index 00000000000..1f83713122c
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/configs/fb/defconfig
@@ -0,0 +1,72 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+# CONFIG_ARCH_LEDS is not set
+# CONFIG_STM32_LTDC_L1_CHROMAKEYEN is not set
+# CONFIG_STM32_LTDC_L2 is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32n6570-dk"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_STM32N6570_DK=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="stm32n6"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32N657X0=y
+CONFIG_ARCH_CHIP_STM32N6=y
+CONFIG_ARCH_INTERRUPTSTACK=4096
+CONFIG_ARCH_IRQBUTTONS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=84000
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DRIVERS_VIDEO=y
+CONFIG_EXAMPLES_ALARM=y
+CONFIG_EXAMPLES_FB=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_I2C=y
+CONFIG_IDLETHREAD_STACKSIZE=4096
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INPUT=y
+CONFIG_INPUT_BUTTONS=y
+CONFIG_INPUT_BUTTONS_LOWER=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_RAM_SIZE=2620416
+CONFIG_RAM_START=0x34180400
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_RTC_ALARM=y
+CONFIG_RTC_DATETIME=y
+CONFIG_RTC_DRIVER=y
+CONFIG_RTC_NALARMS=2
+CONFIG_RTC_PERIODIC=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SPITOOL_MAXBUS=5
+CONFIG_STM32N6_DEBUG=y
+CONFIG_STM32_DMA1=y
+CONFIG_STM32_I2C1=y
+CONFIG_STM32_I2C2=y
+CONFIG_STM32_I2C4=y
+CONFIG_STM32_LTDC=y
+CONFIG_STM32_LTDC_FB_BASE=0x34080000
+CONFIG_STM32_LTDC_FB_SIZE=768000
+CONFIG_STM32_RNG=y
+CONFIG_STM32_RTC=y
+CONFIG_STM32_SPI5=y
+CONFIG_STM32_USART1=y
+CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_SPITOOL=y
+CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_USERLED=y
+CONFIG_USERLED_LOWER=y
+CONFIG_VIDEO_FB=y
diff --git a/boards/arm/stm32n6/stm32n6570-dk/configs/lvgl/defconfig 
b/boards/arm/stm32n6/stm32n6570-dk/configs/lvgl/defconfig
new file mode 100644
index 00000000000..98f054e5c00
--- /dev/null
+++ b/boards/arm/stm32n6/stm32n6570-dk/configs/lvgl/defconfig
@@ -0,0 +1,84 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+# CONFIG_ARCH_LEDS is not set
+# CONFIG_STM32_LTDC_L1_CHROMAKEYEN is not set
+# CONFIG_STM32_LTDC_L2 is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32n6570-dk"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_STM32N6570_DK=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="stm32n6"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32N657X0=y
+CONFIG_ARCH_CHIP_STM32N6=y
+CONFIG_ARCH_INTERRUPTSTACK=4096
+CONFIG_ARCH_IRQBUTTONS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=84000
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DRIVERS_VIDEO=y
+CONFIG_EXAMPLES_ALARM=y
+CONFIG_EXAMPLES_FB=y
+CONFIG_EXAMPLES_LVGLDEMO=y
+CONFIG_EXAMPLES_LVGLDEMO_STACKSIZE=32768
+CONFIG_EXAMPLES_TOUCHSCREEN=y
+CONFIG_FS_PROCFS=y
+CONFIG_GRAPHICS_LVGL=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_I2C=y
+CONFIG_IDLETHREAD_STACKSIZE=4096
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=4096
+CONFIG_INPUT=y
+CONFIG_INPUT_BUTTONS=y
+CONFIG_INPUT_BUTTONS_LOWER=y
+CONFIG_INPUT_GT9XX=y
+CONFIG_LV_USE_CLIB_MALLOC=y
+CONFIG_LV_USE_CLIB_SPRINTF=y
+CONFIG_LV_USE_CLIB_STRING=y
+CONFIG_LV_USE_DEMO_WIDGETS=y
+CONFIG_LV_USE_NUTTX=y
+CONFIG_LV_USE_NUTTX_TOUCHSCREEN=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_RAM_SIZE=2620416
+CONFIG_RAM_START=0x34180400
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_RTC_ALARM=y
+CONFIG_RTC_DATETIME=y
+CONFIG_RTC_DRIVER=y
+CONFIG_RTC_NALARMS=2
+CONFIG_RTC_PERIODIC=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SPITOOL_MAXBUS=5
+CONFIG_STM32N6_DEBUG=y
+CONFIG_STM32_DMA1=y
+CONFIG_STM32_I2C1=y
+CONFIG_STM32_I2C2=y
+CONFIG_STM32_I2C4=y
+CONFIG_STM32_LTDC=y
+CONFIG_STM32_LTDC_FB_BASE=0x34080000
+CONFIG_STM32_LTDC_FB_SIZE=768000
+CONFIG_STM32_RNG=y
+CONFIG_STM32_RTC=y
+CONFIG_STM32_SPI5=y
+CONFIG_STM32_USART1=y
+CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_I2CTOOL=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_SPITOOL=y
+CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_USERLED=y
+CONFIG_USERLED_LOWER=y
+CONFIG_VIDEO_FB=y
diff --git a/boards/arm/stm32n6/stm32n6570-dk/include/board.h 
b/boards/arm/stm32n6/stm32n6570-dk/include/board.h
index a81fa5d5429..caac04b8873 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/include/board.h
+++ b/boards/arm/stm32n6/stm32n6570-dk/include/board.h
@@ -57,6 +57,7 @@
  *     IC2  /6 = 400 MHz  \
  *     IC6  /8 = 300 MHz   > SYSCLK components (SYSSW IC2_IC6_IC11)
  *     IC11 /6 = 400 MHz  /
+ *     IC16 /96 = 25 MHz  -> LTDC pixel clock
  *   PLL2 = HSI / 2 * 48  = 1536 MHz   (audio and SDMMC kernel clocks)
  *   PLL3 = HSE / 3 * 125 = 2000 MHz   (LTDC)
  *   PLL4 = HSI / 4 * 75  = 1200 MHz   (I2C, LTDC)
@@ -104,6 +105,11 @@
 #define STM32_IC11_SRC          RCC_ICCFGR_SEL_PLL1
 #define STM32_IC11_DIV          6
 
+/* IC16 = PLL1 / 96 = 25 MHz -> LTDC pixel clock */
+
+#define STM32_IC16_SRC          RCC_ICCFGR_SEL_PLL1
+#define STM32_IC16_DIV          96
+
 #define STM32_CPUCLK_FREQUENCY  (STM32_PLL1_FREQUENCY / STM32_IC1_DIV)
 #define STM32_SYSCLK_FREQUENCY  (STM32_PLL1_FREQUENCY / STM32_IC2_DIV)
 #define STM32_RCC_CFGR2_HPRE    RCC_CFGR2_HPRE_SYSCLKd2
@@ -140,6 +146,11 @@
 #define STM32_IC11_SRC          RCC_ICCFGR_SEL_PLL1
 #define STM32_IC11_DIV          8
 
+/* IC16 = PLL1 / 32 = 25 MHz -> LTDC pixel clock */
+
+#define STM32_IC16_SRC          RCC_ICCFGR_SEL_PLL1
+#define STM32_IC16_DIV          32
+
 #define STM32_CPUCLK_FREQUENCY  (STM32_PLL1_FREQUENCY / STM32_IC1_DIV)
 #define STM32_SYSCLK_FREQUENCY  (STM32_PLL1_FREQUENCY / STM32_IC2_DIV)
 #define STM32_RCC_CFGR2_HPRE    RCC_CFGR2_HPRE_SYSCLKd2
@@ -187,6 +198,10 @@
 #define STM32_RCC_CCIPR13_USART2SEL RCC_CCIPR13_USART2SEL_HSI
 #define STM32_USART2_FREQUENCY      STM32_HSI_FREQUENCY
 
+/* LTDC kernel clock: IC16 (25 MHz pixel clock) */
+
+#define STM32_RCC_CCIPR4_LTDCSEL RCC_CCIPR4_LTDCSEL_IC16
+
 /* I/O voltage domains ******************************************************/
 
 /* VDDIO2 and VDDIO3 are supplied at 1.8 V on the Discovery kit.
@@ -317,6 +332,62 @@
 #define STM32_RCC_CCIPR9_SPI5SEL RCC_CCIPR9_SPI5SEL_PCLK2
 #define STM32_SPI5_FREQUENCY     STM32_PCLK2_FREQUENCY
 
+/* LTDC *********************************************************************/
+
+/* 5" 800x480 Rocktech RK050HR18 RGB888 panel on the LTDC.  Timings and
+ * polarities as in the Zephyr stm32n6570_dk board display-timings: syncs 4,
+ * porches 8, syncs and DE active low, pixel clock not inverted.  The 25 MHz
+ * IC16 pixel clock gives 820 x 500 clocks per frame, 61 Hz.
+ */
+
+#define GPIO_LTDC_R0     (GPIO_LTDC_R0_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R1     (GPIO_LTDC_R1_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R2     (GPIO_LTDC_R2_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R3     (GPIO_LTDC_R3_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R4     (GPIO_LTDC_R4_4 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R5     (GPIO_LTDC_R5_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R6     (GPIO_LTDC_R6_3 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_R7     (GPIO_LTDC_R7_1 | GPIO_SPEED_100MHZ)
+
+#define GPIO_LTDC_G0     (GPIO_LTDC_G0_3 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G1     (GPIO_LTDC_G1_3 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G2     (GPIO_LTDC_G2_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G3     (GPIO_LTDC_G3_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G4     (GPIO_LTDC_G4_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G5     (GPIO_LTDC_G5_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G6     (GPIO_LTDC_G6_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_G7     (GPIO_LTDC_G7_2 | GPIO_SPEED_100MHZ)
+
+#define GPIO_LTDC_B0     (GPIO_LTDC_B0_4 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B1     (GPIO_LTDC_B1_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B2     (GPIO_LTDC_B2_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B3     (GPIO_LTDC_B3_3 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B4     (GPIO_LTDC_B4_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B5     (GPIO_LTDC_B5_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B6     (GPIO_LTDC_B6_1 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_B7     (GPIO_LTDC_B7_1 | GPIO_SPEED_100MHZ)
+
+#define GPIO_LTDC_CLK    (GPIO_LTDC_CLK_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_DE     (GPIO_LTDC_DE_3 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_HSYNC  (GPIO_LTDC_HSYNC_2 | GPIO_SPEED_100MHZ)
+#define GPIO_LTDC_VSYNC  (GPIO_LTDC_VSYNC_2 | GPIO_SPEED_100MHZ)
+
+#define BOARD_LTDC_WIDTH         800
+#define BOARD_LTDC_HEIGHT        480
+
+#define BOARD_LTDC_OUTPUT_BPP    24
+#define BOARD_LTDC_HSYNC         4
+#define BOARD_LTDC_HBP           8
+#define BOARD_LTDC_HFP           8
+#define BOARD_LTDC_VSYNC         4
+#define BOARD_LTDC_VBP           8
+#define BOARD_LTDC_VFP           8
+
+#define BOARD_LTDC_GCR_PCPOL     0 /* Input pixel clock */
+#define BOARD_LTDC_GCR_DEPOL     0 /* DE active low */
+#define BOARD_LTDC_GCR_VSPOL     0 /* VSYNC active low */
+#define BOARD_LTDC_GCR_HSPOL     0 /* HSYNC active low */
+
 /* USART1 GPIOs *************************************************************/
 
 /* USART1 (ST-LINK Virtual COM Port): PE5=TX (AF7), PE6=RX (AF7)
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt 
b/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
index 9a8754811fd..426a98b5728 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
@@ -36,6 +36,10 @@ if(CONFIG_STM32_SPI)
   list(APPEND SRCS stm32_spi.c)
 endif()
 
+if(CONFIG_STM32_LTDC)
+  list(APPEND SRCS stm32_lcd.c)
+endif()
+
 target_sources(board PRIVATE ${SRCS})
 
 set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs 
b/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
index da47a4d6b1c..519e85a8e2b 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
@@ -39,6 +39,10 @@ ifeq ($(CONFIG_STM32_SPI),y)
 CSRCS += stm32_spi.c
 endif
 
+ifeq ($(CONFIG_STM32_LTDC),y)
+CSRCS += stm32_lcd.c
+endif
+
 DEPPATH += --dep-path board
 VPATH += :board
 CFLAGS += 
${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c 
b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
index b84940016a4..27d7d400617 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
@@ -31,10 +31,26 @@
 #include <nuttx/board.h>
 
 #include "arm_internal.h"
+#include "mpu.h"
 #include "stm32n6570-dk.h"
 
 #include <arch/board/board.h>
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* The LTDC reads the framebuffer from memory, so with the D-cache it must
+ * not be cacheable.
+ */
+
+#if defined(CONFIG_STM32_LTDC) && defined(CONFIG_ARMV8M_DCACHE)
+#  ifndef CONFIG_ARM_MPU
+#    error "The LTDC framebuffer with the D-cache needs CONFIG_ARM_MPU"
+#  endif
+#  define HAVE_FB_MPU 1
+#endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -52,6 +68,17 @@
 
 void stm32_board_initialize(void)
 {
+#ifdef HAVE_FB_MPU
+  /* Map the framebuffer as normal non-cacheable memory, keep the default
+   * memory map for everything else.
+   */
+
+  mpu_configure_region(CONFIG_STM32_LTDC_FB_BASE, CONFIG_STM32_LTDC_FB_SIZE,
+                       MPU_RBAR_XN | MPU_RBAR_AP_RWRW | MPU_RBAR_SH_NO,
+                       MPU_RLAR_NONCACHEABLE);
+  mpu_control(true, false, true);
+#endif
+
 #ifdef CONFIG_ARCH_LEDS
   /* Configure on-board LEDs if LED support has been selected. */
 
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c 
b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
index ac812adce1c..59bc463ca88 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
@@ -35,11 +35,16 @@
 #include <nuttx/input/buttons.h>
 #include <nuttx/timers/rtc.h>
 #include <nuttx/net/realtek_phy.h>
+#include <nuttx/video/fb.h>
 
 #include "stm32_rtc.h"
 #include "stm32n6570-dk.h"
 #include "board_common.h"
 
+#ifdef CONFIG_INPUT_GT9XX
+#  include "stm32_gt9xx.h"
+#endif
+
 #include <arch/board/board.h>
 
 /****************************************************************************
@@ -125,6 +130,29 @@ int stm32_bringup(void)
 #  endif
 #endif
 
+#ifdef CONFIG_INPUT_GT9XX
+  /* Register the GT911 touch controller as /dev/input0.  This also resets
+   * the LCD panel, which shares the reset line, before it is set up.
+   */
+
+  ret = board_gt9xx_initialize(0, TOUCH_I2C_BUS, GPIO_TOUCH_INT,
+                               GPIO_LCD_NRST);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: board_gt9xx_initialize() failed: %d\n", ret);
+    }
+#endif
+
+#ifdef CONFIG_VIDEO_FB
+  /* Initialize and register the LCD framebuffer driver as /dev/fb0 */
+
+  ret = fb_register(0, 0);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret);
+    }
+#endif
+
   UNUSED(ret);
   return OK;
 }
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c 
b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_lcd.c
similarity index 52%
copy from boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
copy to boards/arm/stm32n6/stm32n6570-dk/src/stm32_lcd.c
index b84940016a4..d332904a80e 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_lcd.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
+ * boards/arm/stm32n6/stm32n6570-dk/src/stm32_lcd.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -26,58 +26,89 @@
 
 #include <nuttx/config.h>
 
-#include <debug.h>
-
+#include <nuttx/arch.h>
 #include <nuttx/board.h>
+#include <nuttx/signal.h>
+#include <nuttx/video/fb.h>
 
-#include "arm_internal.h"
+#include "stm32_gpio.h"
+#include "stm32_ltdc.h"
 #include "stm32n6570-dk.h"
 
-#include <arch/board/board.h>
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LCD_NRST low time, as for the GT911 that shares the line */
+
+#define LCD_RESET_DELAY 1000
 
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: stm32_board_initialize
+ * Name: up_fbinitialize
  *
  * Description:
- *   All STM32 architectures must provide the following entry point.  This
- *   entry point is called early in the initialization -- after all memory
- *   has been configured and mapped but before any devices have been
- *   initialized.
+ *   Power the RK050HR18 panel and initialize the LTDC.
  *
  ****************************************************************************/
 
-void stm32_board_initialize(void)
+int up_fbinitialize(int display)
 {
-#ifdef CONFIG_ARCH_LEDS
-  /* Configure on-board LEDs if LED support has been selected. */
+  int ret;
 
-  board_autoled_initialize();
+#ifndef CONFIG_INPUT_GT9XX
+  /* Reset the panel.  With the touch controller, its set-up did it. */
+
+  stm32_configgpio(GPIO_LCD_NRST);
+  nxsig_usleep(LCD_RESET_DELAY);
+  stm32_gpiowrite(GPIO_LCD_NRST, true);
 #endif
+
+  /* Turn the display on */
+
+  stm32_configgpio(GPIO_LCD_DISP);
+  stm32_configgpio(GPIO_LCD_BL);
+  stm32_gpiowrite(GPIO_LCD_DISP, true);
+
+  ret = stm32_ltdcinitialize();
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  stm32_gpiowrite(GPIO_LCD_BL, true);
+  return OK;
 }
 
 /****************************************************************************
- * Name: board_late_initialize
+ * Name: up_fbgetvplane
  *
  * Description:
- *   If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
- *   initialization call will be performed in the boot-up sequence to a
- *   function called board_late_initialize().  board_late_initialize() will
- *   be called immediately after up_initialize() is called and just before
- *   the initial application is started.  This additional initialization
- *   phase may be used, for example, to initialize board-specific device
- *   drivers.
+ *   Return a reference to the framebuffer object for the specified video
+ *   plane.
  *
  ****************************************************************************/
 
-#ifdef CONFIG_BOARD_LATE_INITIALIZE
-void board_late_initialize(void)
+struct fb_vtable_s *up_fbgetvplane(int display, int vplane)
 {
-  /* Perform board-specific initialization here if so configured */
+  return stm32_ltdcgetvplane(vplane);
+}
+
+/****************************************************************************
+ * Name: up_fbuninitialize
+ *
+ * Description:
+ *   Turn the panel off and uninitialize the LTDC.
+ *
+ ****************************************************************************/
 
-  stm32_bringup();
+void up_fbuninitialize(int display)
+{
+  stm32_gpiowrite(GPIO_LCD_BL, false);
+  stm32_gpiowrite(GPIO_LCD_DISP, false);
+
+  stm32_ltdcuninitialize();
 }
-#endif
diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h 
b/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
index 2d7bcf11bf1..8a78676e3ff 100644
--- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
+++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
@@ -66,6 +66,26 @@
 #define GPIO_SPI5_CS   (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHZ | \
                         GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN3)
 
+/* LCD control: LCD_ON/OFF (PQ3) and backlight (PQ6) are active high,
+ * LCD_NRST (PE1, shared with the GT911 touch controller) is active low and
+ * starts asserted.
+ */
+
+#define GPIO_LCD_DISP  (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTQ | GPIO_PIN3)
+#define GPIO_LCD_BL    (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTQ | GPIO_PIN6)
+#define GPIO_LCD_NRST  (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTE | GPIO_PIN1)
+
+/* GT911 touch controller on I2C2 (0x5d): interrupt on PQ4, rising edge.
+ * Its reset is LCD_NRST (PE1).
+ */
+
+#define GPIO_TOUCH_INT (GPIO_INPUT | GPIO_PULLDOWN | GPIO_EXTI | \
+                        GPIO_PORTQ | GPIO_PIN4)
+#define TOUCH_I2C_BUS  2
+
 #ifndef __ASSEMBLY__
 
 /****************************************************************************

Reply via email to