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 778F2C433EF for ; Mon, 14 Feb 2022 22:45:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91B0C83841; Mon, 14 Feb 2022 23:45:30 +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="ZfXQPDNc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 806A083841; Mon, 14 Feb 2022 23:45:28 +0100 (CET) Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) (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 7E5FF836BE for ; Mon, 14 Feb 2022 23:45:24 +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-qv1-xf31.google.com with SMTP id fh9so16124970qvb.1 for ; Mon, 14 Feb 2022 14:45:24 -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=H4C5EK6mabSGDkaY1EfUDS8/XgauSQKbpVJIO6BT3Bs=; b=ZfXQPDNcQE32oMDIMmDYa4c4JLx8alaz+BTbnsPPalZbbvyn0JAXQrAZv3BKDu8tJA F8WqVWD4cvym+JYsyjXH4kCx4gtAOLO1nPINTT5wrzBj6fT01vD5MuI7A5OLZrsYVj9r Y6CrV7c4mRZh8swz4DAXCobZoubzjZADhhzZ8= 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=H4C5EK6mabSGDkaY1EfUDS8/XgauSQKbpVJIO6BT3Bs=; b=EgNf/wQQe3INa2dVltSQtzaSzjMHKhaCbp0uVz/ib9c6nQF//SEJ9O9BZq9x2yiloe MxIfEbWSOjeZXcdEBjozTiHVDSLkP8KGR/w1jvjcF9oECPC0gFdaTZuOPFg0aMju/kLO nSV9T++PAjHfX2dzbAr8c+JC54JOBgHny/BYd8bQg+zmhIm8sG08GiswCyLDlmr4ghl6 2aN9/WyPxVR5JrEwF5Bwh4WZTTB/QpIHZ9wdBeEqYxCxngK6uBuNQ+APTnGjpc3ONziq UbqchNPb7t1VP/YmaLpUuFcJEvWwhA8jbvTfz1cI0xdDb7N/J4DSXxraFzsmKzg5y7Oi FsUQ== X-Gm-Message-State: AOAM532XgzrkfhN1GrhUDMXuumfR7Z1vKvFvxnEs1bk+JMt9kLe0tgVR BU21FCb7APdBFgKA/L3t0VJkdA== X-Google-Smtp-Source: ABdhPJyJSTzjpXQVVXQ9djl88+wuJDoqGWhGcljCFmGhzfAGKvGYS9dx8nOvPxoKivSkbaENAXwzow== X-Received: by 2002:ad4:4eaa:: with SMTP id ed10mr797114qvb.85.1644878723100; Mon, 14 Feb 2022 14:45:23 -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 o13sm19006192qtx.22.2022.02.14.14.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 14:45:22 -0800 (PST) Date: Mon, 14 Feb 2022 17:45:20 -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: <20220214224520.GN3521085@bill-the-cat> References: <20220214165652.298701-1-fb@ltec.ch> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gdTfX7fkYsEEjebm" Content-Disposition: inline In-Reply-To: <20220214165652.298701-1-fb@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 --gdTfX7fkYsEEjebm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Felix Brack > --- >=20 > arch/arm/mach-omap2/am33xx/board.c | 7 +++++++ > drivers/serial/Kconfig | 13 +++++++++++++ > include/debug_uart.h | 15 +++++++++++++++ > 3 files changed, 35 insertions(+) >=20 > diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am3= 3xx/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_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. > + > 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. > + * > * 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 \ 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 Tom --gdTfX7fkYsEEjebm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmIK23wACgkQFHw5/5Y0 tywVTgv/RCyoh08gZ6+civCR/IVC0gCVf7+vA3DXNKWLHiQc3fQi2M6hxMHuVca7 7wlkZYwd9haXggVESPHNBj1Q1BsTLWBKjUGn7APMNLsKvghNaV3+/b3Ks/qjugiU mEL6YQnELgWjvMj9mCkK2x4H2AWI/8trgdiMK3jQS4BHjZo2wqNYXWy+zkoB8HmW 90tWs76VJLf+9lklP+uOy/u6/RrB/VmrGsoHYAEeQQiMjTbozjye7LLJjQyRG7/j ilTmzUuXqYPFbsXb9AQpWqTYTE9n/ChjVpVGwvu/sfxqkzD/CzbcIBNmE2TFhLlI hCx3pJsCfHc4IDg/FFBTWZLwDR13dpPlDKc8ETlEL5C494+oSQcr10q12lMOAnRV DKgL+7S786z8lOA/xbVy5wXX1cg5AIk+CqlXarhwHzsS8xkeHwafnsqeVWnQjosh +favhjZ6FK73r0W8qphlLW0t+6cEbYI/56/xdALGOctXrZUP2aXlt7+DKlNNKD4D NK+bGpV2 =4ve+ -----END PGP SIGNATURE----- --gdTfX7fkYsEEjebm--