diff options
| author | Patrick Delaunay <[email protected]> | 2022-07-27 10:38:11 +0200 |
|---|---|---|
| committer | Patrice Chotard <[email protected]> | 2025-04-25 16:00:22 +0200 |
| commit | 331b4cecc2cf5a21ce8de687dddf7d52293be202 (patch) | |
| tree | 3f6242d58328da43e0994c0d96cd33c5fd5b18bb | |
| parent | 0272e50b55cab43253b1df75fe534f382d60ee1d (diff) | |
board: st: stm32mp2: add user button support
Handle user button 2 to force boot with STM32CubeProgrammer.
Signed-off-by: Patrick Delaunay <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
| -rw-r--r-- | board/st/stm32mp2/stm32mp2.c | 26 | ||||
| -rw-r--r-- | configs/stm32mp25_defconfig | 4 |
2 files changed, 29 insertions, 1 deletions
diff --git a/board/st/stm32mp2/stm32mp2.c b/board/st/stm32mp2/stm32mp2.c index 576a958c783..6e4f19b1664 100644 --- a/board/st/stm32mp2/stm32mp2.c +++ b/board/st/stm32mp2/stm32mp2.c @@ -5,6 +5,7 @@ #define LOG_CATEGORY LOGC_BOARD +#include <button.h> #include <config.h> #include <env_internal.h> #include <fdt_support.h> @@ -13,10 +14,12 @@ #include <misc.h> #include <mmc.h> #include <asm/global_data.h> +#include <asm/io.h> #include <asm/arch/sys_proto.h> #include <dm/device.h> #include <dm/ofnode.h> #include <dm/uclass.h> +#include <linux/delay.h> /* * Get a global data pointer @@ -90,10 +93,33 @@ static int setup_led(enum led_state_t cmd) return ret; } +static void check_user_button(void) +{ + struct udevice *button; + int i; + + if (!IS_ENABLED(CONFIG_CMD_STM32PROG) || !IS_ENABLED(CONFIG_BUTTON)) + return; + + if (button_get_by_label("User-2", &button)) + return; + + for (i = 0; i < 21; ++i) { + if (button_get_state(button) != BUTTON_ON) + return; + if (i < 20) + mdelay(50); + } + + log_notice("entering download mode...\n"); + clrsetbits_le32(TAMP_BOOT_CONTEXT, TAMP_BOOT_FORCED_MASK, BOOT_STM32PROG); +} + /* board dependent setup after realloc */ int board_init(void) { setup_led(LEDST_ON); + check_user_button(); return 0; } diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig index 3d6665335f5..3f765346904 100644 --- a/configs/stm32mp25_defconfig +++ b/configs/stm32mp25_defconfig @@ -39,12 +39,14 @@ CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_MMC_ENV_DEV=-1 CONFIG_NO_NET=y CONFIG_SYS_64BIT_LBA=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_GPIO_HOG=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_STM32F7=y -CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_LED=y CONFIG_LED_GPIO=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_STM32_SDMMC2=y CONFIG_MTD=y CONFIG_USE_SYS_MAX_FLASH_BANKS=y |
