[v2,33/35] board: engicam: stm32mp2: add splash screen
Commit Message
The U-Boot devicetree includes the overlays of all the supported
displays. Enable only the one selected by the "display" environment
variable.
The customer splash image is loaded from its partition, falling back to
the built-in logo.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
Changes in v2:
- Apply the upstream display overlays to the U-Boot devicetree instead
of describing the displays in the -u-boot.dtsi file
- Do not leave the LTDC RGB pins configured with the LVDS display
...m32mp257d-engicam-microgea-rmm-u-boot.dtsi | 5 +
board/engicam/stm32mp2/microgea-stm32mp2.env | 4 +
board/engicam/stm32mp2/stm32mp2.c | 179 ++++++++++++++++++
configs/stm32mp25-microgea-rmm_defconfig | 16 ++
4 files changed, 204 insertions(+)
--
2.43.0
Comments
On 11/7/26 15:32, Dario Binacchi wrote:
> The U-Boot devicetree includes the overlays of all the supported
> displays. Enable only the one selected by the "display" environment
> variable.
>
> The customer splash image is loaded from its partition, falling back to
> the built-in logo.
>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>
> ---
>
> Changes in v2:
> - Apply the upstream display overlays to the U-Boot devicetree instead
> of describing the displays in the -u-boot.dtsi file
> - Do not leave the LTDC RGB pins configured with the LVDS display
>
> ...m32mp257d-engicam-microgea-rmm-u-boot.dtsi | 5 +
> board/engicam/stm32mp2/microgea-stm32mp2.env | 4 +
> board/engicam/stm32mp2/stm32mp2.c | 179 ++++++++++++++++++
> configs/stm32mp25-microgea-rmm_defconfig | 16 ++
> 4 files changed, 204 insertions(+)
>
> diff --git a/arch/arm/dts/stm32mp257d-engicam-microgea-rmm-u-boot.dtsi b/arch/arm/dts/stm32mp257d-engicam-microgea-rmm-u-boot.dtsi
> index 4cc0d47e999d..8a3723baa116 100644
> --- a/arch/arm/dts/stm32mp257d-engicam-microgea-rmm-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp257d-engicam-microgea-rmm-u-boot.dtsi
> @@ -12,6 +12,11 @@
> };
> };
>
> +<dc {
> + clocks = <&rcc CK_KER_LTDC>, <&rcc CK_BUS_LTDC>, <&syscfg>, <&lvds>;
> + bootph-all;
> +};
> +
> &usart2 {
> bootph-all;
> };
> diff --git a/board/engicam/stm32mp2/microgea-stm32mp2.env b/board/engicam/stm32mp2/microgea-stm32mp2.env
> index 1f50f68d4972..cbc0a73f5081 100644
> --- a/board/engicam/stm32mp2/microgea-stm32mp2.env
> +++ b/board/engicam/stm32mp2/microgea-stm32mp2.env
> @@ -7,3 +7,7 @@
> /* Default display of the carrier board */
> display=rk050hr345-ct106a
> extension_overlay_addr=0x90300000
> +
> +splashfile=splash.bmp
> +splashimage=CONFIG_SYS_LOAD_ADDR
> +splashpos=m,m
> diff --git a/board/engicam/stm32mp2/stm32mp2.c b/board/engicam/stm32mp2/stm32mp2.c
> index 5f3afd877a11..64317f271ed7 100644
> --- a/board/engicam/stm32mp2/stm32mp2.c
> +++ b/board/engicam/stm32mp2/stm32mp2.c
> @@ -8,12 +8,23 @@
>
> #include <alist.h>
> #include <config.h>
> +#include <dm.h>
> #include <env.h>
> +#include <event.h>
> #include <extension_board.h>
> #include <log.h>
> +#include <splash.h>
> +#include <asm/arch/stm32.h>
> +#include <asm/arch/sys_proto.h>
> +#include <dm/device-internal.h>
> #include <dm/ofnode.h>
> +#include <dm/ofnode_graph.h>
> +#include <dm/uclass-internal.h>
> #include <linux/string.h>
>
> +#define MICROGEA_RK050HR345 "rk050hr345-ct106a"
> +#define MICROGEA_AM1280800W8TZQW "am-1280800w8tzqw-t00h"
> +
> int checkboard(void)
> {
> const char *fdt_compat;
> @@ -38,6 +49,174 @@ static const char *microgea_get_display(void)
> return display;
> }
>
> +/* Disable a node and unbind its device, if any */
> +static int microgea_disable_node(ofnode node)
> +{
> + struct udevice *dev;
> + int ret;
> +
> + if (!ofnode_valid(node))
> + return 0;
> +
> + if (!device_find_global_by_ofnode(node, &dev)) {
> + ret = device_unbind(dev);
> + if (ret)
> + return ret;
> + }
> +
> + return ofnode_set_enabled(node, false);
> +}
> +
> +static int microgea_ltdc_connect(ofnode ltdc, ofnode ep)
> +{
> + u32 ltdc_phandle, phandle;
> + ofnode ltdc_ep;
> + int ret;
> +
> + ltdc_ep = ofnode_graph_get_endpoint_by_regs(ltdc, -1, -1);
> + if (!ofnode_valid(ltdc_ep) || !ofnode_valid(ep) ||
> + ofnode_read_u32(ltdc_ep, "phandle", <dc_phandle) ||
> + ofnode_read_u32(ep, "phandle", &phandle))
> + return -EINVAL;
> +
> + ret = ofnode_write_u32(ltdc_ep, "remote-endpoint", phandle);
> + if (ret)
> + return ret;
> +
> + return ofnode_write_u32(ep, "remote-endpoint", ltdc_phandle);
> +}
> +
> +static int microgea_disable_compatible(const char *compat)
> +{
> + return microgea_disable_node(ofnode_by_compatible(ofnode_null(),
> + compat));
> +}
> +
> +static const struct microgea_display {
> + const char *name; /* value of the "display" env variable */
> + const char *compatible; /* compatible of its panel */
> + const char *bridge; /* compatible of its bridge, if any */
> +} microgea_displays[] = {
> + {
> + .name = MICROGEA_RK050HR345,
> + .compatible = "rocktech," MICROGEA_RK050HR345,
> + },
> + {
> + .name = MICROGEA_AM1280800W8TZQW,
> + .compatible = "ampire," MICROGEA_AM1280800W8TZQW,
> + .bridge = "st,stm32mp25-lvds",
> + },
> +};
> +
> +static bool microgea_uses_bridge(const struct microgea_display *d,
> + const char *bridge)
> +{
> + return d && d->bridge && !strcmp(d->bridge, bridge);
> +}
> +
> +/*
> + * The U-Boot devicetree includes the overlays of all the displays. Keep
> + * only the one in use, or disable the LTDC if it is not supported.
> + */
> +static int microgea_settings_r(void)
> +{
> + const char *display = microgea_get_display();
> + const struct microgea_display *sel = NULL, *d;
> + struct udevice *video;
> + ofnode ltdc, node, ep;
> + int i, ret;
> +
> + if (uclass_find_first_device(UCLASS_VIDEO, &video) || !video)
> + return 0;
> +
> + ltdc = dev_ofnode(video);
> +
> + for (i = 0; i < ARRAY_SIZE(microgea_displays); i++) {
> + if (display && !strcmp(display, microgea_displays[i].name)) {
> + sel = µgea_displays[i];
> + break;
> + }
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(microgea_displays); i++) {
> + d = µgea_displays[i];
> + if (d == sel)
> + continue;
> +
> + ret = microgea_disable_compatible(d->compatible);
> + if (ret)
> + return ret;
> +
> + if (d->bridge && !microgea_uses_bridge(sel, d->bridge)) {
> + ret = microgea_disable_compatible(d->bridge);
> + if (ret)
> + return ret;
> + }
> + }
> +
> + if (!sel)
> + return microgea_disable_node(ltdc);
> +
> + node = ofnode_by_compatible(ofnode_null(), sel->compatible);
> + if (!ofnode_valid(node))
> + return microgea_disable_node(ltdc);
> +
> + /* Connect the RGB panel to the LTDC */
> + if (!sel->bridge) {
> + ep = ofnode_graph_get_endpoint_by_regs(node, -1, -1);
> + return microgea_ltdc_connect(ltdc, ep);
> + }
> +
> + /* The bridge does not use the LTDC pins */
> + ret = ofnode_delete_prop(ltdc, "pinctrl-names");
> + if (!ret)
> + ret = ofnode_delete_prop(ltdc, "pinctrl-0");
> + if (!ret)
> + ret = ofnode_delete_prop(ltdc, "pinctrl-1");
> + if (ret)
> + return ret;
> +
> + node = ofnode_by_compatible(ofnode_null(), sel->bridge);
> + if (!ofnode_valid(node))
> + return -ENODEV;
> +
> + /* Connect the bridge to the LTDC */
> + ep = ofnode_graph_get_endpoint_by_regs(node, 0, -1);
> + return microgea_ltdc_connect(ltdc, ep);
> +}
> +EVENT_SPY_SIMPLE(EVT_SETTINGS_R, microgea_settings_r);
> +
> +#if CONFIG_IS_ENABLED(SPLASH_SOURCE)
> +static struct splash_location microgea_splash_locations[] = {
> + {
> + .name = "mmc",
> + .storage = SPLASH_STORAGE_MMC,
> + .flags = SPLASH_STORAGE_FS,
> + },
> +};
> +
> +/* Load the customer splash image from its partition, else the built-in logo */
> +int splash_screen_prepare(void)
> +{
> + static char devpart[8];
> + u32 bootmode = get_bootmode();
> + unsigned int instance = (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1;
> +
> + switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
> + case BOOT_FLASH_SD:
> + case BOOT_FLASH_EMMC:
> + snprintf(devpart, sizeof(devpart), "%u:a", instance);
> + microgea_splash_locations[0].devpart = devpart;
> + if (!splash_source_load(microgea_splash_locations,
> + ARRAY_SIZE(microgea_splash_locations)))
> + return 0;
> + break;
> + }
> +
> + return splash_video_logo_load();
> +}
> +#endif
> +
> int board_late_init(void)
> {
> const char *fdt_compat;
> diff --git a/configs/stm32mp25-microgea-rmm_defconfig b/configs/stm32mp25-microgea-rmm_defconfig
> index 34933f1e7e41..0f1b7db7abc8 100644
> --- a/configs/stm32mp25-microgea-rmm_defconfig
> +++ b/configs/stm32mp25-microgea-rmm_defconfig
> @@ -38,6 +38,7 @@ CONFIG_CMD_PWM=y
> # CONFIG_CMD_LOADB is not set
> CONFIG_CMD_MMC=y
> CONFIG_CMD_MTD=y
> +CONFIG_CMD_BMP=y
> CONFIG_CMD_CACHE=y
> CONFIG_CMD_TIME=y
> CONFIG_CMD_RNG=y
> @@ -48,6 +49,7 @@ CONFIG_CMD_UBI=y
> CONFIG_OF_LIVE=y
> CONFIG_OF_UPSTREAM_BUILD_VENDOR=y
> CONFIG_OF_UPSTREAM_VENDOR="st"
> +CONFIG_OF_UPSTREAM_CONTROL_DT_OVERLAYS="st/stm32mp257d-engicam-microgea-rmm-overlay-rk050hr345-ct106a st/stm32mp257d-engicam-microgea-rmm-overlay-am-1280800w8tzqw-t00h"
> CONFIG_ENV_IS_NOWHERE=y
> CONFIG_ENV_IS_IN_MMC=y
> CONFIG_ENV_IS_IN_SPI_FLASH=y
> @@ -98,6 +100,20 @@ CONFIG_DM_SPI=y
> CONFIG_STM32_OSPI=y
> CONFIG_STM32_SPI=y
> # CONFIG_OPTEE_TA_AVB is not set
> +CONFIG_VIDEO=y
> +CONFIG_VIDEO_LOGO=y
> +CONFIG_SYS_WHITE_ON_BLACK=y
> +CONFIG_VIDEO_LCD_ILITEK_ILI9806E=y
> +CONFIG_VIDEO_STM32=y
> +CONFIG_VIDEO_STM32_LVDS=y
> +CONFIG_VIDEO_STM32_MAX_XRES=1280
> +CONFIG_VIDEO_STM32_MAX_YRES=854
> +CONFIG_SPLASH_SCREEN=y
> +CONFIG_SPLASH_SCREEN_ALIGN=y
> +CONFIG_SPLASH_SOURCE=y
> +CONFIG_BMP_16BPP=y
> +CONFIG_BMP_24BPP=y
> +CONFIG_BMP_32BPP=y
> CONFIG_WDT=y
> CONFIG_WDT_STM32MP=y
> CONFIG_WDT_ARM_SMC=y
Hi Dario
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
@@ -12,6 +12,11 @@
};
};
+<dc {
+ clocks = <&rcc CK_KER_LTDC>, <&rcc CK_BUS_LTDC>, <&syscfg>, <&lvds>;
+ bootph-all;
+};
+
&usart2 {
bootph-all;
};
@@ -7,3 +7,7 @@
/* Default display of the carrier board */
display=rk050hr345-ct106a
extension_overlay_addr=0x90300000
+
+splashfile=splash.bmp
+splashimage=CONFIG_SYS_LOAD_ADDR
+splashpos=m,m
@@ -8,12 +8,23 @@
#include <alist.h>
#include <config.h>
+#include <dm.h>
#include <env.h>
+#include <event.h>
#include <extension_board.h>
#include <log.h>
+#include <splash.h>
+#include <asm/arch/stm32.h>
+#include <asm/arch/sys_proto.h>
+#include <dm/device-internal.h>
#include <dm/ofnode.h>
+#include <dm/ofnode_graph.h>
+#include <dm/uclass-internal.h>
#include <linux/string.h>
+#define MICROGEA_RK050HR345 "rk050hr345-ct106a"
+#define MICROGEA_AM1280800W8TZQW "am-1280800w8tzqw-t00h"
+
int checkboard(void)
{
const char *fdt_compat;
@@ -38,6 +49,174 @@ static const char *microgea_get_display(void)
return display;
}
+/* Disable a node and unbind its device, if any */
+static int microgea_disable_node(ofnode node)
+{
+ struct udevice *dev;
+ int ret;
+
+ if (!ofnode_valid(node))
+ return 0;
+
+ if (!device_find_global_by_ofnode(node, &dev)) {
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+ }
+
+ return ofnode_set_enabled(node, false);
+}
+
+static int microgea_ltdc_connect(ofnode ltdc, ofnode ep)
+{
+ u32 ltdc_phandle, phandle;
+ ofnode ltdc_ep;
+ int ret;
+
+ ltdc_ep = ofnode_graph_get_endpoint_by_regs(ltdc, -1, -1);
+ if (!ofnode_valid(ltdc_ep) || !ofnode_valid(ep) ||
+ ofnode_read_u32(ltdc_ep, "phandle", <dc_phandle) ||
+ ofnode_read_u32(ep, "phandle", &phandle))
+ return -EINVAL;
+
+ ret = ofnode_write_u32(ltdc_ep, "remote-endpoint", phandle);
+ if (ret)
+ return ret;
+
+ return ofnode_write_u32(ep, "remote-endpoint", ltdc_phandle);
+}
+
+static int microgea_disable_compatible(const char *compat)
+{
+ return microgea_disable_node(ofnode_by_compatible(ofnode_null(),
+ compat));
+}
+
+static const struct microgea_display {
+ const char *name; /* value of the "display" env variable */
+ const char *compatible; /* compatible of its panel */
+ const char *bridge; /* compatible of its bridge, if any */
+} microgea_displays[] = {
+ {
+ .name = MICROGEA_RK050HR345,
+ .compatible = "rocktech," MICROGEA_RK050HR345,
+ },
+ {
+ .name = MICROGEA_AM1280800W8TZQW,
+ .compatible = "ampire," MICROGEA_AM1280800W8TZQW,
+ .bridge = "st,stm32mp25-lvds",
+ },
+};
+
+static bool microgea_uses_bridge(const struct microgea_display *d,
+ const char *bridge)
+{
+ return d && d->bridge && !strcmp(d->bridge, bridge);
+}
+
+/*
+ * The U-Boot devicetree includes the overlays of all the displays. Keep
+ * only the one in use, or disable the LTDC if it is not supported.
+ */
+static int microgea_settings_r(void)
+{
+ const char *display = microgea_get_display();
+ const struct microgea_display *sel = NULL, *d;
+ struct udevice *video;
+ ofnode ltdc, node, ep;
+ int i, ret;
+
+ if (uclass_find_first_device(UCLASS_VIDEO, &video) || !video)
+ return 0;
+
+ ltdc = dev_ofnode(video);
+
+ for (i = 0; i < ARRAY_SIZE(microgea_displays); i++) {
+ if (display && !strcmp(display, microgea_displays[i].name)) {
+ sel = µgea_displays[i];
+ break;
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(microgea_displays); i++) {
+ d = µgea_displays[i];
+ if (d == sel)
+ continue;
+
+ ret = microgea_disable_compatible(d->compatible);
+ if (ret)
+ return ret;
+
+ if (d->bridge && !microgea_uses_bridge(sel, d->bridge)) {
+ ret = microgea_disable_compatible(d->bridge);
+ if (ret)
+ return ret;
+ }
+ }
+
+ if (!sel)
+ return microgea_disable_node(ltdc);
+
+ node = ofnode_by_compatible(ofnode_null(), sel->compatible);
+ if (!ofnode_valid(node))
+ return microgea_disable_node(ltdc);
+
+ /* Connect the RGB panel to the LTDC */
+ if (!sel->bridge) {
+ ep = ofnode_graph_get_endpoint_by_regs(node, -1, -1);
+ return microgea_ltdc_connect(ltdc, ep);
+ }
+
+ /* The bridge does not use the LTDC pins */
+ ret = ofnode_delete_prop(ltdc, "pinctrl-names");
+ if (!ret)
+ ret = ofnode_delete_prop(ltdc, "pinctrl-0");
+ if (!ret)
+ ret = ofnode_delete_prop(ltdc, "pinctrl-1");
+ if (ret)
+ return ret;
+
+ node = ofnode_by_compatible(ofnode_null(), sel->bridge);
+ if (!ofnode_valid(node))
+ return -ENODEV;
+
+ /* Connect the bridge to the LTDC */
+ ep = ofnode_graph_get_endpoint_by_regs(node, 0, -1);
+ return microgea_ltdc_connect(ltdc, ep);
+}
+EVENT_SPY_SIMPLE(EVT_SETTINGS_R, microgea_settings_r);
+
+#if CONFIG_IS_ENABLED(SPLASH_SOURCE)
+static struct splash_location microgea_splash_locations[] = {
+ {
+ .name = "mmc",
+ .storage = SPLASH_STORAGE_MMC,
+ .flags = SPLASH_STORAGE_FS,
+ },
+};
+
+/* Load the customer splash image from its partition, else the built-in logo */
+int splash_screen_prepare(void)
+{
+ static char devpart[8];
+ u32 bootmode = get_bootmode();
+ unsigned int instance = (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1;
+
+ switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
+ case BOOT_FLASH_SD:
+ case BOOT_FLASH_EMMC:
+ snprintf(devpart, sizeof(devpart), "%u:a", instance);
+ microgea_splash_locations[0].devpart = devpart;
+ if (!splash_source_load(microgea_splash_locations,
+ ARRAY_SIZE(microgea_splash_locations)))
+ return 0;
+ break;
+ }
+
+ return splash_video_logo_load();
+}
+#endif
+
int board_late_init(void)
{
const char *fdt_compat;
@@ -38,6 +38,7 @@ CONFIG_CMD_PWM=y
# CONFIG_CMD_LOADB is not set
CONFIG_CMD_MMC=y
CONFIG_CMD_MTD=y
+CONFIG_CMD_BMP=y
CONFIG_CMD_CACHE=y
CONFIG_CMD_TIME=y
CONFIG_CMD_RNG=y
@@ -48,6 +49,7 @@ CONFIG_CMD_UBI=y
CONFIG_OF_LIVE=y
CONFIG_OF_UPSTREAM_BUILD_VENDOR=y
CONFIG_OF_UPSTREAM_VENDOR="st"
+CONFIG_OF_UPSTREAM_CONTROL_DT_OVERLAYS="st/stm32mp257d-engicam-microgea-rmm-overlay-rk050hr345-ct106a st/stm32mp257d-engicam-microgea-rmm-overlay-am-1280800w8tzqw-t00h"
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_IS_IN_SPI_FLASH=y
@@ -98,6 +100,20 @@ CONFIG_DM_SPI=y
CONFIG_STM32_OSPI=y
CONFIG_STM32_SPI=y
# CONFIG_OPTEE_TA_AVB is not set
+CONFIG_VIDEO=y
+CONFIG_VIDEO_LOGO=y
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_LCD_ILITEK_ILI9806E=y
+CONFIG_VIDEO_STM32=y
+CONFIG_VIDEO_STM32_LVDS=y
+CONFIG_VIDEO_STM32_MAX_XRES=1280
+CONFIG_VIDEO_STM32_MAX_YRES=854
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_SPLASH_SOURCE=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
CONFIG_WDT=y
CONFIG_WDT_STM32MP=y
CONFIG_WDT_ARM_SMC=y