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 B1C35C00140 for ; Mon, 8 Aug 2022 18:03:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B6FD81DAB; Mon, 8 Aug 2022 20:03:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de 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=suse.de header.i=@suse.de header.b="RzCaCES0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="un+uV7E9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E0A1B81DAB; Mon, 8 Aug 2022 20:03:32 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 01E2280F3E for ; Mon, 8 Aug 2022 20:03:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BF6711F893; Mon, 8 Aug 2022 18:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1659981809; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OHOpfJu+dQLEVMNoAuOLKfBxCx6sCzvfwvys/iznqzk=; b=RzCaCES0bbfYaBP3ALz8+JpoYn3yGJQYwiYgg+AFvIekoaYQsRcvyKpsQ7jKGUyZZheWLp yShQjc/Gfx+GU0AbtwZZHmWkR61DR4vu3sqR7j8Lq8J95/NU1zhmfqHa0uMjrmBsv0iLYl KPOJwGJk774tFwuZCkqpFj/Z/Oind3Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1659981809; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OHOpfJu+dQLEVMNoAuOLKfBxCx6sCzvfwvys/iznqzk=; b=un+uV7E95Qkb2l2XpEcYibqgJQdNWEiDlOMBBhZzjYuOHsKA7lrPUIMU74OOZQkvi6/yXi XGB45NzJbRjJMACw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5FB292C143; Mon, 8 Aug 2022 18:03:29 +0000 (UTC) Date: Mon, 8 Aug 2022 20:03:28 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Xavier Drudis Ferran Cc: u-boot@lists.denx.de, Simon Glass , Philipp Tomsich , Kever Yang , Lukasz Majewski , Sean Anderson Subject: Re: [PATCH] arm: rockchip: rk3399: Program PLL clock for DDR at 50 MHz in documented range Message-ID: <20220808180328.GN17705@kitsune.suse.cz> References: <20220716103144.GA2167@begut> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220716103144.GA2167@begut> User-Agent: Mutt/1.10.1 (2018-07-13) 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.6 at phobos.denx.de X-Virus-Status: Clean On Sat, Jul 16, 2022 at 12:31:45PM +0200, Xavier Drudis Ferran wrote: > The original code set up the DDR clock to 48 MHz, not 50MHz as > requested, and did it in a way that didn't satisfy the Application > Notes in RK3399 TRM [1]. 2.9.2.B says: > > PLL frequency range requirement > [...] > FOUTVCO: 800MHz to 3.2GHz > > 2.9.2.A : > PLL output frequency configuration > [...] > FOUTVCO = FREF / REFDIV * FBDIV > FOUTPOSTDIV = FOUTVCO / POSTDIV1 / POSTDIV2 > > FREF = 24 MHz > > The original code gives FOUTVCO: 24MHz/1 * 12 = 288MHz < 800MHz > And the resulting FOUTPOSTDIV is 288MHz / 3 / 2 = 48MHz > but the requested frequency was 50MHz > > Note: > 2.7.2 Detail Register Description > PMUCRU_PPLL_CON0 says > > fbdiv > Feedback Divide Value > Valid divider settings are: > [16, 3200] in integer mode > > So .fbdiv = 12 wouldn't be right. But 2.9.2.C says: > > PLL setting consideration > [...] > The following settings are valid for FBDIV: > DSMPD=1 (Integer Mode): > 12,13,14,16-4095 (practical value is limited to 3200, 2400, or 1600 > (FVCOMAX / FREFMIN)) > [...] > > So .fbdiv = 12 would be right. > > In any case FOUTVCO is still wrong. I thank YouMin Chen for > confirmation and explanation. > > Despite documentation, I don't seem to be able to reproduce a > practical problem with the wrong FOUTVCO. When I initially found it I > thought some problems with detecting the RAM capacity in my Rock Pi 4B > could be related to it and my patch seemed to help. But since I'm no > longer able to reproduce the issue, it works with or without this > patch. And meanwhile a patch[2] by Lee Jones and YouMin Chen addresses > this issue. Btw, shouldn't that be commited? > > So this patches solves no visible problem. Yet, to prevent future > problems, I think it'd be best to stick to spec. > > An alternative to this patch could be > > {.refdiv = 1, .fbdiv = 75, .postdiv1 = 6, .postdiv2 = 6}; > > This would theoretically consume more power and yield less jitter, > according to 2.9.2.C : > > PLL setting consideration > [...] > For lowest power operation, the minimum VCO and FREF frequencies > should be used. For minimum jitter operation, the highest VCO and > FREF frequencies should be used. > [...] > > But I haven't tried it because I don't think it matters much. 50MHz > for DDR is only shortly used by TPL at RAM init. Normal operation is > at 800MHz. Maybe it's better to use less power until later when more > complex software can control batteries or charging or whatever ? > > Cc: Simon Glass > Cc: Philipp Tomsich > Cc: Kever Yang > Cc: Lukasz Majewski > Cc: Sean Anderson > > Link: [1] https://www.rockchip.fr/Rockchip%20RK3399%20TRM%20V1.4%20Part1.pdf > > Link: [2] https://patchwork.ozlabs.org/project/uboot/list/?series=305766 > > Signed-off-by: Xavier Drudis Ferran The incorrect clock settings trigger an assert and prevent the board from booting when clock debugging is enabled. Fix works for me on Pinebook Pro. Thanks Michal Tested-by: Michal Suchánek > --- > drivers/clk/rockchip/clk_rk3399.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c > index 7d31a9f22a..4762462b04 100644 > --- a/drivers/clk/rockchip/clk_rk3399.c > +++ b/drivers/clk/rockchip/clk_rk3399.c > @@ -840,7 +840,7 @@ static ulong rk3399_ddr_set_clk(struct rockchip_cru *cru, > switch (set_rate) { > case 50 * MHz: > dpll_cfg = (struct pll_div) > - {.refdiv = 1, .fbdiv = 12, .postdiv1 = 3, .postdiv2 = 2}; > + {.refdiv = 2, .fbdiv = 75, .postdiv1 = 3, .postdiv2 = 6}; > break; > case 200 * MHz: > dpll_cfg = (struct pll_div) > -- > 2.20.1 >