Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25800455rwd; Mon, 3 Jul 2023 00:54:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlEv9rhK9snY/76WDD6+aa6NmYPxt1gB32Wpm3MVvWHysBAYo0My8HqGLzCygmFoNRhgTs7N X-Received: by 2002:a17:90a:c918:b0:263:27f5:d447 with SMTP id v24-20020a17090ac91800b0026327f5d447mr10511098pjt.9.1688370862635; Mon, 03 Jul 2023 00:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688370862; cv=none; d=google.com; s=arc-20160816; b=NmyJTTSSlR7VkTflghSK18itV4DVJADmty6NtJ4fkpYspF35nZsDwQSLwQvwItpKBn rL2v81lvqLx0+uSGFp04SBpK9b/+zjzMrBoWgY2NMWaLVt1gcNa2eSbUPljjiX+5uSw2 N1JZUc1bcTsh063nwlhfwRanT+9m7t5lvAs4gP/ygOniEzL+JnKjv9lDR21Ms9jp0qDx MQCnTY3D2oWfRT45zdXSlTMFuw+mg1kdrN7guIQ++oAH7v7Lf1+n3ZCN0rBn5SFx9zLD wGk4P3OXKKdnIJIYDadWsfYLWhhL8ajHdUtvdbZtMZQQ9q3hTlPSVvAqtEc6mNAhajYS ozqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=k0LaDAb48FB0BYS1E8TEQR4dsp8mGlbiWW81yfDkHCw=; fh=+KcAhWSG9RzC2SvYVXgDzJ1nkcDBnTpIanTuJBxcWXo=; b=HV3rGvJqbTEbjxdqL2+q/uMeIhrjH4+qKPCIsK6h6kIXs8jmdpeOQte4QIeOKtEk68 IKXV6vcXB3aGYSlfv1J0AozzYGiJ10kEV0EQXUbNCazrwSwC36RFO9VuVlB2V64QooXj IUeqa5wjkpRs680HOFFQQDCBpx9gWHm2dGWT9w6YAM+FSjooh4enF3I5rkHSIFcRhno1 Srwq+JmXHJpa7jUqZD7XGofs/lBDOtWV8XIkzFlPuC9ReG2J7qwrpPV90lHYI9Yuj67m bJchVoD/7drTrDYOfQXAVaKtNv+Udt+77x3iRKgNMazxymmukszGdlaQvLYJFKiXUNNM +1kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=mvjiZmHg; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Ce7zMkfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 13-20020a17090a190d00b00259b2afc651si20127070pjg.62.2023.07.03.00.54.11; Mon, 03 Jul 2023 00:54:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=mvjiZmHg; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Ce7zMkfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbjGCHix (ORCPT + 99 others); Mon, 3 Jul 2023 03:38:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjGCHiw (ORCPT ); Mon, 3 Jul 2023 03:38:52 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5EEC1; Mon, 3 Jul 2023 00:38:51 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E67DC5C031A; Mon, 3 Jul 2023 03:38:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 03 Jul 2023 03:38:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1688369930; x=1688456330; bh=k0 LaDAb48FB0BYS1E8TEQR4dsp8mGlbiWW81yfDkHCw=; b=mvjiZmHgQXm5BDVBRT tgLvfIc3Oesmxeu0XNV/GKB400iYPkX2I5RS798HmwFKrXjUNw7TJqqI+dDkD2nd 66J5H0g0P/6hA/T7WoylPesE9kXAv7Hn7H5FC4jlmHNgapaMjLLvH2TVsOGoHekS TQbj7Tcbx6hpwc8Z78b/CQfxNaXgFlm6HVG8tydIZjNjCRk7LQy2yNYCkFR96ky6 ZlbcZ3ka8VhTrujZ9iZ/fhE0nDVRzOxidjE/KNmdh6O9/cmJHdr08075/xSSxeoZ W1DZVhHeJkm+mrljtRROhMc4QXGKzdKG6yCQ/nE774K1Utm/Cd4d3IB/y9nAqD2I 7dSg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1688369930; x=1688456330; bh=k0LaDAb48FB0B YS1E8TEQR4dsp8mGlbiWW81yfDkHCw=; b=Ce7zMkfPFWDqoWxf7AkyjMNWyhTYg 5VD/n97hJdQgiwzJKIUBH4wvla0QNZUF7OvzTGWqaIBYQWtFkBKp2QFysXqcfk79 vFXumi3qzx7dqDP5FhAkTl/2GLkNsW9gLYWRbmn5VL71rMyNm2iXXDl0uVy3t92X n219wTHuUSRWMCaIWMv5GlBVqjGw5MU4wtggQRylBk15ftbLc5Pn+8yhj9VC1qtu Irfdm2o6LX7rLzZfYKV6AeZmlQ7BE0TCNn+VsetUTcUMJQHRHWG1RUp3oHGKagxG LQalvVYEmR/Nhf5WnbwVkOMVsFYmpV/hkD5q0xqcGMsATdCHibTQwb5Rw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddugdduvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtsfertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeeuveduheeutdekvefgudevjeeufedvvdevhfejgfelgfdtkeevueegteek gfelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jul 2023 03:38:49 -0400 (EDT) Date: Mon, 3 Jul 2023 09:38:48 +0200 From: Maxime Ripard To: Frank Oltmanns Cc: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andre Przywara , Roman Beranek , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 6/8] clk: sunxi-ng: mux: Support finding closest rate Message-ID: References: <20230702-pll-mipi_set_rate_parent-v3-0-46dcb8aa9cbc@oltmanns.dev> <20230702-pll-mipi_set_rate_parent-v3-6-46dcb8aa9cbc@oltmanns.dev> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7wsqxsxlujfkioer" Content-Disposition: inline In-Reply-To: <20230702-pll-mipi_set_rate_parent-v3-6-46dcb8aa9cbc@oltmanns.dev> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --7wsqxsxlujfkioer Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 02, 2023 at 07:55:25PM +0200, Frank Oltmanns wrote: > When finding the best rate for a mux clock, consider rates that are > higher than the requested rate by introducing a new clk_ops structure > that uses the existing __clk_mux_determine_rate_closest function. > Furthermore introduce an initialization macro that uses this new > structure. >=20 > Signed-off-by: Frank Oltmanns > --- > drivers/clk/sunxi-ng/ccu_mux.c | 13 +++++++++++++ > drivers/clk/sunxi-ng/ccu_mux.h | 17 +++++++++++++++++ > 2 files changed, 30 insertions(+) >=20 > diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mu= x.c > index 8594d6a4addd..49a592bdeacf 100644 > --- a/drivers/clk/sunxi-ng/ccu_mux.c > +++ b/drivers/clk/sunxi-ng/ccu_mux.c > @@ -264,6 +264,19 @@ static unsigned long ccu_mux_recalc_rate(struct clk_= hw *hw, > parent_rate); > } > =20 > +const struct clk_ops ccu_mux_closest_ops =3D { > + .disable =3D ccu_mux_disable, > + .enable =3D ccu_mux_enable, > + .is_enabled =3D ccu_mux_is_enabled, > + > + .get_parent =3D ccu_mux_get_parent, > + .set_parent =3D ccu_mux_set_parent, > + > + .determine_rate =3D __clk_mux_determine_rate_closest, > + .recalc_rate =3D ccu_mux_recalc_rate, > +}; > +EXPORT_SYMBOL_NS_GPL(ccu_mux_closest_ops, SUNXI_CCU); > + This is also a bit inconsistent with the other clocks: most (all?) of them will simply handle this through a flag, but this one requires a new set of clk_ops as well? I think we should create our own wrapper here around __clk_mux_determine_rate and either call __clk_mux_determine_rate_closest or __clk_mux_determine_rate depending on the state of the flags, or call __clk_mux_determine_rate_flags with the proper flags set for our clock. The former is probably slightly simpler. > const struct clk_ops ccu_mux_ops =3D { > .disable =3D ccu_mux_disable, > .enable =3D ccu_mux_enable, > diff --git a/drivers/clk/sunxi-ng/ccu_mux.h b/drivers/clk/sunxi-ng/ccu_mu= x.h > index 2c1811a445b0..c4ee14e43719 100644 > --- a/drivers/clk/sunxi-ng/ccu_mux.h > +++ b/drivers/clk/sunxi-ng/ccu_mux.h > @@ -46,6 +46,22 @@ struct ccu_mux { > struct ccu_common common; > }; > =20 > +#define SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(_struct, _name, _parents, = _table, \ > + _reg, _shift, _width, _gate, \ > + _flags) \ > + struct ccu_mux _struct =3D { \ > + .enable =3D _gate, \ > + .mux =3D _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \ > + .common =3D { \ > + .reg =3D _reg, \ > + .hw.init =3D CLK_HW_INIT_PARENTS(_name, \ > + _parents, \ > + &ccu_mux_closest_ops, \ > + _flags), \ > + .features =3D CCU_FEATURE_CLOSEST_RATE, \ > + } \ > + } > + I'm fine with that one, but like we discussed on the NM (I think?) patch already, this creates some clocks and macros that will use the feature as a flag, and some will encode it into their name. Given that we need it here too, I'm really inclined to prefer what you did there, and thus create a new macro for pll-video0 instead of modifying the existing one. Maxime --7wsqxsxlujfkioer Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZKJ7CAAKCRDj7w1vZxhR xX23AP9Gl3oPNcojRTw1oRa+afqZNM7B+cSe67xYnUYlA4vjVgD9GkW8rquZxUuO 0FrevYyTHNypFJAxk4AUScA3gapkoQQ= =hog7 -----END PGP SIGNATURE----- --7wsqxsxlujfkioer--