From 31e9750bc17bd472d4f2a3db297461efc301be51 Mon Sep 17 00:00:00 2001 From: Lionel Debieve Date: Tue, 2 Jul 2019 18:03:34 +0200 Subject: [PATCH] feat(st-clock): check HSE configuration in serial boot In case of programmer mode, the bootrom manages to auto-detect HSE clock configuration. In order to detect a bad device tree setting in BL2, it will crash during programming if the configuration is not aligned with the auto-detection. Signed-off-by: Lionel Debieve Change-Id: I230697695745d6282d14b1ebfa6e4c4caa0cd8e2 --- drivers/st/clk/stm32mp1_clk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/st/clk/stm32mp1_clk.c b/drivers/st/clk/stm32mp1_clk.c index c92bb542b..be8ea20ab 100644 --- a/drivers/st/clk/stm32mp1_clk.c +++ b/drivers/st/clk/stm32mp1_clk.c @@ -1350,6 +1350,13 @@ static void stm32mp1_hse_enable(bool bypass, bool digbyp, bool css) if (css) { mmio_write_32(rcc_base + RCC_OCENSETR, RCC_OCENR_HSECSSON); } + +#if STM32MP_UART_PROGRAMMER || STM32MP_USB_PROGRAMMER + if ((mmio_read_32(rcc_base + RCC_OCENSETR) & RCC_OCENR_HSEBYP) && + (!(digbyp || bypass))) { + panic(); + } +#endif } static void stm32mp1_csi_set(bool enable) -- 2.39.5