Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A7BCC433F5 for ; Thu, 24 Feb 2022 10:01:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B725F83A86; Thu, 24 Feb 2022 11:01:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ltec.ch Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D459383B96; Thu, 24 Feb 2022 11:01:05 +0100 (CET) Received: from mail.ltec.ch (mail.ltec.ch [95.143.48.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6767C83A81 for ; Thu, 24 Feb 2022 11:01:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ltec.ch Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=fb@ltec.ch Received: from nebula.ltec ([172.27.11.2] helo=[172.27.11.35]) by mail.ltec.ch with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nNAvd-00E2lC-QI; Thu, 24 Feb 2022 11:00:53 +0100 Message-ID: <4fadcf26-87a4-4927-aa40-cd6fa063da3d@ltec.ch> Date: Thu, 24 Feb 2022 11:00:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] arm: am33xx: Fix early debug UART initialization Content-Language: en-US To: Simon Glass Cc: U-Boot Mailing List , Igor Grinberg , Enric Balletbo i Serra , Marcin Niestroj , Sjoerd Simons , Yegor Yefremov , Hannes Schmelzer , Parthiban Nallathambi , Hiremath Gireesh , Govindaraji Sivanantham , =?UTF-8?Q?Javier_Mart=c3=adnez_Canillas?= , "Andrew F . Davis" , Samuel Egli , Niel Fourie , Heiko Schocher , Dzmitry Sankouski , Igor Opaniuk , =?UTF-8?Q?Marek_Beh=c3=ban?= , Mark Kettenis , Michal Simek , Moses Christopher , Samuel Holland , Stefan Roese , Stefano Babic , Tom Rini References: <20220214165652.298701-1-fb@ltec.ch> From: Felix Brack In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Hello Simon, On 23.02.22 23:58, Simon Glass wrote: > Hi Felix, > > On Mon, 14 Feb 2022 at 09:57, Felix Brack wrote: >> >> The changes from commit 0dba45864b2a ("arm: Init the debug UART") >> prevent the early debug UART from being initialized correctly. >> By adding a new SoC specific early UART initialization function this > > SoC-specific > > You need the hyphen for this to make sense, since you are creating an adjective. > >> patch provides a generic location to add the required code. This code >> has to be SoC and not board specific. > > board-specific > >> For the am33xx SoCs the fix consist of configuring early clocks. >> >> Signed-off-by: Felix Brack >> --- >> >> arch/arm/mach-omap2/am33xx/board.c | 7 +++++++ >> drivers/serial/Kconfig | 13 +++++++++++++ >> include/debug_uart.h | 15 +++++++++++++++ >> 3 files changed, 35 insertions(+) > > More nits below. > > Reviewed-by: Simon Glass > >> >> diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c >> index c44667668e..a7f0445b93 100644 >> --- a/arch/arm/mach-omap2/am33xx/board.c >> +++ b/arch/arm/mach-omap2/am33xx/board.c >> @@ -604,3 +604,10 @@ int arch_cpu_init_dm(void) >> #endif >> return 0; >> } >> + >> +#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT) >> +void soc_debug_uart_init(void) >> +{ >> + setup_early_clocks(); >> +} >> +#endif >> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig >> index 345d1881f5..3da4064d35 100644 >> --- a/drivers/serial/Kconfig >> +++ b/drivers/serial/Kconfig >> @@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT >> value. Use this value to specify the shift to use, where 0=byte >> registers, 2=32-bit word registers, etc. >> >> +config DEBUG_UART_SOC_INIT >> + bool "Enable SoC-specific debug UART init" >> + depends on DEBUG_UART >> + help >> + Boards using the same SoC might require some common settings before >> + the debug UART can be used. The board specific board_debug_uart_init() >> + is not the right place for such common settings as they would apply >> + to a specific board only instead of all boards using the same SoC. >> + When this option is enabled, the SoC specific function >> + soc_debug_uart_init() will be called when debug_uart_init() is called. >> + You can put any code here that is needed to set up the UART ready for >> + use. > > Please mention the order in which the board and SoC functions are called. > >> + >> config DEBUG_UART_BOARD_INIT >> bool "Enable board-specific debug UART init" >> depends on DEBUG_UART >> diff --git a/include/debug_uart.h b/include/debug_uart.h >> index 714b369e6f..ebc84c44cd 100644 >> --- a/include/debug_uart.h >> +++ b/include/debug_uart.h >> @@ -42,6 +42,12 @@ >> * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the >> * functionality (printch(), etc.) >> * >> + * If your SoC needs additional init for the UART to work, enable >> + * CONFIG_DEBUG_UART_SOC_INIT and write a function called >> + * soc_debug_uart_init() to perform that init. When debug_uart_init() is >> + * called, the init will happen automatically. Board specific code does not >> + * go here, see board_debug_uart_init() below. > > Again please fix your specifics. > > >> + * >> * If your board needs additional init for the UART to work, enable >> * CONFIG_DEBUG_UART_BOARD_INIT and write a function called >> * board_debug_uart_init() to perform that init. When debug_uart_init() is >> @@ -61,6 +67,14 @@ >> */ >> void debug_uart_init(void); >> >> +#ifdef CONFIG_DEBUG_UART_SOC_INIT >> +void soc_debug_uart_init(void); >> +#else >> +static inline void soc_debug_uart_init(void) >> +{ >> +} >> +#endif >> + >> #ifdef CONFIG_DEBUG_UART_BOARD_INIT >> void board_debug_uart_init(void); >> #else >> @@ -192,6 +206,7 @@ void printdec(unsigned int value); >> \ >> void debug_uart_init(void) \ >> { \ >> + soc_debug_uart_init(); \ >> board_debug_uart_init(); \ >> _debug_uart_init(); \ >> _DEBUG_UART_ANNOUNCE \ >> -- >> 2.25.1 >> Thanks for the review! However it looks like this patch will never get applied. If I'm wrong please let me know and I'll be happy to send a fixed version. -- Regards, Felix