Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2277015rdb; Wed, 21 Feb 2024 02:39:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVi6rwk1KRhHMrvQxTce2/OPRiW5vIHnbtd8n4XObUGr9OcNxFka8gvJSL0occsVu0qcm4jg4FXsGARkXlu3qDi/09gEGIRd1/ZDVtDgw== X-Google-Smtp-Source: AGHT+IEfePNSFgcxxHN9QfcttqfDnKshBKqPsbOOMaFmzb7xvHeDz+fWCaDHYrhfMfemVNNl8B5K X-Received: by 2002:a25:ab2f:0:b0:dcc:aa1f:b418 with SMTP id u44-20020a25ab2f000000b00dccaa1fb418mr18004236ybi.1.1708511979840; Wed, 21 Feb 2024 02:39:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708511979; cv=pass; d=google.com; s=arc-20160816; b=tHDfD0tVeaiqm4rxmjfgFCqMvU6lDxCB8D3RXjIfi84RqACw6LJ5yOn/+F81CbWPiW qF52Tc5y43Xs1DHCn7fsP4etF3EbDIMQ8/KrCrWTvvtJ1H/pnfuY0tCETroWgcodNKjN BTlK44eg6ML69APjVe2RkZZ95MFYDpaXoIkchC8ZaaGqj3NtFZ0PsV77GDPR2LGZIXBx vzCsEz4ARWmK+Zeragj4/GqJVeoA3RUhUiDL0CO6hg+cY4yyk+1OKblzSE4ewr89DHJi Yjut6OfgCDjF1OtcuQswW21R8IcRoP5SeoRf/iDpPiO+HG6YevF/hQcidRUdEKNna/5K bXww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:in-reply-to:subject:cc:to:from:references :dkim-signature; bh=VOqX0GOQZZOiGD9BoiPl4P99i5/2V8G3vmiVhpwmjpo=; fh=mjPxLECgmOdrWEfK3KyOC6DpnsdJhLyuB+921lVBm2Q=; b=kxHbKRx3j1PdKdNX+oMlPrA8NnE+d0sWyw46z8LUSJGZV8qAxW14z5GLMAH8TCUzPe fklOAfH+wNIGtnb+eUa3KyeciAFCzvY+NMMRuCqDVw+0okEdUi1j/0SYCiAIToNfJHgx /NhTJl03tRpqZQcOU/BA6BJ1XKMhQfYTWfbm+Ubty+VzSTrPsjpMngzAPckhD+ms0NLm 01bYF1KiZWFgol5D8TZbYpHTVnMsfvkbsthW4/TjHtDz4uKkc6YWfVDqz3AqnM1des2k R6Xd7wkB9OMq6KtG8q3/oWOVVl8tXzCurZqwEVVsbCvOOoDv16Y1P0rfJ7vVi4/2mN3U PP+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oltmanns.dev header.s=MBO0001 header.b=NVUrtqwk; arc=pass (i=1 spf=pass spfdomain=oltmanns.dev dkim=pass dkdomain=oltmanns.dev dmarc=pass fromdomain=oltmanns.dev); spf=pass (google.com: domain of linux-kernel+bounces-74548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oltmanns.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c5-20020a056a00008500b006e0f438e98fsi7920139pfj.208.2024.02.21.02.39.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 02:39:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oltmanns.dev header.s=MBO0001 header.b=NVUrtqwk; arc=pass (i=1 spf=pass spfdomain=oltmanns.dev dkim=pass dkdomain=oltmanns.dev dmarc=pass fromdomain=oltmanns.dev); spf=pass (google.com: domain of linux-kernel+bounces-74548-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oltmanns.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 864C4282296 for ; Wed, 21 Feb 2024 10:39:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 823073D3A1; Wed, 21 Feb 2024 10:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oltmanns.dev header.i=@oltmanns.dev header.b="NVUrtqwk" Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81C533EA89; Wed, 21 Feb 2024 10:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708511944; cv=none; b=btukBm1I69ugESYaI8ulyj+rYYohEc0baGJxy5LuyoME8GpRqbtkuiVczmGrgxmWEs6GhotO/zmK6Rg2jZlIJoG+wD2gFCFYz/VTbCXvZ1KXCyHOAJO0HKRAPiE0Jcp8i9qtcATBNECd1ue+jaem29pUB8aACh1LO/Exlv0+pbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708511944; c=relaxed/simple; bh=3T2LRJtiW3mZfk/PunFIogOMmmkLZ7ysF+8gTpzPau4=; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID: MIME-Version:Content-Type; b=MX3HsSVlcOCgZIdiWlVw02fCfHwRFcQS7USH4BbbFzXwzq9xLmNtpBI4AHS824CMdH44eOQEG2bakBfL9AlD1NeBaTZ408pe2AqFNlxphuaU5Ygm3J9v/yHnRIxJ4h6JWcbXX4yoWCviyrdW2CRqB6/zI9N56GV2uHObueNU1uY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oltmanns.dev; spf=pass smtp.mailfrom=oltmanns.dev; dkim=pass (2048-bit key) header.d=oltmanns.dev header.i=@oltmanns.dev header.b=NVUrtqwk; arc=none smtp.client-ip=80.241.56.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oltmanns.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oltmanns.dev Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Tft6g64Lkz9tln; Wed, 21 Feb 2024 11:38:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1708511931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VOqX0GOQZZOiGD9BoiPl4P99i5/2V8G3vmiVhpwmjpo=; b=NVUrtqwknw/O3TZyiGfvfpG0IBx7JJpeIshlUGI/ALrW+famIowinN8F9Ti3bU4Kb+DskP y775xaFPKAqf07Z9jufvCZ/AuUTAM4pXCgmXlgUugQZxZI4mmfx/4UJIb3CWj7JIytAhQg l3cMMRBSKwmkaUjCkZVPwc9QSZ0W96DsujRbPvrZTUclXWsJ2NVejTPx9Ud7DDCgLM69Gb 4oAYCyVx0a/ZfDI7wBynT1H/fvIHe24aB5hJFSRro6uKd6bhUTPnwEiiZrZqz68LsxqWry p64VobbPssd93ohFph+mesCr7BNyXCE5h4LrsNcuswhXvQdIQyv57qnfdnQpWw== References: <20240205-pinephone-pll-fixes-v2-0-96a46a2d8c9b@oltmanns.dev> <20240205-pinephone-pll-fixes-v2-3-96a46a2d8c9b@oltmanns.dev> From: Frank Oltmanns To: Jernej Skrabec , Maxime Ripard , Diego Roversi Cc: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Samuel Holland , Guido =?utf-8?Q?G=C3=BCnther?= , Purism Kernel Team , Ondrej Jirman , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Subject: Re: [PATCH v2 3/6] clk: sunxi-ng: nkm: Support minimum and maximum rate In-reply-to: <20240205-pinephone-pll-fixes-v2-3-96a46a2d8c9b@oltmanns.dev> Date: Wed, 21 Feb 2024 11:38:39 +0100 Message-ID: <8734tmhzkg.fsf@oltmanns.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4Tft6g64Lkz9tln Hi Jernej, hi Maxime, On 2024-02-05 at 16:22:26 +0100, Frank Oltmanns wrote: > According to the Allwinner User Manual, the Allwinner A64 requires > PLL-MIPI to run at 500MHz-1.4GHz. Add support for that to ccu_nkm. I should point out that limiting PLL-MIPI also fixes a regression that was introduced in 6.5, specifically ca1170b69968233b34d26432245eddf7d265186b "clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux". This has been bisected and reported by Diego [1]. I don't know the procedure (yet), but probably the fix (if and when accepted) should be backported at least to 6.6 (first broken LTS), 6.7 (stable), and 6.8 (next stable). My suggestion: - In V3 of this series, I will reorder the patches, so that what is now PATCH 3 and 4 becomes 1 and 2 respectively, so that they can be applied to 6.6 more easily. - Maxime, IIUC you requested some refactoring for handling the rate limits [2]. I propose, we use my current proposal as-is, and I will do a follow-up series for the refactoring. Please let me know how you would like me to proceed. Thanks, Frank [1]: https://groups.google.com/g/linux-sunxi/c/Rh-Uqqa66bw [2]: https://lore.kernel.org/all/exb2lvjcozak5fayrgyenrd3ntii4jfxgvqork4klyz5pky2aq@dj2zyw5su6pv/ > > Signed-off-by: Frank Oltmanns > --- > drivers/clk/sunxi-ng/ccu_nkm.c | 13 +++++++++++++ > drivers/clk/sunxi-ng/ccu_nkm.h | 2 ++ > 2 files changed, 15 insertions(+) > > diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c > index 1168d894d636..7d135908d6e0 100644 > --- a/drivers/clk/sunxi-ng/ccu_nkm.c > +++ b/drivers/clk/sunxi-ng/ccu_nkm.c > @@ -181,6 +181,12 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, > if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) > rate *= nkm->fixed_post_div; > > + if (nkm->min_rate && rate < nkm->min_rate) > + rate = nkm->min_rate; > + > + if (nkm->max_rate && rate > nkm->max_rate) > + rate = nkm->max_rate; > + > if (!clk_hw_can_set_rate_parent(&nkm->common.hw)) > rate = ccu_nkm_find_best(*parent_rate, rate, &_nkm, &nkm->common); > else > @@ -220,6 +226,13 @@ static int ccu_nkm_set_rate(struct clk_hw *hw, unsigned long rate, > _nkm.min_m = 1; > _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width; > > + > + if (nkm->min_rate && rate < nkm->min_rate) > + rate = nkm->min_rate; > + > + if (nkm->max_rate && rate > nkm->max_rate) > + rate = nkm->max_rate; > + > ccu_nkm_find_best(parent_rate, rate, &_nkm, &nkm->common); > > spin_lock_irqsave(nkm->common.lock, flags); > diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h > index c409212ee40e..358a9df6b6a0 100644 > --- a/drivers/clk/sunxi-ng/ccu_nkm.h > +++ b/drivers/clk/sunxi-ng/ccu_nkm.h > @@ -27,6 +27,8 @@ struct ccu_nkm { > struct ccu_mux_internal mux; > > unsigned int fixed_post_div; > + unsigned long min_rate; > + unsigned long max_rate; > unsigned long max_m_n_ratio; > unsigned long min_parent_m_ratio;