From patchwork Sat Nov 11 10:46:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3010 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id CDD0E3F057 for ; Sat, 11 Nov 2023 11:46:32 +0100 (CET) Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2c53c85e482sf26890371fa.1 for ; Sat, 11 Nov 2023 02:46:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699699592; cv=pass; d=google.com; s=arc-20160816; b=mJL4zn3BaaAir3w1CT8CThwEh0uuIYgEmzyZ/TGe45mUBa62N5kPtilgovz17pBm0d zgwNRvVLrgzqxEGJNBiNDDCA5kxRjya7rifTm+g+3UktELoj5/b8CoESU/MY9wkDDb6C XNABxEikIpR3spnKVjwM07FyEGg1OKQaGwY/jMACsLl3YFqCCm21PBQqSoeH5o72cbco 0G5VYmDkvC9H6bt3IJHM+0xEGFzh2Fg8MS8BXxFtU3SZzapWrWQj3yj7o1bWV7uExnLb +w/uZwN4YJwkuoALehFvJLppKN76l/nF3fdeAarzVIQP7H0OqsePp1JpnMoX9vY8zQDX c87w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=RP95N0hTwpqSrSHde/9nkzYffgAZVaK0OxtFFj6dDCU=; fh=ds9USgbgWjZXzDE7c+iz74F/2F0XZe7HabgW5yBrOTg=; b=sNBurirAB/h+tcDBO7c9Q1cytQom3ro2Fp35u2LT7DXVS2AGe4Sh+2REVmZSAgmRvB hd9RWQhhrXP2y/1Bpg5D1+VDB00RocflMHcAeq13sbPq43jfjv8LmpOduG9A8hyBi7Io fM8NpZUU2D6UPthBZOFW23v4tV3LMmxhcTRLtnwXW8BGk/ZEQ4VaAYPDv6JIRL1Hv2wS kB4xkMMGnw7s9GvwPIUZtQL3wflYTCsScJey46lKWb3Vdm90TLbnpYzd2f3ZmKpd0P4E Zx9Fs7uG1P/H9UmjFKQB08wTSNaNrXpcQB9G/TL395BUcRFzCWNLyAI1In9En5Pym7fd qtqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H9s0GRFn; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1699699592; x=1700304392; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=RP95N0hTwpqSrSHde/9nkzYffgAZVaK0OxtFFj6dDCU=; b=anA4OqKFIgVP36ptSsee2e+SMkVm/QtFUKRqYi1xTeUf0QMMpS3wYZN/C0GGvWNZ6b NA2BEiHvXc8o+PlohuPkCsLomnNWE3PXmomwy3zB+um1mExdW447e8owxQ7IlOT4ZlPu h+usbJ49NRk41aUuyvA4KouPhsdGOhZtzAAjk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699699592; x=1700304392; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RP95N0hTwpqSrSHde/9nkzYffgAZVaK0OxtFFj6dDCU=; b=TE7lDCK1RSJcmp0FHXTChKOGnGd1/cdfFdBYxFICwJ1b3nHw/krdyjk24UQtG1KDVP lGh5lYUZw9ng2QCmR/An48yqTfYN/bAt/vGjcBZspk/ktJ6r/hd8q5V6QB1tO3TehZiZ jNRJHWtZGEY9+UjC+74LU7FrG7berOkVP56V4R5QGHtL4ES/GisBFbo8z2uAX26KCEU0 /2TAL+yWtmdtJQArrCbtvN+uiDAy6fSO0joM8s0GEAJE6QIcR+lDTNIXMlz5RvnKkKlo BTgzLHztVvokVJt+Ay5XOGof28QYQIODgfIZ298GgOMwNOSOxbtQgGvnfHk9Po7RN+KM 17KQ== X-Gm-Message-State: AOJu0Yytm7a+XnjIPhwlxeqEaDHejPlaaC99ZzL/hlJQTBab+D44trLR ovgVDzzHnyMUVioO7VWohyzEJyyliwiVhmk9 X-Google-Smtp-Source: AGHT+IGSVtDQ4H14vBdiXOhzFTmOFx46yQtMCZUtHXMpI9Zie1xUsqE3nVzcUXbHs2owifz6/tTsaQ== X-Received: by 2002:ac2:4307:0:b0:509:1790:e1d5 with SMTP id l7-20020ac24307000000b005091790e1d5mr967171lfh.28.1699699592128; Sat, 11 Nov 2023 02:46:32 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:3c9f:b0:500:7f17:b77d with SMTP id h31-20020a0565123c9f00b005007f17b77dls117792lfv.2.-pod-prod-01-eu; Sat, 11 Nov 2023 02:46:30 -0800 (PST) X-Received: by 2002:a05:6512:2116:b0:505:79f2:5c6c with SMTP id q22-20020a056512211600b0050579f25c6cmr931499lfr.6.1699699590414; Sat, 11 Nov 2023 02:46:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699699590; cv=none; d=google.com; s=arc-20160816; b=cbjsb3hB36uFTTIosvCcSQLbluJ2R6M3+Q37seD4K43CTDOhJxW21Ots557oZ+8GLp gpK+tlf/kF987j63pyU483aV6cQ+Yxuf8aY9zA1oV84j3id+cT9nF5sg9glxfkjaTESm gkdoDvPdpf+WjwOEI0oy1Ya5qGQk3o+xQBzNB4BWcmj1Vb4nsmtvYL9npISlgnSD9k87 BtyU7qrqem0IaBvPdj2cwm4D48P6o9iXucWNJ0z+l66mi1p0QeZdsOGnQK0P2a2vA/jG RHTc3mwwRhbwWtpuUOx8Z61nSGP5wlSHPeM/68FMyI9SBPuGWzc4crc5W8FKLwImnNrq qyrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ScYicUFHb+qoluDbgLSAgAArMfhmqdSv2yQ/g84t7ys=; fh=ds9USgbgWjZXzDE7c+iz74F/2F0XZe7HabgW5yBrOTg=; b=hixFFdvQ6S+ULBHggdvhnypzvfncdEI/EatsGjGpFHTAzatco6qj0n5FzuXkk0HcgI HsfhkVFq1Y5YqlBrd5ssyvGqJGhRUguSu5oqEOrl2ls8WFFXu4EYTN0r6KyHojyumXvf lVpgQrwZJRksWlNsK3wgiYz9fF9Rf2plD0ADlPOHREpMopJbo9mJQiOr/7+/+N9Cx9KQ RKtZ0eDmkJ3RdkvywJg2XVAUhUSXCAjBEkxJo36Fbx3NPP2t2szEFJ9104J9G4ndXXTl 6wmXVlhy+S2nEB/Siop00hAy23DzvX0F+BhortH+DTJwALa+abihlLY/TDkaCurqDU1g UckQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H9s0GRFn; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id w18-20020a50d792000000b00537fa220bfesor210033edi.3.2023.11.11.02.46.30 for (Google Transport Security); Sat, 11 Nov 2023 02:46:30 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:510:b0:543:7256:6370 with SMTP id m16-20020a056402051000b0054372566370mr1234240edv.23.1699699590143; Sat, 11 Nov 2023 02:46:30 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-20-97-182.retail.telecomitalia.it. [79.20.97.182]) by smtp.gmail.com with ESMTPSA id c19-20020a50f613000000b00542d3e470f9sm827534edn.10.2023.11.11.02.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Nov 2023 02:46:29 -0800 (PST) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Lukasz Majewski , Patrice Chotard , Patrick Delaunay , Sean Anderson , uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH 2/2] clk: stm32f: fix setting of LCD clock Date: Sat, 11 Nov 2023 11:46:19 +0100 Message-ID: <20231111104625.137511-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231111104625.137511-1-dario.binacchi@amarulasolutions.com> References: <20231111104625.137511-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H9s0GRFn; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Set pllsaidivr only if the PLLSAIR output frequency is an exact multiple of the pixel clock rate. Otherwise, we search through all combinations of pllsaidivr * pllsair and use the one which gives the rate closest to requested one. Fixes: 5e993508cb25 ("clk: clk_stm32f: Add set_rate for LTDC clock") Signed-off-by: Dario Binacchi Reviewed-by: Patrice Chotard --- drivers/clk/stm32/clk-stm32f.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/clk/stm32/clk-stm32f.c b/drivers/clk/stm32/clk-stm32f.c index 4c1864193357..d68c75ed2013 100644 --- a/drivers/clk/stm32/clk-stm32f.c +++ b/drivers/clk/stm32/clk-stm32f.c @@ -522,18 +522,20 @@ static ulong stm32_set_rate(struct clk *clk, ulong rate) /* get the current PLLSAIR output freq */ pllsair_rate = stm32_clk_get_pllsai_rate(priv, PLLSAIR); - best_div = pllsair_rate / rate; - - /* look into pllsaidivr_table if this divider is available*/ - for (i = 0 ; i < sizeof(pllsaidivr_table); i++) - if (best_div == pllsaidivr_table[i]) { - /* set pll_saidivr with found value */ - clrsetbits_le32(®s->dckcfgr, - RCC_DCKCFGR_PLLSAIDIVR_MASK, - pllsaidivr_table[i] << - RCC_DCKCFGR_PLLSAIDIVR_SHIFT); - return rate; - } + if ((pllsair_rate % rate) == 0) { + best_div = pllsair_rate / rate; + + /* look into pllsaidivr_table if this divider is available */ + for (i = 0 ; i < sizeof(pllsaidivr_table); i++) + if (best_div == pllsaidivr_table[i]) { + /* set pll_saidivr with found value */ + clrsetbits_le32(®s->dckcfgr, + RCC_DCKCFGR_PLLSAIDIVR_MASK, + pllsaidivr_table[i] << + RCC_DCKCFGR_PLLSAIDIVR_SHIFT); + return rate; + } + } /* * As no pllsaidivr value is suitable to obtain requested freq,