Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp297346pxb; Tue, 9 Feb 2021 00:03:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvuZ7axXW1PufoQOaf7H0djTBQ6UiCskEA5Qugx3llVex9n3qNGrQO3IMUJ+5bt8ohC3dS X-Received: by 2002:a50:b742:: with SMTP id g60mr21161231ede.113.1612857783798; Tue, 09 Feb 2021 00:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612857783; cv=none; d=google.com; s=arc-20160816; b=XgsNbpXME3h6WgnmspQAXkQu/bMES2yTm2e8bIkuGd9Fgo7wko9Ep5Yxe0YiGvz5+G P2oFvchGoCE8lnZkC7K2BlS9IMIxAHBpciICeZ0Dj58goFZPvmE1Zdeomuon2w2vGFo0 dX/qkxkDP9zo6/aIFNLewqgWK9/7jg+T9rZWQvBPtrhjBdW1N4eUfIOs1De2OCGuFGar 35HObWgEdaNncfIG3fFLheCblBLA4XOMani+5SejFbvaGnD3YCM4fsJw8F/U9NAlJFsF gIe/hwcfruw4r7rYI10uNbwx7pGMUlQ0oW174n9380+w0uFg7k6C95ltr8QDcADFoSxQ QWWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=4DK6DvdN2QBGl7c4mgkiCyw+ooEr1vsifKpckrNK0QY=; b=m86NJ/FnRKCdbPl1Tdiffcuo3Ue/n9MqcH0kTHAV7N2Zud0XZ7HiuwvOSDF44A9TaQ 06y/LcXw2xX2aUYduZ9d5JVrh1GGYF/4mtaaolNJzUJFlQ0fHCH3AgGKO1a6BYJWegOG q37rtPetVc/P1kYO/2900nbQ9Vo2AOswN1+oanJEHun5Qu9ckvtKbAKo+86m2/n7P3XM jA0EbTlEnkXeDDxAtZUot86u8hm9szaVbIbmLeHfMZmllxY6/QwV7ww99OHLzW3vzwaD ESYLmX74c1SpyCS39oIdo+RSkDF+NsEbSVzzlchFy03TJyoL7cTOi73ypLLGkhcZMTB6 r6zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RZfSdW4M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j21si11723070ejn.713.2021.02.09.00.02.36; Tue, 09 Feb 2021 00:03:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RZfSdW4M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbhBIIB0 (ORCPT + 99 others); Tue, 9 Feb 2021 03:01:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:39216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbhBIIBX (ORCPT ); Tue, 9 Feb 2021 03:01:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27CCC64E6F; Tue, 9 Feb 2021 08:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612857642; bh=PrZKwTBAEkhO9oVwFzz9vR4RpjecGA222H6u+Smz3/g=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=RZfSdW4MONU6xyHZcAlXF3UuyrNKwqpNx49sUuIUYtO86OB+31RzMa1O7dF6M8YBN S9MNPiFRGvoUA8A7uoT3UZCXdmXkFdNWGQbJ+sjvPOwuF+KFSBJW6x2gxRNadUf4bP TGupFGxUhX0KPEaei1olRQFWoplvhuVhF2qYSql41c20wThIpVrLDHHKFENyYOEJl2 h6MSfwndGoBOY8w349HyrpUO+EjDiPP8L/NShDsheNvOfjRpZ9QV9QdZU2yJWTiPRZ i9t4psH+djtVZrQpkwSgDJim/iW8woBnt+ZvJELngCF1WqDRt/z1M9KYOY8Du/SNoX y0os1dyaKr6Yg== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20210126090120.19900-3-gabriel.fernandez@foss.st.com> References: <20210126090120.19900-1-gabriel.fernandez@foss.st.com> <20210126090120.19900-3-gabriel.fernandez@foss.st.com> Subject: Re: [PATCH v2 02/14] clk: stm32mp1: merge 'ck_hse_rtc' and 'ck_rtc' into one clock From: Stephen Boyd Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org To: Alexandre Torgue , Etienne Carriere , Gabriel Fernandez , Maxime Coquelin , Michael Turquette , Philipp Zabel , Rob Herring , marex@denx.de Date: Tue, 09 Feb 2021 00:00:40 -0800 Message-ID: <161285764074.418021.15522379930579131077@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting gabriel.fernandez@foss.st.com (2021-01-26 01:01:08) > From: Gabriel Fernandez >=20 > 'ck_rtc' has multiple clocks as input (ck_hsi, ck_lsi, and ck_hse). > A divider is available only on the specific rtc input for ck_hse. > This Merge will facilitate to have a more coherent clock tree > in no trusted / trusted world. >=20 > Signed-off-by: Gabriel Fernandez > --- > drivers/clk/clk-stm32mp1.c | 49 +++++++++++++++++++++++++++++++++----- > 1 file changed, 43 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c > index 35d5aee8f9b0..0e1d4427a8df 100644 > --- a/drivers/clk/clk-stm32mp1.c > +++ b/drivers/clk/clk-stm32mp1.c > @@ -245,7 +245,7 @@ static const char * const dsi_src[] =3D { > }; > =20 > static const char * const rtc_src[] =3D { > - "off", "ck_lse", "ck_lsi", "ck_hse_rtc" > + "off", "ck_lse", "ck_lsi", "ck_hse" > }; > =20 > static const char * const mco1_src[] =3D { > @@ -1031,6 +1031,42 @@ static struct clk_hw *clk_register_cktim(struct de= vice *dev, const char *name, > return hw; > } > =20 > +/* The divider of RTC clock concerns only ck_hse clock */ > +#define HSE_RTC 3 > + > +static unsigned long clk_divider_rtc_recalc_rate(struct clk_hw *hw, > + unsigned long parent_rat= e) > +{ > + if (clk_hw_get_parent(hw) =3D=3D clk_hw_get_parent_by_index(hw, H= SE_RTC)) > + return clk_divider_ops.recalc_rate(hw, parent_rate); > + > + return parent_rate; > +} > + > +static long clk_divider_rtc_round_rate(struct clk_hw *hw, unsigned long = rate, > + unsigned long *prate) > +{ > + if (clk_hw_get_parent(hw) =3D=3D clk_hw_get_parent_by_index(hw, H= SE_RTC)) This clk op can be called at basically any time. Maybe this should use the determine rate op and then look to see what the parent is that comes in via the rate request structure? Or is the intention to keep this pinned to one particular parent? Looking at this right now it doesn't really make much sense why the current parent state should play into what rate the clk can round to, unless there is some more clk flags going on that constrain the ability to change this clk's parent. > + return clk_divider_ops.round_rate(hw, rate, prate); > + > + return *prate; > +} > + > +static int clk_divider_rtc_set_rate(struct clk_hw *hw, unsigned long rat= e, > + unsigned long parent_rate) > +{ > + if (clk_hw_get_parent(hw) =3D=3D clk_hw_get_parent_by_index(hw, H= SE_RTC)) > + return clk_divider_ops.set_rate(hw, rate, parent_rate); > + > + return parent_rate; > +} > +