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 3F803C433EF for ; Tue, 4 Jan 2022 22:14:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC4AC8307D; Tue, 4 Jan 2022 23:13:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A9Rao1bi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82D8A83092; Tue, 4 Jan 2022 23:13:57 +0100 (CET) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 08A9E8307D for ; Tue, 4 Jan 2022 23:13:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=judge.packham@gmail.com Received: by mail-il1-x12e.google.com with SMTP id d14so29458707ila.1 for ; Tue, 04 Jan 2022 14:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=s8ue6ro/roPd5J3uxT90wUR85dOvNlxS4zVYNlceF1E=; b=A9Rao1bi9qL4pioroDGafzmWJkoIA3OuVNxX+tK6iEDLPZZDs4C59zsyz3ZtGG58nf mVHxzOin3eYoQkf9yt4QtdUXc80XjGyP1vHlFSeJTnIU5EcH7VwxOdfIr7kA2tNgOwFW +j7smeJVKNfqODtxMKOikfgEdOzT5mOU27Tk/4mUL3YU6BJRETe2fdtl+9y5V8YZEcQz SqrpiZn/zRLxn8fzby+/v0joYSE5CADAUG+pjCuulJjg/a59vZbZZGUMH2zgXg1GZvII v22wDZwqzMSzv5QLSkRw219BNthXPUb1sYtYRUjFRhpwNeDFtxHq+cdTZa8e2ajJ276V c12A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=s8ue6ro/roPd5J3uxT90wUR85dOvNlxS4zVYNlceF1E=; b=2WQ0upCA1DPrUlNtWd+AEzLwSMKiQwtPBAVNQiIK/8iafBAhP4kWRWJFtqGelMlbnJ uD9oR4VQN6TJrPr6TchYIxPc2SKNiU+Op8h9CcXo0fhLJSJnr8CHt//VXB0Zf3SdG/mw BeXRKoFwpC24SU+BrCsJjhTkxYULDqbH/l1cwKjRDkYihpjTXGl/aQjAvPnvwfY2SVEn XUtv2SmIIWIPXWFPcWTlSmSFeVeB8uicLN+oS1XgX8KItVXBtwEzOcHhUpXIazjnXT/K euD3o61uft87C4EvdxWawZzuVlv/kFMSb3MQpLNnM88swvSspyEcjJI3xzzpGk0rAKhb 1qMg== X-Gm-Message-State: AOAM532sk484NYFsJYR8BWFtnYNSB/JJO/iwnGsFDjIE1hklHBluwsbx ytJrJLYK7wBiV+quCOhP5N1mu64eRao3H7DiSI8= X-Google-Smtp-Source: ABdhPJy/ur5WtqXhdxDtHkgHwnWBHAVN+6KGxpjKHRtMcIwM7oCMKrKNdEkDVCugTmgrBPLKkZtpPHPkpc1SJyHCLD0= X-Received: by 2002:a05:6e02:b2f:: with SMTP id e15mr24490492ilu.110.1641334432828; Tue, 04 Jan 2022 14:13:52 -0800 (PST) MIME-Version: 1.0 References: <20220104145749.18626-1-kabel@kernel.org> In-Reply-To: <20220104145749.18626-1-kabel@kernel.org> From: Chris Packham Date: Wed, 5 Jan 2022 11:13:41 +1300 Message-ID: Subject: Re: [PATCH u-boot-marvell] ddr: marvell: a38x: Fix Synchronous vs Asynchronous mode determination To: =?UTF-8?B?TWFyZWsgQmVow7pu?= Cc: Chris Packham , Stefan Roese , Baruch Siach , =?UTF-8?B?UGF2b2wgUm9ow6Fy?= , u-boot , Dirk Eibach , Mario Six , Dennis Gilmore , Kostya Porotchkin , =?UTF-8?B?TWFyZWsgQmVow7pu?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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, Jan 5, 2022 at 3:57 AM Marek Beh=C3=BAn wrote: > > From: Marek Beh=C3=BAn > > Before commit 4c289425752f ("mv_ddr: a38x: add support for ddr async > mode"), Asynchornous Mode was only used when the CPU Subsystem Clock > Options[4:0] field in the SAR1 register was set to value 0x13: CPU at > 2 GHz and DDR at 933 MHz. > > Then commit 4c289425752f ("mv_ddr: a38x: add support for ddr async > mode") added support for Asynchornous Modes with frequencies other than > 933 MHz (but at least 467 MHz), but the code it added to check for > whether Asynchornous Mode should be used is wrong: it checks whether the > frequency setting in board DDR topology map is set to value other than > MV_DDR_FREQ_SAR. > > Thus boards which define a specific value, greater than 400 MHz, for DDR > frequency in their board topology (e.g. Turris Omnia defines > MV_DDR_FREQ_800), are incorrectly put into Asynchornous Mode after that > commit. > > The A38x Functional Specification, section 10.12 DRAM Clocking, says: > In Synchornous mode, the DRAM and CPU clocks are edge aligned and run > in 1:2 or 1:3 CPU to DRAM frequency ratios. > > Change the check for whether Asynchornous Mode should be used according > to this explanation in Functional Specification. > > Signed-off-by: Marek Beh=C3=BAn Tested-by: Chris Packham > --- > A PR was also created for mv-ddr-marvell: > https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/pull/35 > > Please test this. It is possible this commit will fix DDR training > issues, since commit 4c289425752f in mv-ddr-marvell started using > Asynchronous Mode where Synchronous Mode was used previously. > --- > drivers/ddr/marvell/a38x/mv_ddr_plat.c | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 deletions(-) > > diff --git a/drivers/ddr/marvell/a38x/mv_ddr_plat.c b/drivers/ddr/marvell= /a38x/mv_ddr_plat.c > index faafc86ea2..7c7bce73a3 100644 > --- a/drivers/ddr/marvell/a38x/mv_ddr_plat.c > +++ b/drivers/ddr/marvell/a38x/mv_ddr_plat.c > @@ -167,8 +167,6 @@ static u16 a38x_vco_freq_per_sar_ref_clk_40_mhz[] =3D= { > }; > > > -static u32 async_mode_at_tf; > - > static u32 dq_bit_map_2_phy_pin[] =3D { > 1, 0, 2, 6, 9, 8, 3, 7, /* 0 */ > 8, 9, 1, 7, 2, 6, 3, 0, /* 1 */ > @@ -734,7 +732,8 @@ static int ddr3_tip_a38x_set_divider(u8 dev_num, u32 = if_id, > u32 divider =3D 0; > u32 sar_val, ref_clk_satr; > u32 async_val; > - u32 freq =3D mv_ddr_freq_get(frequency); > + u32 cpu_freq; > + u32 ddr_freq =3D mv_ddr_freq_get(frequency); > > if (if_id !=3D 0) { > DEBUG_TRAINING_ACCESS(DEBUG_LEVEL_ERROR, > @@ -751,11 +750,14 @@ static int ddr3_tip_a38x_set_divider(u8 dev_num, u3= 2 if_id, > ref_clk_satr =3D reg_read(DEVICE_SAMPLE_AT_RESET2_REG); > if (((ref_clk_satr >> DEVICE_SAMPLE_AT_RESET2_REG_REFCLK_OFFSET) = & 0x1) =3D=3D > DEVICE_SAMPLE_AT_RESET2_REG_REFCLK_25MHZ) > - divider =3D a38x_vco_freq_per_sar_ref_clk_25_mhz[sar_val]= / freq; > + cpu_freq =3D a38x_vco_freq_per_sar_ref_clk_25_mhz[sar_val= ]; > else > - divider =3D a38x_vco_freq_per_sar_ref_clk_40_mhz[sar_val]= / freq; > + cpu_freq =3D a38x_vco_freq_per_sar_ref_clk_40_mhz[sar_val= ]; > + > + divider =3D cpu_freq / ddr_freq; > > - if ((async_mode_at_tf =3D=3D 1) && (freq > 400)) { > + if (((cpu_freq % ddr_freq !=3D 0) || (divider !=3D 2 && divider != =3D 3)) && > + (ddr_freq > 400)) { > /* Set async mode */ > dunit_write(0x20220, 0x1000, 0x1000); > dunit_write(0xe42f4, 0x200, 0x200); > @@ -869,8 +871,6 @@ int ddr3_tip_ext_write(u32 dev_num, u32 if_id, u32 re= g_addr, > > int mv_ddr_early_init(void) > { > - struct mv_ddr_topology_map *tm =3D mv_ddr_topology_map_get(); > - > /* FIXME: change this configuration per ddr type > * configure a380 and a390 to work with receiver odt timing > * the odt_config is defined: > @@ -882,9 +882,6 @@ int mv_ddr_early_init(void) > > mv_ddr_sw_db_init(0, 0); > > - if (tm->interface_params[0].memory_freq !=3D MV_DDR_FREQ_SAR) > - async_mode_at_tf =3D 1; > - > return MV_OK; > } > > -- > 2.34.1 >