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 X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5A3AC07E96 for ; Thu, 15 Jul 2021 06:15:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B2CDB61358 for ; Thu, 15 Jul 2021 06:15:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2CDB61358 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E643829CA; Thu, 15 Jul 2021 08:15:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gerhold.net header.i=@gerhold.net header.b="dW1uiMiC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 76881829CA; Thu, 15 Jul 2021 08:15:45 +0200 (CEST) Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.221]) (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 8204F80C8A for ; Thu, 15 Jul 2021 08:15:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=stephan@gerhold.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1626329741; s=strato-dkim-0002; d=gerhold.net; h=In-Reply-To:References:Message-ID:Subject:Cc:To:From:Date:Cc:Date: From:Subject:Sender; bh=1pXOrhsOQpJyNT7fwOqaWAVwDN/b59NKSA/j0TeLPkk=; b=dW1uiMiCcmnU0eByjSvHgMbFGqHNTTwLMvuSuidg6wVVnOVK7DwCw+c3s48TXAF7cR xQVPwrBgqOR1uF+1tfxW/J6DowF/YWCGGtw5Avg7We0c7d4/Afu6p/1BW6kyBa7n1Atj Y4ZJkEcoGANa974d+BKDclID+aDwCShwHfgexYLeN0A4rwdV00p8sjwTDmG/EPdN75TD aBA6j80Io4wkft8eohj+l+3iaY+QPLDTFvoOcAX1VuQTfCZGiFRor1tLq8BDmYMO5sDZ MbmWB0/KlXE/Tc1KtGre8dNXTtlPyOqSqBHNW5eQnNuVYOjdef/8VoAQLGYR4hSi7Q4y 8rbQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVOQ/OcYgojyw4j34+u26zEodhPgRDZ8nwIc3ABg==" X-RZG-CLASS-ID: mo00 Received: from gerhold.net by smtp.strato.de (RZmta 47.28.1 DYNA|AUTH) with ESMTPSA id g02a44x6F6Ff2aI (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 15 Jul 2021 08:15:41 +0200 (CEST) Date: Thu, 15 Jul 2021 08:15:33 +0200 From: Stephan Gerhold To: Ramon Fried Cc: U-Boot Mailing List , Nicolas Dechesne Subject: Re: [PATCH 3/3] serial: serial_msm: Delay initialization to let pins stabilize Message-ID: References: <20210714085626.5961-1-stephan@gerhold.net> <20210714085626.5961-4-stephan@gerhold.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Wed, Jul 14, 2021 at 11:39:34PM +0300, Ramon Fried wrote: > On Wed, Jul 14, 2021 at 11:56 AM Stephan Gerhold wrote: > > > > For some reason, the DragonBoard 410c aborts autoboot immediately if > > U-Boot is started without LK. It looks like it picks up a single broken > > character via serial and therefore believes a key was pressed to abort > > autoboot. > > > > After some debugging, it seems like adding some delay after pinctrl > > setup but before UART initialization fixes the issue. It's also worth > > mentioning that unlike when booting from LK, the pinctrl setup is > > actually necessary when booting U-Boot without LK since UART is broken > > if the pinctrl line is removed. > > > > I suspect that reconfiguring the pins might take some time to stabilize > > and if the UART controller is enabled too quickly it will pick up some > > random noise. Adding a few milliseconds of delay fixes the issue and > > shouldn't have any other negative side effects. > > > > 3ms seems to be the minimum delay required in my tests, use 5ms instead > > just to be sure. > > > > Signed-off-by: Stephan Gerhold > > --- > > > > drivers/serial/serial_msm.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c > > index d8dd5c1104..ac4d0824b9 100644 > > --- a/drivers/serial/serial_msm.c > > +++ b/drivers/serial/serial_msm.c > > @@ -18,6 +18,7 @@ > > #include > > #include > > #include > > +#include > > #include > > > > /* Serial registers - this driver works in uartdm mode*/ > > @@ -193,6 +194,9 @@ static int msm_uart_clk_init(struct udevice *dev) > > > > static void uart_dm_init(struct msm_serial_data *priv) > > { > > + /* Delay initialization for a bit to let pins stabilize if necessary */ > > + mdelay(5); > > + > > writel(priv->clk_bit_rate, priv->base + UARTDM_CSR); > > writel(0x0, priv->base + UARTDM_MR1); > > writel(MSM_BOOT_UART_DM_8_N_1_MODE, priv->base + UARTDM_MR2); > > -- > > 2.32.0 > > > Eh...this is not a nice fix, perhaps just clearing the RX buffer after > initialization will work better ? I don't like it much either but this is the best I came up with even after spending several hours trying to track down the problem. I also tried porting more register initialization from LK, probably even tried clearing the RX buffer again after initialization. The problem is: In my tests there was no way to get rid of the delay, because the character doesn't show up until a few milliseconds after initialization. What you suggest would only work like this: mdelay(5); // Wait for the weird character to show up Which is not much different (and in fact will take longer) than: mdelay(5); So unfortunately I can't think of a way to get rid of the delay. :( I'm not sure if this is some strange problem of my DB410c, I'd actually be curious if the problem can also be reproduced on others. Stephan