From mboxrd@z Thu Jan 1 00:00:00 1970 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 1DEF1C433EF for ; Tue, 15 Feb 2022 12:37:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AB292839F5; Tue, 15 Feb 2022 13:37:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="Du8RCzHd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC571839F5; Tue, 15 Feb 2022 13:37:21 +0100 (CET) Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E53AF80F47 for ; Tue, 15 Feb 2022 13:37:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x832.google.com with SMTP id x5so18329856qtw.10 for ; Tue, 15 Feb 2022 04:37:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aGkILysNNOWsAGYF2O/5dszugZaoLB8LDn9kwVpMhXE=; b=Du8RCzHdZY5gLufDdrqu+kNNQsZRhcPE7x7zoL1+2Dho45VGxmIsX0q9RRHsCtZuAd 8DfApoJ1tzKeyLJqvXc7wJpyZ6KYKUvHRYLaKJyjUV0HSc86E4Wl1ngNK/rq7M0RunjB T6dQOBviDTmSfZHoXK50CUZvKUBfpwUEA37/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aGkILysNNOWsAGYF2O/5dszugZaoLB8LDn9kwVpMhXE=; b=8G/VSl5qrScK8KCyBix9oUKkGF1Czoi6km0heOpaqDzYHL32JE3DLMjSlVIC9BN29k aF/hQRId+1xSd/T8NcYeyGuUjIvXdQiJk8m7hOwCXTZz6VlTJjvnFMgEkkWd++4FlmYL wRwDJ/ZABXXpgq1zM2nI9OVSL/es/c7cbdKxEyPqqNlwkx1mGKAhZTR6MIGx7ObZ6aHi d2P2HuzZX/UQORIGupmyvo/7h6c8MoZqVPv9yAFO2yNYK99BEEiNUt1c57ddeoCjAXNQ 1HdcKDcWWqczVY89ZwPbYhDsHWChptosi3L9mKmrRhF4vUpUqCswUtVWAft/tiU3dlZs jp0A== X-Gm-Message-State: AOAM530dlhdUNhzfoMImIHNwG0IYpzXkJKDwThfDnJIfm96SpzKb/eay KI1N92nhMeWMeBR5WIjho3ABvQ== X-Google-Smtp-Source: ABdhPJye/G3NbhRtTrUtKZQsQqO/9rYTG0xUXbIk4pmVvSI650l5dHPbcJn8PfZAJTuPWLh+gu8lKw== X-Received: by 2002:a05:622a:254:: with SMTP id c20mr2368781qtx.407.1644928636646; Tue, 15 Feb 2022 04:37:16 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-2ef0-5dff-fedb-a8ba.res6.spectrum.com. [2603:6081:7b01:cbda:2ef0:5dff:fedb:a8ba]) by smtp.gmail.com with ESMTPSA id y15sm17362604qko.95.2022.02.15.04.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 04:37:15 -0800 (PST) Date: Tue, 15 Feb 2022 07:37:13 -0500 From: Tom Rini To: Felix Brack Cc: u-boot@lists.denx.de, Igor Grinberg , Enric Balletbo i Serra , Marcin Niestroj , Sjoerd Simons , Yegor Yefremov , Hannes Schmelzer , Parthiban Nallathambi , Hiremath Gireesh , Govindaraji.Sivanantham@in.bosch.com, Javier =?iso-8859-1?Q?Mart=EDnez?= Canillas , "Andrew F . Davis" , Samuel Egli , Niel Fourie , sjg@chromium.org, Heiko Schocher , Dzmitry Sankouski , Igor Opaniuk , Marek =?iso-8859-1?Q?Beh=FAn?= , Mark Kettenis , Michal Simek , Moses Christopher , Samuel Holland , Stefan Roese , Stefano Babic Subject: Re: [PATCH] arm: am33xx: Fix early debug UART initialization Message-ID: <20220215123713.GO3521085@bill-the-cat> References: <20220214165652.298701-1-fb@ltec.ch> <20220214224520.GN3521085@bill-the-cat> <0b0e5aeb-8a48-3b63-1222-e3c98ade3eb8@ltec.ch> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gm5TwAJMO0F2iVRz" Content-Disposition: inline In-Reply-To: <0b0e5aeb-8a48-3b63-1222-e3c98ade3eb8@ltec.ch> X-Clacks-Overhead: GNU Terry Pratchett 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 --gm5TwAJMO0F2iVRz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 15, 2022 at 11:53:41AM +0100, Felix Brack wrote: > Hello Tom, >=20 > On 14.02.22 23:45, Tom Rini wrote: > > On Mon, Feb 14, 2022 at 05:56:52PM +0100, 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 > >> patch provides a generic location to add the required code. This code > >> has to be SoC and not 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(+) > >> > >> 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=3Dbyte > >> registers, 2=3D32-bit word registers, etc. > >> =20 > >> +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_in= it() > >> + 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 cal= led. > >> + You can put any code here that is needed to set up the UART ready = for > >> + use. > >> + > >> 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 do= es not > >> + * go here, see board_debug_uart_init() below. > >> + * > >> * 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); > >> =20 > >> +#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 \ > >=20 > > I'd be inclined to just re-use board_debug_uart_init on am33xx like > > other "board" function we have in the SoC level board.c file. That's > > likely what other platforms are doing as well where this is more SoC > > than board dependent? Thanks for digging in here BTW, I think I never > > saw this myself when I needed the UART because I have mine set for UART > > boot first (and then it does SD boot). > >=20 > On the PDU001 board the board specific board_debug_uart_init() is (for > now) responsible for the pin configuration of UART3 (the debug UART). > From a discussion with Simon I concluded that other boards based on the > AM33XX SoCs are also affected from the problem introduced with commit > 0dba45864b2a. > The function board_debug_uart_init() can not be moved to the SoC level > since some boards (like the PDU001) require it. Hence the idea of a SoC > specific soc_debug_uart_init() function. > However I now realize that such a "one fits it all" solution is probably > not the right way to fix things. It might be better to fix this on board > level especially since there are some boards that are not affected at all. > Hence I think it is best to drop my patch. I will send a new patch > fixing the problem for the PDU001 board specifically. Ah, OK, thanks. --=20 Tom --gm5TwAJMO0F2iVRz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmILnnYACgkQFHw5/5Y0 tyzYyAv/TLQRZ0c3vD80D0Gu/qPJBmFrYTJ3soDBykLO4hUvg3QBScIbVbdGW5Gs 2/KiO9AE2cgfQYpDWCVGqUb8IZacazkqlZI3BI02dFtcVU6D28lPeXFms6/Q2Nrg ZxAre1WPVQFXWChKXZIxVcBQgzIABMuEGjbCFTI9mb5cRkxzqAkWm0NGurB91m0R PgpVBwZNWZlkzkCqItWqwTTyecXQD2YAjEoxqpTFzlQGk6AcNOZRWvtGzGXDD2Wi yDGQ0AiYEiQqSTFZFPMIEB5bYo5VtciZPhxyRjVr6Edj5NXza+zRlzDLufGEINmW W/h8rrhad4Q/qmn2aUi5ZNyn7DPw1TDNM9TpWhHwHQmpTqqI287xhWnq46D3G0zo rqBR8bLp+LJRdLKpN3nnOdVn3JStzb89XYpbAVTwn9jiHKCE1HjDlCODBDfGNVtb M5zsc/fLFlVqUjU+67oCWSxbDGL7slfkK5hOQgcROxpQYwm0qRDmn4YUENe0gV5Y S6XomuGR =Byav -----END PGP SIGNATURE----- --gm5TwAJMO0F2iVRz--