From 9c1f71060b1396fd2940e9c7b0b08f6baf1d2a36 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Fri, 25 Sep 2020 17:13:09 +0200 Subject: [PATCH] arm: Implement show_boot_progress() for imx53's HSC and DDC devices This patch provides information regarding the boot stage with using LEDs. On the very beginning of U-Boot execution the GREEN LED is turned on. When the execution is passed to Linux kernel the GREEN LED is off and RED one is ON. Afterwards, when Linux takes over the execution, the "heartbeat" driver provides indication if the board is still alive. Please also note that this patch uses {set|clr}bits_le32 macros as turning ON GREEN LED is performed in a _very_ early stage of U-Boot execution before DM_GPIOs are initialized. Signed-off-by: Lukasz Majewski --- board/k+p/kp_imx53/kp_imx53.c | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/board/k+p/kp_imx53/kp_imx53.c b/board/k+p/kp_imx53/kp_imx53.c index eb5b67d1e6..efca3e0965 100644 --- a/board/k+p/kp_imx53/kp_imx53.c +++ b/board/k+p/kp_imx53/kp_imx53.c @@ -17,11 +17,13 @@ #include #include #include +#include #include "kp_id_rev.h" #define BOOSTER_OFF IMX_GPIO_NR(2, 23) #define LCD_BACKLIGHT IMX_GPIO_NR(1, 1) #define KEY1 IMX_GPIO_NR(2, 26) +#define LED_RED IMX_GPIO_NR(3, 28) DECLARE_GLOBAL_DATA_PTR; @@ -151,3 +153,52 @@ int board_late_init(void) return ret; } + +#define GPIO_DR 0x0 +#define GPIO_GDIR 0x4 +#define GPIO_ALT1 0x1 +#define GPIO5_BASE 0x53FDC000 +#define IOMUXC_EIM_WAIT 0x53FA81E4 +/* Green LED: GPIO5_0 */ +#define GPIO_GREEN BIT(0) + +void show_boot_progress(int status) +{ + /* + * This BOOTSTAGE_ID is called at very early stage of execution. DM gpio + * is not yet initialized. + */ + if (status == BOOTSTAGE_ID_START_UBOOT_F) { + /* + * After ROM execution the EIM_WAIT PAD is set as ALT0 + * (according to RM it shall be ALT1 after reset). To use it as + * GPIO we need to set it to ALT1. + */ + setbits_le32(((uint32_t *)(IOMUXC_EIM_WAIT)), GPIO_ALT1); + + /* Configure green LED GPIO pin direction */ + setbits_le32(((uint32_t *)(GPIO5_BASE + GPIO_GDIR)), + GPIO_GREEN); + /* Turn on green LED */ + setbits_le32(((uint32_t *)(GPIO5_BASE + GPIO_DR)), GPIO_GREEN); + } + + /* + * This BOOTSTAGE_ID is called just before handling execution to kernel + * - i.e. gpio subsystem is already initialized + */ + if (status == BOOTSTAGE_ID_BOOTM_HANDOFF) { + /* + * Off green LED - the same approach - i.e. non dm gpio + * (*bits_le32) is used as in the very early stage. + */ + clrbits_le32(((uint32_t *)(GPIO5_BASE + GPIO_DR)), + GPIO_GREEN); + + /* + * On red LED + */ + gpio_request(LED_RED, "LED_RED_ERROR"); + gpio_direction_output(LED_RED, 1); + } +} -- 2.39.5