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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4360C41535 for ; Tue, 19 Dec 2023 16:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GCNVAbbGqW6f7e44Rkl1sGFqnTQsISEuir7xXFAIii0=; b=yD3zIP9HmT1xW3 h4CQquvqY5QeBsnz3F8FCSKn3Kt2ilM7ICNztnjSS/dXFIxkiwqt/vczPASBOEK1mIfyfv4uModtH Htp8VDDU3j87ZByI+RAxC5kM0o2zUy+l3wp75cg1JsupJwPBJ4lynEMg+250Qc4Bd1gJl9k9ubUHh br/UjAhSdiDhEDsgDs3A5xjxH8DH8+Aw2yGue6ElyL3RPxxGJ8Az3iQqGtbQ3vznb/22W9+lEWiYi 9UsevOPpAmXoToLQSeeQfvEdUzvVnUGsNfdncAWbFwUnCmoHpaIWqT/qqOyvf1k9O5oNUSym5PxxC LSPm0cCynMYs7kJoHi+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFdKp-00EmFS-0F; Tue, 19 Dec 2023 16:52:47 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFdKm-00EmEw-2G for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 16:52:46 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a236d77dceeso216643166b.2 for ; Tue, 19 Dec 2023 08:52:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703004763; x=1703609563; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uxC6S8Df4SvnkAXMbWUKpOTSQ1v3y3ScMeHuaO257hA=; b=D4YLDh+oBMPuP3sTR0/KRHVOP9njTGd7k3SEgWsIByf1RH61FpelvRHFKPqn2AldlG pRYirDF0JbkXB9jBC1XWtF5jM9zAPm+icD3mnXHUkUsP6ZftFxojJ7/Ii19inQBIyKhZ 4H3IqzZW6N5Chs9bg7cEiPsJhXmGXf9cNl+bZ3Rx/MxuQiEwWnhdvhbVtHQF7vDitEGV sb6YhoUn4+VexIpxiPO4sRuxc4z7/cBxiaDG6JS2PWwbGaP8XShmFu8spwAGer5gT6IV rujs4JlgXRAXWTyOdbxDX0HmRox8xTUMxI2DsQYe1Q9FiZKq4nzgE7KmJbBRZI3FBWpy 6z9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703004763; x=1703609563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uxC6S8Df4SvnkAXMbWUKpOTSQ1v3y3ScMeHuaO257hA=; b=bd3jLQsQWsq7lN8QPbGvXwGHWzMliiUsb46jjhgdQg9459uD3xR5CiqabCD2I5MTFe 90mLb+XmC9YzR1MqE+rgur8lU4Jqr3gkKp12cFbg7sZRcDsuUNgfnDyzywr/j9uv2//x +0g5ZD1YT7LNkQ6AK8QMe0UMe++M4o9Dk0aStef8eRBsyvksUQm+xoF01oBIb8pJXdZ4 0mcRMpYZqbh72e0Ds1mm8XsCdTu9l8AzYOKypWfoM0oGPu0qNjn5zAobM5RE2qIRsbE3 cxjrXeUpXJylyFzD4KPAW9dr+jPfbnUS+mAaL185ic1ub9Qw0B7h5x0v5Env2eZCm/2W TGpw== X-Gm-Message-State: AOJu0Yy7ZdLFJM2mJTJENajkVSA5bXhu1lTfUsVRwhGJhGz3fSdYDQ8k HYxowU4/wgDleIgsoFpiXEY= X-Google-Smtp-Source: AGHT+IGAGwRqdPR1+1UIH4G19Rxphe2JUwS3RizzhgFClQPqT3fjslJQZ2yevwgtTAN2fDlpbvd1Wg== X-Received: by 2002:a17:906:e011:b0:a23:350a:2d02 with SMTP id cu17-20020a170906e01100b00a23350a2d02mr1742458ejb.104.1703004762981; Tue, 19 Dec 2023 08:52:42 -0800 (PST) Received: from jernej-laptop.localnet (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id lm11-20020a17090718cb00b00a1db76f99c8sm15833180ejc.93.2023.12.19.08.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:52:41 -0800 (PST) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Samuel Holland , Guido =?ISO-8859-1?Q?G=FCnther?= , Purism Kernel Team , Ondrej Jirman , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Frank Oltmanns Cc: 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, Frank Oltmanns Subject: Re: [PATCH 3/5] clk: sunxi-ng: nm: Support constraints on n/m ratio and parent rate Date: Tue, 19 Dec 2023 17:52:40 +0100 Message-ID: <1871631.tdWV9SEqCh@jernej-laptop> In-Reply-To: <20231218-pinephone-pll-fixes-v1-3-e238b6ed6dc1@oltmanns.dev> References: <20231218-pinephone-pll-fixes-v1-0-e238b6ed6dc1@oltmanns.dev> <20231218-pinephone-pll-fixes-v1-3-e238b6ed6dc1@oltmanns.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_085244_740965_5B5034FE X-CRM114-Status: GOOD ( 21.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dne ponedeljek, 18. december 2023 ob 14:35:21 CET je Frank Oltmanns napisal(a): > The Allwinner A64 manual lists the following constraint for the > PLL-VIDEO0 clock: 8 <= N/M <= 25 > > The PLL-MIPI clock is implemented as ccu_nm. Therefore, add support for > this constraint. > > Signed-off-by: Frank Oltmanns > --- > drivers/clk/sunxi-ng/ccu_nm.c | 21 +++++++++++++++++++-- > drivers/clk/sunxi-ng/ccu_nm.h | 34 ++++++++++++++++++++++++++++++++-- > 2 files changed, 51 insertions(+), 4 deletions(-) > > diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c > index ffac3deb89d6..cfc6981e398b 100644 > --- a/drivers/clk/sunxi-ng/ccu_nm.c > +++ b/drivers/clk/sunxi-ng/ccu_nm.c > @@ -27,6 +27,19 @@ static unsigned long ccu_nm_calc_rate(unsigned long parent, > return rate; > } > > +static bool ccu_nm_is_valid_rate(struct ccu_common *common, unsigned long n, unsigned long m) > +{ > + struct ccu_nm *nm = container_of(common, struct ccu_nm, common); > + > + if (nm->max_nm_ratio && (n > nm->max_nm_ratio * m)) > + return false; > + > + if (nm->min_nm_ratio && (n < nm->min_nm_ratio * m)) > + return false; > + > + return true; > +} > + > static unsigned long ccu_nm_find_best(struct ccu_common *common, unsigned long parent, > unsigned long rate, struct _ccu_nm *nm) > { > @@ -36,8 +49,12 @@ static unsigned long ccu_nm_find_best(struct ccu_common *common, unsigned long p > > for (_n = nm->min_n; _n <= nm->max_n; _n++) { > for (_m = nm->min_m; _m <= nm->max_m; _m++) { > - unsigned long tmp_rate = ccu_nm_calc_rate(parent, > - _n, _m); > + unsigned long tmp_rate; > + > + if (!ccu_nm_is_valid_rate(common, _n, _m)) > + continue; > + > + tmp_rate = ccu_nm_calc_rate(parent, _n, _m); > > if (ccu_is_better_rate(common, rate, tmp_rate, best_rate)) { > best_rate = tmp_rate; > diff --git a/drivers/clk/sunxi-ng/ccu_nm.h b/drivers/clk/sunxi-ng/ccu_nm.h > index 93c11693574f..0075df6d9697 100644 > --- a/drivers/clk/sunxi-ng/ccu_nm.h > +++ b/drivers/clk/sunxi-ng/ccu_nm.h > @@ -31,6 +31,8 @@ struct ccu_nm { > unsigned int fixed_post_div; > unsigned int min_rate; > unsigned int max_rate; > + unsigned long min_nm_ratio; /* minimum value for m/n */ > + unsigned long max_nm_ratio; /* maximum value for m/n */ Comment is wrong, it should be "n/m". For consistency with nkm patch, min_n_m_ratio and max_n_m_ratio. Best regards, Jernej > > struct ccu_common common; > }; > @@ -108,7 +110,8 @@ struct ccu_nm { > }, \ > } > > -#define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX_FEAT(_struct, _name, \ > +#define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX_FEAT_NM_RATIO( \ > + _struct, _name, \ > _parent, _reg, \ > _min_rate, _max_rate, \ > _nshift, _nwidth, \ > @@ -117,7 +120,9 @@ struct ccu_nm { > _frac_rate_0, \ > _frac_rate_1, \ > _gate, _lock, _flags, \ > - _features) \ > + _features, \ > + _min_nm_ratio, \ > + _max_nm_ratio) \ > struct ccu_nm _struct = { \ > .enable = _gate, \ > .lock = _lock, \ > @@ -128,6 +133,8 @@ struct ccu_nm { > _frac_rate_1), \ > .min_rate = _min_rate, \ > .max_rate = _max_rate, \ > + .min_nm_ratio = _min_nm_ratio, \ > + .max_nm_ratio = _max_nm_ratio, \ > .common = { \ > .reg = _reg, \ > .features = _features, \ > @@ -138,6 +145,29 @@ struct ccu_nm { > }, \ > } > > +#define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX_FEAT(_struct, _name, \ > + _parent, _reg, \ > + _min_rate, _max_rate, \ > + _nshift, _nwidth, \ > + _mshift, _mwidth, \ > + _frac_en, _frac_sel, \ > + _frac_rate_0, \ > + _frac_rate_1, \ > + _gate, _lock, _flags, \ > + _features) \ > + SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX_FEAT_NM_RATIO( \ > + _struct, _name, \ > + _parent, _reg, \ > + _min_rate, _max_rate, \ > + _nshift, _nwidth, \ > + _mshift, _mwidth, \ > + _frac_en, _frac_sel, \ > + _frac_rate_0, \ > + _frac_rate_1, \ > + _gate, _lock, _flags, \ > + _features, \ > + 0, 0) > + > #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(_struct, _name, \ > _parent, _reg, \ > _min_rate, _max_rate, \ > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel