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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05B99C433EF for ; Wed, 3 Nov 2021 05:38:33 +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 7E1B961108 for ; Wed, 3 Nov 2021 05:38:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7E1B961108 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E9BA2834A3; Wed, 3 Nov 2021 06:38:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1635917911; bh=BT91071zCfANhnZqNrBpRHZIa4PiKXzI7slkLL5aoE4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=nhOT/GaAWk7p3L9aXX+pYjYk9la7wm4uWeJzA6obRD6/PakSMS4XToRr013mGv5B0 Frnk5h+v+Ln7hCT5JBYPLYYqysHZ1U/El0grJRHOkgjSxjmEd6SYSY0WrCo5DbJ79i G/EUS9C76Ozprgs/TzDuNBkFTy40pEkfuC2PGdybHoXXF0QN5UExeNalQtxxLicYak t2tMTJ/wh2fP+DhE4yNZWWrDfx63wKz1KMZo1xT8Xw7rOkCQDd44irxrsE09gD/lkM S69lOvxFYD/FyDQmXiT6Jlwbtd65YT+QWkmc/bl4eb2fkYJ4y3PbctQzIIPYc6NmXf 5L9E6Toj+nC8g== Received: by phobos.denx.de (Postfix, from userid 109) id 85D6B8343B; Wed, 3 Nov 2021 06:38:29 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [91.198.250.253]) (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 7C30383622 for ; Wed, 3 Nov 2021 06:38:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp102.mailbox.org (unknown [91.198.250.119]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4HkbCf2pR1zQjPn; Wed, 3 Nov 2021 06:38:22 +0100 (CET) Subject: Re: [PATCH u-boot-marvell 3/5] tools: kwboot: Increase delay after changing baudrate in ARM code To: =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de, =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20211027185702.8186-1-kabel@kernel.org> <20211027185702.8186-4-kabel@kernel.org> From: Stefan Roese Message-ID: <234ab30f-a117-eae0-508e-45be7e155638@denx.de> Date: Wed, 3 Nov 2021 06:38:18 +0100 MIME-Version: 1.0 In-Reply-To: <20211027185702.8186-4-kabel@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3E70026A 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 27.10.21 20:57, Marek Behún wrote: > From: Pali Rohár > > Increase loop cycles from 600000 to 2998272, which should increase delay > from 1ms to about 5ms on 1200 MHz CPU. > > The Number 2998272 was chosen as the nearest value around 3000000 which can > be encoded into one ARM mov instruction. It avoids usage of movt instruction > which is not supported by ARMv5te cores. > > Signed-off-by: Pali Rohár > Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > tools/kwboot.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/tools/kwboot.c b/tools/kwboot.c > index a6bfd3d4ce..84294cadfe 100644 > --- a/tools/kwboot.c > +++ b/tools/kwboot.c > @@ -119,7 +119,7 @@ static unsigned char kwboot_baud_code[] = { > /* ; writel(UART_BASE + DLL, new_dll); */ > /* ; writel(UART_BASE + DLH, new_dlh); */ > /* ; writel(UART_BASE + LCR, lcr & ~DLAB); */ > - /* ; msleep(1); */ > + /* ; msleep(5); */ > /* ; return 0; */ > /* ; } */ > > @@ -130,7 +130,7 @@ static unsigned char kwboot_baud_code[] = { > 0x01, 0x00, 0x4d, 0xe3, /* movt r0, #0xd001 */ > > /* ; r2 = address of preamble string */ > - 0xd0, 0x20, 0x8f, 0xe2, /* adr r2, preamble */ > + 0xcc, 0x20, 0x8f, 0xe2, /* adr r2, preamble */ > > /* ; Send preamble string over UART */ > /* .Lloop_preamble: */ > @@ -177,15 +177,15 @@ static unsigned char kwboot_baud_code[] = { > > /* ; Read old baudrate value */ > /* ; r2 = old_baudrate */ > - 0x8c, 0x20, 0x9f, 0xe5, /* ldr r2, old_baudrate */ > + 0x88, 0x20, 0x9f, 0xe5, /* ldr r2, old_baudrate */ > > /* ; Calculate base clock */ > /* ; r1 = r2 * r1 */ > 0x92, 0x01, 0x01, 0xe0, /* mul r1, r2, r1 */ > > /* ; Read new baudrate value */ > - /* ; r2 = baudrate */ > - 0x88, 0x20, 0x9f, 0xe5, /* ldr r2, baudrate */ > + /* ; r2 = new_baudrate */ > + 0x84, 0x20, 0x9f, 0xe5, /* ldr r2, new_baudrate */ > > /* ; Calculate new Divisor Latch */ > /* ; r1 = DIV_ROUND(r1, r2) = */ > @@ -225,10 +225,10 @@ static unsigned char kwboot_baud_code[] = { > 0x80, 0x10, 0xc1, 0xe3, /* bic r1, r1, #0x80 */ > 0x0c, 0x10, 0x80, 0xe5, /* str r1, [r0, #0x0c] */ > > - /* ; Sleep 1ms ~~ 600000 cycles at 1200 MHz */ > - /* ; r1 = 600000 */ > - 0x9f, 0x1d, 0xa0, 0xe3, /* mov r1, #0x27c0 */ > - 0x09, 0x10, 0x40, 0xe3, /* movt r1, #0x0009 */ > + /* ; Loop 0x2dc000 (2998272) cycles */ > + /* ; which is about 5ms on 1200 MHz CPU */ > + /* ; r1 = 0x2dc000 */ > + 0xb7, 0x19, 0xa0, 0xe3, /* mov r1, #0x2dc000 */ > /* .Lloop_sleep: */ > 0x01, 0x10, 0x41, 0xe2, /* sub r1, r1, #1 */ > 0x00, 0x00, 0x51, 0xe3, /* cmp r1, #0 */ > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de